UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
u2d_point.hpp
1 /* u2d_point.hpp */
2 /* $Id: u2d_point.hpp,v 1.2 2008/05/27 09:38:22 sasha Exp $ */
3 #ifndef __u2d_point_hpp
4 #define __u2d_point_hpp
5 
6 #include <vector>
7 #include <math.h>
8 
10 class U2dPoint
11 {
12 public:
13 
15  U2dPoint ();
16 
17  virtual ~U2dPoint(){};
18 
20  U2dPoint (const U2dPoint& p);
21 
23  U2dPoint (double x, double z);
24 
26  U2dPoint& operator= (const U2dPoint& p);
27 
29  bool operator==(const U2dPoint&) const;
30 
32  bool operator!=(const U2dPoint&) const;
33 
34  // Point and Vector Operations (always valid)
35  U2dPoint operator+(U2dPoint); // +translate
36  U2dPoint operator-(U2dPoint); // -translate
37 
38  // Scalar Multiplication
39  friend U2dPoint operator*(int, U2dPoint);
40  friend U2dPoint operator*(U2dPoint, int);
41  friend U2dPoint operator*(double, U2dPoint);
42  friend U2dPoint operator*(U2dPoint, double);
43 
44  // Scalar Division
45  friend U2dPoint operator/(U2dPoint, int);
46  friend U2dPoint operator/(U2dPoint, double);
47 
48 
49  static bool x_asc(const U2dPoint& p1, const U2dPoint& p2) { return p1.m_X < p2.m_X; }
50 
51  static bool z_asc(const U2dPoint& p1, const U2dPoint& p2) { return p1.m_Z < p2.m_Z; }
52 
53  static bool x_desc(const U2dPoint& p1, const U2dPoint& p2) { return p1.m_X > p2.m_X; }
54 
55  static bool z_desc(const U2dPoint& p1, const U2dPoint& p2) { return p1.m_Z > p2.m_Z; }
56 
58  static double pDistance(const U2dPoint& p0, const U2dPoint& p1);
59 
61  static int getNeighbour(const U2dPoint& p, std::vector<U2dPoint*>& p_ar);
62  static int getNeighbour(const U2dPoint& p, std::vector<U2dPoint>& p_ar);
63 
64 
65 
67  double getX () const;
68 
70  double getZ () const;
71 
73  void setXZ (double x, double z);
74 
76  void setX (double x);
77 
79  void setZ (double z);
80 
81 
82 protected:
83 
85  double m_X, m_Z;
86 
87 };
88 
89 
90 /* INLINE implementation */
91 
93  : m_X(0.0), m_Z(0.0)
94 {
95  /* dummy */
96 }
97 
98 inline U2dPoint::U2dPoint (const U2dPoint& p)
99  : m_X(p.getX()), m_Z(p.getZ())
100 {
101  /* dummy */
102 }
103 
104 inline U2dPoint::U2dPoint (double x, double z)
105  : m_X(x), m_Z(z)
106 {
107  /* dummy */
108 }
109 
110 
111 inline U2dPoint&
113 {
114  m_X = p.getX();
115  m_Z = p.getZ();
116  return *this;
117 }
118 
119 inline double
121 {
122  return m_X;
123 }
124 
125 inline double
127 {
128  return m_Z;
129 }
130 
131 inline void
132 U2dPoint::setXZ (double x, double z)
133 {
134  m_X = x;
135  m_Z = z;
136 }
137 
138 inline void
139 U2dPoint::setX (double x)
140 {
141  m_X = x;
142 }
143 
144 inline void
145 U2dPoint::setZ (double z)
146 {
147  m_Z = z;
148 }
149 
150 
151 typedef std::vector<U2dPoint> U2dPoints;
152 typedef std::vector<U2dPoint*> U2dPointsAr;
153 typedef std::vector<U2dPointsAr> U2dPointsMatrix;
154 
155 
157 {
158  U2dPoint p;
159  double f;
160  double t;
161 };
162 
163 
164 
165 #endif /* u2d_point.hpp */
double m_X
Definition: u2d_point.hpp:85
static double pDistance(const U2dPoint &p0, const U2dPoint &p1)
U2dPoint & operator=(const U2dPoint &p)
Definition: u2d_point.hpp:112
Definition: u2d_point.hpp:10
void setXZ(double x, double z)
Definition: u2d_point.hpp:132
void setZ(double z)
Definition: u2d_point.hpp:145
bool operator!=(const U2dPoint &) const
double getX() const
Definition: u2d_point.hpp:120
bool operator==(const U2dPoint &) const
double getZ() const
Definition: u2d_point.hpp:126
U2dPoint()
Definition: u2d_point.hpp:92
void setX(double x)
Definition: u2d_point.hpp:139
Definition: u2d_point.hpp:156
static int getNeighbour(const U2dPoint &p, std::vector< U2dPoint * > &p_ar)