Bayeux  3.4.1
Core Foundation library for SuperNEMO
triangle.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2015-02-18
4  * Last modified: 2015-02-18
5  *
6  * License:
7  *
8  * Description:
9  *
10  * A triangle in 3D space
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_TRIANGLE_H
17 #define GEOMTOOLS_TRIANGLE_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  class triangle : public i_shape_2d,
30  public i_polygon
31  {
32 
33  public:
34 
36  static const std::string & triangle_label();
37 
39  bool is_valid() const;
40 
42  virtual double get_perimeter(uint32_t flags_ = ALL_PIECES) const;
43 
45  virtual double get_surface(uint32_t flags_ = ALL_PIECES) const;
46 
48  static bool check_alignement(const geomtools::vector_3d & v0_,
49  const geomtools::vector_3d & v1_,
50  const geomtools::vector_3d & v2_,
51  double tolerance_ = 0.0);
52 
54  void set_vertexes(const vector_3d & p0_, const vector_3d & p1_, const vector_3d & p2_);
55 
57  void set_vertexes_ext(const vector_3d & p0_, const vector_3d & p1_, const vector_3d & p2_);
58 
60  bool has_vertex_0_ext() const;
61 
63  bool has_vertex_1_ext() const;
64 
66  bool has_vertex_2_ext() const;
67 
69  const vector_3d & get_vertex_0() const;
70 
72  const vector_3d & get_vertex_1() const;
73 
75  const vector_3d & get_vertex_2() const;
76 
78  const vector_3d & get_vertex(int) const;
79 
81  triangle();
82 
84  triangle(const vector_3d & p0_, const vector_3d & p1_, const vector_3d & p2_);
85 
87  virtual ~triangle();
88 
90  void initialize(const datatools::properties &, const handle_dict_type * = 0);
91 
93  void reset();
94 
96  virtual std::string get_shape_name() const;
97 
99  virtual bool is_on_surface(const vector_3d &,
100  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
101 
103  virtual vector_3d get_normal_on_surface(const vector_3d & position_,
104  bool check_ = false,
105  double skin_ = GEOMTOOLS_PROPER_TOLERANCE) const;
106 
108  virtual bool find_intercept(const vector_3d & from_,
109  const vector_3d & direction_,
110  face_intercept_info & intercept_,
111  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
112 
114  virtual void tree_dump(std::ostream & out_ = std::clog,
115  const std::string & title_ = "",
116  const std::string & indent_ = "",
117  bool inherit_= false) const;
118 
120  void compute_proper_frame(vector_3d & u0_, vector_3d & u1_, vector_3d & u2_) const;
121 
123  bool compute_proper_frame_coordinates(const vector_3d & position_, double & xp_, double & yp_, double & zp_) const;
124 
125 
134  ),
139  )
140  };
141 
143  virtual void generate_wires_self(wires_type & wires_,
144  uint32_t options_ = 0) const;
145 
147  virtual unsigned int compute_vertexes(vertex_col_type & vertexes_) const;
148 
149  protected:
150 
152  void _set_defaults();
153 
154  private:
155 
156  const vector_3d * _vertex_0_ext_;
157  const vector_3d * _vertex_1_ext_;
158  const vector_3d * _vertex_2_ext_;
159  vector_3d _vertex_0_;
160  vector_3d _vertex_1_;
161  vector_3d _vertex_2_;
162 
163  // Registration interface :
165 
166  };
167 
168 } // end of namespace geomtools
169 
170 #endif // GEOMTOOLS_TRIANGLE_H
171 
172 /*
173 ** Local Variables: --
174 ** mode: c++ --
175 ** c-file-style: "gnu" --
176 ** tab-width: 2 --
177 ** End: --
178 */
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.
void initialize(const datatools::properties &, const handle_dict_type *=0)
Initialize from properties and a dictionary of 3D-objects.
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.
Do not render the third external edges.
Definition: triangle.h:130
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.
void reset()
Reset.
const vector_3d & get_vertex_1() const
Return the second vertex.
bool is_valid() const
Check the validity of the triangle.
void _set_defaults()
Set defaults attributes.
Last defined bit.
Definition: triangle.h:135
Do not render the external edges.
Definition: triangle.h:131
The face_intercept_info class hosts the parameters of.
Definition: face_intercept_info.h:31
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
virtual double get_surface(uint32_t flags_=ALL_PIECES) const
Return the surface.
triangle_wires_rendering_option_type
3D rendering options
Definition: triangle.h:127
void set_vertexes(const vector_3d &p0_, const vector_3d &p1_, const vector_3d &p2_)
Set the 3 vertexes.
bool has_vertex_0_ext() const
Check if the first vertex is referenced from an outside object.
static bool check_alignement(const geomtools::vector_3d &v0_, const geomtools::vector_3d &v1_, const geomtools::vector_3d &v2_, double tolerance_=0.0)
Check the alignment of 3 points candidate to make a triangle.
static const uint32_t ALL_PIECES
Special flag representing all pieces composing a 2D shape.
Definition: i_shape_2d.h:53
static const std::string & triangle_label()
Return the class label.
void set_vertexes_ext(const vector_3d &p0_, const vector_3d &p1_, const vector_3d &p2_)
Set the 3 vertexes as handle to external vertexes.
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.
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
A triangle.
Definition: triangle.h:29
virtual ~triangle()
Destructor.
const vector_3d & get_vertex(int) const
Return the vertex by index.
virtual double get_perimeter(uint32_t flags_=ALL_PIECES) const
Return the perimeter.
#define GEOMTOOLS_OBJECT_3D_REGISTRATION_INTERFACE(ModelClassName)
Definition: i_object_3d.h:260
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
bool has_vertex_2_ext() const
Check if the third vertex is referenced from an outside object.
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
bool has_vertex_1_ext() const
Check if the second vertex is referenced from an outside object.
Last defined bit.
Definition: i_wires_3d_rendering.h:62
const vector_3d & get_vertex_2() const
Return the third vertex.
triangle()
Default constructor.
Polygon 2D shape.
Definition: i_polygon.h:28
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
virtual unsigned int compute_vertexes(vertex_col_type &vertexes_) const
Build an ordered collection of vertexes.
Rendering options bit mask.
Definition: triangle.h:136
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a sequence of polylines for wires 3D rendering.
const vector_3d & get_vertex_0() const
Return the first vertex.
Do not render the first external edges.
Definition: triangle.h:128
Do not render the second external edges.
Definition: triangle.h:129
virtual std::string get_shape_name() const
Return the identifier/name of the shape.
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.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125