IMP  2.1.1
The Integrative Modeling Platform
ProjectionParameters.h
Go to the documentation of this file.
1 /**
2  * \file ProjectionParameters.h
3  * \brief Decorator for projection parameters
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5 */
6 
7 #ifndef IMPEM2D_PROJECTION_PARAMETERS_H
8 #define IMPEM2D_PROJECTION_PARAMETERS_H
9 
10 #include "IMP/em2d/em2d_config.h"
11 #include "IMP/algebra/Vector3D.h"
12 #include "IMP/algebra/Vector2D.h"
13 #include "IMP/algebra/Rotation3D.h"
14 #include "IMP/Decorator.h"
15 #include "IMP/decorator_macros.h"
16 #include "IMP/ScoreState.h"
17 #include "IMP/score_state_macros.h"
18 
19 
20 
21 IMPEM2D_BEGIN_NAMESPACE
22 
23 //! Decorator for particles representing the parameters
24 //! Rotation and tranlation. In this cases, the translation is the translation
25 //! to apply to the model in 3D, in order to perform the registration
26 class IMPEM2DEXPORT ProjectionParameters: public Decorator {
27  static void do_setup_particle(kernel::Model *m,
29 
30 public:
31 
34 
36 
37  //! Keys of the decorator
38  // FloatKeys get_keys();
39  static const FloatKeys& get_keys();
40 
41  //! ranges for the keys. Only adjust the translations, the rotations are
42  //! self adjusted
43  void set_proper_ranges_for_keys(kernel::Model *m,
44  const algebra::Vector3D &min_translation_values,
45  const algebra::Vector3D &max_translation_values);
46 
47  //!Return true of the particle is a set of projection parameters
49 
50 
51  //! Get whether the parameters are optimized
52  /*! \return true only if all of them are optimized.
53  */
54  bool get_parameters_optimized() const {
55  for(int i=0;i<6;++i) {
56  if(get_particle()->get_is_optimized(get_keys()[i])==false) {
57  return false;
58  }
59  }
60  return true;
61  }
62 
63  algebra::Vector3D get_translation() const {
64  return algebra::Vector3D(get_translation_x(),
65  get_translation_y(),
66  0.0);
67 
68  }
69 
70  void set_translation(const algebra::Vector3D &v) {
71  set_translation_x(v[0]);
72  set_translation_y(v[1]);
73  }
74 
75  algebra::Rotation3D get_rotation() const {
76  algebra::Vector4D v(get_quaternion_1(),
77  get_quaternion_2(),
78  get_quaternion_3(),
79  get_quaternion_4());
80  // normalize the vector. Given that the numbers generated with
81  // simplex are not necessarily a unit vector.
83  return algebra::Rotation3D(unit[0],
84  unit[1],
85  unit[2],
86  unit[3]);
87  }
88 
89  void set_rotation(const algebra::Rotation3D &R) {
90  set_quaternion_1(R.get_quaternion()[0]);
91  set_quaternion_2(R.get_quaternion()[1]);
92  set_quaternion_3(R.get_quaternion()[2]);
93  set_quaternion_4(R.get_quaternion()[3]);
94  }
95 
96  //! Set whether the parameters are optimized
97  inline void set_parameters_optimized(bool tf) const {
98  for(int i=0;i<6;++i) {
99  get_particle()->set_is_optimized(get_keys()[i], tf);
100  }
101  }
102 
103 
104 
105  //! Get and set functions for the parameters
106  IMP_DECORATOR_GET_SET(quaternion_1,get_keys()[0],Float,double);
107  IMP_DECORATOR_GET_SET(quaternion_2,get_keys()[1],Float,double);
108  IMP_DECORATOR_GET_SET(quaternion_3,get_keys()[2],Float,double);
109  IMP_DECORATOR_GET_SET(quaternion_4,get_keys()[3],Float,double);
110  IMP_DECORATOR_GET_SET(translation_x,get_keys()[4],Float,double);
111  IMP_DECORATOR_GET_SET(translation_y,get_keys()[5],Float,double);
112 
113 private:
114  algebra::Rotation3D rotation_;
115  algebra::Vector3D translation_;
116 
117 };
118 
120 
121 
122 
123 
124 //! Score state to give information about the values of a ProjectionParameters
125 //! Decorator
126 class IMPEM2DEXPORT ProjectionParametersScoreState : public ScoreState {
127 public:
129  ScoreState(p->get_model(),
130  "ProjectionParametersScoreState%1%") {
131  proj_params_ = p;
132  }
133  virtual void do_before_evaluate() IMP_OVERRIDE;
134  virtual void do_after_evaluate(DerivativeAccumulator *da) IMP_OVERRIDE;
135  virtual kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
136  virtual kernel::ModelObjectsTemp do_get_outputs() const IMP_OVERRIDE;
138 
139 private:
140  // kernel::Particle to store the projection params
141  base::Pointer<kernel::Particle> proj_params_;
142 };
143 
144 
145 
146 IMPEM2D_END_NAMESPACE
147 
148 #endif /* IMPEM2D_PROJECTION_PARAMETERS_H */
Import IMP/kernel/Decorator.h in the namespace.
Class for adding derivatives from restraints to the model.
IMP::kernel::ScoreState ScoreState
Particle * get_particle() const
Simple 2D vector class.
void set_parameters_optimized(bool tf) const
Set whether the parameters are optimized.
#define IMP_DECORATOR_METHODS(Name, Parent)
A smart pointer to a reference counted object.
Definition: base/Pointer.h:87
ScoreStates maintian invariants in the Model.
VectorD< 4 > Vector4D
Definition: VectorD.h:591
static bool get_is_setup(Particle *p)
Return true if the particle can be cast to the decorator.
#define IMP_DECORATOR_SETUP_0(Name)
Import IMP/kernel/decorator_macros.h in the namespace.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Import IMP/kernel/ScoreState.h in the namespace.
Class to handle individual model particles.
Simple 3D rotation class.
3D rotation class.
Definition: Rotation3D.h:45
Import IMP/kernel/score_state_macros.h in the namespace.
VectorD< 3 > Vector3D
Definition: VectorD.h:587
virtual ModelObjectsTemp do_get_inputs() const =0
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
Simple 3D vector class.
bool get_parameters_optimized() const
Get whether the parameters are optimized.
VectorD get_unit_vector() const
Definition: VectorD.h:204
#define IMP_DECORATOR_GET_SET(name, AttributeKey, Type, ReturnType)
Define methods for getting and setting a particular simple field.
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
virtual ModelObjectsTemp do_get_outputs() const =0
Class for storing model, its restraints, constraints, and particles.