Bayeux  3.4.1
Core Foundation library for SuperNEMO
smart_id_locator.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-05-30
4  * Last modified: 2010-05-30
5  *
6  * License:
7  *
8  * Description:
9  * A smart geometry locator based on a geom_map and optimized for fast search
10  *
11  * History:
12  *
13  */
14 
15 #ifndef GEOMTOOLS_SMART_ID_LOCATOR_H
16 #define GEOMTOOLS_SMART_ID_LOCATOR_H 1
17 
18 // Standard library:
19 #include <iostream>
20 #include <string>
21 #include <list>
22 
23 // Third party:
24 // - Boost:
25 #include <boost/cstdint.hpp>
26 
27 // This project:
28 #include <geomtools/i_locator.h>
29 #include <geomtools/id_selector.h>
30 
31 namespace geomtools {
32 
33  class geom_map;
34 
36  class smart_id_locator : public i_locator
37  {
38  public:
39 
41  enum mode_type {
43  MODE_LAST = 1,
45  };
46 
49 
51 
53  bool is_initialized () const;
54 
56  void set_gmap (const geom_map & gmap_);
57 
60 
62  smart_id_locator (const geom_map & gmap_);
63 
65  smart_id_locator (const geom_map & gmap_,
66  uint32_t type_,
67  int mode_ = MODE_DEFAULT);
68 
70  smart_id_locator (const geom_map & gmap_,
71  const std::string & rules_,
72  int mode_ = MODE_DEFAULT);
73 
75  virtual ~smart_id_locator ();
76 
78  void initialize (uint32_t type_, int mode_ = MODE_DEFAULT);
79 
81  void initialize (const std::string & selection_rules_, int mode_ = MODE_DEFAULT);
82 
84  void reset ();
85 
87  const std::list<const geom_info *> & get_ginfos () const;
88 
90  virtual bool validate_id (const geom_id & id_) const;
91 
93  virtual const geom_info & get_geom_info (const geom_id & id_) const;
94 
96  virtual const geom_id & get_geom_id (const vector_3d & world_position_,
97  int type_ = geom_id::INVALID_TYPE,
98  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
99 
101  void tree_dump(std::ostream & out_ = std::clog,
102  const std::string & title_ = "",
103  const std::string & indent_ = "",
104  bool inherit_ = false) const;
105 
107  void dump(std::ostream & out_ = std::clog) const;
108 
110  void print_infos(std::ostream & out_) const;
111 
112  protected:
113 
115  void _construct ();
116 
117  private:
118 
119  datatools::logger::priority _logging_priority_;
120  bool _initialized_;
121  int _mode_;
122  uint32_t _type_;
123  id_selector _idsel_;
124  const geom_map * _gmap_;
125 
126  // Optimization data
127  std::list<const geom_info *> _ginfos_;
128  const geom_info * _last_found_;
129 
130  };
131 
132 } // end of namespace geomtools
133 
134 #endif // GEOMTOOLS_SMART_ID_LOCATOR_H
135 
136 /*
137 ** Local Variables: --
138 ** mode: c++ --
139 ** c-file-style: "gnu" --
140 ** tab-width: 2 --
141 ** End: --
142 */
virtual const geom_info & get_geom_info(const geom_id &id_) const
Retrieve the geometry info object from its geometry Id.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
Definition: i_locator.h:42
bool is_initialized() const
Check Initialization flag.
Definition: smart_id_locator.h:42
smart_id_locator()
Constructor.
const std::list< const geom_info * > & get_ginfos() const
Get the list of geometry info object handles.
A record for geometry information about a physical volume in a virtual geometry.
Definition: geom_info.h:38
Definition: smart_id_locator.h:44
virtual const geom_id & get_geom_id(const vector_3d &world_position_, int type_=geom_id::INVALID_TYPE, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Retrieve the geometry Id of the volume from the world position.
virtual bool validate_id(const geom_id &id_) const
Check if a given geom Id is valid.
Definition: smart_id_locator.h:43
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
Locator of geometry volumes by thier geometry Id.
Definition: smart_id_locator.h:36
Definition: geom_map.h:48
datatools::logger::priority get_logging_priority() const
Get logging priority threshold.
virtual ~smart_id_locator()
Destructor.
mode_type
Mode.
Definition: smart_id_locator.h:41
void set_logging_priority(datatools::logger::priority)
void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
A selector of geometry IDs using a specific geometry category.
Definition: id_selector.h:34
void dump(std::ostream &out_=std::clog) const
Dump.
void print_infos(std::ostream &out_) const
Print.
Definition: geom_id.h:41
void initialize(uint32_t type_, int mode_=MODE_DEFAULT)
Initialize the locator from the geometry type.
static const uint32_t INVALID_TYPE
Definition: geom_id.h:45
void set_gmap(const geom_map &gmap_)
Set the reference geometry map.
void reset()
Reset the locator.
void _construct()
Construction.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39