IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Mesh3d.h
1 // Mesh3d.h:
3 // ---------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_MESH3D_H__
16 #define __IPSDKGEOMETRY_MESH3D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::geom::Mesh3d<T>::_mesh3dType': class 'ipsdk::geom::eMesh3dType' needs to have dll-interface to be used by clients of class 'ipsdk::geom::Mesh3d<T>'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
23 #include <IPSDKGeometry/Entity/3d/BaseTypedGeometryEntity3d.h>
28 #include <IPSDKGeometry/Entity/3d/Triangle/Triangle3d.h>
30 #include <boost/tuple/tuple.hpp>
31 #include <IPSDKGeometry/Entity/3d/BoundingBox/BoundingBox3d.h>
32 #include <IPSDKGeometry/Transform/3d/BaseGeometryTransform3d.h>
33 
34 
35 namespace ipsdk {
36 namespace geom {
37 
38 
41 
42 template <typename T>
44 {
45  // declare serial class
47 
48 protected:
49 
50 
51 // predefined public types
52 public:
54  static const eCoordinateSystem3dType::domain g_coordinateSystem3dType = eCoordinateSystem3dType::eCS3DT_Cartesian;
55 
57  static const eEntity3dType::domain g_entity3dType = eEntity3dType::eE3DT_Mesh;
58 
60  typedef T DataType;
61 
64 
66  typedef std::vector<VertexType> VertexColl;
67 
69  typedef typename VertexColl::iterator VertexIterator;
70 
72  typedef boost::shared_ptr<BoundingBox3d<DataType>> BoundingBox3dPtr;
73 
74 
75 public:
78  Mesh3d();
79  ~Mesh3d();
81 
82 // methods
83 public:
85  inline eCoordinateSystem3dType getCoordinateSystem3dType() const;
86 
88  inline eEntity3dType getEntity3dType() const;
89 
91  inline const eMesh3dType& getMesh3dType() const;
92 
94  inline void setMesh3dType(const eMesh3dType& mesh3dType);
95 
97  inline bool isEmpty() const;
98 
100  inline ipUInt64 getNbVertices() const;
101 
103  inline ipUInt64 getNbTriangles() const;
104 
106  inline ipUInt64 getNbEdges() const;
107 
109  inline const VertexColl& getVertexColl() const;
110 
112  inline VertexColl& getVertexColl();
113 
116  inline const UInt64Vector& getVertexToHalfEdgeColl() const;
117 
120  inline UInt64Vector& getVertexToHalfEdgeColl();
121 
124  inline const UInt64Vector& getTriangleToHalfEdgeColl() const;
125 
128  inline UInt64Vector& getTriangleToHalfEdgeColl();
129 
132  inline const TriVertexIxColl& getTriVertexIxColl() const;
133 
136  inline TriVertexIxColl& getTriVertexIxColl();
137 
138 
139  //inline std::vector<std::vector<ipUInt32>>& getTriVertexIxList();
140 
142  inline const Mesh3dHalfEdgeColl& getHalfEdgeColl() const;
143 
145  inline Mesh3dHalfEdgeColl& getHalfEdgeColl();
146 
150  const Mesh3dHalfEdge& getOppositeHalfEdge(const Mesh3dHalfEdge& halfEdge) const;
151 
155  const Mesh3dHalfEdge& getPreviousHalfEdge(const Mesh3dHalfEdge& halfEdge) const;
156 
160  const Mesh3dHalfEdge& getNextHalfEdge(const Mesh3dHalfEdge& halfEdge) const;
161 
165  const VertexType& getStartVertex(const Mesh3dHalfEdge& halfEdge) const;
166 
170  const VertexType& getEndVertex(const Mesh3dHalfEdge& halfEdge) const;
171 
175  Triangle3d<T> extractTriangle(const ipUInt64 triangleIdx) const;
176 
181  Triangle3d<T> extractLeftTriangle(const Mesh3dHalfEdge& halfEdge) const;
182 
187  Triangle3d<T> extractRightTriangle(const Mesh3dHalfEdge& halfEdge) const;
188 
190  inline BoundingBox3dPtr getBoundingBox();
191 
193  BoundingBox3dPtr computeBoundingBox();
194 
196  void copyFromMesh(const Mesh3d<T>& meshIn);
197 
198 
201  inline VertexIterator beginVertex();
202  inline VertexIterator endVertex();
204 
206  void clear();
207 
208 // attributes
209 protected:
212 
215 
219 
223 
226 
228  TriVertexIxColl _triVertexIxColl;
229 
232 
233 };
234 
237 
238 template <typename T>
241 {
242  return g_coordinateSystem3dType;
243 }
244 
245 template <typename T>
246 inline eEntity3dType
248 {
249  return g_entity3dType;
250 }
251 
252 template <typename T>
253 inline const eMesh3dType&
255 {
256  return _mesh3dType;
257 }
258 
259 template <typename T>
260 inline void
262 {
263  _mesh3dType = mesh3dType;
264 }
265 
266 template <typename T>
267 inline bool
269 {
270  return _vertexColl.empty();
271 }
272 
273 template <typename T>
274 IPSDK_FORCEINLINE ipUInt64
276 {
277  return static_cast<ipUInt64>(_vertexColl.size());
278 }
279 
280 template <typename T>
281 IPSDK_FORCEINLINE ipUInt64
283 {
284  return static_cast<ipUInt64>(_triangleToHalfEdgeColl.size());
285 }
286 
287 template <typename T>
288 IPSDK_FORCEINLINE ipUInt64
290 {
291  return static_cast<ipUInt64>(_halfEdgeColl.size() / 2);
292 }
293 
294 template <typename T>
295 IPSDK_FORCEINLINE const typename Mesh3d<T>::VertexColl&
297 {
298  return _vertexColl;
299 }
300 
301 template <typename T>
302 IPSDK_FORCEINLINE typename Mesh3d<T>::VertexColl&
304 {
305  return _vertexColl;
306 }
307 
308 template <typename T>
309 IPSDK_FORCEINLINE const UInt64Vector&
311 {
312  return _vertexToHalfEdgeColl;
313 }
314 
315 template <typename T>
316 IPSDK_FORCEINLINE UInt64Vector&
318 {
319  return _vertexToHalfEdgeColl;
320 }
321 
322 template <typename T>
323 IPSDK_FORCEINLINE const UInt64Vector&
325 {
326  return _triangleToHalfEdgeColl;
327 }
328 
329 template <typename T>
330 IPSDK_FORCEINLINE UInt64Vector&
332 {
333  return _triangleToHalfEdgeColl;
334 }
335 
336 template <typename T>
337 //TEST//
338 IPSDK_FORCEINLINE const TriVertexIxColl&
340 {
341  return _triVertexIxColl;
342 }
343 
344 template <typename T>
345 //TEST//
346 IPSDK_FORCEINLINE TriVertexIxColl&
348 {
349  return _triVertexIxColl;
350 }
351 /*
352 template <typename T>
353 IPSDK_FORCEINLINE std::vector<std::vector<ipUInt32>>&
354 Mesh3d<T>::getTriVertexIxList()
355 {
356  typedef std::vector<std::vector<ipUInt32>> TriVertexIxListType;
357  TriVertexIxListType triVertexIxList;
358  triVertexIxList.resize(_triVertexIxColl.size());
359 
360  TriVertexIxListType::iterator it = triVertexIxList.begin();
361  for (TriVertexIx& curTriVertexIx: _triVertexIxColl) {
362 
363  (*it).resize(3);
364 
365  std::vector<ipUInt32>::iterator subIt = it->begin();
366 
367  (*subIt++) = curTriVertexIx._vertexIx0;
368  (*subIt++) = curTriVertexIx._vertexIx1;
369  (*subIt++) = curTriVertexIx._vertexIx2;
370 
371  ++it;
372  }
373 
374  return triVertexIxList;
375 }
376 */
377 
378 
379 template <typename T>
380 IPSDK_FORCEINLINE const Mesh3dHalfEdgeColl&
382 {
383  return _halfEdgeColl;
384 }
385 
386 template <typename T>
387 IPSDK_FORCEINLINE Mesh3dHalfEdgeColl&
389 {
390  return _halfEdgeColl;
391 }
392 
393 template <typename T>
394 IPSDK_FORCEINLINE typename Mesh3d<T>::VertexIterator
396 {
397  return _vertexColl.begin();
398 }
399 
400 template <typename T>
401 IPSDK_FORCEINLINE typename Mesh3d<T>::VertexIterator
403 {
404  return _vertexColl.end();
405 }
406 
407 template <typename T>
408 IPSDK_FORCEINLINE typename Mesh3d<T>::BoundingBox3dPtr
410 {
411  if (_boundingBox3d.get() == nullptr)
412  _boundingBox3d = computeBoundingBox();
413 
414  return _boundingBox3d;
415 }
416 
417 
420 
421 } // end of namespace geom
422 } // end of namespace ipsdk
423 
424 #pragma warning (pop)
425 
426 #endif // __IPSDKGEOMETRY_MESH3D_H__
BoundingBox3dPtr _boundingBox3d
bounding box associated to mesh
Definition: Mesh3d.h:231
TriVertexIxColl _triVertexIxColl
collection of triangles represented by vertices indices
Definition: Mesh3d.h:228
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
eCoordinateSystem3dType
Enumerate describing coordinate system 3d type.
Definition: GeometryEntity3dTypes.h:74
boost::shared_ptr< BoundingBox3d< DataType > > BoundingBox3dPtr
Bounding box 3d associated to entity.
Definition: Mesh3d.h:72
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
#define IPSDK_DECLARE_GEOMETRY_ENTITY_3D(libraryName, className)
Macro allowing to declare a geometry entity 3d.
Definition: GeometryEntity3dHdrMacros.h:131
eEntity3dType getEntity3dType() const
method allowing to retrieve entity 3d type
Definition: Mesh3d.h:247
Basic operators used for mesh 3d management.
const UInt64Vector & getTriangleToHalfEdgeColl() const
Definition: Mesh3d.h:324
VertexIterator beginVertex()
Definition: Mesh3d.h:395
std::vector< ipUInt64 > UInt64Vector
stl vector collections
Definition: BaseCollections.h:35
UInt64Vector _triangleToHalfEdgeColl
Definition: Mesh3d.h:222
const TriVertexIxColl & getTriVertexIxColl() const
Definition: Mesh3d.h:339
std::vector< Mesh3dHalfEdge > Mesh3dHalfEdgeColl
collection of half edges information associated to mesh 3d objects
Definition: Mesh3dTypes.h:116
BoundingBox3dPtr getBoundingBox()
access to the max z of the bounding box
Definition: Mesh3d.h:409
eCoordinateSystem3dType getCoordinateSystem3dType() const
method allowing to retrieve coordinate system 3d type
Definition: Mesh3d.h:240
Definition: Mesh3dTypes.h:52
VertexColl _vertexColl
collection of vertex associated to mesh
Definition: Mesh3d.h:214
bool isEmpty() const
method allowing to check whether mesh is empty
Definition: Mesh3d.h:268
const eMesh3dType & getMesh3dType() const
retrieve mesh 3d type
Definition: Mesh3d.h:254
UInt64Vector _vertexToHalfEdgeColl
Definition: Mesh3d.h:218
const UInt64Vector & getVertexToHalfEdgeColl() const
Definition: Mesh3d.h:310
Predefined types for mesh 3d management.
ipUInt64 getNbTriangles() const
retrieve number of triangles
Definition: Mesh3d.h:282
ipUInt64 getNbVertices() const
retrieve number of vertices
Definition: Mesh3d.h:275
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
std::vector< VertexType > VertexColl
collection of vertexes associated to polygon
Definition: Mesh3d.h:66
const VertexColl & getVertexColl() const
retrieve vertex collection
Definition: Mesh3d.h:296
3d triangle associated to cartesian 3d coordinates
Definition: Triangle3d.h:37
VertexIterator endVertex()
Definition: Mesh3d.h:402
ipUInt64 getNbEdges() const
retrieve number of edges
Definition: Mesh3d.h:289
T DataType
underlying data type associated to object
Definition: Mesh3d.h:60
const Mesh3dHalfEdgeColl & getHalfEdgeColl() const
retrieve half edge information collection
Definition: Mesh3d.h:381
Utility functions for mesh 3d management.
Point3dData< T > VertexType
vertex type associated to object
Definition: Mesh3d.h:63
eEntity3dType
Enumerate describing entity 3d type.
Definition: GeometryEntity3dTypes.h:38
Header files allowing to gather iterators and circulators framework for mesh 3d objects.
VertexColl::iterator VertexIterator
iterator allowing to modify verices coordinates
Definition: Mesh3d.h:69
eMesh3dType _mesh3dType
flag indicating whether mesh is exterior or interior
Definition: Mesh3d.h:211
Closed mesh associated to a triangulated boundary.
Definition: Mesh3d.h:43
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity3d.h:27
eMesh3dType
Enumerate describing mesh type.
Definition: Mesh3dTypes.h:35
Cartesian coordinate system.
Definition: GeometryEntity3dTypes.h:76
Mesh3dHalfEdgeColl _halfEdgeColl
collection of half edge information
Definition: Mesh3d.h:225
Lightweight structure used to store Point3d data.
Definition: GeometryEntity3dTypes.h:27
void setMesh3dType(const eMesh3dType &mesh3dType)
setup mesh 3d type
Definition: Mesh3d.h:261
boost::enable_if< typename boost::mpl::and_< typename boost::is_same< boost::mpl::int_< AttributeType::g_attributeType >, boost::mpl::int_< eAttributeType::eAT_DataItem > >::type, typename boost::is_same< boost::mpl::int_< LeafCollType::g_itemType >, boost::mpl::int_< eDataItemType::eDIT_LeafColl > >::type >::type, RulePtr >::type isEmpty(const boost::shared_ptr< AttributeType > &pAttribute)
functions allowing to check that a leaf collection is empty
Definition: LeafCollSizeRuleOperators.h:65
Mesh.
Definition: GeometryEntity3dTypes.h:56