Bayeux  3.4.1
Core Foundation library for SuperNEMO
line_3d.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2008-12-18
4  * Last modified: 2015-02-22
5  *
6  * License:
7  *
8  * Description:
9  * Line 3D model
10  *
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_LINE_3D_H
17 #define GEOMTOOLS_LINE_3D_H 1
18 
19 // Standard library:
20 #include <iostream>
21 #include <string>
22 
23 // - Bayeux/datatools:
24 #include <datatools/i_tree_dump.h>
26 
27 // This project:
28 #include <geomtools/i_shape_1d.h>
29 #include <geomtools/utils.h>
31 
32 namespace geomtools {
33 
34  // Forward declaration:
35  class placement;
36 
38  class line_3d : public i_shape_1d,
40  {
41  public:
42 
44  static const std::string & line_3d_label();
45 
47  bool is_normal();
48 
50  virtual std::string get_shape_name() const;
51 
53  bool is_valid() const;
54 
56  void invalidate();
57 
59  const vector_3d & get_first() const;
60 
62  void set_first(double x_, double y_, double z_);
63 
65  void set_first(const vector_3d &);
66 
68  const vector_3d & get_last() const;
69 
71  void set_last(double x_, double y_, double z_);
72 
74  void set_last(const vector_3d &);
75 
77  vector_3d get_point(double t_) const;
78 
80  virtual double get_length(uint32_t flags_ = PATH_ALL_BITS) const;
81 
83  line_3d();
84 
86  line_3d(const vector_3d & first_,
87  const vector_3d & last_);
88 
90  line_3d(double x0_, double y0_, double z0_,
91  double x1_, double y1_, double z1_);
92 
94  line_3d(const segment_type & segment_);
95 
97  virtual ~line_3d();
98 
100  virtual void tree_dump(std::ostream & out_ = std::clog,
101  const std::string & title_ = "",
102  const std::string & indent_ = "",
103  bool inherit_ = false) const;
104 
106  static void print_xyz(std::ostream & out_, const line_3d & line_);
107 
119  static void orthogonal_projection(const vector_3d & p_,
120  const vector_3d & m_,
121  const vector_3d & u_,
122  vector_3d & h_);
123 
135  static double distance_to_line(const vector_3d & p_,
136  const vector_3d & m_,
137  const vector_3d & u_);
138 
150  double get_distance_to_line(const vector_3d & position_ ) const;
151 
153  bool compute_orthogonal_projection(const vector_3d & position_, vector_3d & proj_) const;
154 
156  bool is_on_line(const vector_3d & position_,
157  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
158 
160  bool is_on_segment(const vector_3d & position_,
161  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
162 
164  virtual bool is_on_curve(const vector_3d & position_,
165  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
166 
168  virtual vector_3d get_direction_on_curve(const vector_3d & position_) const;
169 
172 
175 
177  virtual void generate_wires_self(wires_type & wires_,
178  uint32_t options_ = 0) const;
179 
180  private:
181 
182  vector_3d _first_;
183  vector_3d _last_;
184 
185  // Serialization interface
187 
188  };
189 
192 
193 } // end of namespace geomtools
194 
195 #include <boost/serialization/export.hpp>
196 BOOST_CLASS_EXPORT_KEY2(geomtools::line_3d, "geomtools::line_3d")
197 
198 // Class version:
199 #include <boost/serialization/version.hpp>
200 BOOST_CLASS_VERSION(geomtools::line_3d, 2)
201 
202 #endif // GEOMTOOLS_LINE_3D_H
203 
204 /*
205 ** Local Variables: --
206 ** mode: c++ --
207 ** c-file-style: "gnu" --
208 ** tab-width: 2 --
209 ** End: --
210 */
The abstract base class for all 1D curves/shapes.
Definition: i_shape_1d.h:32
const vector_3d & get_last() const
Return the stop position on the line.
Definition: utils.h:184
virtual double get_length(uint32_t flags_=PATH_ALL_BITS) const
Return the length of the linear segment.
static double distance_to_line(const vector_3d &p_, const vector_3d &m_, const vector_3d &u_)
bool is_valid() const
Check if the line is valid.
bool compute_orthogonal_projection(const vector_3d &position_, vector_3d &proj_) const
Compute the orthogonal projection on the segment.
bool is_normal()
Check if the shape is normal.
An line/segment (1D shape) in a 3D space.
Definition: line_3d.h:38
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
#define GEOMTOOLS_PROPER_TOLERANCE
Definition: geomtools_config.h:26
static void print_xyz(std::ostream &out_, const line_3d &line_)
Print approximated data (x,y,z) triplets representing the line.
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate a sequence of polylines for wires 3D rendering.
double get_distance_to_line(const vector_3d &position_) const
bool is_on_line(const vector_3d &position_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a position is along the support line of the segment.
polyline_type make_vertex_collection() const
Return a collection of vertexes representing the line.
virtual ~line_3d()
Destructor.
void set_first(double x_, double y_, double z_)
Set the start position on the line.
line_3d segment_3d
Type alias for the line_3d class.
Definition: line_3d.h:191
void invalidate()
Invalidate the line.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
bool is_on_segment(const vector_3d &position_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a position is on the line segment.
brief Abstract interface for objects that can describe themselves as a collection of polylines for 3D...
Definition: i_wires_3d_rendering.h:39
virtual std::string get_shape_name() const
Return the identifier/name of the shape.
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
std::list< vector_3d > polyline_type
Definition: utils.h:55
line_3d()
Default constructor.
vector_3d get_point(double t_) const
Return the position at given parameter.
basic_segment_3d segment_type
Definition: utils.h:51
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
static const std::string & line_3d_label()
Return the identifier label for the class.
virtual bool is_on_curve(const vector_3d &position_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Check if a position is on the line segment.
virtual vector_3d get_direction_on_curve(const vector_3d &position_) const
Return the direction at some position in on the line.
const vector_3d & get_first() const
Return the start position on the line.
static void orthogonal_projection(const vector_3d &p_, const vector_3d &m_, const vector_3d &u_, vector_3d &h_)
void set_last(double x_, double y_, double z_)
Set the last position on the line.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39