Bayeux  3.4.1
Core Foundation library for SuperNEMO
cylinder.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2008-05-24
4  * Last modified: 2015-02-15
5  *
6  * License:
7  *
8  * Description:
9  *
10  * A cylinder on z-axis
11  *
12  */
13 
14 #ifndef GEOMTOOLS_CYLINDER_H
15 #define GEOMTOOLS_CYLINDER_H 1
16 
17 // Standard library:
18 #include <sstream>
19 #include <stdexcept>
20 
21 // Third party:
22 // - Bayeux/datatools:
24 
25 // This project:
26 #include <geomtools/i_shape_3d.h>
27 #include <geomtools/i_stackable.h>
28 
29 namespace datatools {
30  // Forward class declaration:
31  class properties;
32 }
33 
34 namespace geomtools {
35 
36  // Class forward declarations:
37  class disk;
38  class cylindrical_sector;
39 
41  class cylinder : public i_shape_3d ,
42  public i_stackable
43  {
44 
45  public:
46 
48  static const std::string & cylinder_label();
49 
53  FACE_SIDE = 0x1,
54  FACE_BOTTOM = 0x2,
55  FACE_TOP = 0x4,
57  | FACE_BOTTOM
58  | FACE_TOP)
59  };
60 
63  disk & face_,
64  placement & face_placement_) const;
65 
68  placement & face_placement_) const;
69 
71  virtual unsigned int compute_faces(face_info_collection_type & faces_) const;
72 
74  double get_xmin () const;
75 
77  double get_xmax () const;
78 
80  double get_ymin () const;
81 
83  double get_ymax () const;
84 
86  double get_zmin () const;
87 
89  double get_zmax () const;
90 
92  double get_z () const;
93 
95  void set_z (double);
96 
98  void set_diameter (double);
99 
101  double get_half_z () const;
102 
104  void set_half_z (double);
105 
107  double get_r () const;
108 
110  double get_radius () const;
111 
113  double get_diameter () const;
114 
116  void set_r (double);
117 
119  void set (double r_, double z_);
120 
121  void set_alternative (double, double);
122 
124  cylinder ();
125 
127  cylinder (double a_radius, double a_z);
128 
130  virtual ~cylinder ();
131 
133  virtual std::string get_shape_name () const;
134 
136  virtual double get_parameter (const std::string &) const;
137 
139  bool is_valid () const;
140 
142  void init ();
143 
145  virtual void initialize(const datatools::properties &, const handle_dict_type * = 0);
146 
148  virtual void reset ();
149 
151  virtual double get_surface (uint32_t a_mask = FACE_ALL) const;
152 
154  virtual double get_volume (uint32_t flags_ = 0) const;
155 
157  virtual bool is_inside (const vector_3d &,
158  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
159 
161  virtual bool is_outside (const vector_3d &,
162  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
163 
165  virtual face_identifier on_surface(const vector_3d &,
166  const face_identifier & a_surface_mask = face_identifier::face_bits_any(),
167  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
168 
170  virtual vector_3d get_normal_on_surface(const vector_3d & a_position,
171  const face_identifier & a_surface_bit) const;
172 
174  virtual bool find_intercept (const vector_3d & a_from,
175  const vector_3d & a_direction,
176  face_intercept_info & a_intercept,
177  double a_skin = GEOMTOOLS_PROPER_TOLERANCE) const;
178 
179  friend std::ostream & operator<< (std::ostream &, const cylinder &);
180 
181  friend std::istream & operator>> (std::istream &, cylinder &);
182 
184  virtual void tree_dump (std::ostream & a_out = std::clog,
185  const std::string & a_title = "",
186  const std::string & a_indent = "",
187  bool a_inherit = false) const;
188 
198  };
199 
201  virtual void generate_wires_self(wires_type & wires_,
202  uint32_t options_ = 0) const;
203 
206 
207  protected:
208 
210  void _set_defaults();
211 
213  virtual void _build_bounding_data();
214 
215  private:
216 
217  double _z_; //<! Height
218  double _radius_; //<! Radius
219 
220  // Registration interface :
222 
223  };
224 
225 } // end of namespace geomtools
226 
228 // @arg geomtools::cylinder the name the class
230 
231 #endif // GEOMTOOLS_CYLINDER_H
232 
233 /*
234 ** Local Variables: --
235 ** mode: c++ --
236 ** c-file-style: "gnu" --
237 ** tab-width: 2 --
238 ** End: --
239 */
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.
Mother abstract class for all 3D solid shapes.
Definition: i_shape_3d.h:46
cylinder_wires_rendering_option_type
3D rendering options
Definition: cylinder.h:190
virtual double get_volume(uint32_t flags_=0) const
Compute the volume of the cylinder.
Identifier of a face attached to a solid shape.
Definition: face_identifier.h:32
Do not render the bottom face.
Definition: cylinder.h:191
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)
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_zmax() const
Return the max Z coordinates (bounding box)
void set_z(double)
Set the Z dimension.
Definition: cylinder.h:52
An object that describes the way an object of a given class can be configured through properties.
Definition: object_configuration_description.h:234
cylinder()
Default constructor.
static const std::string & cylinder_label()
Return the cylinder shape label.
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
void _set_defaults()
Set default attributes.
Last defined bit.
Definition: cylinder.h:194
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
Do not render the side face.
Definition: cylinder.h:193
virtual bool is_outside(const vector_3d &, double a_skin=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is outside the cylinder.
Definition: cylinder.h:54
Definition: cylinder.h:55
Abstract base stackable object.
Definition: i_stackable.h:32
double get_z() const
Return the Z dimension.
A spherical sector (2D shape)
Definition: cylindrical_sector.h:24
double get_diameter() const
Return the diameter.
Rendering options bit mask.
Definition: cylinder.h:195
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
double get_radius() const
Return the radius.
friend std::ostream & operator<<(std::ostream &, const cylinder &)
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.
friend std::istream & operator>>(std::istream &, cylinder &)
double get_xmin() const
Return the min X coordinates (bounding box)
static const face_identifier & face_bits_any()
Return a singleton face identifier with any bit.
double get_xmax() const
Return the max X coordinates (bounding box)
double get_half_z() const
Return half the Z dimension.
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
Definition: cylinder.h:56
static const uint32_t FACE_BITS_NONE
No valid or known face bit.
Definition: face_identifier.h:45
double get_r() const
Return the radius.
virtual ~cylinder()
Destructor.
void set(double r_, double z_)
Set the radius ad Z dimension.
virtual double get_surface(uint32_t a_mask=FACE_ALL) const
Compute the surface of the cylinder.
void set_alternative(double, double)
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 surface.
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
double get_zmin() const
Return the min Z coordinates (bounding box)
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
void set_r(double)
Set the radius.
bool is_valid() const
Check the validity.
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
static void init_ocd(datatools::object_configuration_description &)
OCD support.
virtual double get_parameter(const std::string &) const
Return a parameter by name.
virtual void _build_bounding_data()
Build the bounding data.
The 3D shape model for a cylinder.
Definition: cylinder.h:41
The placement for a geometry volume with its translation and rotation with respect to some mother ref...
Definition: placement.h:34
virtual unsigned int compute_faces(face_info_collection_type &faces_) const
Return a collection of face info objects.
void init()
Initialize.
virtual void reset()
Reset the cylinder.
void compute_side_face(cylindrical_sector &face_, placement &face_placement_) const
Compute the side bottom face and placement.
void set_half_z(double)
Set half the Z dimension.
virtual bool is_inside(const vector_3d &, double a_skin=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point is inside the cylinder.
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
double get_ymin() const
Return the min Y coordinates (bounding box)
void set_diameter(double)
Return the diameter.
void compute_top_bottom_face(faces_mask_type face_id_, disk &face_, placement &face_placement_) const
Compute the top or bottom face and placement.
Definition: cylinder.h:53
double get_ymax() const
Return the max Y coordinates (bounding box)
virtual void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize the cylinder from properties.
std::vector< face_info > face_info_collection_type
Type alias for a collection of face information objects.
Definition: face_info.h:168
Do not render the top face.
Definition: cylinder.h:192
A disk/ring sector surface (2D shape)
Definition: disk.h:26
faces_mask_type
Masks used for the faces of the cylinder.
Definition: cylinder.h:51
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125