9 #ifndef IMPKINEMATICS_KINEMATIC_FOREST_H
10 #define IMPKINEMATICS_KINEMATIC_FOREST_H
12 #include "kinematics_config.h"
19 #include <boost/unordered_set.hpp>
28 IMPKINEMATICS_BEGIN_NAMESPACE
80 void add_edge(
Joint* joint);
90 for (
int i = 0; i < (int)rbs.size() - 1; i++) {
91 add_edge(rbs[i], rbs[i + 1]);
105 IMP_LOG(
VERBOSE,
"updating internal coords needed?" << std::endl);
106 if (is_internal_coords_updated_) {
109 IMP_LOG(
VERBOSE,
"updating!" << std::endl);
110 for (
unsigned int i = 0; i < joints_.size(); i++) {
111 joints_[i]->update_joint_from_cartesian_witnesses();
113 is_internal_coords_updated_ =
true;
119 if (is_external_coords_updated_) {
123 std::queue<KinematicNode> q;
124 boost::unordered_set<KinematicNode>::iterator it;
125 for (it = roots_.begin(); it != roots_.end(); it++) {
132 for (
unsigned int i = 0; i < out_joints.size(); i++) {
133 Joint* joint_i = out_joints[i];
139 is_external_coords_updated_ =
true;
146 std::queue<KinematicNode> q;
147 boost::unordered_set<KinematicNode>::iterator it;
148 for (it = roots_.begin(); it != roots_.end(); it++) q.push(*it);
153 if (n.get_in_joint() !=
nullptr) ret.push_back(n.get_in_joint());
156 for (
unsigned int i = 0; i < out_joints.size(); i++) {
157 Joint* joint_i = out_joints[i];
170 is_external_coords_updated_ =
false;
179 is_internal_coords_updated_ =
false;
192 "A KinematicForest can only handle particles "
193 <<
" that were previously added to it");
195 mark_external_coordinates_changed();
202 "A KinematicForest can only handle particles "
203 <<
" that were previously added to it");
205 return rb.get_coordinates();
212 return KinematicNode::get_is_setup(p) &&
213 nodes_.find(KinematicNode(p)) != nodes_.end();
223 "A KinematicForest can only handle particles "
224 <<
" that were previously added to it");
225 const_cast<KinematicForest*
>(
this)->update_all_external_coordinates();
241 "A KinematicForest can only handle particles "
242 <<
" that were previously added to it");
244 mark_external_coordinates_changed();
259 mark_internal_coordinates_changed();
271 friend std::ostream& operator<<(std::ostream& s,
const KinematicForest& kt);
277 bool is_internal_coords_updated_;
278 bool is_external_coords_updated_;
282 boost::unordered_set<KinematicNode> roots_;
285 boost::unordered_set<KinematicNode> nodes_;
292 IMPKINEMATICS_END_NAMESPACE
void update_all_external_coordinates()
The base class for decorators.
void mark_external_coordinates_changed()
void mark_internal_coordinates_changed()
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Storage of a model, its restraints, constraints and particles.
void update_all_internal_coordinates()
Exception definitions and assertions.
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
void reset_root(IMP::Particle *new_root)
rebuild tree (same topology but change directionality)
Class for storing model, its restraints, constraints, and particles.
Decorator for helping deal with a hierarchy of molecules.
void set_reference_frame_safe(IMP::core::RigidBody rb, IMP::algebra::ReferenceFrame3D r)
void add_rigid_bodies_in_chain(IMP::core::RigidBodies rbs)
functionality for defining a kinematic joint between rigid bodies as part of a kinematic tree ...
The standard decorator for manipulating molecular structures.
void set_reference_frame(const IMP::algebra::ReferenceFrame3D &tr)
Set the current reference frame.
Common base class for heavy weight IMP objects.
Various general useful macros for IMP.
#define IMP_UNUSED(variable)
void set_coordinates(const algebra::Vector3D &v)
set all coordinates from a vector
void set_coordinates_safe(IMP::core::RigidBody rb, IMP::algebra::Vector3D c)
functionality for defining nodes on a kinematic chain
virtual void update_child_node_reference_frame() const
Particle * get_particle() const
Returns the particle decorated by this decorator.
Joints get_ordered_joints() const
return joints sorted by BFS traversal
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
A rigid body that is connected by a joint to other rigid bodies.
Joint * add_edge(IMP::core::RigidBody parent, IMP::core::RigidBody child)
Exception definitions and assertions.
Base class for joints between rigid bodies in a kinematic tree.
A shared base class to help in debugging and things.
Class to handle individual particles of a Model object.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
void transform(RigidBody a, const algebra::Transformation3D &tr)
Transform a rigid body.
#define IMP_NOT_IMPLEMENTED
Use this to mark that the method is not implemented yet.
void apply_transform_safely(IMP::algebra::Transformation3D tr)
apply a rigid body transformation to the entire forest safely
A decorator for a rigid body.
Define and manipulate a kinematic structure over a model.
IMP::algebra::ReferenceFrame3D get_reference_frame() const