00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPDOMINO_TRANSFORMATION_H
00009 #define IMPDOMINO_TRANSFORMATION_H
00010
00011 #include "domino_config.h"
00012 #include <IMP/Decorator.h>
00013 #include <IMP/algebra/Vector3D.h>
00014 #include <IMP/algebra/Transformation3D.h>
00015
00016 IMPDOMINO_BEGIN_NAMESPACE
00017
00018
00019
00020
00021
00022
00023 class IMPDOMINOEXPORT Transformation: public Decorator
00024 {
00025 public:
00026
00027 static FloatKey get_translation_key(unsigned int i) {
00028 IMP_USAGE_CHECK(i <3, "Out of range coordinate");
00029 return IMP::internal::xyzr_keys[i];
00030 }
00031
00032 static FloatKey get_rotation_key(unsigned int i) {
00033 IMP_USAGE_CHECK(i <4, "Out of range coordinate");
00034 return get_rotation_keys()[i];
00035 }
00036
00037 static const FloatKeys &get_rotation_keys();
00038 static const FloatKeys &get_translation_keys();
00039 static const IntKey &get_transformation_index_key();
00040 IMP_DECORATOR(Transformation, Decorator);
00041
00042
00043 static Transformation setup_particle(Particle *p,
00044 const algebra::Transformation3D &t=
00045 algebra::get_identity_transformation_3d(),
00046 Int index=0){
00047 algebra::VectorD<3> trans=t.get_translation();
00048 algebra::VectorD<4> rot = t.get_rotation().get_quaternion();
00049 p->add_attribute(get_translation_key(0),trans[0]);
00050 p->add_attribute(get_translation_key(1),trans[1]);
00051 p->add_attribute(get_translation_key(2),trans[2]);
00052 p->add_attribute(get_rotation_key(0),rot[0]);
00053 p->add_attribute(get_rotation_key(1),rot[1]);
00054 p->add_attribute(get_rotation_key(2),rot[2]);
00055 p->add_attribute(get_rotation_key(3),rot[3]);
00056 p->add_attribute(get_transformation_index_key(),index);
00057 return Transformation(p);
00058 }
00059
00060 IMP_DECORATOR_GET_SET(x, get_translation_key(0), Float, Float);
00061 IMP_DECORATOR_GET_SET(y, get_translation_key(1), Float, Float);
00062 IMP_DECORATOR_GET_SET(z, get_translation_key(2), Float, Float);
00063 IMP_DECORATOR_GET_SET(a, get_rotation_key(0), Float, Float);
00064 IMP_DECORATOR_GET_SET(b, get_rotation_key(1), Float, Float);
00065 IMP_DECORATOR_GET_SET(c, get_rotation_key(2), Float, Float);
00066 IMP_DECORATOR_GET_SET(d, get_rotation_key(3), Float, Float);
00067 IMP_DECORATOR_GET_SET(i, get_transformation_index_key(), Int, Int);
00068
00069 static bool particle_is_instance(Particle *p) {
00070 IMP_USAGE_CHECK( p->has_attribute(get_translation_key(0))
00071 && p->has_attribute(get_translation_key(1))
00072 && p->has_attribute(get_translation_key(2))
00073 && p->has_attribute(get_rotation_key(0))
00074 && p->has_attribute(get_rotation_key(1))
00075 && p->has_attribute(get_rotation_key(2))
00076 && p->has_attribute(get_rotation_key(3))
00077 && p->has_attribute(get_transformation_index_key()),
00078 "Particle expected to either have x,y,z,a,b,c,d attributes.");
00079 return true;
00080 }
00081
00082 algebra::Transformation3D get_transformation();
00083 };
00084
00085 IMP_OUTPUT_OPERATOR(Transformation);
00086
00087 typedef Decorators<Transformation, Particles> Transformations;
00088
00089 IMPDOMINO_END_NAMESPACE
00090
00091 #endif