Bayeux  3.4.1
Core Foundation library for SuperNEMO
placement.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2008-05-23
4  * Last modified: 2016-07-06
5  *
6  * License:
7  *
8  * Description:
9  *
10  * Placement.
11  *
12  */
13 
14 #ifndef GEOMTOOLS_PLACEMENT_H
15 #define GEOMTOOLS_PLACEMENT_H 1
16 
17 // Standard library:
18 #include <iostream>
19 #include <string>
20 #include <vector>
21 
22 // This project:
23 #include <datatools/properties.h>
24 #include <datatools/bit_mask.h>
25 #include <geomtools/i_placement.h>
27 
28 namespace geomtools {
29 
30  class stackable_data;
31 
34  class placement : public i_placement
35  {
36 
37  public:
38 
77  class builder
78  {
79  public:
80 
81  enum init_flags {
84  };
85 
95  };
96 
98  static child_to_mother_gap_mode get_gap_mode(const std::string & label_);
99 
101  static std::string get_gap_mode_label(child_to_mother_gap_mode);
102 
105 
107  builder(uint32_t flags_ = 0);
108 
109  bool has_mother_stackable() const;
110 
111  void set_mother_stackable(const stackable_data &);
112 
113  bool has_child_stackable() const;
114 
115  void set_child_stackable(const stackable_data &);
116 
117  bool use_child_to_mother_gap() const;
118 
119  bool allowed_rotation() const;
120 
122  void configure(uint32_t flags_ = 0);
123 
125  void reset();
126 
128  void build(const datatools::properties & config_,
129  placement & p_) const;
130 
131  protected:
132 
133  void _build(const datatools::properties & config_,
134  placement & p_) const;
135 
136  private:
137 
138  bool _no_child_to_mother_gap_ = false;
139  bool _no_rotation_ = false;
140  const stackable_data * _mother_stackable_ = nullptr;
141  const stackable_data * _child_stackable_ = nullptr;
142 
143  };
144 
146  bool is_valid() const;
147 
149  void invalidate();
150 
152  const vector_3d & get_translation() const;
153 
156 
158  void set_translation(double, double, double);
159 
161  void set_translation_xyz(double, double, double);
162 
164  void set_translation(const vector_3d &);
165 
167  void set_translation_v(const vector_3d &);
168 
170  void translate(const vector_3d &);
171 
173  void translate(double dx_, double dy_, double dz_);
174 
176  bool is_simple_rotation() const;
177 
179  bool is_rotation_x() const;
180 
182  bool is_rotation_y() const;
183 
185  bool is_rotation_z() const;
186 
188  int get_rotation_axis() const;
189 
191  double get_rotation_angle() const;
192 
194  bool is_zyz_rotation() const;
195 
197  double get_phi() const;
198 
200  double get_theta() const;
201 
203  double get_delta() const;
204 
206  bool has_angles() const;
207 
209  const rotation_3d & get_rotation() const;
210 
212  const rotation_3d & get_inverse_rotation() const;
213 
214  // geomtools::i_placement interface:
215 
217  virtual size_t get_dimension() const;
218 
220  virtual size_t get_number_of_items() const;
221 
223  virtual void get_placement(int item_, placement & p_) const;
224 
226  virtual bool is_replica() const;
227 
229  virtual bool has_only_one_rotation() const;
230 
232  virtual size_t compute_index_map(std::vector<uint32_t> & map_,
233  int item_) const;
234 
236  bool is_identity() const;
237 
239  void set_identity();
240 
242  void set_orientation(int axis_, double angle_);
243 
245  void set_orientation_axis_angle(int axis_, double angle_);
246 
248  void set_orientation(double phi_, double theta_, double delta_);
249 
251  void set_orientation_zyz(double phi_, double theta_, double delta_);
252 
254  void set_orientation(double angle0_, double angle1_, double angle2_, euler_angles_type euler_angle_);
255 
257  void set(double x_, double y_, double z_,
258  double phi_, double theta_, double delta_);
259 
261  void set(double x_, double y_, double z_,
262  double angle0_, double angle1_, double angle2_, euler_angles_type euler_angle_);
263 
265  void set(double x_, double y_, double z_,
266  int axis_, double angle_);
267 
269  void set(const vector_3d & t_,
270  double phi_, double theta_, double delta_);
271 
273  void set(const vector_3d & t_,
274  double angle0_, double angle1_, double angle2_, euler_angles_type euler_angle_);
275 
276 
278  void set(const vector_3d & t_,
279  int axis_, double angle_);
280 
282  void set_orientation(const rotation_3d &);
283 
285  void set_orientation_xyz(double phi_, double theta_, double delta_);
286 
288  placement();
289 
291  placement(const vector_3d & translation_);
292 
294  placement(double x_,
295  double y_,
296  double z_);
297 
299  placement(const vector_3d & translation_,
300  double phi_,
301  double theta_,
302  double delta_);
303 
305  placement(const vector_3d & translation_,
306  int axis_,
307  double angle_);
308 
310  placement(double x_,
311  double y_,
312  double z_,
313  double phi_,
314  double theta_,
315  double delta_);
316 
318  placement(double x_,
319  double y_,
320  double z_,
321  double angle0_,
322  double angle1_,
323  double angle2_,
324  euler_angles_type euler_angles_);
325 
327  placement(const vector_3d & translation_,
328  double angle0_,
329  double angle1_,
330  double angle2_,
331  euler_angles_type euler_angles_);
332 
334  placement(double x_,
335  double y_,
336  double z_,
337  int axis_,
338  double angle_);
339 
341  placement(const vector_3d & translation_,
342  const rotation_3d & rotation_);
343 
345  virtual ~placement();
346 
348  virtual void reset();
349 
350  // Transformation methods:
351 
352  void mother_to_child(const vector_3d &, vector_3d &) const;
353 
354  vector_3d mother_to_child(const vector_3d &) const;
355 
356  void child_to_mother(const vector_3d &, vector_3d &) const;
357 
358  vector_3d child_to_mother(const vector_3d &) const;
359 
360  void mother_to_child_direction(const vector_3d &, vector_3d &) const;
361 
363 
364  void child_to_mother_direction(const vector_3d &, vector_3d &) const;
365 
367 
368  //void mother_to_child(const placement &, placement &) const;
369 
370  void child_to_mother(const placement &, placement &) const;
371 
372 
383  void relocate(const placement &, placement &) const;
384 
385  void initialize(const datatools::properties & config_, uint32_t flags_ = 0);
386 
388  virtual void tree_dump(std::ostream & out_ = std::clog,
389  const std::string & title_ = "",
390  const std::string & indent_ = "",
391  bool inherit_ = false) const;
392 
394  void dump(std::ostream & out_ = std::clog,
395  const std::string & title_ = "geomutils::placement",
396  const std::string & indent_ = "") const;
397 
399  static bool from_string(const std::string &, placement &);
400 
402  static void to_string(std::string &, const placement &);
403 
405  void test() const;
406 
407 
408  private:
409 
411  void _compute_orientation_();
412 
414  void _compute_orientation_xyz_(); // just for test
415 
416  private:
417 
418  vector_3d _translation_;
419  int _rotation_axis_;
420  double _rotation_angle_;
421  double _phi_, _theta_, _delta_;
422  rotation_3d _rotation_;
423  rotation_3d _inverse_rotation_;
424 
427 
428 
429  DR_CLASS_RTTI()
430 
431  };
432 
433  std::ostream & operator<< (std::ostream & out_, const placement &);
434 
435 } // end of namespace geomtools
436 
437 #include <boost/serialization/export.hpp>
438 BOOST_CLASS_EXPORT_KEY2(geomtools::placement, "geomtools::placement")
439 
440 // Activate reflection layer :
442 
443 /*
444 // Class version:
445 #include <boost/serialization/version.hpp>
446 BOOST_CLASS_VERSION(geomtools::placement, 0)
447 */
448 
449 #endif // GEOMTOOLS_PLACEMENT_H
450 
451 // Local Variables: --
452 // mode: c++ --
453 // c-file-style: "gnu" --
454 // tab-width: 2 --
455 // End: --
#define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
Undefined gap mode.
Definition: placement.h:88
void _build(const datatools::properties &config_, placement &p_) const
bool is_rotation_y() const
Check if the orientation is defined as a Y axis rotation.
virtual void get_placement(int item_, placement &p_) const
Compute the placement at given index.
Gap between the child maximum border to mother minimum border.
Definition: placement.h:93
void child_to_mother(const vector_3d &, vector_3d &) const
void set_orientation_axis_angle(int axis_, double angle_)
Set orientation by axis and angle.
Gap between the child origin to mother maximum border.
Definition: placement.h:90
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
child_to_mother_gap_mode
Child to mother gap mode:
Definition: placement.h:87
virtual size_t get_number_of_items() const
Return the number of placement entries associated to this placement object.
void dump(std::ostream &out_=std::clog, const std::string &title_="geomutils::placement", const std::string &indent_="") const
Basic print.
bool use_child_to_mother_gap() const
static const uint32_t bit01
Definition: bit_mask.h:28
void set_translation(double, double, double)
Set the translation from a (x,y,z) coordinate triplet.
void configure(uint32_t flags_=0)
Configure from flags.
init_flags
Definition: placement.h:81
virtual void reset()
Reset.
void translate(const vector_3d &)
Translate the current translation by some shift.
static bool needs_stackable_child(child_to_mother_gap_mode)
Check if a given child/mother gap mode needs child stackable informations.
Inhibit the child/mother gap build modes.
Definition: placement.h:82
bool is_rotation_z() const
Check if the orientation is defined as a Z axis rotation.
virtual size_t get_dimension() const
Return the dimension of the(multi-)placement object.
void set_child_stackable(const stackable_data &)
void set_translation_xyz(double, double, double)
Set the translation from a (x,y,z) coordinate triplet.
void set_translation_v(const vector_3d &)
Set the translation.
void set_orientation_zyz(double phi_, double theta_, double delta_)
Set orientation by ZYZ Euler angles.
bool is_identity() const
Check if the placement is identity.
void relocate(const placement &, placement &) const
static void to_string(std::string &, const placement &)
Convert to a description string.
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
Gap between the child origin to mother minimum border.
Definition: placement.h:89
void invalidate()
Invalidate.
void test() const
Test method.
static child_to_mother_gap_mode get_gap_mode(const std::string &label_)
Return child/mother gap mode from a label.
int get_rotation_axis() const
Return rotation axis.
void initialize(const datatools::properties &config_, uint32_t flags_=0)
builder(uint32_t flags_=0)
Constructor from initialization flags.
const vector_3d & get_translation() const
Return the translation.
double get_delta() const
Return delta Euler angle.
bool has_angles() const
Chec if Euler angles are defined.
void set(double x_, double y_, double z_, double phi_, double theta_, double delta_)
Set translation by (x,y,z) coordinate triplet and orientation by ZYZ Euler angles.
void set_identity()
Set identity.
void build(const datatools::properties &config_, placement &p_) const
Build a placement object from a set of parameters.
double get_theta() const
Return theta Euler angle.
Gap between the child minimum border to mother minimum border.
Definition: placement.h:91
CLHEP::HepRotation rotation_3d
Alias for the CLHEP 3D-rotation class.
Definition: clhep.h:66
const key_predicate &predicate_ const
Definition: properties.h:1475
void set_orientation_xyz(double phi_, double theta_, double delta_)
Set the rotation using XYZ Euler angles (experimental)
static bool from_string(const std::string &, placement &)
Parse from a description string.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
Construct a placement.
Definition: placement.h:77
const rotation_3d & get_inverse_rotation() const
Return the inverse rotation matrix.
virtual size_t compute_index_map(std::vector< uint32_t > &map_, int item_) const
Compute the list of multi-dimension multiplet for placement at given index.
void set_mother_stackable(const stackable_data &)
bool is_rotation_x() const
Check if the orientation is defined as a X axis rotation.
Inhibit rotation.
Definition: placement.h:83
Abstract interface for all placement objects.
Definition: i_placement.h:42
bool is_simple_rotation() const
Check if the orientation is defined as a simple rotation (X, Y or Z axis)
The placement for a geometry volume with its translation and rotation with respect to some mother ref...
Definition: placement.h:34
Data for stacking along X, Y and/or Z axis.
Definition: i_stackable.h:161
placement()
Constructor.
virtual bool has_only_one_rotation() const
Check if the (multi-)placement has only one rotation for all its placement objects.
Gap between the child minimum border to mother maximum border.
Definition: placement.h:92
euler_angles_type
Type of Euler angles.
Definition: utils.h:250
void mother_to_child(const vector_3d &, vector_3d &) const
virtual ~placement()
Destructor.
static const uint32_t bit00
Definition: bit_mask.h:27
virtual bool is_replica() const
Check if placement is a replica.
bool is_valid() const
Check validity.
const rotation_3d & get_rotation() const
Return the rotation matrix.
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
vector_3d & grab_translation()
Return the mutable translation.
Gap between the child maximum border to mother maximum border.
Definition: placement.h:94
void mother_to_child_direction(const vector_3d &, vector_3d &) const
void set_orientation(int axis_, double angle_)
Set orientation by axis and angle.
void child_to_mother_direction(const vector_3d &, vector_3d &) const
double get_rotation_angle() const
Return rotation angle.
static std::string get_gap_mode_label(child_to_mother_gap_mode)
Return the label associated ti a given child/mother gap mode.
void reset()
Reset the builder.
double get_phi() const
Return phi Euler angle.
bool is_zyz_rotation() const
Check if the orientation is defined through ZYZ Euler angles.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125