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"
24 IMPCORE_BEGIN_NAMESPACE
26 IMP_DECORATORS_DECL(RigidMember, RigidMembers);
103 void setup_score_states();
117 IMPCORE_DEPRECATED_FUNCTION_DECL(2.2)
119 IMPCORE_DEPRECATED_FUNCTION_DEF(2.2,
"Use get_rigid_members() instead.");
120 return get_rigid_members();
129 if (
get_model()->get_has_attribute(internal::rigid_body_data().members_,
154 return get_member_particle_indexes() + get_body_member_particle_indexes();
177 static void teardown_particle(
RigidBody rb);
179 IMP_CXX11_DEFAULT_COPY_CONSTRUCTOR(
RigidBody);
184 return internal::get_has_required_attributes_for_body(m, pi);
194 get_model()->get_attribute(internal::rigid_body_data().quaternion_[0],
196 get_model()->get_attribute(internal::rigid_body_data().quaternion_[1],
198 get_model()->get_attribute(internal::rigid_body_data().quaternion_[2],
200 get_model()->get_attribute(internal::rigid_body_data().quaternion_[3],
203 "Rotation is not a unit vector: " << v);
209 bool assume_normalized =
true;
261 for (
unsigned int i = 0; i < 3; ++i) {
277 void normalize_rotation();
281 void update_members();
287 unsigned int get_number_of_members()
const {
288 return get_body_member_particle_indexes().size() +
289 get_member_particle_indexes().size();
292 RigidMember get_member(
unsigned int i)
const;
356 "Can only set the internal transformation if member is"
357 <<
" a rigid body itself.");
358 set_internal_coordinates(v.get_translation());
384 "Can only set the internal transformation if member is a "
385 <<
"rigid body itself.");
389 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[0],
391 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[1],
393 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[2],
395 get_model()->get_attribute(internal::rigid_body_data().lquaternion_[3],
414 IMP_CXX11_DEFAULT_COPY_CONSTRUCTOR(RigidBodyMember);
418 return internal::get_has_required_attributes_for_member(m, p);
421 static FloatKeys get_internal_coordinate_keys() {
422 return internal::rigid_body_data().child_keys_;
446 return internal::get_has_required_attributes_for_rigid_member(m, p);
466 return internal::get_has_required_attributes_for_non_member(m, p);
472 class IMPCOREEXPORT RigidMembersRefiner :
public Refiner {
474 RigidMembersRefiner(std::string name =
"RigidMembersRefiner%d")
483 kernel::
Model *m, const kernel::ParticleIndexes &pis) const IMP_OVERRIDE;
488 IMPCOREEXPORT RigidMembersRefiner *get_rigid_members_refiner();
514 return get_initial_reference_frame(ps[0]->get_model(),
531 IMP_DECORATORS_DEF(RigidMember, RigidMembers);
536 base::TextOutput out =
537 base::TextOutput(std::cout));
545 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 (local) coordinates for this member
Import IMP/kernel/SingletonModifier.h in the namespace.
ParticleIndex get_particle_index() const
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 (local) 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
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
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 set_reference_frame(const IMP::algebra::ReferenceFrame3D &tr)
Set the current reference frame.
A Cartesian vector in D-dimensions.
Import IMP/kernel/Refiner.h in the namespace.
void set_coordinates(const algebra::Vector3D &v)
set all coordinates from a vector
kernel::ParticleIndexes get_member_indexes() const
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.
Simple 3D rotation class.
void set_internal_transformation(const algebra::Transformation3D &v)
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
base::Index< ParticleIndexTag > ParticleIndex
Key< 4, true > ObjectKey
The type used to identify an Object attribute.
void set_coordinates(const algebra::Vector3D ¢er)
sets the global coordinates of this member using 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
void show_rigid_body_hierarchy(RigidBody rb, base::TextOutput out=base::TextOutput(std::cout))
kernel::ParticlesTemp create_rigid_bodies(kernel::Model *m, unsigned int n, bool no_members=false)
kernel::ParticleIndex get_root_rigid_body(RigidMember m)
void transform(RigidBody a, const algebra::Transformation3D &tr)
Transform a rigid body.
Simple 3D rotation class.
void clear_particle_caches(ParticleIndex pi)
A decorator for a rigid body.
algebra::Transformation3D get_internal_transformation() const
Abstract class to implement hierarchical methods.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Decorator for a sphere-like particle.
const kernel::ParticleIndexes & get_body_member_particle_indexes() const
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
const algebra::Vector3D & get_internal_coordinates() const
Return the internal (local) coordinates of this member.
Class for storing model, its restraints, constraints, and particles.
IMP::algebra::ReferenceFrame3D get_reference_frame() const
Get the reference frame for the local coordinates.