Bayeux  3.4.1
Core Foundation library for SuperNEMO
extruded_box.h
Go to the documentation of this file.
1 /* Author(s): Arnaud Chapon <chapon@lpccaen.in2p3.fr>
3  * François Mauger <mauger@lpccaen.in2p3.fr>
4  * Creation date: 2014-10-27
5  * Last modified: 2015-03-23
6  *
7  * License:
8  *
9  * Description:
10  * Interface:
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_EXTRUDED_BOX_H
17 #define GEOMTOOLS_EXTRUDED_BOX_H 1
18 
19 // Third party:
20 // - Boost:
21 #include <boost/cstdint.hpp>
22 #include <boost/scoped_ptr.hpp>
23 // - Bayeux/datatools:
25 
26 // This project:
27 #include <geomtools/i_shape_3d.h>
28 #include <geomtools/i_stackable.h>
29 #include <geomtools/placement.h>
30 
31 namespace datatools {
32  // Forward class declaration:
33  class properties;
34 }
35 
36 namespace geomtools {
37 
38  // Forward class declaration:
39  class box;
40  class composite_surface;
41 
43  class extruded_box : public i_shape_3d,
44  public i_stackable
45  {
46 
47  public:
48 
50  static const std::string & extruded_box_label();
51 
68  | FACE_FRONT
69  | FACE_LEFT
70  | FACE_RIGHT
71  | FACE_BOTTOM
72  | FACE_TOP
79  };
80 
82  double get_xmin() const;
83 
85  double get_xmax() const;
86 
88  double get_ymin() const;
89 
91  double get_ymax() const;
92 
94  double get_zmin() const;
95 
97  double get_zmax() const;
98 
100  double get_x() const;
101 
103  void set_x(double);
104 
106  double get_half_x() const;
107 
109  void set_half_x(double);
110 
112  double get_y() const;
113 
115  void set_y(double);
116 
118  double get_half_y() const;
119 
121  void set_half_y(double);
122 
124  double get_z() const;
125 
127  void set_z(double);
128 
130  double get_half_z() const;
131 
133  void set_half_z(double);
134 
136  void set(double, double, double, double);
137 
139  void set_half(double, double, double, double);
140 
142  double get_thickness() const;
143 
145  void set_thickness(double);
146 
148  bool has_bottom() const;
149 
151  void set_bottom(bool);
152 
154  void add_bottom();
155 
157  void remove_bottom();
158 
160  bool has_top() const;
161 
163  void set_top(bool);
164 
166  void add_top();
167 
169  void remove_top();
170 
172  extruded_box();
173 
175  extruded_box(double x_, double y_, double z_, double t_,
176  bool has_top_ = true, bool has_bottom_ = true);
177 
179  virtual ~extruded_box();
180 
182  virtual std::string get_shape_name() const;
183 
184  // Check the validity of the object
185  bool is_valid() const;
186 
188  virtual void initialize(const datatools::properties &,
189  const handle_dict_type *);
190 
192  virtual void reset();
193 
195  double get_parameter(const std::string &) const;
196 
198  virtual double get_surface(uint32_t mask_ = FACE_ALL) const;
199 
201  virtual double get_volume(uint32_t flags_ = 0) const;
202 
204  virtual bool is_inside(const vector_3d &,
205  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
206 
208  virtual bool is_outside(const vector_3d &,
209  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
210 
212  virtual face_identifier on_surface(const vector_3d &,
213  const face_identifier & a_surface_mask = face_identifier::face_bits_any(),
214  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
215 
217  virtual vector_3d get_normal_on_surface(const vector_3d & a_position,
218  const face_identifier & a_surface_bit) const;
219 
221  friend std::ostream & operator<<( std::ostream &, const extruded_box & );
222 
224  friend std::istream & operator>>( std::istream &, extruded_box & );
225 
227  virtual bool find_intercept(const vector_3d & from_,
228  const vector_3d & direction_,
229  face_intercept_info & intercept_,
230  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
231 
233  virtual void tree_dump(std::ostream & out_ = std::clog,
234  const std::string & title_ = "",
235  const std::string & indent_ = "",
236  bool inherit_ = false) const;
237 
239  virtual unsigned int compute_faces(face_info_collection_type & faces_) const;
240 
242  void compute_outer_box(box & outer_box_) const;
243 
245  void compute_inner_box(box & inner_box_, placement & face_placement_) const;
246 
249  composite_surface & face_,
250  placement & face_placement_) const;
251 
259  };
260 
262  virtual void generate_wires_self(wires_type & wires_,
263  uint32_t options_ = 0) const;
264 
267 
268  protected:
269 
271  void _set_default();
272 
274  virtual void _build_bounding_data();
275 
276  private:
277 
278  double _x_;
279  double _y_;
280  double _z_;
281  double _thickness_;
282  bool _has_top_;
283  bool _has_bottom_;
284 
285  // // Work
286  // datatools::handle<box> _h_outer_box_;
287  // datatools::handle<box> _h_inner_box_;
288  // placement _inner_box_placement_;
289 
290  // Registration interface :
292 
293  };
294 
295 } // end of namespace geomtools
296 
298 // @arg geomtools::extruded_box the name the class with registered OCD support
300 
301 #endif // GEOMTOOLS_EXTRUDED_BOX_H
302 
303 /*
304 ** Local Variables: --
305 ** mode: c++ --
306 ** c-file-style: "gnu" --
307 ** tab-width: 2 --
308 ** End: --
309 */
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
void compute_outer_box(box &outer_box_) const
Compute the outer box.
extruded_box()
Default constructor.
static const uint32_t bit08
Definition: bit_mask.h:35
double get_x() const
Return the X dimension.
Definition: extruded_box.h:56
void set_half_y(double)
Set the half the Y dimension.
void set_z(double)
Set the Z dimension.
static const uint32_t bit07
Definition: bit_mask.h:34
Mother abstract class for all 3D solid shapes.
Definition: i_shape_3d.h:46
Definition: extruded_box.h:61
The abstract base class for all 2D shapes/surfaces.
Definition: composite_surface.h:26
Definition: extruded_box.h:65
void set_bottom(bool)
Set a bottom to the extruded box.
Definition: extruded_box.h:59
virtual void initialize(const datatools::properties &, const handle_dict_type *)
Initialize the extruded_box from properties.
double get_zmax() const
Return the max Z coordinates (bounding box)
Do not render the internal faces.
Definition: extruded_box.h:255
static const uint32_t bit01
Definition: bit_mask.h:28
static const uint32_t bit09
Definition: bit_mask.h:36
void compute_extruded_top_bottom_face(faces_mask_type face_id_, composite_surface &face_, placement &face_placement_) const
Compute the top face and placement.
static const uint32_t bit03
Definition: bit_mask.h:30
The 3D shape model for a box.
Definition: box.h:44
void _set_default()
Set default attributes.
bool has_bottom() const
Return if extruded box has a bottom.
Identifier of a face attached to a solid shape.
Definition: face_identifier.h:32
virtual void reset()
Reset.
double get_parameter(const std::string &) const
Return the value of some parameter given by name.
Rendering options bit mask.
Definition: extruded_box.h:257
void set_half_z(double)
Set the half the Z dimension.
static const uint32_t bit04
Definition: bit_mask.h:31
static const uint32_t bit06
Definition: bit_mask.h:33
friend std::ostream & operator<<(std::ostream &, const extruded_box &)
Print operator.
double get_xmax() const
Return the max X 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
Definition: extruded_box.h:66
void set_half(double, double, double, double)
Set the halves of all dimensions.
double get_z() const
Return the Z dimension.
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
void add_bottom()
Add a bottom to the extruded box.
double get_half_x() const
Return the half the X dimension.
virtual double get_surface(uint32_t mask_=FACE_ALL) const
Return the cumulated surface of the extruded_box given a list of faces.
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
faces_mask_type
Masks used for the 6 faces of the extruded_box.
Definition: extruded_box.h:53
virtual double get_volume(uint32_t flags_=0) const
Return the volume of the extruded_box.
static const uint32_t bit11
Definition: bit_mask.h:38
virtual bool is_inside(const vector_3d &, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is inside the extruded_box.
Abstract base stackable object.
Definition: i_stackable.h:32
void set_top(bool)
Set a top to the extruded box.
friend std::istream & operator>>(std::istream &, extruded_box &)
Read operator.
extruded_box_wires_rendering_option_type
3D rendering options
Definition: extruded_box.h:253
double get_ymin() const
Return the min Y coordinates (bounding box)
void set_thickness(double)
Set the thickness of extruded box.
The 3D shape model for an extruded box.
Definition: extruded_box.h:43
void set(double, double, double, double)
Set all dimensions.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
static void init_ocd(datatools::object_configuration_description &)
OCD support.
double get_zmin() const
Return the min Z coordinates (bounding box)
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)
static const face_identifier & face_bits_any()
Return a singleton face identifier with any bit.
void compute_inner_box(box &inner_box_, placement &face_placement_) const
Compute the inner box and its placement.
double get_ymax() const
Return the max Y coordinates (bounding box)
static const uint32_t bit10
Definition: bit_mask.h:37
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 bit02
Definition: bit_mask.h:29
static const uint32_t FACE_BITS_NONE
No valid or known face bit.
Definition: face_identifier.h:45
static const uint32_t bit05
Definition: bit_mask.h:32
virtual void _build_bounding_data()
Build the bounding data.
virtual bool is_outside(const vector_3d &, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is inside the extruded_box.
double get_xmin() const
Return the min X coordinates (bounding box)
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
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.
void remove_bottom()
Remove the bottom of the extruded box.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
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.
static const std::string & extruded_box_label()
Return the extruded_box shape label.
virtual unsigned int compute_faces(face_info_collection_type &faces_) const
Return a collection of face info objects.
Definition: extruded_box.h:63
Definition: extruded_box.h:67
bool has_top() const
Return if extruded box has a top.
double get_thickness() const
Return the thickness of extruded box.
Do not render the external faces.
Definition: extruded_box.h:254
Last defined bit.
Definition: i_wires_3d_rendering.h:62
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
double get_y() const
Return the Y dimension.
The placement for a geometry volume with its translation and rotation with respect to some mother ref...
Definition: placement.h:34
virtual ~extruded_box()
Destructor.
Definition: extruded_box.h:54
bool is_valid() const
Check the validity of the object.
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
Definition: extruded_box.h:58
void set_y(double)
Set the Y dimension.
void set_half_x(double)
Set the half the X dimension.
static const uint32_t bit00
Definition: bit_mask.h:27
Last defined bit.
Definition: extruded_box.h:256
virtual std::string get_shape_name() const
Return the name of the shape.
virtual bool find_intercept(const vector_3d &from_, const vector_3d &direction_, face_intercept_info &intercept_, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Find the intercept point of a segment with the extruded_box.
Definition: extruded_box.h:64
Definition: extruded_box.h:55
void remove_top()
Remove the top of the extruded box.
Definition: extruded_box.h:62
void set_x(double)
Set the X dimension.
double get_half_z() const
Return the half the Z dimension.
Definition: extruded_box.h:60
std::vector< face_info > face_info_collection_type
Type alias for a collection of face information objects.
Definition: face_info.h:168
void add_top()
Add a top to the extruded box.
double get_half_y() const
Return the half the Y dimension.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
Definition: extruded_box.h:57
A dictionary of arbitrary properties.
Definition: properties.h:125