8 #ifndef IMPCORE_RIGID_BODIES_H
9 #define IMPCORE_RIGID_BODIES_H
11 #include <IMP/core/core_config.h>
12 #include "internal/rigid_bodies.h"
25 IMPCORE_BEGIN_NAMESPACE
27 IMP_DECORATORS_DECL(RigidMember, RigidMembers);
94 void setup_score_states();
104 if (
get_model()->get_has_attribute(internal::rigid_body_data().members_,
105 get_particle_index())) {
107 get_particle_index());
116 internal::rigid_body_data().body_members_, get_particle_index())) {
118 internal::rigid_body_data().body_members_, get_particle_index());
131 static void teardown_particle(
RigidBody rb);
133 IMP_CXX11_DEFAULT_COPY_CONSTRUCTOR(
RigidBody);
138 return internal::get_has_required_attributes_for_body(m, pi);
148 get_model()->get_attribute(internal::rigid_body_data().quaternion_[0],
149 get_particle_index()),
150 get_model()->get_attribute(internal::rigid_body_data().quaternion_[1],
151 get_particle_index()),
152 get_model()->get_attribute(internal::rigid_body_data().quaternion_[2],
153 get_particle_index()),
154 get_model()->get_attribute(internal::rigid_body_data().quaternion_[3],
155 get_particle_index()));
157 "Rotation is not a unit vector: " << v);
212 for (
unsigned int i = 0; i < 3; ++i) {
214 internal::rigid_body_data().torque_[i], get_particle_index());
225 void normalize_rotation();
228 void update_members();
234 unsigned int get_number_of_members()
const {
235 return get_body_member_particle_indexes().size() +
236 get_member_particle_indexes().size();
239 RigidMember get_member(
unsigned int i)
const;
267 return get_model()->get_internal_coordinates(get_particle_index());
272 get_model()->get_internal_coordinates(get_particle_index()) = v;
273 get_rigid_body().get_model()->clear_particle_caches(get_particle_index());
280 internal::rigid_body_data().lquaternion_[0], get_particle_index()),
281 "Can only set the internal transformation if member is"
282 <<
" a rigid body itself.");
283 set_internal_coordinates(v.get_translation());
286 get_particle_index(),
289 get_particle_index(),
292 get_particle_index(),
295 get_particle_index(),
297 get_rigid_body().get_model()->clear_particle_caches(get_particle_index());
303 internal::rigid_body_data().lquaternion_[0], get_particle_index()),
304 "Can only set the internal transformation if member is a "
305 <<
"rigid body itself.");
307 get_model()->get_internal_coordinates(get_particle_index());
309 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[0],
310 get_particle_index()),
311 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[1],
312 get_particle_index()),
313 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[2],
314 get_particle_index()),
315 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[3],
316 get_particle_index()));
332 IMP_CXX11_DEFAULT_COPY_CONSTRUCTOR(RigidBodyMember);
336 return internal::get_has_required_attributes_for_member(m, p);
339 static FloatKeys get_internal_coordinate_keys() {
340 return internal::rigid_body_data().child_keys_;
359 return internal::get_has_required_attributes_for_rigid_member(m, p);
379 return internal::get_has_required_attributes_for_non_member(m, p);
385 class IMPCOREEXPORT RigidMembersRefiner :
public Refiner {
387 RigidMembersRefiner(std::string name =
"RigidMembersRefiner%d")
396 kernel::
Model *m, const kernel::ParticleIndexes &pis) const IMP_OVERRIDE;
401 IMPCOREEXPORT RigidMembersRefiner *get_rigid_members_refiner();
444 IMP_DECORATORS_DEF(RigidMember, RigidMembers);
447 IMPCORE_END_NAMESPACE
void add_to_derivatives(const algebra::Vector3D &v, DerivativeAccumulator &d)
Add something to the derivative of the coordinates.
void set_internal_coordinates(const algebra::Vector3D &v) const
set the internal coordinates for this member
Import IMP/kernel/SingletonModifier.h in the namespace.
ParticleIndexes get_indexes(const ParticlesTemp &ps)
Class for adding derivatives from restraints to the model.
virtual const ParticlesTemp get_refined(Particle *a) const =0
Refine the passed particle into a set of particles.
A member of a rigid body, it has internal coordinates.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
Import IMP/kernel/SingletonContainer.h in the namespace.
algebra::Vector3D get_coordinates() const
Get the coordinates of the particle.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex pi)
const kernel::ParticleIndexes & get_member_particle_indexes() const
Return the members as particle pointers.
#define IMP_DECORATOR_METHODS(Name, Parent)
algebra::ReferenceFrame3D get_initial_reference_frame(kernel::Model *m, const kernel::ParticleIndexes &pis)
Model * get_model() const
Returns the Model containing the particle.
A decorator for a particle that is part of a rigid body.
bool get_coordinates_are_optimized() const
Get whether the coordinates are optimized.
void add_rigid_body_cache_key(ObjectKey k)
#define IMP_USAGE_CHECK_FLOAT_EQUAL(expra, exprb, message)
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
const Vector4D & get_quaternion() const
Return the quaternion so that it can be stored.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
virtual bool get_can_refine(Particle *) const
Return true if this refiner can refine that particle.
algebra::Vector3D get_torque() const
void transform(Hierarchy h, const algebra::Transformation3D &tr)
void set_reference_frame(const IMP::algebra::ReferenceFrame3D &tr)
Set the current reference frame.
Import IMP/kernel/Refiner.h in the namespace.
void set_coordinates(const algebra::Vector3D &v)
set all coordinates from a vector
Represent an XYZR particle with a sphere.
A decorator for a particle with x,y,z coordinates.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndexAdaptor p)
return true if it is a rigid member
const algebra::Vector3D & get_coordinates() const
Convert it to a vector.
Class to handle individual model particles.
A decorator for a particle that is part of a rigid body but not rigid.
Import IMP/kernel/refiner_macros.h in the namespace.
Simple 3D rotation class.
void set_internal_transformation(const algebra::Transformation3D &v)
Member must be a rigid body.
void set_coordinates_are_optimized(bool tf) const
Set whether the coordinates are optimized.
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndexAdaptor p)
return true if it is a rigid member
Key< 4, true > ObjectKey
The type used to identify an Object attribute.
void set_coordinates(const algebra::Vector3D ¢er)
XYZ::set_coordiantes()
IMP::kernel::Particle Particle
static bool get_is_setup(kernel::Model *m, kernel::ParticleIndex p)
return true if it is a rigid member
kernel::ParticlesTemp create_rigid_bodies(kernel::Model *m, unsigned int n, bool no_members=false)
Simple 3D rotation class.
A decorator for a rigid body.
Abstract class to implement hierarchical methods.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Decorator for a sphere-like particle.
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
const algebra::Vector3D & get_internal_coordinates() const
Return the current orientation of the body.
Class for storing model, its restraints, constraints, and particles.
IMP::algebra::ReferenceFrame3D get_reference_frame() const
Get the reference frame for the local coordinates.