Bayeux  3.4.1
Core Foundation library for SuperNEMO
i_object_3d.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: 2015-04-25
5  *
6  * License:
7  *
8  * Description:
9  *
10  * Interface for object than can be described in a 3D reference frame
11  * and possibly drawn with some graphics renderer.
12  *
13  * History:
14  *
15  */
16 
17 #ifndef GEOMTOOLS_I_OBJECT_3D_H
18 #define GEOMTOOLS_I_OBJECT_3D_H 1
19 
21 #include <string>
22 #include <iostream>
23 #include <sstream>
24 #include <map>
25 
26 // Third party:
27 // - Bayeux/datatools:
28 #include <datatools/ocd_macros.h>
29 #include <datatools/handle.h>
30 #include <datatools/i_tree_dump.h>
32 #include <datatools/logger.h>
33 
34 // This project:
35 #include <geomtools/utils.h>
37 
38 namespace datatools {
39  // Forward class declaration:
40  class properties;
41 }
42 
43 namespace geomtools {
44 
45  // Forward declaration:
46  class box;
47 
49  class i_object_3d :
52  {
53  public:
54 
61  };
62 
65 
68  {
69  public:
70 
72  object_entry();
73 
75  ~object_entry();
76 
78  void reset();
79 
81  void set_name(const std::string &);
82 
84  const std::string & get_name() const;
85 
87  void set_type_id(const std::string & type_id_);
88 
90  const std::string & get_type_id() const;
91 
93  void set_status(uint32_t);
94 
96  uint32_t get_status() const;
97 
99  const datatools::properties & get_config() const;
100 
103 
105  bool has_object() const;
106 
108  const i_object_3d & get_object() const;
109 
111  void set_object(i_object_3d *);
112 
113  private:
114 
115  std::string _name_;
116  std::string _type_id_;
117  uint32_t _status_;
118  datatools::properties _config_;
119  handle_type _hobject_;
120 
121  };
122 
124  typedef std::map<std::string, object_entry> handle_dict_type;
125 
127  virtual int get_dimensional() const = 0;
128 
130  virtual std::string get_shape_name() const = 0;
131 
133  virtual bool is_valid() const = 0;
134 
137 
140 
142  bool has_wires_drawer() const;
143 
145  void set_wires_drawer(i_wires_3d_rendering & wires_drawer_);
146 
148  void reset_wires_drawer();
149 
152 
154  const i_wires_3d_rendering & get_wires_drawer() const;
155 
157  double compute_tolerance(double tolerance_) const;
158 
160  double compute_angular_tolerance(double angular_tolerance_) const;
161 
163  double get_tolerance() const;
164 
166  void set_tolerance(double tolerance_);
167 
169  double get_angular_tolerance() const;
170 
172  void set_angular_tolerance(double tolerance_);
173 
175  virtual bool is_composite() const;
176 
178  i_object_3d();
179 
181  i_object_3d(double tolerance_);
182 
184  i_object_3d(double tolerance_, double angular_tolerance_);
185 
187  i_object_3d(const i_object_3d &);
188 
190  i_object_3d & operator=(const i_object_3d &);
191 
193  virtual ~i_object_3d();
194 
196  void initialize_simple();
197 
199  virtual void initialize(const datatools::properties &, const handle_dict_type * = 0);
200 
202  virtual void reset();
203 
205  virtual void tree_dump(std::ostream & out_ = std::clog,
206  const std::string & title_ = "",
207  const std::string & indent_ = "",
208  bool inherit_ = false) const;
209 
212 
213  protected:
214 
216  void _set_defaults();
217 
219  void _initialize(const datatools::properties &, const handle_dict_type * = 0);
220 
222  void _reset();
223 
224  private:
225 
226  // Parameters:
227  datatools::logger::priority _logging_priority_;
228  double _tolerance_;
229  double _angular_tolerance_;
230 
231  // Work:
232  i_wires_3d_rendering * _wires_drawer_;
233 
234  // Serialization interface
236 
237  // Factory stuff :
239 
240  public:
241 
243  class i_getter
244  {
245  public:
246 
247  virtual ~i_getter();
248 
249  virtual const i_object_3d * get(const std::string & name_,
250  const datatools::properties & params_) = 0;
251 
252  const i_object_3d * get(const std::string & name_);
253 
254  };
255 
256  };
257 
258 } // end of namespace geomtools
259 
260 #define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName) \
261  private: \
262  DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE(::geomtools::i_object_3d,ModelClassName) \
263 
264 
265 #define GEOMTOOLS_OBJECT_3D_REGISTRATION_IMPLEMENT(ModelClassName,ModelClassId) \
266  DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION(::geomtools::i_object_3d,ModelClassName,ModelClassId) \
267 
268 
269 /*
270 // Class version:
271 #include <boost/serialization/version.hpp>
272 BOOST_CLASS_VERSION(geomtools::i_object_3d, 0)
273 */
274 
275 #endif // GEOMTOOLS_I_OBJECT_3D_H
276 
277 /*
278 ** Local Variables: --
279 ** mode: c++ --
280 ** c-file-style: "gnu" --
281 ** tab-width: 2 --
282 ** End: --
283 */
Mother abstract class for all 3D object classes.
Definition: i_object_3d.h:49
No dimension object (example: a vertex)
Definition: i_object_3d.h:57
virtual ~i_object_3d()
Destructor.
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
~object_entry()
Destructor.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
void set_logging_priority(datatools::logger::priority)
Set the logging priority threshold.
i_wires_3d_rendering & grab_wires_drawer()
Return a wires drawer.
virtual void reset()
Reset.
void _set_defaults()
Set default values for attributes.
void set_object(i_object_3d *)
Set object handle.
dimensional_type
Known dimensions.
Definition: i_object_3d.h:56
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
Object 3D abstract getter class.
Definition: i_object_3d.h:243
const T & get(const service_dict_type &services_, const std::string &service_name_)
Definition: service_tools-inl.h:75
An entry that stores a 3D object.
Definition: i_object_3d.h:67
bool has_object() const
Check object.
virtual std::string get_shape_name() const =0
Return the name of the shape.
void set_tolerance(double tolerance_)
Set the distance tolerance.
An object that describes the way an object of a given class can be configured through properties.
Definition: object_configuration_description.h:234
const std::string & get_type_id() const
Return the type identifier of the object.
void set_angular_tolerance(double tolerance_)
Set the angular tolerance.
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
void set_wires_drawer(i_wires_3d_rendering &wires_drawer_)
Set a wires drawer.
double compute_angular_tolerance(double angular_tolerance_) const
Return the angular tolerance.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
const std::string & get_name() const
Return the name of the object.
virtual bool is_valid() const =0
Check the validity of the object.
virtual bool is_composite() const
Check if the object is composite.
void reset_wires_drawer()
Reset the wires drawer.
void set_status(uint32_t)
Set status.
virtual void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize from properties and a dictionary of 3D-objects.
void _initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize from properties.
Three dimension object (example: a box)
Definition: i_object_3d.h:60
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
object_entry()
Default constructor.
brief Abstract interface for objects that can describe themselves as a collection of polylines for 3D...
Definition: i_wires_3d_rendering.h:39
void set_name(const std::string &)
Set the name.
i_object_3d()
Default constructor.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Utilities for logging information.
void initialize_simple()
Initialize the 3D object.
const i_wires_3d_rendering & get_wires_drawer() const
Return a wires drawer.
datatools::logger::priority get_logging_priority() const
Return the logging priority threshold.
void reset()
Reset.
const i_object_3d & get_object() const
Return the reference to the object.
datatools::handle< i_object_3d > handle_type
A handle to a 3D object.
Definition: i_object_3d.h:64
datatools::properties & grab_config()
Return the reference to the configuration.
i_object_3d & operator=(const i_object_3d &)
Assignment operator.
double compute_tolerance(double tolerance_) const
Return the distance tolerance.
bool has_wires_drawer() const
Check is a wires drawer is available.
void set_type_id(const std::string &type_id_)
Set the type identifier of the object.
#define DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE(BaseType)
Declaration of a system (allocator/functor) factory register as a static member of a base class and s...
Definition: factory_macros.h:52
One dimension object (example: a segment)
Definition: i_object_3d.h:58
double get_angular_tolerance() const
Return the angular tolerance.
const datatools::properties & get_config() const
Return the reference to the configuration.
virtual int get_dimensional() const =0
Return the dimension of the object.
static void init_ocd(datatools::object_configuration_description &)
OCD support.
double get_tolerance() const
Return the distance tolerance.
uint32_t get_status() const
Return status.
Two dimension object (example: a rectangle)
Definition: i_object_3d.h:59
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125