MeVisLab Toolbox Reference
CSOPathPointIterator.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 
16 
17 #pragma once
18 
19 
20 #include "CSOBase/CSO.h"
21 #include "MLCSOIncludes.h"
22 
23 ML_START_NAMESPACE
24 
26 {
27 public:
28 
30 
31  static const unsigned int INVALID_INDEX;
32 
34 
38  CSOPathPointIterator(CSO* cso, unsigned int startPathIndex=0, unsigned int startPointIndex=0);
40  CSOPathPointIterator(CSO* cso, CSOPathPoints* pathPoints, unsigned int startPathIndex, unsigned int startPointIndex);
42  CSOPathPointIterator(CSO* cso, CSOPathPoints* pathPoints, unsigned int startPointIndex);
44  CSOPathPointIterator(CSO* cso, CSOSeedPoint* startSeedPoint);
47 
49  ~CSOPathPointIterator() = default;
50 
52 
54  CSOPathPointIterator& operator++ ();
56  CSOPathPointIterator operator++ (int dummy);
57 
59  CSOPathPointIterator& operator-- ();
61  CSOPathPointIterator operator-- (int dummy);
62 
67 
69  CSOPathPointIterator operator+ (int offset) const;
71  CSOPathPointIterator operator- (int offset) const;
72 
74  CSOPathPointIterator& operator= (const CSOPathPointIterator& rhs);
75 
77  bool operator== (const CSOPathPointIterator& rhs) const;
79  bool operator!= (const CSOPathPointIterator& rhs) const;
81  bool operator> (const CSOPathPointIterator& rhs) const;
83  bool operator>= (const CSOPathPointIterator& rhs) const;
85  bool operator< (const CSOPathPointIterator& rhs) const;
87  bool operator<= (const CSOPathPointIterator& rhs) const;
88 
90 
92  inline const CSO* getCSO () const { return _cso; }
94  inline CSO* getCSO () { return _cso; }
95 
97  inline unsigned int getPathIndex () const { return _pathIndex; }
99  inline unsigned int getPointIndex () const { return _pointIndex; }
100 
101  // Returns a pointer to the current path point list.
102  inline const CSOPathPoints* getPathPoints() const { return _pathPoints; }
103  // Returns a pointer to the current path point list.
104  inline CSOPathPoints* getPathPoints() { return _pathPoints; }
105 
107  inline Vector3 getPos () const { return _pathPoints->getPosAt(_pointIndex); }
109  inline const Vector4& getPosValue () const { return _pathPoints->getPosValueAt(_pointIndex); }
111  inline double getValue () const { return _pathPoints->getValueAt(_pointIndex); }
112 
114  inline void setPos(const Vector3& p) { _pathPoints->setPosAt(p, _pointIndex); }
116  inline void setPosValue(const Vector4& p) { _pathPoints->setPosValueAt(p, _pointIndex); }
118  inline void setValue(const double& v) { _pathPoints->setValueAt(static_cast<float>(v), _pointIndex); }
119 
121  inline unsigned int numPoints () const { return _numPoints; }
124  inline unsigned int numProcessedPoints () const { return mlAbs(_pointCounterInc-_pointCounterDec); }
127  inline unsigned int numTotalProcessedPoints () const { return isEnd() ? _pointCounterInc+_pointCounterDec : _pointCounterInc+_pointCounterDec+1; }
128 
130 
132  void resetCounters() { _pointCounterInc = _pointCounterDec = 0; }
133 
135 
137  void makeEnd();
140  inline bool isEnd() const { return (_pathIndex == INVALID_INDEX) && (_pointIndex == INVALID_INDEX); }
141 
146 
147 private:
148 
150  void _copy(const CSOPathPointIterator& rhs);
151 
153  bool _valid() const;
154 
157  bool _findValidPathPointList();
158 
160  CSO* _cso;
162  CSOPathPoints* _pathPoints;
163 
165  unsigned int _pathIndex;
167  unsigned int _pointIndex;
168 
170  unsigned int _numPathPointLists;
172  unsigned int _numPoints;
173 
175  unsigned int _startPathIndex;
177  unsigned int _startPointIndex;
178 
180  unsigned int _pointCounterInc;
181 
183  unsigned int _pointCounterDec;
184 };
185 
187 {
188 public:
189 
191 
192  static const unsigned int INVALID_INDEX;
193 
195 
199  CSOPathPointConstIterator(const CSO* cso, unsigned int startPathIndex=0, unsigned int startPointIndex=0);
201  CSOPathPointConstIterator(const CSO* cso, const CSOPathPoints* pathPoints, unsigned int startPathIndex, unsigned int startPointIndex=0);
203  CSOPathPointConstIterator(const CSO* cso, const CSOPathPoints* pathPoints, unsigned int startPointIndex=0);
205  CSOPathPointConstIterator(const CSO* cso, const CSOSeedPoint* startSeedPoint);
208 
211 
213 
217  CSOPathPointConstIterator operator++ (int dummy);
218 
222  CSOPathPointConstIterator operator-- (int dummy);
223 
228 
233 
236 
238  bool operator== (const CSOPathPointConstIterator& rhs) const;
240  bool operator!= (const CSOPathPointConstIterator& rhs) const;
242  bool operator> (const CSOPathPointConstIterator& rhs) const;
244  bool operator>= (const CSOPathPointConstIterator& rhs) const;
246  bool operator< (const CSOPathPointConstIterator& rhs) const;
248  bool operator<= (const CSOPathPointConstIterator& rhs) const;
249 
251 
253  inline const CSO* getCSO () const { return _cso; }
254 
256  inline unsigned int getPathIndex () const { return _pathIndex; }
258  inline unsigned int getPointIndex () const { return _pointIndex; }
259 
260  // Returns a pointer to the current path point list.
261  inline const CSOPathPoints* getPathPoints () const { return _pathPoints; }
262 
264  inline Vector3 getPos () const { return _pathPoints->getPosAt(_pointIndex); }
266  inline const Vector4& getPosValue () const { return _pathPoints->getPosValueAt(_pointIndex); }
268  inline double getValue () const { return _pathPoints->getValueAt(_pointIndex); }
269 
271  inline unsigned int numPoints () const { return _numPoints; }
274  inline unsigned int numProcessedPoints () const { return mlAbs(_pointCounterInc-_pointCounterDec); }
277  inline unsigned int numTotalProcessedPoints () const { return isEnd() ? _pointCounterInc+_pointCounterDec : _pointCounterInc+_pointCounterDec+1; }
278 
280 
282  void resetCounters() { _pointCounterInc = _pointCounterDec = 0; }
283 
285 
287  void makeEnd();
290  inline bool isEnd() const { return (_pathIndex == INVALID_INDEX) && (_pointIndex == INVALID_INDEX); }
291 
296 
297 private:
298 
300  void _copy(const CSOPathPointConstIterator& rhs);
301 
303  bool _valid() const;
304 
307  bool _findValidPathPointList();
308 
310  const CSO* _cso;
312  const CSOPathPoints* _pathPoints;
313 
315  unsigned int _pathIndex;
317  unsigned int _pointIndex;
318 
320  unsigned int _numPathPointLists;
322  unsigned int _numPoints;
323 
325  unsigned int _startPathIndex;
327  unsigned int _startPointIndex;
328 
330  unsigned int _pointCounterInc;
331 
333  unsigned int _pointCounterDec;
334 };
335 
338 
341 
343 
344 ML_END_NAMESPACE
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition: MLCSOSystem.h:23
void makeEnd()
Makes this iterator pointing to the "end" of the CSO.
bool isEnd() const
Returns whether this iterator points to the end of the CSO.
unsigned int numTotalProcessedPoints() const
Returns the total number of processed points (i.e.
const Vector4 & getPosValue() const
Returns the current point including its value.
CSOPathPointConstIterator prev() const
Returns an iterator to the prev path point if available and otherwise a CSOPathPointIteratorEnd.
CSOPathPointConstIterator(const CSO *cso, const CSOPathPoints *pathPoints, unsigned int startPointIndex=0)
Constructor.
unsigned int getPointIndex() const
Returns the index of the current point.
Vector3 getPos() const
Returns the current point.
CSOPathPointConstIterator(const CSO *cso, unsigned int startPathIndex=0, unsigned int startPointIndex=0)
Constructor.
~CSOPathPointConstIterator()=default
Default destructor.
unsigned int numPoints() const
Returns the total number of points of the CSO.
const CSOPathPoints * getPathPoints() const
CSOPathPointConstIterator(const CSOPathPointConstIterator &rhs)
Copy constructor.
CSOPathPointConstIterator()
Default constructor.
static const unsigned int INVALID_INDEX
unsigned int numProcessedPoints() const
Returns the number of processed points (relative to the start).
unsigned int getPathIndex() const
Returns the index of the current path.
void resetCounters()
Resets the internal counters that define the number of processed points.
CSOPathPointConstIterator(const CSO *cso, const CSOSeedPoint *startSeedPoint)
Constructor.
const CSO * getCSO() const
Returns the CSO.
CSOPathPointConstIterator next() const
Returns an iterator to the next path point if available and otherwise a CSOPathPointIteratorEnd.
CSOPathPointConstIterator(const CSO *cso, const CSOPathPoints *pathPoints, unsigned int startPathIndex, unsigned int startPointIndex=0)
Constructor.
double getValue() const
Returns the value of the current point.
void setPos(const Vector3 &p)
Sets the current point to the given value.
double getValue() const
Returns the value of the current point.
CSOPathPointIterator(const CSOPathPointIterator &rhs)
Copy constructor.
unsigned int getPathIndex() const
Returns the index of the current path.
bool isEnd() const
Returns if this iterator points to the end of the cso.
void setPosValue(const Vector4 &p)
Sets the current point and its value to the given value.
CSO * getCSO()
Returns the cso.
CSOPathPointIterator next() const
Returns an iterator to the next path point if available and otherwise a CSOPathPointIteratorEnd.
CSOPathPointIterator(CSO *cso, CSOSeedPoint *startSeedPoint)
Constructor.
const CSO * getCSO() const
Returns the cso.
static const unsigned int INVALID_INDEX
CSOPathPointIterator(CSO *cso, CSOPathPoints *pathPoints, unsigned int startPathIndex, unsigned int startPointIndex)
Constructor.
~CSOPathPointIterator()=default
Default destructor.
void resetCounters()
Resets the internal counters that define the number of processed points.
unsigned int numProcessedPoints() const
Returns the number of processed points (relative to the start).
const Vector4 & getPosValue() const
Returns the current point including its value.
void makeEnd()
Makes this iterator pointing to the "end" of the cso.
CSOPathPointIterator prev() const
Returns an iterator to the prev path point if available and otherwise a CSOPathPointIteratorEnd.
unsigned int getPointIndex() const
Returns the index of the current point.
CSOPathPointIterator(CSO *cso, CSOPathPoints *pathPoints, unsigned int startPointIndex)
Constructor.
CSOPathPointIterator(CSO *cso, unsigned int startPathIndex=0, unsigned int startPointIndex=0)
Constructor.
Vector3 getPos() const
Returns the current point.
unsigned int numTotalProcessedPoints() const
Returns the total number of processed points (i.e.
CSOPathPointIterator()
Default constructor.
void setValue(const double &v)
Sets the value of the current point to the given value.
unsigned int numPoints() const
Returns the total number of points of the cso.
const CSOPathPoints * getPathPoints() const
The CSOPathPoints is a list of world coordinates which are interpolated by a certain interpolation sc...
Definition: CSOPathPoints.h:37
The CSOSeedPoint can be interactively set and modified and is the framework for contours.
Definition: CSOSeedPoint.h:35
The CSO represents a contour segmentation object.
Definition: CSO.h:44
const unsigned int INVALID_INDEX
A symbolic value that indicates an invalid index (-1).
Definition: CSOGeometry.h:234
ScopeGuard< Functor > operator+(ScopeGuardOnExit, Functor &&fn)
Definition: mlScopeGuard.h:82
T mlAbs(T a)
Defines ML specific abs template since only type depended library functions exists.
Definition: mlUtilsSystem.h:76
const CSOPathPointIterator CSOPathPointIteratorEnd
A symbolic iterator that indicates that a CSOPathPointIterator has reached the end of a cso.
FloatingPointVector< T, size, DataContainer > & operator-=(FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer)
Arithmetic assignment: Component wise subtraction of buffer from *this.
const CSOPathPointConstIterator CSOPathPointConstIteratorEnd
A symbolic iterator that indicates that a CSOPathPointConstIterator has reached the end of a cso.
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Return true if yes.
Definition: mlMatrix2.h:425
bool operator!=(const Tmat2< DT > &a, const Tmat2< DT > &b)
a != b ? Return true if yes.
Definition: mlMatrix2.h:433
FloatingPointVector< T, size, DataContainer > & operator+=(FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer)
Arithmetic assignment: Component wise addition.
FloatingPointVector< T, size, DataContainer > operator-(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component wise subtraction of rhs from lhs.