Bayeux  3.4.1
Core Foundation library for SuperNEMO
logical_volume.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-08
4  * Last modified: 2013-06-26
5  *
6  * License:
7  *
8  * Description:
9  * Logical volume.
10  *
11  * History:
12  *
13  */
14 
15 #ifndef GEOMTOOLS_LOGICAL_VOLUME_H
16 #define GEOMTOOLS_LOGICAL_VOLUME_H 1
17 
18 // Standard library:
19 #include <string>
20 #include <map>
21 
22 // Third party:
23 // - Bayeux/datatools:
24 #include <datatools/properties.h>
25 #include <datatools/i_tree_dump.h>
26 #include <datatools/logger.h>
27 
28 // This project:
29 #include <geomtools/i_shape_3d.h>
30 #include <geomtools/material.h>
31 
32 namespace geomtools {
33 
34  // Forward declarations:
35  class physical_volume;
36  class i_model;
37  class placement;
38 
42  {
43  public:
44 
46  typedef std::map<std::string, const physical_volume *> physicals_col_type;
47 
49  class locate_result {
50  public:
52  locate_result();
54  void reset();
56  void dump(std::ostream & out_ = std::clog, const std::string & indent_ = "") const;
58  void set_shape_domain_flags(uint32_t);
60  void set_daughter_name(const std::string &);
62  void set_daughter(const physical_volume &);
66  void set_position_in_daughter(const vector_3d &);
68  uint32_t get_shape_domain_flags() const;
70  bool has_daughter() const;
72  const std::string & get_daughter_name() const;
74  const physical_volume & get_daughter() const;
76  bool has_daughter_placement_index() const;
78  int get_daughter_placement_index() const;
80  bool has_position_in_daughter() const;
82  const vector_3d & get_position_in_daughter() const;
83  private:
84  uint32_t _shape_domain_flags_;
85  std::string _daughter_name_;
86  const physical_volume * _daughter_physical_;
87  int _daughter_placement_index_;
88  vector_3d _position_in_daughter_;
89  };
90 
92  static const std::string & has_replica_flag();
93 
95  bool is_locked () const;
96 
98  void lock ();
99 
101  void unlock ();
102 
104  bool has_name() const;
105 
107  const std::string & get_name () const;
108 
110  void set_name (const std::string &);
111 
112  const datatools::properties & get_parameters () const;
113 
115 
116  bool has_shape () const;
117 
118  void set_shape (const i_shape_3d &);
119 
120  void set_shape (const i_shape_3d *);
121 
122  const i_shape_3d & get_shape () const;
123 
124  const physicals_col_type & get_physicals () const;
125 
126  const physicals_col_type & get_real_physicals () const;
127 
129  logical_volume ();
130 
132  logical_volume (const std::string &);
133 
135  logical_volume (const std::string &, const i_shape_3d &);
136 
138  logical_volume (const std::string &, const i_shape_3d *);
139 
141  virtual ~logical_volume ();
142 
144  virtual void tree_dump (std::ostream & out_ = std::clog,
145  const std::string & title_ = "",
146  const std::string & indent_ = "",
147  bool inherit_ = false) const;
148 
149  bool has_physical (const std::string & name_) const;
150 
151  bool has_material_ref () const;
152 
153  std::string get_material_ref () const;
154 
155  void set_material_ref (const std::string & = "");
156 
157  const physical_volume & get_physical (const std::string & name_) const;
158 
159  void add_physical (const physical_volume & phys_, const std::string & name_ = "");
160 
161  bool is_replica () const;
162 
163  bool is_abstract () const;
164 
165  void set_abstract (bool a_);
166 
167  bool has_effective_shape() const;
168 
169  void set_effective_shape (const i_shape_3d &);
170 
171  const i_shape_3d & get_effective_shape () const;
172 
173  bool has_geometry_model() const;
174 
175  void set_geometry_model (const i_model &);
176 
177  const i_model & get_geometry_model () const;
178 
179  bool has_effective_material_ref () const;
180 
181  std::string get_effective_material_ref () const;
182 
183  void set_effective_material_ref (const std::string & = "");
184 
186 
188 
190 
191  uint32_t locate(const vector_3d & local_position_,
192  bool ignore_daugthers_ = false,
193  double tolerance_ = 0.0, double daughter_tolerance_ = 0.0,
194  locate_result * = 0) const;
195 
196  static bool same(const logical_volume & log1_, const logical_volume & log2_, uint32_t mode_ = 0);
197 
198  private:
199 
200  void _clear_shape_ ();
201 
202  void _init_defaults_ ();
203 
204  void _at_lock_ ();
205 
206  void _compute_real_physicals_ ();
207 
208  void set_logging_priority(datatools::logger::priority);
209 
210  datatools::logger::priority get_logging_priority() const;
211 
212  private:
213 
214  std::string _name_;
215  datatools::logger::priority _logging_priority_;
216  std::string _material_ref_;
217  bool _locked_;
218  datatools::properties _parameters_;
219  bool _own_shape_;
220  const i_shape_3d * _shape_;
221  physicals_col_type _physicals_;
222  bool _abstract_;
223 
224  // Experimental:
225  const i_model * _geo_model_;
226  const i_shape_3d * _effective_shape_;
227  const placement * _effective_relative_placement_;
228  std::string _effective_material_ref_;
229 
230  physicals_col_type _real_physicals_;
231 
232  public:
233 
234  typedef std::map<std::string, const logical_volume *> dict_type;
235 
236  };
237 
238 } // end of namespace geomtools
239 
240 #endif // GEOMTOOLS_LOGICAL_VOLUME_H
241 
242 /*
243 ** Local Variables: --
244 ** mode: c++ --
245 ** c-file-style: "gnu" --
246 ** tab-width: 2 --
247 ** End: --
248 */
void set_geometry_model(const i_model &)
uint32_t locate(const vector_3d &local_position_, bool ignore_daugthers_=false, double tolerance_=0.0, double daughter_tolerance_=0.0, locate_result *=0) const
void set_effective_material_ref(const std::string &="")
const std::string & get_name() const
Return the name of the volume.
void dump(std::ostream &out_=std::clog, const std::string &indent_="") const
Basic print.
void set_shape_domain_flags(uint32_t)
Set the shape domain flags.
The base class for geometry models.
Definition: i_model.h:45
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
Mother abstract class for all 3D solid shapes.
Definition: i_shape_3d.h:46
const i_model & get_geometry_model() const
const datatools::properties & get_parameters() const
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
bool has_physical(const std::string &name_) const
void set_daughter_placement_index(int)
Set the daughter physical volume's placement index.
static const std::string & has_replica_flag()
Return the name of the flag that indicated a replica.
void set_name(const std::string &)
Set the name of the volume.
void set_shape(const i_shape_3d &)
A physical geometry volume (ala GDML)
Definition: physical_volume.h:36
void lock()
Lock the volume.
const i_shape_3d & get_shape() const
const physicals_col_type & get_real_physicals() const
A logical geometry volume (ala GDML)
Definition: logical_volume.h:40
bool has_name() const
Check the name of the volume.
const physical_volume & get_daughter() const
Return a const reference to the daughter.
void unlock()
Unlock the volume.
void set_effective_shape(const i_shape_3d &)
const i_shape_3d & get_effective_shape() const
int get_daughter_placement_index() const
Return the daughter physical volume's placement index.
bool has_effective_relative_placement() const
bool is_locked() const
Check the lock flag.
const vector_3d & get_position_in_daughter() const
Return the position in the reference frame of the daughter volume.
virtual ~logical_volume()
Desctructor.
void add_physical(const physical_volume &phys_, const std::string &name_="")
const physicals_col_type & get_physicals() const
bool has_effective_shape() const
bool has_geometry_model() const
std::string get_material_ref() const
bool has_material_ref() const
void set_effective_relative_placement(const placement &)
std::map< std::string, const physical_volume * > physicals_col_type
Dictionary of (daughter) physical volumes.
Definition: logical_volume.h:46
bool has_daughter() const
Check if a daughter is available.
void set_daughter(const physical_volume &)
Set the daughter physical volume.
datatools::properties & grab_parameters()
std::string get_effective_material_ref() const
bool has_effective_material_ref() const
const physical_volume & get_physical(const std::string &name_) const
const std::string & get_daughter_name() const
Set the daughter name.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
std::map< std::string, const logical_volume * > dict_type
Definition: logical_volume.h:234
void set_abstract(bool a_)
Data structure resulting of the logical_volume::locate method.
Definition: logical_volume.h:49
Utilities for logging information.
The placement for a geometry volume with its translation and rotation with respect to some mother ref...
Definition: placement.h:34
bool has_position_in_daughter() const
Check if the position in the reference frame of the daughter volume is available.
const placement & get_effective_relative_placement() const
uint32_t get_shape_domain_flags() const
Return the shape domain flags.
void set_material_ref(const std::string &="")
void set_daughter_name(const std::string &)
Set the daughter name.
bool has_daughter_placement_index() const
Check if the daughter placement index is set.
static bool same(const logical_volume &log1_, const logical_volume &log2_, uint32_t mode_=0)
logical_volume()
Default constructor.
void set_position_in_daughter(const vector_3d &)
Set the position in the reference frame of the daughter volume.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125