Bayeux  3.4.1
Core Foundation library for SuperNEMO
geom_map.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-04-30
4  * Last modified: 2010-04-30
5  *
6  * License:
7  *
8  * Description:
9  * Geometry mapping of geom_id's
10  *
11  * A geometry map:
12  *
13  * History:
14  *
15  */
16 
17 #ifndef GEOMTOOLS_GEOM_MAP_H
18 #define GEOMTOOLS_GEOM_MAP_H 1
19 
20 // Standard library:
21 #include <cstdlib>
22 #include <stdexcept>
23 #include <iostream>
24 #include <sstream>
25 #include <string>
26 #include <vector>
27 #include <map>
28 #include <list>
29 #include <algorithm>
30 
31 // Third party:
32 // - Boost:
33 #include <boost/cstdint.hpp>
34 // - Bayeux/datatools:
35 #include <datatools/logger.h>
36 
37 // This project:
38 #include <geomtools/utils.h>
39 #include <geomtools/i_locator.h>
40 #include <geomtools/geom_id.h>
41 #include <geomtools/geom_info.h>
42 
43 namespace geomtools {
44 
45  class id_mgr;
46  class model_factory;
47 
48  class geom_map : public i_locator
49  {
50  public:
51 
52  typedef std::vector<const geom_info*> ginfo_ptr_collection_type;
53  typedef std::map<uint32_t, ginfo_ptr_collection_type> ginfo_collections_with_type_dict_type;
54 
55  protected:
56 
57  const id_mgr & _get_id_manager () const;
58 
59  const geom_info_dict_type & _get_geom_infos () const;
60 
62 
63  public:
64 
66 
68 
69  bool is_debug() const;
70 
71  void set_debug(bool);
72 
73  const id_mgr & get_id_manager () const;
74 
75  const geom_info_dict_type & get_geom_infos () const;
76 
77  geom_map ();
78 
79  virtual ~geom_map ();
80 
81  bool has_id_manager () const;
82 
83  void set_id_manager (const id_mgr & mgr_);
84 
85  const geom_id & get_invalid_geom_id () const;
86 
87  /*** i_locator interface ***/
88 
89  virtual bool validate_id (const geom_id & id_) const;
90 
91  virtual const geom_info & get_geom_info (const geom_id &) const;
92 
93  virtual const geom_id & get_geom_id (const vector_3d & world_position_,
94  int type_,
95  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
96 
97  virtual bool has_geom_info (const geom_id &) const;
98 
100  void compute_matching_geom_id (const geom_id & gid_pattern_,
101  std::vector<geom_id> & gids_,
102  bool append_ = false) const;
103 
104  const geom_info * get_geom_info_ptr (const geom_id &) const;
105 
106  void get_geom_id (const vector_3d & world_position_,
107  int type_,
108  geom_id & gid_,
109  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
110 
111  void get_geom_id (const vector_3d & world_position_,
112  const std::string & category_,
113  geom_id & gid_,
114  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
115 
116  virtual const geom_id & get_geom_id (const vector_3d & world_position_,
117  const std::string & category_,
118  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
119 
120  virtual void build_from (const model_factory & factory_,
121  const std::string & mother_ = "world");
122 
130  static bool check_inside (const geom_info & ginfo_,
131  const vector_3d & world_position_,
132  double tolerance_,
133  bool reverse_ = false);
134 
135  bool has_ginfo_collection_with_type (uint32_t type_) const;
136 
137  const ginfo_ptr_collection_type & get_ginfo_collection_with_type (uint32_t type_) const;
138 
139  private:
140 
142  // Note: instantiate at first use technique
143  const ginfo_ptr_collection_type & _compute_ginfo_collection_with_type_ (uint32_t type_);
144 
145  protected:
146 
148 
150 
151  private:
152 
153  geom_id _invalid_geom_id_;
154  const id_mgr * _id_manager_;
155  geom_info_dict_type _geom_infos_;
156 
157  ginfo_collections_with_type_dict_type _geom_infos_with_type_map_;
158 
159  };
160 
161 } // end of namespace geomtools
162 
163 #endif // GEOMTOOLS_GEOM_MAP_H
164 
165 /*
166 ** Local Variables: --
167 ** mode: c++ --
168 ** c-file-style: "gnu" --
169 ** tab-width: 2 --
170 ** End: --
171 */
const geom_info_dict_type & get_geom_infos() const
const geom_id & get_invalid_geom_id() const
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
Definition: i_locator.h:42
virtual const geom_id & get_geom_id(const vector_3d &world_position_, int type_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
datatools::logger::priority get_logging_priority() const
const geom_info_dict_type & _get_geom_infos() const
virtual const geom_info & get_geom_info(const geom_id &) const
Given a geometry ID, returns the associated geom_info instance (from some internal table).
A record for geometry information about a physical volume in a virtual geometry.
Definition: geom_info.h:38
void set_logging_priority(datatools::logger::priority)
const ginfo_collections_with_type_dict_type & get_geom_infos_with_type_map() const
void set_debug(bool)
bool has_id_manager() const
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
std::map< geom_id, geom_info > geom_info_dict_type
Dictionary of geometry information objects (key type is: geomtools::geom_id)
Definition: geom_info.h:105
bool is_debug() const
bool has_ginfo_collection_with_type(uint32_t type_) const
virtual bool validate_id(const geom_id &id_) const
Given a geometry ID, check if it is valid (known within some internal table).
Definition: id_mgr.h:37
virtual bool has_geom_info(const geom_id &) const
Definition: geom_map.h:48
const ginfo_ptr_collection_type & get_ginfo_collection_with_type(uint32_t type_) const
const geom_info * get_geom_info_ptr(const geom_id &) const
void compute_matching_geom_id(const geom_id &gid_pattern_, std::vector< geom_id > &gids_, bool append_=false) const
Compute the list of GIDs matching a given GID pattern (including 'ANY' addresses)
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
virtual void build_from(const model_factory &factory_, const std::string &mother_="world")
static bool check_inside(const geom_info &ginfo_, const vector_3d &world_position_, double tolerance_, bool reverse_=false)
Utilities for logging information.
The factory of geometry models.
Definition: model_factory.h:40
void set_id_manager(const id_mgr &mgr_)
Definition: geom_id.h:41
const id_mgr & get_id_manager() const
std::map< uint32_t, ginfo_ptr_collection_type > ginfo_collections_with_type_dict_type
Definition: geom_map.h:53
datatools::logger::priority _logging
Definition: geom_map.h:149
const id_mgr & _get_id_manager() const
std::vector< const geom_info * > ginfo_ptr_collection_type
Definition: geom_map.h:52
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39