MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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:
29
30 static const unsigned int INVALID_INDEX;
31
33
37 CSOPathPointIterator(CSO* cso, unsigned int startPathIndex = 0, unsigned int startPointIndex = 0);
46
49
51
56
61
66
71
74
87
89
91 inline const CSO* getCSO() const
92 {
93 return _cso;
94 }
96 inline CSO* getCSO()
97 {
98 return _cso;
99 }
100
102 inline unsigned int getPathIndex() const
103 {
104 return _pathIndex;
105 }
107 inline unsigned int getPointIndex() const
108 {
109 return _pointIndex;
110 }
111
112 // Returns a pointer to the current path point list.
113 inline const CSOPathPoints* getPathPoints() const
114 {
115 return _pathPoints;
116 }
117 // Returns a pointer to the current path point list.
119 {
120 return _pathPoints;
121 }
122
124 inline Vector3 getPos() const
125 {
126 return _pathPoints->getPosAt(_pointIndex);
127 }
129 inline const Vector4& getPosValue() const
130 {
131 return _pathPoints->getPosValueAt(_pointIndex);
132 }
134 inline double getValue() const
135 {
136 return _pathPoints->getValueAt(_pointIndex);
137 }
138
140 inline void setPos(const Vector3& p)
141 {
142 _pathPoints->setPosAt(p, _pointIndex);
143 }
145 inline void setPosValue(const Vector4& p)
146 {
147 _pathPoints->setPosValueAt(p, _pointIndex);
148 }
150 inline void setValue(const double& v)
151 {
152 _pathPoints->setValueAt(static_cast<float>(v), _pointIndex);
153 }
154
156 inline unsigned int numPoints() const
157 {
158 return _numPoints;
159 }
162 inline unsigned int numProcessedPoints() const
163 {
164 return mlAbs(_pointCounterInc - _pointCounterDec);
165 }
168 inline unsigned int numTotalProcessedPoints() const
169 {
170 return isEnd() ? _pointCounterInc + _pointCounterDec : _pointCounterInc + _pointCounterDec + 1;
171 }
172
174
177 {
178 _pointCounterInc = _pointCounterDec = 0;
179 }
180
182
184 void makeEnd();
187 inline bool isEnd() const
188 {
189 return (_pathIndex == INVALID_INDEX) && (_pointIndex == INVALID_INDEX);
190 }
191
196
197private:
199 void _copy(const CSOPathPointIterator& rhs);
200
202 bool _valid() const;
203
206 bool _findValidPathPointList();
207
209 CSO* _cso;
211 CSOPathPoints* _pathPoints;
212
214 unsigned int _pathIndex;
216 unsigned int _pointIndex;
217
219 unsigned int _numPathPointLists;
221 unsigned int _numPoints;
222
224 unsigned int _startPathIndex;
226 unsigned int _startPointIndex;
227
229 unsigned int _pointCounterInc;
230
232 unsigned int _pointCounterDec;
233};
234
236{
237public:
239
240 static const unsigned int INVALID_INDEX;
241
243
247 CSOPathPointConstIterator(const CSO* cso, unsigned int startPathIndex = 0, unsigned int startPointIndex = 0);
250 unsigned int startPointIndex = 0);
257
260
262
267
272
277
282
285
298
300
302 inline const CSO* getCSO() const
303 {
304 return _cso;
305 }
306
308 inline unsigned int getPathIndex() const
309 {
310 return _pathIndex;
311 }
313 inline unsigned int getPointIndex() const
314 {
315 return _pointIndex;
316 }
317
318 // Returns a pointer to the current path point list.
319 inline const CSOPathPoints* getPathPoints() const
320 {
321 return _pathPoints;
322 }
323
325 inline Vector3 getPos() const
326 {
327 return _pathPoints->getPosAt(_pointIndex);
328 }
330 inline const Vector4& getPosValue() const
331 {
332 return _pathPoints->getPosValueAt(_pointIndex);
333 }
335 inline double getValue() const
336 {
337 return _pathPoints->getValueAt(_pointIndex);
338 }
339
341 inline unsigned int numPoints() const
342 {
343 return _numPoints;
344 }
347 inline unsigned int numProcessedPoints() const
348 {
349 return mlAbs(_pointCounterInc - _pointCounterDec);
350 }
353 inline unsigned int numTotalProcessedPoints() const
354 {
355 return isEnd() ? _pointCounterInc + _pointCounterDec : _pointCounterInc + _pointCounterDec + 1;
356 }
357
359
362 {
363 _pointCounterInc = _pointCounterDec = 0;
364 }
365
367
369 void makeEnd();
372 inline bool isEnd() const
373 {
374 return (_pathIndex == INVALID_INDEX) && (_pointIndex == INVALID_INDEX);
375 }
376
381
382private:
384 void _copy(const CSOPathPointConstIterator& rhs);
385
387 bool _valid() const;
388
391 bool _findValidPathPointList();
392
394 const CSO* _cso;
396 const CSOPathPoints* _pathPoints;
397
399 unsigned int _pathIndex;
401 unsigned int _pointIndex;
402
404 unsigned int _numPathPointLists;
406 unsigned int _numPoints;
407
409 unsigned int _startPathIndex;
411 unsigned int _startPointIndex;
412
414 unsigned int _pointCounterInc;
415
417 unsigned int _pointCounterDec;
418};
419
422
425
427
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
CSOPathPointConstIterator & operator++()
Steps to the next point on the CSO (prefix).
bool operator!=(const CSOPathPointConstIterator &rhs) const
Comparison operator.
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., using both increments and decrements).
CSOPathPointConstIterator & operator-=(int offset)
Steps to the previous point by the given offset.
CSOPathPointConstIterator prev() const
Returns an iterator to the prev path point if available; otherwise, it returns a CSOPathPointIterator...
CSOPathPointConstIterator(const CSO *cso, const CSOPathPoints *pathPoints, unsigned int startPointIndex=0)
Constructor.
unsigned int getPointIndex() const
Returns the index of the current point.
CSOPathPointConstIterator & operator--()
Steps to the previous point on the CSO (prefix).
Vector3 getPos() const
Returns the current point.
CSOPathPointConstIterator(const CSO *cso, unsigned int startPathIndex=0, unsigned int startPointIndex=0)
Constructor.
~CSOPathPointConstIterator()=default
Default destructor.
CSOPathPointConstIterator & operator=(const CSOPathPointConstIterator &rhs)
Assignment operator.
CSOPathPointConstIterator operator--(int dummy)
Steps to the previous point on the CSO (postfix).
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 operator++(int dummy)
Steps to the next point on the CSO (postfix).
CSOPathPointConstIterator(const CSOPathPointConstIterator &rhs)
Copy constructor.
CSOPathPointConstIterator operator+(int offset) const
Steps to the next point by the given offset.
bool operator>(const CSOPathPointConstIterator &rhs) const
Comparison operator.
CSOPathPointConstIterator()
Default constructor.
bool operator>=(const CSOPathPointConstIterator &rhs) const
Comparison operator.
static const unsigned int INVALID_INDEX
const CSOPathPoints * getPathPoints() const
unsigned int numProcessedPoints() const
Returns the number of processed points (relative to the start).
CSOPathPointConstIterator & operator+=(int offset)
Steps to the next point by the given offset.
unsigned int getPathIndex() const
Returns the index of the current path.
bool operator<(const CSOPathPointConstIterator &rhs) const
Comparison operator.
const CSO * getCSO() const
Returns the CSO.
bool operator==(const CSOPathPointConstIterator &rhs) const
Comparison operator.
void resetCounters()
Resets the internal counters that define the number of processed points.
CSOPathPointConstIterator(const CSO *cso, const CSOSeedPoint *startSeedPoint)
Constructor.
bool operator<=(const CSOPathPointConstIterator &rhs) const
Comparison operator.
CSOPathPointConstIterator operator-(int offset) const
Steps to the previous point by the given offset.
CSOPathPointConstIterator next() const
Returns an iterator to the next path point if available; otherwise, it returns a CSOPathPointIterator...
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.
CSOPathPointIterator & operator--()
Steps to the previous point on the CSO (prefix).
const CSOPathPoints * getPathPoints() const
double getValue() const
Returns the value of the current point.
CSOPathPointIterator & operator=(const CSOPathPointIterator &rhs)
Assignment operator.
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 operator--(int dummy)
Steps to the previous point on the CSO (postfix).
CSOPathPointIterator next() const
Returns an iterator to the next path point if available; otherwise, it returns a CSOPathPointIterator...
CSOPathPointIterator(CSO *cso, CSOSeedPoint *startSeedPoint)
Constructor.
CSOPathPointIterator operator++(int dummy)
Steps to the next point on the CSO (postfix).
static const unsigned int INVALID_INDEX
CSOPathPointIterator(CSO *cso, CSOPathPoints *pathPoints, unsigned int startPathIndex, unsigned int startPointIndex)
Constructor.
bool operator<(const CSOPathPointIterator &rhs) const
Comparison operator.
bool operator<=(const CSOPathPointIterator &rhs) const
Comparison operator.
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).
bool operator>(const CSOPathPointIterator &rhs) const
Comparison operator.
bool operator==(const CSOPathPointIterator &rhs) const
Comparison operator.
void makeEnd()
Makes this iterator pointing to the "end" of the CSO.
CSOPathPointIterator & operator-=(int offset)
Steps to the previous point by the given offset.
CSOPathPointIterator & operator+=(int offset)
Steps to the next point by the given offset.
CSOPathPointIterator prev() const
Returns an iterator to the prev path point if available; otherwise, it returns a CSOPathPointIterator...
unsigned int getPointIndex() const
Returns the index of the current point.
const Vector4 & getPosValue() const
Returns the current point including its value.
CSOPathPointIterator & operator++()
Steps to the next point on the CSO (prefix).
bool operator!=(const CSOPathPointIterator &rhs) const
Comparison operator.
CSOPathPointIterator(CSO *cso, CSOPathPoints *pathPoints, unsigned int startPointIndex)
Constructor.
CSOPathPointIterator(CSO *cso, unsigned int startPathIndex=0, unsigned int startPointIndex=0)
Constructor.
CSOPathPointIterator operator+(int offset) const
Steps to the next point by the given offset.
Vector3 getPos() const
Returns the current point.
unsigned int numTotalProcessedPoints() const
Returns the total number of processed points (i.e., using both increments and decrements).
CSOPathPointIterator()
Default constructor.
CSOPathPointIterator operator-(int offset) const
Steps to the previous point by the given offset.
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.
bool operator>=(const CSOPathPointIterator &rhs) const
Comparison operator.
const CSO * getCSO() const
Returns the CSO.
The CSOPathPoints is a list of world coordinates that are interpolated by a certain interpolation sch...
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-dependent 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.