UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
u3d_point.hpp
1 /* u3d_point.hpp */
2 /* $Id: u3d_point.hpp,v 1.11 2008/03/04 16:39:44 guser3 Exp $ */
3 #ifndef __u3d_point_hpp
4 #define __u3d_point_hpp
5 
6 //#include <vector>
7 
8 #include "u3d_defines.hpp"
9 
10 //class U3dBox;
11 
12 
14 class U3dPoint
15 {
16 public:
17 
19  U3dPoint ();
20 
21  virtual ~U3dPoint(){};
22 
24  U3dPoint (const U3dPoint& p);
25 
27  U3dPoint (double x, double y, double z);
28 
29  /* Create point with given point coordinates. */
30  //U3dPoint (U3dVertex vertex);
31 
33  U3dPoint& operator= (const U3dPoint& p);
34 
36  bool operator==(const U3dPoint&) const;
37 
39  bool operator!=(const U3dPoint&) const;
40 
41  // Point and Vector Operations (always valid)
42  U3dPoint operator+(U3dPoint) const; // +translate
43  U3dPoint operator-(U3dPoint) const; // -translate
44  //U3dPoint& operator+=(U3dVector); // inc translate
45  //U3dPoint& operator-=(U3dVector); // dec translate
46 
47  // Scalar Multiplication
48  friend U3dPoint operator*(int, U3dPoint);
49  friend U3dPoint operator*(U3dPoint, int);
50  friend U3dPoint operator*(double, U3dPoint);
51  friend U3dPoint operator*(U3dPoint, double);
52 
53  // Scalar Division
54  friend U3dPoint operator/(U3dPoint, int);
55  friend U3dPoint operator/(U3dPoint, double);
56 
58  double getX () const;
59 
61  double getY () const;
62 
64  double getZ () const;
65 
66  /* Check the point is inside given box. */
67  //virtual bool isInside (const U3dBox& mbox) const;
68 
70  void setXYZ (double x, double y, double z);
71 
73  void setX (double x);
74 
76  void setY (double y);
77 
79  void setZ (double z);
80 
81  //U3dVertex getVertex();
82 
83 protected:
84 
86  double fX, fY, fZ;
87 
88 };
89 
90 
91 /* INLINE implementation */
92 
93 inline U3dPoint::U3dPoint ()
94  : fX(0.0), fY(0.0), fZ(0.0)
95 {
96  /* dummy */
97 }
98 
99 inline U3dPoint::U3dPoint (const U3dPoint& p)
100  : fX(p.getX()), fY(p.getY()), fZ(p.getZ())
101 {
102  /* dummy */
103 }
104 
105 inline U3dPoint::U3dPoint (double x, double y, double z)
106  : fX(x), fY(y), fZ(z)
107 {
108  /* dummy */
109 }
110 /*
111  inline U3dPoint::U3dPoint (U3dVertex vertex)
112  : fX(vertex.x), fY(vertex.y), fZ(vertex.z)
113  {
114 
115  }*/
116 
117 inline U3dPoint&
119 {
120  fX = p.getX();
121  fY = p.getY();
122  fZ = p.getZ();
123  return *this;
124 }
125 
126 inline double
127 U3dPoint::getX () const
128 {
129  return fX;
130 }
131 
132 inline double
133 U3dPoint::getY () const
134 {
135  return fY;
136 }
137 
138 inline double
139 U3dPoint::getZ () const
140 {
141  return fZ;
142 }
143 
144 inline void
145 U3dPoint::setXYZ (double x, double y, double z)
146 {
147  fX = x;
148  fY = y;
149  fZ = z;
150 }
151 
152 inline void
153 U3dPoint::setX (double x)
154 {
155  fX = x;
156 }
157 
158 inline void
159 U3dPoint::setY (double y)
160 {
161  fY = y;
162 }
163 
164 inline void
165 U3dPoint::setZ (double z)
166 {
167  fZ = z;
168 }
169 
170 typedef safe_vector<U3dPoint*> U3dPointsAr;
171 typedef safe_vector<U3dPointsAr> U3dPointsMatrix;
172 
173 
174 /*=========================== GLOBAL FUNCTIONS ========================*/
175 
177 inline double pDistance(U3dPoint p0, U3dPoint p1)
178 {
179  return sqrt ( (p0.getX()-p1.getX())*(p0.getX()-p1.getX()) +
180  (p0.getY()-p1.getY())*(p0.getY()-p1.getY()) +
181  (p0.getZ()-p1.getZ())*(p0.getZ()-p1.getZ()) );
182 };
183 
185 int getNeighbour(U3dPoint p, U3dPointsAr p_ar);
186 
187 
188 #endif /* u3d_point.hpp */
void setXYZ(double x, double y, double z)
Definition: u3d_point.hpp:147
void setY(double y)
Definition: u3d_point.hpp:161
void setX(double x)
Definition: u3d_point.hpp:155
double getZ() const
Definition: u3d_point.hpp:141
double fX
Definition: u3d_point.hpp:86
double getY() const
Definition: u3d_point.hpp:135
U3dPoint & operator=(const U3dPoint &p)
Definition: u3d_point.hpp:120
Definition: u3d_point.hpp:16
bool operator!=(const U3dPoint &) const
void setZ(double z)
Definition: u3d_point.hpp:167
Definition: u3d_defines.hpp:188
U3dPoint()
Definition: u3d_point.hpp:95
double getX() const
Definition: u3d_point.hpp:129
bool operator==(const U3dPoint &) const