GeoLine.h
Go to the documentation of this file.
1 /**
2  * \file GeoLine.h
3  *
4  * \ingroup GeoAlgo
5  *
6  * \brief Class def header for a class Line
7  *
8  * @author David Caratelli
9  */
10 
11 /** \addtogroup GeoAlgo
12 
13  @{*/
14 #ifndef BASICTOOL_GEOLINE_H
15 #define BASICTOOL_GEOLINE_H
16 
18 
19 namespace geoalgo {
20  /**
21  \class Line
22  @brief Representation of a 3D infinite line.
23  Defines an infinite 3D line by having 2 points which completely determine the line
24  along which the line extends. It hides the point attributes from users for \n
25  protecting the dimensionality.
26  */
27  class Line {
28 
29  public:
30 
31  /// Default constructor
32  Line();
33 
34  /// Default destructor
35  virtual ~Line(){}
36 
37  /// Alternative ctor (1)
38  Line(const double x1, const double y1, const double z1,
39  const double x2, const double y2, const double z2);
40 
41  /// Altenartive ctor (2)
42  Line(const Point_t& pt1, const Point_t& pt2);
43 
44  //
45  // Getters
46  //
47  const Point_t& Pt1() const; ///< Start getter
48  const Point_t& Pt2() const; ///< Direction getter
49 
50  //
51  // Setters
52  //
53  void Pt1(const double x, const double y, const double z); ///< Pt1 setter
54  void Pt2(const double x, const double y, const double z); ///< Pt2 setter
55 
56  protected:
57 
58  /// Compatibility check
59  void check_and_raise(const Point_t& p1, const Point_t& p2) const;
60 
61  Point_t _pt1; ///< First point denoting infinite line
62  Vector_t _pt2; ///< Second point denoting infinite line
63 
64  public:
65  //
66  // Template
67  //
68  /// Alternative ctor using template (3)
69  template <class T, class U> Line(const T& pt1, const U& pt2)
70  : Line(Point_t(pt1), Point_t(pt2))
71  {}
72 
73  /// Pt1 setter template
74  template<class T>
75  void Pt1(const T& pt1)
76  {
77  _pt1 = Point_t(pt1);
78  check_and_raise(_pt1,_pt2);
79  }
80 
81  /// Pt2 setter template
82  template<class T>
83  void Pt2(const T& pt2)
84  {
85  _pt2 = Vector_t(pt2);
86  check_and_raise(_pt1,_pt2);
87  }
88  };
89 
90 
91  typedef Line Line_t;
92 }
93 #endif
94 /** @} */ // end of doxygen group
const Point_t & Pt2() const
Direction getter.
Definition: GeoLine.cxx:23
virtual ~Line()
Default destructor.
Definition: GeoLine.h:35
Point_t _pt1
First point denoting infinite line.
Definition: GeoLine.h:61
Class def header for a class Point and Vector.
const Point_t & Pt1() const
Start getter.
Definition: GeoLine.cxx:22
Representation of a 3D infinite line. Defines an infinite 3D line by having 2 points which completely...
Definition: GeoLine.h:27
Vector Point_t
Definition: GeoVector.h:196
void Pt2(const T &pt2)
Pt2 setter template.
Definition: GeoLine.h:83
Line(const T &pt1, const U &pt2)
Alternative ctor using template (3)
Definition: GeoLine.h:69
Vector_t _pt2
Second point denoting infinite line.
Definition: GeoLine.h:62
Vector Vector_t
Point has same feature as Vector.
Definition: GeoVector.h:195
list x
Definition: train.py:276
Line()
Default constructor.
Definition: GeoLine.cxx:6
Line Line_t
Definition: GeoLine.h:91
void Pt1(const T &pt1)
Pt1 setter template.
Definition: GeoLine.h:75
void check_and_raise(const Point_t &p1, const Point_t &p2) const
Compatibility check.
Definition: GeoLine.cxx:41