12 #ifndef IMPKINEMATICS_KINEMATIC_FOREST_H
13 #define IMPKINEMATICS_KINEMATIC_FOREST_H
15 #include "kinematics_config.h"
31 IMPKINEMATICS_BEGIN_NAMESPACE
86 void add_edge(
Joint* joint);
95 for(
int i = 0 ; i < (int)rbs.size() - 1; i++){
96 add_edge( rbs[i], rbs[i+1] );
107 void update_all_internal_coordinates(){
108 IMP_LOG(
VERBOSE,
"updating internal coords needed?" << std::endl);
109 if(is_internal_coords_updated_){
112 IMP_LOG(
VERBOSE,
"updating!" << std::endl);
113 for(
unsigned int i = 0; i < joints_.size(); i++){
114 joints_[i]->update_joint_from_cartesian_witnesses();
116 is_internal_coords_updated_ =
true;
119 void update_all_external_coordinates(){
120 if(is_external_coords_updated_){
124 std::queue<KinematicNode> q;
126 for(it = roots_.begin(); it != roots_.end(); it++){
130 KinematicNode n = q.front();
133 for(
unsigned int i = 0; i < out_joints.size(); i++){
134 Joint* joint_i = out_joints[i];
136 joint_i->update_child_node_reference_frame();
137 q.push( KinematicNode(joint_i->get_child_node() ) );
140 is_external_coords_updated_ =
true;
144 Joints get_ordered_joints()
const {
147 std::queue<KinematicNode> q;
149 for(it = roots_.begin(); it != roots_.end(); it++) q.push(*it);
152 KinematicNode n = q.front();
154 if(n.get_in_joint() !=
nullptr) ret.push_back(n.get_in_joint());
157 for(
unsigned int i = 0; i < out_joints.size(); i++) {
158 Joint* joint_i = out_joints[i];
159 q.push(KinematicNode(joint_i->get_child_node()));
171 is_external_coords_updated_ =
false;
180 is_internal_coords_updated_ =
false;
191 void set_coordinates_safe
194 "A KinematicForest can only handle particles "
195 <<
" that were perviously added to it" );
197 mark_external_coordinates_changed();
205 "A KinematicForest can only handle particles "
206 <<
" that were perviously added to it" );
208 return rb.get_coordinates();
216 KinematicNode::get_is_setup( p ) &&
217 nodes_.find( KinematicNode( p ) ) != nodes_.end() ;
227 "A KinematicForest can only handle particles "
228 <<
" that were perviously added to it" );
229 const_cast<KinematicForest*
>(
this)->update_all_external_coordinates();
241 void set_reference_frame_safe
244 "A KinematicForest can only handle particles "
245 <<
" that were perviously added to it" );
247 mark_external_coordinates_changed();
258 friend std::ostream& operator<<(std::ostream& s,
265 bool is_internal_coords_updated_;
266 bool is_external_coords_updated_;
282 IMPKINEMATICS_END_NAMESPACE
Import IMP/kernel/Decorator.h in the namespace.
void mark_external_coordinates_changed()
#define IMP_NOT_IMPLEMENTED
Use this to make that the method is not implemented yet.
IMP::base::Vector< IMP::base::WeakPointer< Joint > > JointsTemp
Particle * get_particle() const
void mark_internal_coordinates_changed()
#define IMP_UNUSED(variable)
#define IMP_NEW(Typename, varname, args)
Declare a ref counted pointer to a new object.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Decorator for helping deal with a hierarchy of molecules.
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.
void set_coordinates(const algebra::Vector3D &v)
set all coordinates from a vector
Various general useful macros for IMP.
functionality for defining nodes on a kinematic chain
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Class to handle individual model particles.
IMP::base::Vector< IMP::base::Pointer< Joint > > Joints
Storage of a model, its restraints, constraints and particles.
Common base class for heavy weight IMP objects.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Exception definitions and assertions.
Joint * add_edge(IMP::core::RigidBody parent, IMP::core::RigidBody child)
Exception definitions and assertions.
A shared base class to help in debugging and things.
A decorator for a rigid body.
Declare an efficient stl-compatible set.
Class for storing model, its restraints, constraints, and particles.
IMP::algebra::ReferenceFrame3D get_reference_frame() const
Get the reference frame for the local coordinates.