IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Triangle3d.h
1 // Triangle3d.h:
3 // -------------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_TRIANGLE3D_H__
16 #define __IPSDKGEOMETRY_TRIANGLE3D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::geom::Triangle3d<ipsdk::ipInt32>::_pt0': struct 'ipsdk::geom::Point3dData<T>' needs to have dll-interface to be used by clients of class 'ipsdk::geom::Triangle3d<ipsdk::ipInt32>'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
24 #include <IPSDKGeometry/Entity/3d/BaseTypedGeometryEntity3d.h>
25 #include <IPSDKGeometry/Entity/3d/Point/Point3dData.h>
26 #include <IPSDKGeometry/Entity/3d/Vector/Vector3d.h>
29 
30 namespace ipsdk {
31 namespace geom {
32 
35 
36 template <typename T>
38 {
39  // declare 3d geometry entity
41 
42 // predefined public types
43 public:
45  static const eCoordinateSystem3dType::domain g_coordinateSystem3dType = eCoordinateSystem3dType::eCS3DT_Cartesian;
46 
48  static const eEntity3dType::domain g_entity3dType = eEntity3dType::eE3DT_Triangle;
49 
50 public:
53  Triangle3d();
54  Triangle3d(const Point3dData<T>& pt0,
55  const Point3dData<T>& pt1,
56  const Point3dData<T>& pt2);
57  ~Triangle3d();
59 
60 // methods
61 public:
63  inline eCoordinateSystem3dType getCoordinateSystem3dType() const;
64 
66  inline eEntity3dType getEntity3dType() const;
67 
70  inline void setCoords(const Point3dData<T>& pt0,
71  const Point3dData<T>& pt1,
72  const Point3dData<T>& pt2);
73  inline void setPoint0(const Point3dData<T>& pt0);
74  inline Point3dData<T>& getPoint0();
75  inline const Point3dData<T>& getPoint0() const;
76  inline void setPoint1(const Point3dData<T>& pt1);
77  inline Point3dData<T>& getPoint1();
78  inline const Point3dData<T>& getPoint1() const;
79  inline void setPoint2(const Point3dData<T>& pt2);
80  inline Point3dData<T>& getPoint2();
81  inline const Point3dData<T>& getPoint2() const;
83 
87  Vector3d getUnitNormal() const;
88  inline void getUnitNormal(ipReal64& nx,
89  ipReal64& ny,
90  ipReal64& nz) const;
92 
96  Vector3d getNormal() const;
97  inline void getNormal(ipReal64& nx,
98  ipReal64& ny,
99  ipReal64& nz) const;
101 
103  Point3dData<ipReal64> getBarycenter() const;
104 
106  inline ipReal64 perimeter() const;
107 
109  inline ipReal64 area() const;
110 
111 // attributes
112 protected:
119 };
120 
123 
124 template <typename T>
127 {
128  return g_coordinateSystem3dType;
129 }
130 
131 template <typename T>
132 inline eEntity3dType
134 {
135  return g_entity3dType;
136 }
137 
138 template <typename T>
139 inline void
141  const Point3dData<T>& pt1,
142  const Point3dData<T>& pt2)
143 {
144  _pt0 = pt0;
145  _pt1 = pt1;
146  _pt2 = pt2;
147 }
148 
149 template <typename T>
150 inline void
152 {
153  _pt0 = pt0;
154 }
155 
156 template <typename T>
157 inline Point3dData<T>&
159 {
160  return _pt0;
161 }
162 
163 template <typename T>
164 inline const Point3dData<T>&
166 {
167  return _pt0;
168 }
169 
170 template <typename T>
171 inline void
173 {
174  _pt1 = pt1;
175 }
176 
177 template <typename T>
178 inline Point3dData<T>&
180 {
181  return _pt1;
182 }
183 
184 template <typename T>
185 inline const Point3dData<T>&
187 {
188  return _pt1;
189 }
190 
191 template <typename T>
192 inline void
194 {
195  _pt2 = pt2;
196 }
197 
198 template <typename T>
199 inline Point3dData<T>&
201 {
202  return _pt2;
203 }
204 
205 template <typename T>
206 inline const Point3dData<T>&
208 {
209  return _pt2;
210 }
211 
212 template <typename T>
213 inline void
215  ipReal64& ny,
216  ipReal64& nz) const
217 {
218  math::triangleUnitNormal(_pt0._x, _pt0._y, _pt0._z,
219  _pt1._x, _pt1._y, _pt1._z,
220  _pt2._x, _pt2._y, _pt2._z,
221  nx, ny, nz);
222 }
223 
224 template <typename T>
225 inline void
227  ipReal64& ny,
228  ipReal64& nz) const
229 {
230  math::triangleNormal(_pt0._x, _pt0._y, _pt0._z,
231  _pt1._x, _pt1._y, _pt1._z,
232  _pt2._x, _pt2._y, _pt2._z,
233  nx, ny, nz);
234 }
235 
236 template <typename T>
237 inline ipReal64
239 {
240  return math::trianglePerimeter(_pt0._x, _pt0._y, _pt0._z,
241  _pt1._x, _pt1._y, _pt1._z,
242  _pt2._x, _pt2._y, _pt2._z);
243 }
244 
245 template <typename T>
246 inline ipReal64
248 {
249  return math::triangleArea(_pt0._x, _pt0._y, _pt0._z,
250  _pt1._x, _pt1._y, _pt1._z,
251  _pt2._x, _pt2._y, _pt2._z);
252 }
253 
256 
257 } // end of namespace geom
258 } // end of namespace ipsdk
259 
260 #pragma warning (pop)
261 
262 #endif // __IPSDKGEOMETRY_TRIANGLE3D_H__
Point3dData< T > & getPoint1()
access to the triangle parameters
Definition: Triangle3d.h:179
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
eCoordinateSystem3dType
Enumerate describing coordinate system 3d type.
Definition: GeometryEntity3dTypes.h:74
IPSDK_FORCEINLINE bool triangleUnitNormal(const ipReal64 x0, const ipReal64 y0, const ipReal64 z0, const ipReal64 x1, const ipReal64 y1, const ipReal64 z1, const ipReal64 x2, const ipReal64 y2, const ipReal64 z2, ipReal64 &nx, ipReal64 &ny, ipReal64 &nz)
computation of triangle unit normal from its vertives coordinates
Definition: Triangle3d.h:68
eCoordinateSystem3dType getCoordinateSystem3dType() const
method allowing to retrieve coordinate system 3d type
Definition: Triangle3d.h:126
IPSDK_FORCEINLINE ipReal64 triangleArea(const ipReal64 x0, const ipReal64 y0, const ipReal64 z0, const ipReal64 x1, const ipReal64 y1, const ipReal64 z1, const ipReal64 x2, const ipReal64 y2, const ipReal64 z2)
computation of triangle area from its vertives coordinates
Definition: Triangle3d.h:40
ipReal64 perimeter() const
retrieve triangle perimeter
Definition: Triangle3d.h:238
IPSDK_FORCEINLINE void triangleNormal(const ipReal64 x0, const ipReal64 y0, const ipReal64 z0, const ipReal64 x1, const ipReal64 y1, const ipReal64 z1, const ipReal64 x2, const ipReal64 y2, const ipReal64 z2, ipReal64 &nx, ipReal64 &ny, ipReal64 &nz)
computation of triangle normal from its vertives coordinates
Definition: Triangle3d.h:54
#define IPSDK_DECLARE_GEOMETRY_ENTITY_3D(libraryName, className)
Macro allowing to declare a geometry entity 3d.
Definition: GeometryEntity3dHdrMacros.h:131
Point3dData< T > _pt2
points associated to triangle
Definition: Triangle3d.h:117
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Utility functions used to handle triangle 3d.
void setCoords(const Point3dData< T > &pt0, const Point3dData< T > &pt1, const Point3dData< T > &pt2)
access to the triangle parameters
Definition: Triangle3d.h:140
Vector class associated to spherical 3d coordinates.
Definition: Vector3d.h:32
Point3dData< T > _pt0
points associated to triangle
Definition: Triangle3d.h:115
Point3dData< T > & getPoint0()
access to the triangle parameters
Definition: Triangle3d.h:158
void setPoint1(const Point3dData< T > &pt1)
access to the triangle parameters
Definition: Triangle3d.h:172
Definition of import/export macro for library.
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
void setPoint0(const Point3dData< T > &pt0)
access to the triangle parameters
Definition: Triangle3d.h:151
IPSDK_FORCEINLINE ipReal64 trianglePerimeter(const ipReal64 x0, const ipReal64 y0, const ipReal64 z0, const ipReal64 x1, const ipReal64 y1, const ipReal64 z1, const ipReal64 x2, const ipReal64 y2, const ipReal64 z2)
computation of triangle perimeter from its vertives coordinates
Definition: Triangle3d.h:29
3d triangle associated to cartesian 3d coordinates
Definition: Triangle3d.h:37
void setPoint2(const Point3dData< T > &pt2)
access to the triangle parameters
Definition: Triangle3d.h:193
ipReal64 area() const
retrieve triangle area
Definition: Triangle3d.h:247
eEntity3dType getEntity3dType() const
method allowing to retrieve entity 3d type
Definition: Triangle3d.h:133
eEntity3dType
Enumerate describing entity 3d type.
Definition: GeometryEntity3dTypes.h:38
Point3dData< T > _pt1
points associated to triangle
Definition: Triangle3d.h:116
Vector3d getUnitNormal() const
retrieve triangle unit normal (computes unit cross product of pt1-pt0 and pt2-pt0) ...
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity3d.h:27
Cartesian coordinate system.
Definition: GeometryEntity3dTypes.h:76
Vector3d getNormal() const
retrieve triangle normal (computes cross product of pt1-pt0 and pt2-pt0)
Lightweight structure used to store Point3d data.
Definition: GeometryEntity3dTypes.h:27
Point3dData< T > & getPoint2()
access to the triangle parameters
Definition: Triangle3d.h:200
Triangle.
Definition: GeometryEntity3dTypes.h:66
Basic operators used for triangle 3d management.