IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Mesh3dVertexTriangleConstCirculator.h
1 // Mesh3dVertexTriangleConstCirculator.h:
3 // --------------------------------------
4 //
15 
16 #ifndef __IPSDKGEOMETRY_MESH3DVERTEXTRIANGLECONSTCIRCULATOR_H__
17 #define __IPSDKGEOMETRY_MESH3DVERTEXTRIANGLECONSTCIRCULATOR_H__
18 
21 #include <IPSDKGeometry/Entity/3d/Triangle/Triangle3d.h>
24 
25 namespace ipsdk {
26 namespace geom {
27 
30 
31 template <typename MeshType>
33 {
34 // predefined public types
35 public:
37  typedef typename MeshType::DataType T;
38 
40  typedef typename MeshType::VertexType VertexType;
41 
44 
47 
49  typedef std::input_iterator_tag iterator_category;
50 
53 
54  // difference type for iterator
55  typedef ipUInt32 difference_type;
56 
58  typedef const TriangleType* pointer;
59 
60  // reference type associated to iterator
61  typedef const TriangleType& reference;
62 
63 public:
67  _pMesh(0),
70 
71  {
72  }
73  Mesh3dVertexTriangleConstCirculator(const MeshType* pMesh,
74  const ipUInt32 startVertexIdx) :
75  _pMesh(pMesh),
76  _startHalfEdgeIdx(_pMesh->getVertexToHalfEdgeColl()[startVertexIdx]),
78  {
79  updateData();
80  }
81  Mesh3dVertexTriangleConstCirculator(const Iterator& iter) :
82  _pMesh(iter._pMesh),
85  _triangle(iter._triangle)
86  {
87  }
88  Mesh3dVertexTriangleConstCirculator& operator= (const Iterator& iter)
89  {
90  _pMesh = iter._pMesh;
91  _startHalfEdgeIdx = iter._startHalfEdgeIdx;
92  _curHalfEdgeIdx = iter._curHalfEdgeIdx;
93  _triangle = iter._triangle;
94  }
95  ~Mesh3dVertexTriangleConstCirculator()
96  {
97  }
99 
100 // methods
101 public:
103  const ipUInt32 getStartHalfEdgeIdx() const;
104 
106  const ipUInt32 getCurHalfEdgeIdx() const;
107 
109  const VertexType& getStartVertex() const;
110 
112  inline Iterator& operator++();
113 
116  inline bool operator==(const Iterator& iter) const;
117  inline bool operator!=(const Iterator& iter) const;
119 
121  inline const TriangleType* operator->() const;
122 
124  inline const TriangleType& operator*() const;
125 
127  void swap(Iterator& iter);
128 
129 protected:
131  inline void updateData();
132 
133 // attributes
134 protected:
136  const MeshType* _pMesh;
137 
140 
144 
147 };
148 
151 
152 template <typename MeshType>
153 IPSDK_FORCEINLINE const ipUInt32
155 {
156  return _startHalfEdgeIdx;
157 }
158 
159 template <typename MeshType>
160 IPSDK_FORCEINLINE const ipUInt32
162 {
163  return _curHalfEdgeIdx;
164 }
165 
166 template <typename MeshType>
167 IPSDK_FORCEINLINE const typename Mesh3dVertexTriangleConstCirculator<MeshType>::VertexType&
169 {
170  const Mesh3dHalfEdge& startHalfEdge = _pMesh->getHalfEdgeColl()[_startHalfEdgeIdx];
171  const VertexType& startVertex = _pMesh->getVertexColl()[startHalfEdge._startVertexIdx];
172 
173  return startVertex;
174 }
175 
176 template <typename MeshType>
179 {
180  // search for next half edge
181  const Mesh3dHalfEdge& curHalfEdge = _pMesh->getHalfEdgeColl()[_curHalfEdgeIdx];
182  const Mesh3dHalfEdge& oppositeHalfEdge = _pMesh->getHalfEdgeColl()[curHalfEdge._oppositeHalfEdgeIdx];
183  _curHalfEdgeIdx = oppositeHalfEdge._nextHalfEdgeIdx;
184  if (_curHalfEdgeIdx == _startHalfEdgeIdx)
185  _curHalfEdgeIdx = NumericLimits<ipUInt32>::max();
186  updateData();
187 
188  return *this;
189 }
190 
191 template <typename MeshType>
192 IPSDK_FORCEINLINE bool
194 {
195  return _curHalfEdgeIdx == iter._curHalfEdgeIdx;
196 }
197 
198 template <typename MeshType>
199 IPSDK_FORCEINLINE bool
201 {
202  return _curHalfEdgeIdx != iter._curHalfEdgeIdx;
203 }
204 
205 template <typename MeshType>
206 IPSDK_FORCEINLINE const typename Mesh3dVertexTriangleConstCirculator<MeshType>::TriangleType*
208 {
209  return &_triangle;
210 }
211 
212 template <typename MeshType>
213 IPSDK_FORCEINLINE const typename Mesh3dVertexTriangleConstCirculator<MeshType>::TriangleType&
215 {
216  return _triangle;
217 }
218 
219 template <typename MeshType>
220 IPSDK_FORCEINLINE void
222 {
223  const Mesh3dHalfEdge& curHalfEdge = _pMesh->getHalfEdgeColl()[_curHalfEdgeIdx];
224  const Mesh3dHalfEdge& nextHalfEdge = _pMesh->getHalfEdgeColl()[curHalfEdge._nextHalfEdgeIdx];
225  const Mesh3dHalfEdge& prevHalfEdge = _pMesh->getHalfEdgeColl()[nextHalfEdge._nextHalfEdgeIdx];
226  const VertexType& v0 = _pMesh->getVertexColl()[curHalfEdge._startVertexIdx];
227  const VertexType& v1 = _pMesh->getVertexColl()[nextHalfEdge._startVertexIdx];
228  const VertexType& v2 = _pMesh->getVertexColl()[prevHalfEdge._startVertexIdx];
229 
230  _triangle.setCoords(v0, v1, v2);
231 }
232 
233 template <typename MeshType>
234 inline void
236 {
237  std::swap(_pMesh, iter._pMesh);
238  std::swap(_startHalfEdgeIdx, iter._startHalfEdgeIdx);
239  std::swap(_curHalfEdgeIdx, iter._curHalfEdgeIdx);
240  std::swap(_triangle, iter._triangle);
241 }
242 
245 
246 } // end of namespace geom
247 } // end of namespace ipsdk
248 
249 #endif // __IPSDKGEOMETRY_MESH3DVERTEXTRIANGLECONSTCIRCULATOR_H__
ipUInt32 _startHalfEdgeIdx
starting half edge index
Definition: Mesh3dVertexTriangleConstCirculator.h:139
const ipUInt32 getStartHalfEdgeIdx() const
retrieve starting half edge index associated to circulator
Definition: Mesh3dVertexTriangleConstCirculator.h:154
const ipUInt32 getCurHalfEdgeIdx() const
retrieve current half edge index associated to circulator
Definition: Mesh3dVertexTriangleConstCirculator.h:161
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
void updateData()
method allowing to update iterator internal data
Definition: Mesh3dVertexTriangleConstCirculator.h:221
const TriangleType * pointer
pointer type for iterator
Definition: Mesh3dVertexTriangleConstCirculator.h:58
TriangleType value_type
value type associated to iterator
Definition: Mesh3dVertexTriangleConstCirculator.h:52
Iterator & operator++()
increment of iterator
Definition: Mesh3dVertexTriangleConstCirculator.h:178
ipUInt32 _curHalfEdgeIdx
Definition: Mesh3dVertexTriangleConstCirculator.h:143
const VertexType & getStartVertex() const
retrieve starting vertex associated to circulator
Definition: Mesh3dVertexTriangleConstCirculator.h:168
Definition: Mesh3dTypes.h:52
Definition: NumericLimits.h:27
IPSDK_FORCEINLINE PackT max(const PackT &in1, const PackT &in2)
returns the maximum of 2 packs
Definition: max.h:40
Predefined types for mesh 3d management.
bool operator!=(const Iterator &iter) const
iterator comparison
Definition: Mesh3dVertexTriangleConstCirculator.h:200
Definition of import/export macro for library.
TriangleType _triangle
triangle data associated to current iterator position
Definition: Mesh3dVertexTriangleConstCirculator.h:146
3d triangle associated to cartesian 3d coordinates
Definition: Triangle3d.h:37
ipUInt64 _oppositeHalfEdgeIdx
Definition: Mesh3dTypes.h:62
MeshType::DataType T
underlying mesh 3d data type
Definition: Mesh3dVertexTriangleConstCirculator.h:37
const TriangleType * operator->() const
retrieve current triangle associated to iterator position
Definition: Mesh3dVertexTriangleConstCirculator.h:207
Triangle3d< T > TriangleType
underlying triangle 3d type
Definition: Mesh3dVertexTriangleConstCirculator.h:43
Vector DataType
data type used for estimation
Definition: EstimationTypes.h:58
Iterator class allowing to circulate over triangle with a top associated to a given vertex...
Definition: Mesh3dVertexTriangleConstCirculator.h:32
bool operator==(const Iterator &iter) const
iterator comparison
Definition: Mesh3dVertexTriangleConstCirculator.h:193
ipUInt64 _startVertexIdx
index of start vertex for half edge
Definition: Mesh3dTypes.h:55
void swap(Iterator &iter)
swap between iterators
Definition: Mesh3dVertexTriangleConstCirculator.h:235
ipUInt64 _nextHalfEdgeIdx
index of next half edge inside left triangle
Definition: Mesh3dTypes.h:65
MeshType::VertexType VertexType
underlying mesh 3d vertex type
Definition: Mesh3dVertexTriangleConstCirculator.h:40
const TriangleType & operator*() const
retrieve current triangle associated to iterator position
Definition: Mesh3dVertexTriangleConstCirculator.h:214
std::input_iterator_tag iterator_category
iterator category
Definition: Mesh3dVertexTriangleConstCirculator.h:49
const MeshType * _pMesh
reference to mesh 3d associated to iterator
Definition: Mesh3dVertexTriangleConstCirculator.h:136
Mesh3dVertexTriangleConstCirculator< MeshType > Iterator
iterator type
Definition: Mesh3dVertexTriangleConstCirculator.h:46
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53