IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Segment3d.h
1 // Segment3d.h:
3 // ------------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_SEGMENT3D_H__
16 #define __IPSDKGEOMETRY_SEGMENT3D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::geom::Segment3d<ipsdk::ipInt32>::_pt0' : struct 'ipsdk::geom::Point3dData<T>' needs to have dll-interface to be used by clients of class 'ipsdk::geom::Segment3d<ipsdk::ipInt32>'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
25 #include <IPSDKGeometry/Entity/3d/Point/Point3d.h>
26 #include <IPSDKGeometry/Entity/3d/Vector/Vector3d.h>
28 
29 namespace ipsdk {
30 namespace geom {
31 
32 class Vector3d;
33 
36 
37 template <typename T>
39 {
40  // declare 3d geometry entity
42 
43 // predefined public types
44 public:
46  static const eCoordinateSystem3dType::domain g_coordinateSystem3dType = eCoordinateSystem3dType::eCS3DT_Cartesian;
47 
49  static const eEntity3dType::domain g_entity3dType = eEntity3dType::eE3DT_Segment;
50 
51 public:
54  Segment3d();
55  Segment3d(const T x0, const T y0, const T z0, const T x1, const T y1, const T z1);
56  Segment3d(const Point3d<T>& pt0, const Point3d<T>& pt1);
57  Segment3d(const Point3dData<T>& pt0, const Point3dData<T>& pt1);
58  Segment3d(const Point3d<T>& pt0, const Vector3d& v01);
59  Segment3d(const Point3dData<T>& pt0, const Vector3d& v01);
60  ~Segment3d();
62 
63 // methods
64 public:
66  inline eCoordinateSystem3dType getCoordinateSystem3dType() const;
67 
69  inline eEntity3dType getEntity3dType() const;
70 
73  inline void setCoords(const T x0, const T y0, const T z0, const T x1, const T y1, const T z1);
74  inline void setCoords(const Point3d<T>& pt0, const Point3d<T>& pt1);
75  inline void setCoords(const Point3dData<T>& pt0, const Point3dData<T>& pt1);
76  inline void setCoords(const Point3d<T>& pt, const Vector3d& v01);
77  inline void setCoords(const Point3dData<T>& pt, const Vector3d& v01);
78  inline void setPoint0(const Point3d<T>& pt0);
79  inline void setPoint0(const Point3dData<T>& pt0);
80  inline void setPoint1(const Point3d<T>& pt1);
81  inline void setPoint1(const Point3dData<T>& pt1);
82  inline const Point3dData<T>& getPoint0() const;
83  inline const Point3dData<T>& getPoint1() const;
85 
87  ipReal64 getLength() const;
88 
91  Vector3d getDirection() const;
92 
95  Vector3d getUnitDirection() const;
96 
99  inline ipReal64 getMiddleX() const;
100  inline ipReal64 getMiddleY() const;
101  inline ipReal64 getMiddleZ() const;
102  inline Point3dData<ipReal64> getMiddlePoint() const;
104 
107  inline ipReal64 distance(const Point3d<T>& pt) const;
108  inline ipReal64 distance(const Point3d<T>& pt,
109  Point3d<ipReal64>& nearestPointOnSegment) const;
110  ipReal64 distance(const Point3dData<T>& pt) const;
111  ipReal64 distance(const Point3dData<T>& pt,
112  Point3dData<ipReal64>& nearestPointOnSegment) const;
114 
117  ipReal64 distance(const Segment3d<T>& otherSegment) const;
118  inline ipReal64 distance(const Segment3d<T>& otherSegment,
119  Point3d<ipReal64>& nearestPointOnThisSegment,
120  Point3d<ipReal64>& nearestPointOnOtherSegment) const;
121  ipReal64 distance(const Segment3d<T>& otherSegment,
122  Point3dData<ipReal64>& nearestPointOnThisSegment,
123  Point3dData<ipReal64>& nearestPointOnOtherSegment) const;
125 
126 // attributes
127 protected:
130 
133 };
134 
137 
138 template <typename T>
139 inline
140 Segment3d<T>::Segment3d(const T x0, const T y0, const T z0, const T x1, const T y1, const T z1) :
141  _pt0(x0, y0, z0),
142  _pt1(x1, y1, z1)
143 {
144 
145 }
146 
147 template <typename T>
148 inline
149 Segment3d<T>::Segment3d(const Point3d<T>& pt0, const Point3d<T>& pt1) :
150  _pt0(pt0.getCoords()),
151  _pt1(pt1.getCoords())
152 {
153 
154 }
155 
156 template <typename T>
157 inline
158 Segment3d<T>::Segment3d(const Point3dData<T>& pt0, const Point3dData<T>& pt1) :
159  _pt0(pt0),
160  _pt1(pt1)
161 {
162 
163 }
164 
165 template <typename T>
166 inline
167 Segment3d<T>::Segment3d(const Point3d<T>& pt0, const Vector3d& v01)
168 {
169  setCoords(pt0, v01);
170 }
171 
172 template <typename T>
173 inline
174 Segment3d<T>::Segment3d(const Point3dData<T>& pt0, const Vector3d& v01)
175 {
176  setCoords(pt0, v01);
177 }
178 
179 template <typename T>
182 {
183  return g_coordinateSystem3dType;
184 }
185 
186 template <typename T>
187 inline eEntity3dType
189 {
190  return g_entity3dType;
191 }
192 
193 template <typename T>
194 inline void
195 Segment3d<T>::setCoords(const T x0, const T y0, const T z0, const T x1, const T y1, const T z1)
196 {
197  _pt0.setCoords(x0, y0, z0);
198  _pt1.setCoords(x1, y1, z1);
199 }
200 
201 template <typename T>
202 inline void
204 {
205  _pt0 = pt0.getCoords();
206  _pt1 = pt1.getCoords();
207 }
208 
209 template <typename T>
210 inline void
212 {
213  _pt0 = pt0;
214  _pt1 = pt1;
215 }
216 
217 template <typename T>
218 inline void
220 {
221  setCoords(pt.getCoords(), v01);
222 }
223 
224 template <typename T>
225 inline void
227 {
228  _pt0 = pt;
229  _pt1 = pt;
230  _pt1._x += math::round<T>(v01.getX());
231  _pt1._y += math::round<T>(v01.getY());
232  _pt1._z += math::round<T>(v01.getZ());
233 }
234 
235 template <typename T>
236 inline void
238 {
239  _pt0 = pt0.getCoords();
240 }
241 
242 template <typename T>
243 inline void
245 {
246  _pt0 = pt0;
247 }
248 
249 template <typename T>
250 inline void
252 {
253  _pt1 = pt1.getCoords();
254 }
255 
256 template <typename T>
257 inline void
259 {
260  _pt1 = pt1;
261 }
262 
263 template <typename T>
264 inline const Point3dData<T>&
266 {
267  return _pt0;
268 }
269 
270 template <typename T>
271 inline const Point3dData<T>&
273 {
274  return _pt1;
275 }
276 
277 template <typename T>
278 inline ipReal64
280 {
281  return (_pt0._x + _pt1._x) / 2.0;
282 }
283 
284 template <typename T>
285 inline ipReal64
287 {
288  return (_pt0._y + _pt1._y) / 2.0;
289 }
290 
291 template <typename T>
292 inline ipReal64
294 {
295  return (_pt0._z + _pt1._z) / 2.0;
296 }
297 
298 template <typename T>
301 {
302  return Point3dData<ipReal64>(getMiddleX(), getMiddleY(), getMiddleZ());
303 }
304 
305 template <typename T>
306 inline ipReal64
308 {
309  return distance(pt.getCoords());
310 }
311 
312 template <typename T>
313 inline ipReal64
315  Point3d<ipReal64>& nearestPointOnSegment) const
316 {
317  return distance(pt.getCoords(), nearestPointOnSegment.getCoords());
318 }
319 
320 template <typename T>
321 inline ipReal64
323  Point3d<ipReal64>& nearestPointOnThisSegment,
324  Point3d<ipReal64>& nearestPointOnOtherSegment) const
325 {
326  return distance(otherSegment, nearestPointOnThisSegment.getCoords(), nearestPointOnOtherSegment.getCoords());
327 }
328 
331 
332 } // end of namespace geom
333 } // end of namespace ipsdk
334 
335 #pragma warning (pop)
336 
337 #endif // __IPSDKGEOMETRY_SEGMENT3D_H__
3d segment associated to two points
Definition: Segment3d.h:38
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
eCoordinateSystem3dType
Enumerate describing coordinate system 3d type.
Definition: GeometryEntity3dTypes.h:74
void setCoords(const T x0, const T y0, const T z0, const T x1, const T y1, const T z1)
access to segment coordinates
Definition: Segment3d.h:195
Point class associated to cartesian 3d coordinates.
Definition: GeometryEntity3dTypes.h:29
#define IPSDK_DECLARE_GEOMETRY_ENTITY_3D(libraryName, className)
Macro allowing to declare a geometry entity 3d.
Definition: GeometryEntity3dHdrMacros.h:131
Point3dData< T > _pt1
second point associated to segment
Definition: Segment3d.h:132
Point3dData< T > _pt0
first point associated to segment
Definition: Segment3d.h:129
const Point3dData< T > & getPoint1() const
access to segment coordinates
Definition: Segment3d.h:272
T _x
x coordinate of point
Definition: Point3dData.h:69
Operators associated to segment 3d entities.
eCoordinateSystem3dType getCoordinateSystem3dType() const
method allowing to retrieve coordinate system 3d type
Definition: Segment3d.h:181
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
ipReal64 distance(const Point3d< T > &pt) const
retrieve orthogonal distance between point and segment
Definition: Segment3d.h:307
const Point3dData< T > & getPoint0() const
access to segment coordinates
Definition: Segment3d.h:265
const Point3dData< T > & getCoords() const
access to point coordinates
Definition: Point3d.h:142
ipReal64 getX() const
retrieve cartesian components of vector
Definition: Vector3d.h:264
Vector class associated to spherical 3d coordinates.
Definition: Vector3d.h:32
IPSDKGEOMETRY_API ipReal64 distance(const Point2d< T > &pt1, const Point2d< T > &pt2)
compute euclidian distance between two points
Definition of import/export macro for library.
Segment.
Definition: GeometryEntity3dTypes.h:64
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
void setPoint1(const Point3d< T > &pt1)
access to segment coordinates
Definition: Segment3d.h:251
ipReal64 getZ() const
retrieve cartesian components of vector
Definition: Vector3d.h:276
ipReal64 getMiddleZ() const
retrieve segment middle point coordinates
Definition: Segment3d.h:293
Point3dData< ipReal64 > getMiddlePoint() const
retrieve segment middle point coordinates
Definition: Segment3d.h:300
Utility functions for ipsdk math library.
eEntity3dType
Enumerate describing entity 3d type.
Definition: GeometryEntity3dTypes.h:38
eEntity3dType getEntity3dType() const
method allowing to retrieve entity 3d type
Definition: Segment3d.h:188
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity3d.h:27
boost::numeric::ublas::bounded_vector< ipReal64, 3 > Vector3d
3d vector type associated to library
Definition: LinearAlgebraTypes.h:42
Cartesian coordinate system.
Definition: GeometryEntity3dTypes.h:76
ipReal64 getMiddleX() const
retrieve segment middle point coordinates
Definition: Segment3d.h:279
Lightweight structure used to store Point3d data.
Definition: GeometryEntity3dTypes.h:27
void setPoint0(const Point3d< T > &pt0)
access to segment coordinates
Definition: Segment3d.h:237
ipReal64 getMiddleY() const
retrieve segment middle point coordinates
Definition: Segment3d.h:286
ipReal64 getY() const
retrieve cartesian components of vector
Definition: Vector3d.h:270