Bayeux  3.4.1
Core Foundation library for SuperNEMO
box.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-02-15
5  *
6  * License:
7  *
8  * Description:
9  *
10  * Box solid shape
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_BOX_H
17 #define GEOMTOOLS_BOX_H 1
18 
19 // Standard library:
20 #include <vector>
21 
22 // Third party:
23 // - Boost:
24 #include <boost/cstdint.hpp>
25 // - Bayeux/datatools:
27 
28 // This project:
29 #include <geomtools/i_shape_3d.h>
30 #include <geomtools/i_stackable.h>
31 #include <geomtools/placement.h>
32 
33 namespace datatools {
34  // Forward class declaration:
35  class properties;
36 }
37 
38 namespace geomtools {
39 
40  // Class forward declarations:
41  class rectangle;
42 
44  class box : public i_shape_3d ,
45  public i_stackable
46  {
47 
48  public:
49 
51  static const std::string & box_label();
52 
56  _FACE_BEGIN = 0x1,
57  FACE_BACK = 0x1,
58  FACE_FRONT = 0x2,
59  FACE_LEFT = 0x4,
60  FACE_RIGHT = 0x8,
61  FACE_BOTTOM = 0x10,
62  FACE_TOP = 0x20,
63  _FACE_END = 0x40,
65  | FACE_FRONT
66  | FACE_LEFT
67  | FACE_RIGHT
68  | FACE_BOTTOM
69  | FACE_TOP)
70  };
71 
73  double get_xmin() const;
74 
76  double get_xmax() const;
77 
79  double get_ymin() const;
80 
82  double get_ymax() const;
83 
85  double get_zmin() const;
86 
88  double get_zmax() const;
89 
91  double get_x() const;
92 
94  void set_x(double);
95 
97  double get_half_x() const;
98 
100  void set_half_x(double);
101 
103  double get_y() const;
104 
106  void set_y(double);
107 
109  double get_half_y() const;
110 
112  void set_half_y(double);
113 
115  double get_z() const;
116 
118  void set_z(double);
119 
121  double get_half_z() const;
122 
124  void set_half_z(double);
125 
127  void set(double, double, double);
128 
130  void set_half(double, double, double);
131 
133  box();
134 
136  box(double a_x, double a_y, double a_z);
137 
139  virtual ~box();
140 
142  virtual std::string get_shape_name() const;
143 
144  // Check the validity of the object
145  bool is_valid() const;
146 
148  virtual void initialize(const datatools::properties &, const handle_dict_type * = 0);
149 
151  virtual void reset();
152 
154  double get_parameter(const std::string &) const;
155 
157  virtual double get_surface(uint32_t a_mask = FACE_ALL) const;
158 
160  virtual double get_volume(uint32_t flags_ = 0) const;
161 
163  virtual unsigned int compute_faces(face_info_collection_type & faces_) const;
164 
166  virtual bool is_inside(const vector_3d &,
167  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
168 
170  virtual bool is_outside(const vector_3d &,
171  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
172 
174  virtual face_identifier on_surface(const vector_3d &,
175  const face_identifier & a_surface_mask = face_identifier::face_bits_any(),
176  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
177 
179  virtual vector_3d get_normal_on_surface(const vector_3d & a_position,
180  const face_identifier & a_surface_bit) const;
181 
183  friend std::ostream & operator<<( std::ostream & , const box & );
184 
186  friend std::istream & operator>>( std::istream & , box & );
187 
189  virtual bool find_intercept(const vector_3d & a_from,
190  const vector_3d & a_direction,
191  face_intercept_info & a_intercept,
192  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
193 
195  virtual void tree_dump(std::ostream & a_out = std::clog,
196  const std::string & a_title = "",
197  const std::string & a_indent = "",
198  bool a_inherit = false) const;
199 
215  };
216 
218  virtual void generate_wires_self(wires_type & wires_,
219  uint32_t options_ = 0) const;
220 
222  void compute_vertexes(std::vector<vector_3d> & vv_) const;
223 
225  void compute_transformed_vertexes(const placement & p_, std::vector<vector_3d> & vv_) const;
226 
228  void compute_face(faces_mask_type face_id_,
229  rectangle & face_,
230  placement & face_placement_) const;
231 
234 
235  protected:
236 
238  void _set_defaults();
239 
241  virtual void _build_bounding_data();
242 
243  private:
244 
245  double _x_;
246  double _y_;
247  double _z_;
248 
249  // Registration interface :
251 
252  };
253 
254 } // end of namespace geomtools
255 
257 // @param geomtools::box the name of the class with registered OCD support
259 
260 #endif // GEOMTOOLS_BOX_H
261 
262 /*
263 ** Local Variables: --
264 ** mode: c++ --
265 ** c-file-style: "gnu" --
266 ** tab-width: 2 --
267 ** End: --
268 */
void set_half_x(double)
Set the half the X dimension.
box()
Default constructor.
void compute_vertexes(std::vector< vector_3d > &vv_) const
Compute the positions of the 8 vertexes of the box.
void _set_defaults()
Set default attributes.
Mother abstract class for all 3D solid shapes.
Definition: i_shape_3d.h:46
Last defined bit.
Definition: box.h:208
virtual face_identifier on_surface(const vector_3d &, const face_identifier &a_surface_mask=face_identifier::face_bits_any(), double a_skin=GEOMTOOLS_PROPER_TOLERANCE) const
Return the surface bit a point belongs to.
double get_ymax() const
Return the max Y coordinates (bounding box)
void set_z(double)
Set the Z dimension.
void set_half_z(double)
Set the half the Z dimension.
void set_x(double)
Set the X dimension.
The 3D shape model for a box.
Definition: box.h:44
Identifier of a face attached to a solid shape.
Definition: face_identifier.h:32
void set_half(double, double, double)
Set the halves of all dimensions.
Rendering options bit mask.
Definition: box.h:209
Do not render the Z- (bottom) face.
Definition: box.h:206
virtual bool is_outside(const vector_3d &, double a_skin=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is inside the box.
double get_xmin() const
Return the min X coordinates (bounding box)
double get_ymin() const
Return the min Y coordinates (bounding box)
An object that describes the way an object of a given class can be configured through properties.
Definition: object_configuration_description.h:234
double get_half_x() const
Return the half the X dimension.
friend std::ostream & operator<<(std::ostream &, const box &)
Print operator.
double get_z() const
Return the Z dimension.
void compute_face(faces_mask_type face_id_, rectangle &face_, placement &face_placement_) const
Compute an arbitrary face.
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a list of polylines representing the contour of the shape (for display clients)
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
Definition: box.h:58
virtual double get_surface(uint32_t a_mask=FACE_ALL) const
Return the cumulated surface of the box given a list of faces.
Definition: box.h:55
box_wires_rendering_option_type
3D rendering options
Definition: box.h:201
Abstract base stackable object.
Definition: i_stackable.h:32
void set(double, double, double)
Set all dimensions.
Definition: box.h:63
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
Do not render the Y+ (right) face.
Definition: box.h:205
static const face_identifier & face_bits_any()
Return a singleton face identifier with any bit.
Definition: box.h:60
Do not render the X+ (front) face.
Definition: box.h:203
Definition: box.h:57
virtual unsigned int compute_faces(face_info_collection_type &faces_) const
Return a collection of face info objects.
Do not render the X- (back) face.
Definition: box.h:202
double get_zmin() const
Return the min Z coordinates (bounding box)
Do not render the Z+ (top) face.
Definition: box.h:207
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
static const uint32_t FACE_BITS_NONE
No valid or known face bit.
Definition: face_identifier.h:45
virtual double get_volume(uint32_t flags_=0) const
Return the volume of the box.
Definition: box.h:56
virtual void _build_bounding_data()
Build the bounding data.
virtual void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize the box from properties.
virtual ~box()
Destructor.
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
static const std::string & box_label()
Return the box shape label.
Definition: box.h:64
virtual void reset()
Reset.
double get_xmax() const
Return the max X coordinates (bounding box)
double get_half_z() const
Return the half the Z dimension.
virtual void tree_dump(std::ostream &a_out=std::clog, const std::string &a_title="", const std::string &a_indent="", bool a_inherit=false) const
Smart print.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
static void init_ocd(datatools::object_configuration_description &)
OCD support.
faces_mask_type
Masks used for the 6 faces of the box.
Definition: box.h:54
A rectangular surface (2D shape)
Definition: rectangle.h:30
virtual bool find_intercept(const vector_3d &a_from, const vector_3d &a_direction, face_intercept_info &a_intercept, double a_skin=GEOMTOOLS_PROPER_TOLERANCE) const
Find the intercept point of a segment with the box.
virtual std::string get_shape_name() const
Return the name of the shape.
Last defined bit.
Definition: i_wires_3d_rendering.h:62
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Definition: box.h:59
double get_zmax() const
Return the max Z coordinates (bounding box)
The placement for a geometry volume with its translation and rotation with respect to some mother ref...
Definition: placement.h:34
Do not render the Y- (left) face.
Definition: box.h:204
Definition: box.h:62
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
double get_x() const
Return the X dimension.
Definition: box.h:61
void set_half_y(double)
Set the half the Y dimension.
void compute_transformed_vertexes(const placement &p_, std::vector< vector_3d > &vv_) const
Compute the positions of the 8 vertexes in a given transformation.
friend std::istream & operator>>(std::istream &, box &)
Read operator.
double get_y() const
Return the Y dimension.
virtual bool is_inside(const vector_3d &, double a_skin=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is inside the box.
bool is_valid() const
Check the validity of the object.
virtual vector_3d get_normal_on_surface(const vector_3d &a_position, const face_identifier &a_surface_bit) const
Return the vector normal to the surface at some position.
double get_half_y() const
Return the half the Y dimension.
std::vector< face_info > face_info_collection_type
Type alias for a collection of face information objects.
Definition: face_info.h:168
void set_y(double)
Set the Y dimension.
double get_parameter(const std::string &) const
Return the value of some parameter given by name.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125