Bayeux  3.4.1
Core Foundation library for SuperNEMO
regular_polygon.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-14
4  * Last modified: 2015-02-16
5  *
6  * License:
7  *
8  * Description:
9  *
10  * A regular_polygon in x-y plane
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_REGULAR_POLYGON_H
17 #define GEOMTOOLS_REGULAR_POLYGON_H 1
18 
19 // Standard library:
20 #include <string>
21 
22 // This project:
23 #include <geomtools/i_shape_2d.h>
24 #include <geomtools/i_polygon.h>
25 
26 namespace geomtools {
27 
29 
50  class regular_polygon : public i_shape_2d,
51  public i_polygon
52  {
53 
54  public:
55 
56  static const std::string & regular_polygon_label();
57 
59  enum mode_type {
62  };
63 
65  static const unsigned int MIN_NUMBER_OF_SIDES = 3;
66 
68  bool is_valid() const;
69 
71  uint32_t get_n_sides() const;
72 
74  void set_n_sides(uint32_t);
75 
77  double get_apothem() const;
78 
80  virtual double get_perimeter(uint32_t flags_ = ALL_PIECES) const;
81 
83  double get_side_length() const;
84 
86  double get_reference_angle() const;
87 
89  double get_r() const;
90 
92  double get_radius() const;
93 
95  void set_r(double);
96 
98  void set_diameter(double);
99 
101  virtual double get_diameter() const;
102 
104  virtual double get_surface(uint32_t flags_ = ALL_PIECES) const;
105 
107  void get_vertex(int n_, double & x_, double & y_) const;
108 
110  void get_vertex(int n_, vector_3d & vertex_) const;
111 
113  regular_polygon();
114 
116  regular_polygon(uint32_t n_sides_, double r_, int mode_ = BUILD_BY_RADIUS);
117 
119  virtual ~regular_polygon();
120 
122  void initialize(const datatools::properties &, const handle_dict_type * = 0);
123 
125  void reset();
126 
128  virtual std::string get_shape_name() const;
129 
131  virtual bool is_on_surface(const vector_3d &,
132  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
133 
135  virtual vector_3d get_normal_on_surface(const vector_3d & position_,
136  bool check_ = true,
137  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
138 
140  virtual bool find_intercept(const vector_3d & from_,
141  const vector_3d & direction_,
142  face_intercept_info & intercept_,
143  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
144 
146  virtual void tree_dump(std::ostream & out_ = std::clog,
147  const std::string & title_ = "",
148  const std::string & indent_ = "",
149  bool inherit_= false) const;
150 
156  };
157 
159  virtual void generate_wires_self(wires_type & wires_,
160  uint32_t options_ = 0) const;
161 
163  virtual unsigned int compute_vertexes(vertex_col_type & vertexes_) const;
164 
165  private:
166 
167  uint32_t _n_sides_;
168  double _r_;
169 
170  // Registration interface :
172 
173  };
174 
175 } // end of namespace geomtools
176 
177 #endif // GEOMTOOLS_REGULAR_POLYGON_H
178 
179 /*
180 ** Local Variables: --
181 ** mode: c++ --
182 ** c-file-style: "gnu" --
183 ** tab-width: 2 --
184 ** End: --
185 */
double get_side_length() const
Return the length of a side.
bool is_valid() const
Check the validity of the polygon.
A regular polygon.
Definition: regular_polygon.h:50
double get_apothem() const
Return the apothem.
virtual double get_diameter() const
Return the diameter.
virtual ~regular_polygon()
Destructor.
rp_wires_rendering_option_type
3D rendering options
Definition: regular_polygon.h:152
void set_r(double)
Set the radius.
static const std::string & regular_polygon_label()
void get_vertex(int n_, double &x_, double &y_) const
Compute the coordinates of a vertex given its index.
Do not render the external edges.
Definition: regular_polygon.h:153
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize from properties and a dictionary of 3D-objects.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
double get_radius() const
Return the radius.
virtual std::string get_shape_name() const
Return the identifier/name of the shape.
static const uint32_t ALL_PIECES
Special flag representing all pieces composing a 2D shape.
Definition: i_shape_2d.h:53
double get_reference_angle() const
Return the reference angle.
virtual double get_surface(uint32_t flags_=ALL_PIECES) const
Return the surface.
Rendering options bit mask.
Definition: regular_polygon.h:155
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
Definition: regular_polygon.h:61
Last defined bit.
Definition: regular_polygon.h:154
void set_diameter(double)
Set the diameter.
void set_n_sides(uint32_t)
Set the number of sides.
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
The abstract base class for all 2D shapes/surfaces.
Definition: i_shape_2d.h:37
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
virtual vector_3d get_normal_on_surface(const vector_3d &position_, bool check_=true, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Return the normal direction at some position on the 2D shape's path.
double get_r() const
Return the radius.
regular_polygon()
Default constructor.
uint32_t get_n_sides() const
Return the number of sides.
Last defined bit.
Definition: i_wires_3d_rendering.h:62
Polygon 2D shape.
Definition: i_polygon.h:28
mode_type
Construction mode.
Definition: regular_polygon.h:59
virtual unsigned int compute_vertexes(vertex_col_type &vertexes_) const
Build an ordered collection of vertexes.
std::vector< vector_3d > vertex_col_type
Aliases for an ordered collection of 3D vertice.
Definition: utils.h:58
virtual bool find_intercept(const vector_3d &from_, const vector_3d &direction_, face_intercept_info &intercept_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Find the intercept of a ray with the 2D shape's surfaces.
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
virtual bool is_on_surface(const vector_3d &, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Check is a given point belongs to the surface of the 2D shape.
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a sequence of polylines for wires 3D rendering.
virtual double get_perimeter(uint32_t flags_=ALL_PIECES) const
Return the perimeter.
Definition: regular_polygon.h:60
static const unsigned int MIN_NUMBER_OF_SIDES
The minimum number of sides.
Definition: regular_polygon.h:65
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125