IMP  2.1.1
The Integrative Modeling Platform
CompositeJoint.h
Go to the documentation of this file.
1 /**
2  * \file CompositeJoint.h
3  * \brief a joint composed of several joints, applied on the same
4  * pair of rigid bodies
5  * \authors Dina Schneidman, Barak Raveh
6  *
7 
8  * Copyright 2007-2012 IMP Inventors. All rights reserved.
9  */
10 
11 #ifndef IMPKINEMATICS_COMPOSITE_JOINT_H
12 #define IMPKINEMATICS_COMPOSITE_JOINT_H
13 
14 #include "kinematics_config.h"
16 #include <IMP/kinematics/Joint.h>
17 #include <IMP/base/Object.h>
18 //#include <IMP/compatibility/nullptr.h>
19 #include <IMP/base/exception.h>
20 #include <IMP/core/internal/dihedral_helpers.h>
21 #include <IMP/algebra/Vector3D.h>
22 #include <IMP/base/check_macros.h>
23 
24 IMPKINEMATICS_BEGIN_NAMESPACE
25 
26 class KinematicForest;
27 
28 /********************** CompositeJoint ***************/
29 
30 /**
31  A joint that combines several inner joints, acting on the same
32  pair of rigid bodies
33 */
34 class IMPKINEMATICSEXPORT CompositeJoint : public Joint
35 {
36  public:
37  /**
38  Constructs a composite joint between parent and child,
39  with the specified list of inner joints connecting them.
40 
41  @param parent rigid body upstream of this joint
42  @param child rigid body downstream of this joint
43  @param[in] joints The list of inner joints connecting the two
44  rigid bodies. These will be applied by their
45  specified order in the list, from the parent
46  rigid body to the child rigid body. It is
47  assumed all these joints share the same
48  parent and child as the composite joint.
49  */
51  (IMP::core::RigidBody parent,
53  Joints joints = Joints() );
54 
55  /**
56  adds a joint at the end of the list of joints (closest to the child
57  rigid body)
58  @note the joint must have the same parent and child as the composite
59  joint
60  */
62  IMP_ALWAYS_CHECK( j->get_parent_node() == this->get_parent_node() &&
63  j->get_child_node() == this->get_child_node(),
64  "inner joint within a composite joint must have"
65  "the same parent and child rigid body nodes",
66  ValueException);
67  joints_.push_back(j);
68  }
69 
70  /**
71  adds a joint at the front of the list of joints (closest to the parent
72  rigid body)
73  @note the joint must have the same parent and child as the composite
74  joint
75  */
77  IMP_ALWAYS_CHECK( j->get_parent_node() == this->get_parent_node() &&
78  j->get_child_node() == this->get_child_node(),
79  "inner joint within a composite joint must have"
80  << "the same parent and child rigid body nodes",
81  ValueException);
82  joints_.insert(joints_.begin(), j);
83  }
84 
85  /**
86  Sets the list of inner joints instead of the existing one,
87 
88  @param joints the new joints, ordered from the parent rigid body
89  downstream to the child rigid body.
90 
91  @note All joints must have the same parent and child as the composite
92  joint
93  @note This invalidates all existing inner joints if any, detaching
94  them from their current KinematicForest owner if it exists.
95  */
96  void set_joints(Joints joints);
97 
98  /**
99  returns the list of inner joints, ordered from the parent
100  rigid body downstream to the child rigid body
101  */
102  const Joints& get_inner_joints() const {
103  return joints_;
104  }
105 
106 #ifndef SWIG
107  /**
108  returns the list of inner joints, ordered from the parent
109  rigid body downstream to the child rigid body
110  */
112  return joints_;
113  }
114 #endif
115 
116 
117  protected:
118  /**
119  update the child node reference frame by applying all the
120  inner joints
121  */
122  virtual void update_child_node_reference_frame() const;
123 
124 
125  /**
126  Updates all inner joints value, and the overall transformation
127  resulting from their combinations, based on the external coordinates
128  of the witnesses to each of the inner joints.
129 
130  @note It is assumed that external coordinates are updated before
131  calling this function.
132  */
133 
135 
136  private:
137  Joints joints_; // list of inner joints
138 };
139 
141 
142 IMPKINEMATICS_END_NAMESPACE
143 
144 #endif /* IMPKINEMATICS_COMPOSITE_JOINT_H */
virtual void update_joint_from_cartesian_witnesses()
functionality for defining a kinematic joint between rigid bodies as part of a kinematic tree ...
functionality for defining nodes on a kinematic chain
const Joints & get_inner_joints() const
IMP::base::Vector< IMP::base::Pointer< Joint > > Joints
Definition: Joint.h:145
virtual void update_child_node_reference_frame() const
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Exception definitions and assertions.
Simple 3D vector class.
Exception definitions and assertions.
A shared base class to help in debugging and things.
A decorator for a rigid body.
Definition: rigid_bodies.h:75
#define IMP_ALWAYS_CHECK(condition, message, exception_name)
Throw an exception if a check fails.