Bayeux  3.4.1
Core Foundation library for SuperNEMO
polyline_3d.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2009-03-31
4  * Last modified: 2009-03-31
5  */
6 
7 #ifndef GEOMTOOLS_POLYLINE_3D_H
8 #define GEOMTOOLS_POLYLINE_3D_H 1
9 
10 // Standard library:
11 #include <iostream>
12 #include <stdexcept>
13 #include <list>
14 
15 // Third party:
16 // - Bayeux/datatools:
18 
19 // This project:
20 #include <geomtools/i_shape_1d.h>
21 #include <geomtools/utils.h>
23 
24 namespace geomtools {
25 
27  class polyline_3d : public i_shape_1d,
29  {
30  public:
31 
33  static const std::string & polyline_3d_label();
34 
35  static const bool CLOSED = true;
36  static const bool closed = CLOSED;
37  static const bool OPEN = false;
38  static const bool open = OPEN;
39  static const bool DEFAULT_CLOSED = OPEN;
40 
43 
45  virtual std::string get_shape_name() const;
46 
48  bool is_valid() const;
49 
51  bool is_closed() const;
52 
54  void set_closed(bool);
55 
57  bool is_empty() const;
58 
60  polyline_3d();
61 
63  polyline_3d(bool closed_);
64 
66  virtual ~polyline_3d();
67 
69  void clear();
70 
72  void add(const vector_3d &);
73 
75  int get_number_of_points() const;
76 
78  const vector_3d & get_point(int i_) const;
79 
81  int get_number_of_vertex() const;
82 
84  int get_number_of_vertexes() const;
85 
87  const vector_3d & get_vertex(int i_) const;
88 
90  virtual double get_length(uint32_t flags_ = PATH_ALL_BITS) const;
91 
92  // inefficient algorithm:
94 
95  // inefficient algorithm:
97 
99  virtual bool is_on_curve(const vector_3d & position_,
100  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
101 
103  virtual vector_3d get_direction_on_curve(const vector_3d & position_) const;
104 
106  const polyline_type & get_points() const;
107 
110 
112  virtual void tree_dump(std::ostream & out_ = std::clog,
113  const std::string & title_ = "",
114  const std::string & indent_ = "",
115  bool inherit_ = false) const;
116 
118  virtual void generate_wires_self(wires_type & wires_,
119  uint32_t options_ = 0) const;
120 
121  private:
122 
123  bool _closed_;
124  polyline_type _points_;
125 
128 
129  };
130 
131 } // end of namespace geomtools
132 
133 BOOST_CLASS_EXPORT_KEY2(geomtools::polyline_3d, "geomtools::polyline_3d")
134 
135 // Explicit class version:
136 #include <boost/serialization/version.hpp>
137 BOOST_CLASS_VERSION(geomtools::polyline_3d, 2)
138 
139 #endif // GEOMTOOLS_POLYLINE_3D_H
140 
141 /*
142 ** Local Variables: --
143 ** mode: c++ --
144 ** c-file-style: "gnu" --
145 ** tab-width: 2 --
146 ** End: --
147 */
The abstract base class for all 1D curves/shapes.
Definition: i_shape_1d.h:32
virtual double get_length(uint32_t flags_=PATH_ALL_BITS) const
Return the length of the linear segment.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Definition: utils.h:184
bool is_closed() const
Check if the polyline is closed.
static const bool OPEN
Definition: polyline_3d.h:37
void clear()
Remove all points.
int get_number_of_vertexes() const
Return the number of vertexes in the sequence.
std::list< vector_3d > basic_polyline_3d
Aliases for a list of 3D vertice as a 3D-polyline.
Definition: utils.h:54
const vector_3d & get_vertex(int i_) const
Return the vertex at given index.
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
int get_number_of_points() const
Return the number of points in the sequence.
polyline_type make_vertex_collection() const
void add(const vector_3d &)
Add a point at the end of the sequence.
virtual bool is_on_curve(const vector_3d &position_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a point belongs to the polyline.
virtual vector_3d get_direction_on_curve(const vector_3d &position_) const
Return the direction at some position along the polyline.
static const bool CLOSED
Definition: polyline_3d.h:35
virtual ~polyline_3d()
Destructor.
static const bool closed
Definition: polyline_3d.h:36
bool is_valid() const
Check if the polyline is valid.
A sequence of connected linear segments (3D)
Definition: polyline_3d.h:27
polyline_3d()
Default constructor.
static const bool open
Definition: polyline_3d.h:38
polyline_type & grab_points()
Return a mutable reference to the collection of points.
static const std::string & polyline_3d_label()
Return the identifier of the polyline 3D-object.
virtual std::string get_shape_name() const
Return the name of the shape.
brief Abstract interface for objects that can describe themselves as a collection of polylines for 3D...
Definition: i_wires_3d_rendering.h:39
void set_closed(bool)
Set the 'closed' flag.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
const vector_3d & get_point(int i_) const
Return the point at given index.
std::list< vector_3d > polyline_type
Definition: utils.h:55
static const bool DEFAULT_CLOSED
Definition: polyline_3d.h:39
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
int get_number_of_vertex() const
polyline_type point_col
A sequence of vertexes.
Definition: polyline_3d.h:42
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a sequence of polylines for wires 3D rendering.
const polyline_type & get_points() const
Return a non mutable reference to the collection of points.
bool is_empty() const
Check if the polyline has no points.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39