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
24
26{
27public:
28
30
31 static const unsigned int INVALID_INDEX;
32
34
38 CSOPathPointIterator(CSO* cso, unsigned int startPathIndex=0, unsigned int startPointIndex=0);
47
50
52
54 CSOPathPointIterator& operator++ ();
56 CSOPathPointIterator operator++ (int dummy);
57
59 CSOPathPointIterator& operator-- ();
61 CSOPathPointIterator operator-- (int dummy);
62
64 CSOPathPointIterator& operator+= (int offset);
66 CSOPathPointIterator& operator-= (int offset);
67
69 CSOPathPointIterator operator+ (int offset) const;
71 CSOPathPointIterator operator- (int offset) const;
72
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
147private:
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{
188public:
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);
208
211
213
218
223
225 CSOPathPointConstIterator& operator+= (int offset);
227 CSOPathPointConstIterator& operator-= (int offset);
228
230 CSOPathPointConstIterator operator+ (int offset) const;
232 CSOPathPointConstIterator operator- (int offset) const;
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
297private:
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
#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.
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.
const Vector4 & getPosValue() const
Returns the current point including its value.
unsigned int numPoints() const
Returns the total number of points of the CSO.
CSOPathPointConstIterator(const CSOPathPointConstIterator &rhs)
Copy constructor.
CSOPathPointConstIterator()
Default constructor.
static const unsigned int INVALID_INDEX
const CSOPathPoints * getPathPoints() const
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.
const CSO * getCSO() const
Returns the CSO.
void resetCounters()
Resets the internal counters that define the number of processed points.
CSOPathPointConstIterator(const CSO *cso, const CSOSeedPoint *startSeedPoint)
Constructor.
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.
const CSOPathPoints * getPathPoints() const
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.
CSOPathPointIterator next() const
Returns an iterator to the next path point if available and otherwise a CSOPathPointIteratorEnd.
CSOPathPointIterator(CSO *cso, CSOSeedPoint *startSeedPoint)
Constructor.
static const unsigned int INVALID_INDEX
CSOPathPointIterator(CSO *cso, CSOPathPoints *pathPoints, unsigned int startPathIndex, unsigned int startPointIndex)
Constructor.
CSO * getCSO()
Returns the cso.
~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).
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.
const Vector4 & getPosValue() const
Returns the current point including its value.
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 CSO * getCSO() const
Returns the cso.
The CSOPathPoints is a list of world coordinates which are interpolated by a certain interpolation sc...
The CSOSeedPoint can be interactively set and modified and is the framework for contours.
The CSO represents a contour segmentation object.
Definition CSO.h:44
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
T mlAbs(T a)
Defines ML specific abs template since only type depended library functions exists.
const CSOPathPointIterator CSOPathPointIteratorEnd
A symbolic iterator that indicates that a CSOPathPointIterator has reached the end of a cso.
const CSOPathPointConstIterator CSOPathPointConstIteratorEnd
A symbolic iterator that indicates that a CSOPathPointConstIterator has reached the end of a cso.