IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Sphere3d.h
1 // Sphere3d.h:
3 // -----------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_SPHERE3D_H__
16 #define __IPSDKGEOMETRY_SPHERE3D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::geom::Sphere3d<ipsdk::ipInt32>::_centerPt': struct 'ipsdk::geom::Point3dData<T>' needs to have dll-interface to be used by clients of class 'ipsdk::geom::Sphere3d<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/Point3d.h>
28 
29 namespace ipsdk {
30 namespace geom {
31 
34 
35 template <typename T>
37 {
38  // declare 3d geometry entity
40 
41 // predefined public types
42 public:
44  static const eCoordinateSystem3dType::domain g_coordinateSystem3dType = eCoordinateSystem3dType::eCS3DT_Cartesian;
45 
47  static const eEntity3dType::domain g_entity3dType = eEntity3dType::eE3DT_Sphere;
48 
49 public:
52  Sphere3d();
53  Sphere3d(const Point3dData<T>& center, const T radius);
54  Sphere3d(const Point3d<T>& center, const T radius);
55  Sphere3d(const T xCenter, const T yCenter, const T zCenter, const T radius);
56  ~Sphere3d();
58 
59 // methods
60 public:
62  inline eCoordinateSystem3dType getCoordinateSystem3dType() const;
63 
65  inline eEntity3dType getEntity3dType() const;
66 
69  inline void setCoords(const Point3dData<T>& centerPt, const T radius);
70  inline void setCoords(const Point3d<T>& centerPt, const T radius);
71  inline void setCoords(const T xCenter, const T yCenter, const T zCenter, const T radius);
72  inline void setCenter(const Point3dData<T>& centerPt);
73  inline void setCenter(const Point3d<T>& centerPt);
74  inline void setCenter(const T xCenter, const T yCenter, const T zCenter);
75  inline void setRadius(const T radius);
76  inline T getRadius() const;
77  inline T centerX() const;
78  inline T centerY() const;
79  inline T centerZ() const;
80  inline const Point3dData<T>& center() const;
81  inline Point3dData<T>& center();
83 
86  inline ipReal64 distance(const Point3d<T>& pt) const;
87  ipReal64 distance(const Point3dData<T>& pt) const;
89 
93  inline ipReal64 signedDistance(const Point3d<T>& pt) const;
94  ipReal64 signedDistance(const Point3dData<T>& pt) const;
96 
98  ipReal64 area() const;
99 
101  ipReal64 volume() const;
102 
103 // attributes
104 protected:
107 
110 
111 };
112 
115 
116 template <typename T>
119 {
120  return g_coordinateSystem3dType;
121 }
122 
123 template <typename T>
124 inline eEntity3dType
126 {
127  return g_entity3dType;
128 }
129 
130 template <typename T>
131 inline void
132 Sphere3d<T>::setCoords(const Point3dData<T>& centerPt, const T radius)
133 {
134  _centerPt = centerPt;
135  _radius = radius;
136 }
137 
138 template <typename T>
139 inline void
140 Sphere3d<T>::setCoords(const Point3d<T>& centerPt, const T radius)
141 {
142  _centerPt = centerPt.getCoords();
143  _radius = radius;
144 }
145 
146 template <typename T>
147 inline void
148 Sphere3d<T>::setCoords(const T xCenter, const T yCenter, const T zCenter, const T radius)
149 {
150  _centerPt.setCoords(xCenter, yCenter, zCenter);
151  _radius = radius;
152 }
153 
154 template <typename T>
155 inline void
157 {
158  _centerPt = centerPt;
159 }
160 
161 template <typename T>
162 inline void
164 {
165  _centerPt = centerPt.getCoords();
166 }
167 
168 template <typename T>
169 inline void
170 Sphere3d<T>::setCenter(const T xCenter, const T yCenter, const T zCenter)
171 {
172  _centerPt.setCoords(xCenter, yCenter, zCenter);
173 }
174 
175 template <typename T>
176 inline void
177 Sphere3d<T>::setRadius(const T radius)
178 {
179  _radius = radius;
180 }
181 
182 template <typename T>
183 inline T
185 {
186  return _centerPt._x;
187 }
188 
189 template <typename T>
190 inline T
192 {
193  return _centerPt._y;
194 }
195 
196 template <typename T>
197 inline T
199 {
200  return _centerPt._z;
201 }
202 
203 template <typename T>
204 inline const Point3dData<T>&
206 {
207  return _centerPt;
208 }
209 
210 template <typename T>
211 inline Point3dData<T>&
213 {
214  return _centerPt;
215 }
216 
217 template <typename T>
218 inline T
220 {
221  return _radius;
222 }
223 
224 template <typename T>
225 inline ipReal64
227 {
228  return distance(pt.getCoords());
229 }
230 
231 template <typename T>
232 inline ipReal64
234 {
235  return std::abs(signedDistance(pt));
236 }
237 
238 template <typename T>
239 inline ipReal64
241 {
242  return signedDistance(pt.getCoords());
243 }
244 
245 template <typename T>
246 inline ipReal64
248 {
249  return math::sphereArea(_radius);
250 }
251 
252 template <typename T>
253 inline ipReal64
255 {
256  return math::sphereVolume(_radius);
257 }
258 
261 
262 } // end of namespace geom
263 } // end of namespace ipsdk
264 
265 #pragma warning (pop)
266 
267 #endif // __IPSDKGEOMETRY_SPHERE3D_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
eCoordinateSystem3dType
Enumerate describing coordinate system 3d type.
Definition: GeometryEntity3dTypes.h:74
void setCenter(const Point3dData< T > &centerPt)
access to the sphere parameters
Definition: Sphere3d.h:156
Point class associated to cartesian 3d coordinates.
Definition: GeometryEntity3dTypes.h:29
T centerX() const
access to the sphere parameters
Definition: Sphere3d.h:184
3d sphere associated to cartesian 3d coordinates
Definition: Sphere3d.h:36
ipReal64 area() const
retrieve sphere area
Definition: Sphere3d.h:247
#define IPSDK_DECLARE_GEOMETRY_ENTITY_3D(libraryName, className)
Macro allowing to declare a geometry entity 3d.
Definition: GeometryEntity3dHdrMacros.h:131
Point3dData< T > _centerPt
center of the sphere
Definition: Sphere3d.h:106
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
IPSDK_FORCEINLINE ipReal64 sphereVolume(const ipReal64 radius)
compute sphere volume
Definition: Sphere3d.h:54
IPSDK_FORCEINLINE ipReal64 sphereArea(const ipReal64 radius)
compute sphere area
Definition: Sphere3d.h:47
const Point3dData< T > & getCoords() const
access to point coordinates
Definition: Point3d.h:142
T centerZ() const
access to the sphere parameters
Definition: Sphere3d.h:198
ipReal64 distance(const Point3d< T > &pt) const
retrieve orthogonal distance between point and sphere
Definition: Sphere3d.h:226
T _radius
radius of the circle
Definition: Sphere3d.h:109
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.
Utility functions used to handle spheres 3d.
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
T getRadius() const
access to the sphere parameters
Definition: Sphere3d.h:219
ipReal64 volume() const
retrieve sphere volume
Definition: Sphere3d.h:254
eEntity3dType
Enumerate describing entity 3d type.
Definition: GeometryEntity3dTypes.h:38
ipReal64 signedDistance(const Point3d< T > &pt) const
retrieve signed orthogonal distance between point and sphere (positive value stands for exterior poin...
Definition: Sphere3d.h:240
void setRadius(const T radius)
access to the sphere parameters
Definition: Sphere3d.h:177
Basic operators used for sphere 3d management.
void setCoords(const Point3dData< T > &centerPt, const T radius)
access to the sphere parameters
Definition: Sphere3d.h:132
eCoordinateSystem3dType getCoordinateSystem3dType() const
method allowing to retrieve coordinate system 3d type
Definition: Sphere3d.h:118
const Point3dData< T > & center() const
access to the sphere parameters
Definition: Sphere3d.h:205
eEntity3dType getEntity3dType() const
method allowing to retrieve entity 3d type
Definition: Sphere3d.h:125
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity3d.h:27
Cartesian coordinate system.
Definition: GeometryEntity3dTypes.h:76
Sphere.
Definition: GeometryEntity3dTypes.h:48
Lightweight structure used to store Point3d data.
Definition: GeometryEntity3dTypes.h:27
T centerY() const
access to the sphere parameters
Definition: Sphere3d.h:191
IPSDK_FORCEINLINE PackT abs(const PackT &in)
returns the absolute value of a pack
Definition: abs.h:41