IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Mesh3dVertexVertexConstCirculator.h
1 // Mesh3dVertexVertexConstCirculator.h:
3 // ------------------------------------
4 //
15 
16 #ifndef __IPSDKGEOMETRY_MESH3DVERTEXVERTEXCONSTCIRCULATOR_H__
17 #define __IPSDKGEOMETRY_MESH3DVERTEXVERTEXCONSTCIRCULATOR_H__
18 
23 
24 namespace ipsdk {
25 namespace geom {
26 
29 
30 template <typename MeshType>
32 {
33 // predefined public types
34 public:
36  typedef typename MeshType::DataType T;
37 
39  typedef typename MeshType::VertexType VertexType;
40 
43 
45  typedef std::input_iterator_tag iterator_category;
46 
49 
50  // difference type for iterator
51  typedef ipUInt32 difference_type;
52 
54  typedef const VertexType* pointer;
55 
56  // reference type associated to iterator
57  typedef const VertexType& reference;
58 
59 public:
63  _pMesh(0),
66 
67  {
68  }
69  Mesh3dVertexVertexConstCirculator(const MeshType* pMesh,
70  const ipUInt32 startVertexIdx) :
71  _pMesh(pMesh),
72  _startHalfEdgeIdx(_pMesh->getVertexToHalfEdgeColl()[startVertexIdx]),
74  {
75 
76  }
77  Mesh3dVertexVertexConstCirculator(const Iterator& iter) :
78  _pMesh(iter._pMesh),
81  {
82  }
83  Mesh3dVertexVertexConstCirculator& operator= (const Iterator& iter)
84  {
85  _pMesh = iter._pMesh;
86  _startHalfEdgeIdx = iter._startHalfEdgeIdx;
87  _curHalfEdgeIdx = iter._curHalfEdgeIdx;
88  }
89  ~Mesh3dVertexVertexConstCirculator()
90  {
91  }
93 
94 // methods
95 public:
97  const ipUInt32 getStartHalfEdgeIdx() const;
98 
100  const ipUInt32 getCurHalfEdgeIdx() const;
101 
103  const VertexType& getStartVertex() const;
104 
106  inline Iterator& operator++();
107 
110  inline bool operator==(const Iterator& iter) const;
111  inline bool operator!=(const Iterator& iter) const;
113 
115  inline const VertexType* operator->() const;
116 
118  inline const VertexType& operator*() const;
119 
121  void swap(Iterator& iter);
122 
123 // attributes
124 protected:
126  const MeshType* _pMesh;
127 
130 
134 };
135 
138 
139 template <typename MeshType>
140 IPSDK_FORCEINLINE const ipUInt32
142 {
143  return _startHalfEdgeIdx;
144 }
145 
146 template <typename MeshType>
147 IPSDK_FORCEINLINE const ipUInt32
149 {
150  return _curHalfEdgeIdx;
151 }
152 
153 template <typename MeshType>
154 IPSDK_FORCEINLINE const typename Mesh3dVertexVertexConstCirculator<MeshType>::VertexType&
156 {
157  const Mesh3dHalfEdge& startHalfEdge = _pMesh->getHalfEdgeColl()[_startHalfEdgeIdx];
158  const VertexType& startVertex = _pMesh->getVertexColl()[startHalfEdge._startVertexIdx];
159 
160  return startVertex;
161 }
162 
163 template <typename MeshType>
166 {
167  // search for next half edge
168  const Mesh3dHalfEdge& curHalfEdge = _pMesh->getHalfEdgeColl()[_curHalfEdgeIdx];
169  const Mesh3dHalfEdge& oppositeHalfEdge = _pMesh->getHalfEdgeColl()[curHalfEdge._oppositeHalfEdgeIdx];
170  _curHalfEdgeIdx = oppositeHalfEdge._nextHalfEdgeIdx;
171  if (_curHalfEdgeIdx == _startHalfEdgeIdx)
172  _curHalfEdgeIdx = NumericLimits<ipUInt32>::max();
173 
174  return *this;
175 }
176 
177 template <typename MeshType>
178 IPSDK_FORCEINLINE bool
180 {
181  return _curHalfEdgeIdx == iter._curHalfEdgeIdx;
182 }
183 
184 template <typename MeshType>
185 IPSDK_FORCEINLINE bool
187 {
188  return _curHalfEdgeIdx != iter._curHalfEdgeIdx;
189 }
190 
191 template <typename MeshType>
192 IPSDK_FORCEINLINE const typename Mesh3dVertexVertexConstCirculator<MeshType>::VertexType*
194 {
195  const Mesh3dHalfEdge& curHalfEdge = _pMesh->getHalfEdgeColl()[_curHalfEdgeIdx];
196  const VertexType& curVertex = _pMesh->getVertexColl()[curHalfEdge._startVertexIdx];
197 
198  return &curVertex;
199 }
200 
201 template <typename MeshType>
202 IPSDK_FORCEINLINE const typename Mesh3dVertexVertexConstCirculator<MeshType>::VertexType&
204 {
205  const Mesh3dHalfEdge& curHalfEdge = _pMesh->getHalfEdgeColl()[_curHalfEdgeIdx];
206  const VertexType& curVertex = _pMesh->getVertexColl()[curHalfEdge._startVertexIdx];
207 
208  return curVertex;
209 }
210 
211 template <typename MeshType>
212 inline void
214 {
215  std::swap(_pMesh, iter._pMesh);
216  std::swap(_startHalfEdgeIdx, iter._startHalfEdgeIdx);
217  std::swap(_curHalfEdgeIdx, iter._curHalfEdgeIdx);
218 }
219 
222 
223 } // end of namespace geom
224 } // end of namespace ipsdk
225 
226 #endif // __IPSDKGEOMETRY_MESH3DVERTEXVERTEXCONSTCIRCULATOR_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
MeshType::VertexType VertexType
underlying mesh 3d vertex type
Definition: Mesh3dVertexVertexConstCirculator.h:39
std::input_iterator_tag iterator_category
iterator category
Definition: Mesh3dVertexVertexConstCirculator.h:45
bool operator==(const Iterator &iter) const
iterator comparison
Definition: Mesh3dVertexVertexConstCirculator.h:179
VertexType value_type
value type associated to iterator
Definition: Mesh3dVertexVertexConstCirculator.h:48
MeshType::DataType T
underlying mesh 3d data type
Definition: Mesh3dVertexVertexConstCirculator.h:36
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
bool operator!=(const Iterator &iter) const
iterator comparison
Definition: Mesh3dVertexVertexConstCirculator.h:186
Predefined types for mesh 3d management.
Definition of import/export macro for library.
Mesh3dVertexVertexConstCirculator< MeshType > Iterator
iterator type
Definition: Mesh3dVertexVertexConstCirculator.h:42
Iterator class allowing to circulate over vertices immediatly neighbors of a given vertex...
Definition: Mesh3dVertexVertexConstCirculator.h:31
ipUInt64 _oppositeHalfEdgeIdx
Definition: Mesh3dTypes.h:62
const VertexType & getStartVertex() const
retrieve starting vertex associated to circulator
Definition: Mesh3dVertexVertexConstCirculator.h:155
Vector DataType
data type used for estimation
Definition: EstimationTypes.h:58
void swap(Iterator &iter)
swap between iterators
Definition: Mesh3dVertexVertexConstCirculator.h:213
ipUInt64 _startVertexIdx
index of start vertex for half edge
Definition: Mesh3dTypes.h:55
const VertexType * pointer
pointer type for iterator
Definition: Mesh3dVertexVertexConstCirculator.h:54
ipUInt32 _curHalfEdgeIdx
Definition: Mesh3dVertexVertexConstCirculator.h:133
ipUInt64 _nextHalfEdgeIdx
index of next half edge inside left triangle
Definition: Mesh3dTypes.h:65
const MeshType * _pMesh
reference to mesh 3d associated to iterator
Definition: Mesh3dVertexVertexConstCirculator.h:126
const ipUInt32 getCurHalfEdgeIdx() const
retrieve current half edge index associated to circulator
Definition: Mesh3dVertexVertexConstCirculator.h:148
const ipUInt32 getStartHalfEdgeIdx() const
retrieve starting half edge index associated to circulator
Definition: Mesh3dVertexVertexConstCirculator.h:141
const VertexType & operator*() const
retrieve current triangle associated to iterator position
Definition: Mesh3dVertexVertexConstCirculator.h:203
ipUInt32 _startHalfEdgeIdx
starting half edge index
Definition: Mesh3dVertexVertexConstCirculator.h:129
const VertexType * operator->() const
retrieve current triangle associated to iterator position
Definition: Mesh3dVertexVertexConstCirculator.h:193
Iterator & operator++()
increment of iterator
Definition: Mesh3dVertexVertexConstCirculator.h:165
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53