IMP logo
IMP Reference Guide  2.6.1
The Integrative Modeling Platform
KinematicNode.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kinematics/KinematicNode.h
3  * \brief functionality for defining nodes on a kinematic chain
4  * \authors Dina Schneidman, Barak Raveh
5  *
6  * Copyright 2007-2016 IMP Inventors. All rights reserved.
7  */
8 
9 #ifndef IMPKINEMATICS_KINEMATIC_NODE_H
10 #define IMPKINEMATICS_KINEMATIC_NODE_H
11 
12 #include "kinematics_config.h"
13 #include <IMP/core/rigid_bodies.h>
14 #include <IMP/kinematics/Joint.h>
15 
16 #include <IMP/exception.h>
17 
18 IMPKINEMATICS_BEGIN_NAMESPACE
19 
20 class KinematicForest;
21 
22 // TODO: check for cycles
23 // TODO: privatize most methods INCLUDING constructor
24 
25 /**
26  A KinematicNode is a rigid body that is connected by a joint to other
27  rigid bodies
28 */
29 class IMPKINEMATICSEXPORT KinematicNode : public IMP::core::RigidBody {
30  friend class KinematicForest;
31 
32  static void do_setup_particle(Model* m, ParticleIndex p,
33  KinematicForest* owner,
34  Joint* in_joint = nullptr,
35  Joints out_joints = Joints());
36 
37  public:
41  in_joint);
43  in_joint, Joints, out_joints);
44 
45  /**
46  @brief Return true if the particle is a kinematic node (has the
47  appropriate properties).
48  */
49  inline static bool get_is_setup(Model* m, ParticleIndex pi);
50 
51  private:
52  //! returns the kinematic forest associated with this node
53  KinematicForest* get_owner();
54 
55  //! return nullptr if does not have incoming joint
56  inline Joint* get_in_joint();
57 
58  //! returns list of outcoming joints
59  inline JointsTemp get_out_joints();
60 
61  void set_out_joints(Joints in);
62 
63  void add_out_joint(Joint* j);
64 
65  void set_in_joint(Joint* j);
66 
67  static ObjectKey get_owner_key() {
68  static ObjectKey k("kinematics__kinematic_node_owner");
69  return k;
70  }
71 
72  static ObjectKey get_in_joint_key() {
73  static ObjectKey k("kinematics__kinematic_node_in_joint");
74  return k;
75  }
76 
77  static ObjectsKey get_out_joints_key() {
78  static ObjectsKey k("kinematics__kinematic_node_out_joint");
79  return k;
80  }
81 };
82 
83 /************** inlines ***********/
84 
85 bool KinematicNode::get_is_setup(Model* m, ParticleIndex pi) {
86  return m->get_has_attribute(get_owner_key(), pi);
87 }
88 
89 //! return nullptr if does not have incoming joint
90 Joint* KinematicNode::get_in_joint() {
91  if (!get_model()->get_has_attribute(get_in_joint_key(),
92  get_particle_index())) {
93  return nullptr;
94  }
95  Object* obj =
96  get_model()->get_attribute(get_in_joint_key(), get_particle_index());
97  return static_cast<Joint*>(obj);
98 }
99 
100 //! returns list of outcoming joints, or empty list if attribute
101 //! does not exist
102 JointsTemp KinematicNode::get_out_joints() {
103  JointsTemp joints;
104  if (!get_model()->get_has_attribute(get_out_joints_key(),
105  get_particle_index())) {
106  return joints;
107  }
108  Objects objs =
109  get_model()->get_attribute(get_out_joints_key(), get_particle_index());
110  for (unsigned int i = 0; i < objs.size(); i++) {
111  Object* o = objs[i];
112  Joint* j = static_cast<Joint*>(o);
113  joints.push_back(j);
114  }
115  return joints;
116 }
117 
118 // IMP_DECORATORS_DEF(KinematicNode, KinematicNodes);
119 IMP_DECORATORS(KinematicNode, KinematicNodes, IMP::core::RigidBody);
120 
121 IMPKINEMATICS_END_NAMESPACE
122 
123 #endif /* IMPKINEMATICS_KINEMATIC_NODE_H */
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Exception definitions and assertions.
IMP::Vector< IMP::WeakPointer< Joint > > JointsTemp
Definition: Joint.h:130
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
functionality for defining a kinematic joint between rigid bodies as part of a kinematic tree ...
Common base class for heavy weight IMP objects.
Definition: Object.h:106
functionality for defining rigid bodies
#define IMP_DECORATOR_SETUP_2(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name)
IMP::Vector< IMP::Pointer< Joint > > Joints
Definition: Joint.h:130
IMP::Vector< IMP::Pointer< Object > > Objects
A list of objects.
Definition: types.h:60
#define IMP_DECORATOR_METHODS(Name, Parent)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
A decorator for a rigid body.
Definition: rigid_bodies.h:75
#define IMP_DECORATOR_SETUP_3(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name)