Bayeux  3.4.1
Core Foundation library for SuperNEMO
quadrangle.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2015-02-21
4  * Last modified: 2015-02-21
5  *
6  * License:
7  *
8  * Description:
9  *
10  * A planar quadrangle in 3D space
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_QUADRANGLE_H
17 #define GEOMTOOLS_QUADRANGLE_H 1
18 
19 // Standard library:
20 #include <string>
21 
22 // Third party:
23 // - Boost:
24 #include <boost/scoped_ptr.hpp>
25 
26 // This project:
27 #include <geomtools/i_shape_2d.h>
28 #include <geomtools/i_polygon.h>
29 
30 namespace geomtools {
31 
32  // Forward declaration:
33  class triangle;
34 
36  class quadrangle : public i_shape_2d,
37  public i_polygon
38  {
39 
40  public:
41 
43  static const std::string & quadrangle_label();
44 
46  bool is_valid() const;
47 
49  virtual double get_perimeter(uint32_t flags_ = ALL_PIECES) const;
50 
52  virtual double get_surface(uint32_t flags_ = ALL_PIECES) const;
53 
55  static bool check_vertexes(const geomtools::vector_3d & v0_,
56  const geomtools::vector_3d & v1_,
57  const geomtools::vector_3d & v2_,
58  const geomtools::vector_3d & v3_,
59  double tolerance_ = 0.0);
60 
62  void set_vertexes(const vector_3d & p0_, const vector_3d & p1_, const vector_3d & p2_, const vector_3d & p3_);
63 
65  void set_vertexes_ext(const vector_3d & p0_, const vector_3d & p1_, const vector_3d & p2_, const vector_3d & p3_);
66 
68  bool has_vertex_0_ext() const;
69 
71  bool has_vertex_1_ext() const;
72 
74  bool has_vertex_2_ext() const;
75 
77  bool has_vertex_3_ext() const;
78 
80  const vector_3d & get_vertex_0() const;
81 
83  const vector_3d & get_vertex_1() const;
84 
86  const vector_3d & get_vertex_2() const;
87 
89  const vector_3d & get_vertex_3() const;
90 
92  const vector_3d & get_vertex(int) const;
93 
95  quadrangle();
96 
98  quadrangle(const vector_3d & p0_, const vector_3d & p1_, const vector_3d & p2_, const vector_3d & p3_);
99 
101  virtual ~quadrangle();
102 
104  void initialize(const datatools::properties &, const handle_dict_type * = 0);
105 
107  void reset();
108 
110  virtual std::string get_shape_name() const;
111 
113  virtual bool is_on_surface(const vector_3d &,
114  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
115 
117  virtual vector_3d get_normal_on_surface(const vector_3d & position_,
118  bool check_ = false,
119  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
120 
122  virtual bool find_intercept(const vector_3d & from_,
123  const vector_3d & direction_,
124  face_intercept_info & intercept_,
125  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
126 
128  virtual void tree_dump(std::ostream & out_ = std::clog,
129  const std::string & title_ = "",
130  const std::string & indent_ = "",
131  bool inherit_= false) const;
132 
135  IT_NONE = 0,
136  IT_FIRST = 1,
138  };
139 
141  void make_pair_of_triangles(triangle & ta_, triangle & tb_, int = 0) const;
142 
145 
147  void compute_proper_frame(vector_3d & u0_, vector_3d & u1_, vector_3d & u2_) const;
148 
150  bool compute_proper_frame_coordinates(const vector_3d & position_, double & xp_, double & yp_, double & zp_) const;
151 
152 
163  ),
169  )
170  };
171 
173  virtual void generate_wires_self(wires_type & wires_,
174  uint32_t options_ = 0) const;
175 
177  virtual unsigned int compute_vertexes(vertex_col_type & vertexes_) const;
178 
179  protected:
180 
182  void _set_defaults();
183 
184  private:
185 
186  const vector_3d * _vertex_0_ext_;
187  const vector_3d * _vertex_1_ext_;
188  const vector_3d * _vertex_2_ext_;
189  const vector_3d * _vertex_3_ext_;
190  vector_3d _vertex_0_;
191  vector_3d _vertex_1_;
192  vector_3d _vertex_2_;
193  vector_3d _vertex_3_;
194 
195  // Working data:
196  boost::scoped_ptr<triangle> _t012_;
197  boost::scoped_ptr<triangle> _t023_;
198 
199  // Registration interface :
201 
202  };
203 
204 } // end of namespace geomtools
205 
206 #endif // GEOMTOOLS_QUADRANGLE_H
207 
208 /*
209 ** Local Variables: --
210 ** mode: c++ --
211 ** c-file-style: "gnu" --
212 ** tab-width: 2 --
213 ** End: --
214 */
const vector_3d & get_vertex_3() const
Return the vertex 3.
const vector_3d & get_vertex_1() const
Return the vertex 1.
Second triangle (v0, v2, v3)
Definition: quadrangle.h:137
Do not render the external edges.
Definition: quadrangle.h:159
void _set_defaults()
Set defaults attributes.
Last defined bit.
Definition: quadrangle.h:164
bool has_vertex_0_ext() const
Check if the first vertex is referenced from an outside object.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
virtual double get_surface(uint32_t flags_=ALL_PIECES) const
Return the surface.
None.
Definition: quadrangle.h:135
void set_vertexes(const vector_3d &p0_, const vector_3d &p1_, const vector_3d &p2_, const vector_3d &p3_)
Set the 3 vertexes.
static bool check_vertexes(const geomtools::vector_3d &v0_, const geomtools::vector_3d &v1_, const geomtools::vector_3d &v2_, const geomtools::vector_3d &v3_, double tolerance_=0.0)
Check the alignment of 4 points candidate to make a quadrangle.
const vector_3d & get_vertex(int) const
Return the vertex by index.
virtual vector_3d get_normal_on_surface(const vector_3d &position_, bool check_=false, double skin_=GEOMTOOLS_PROPER_TOLERANCE) const
Return the normal direction at some position on the 2D shape's path.
First triangle (v0, v1, v2)
Definition: quadrangle.h:136
const vector_3d & get_vertex_0() const
Return the vertex 0.
bool is_valid() const
Check the validity of the quadrangle.
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
const vector_3d & get_vertex_2() const
Return the vertex 2.
static const uint32_t ALL_PIECES
Special flag representing all pieces composing a 2D shape.
Definition: i_shape_2d.h:53
virtual double get_perimeter(uint32_t flags_=ALL_PIECES) const
Return the perimeter.
inner_triangle_index_type
Index of an inner triangle.
Definition: quadrangle.h:134
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
Rendering options bit mask.
Definition: quadrangle.h:165
A triangle.
Definition: triangle.h:29
bool compute_proper_frame_coordinates(const vector_3d &position_, double &xp_, double &yp_, double &zp_) const
Compute the coordinates of a point with respect to the (V0, VOV1, V0V2, V0V1^V0V1) system.
virtual unsigned int compute_vertexes(vertex_col_type &vertexes_) const
Build an ordered collection of vertexes.
Do not render the second external edges.
Definition: quadrangle.h:156
void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize from properties and a dictionary of 3D-objects.
bool has_vertex_2_ext() const
Check if the third vertex is referenced from an outside object.
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
Do not render the third external edges.
Definition: quadrangle.h:157
The abstract base class for all 2D shapes/surfaces.
Definition: i_shape_2d.h:37
void compute_proper_frame(vector_3d &u0_, vector_3d &u1_, vector_3d &u2_) const
Compute the vectors of the proper frame (V0, VOV1, V0V2, V0V1^V0V1) system.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
virtual ~quadrangle()
Destructor.
static const std::string & quadrangle_label()
Return the class label.
Do not render the fourth external edges.
Definition: quadrangle.h:158
Last defined bit.
Definition: i_wires_3d_rendering.h:62
bool has_vertex_3_ext() const
Check if the fourth vertex is referenced from an outside object.
virtual std::string get_shape_name() const
Return the identifier/name of the shape.
Polygon 2D shape.
Definition: i_polygon.h:28
quadrangle_wires_rendering_option_type
3D rendering options
Definition: quadrangle.h:154
const triangle & get_triangle(inner_triangle_index_type i_) const
Return a non mutable reference to one of the inner triangles.
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a sequence of polylines for wires 3D rendering.
std::vector< vector_3d > vertex_col_type
Aliases for an ordered collection of 3D vertice.
Definition: utils.h:58
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
bool has_vertex_1_ext() const
Check if the second vertex is referenced from an outside object.
Do not render the first external edges.
Definition: quadrangle.h:155
void make_pair_of_triangles(triangle &ta_, triangle &tb_, int=0) const
Generate a pair of complementary triangles from the quadrangle.
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.
quadrangle()
Default constructor.
A quadrangle.
Definition: quadrangle.h:36
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.
void set_vertexes_ext(const vector_3d &p0_, const vector_3d &p1_, const vector_3d &p2_, const vector_3d &p3_)
Set the 3 vertexes as handle to external vertexes.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125