Bayeux  3.4.1
Core Foundation library for SuperNEMO
polycone.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-03-14
4  * Last modified: 2015-03-12
5  *
6  * License:
7  *
8  * Description:
9  *
10  * Polycone 3D solid shape
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_POLYCONE_H
17 #define GEOMTOOLS_POLYCONE_H 1
18 
19 // Standard library:
20 #include <iostream>
21 #include <string>
22 #include <map>
23 #include <limits>
24 
25 // This project:
26 #include <geomtools/i_shape_3d.h>
27 #include <geomtools/i_stackable.h>
29 
30 namespace geomtools {
31 
32  // Forward class declaration:
33  class right_circular_conical_nappe;
34  class quadrangle;
35  class disk;
36  class composite_surface;
37 
39  class polycone : public i_shape_3d,
40  public i_stackable
41  {
42  public:
43 
45  static const std::string & polycone_label();
46 
58  | FACE_BOTTOM
59  | FACE_TOP
62  };
63 
66  RMIN_RMAX = 0,
69  };
70 
72  struct r_min_max
73  {
74  double rmin;
75  double rmax;
76  };
77 
79  struct frustrum_data {
80  // Bottom parameters:
81  double z1, a1, b1;
82  // Top parameters:
83  double z2, a2, b2;
84  };
85 
86  // Type alias
87  typedef std::map<double, r_min_max> rz_col_type;
88 
90  bool is_extruded () const;
91 
93  double get_xmin () const;
94 
96  double get_xmax () const;
97 
99  double get_ymin () const;
100 
102  double get_ymax () const;
103 
105  double get_zmin () const;
106 
108  double get_zmax () const;
109 
111  double get_z () const;
112 
114  bool has_partial_angle() const;
115 
117  bool has_start_angle() const;
118 
120  void set_start_angle(double);
121 
123  double get_start_angle() const;
124 
126  bool has_delta_angle() const;
127 
129  void set_delta_angle(double);
130 
132  double get_delta_angle() const;
133 
135  unsigned int number_of_frustra() const;
136 
138  void get_frustrum_data(size_t i_, frustrum_data &) const;
139 
141  const rz_col_type & points() const;
142 
144  polycone ();
145 
147  virtual ~polycone ();
148 
150  virtual std::string get_shape_name() const;
151 
153  bool is_valid () const;
154 
156  void add(double z_, double rmax_, bool compute_ = true);
157 
159  void add(double z_, double rmin_, double rmax_, bool compute_ = true);
160 
162  void initialize ();
163 
165  void initialize (const std::string & filename_);
166 
203  void initialize (const std::string & filename_,
204  double zmin_ = std::numeric_limits<double>::quiet_NaN (),
205  double zmax_ = std::numeric_limits<double>::quiet_NaN (),
206  int mode_ = RMIN_RMAX);
207 
209  virtual void initialize (const datatools::properties & setup_, const handle_dict_type * = 0);
210 
212  virtual void reset ();
213 
215  bool has_top_face() const;
216 
218  bool has_bottom_face() const;
219 
221  bool has_inner_face() const;
222 
224  bool has_angle_faces() const;
225 
227  void compute_top_face(disk & top_disk_, placement &) const;
228 
230  void compute_bottom_face(disk & bottom_disk_, placement &) const;
231 
233  void compute_frustrum(right_circular_conical_frustrum & f_, placement &, int index_) const;
234 
236  void compute_inner_face(right_circular_conical_nappe & in_, placement &, int index_) const;
237 
239  void compute_outer_face(right_circular_conical_nappe & on_, placement &, int index_) const;
240 
242  get_start_stop_angle_face_type(int index_) const;
243 
245  void compute_start_angle_face(quadrangle & qface_, triangle & tface_, placement &, int index_) const;
246 
248  void compute_stop_angle_face(quadrangle & qface_, triangle & tface_, placement &, int index_) const;
249 
251  void compute_outer_face(composite_surface & face_, placement &) const;
252 
254  void compute_inner_face(composite_surface & face_, placement &) const;
255 
258 
260  void compute_stop_angle_face(composite_surface & face_, placement &) const;
261 
263  virtual unsigned int compute_faces(face_info_collection_type &) const;
264 
266  void compute_inner_polycone (polycone & ip_);
267 
269  void compute_outer_polycone (polycone & op_);
270 
272  virtual double get_volume (uint32_t flags_ = 0) const;
273 
275  virtual double get_surface (uint32_t mask_ = FACE_ALL) const;
276 
278  double get_z_min () const;
279 
281  double get_z_max () const;
282 
284  double get_r_max () const;
285 
287  double get_parameter ( const std::string & flag_ ) const;
288 
290  virtual bool is_inside (const vector_3d &,
291  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
292 
294  virtual bool is_outside (const vector_3d &,
295  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
296 
298  virtual face_identifier on_surface(const vector_3d &,
299  const face_identifier & a_surface_mask = face_identifier::face_bits_any(),
300  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
301 
303  virtual vector_3d get_normal_on_surface (const vector_3d & position_,
304  const face_identifier & ) const;
305 
307  virtual bool find_intercept(const vector_3d & from_,
308  const vector_3d & direction_,
309  face_intercept_info & intercept_,
310  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
311 
312  // Smart print
313  virtual void tree_dump (std::ostream & out_ = std::clog,
314  const std::string & title_ = "",
315  const std::string & indent_ = "",
316  bool inherit_ = false) const;
317 
318  friend std::ostream & operator<< (std::ostream &, const polycone &);
319 
320  friend std::istream & operator>> (std::istream &, polycone &);
321 
337  };
338 
340  virtual void generate_wires_self(wires_type & wires_, uint32_t options_ = 0) const;
341 
342  protected:
343 
345  virtual void _build_bounding_data();
346 
348  void _set_defaults();
349 
351  virtual void _at_lock();
352 
353  private:
354 
355  void _compute_surfaces_();
356 
357  void _compute_volume_();
358 
359  void _compute_limits_();
360 
361  void _compute_misc_();
362 
363  void _compute_all_();
364 
365  // Interpolation:
366  void _build_from_envelope_and_skin_ (double thickness_,
367  double step_,
368  double zmin_,
369  double zmax_);
370 
371  void _build_from_envelope_and_skin_ (double thickness_, double step_ = 0.0);
372 
373  private:
374 
375  // Parameters:
376  rz_col_type _points_;
377  double _start_angle_;
378  double _delta_angle_;
379 
380  // Working data:
381  bool _computed_;
382  boost::logic::tribool _has_top_face_;
383  boost::logic::tribool _has_bottom_face_;
384  boost::logic::tribool _has_inner_face_;
385  double _top_surface_;
386  double _bottom_surface_;
387  double _outer_side_surface_;
388  double _inner_side_surface_;
389  double _start_angle_surface_;
390  double _stop_angle_surface_;
391  double _outer_volume_;
392  double _inner_volume_;
393  double _volume_;
394  double _z_min_;
395  double _z_max_;
396  double _r_max_;
397  bool _extruded_;
398 
399  // Registration interface :
401 
402  };
403 
404 } // end of namespace geomtools
405 
406 #endif // GEOMTOOLS_POLYCONE_H
407 
408 /*
409 ** Local Variables: --
410 ** mode: c++ --
411 ** c-file-style: "gnu" --
412 ** tab-width: 2 --
413 ** End: --
414 */
double rmax
Rmax.
Definition: polycone.h:75
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)
Right circular conical frustrum (3D shape)
Definition: right_circular_conical_frustrum.h:32
ssaf_type
Start/stop angle face type.
Definition: right_circular_conical_frustrum.h:202
void set_delta_angle(double)
Set the delta phi angle.
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 with a face of the frustrum.
double get_ymin() const
Return the Y min.
void add(double z_, double rmax_, bool compute_=true)
Add a new point with only Rmax.
Definition: polycone.h:55
Last defined bit.
Definition: polycone.h:330
Right circular conical nappe (2D shape)
Definition: right_circular_conical_nappe.h:29
Definition: polycone.h:54
void set_start_angle(double)
Set the start phi angle.
static const std::string & polycone_label()
Return the identifier label for the class.
right_circular_conical_frustrum::ssaf_type get_start_stop_angle_face_type(int index_) const
Mother abstract class for all 3D solid shapes.
Definition: i_shape_3d.h:46
The abstract base class for all 2D shapes/surfaces.
Definition: composite_surface.h:26
double get_z_max() const
Return the max Z.
Polycone 3D solid shape.
Definition: polycone.h:39
Use one first column for Rmin and second one for Rmax.
Definition: polycone.h:66
virtual double get_volume(uint32_t flags_=0) const
Compute the volume.
virtual void _at_lock()
Executed at lock stage.
double a2
Definition: polycone.h:83
double get_r_max() const
Return the max eadius.
bool has_partial_angle() const
Check if the nappe has partial phi angle.
void compute_outer_polycone(polycone &op_)
Compute the outer polycone.
static const uint32_t bit01
Definition: bit_mask.h:28
static const uint32_t bit03
Definition: bit_mask.h:30
Identifier of a face attached to a solid shape.
Definition: face_identifier.h:32
virtual bool is_inside(const vector_3d &, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is inside the frustrum.
friend std::istream & operator>>(std::istream &, polycone &)
bool is_valid() const
Check if the solid is valid.
static const uint32_t bit04
Definition: bit_mask.h:31
Do not render the inner face.
Definition: polycone.h:326
double z1
Definition: polycone.h:81
Data describing one frustrum.
Definition: polycone.h:79
bool has_angle_faces() const
Check for angle faces.
bool has_inner_face() const
Check for an inner face.
Do not render the stop angle face.
Definition: polycone.h:329
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
double get_zmin() const
Return the Z min.
unsigned int number_of_frustra() const
Return the number of frustra.
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
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.
Definition: polycone.h:56
Abstract base stackable object.
Definition: i_stackable.h:32
void compute_bottom_face(disk &bottom_disk_, placement &) const
Compute the bottom face.
double get_xmax() const
Return the X max.
void get_frustrum_data(size_t i_, frustrum_data &) const
Compute frustrum data at given index.
virtual std::string get_shape_name() const
Return the identifier/name of the shape.
std::map< double, r_min_max > rz_col_type
Definition: polycone.h:87
faces_mask_type
Face flags.
Definition: polycone.h:48
double get_xmin() const
Return the X min.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Definition: polycone.h:49
double get_delta_angle() const
Return the delta phi angle.
void compute_stop_angle_face(quadrangle &qface_, triangle &tface_, placement &, int index_) const
Compute the stop phi angle face.
static const face_identifier & face_bits_any()
Return a singleton face identifier with any bit.
Do not render the bottom face.
Definition: polycone.h:324
friend std::ostream & operator<<(std::ostream &, const polycone &)
double get_start_angle() const
Return the start phi angle.
Definition: polycone.h:50
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
A triangle.
Definition: triangle.h:29
double b2
Definition: polycone.h:83
Ignore first column as Rmin and use only second one for Rmax.
Definition: polycone.h:67
static const uint32_t bit05
Definition: bit_mask.h:32
bool has_delta_angle() const
Check the delta phi angle.
double z2
Definition: polycone.h:83
Do not render the outer face.
Definition: polycone.h:327
double get_ymax() const
Return the Y max.
double a1
Definition: polycone.h:81
Definition: polycone.h:51
datafile_column_mode
Format of the datafile for reading Z/Rmin/Rmax data.
Definition: polycone.h:65
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
double get_z() const
Return the Z dimension.
void compute_inner_face(right_circular_conical_nappe &in_, placement &, int index_) const
Compute the inner face at given frustrum index.
void compute_start_angle_face(quadrangle &qface_, triangle &tface_, placement &, int index_) const
Compute the start phi angle face.
Use one first column as Rmax.
Definition: polycone.h:68
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
Rendering options bit mask.
Definition: polycone.h:331
double get_z_min() const
Return the min Z.
Last defined bit.
Definition: i_wires_3d_rendering.h:62
polycone_wires_rendering_option_type
3D rendering options
Definition: polycone.h:323
double rmin
Rmin.
Definition: polycone.h:74
double b1
Definition: polycone.h:81
The placement for a geometry volume with its translation and rotation with respect to some mother ref...
Definition: placement.h:34
virtual void reset()
Reset/invalidate the solid.
Do not render the top face.
Definition: polycone.h:325
Definition: polycone.h:52
virtual void _build_bounding_data()
Build bounding data.
void initialize()
Initialize.
void compute_outer_face(right_circular_conical_nappe &on_, placement &, int index_) const
Compute the outer face at given frustrum index.
const rz_col_type & points() const
Return the dictionary of points.
virtual double get_surface(uint32_t mask_=FACE_ALL) const
Compute the surface.
polycone()
Default constructor.
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
Rmin/Rmax doublet.
Definition: polycone.h:72
static const uint32_t bit00
Definition: bit_mask.h:27
double get_zmax() const
Return the Z max.
void compute_frustrum(right_circular_conical_frustrum &f_, placement &, int index_) const
Compute frustrum at given index.
void _set_defaults()
Set default attributes.
bool is_extruded() const
Check if the polycone has a hole (Rmin != 0)
virtual ~polycone()
Destructor.
void compute_top_face(disk &top_disk_, placement &) const
Compute the top face.
A quadrangle.
Definition: quadrangle.h:36
Do not render the start angle face.
Definition: polycone.h:328
bool has_top_face() const
Check for a top face.
Definition: polycone.h:53
std::vector< face_info > face_info_collection_type
Type alias for a collection of face information objects.
Definition: face_info.h:168
void compute_inner_polycone(polycone &ip_)
Compute the inner polycone.
bool has_start_angle() const
Check the start phi angle.
virtual vector_3d get_normal_on_surface(const vector_3d &position_, const face_identifier &) const
Compute the normal to the surface of the furstrum.
A disk/ring sector surface (2D shape)
Definition: disk.h:26
virtual bool is_outside(const vector_3d &, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is outside the frustrum.
bool has_bottom_face() const
Check for a bottom face.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
virtual unsigned int compute_faces(face_info_collection_type &) const
Compute informations about the faces of this solid shape.
A dictionary of arbitrary properties.
Definition: properties.h:125
double get_parameter(const std::string &flag_) const
Return a parameter by name.