27 :
itk::LightObject(), m_Vertices(other.m_Vertices), m_IsClosed(other.m_IsClosed)
33 delete this->m_Vertices;
38 this->m_Vertices->push_back(
new VertexType(vertex, isControlPoint));
43 this->m_Vertices->push_back(&vertex);
48 this->m_Vertices->push_front(
new VertexType(vertex, isControlPoint));
53 this->m_Vertices->push_front(&vertex);
58 if (index >= 0 && this->GetSize() > index)
60 auto _where = this->m_Vertices->begin();
62 this->m_Vertices->insert(_where,
new VertexType(vertex, isControlPoint));
68 if (pointId >= 0 && this->GetSize() > pointId)
70 this->m_Vertices->at(pointId)->Coordinates = point;
76 if (pointId >= 0 && this->GetSize() > pointId)
78 this->m_Vertices->at(pointId)->Coordinates = vertex->
Coordinates;
79 this->m_Vertices->at(pointId)->IsControlPoint = vertex->
IsControlPoint;
85 return this->m_Vertices->at(index);
90 return this->m_Vertices->empty();
100 return BruteForceGetVertexAt(point, eps);
109 std::deque<std::pair<double, VertexType *>> nearestlist;
119 double distance = currentPoint.EuclideanDistanceTo(point);
123 if (nearestlist.size() < 1)
125 nearestlist.push_front(std::pair<double, VertexType *>((*it)->Coordinates.EuclideanDistanceTo(point), (*it)));
128 else if (distance < nearestlist.front().first)
131 nearestlist.push_front(std::pair<double, VertexType *>((*it)->Coordinates.EuclideanDistanceTo(point), (*it)));
137 if (nearestlist.size() > 0)
140 auto it = nearestlist.begin();
141 auto end = nearestlist.end();
144 if ((*it).second->IsControlPoint)
153 return nearestlist.front().second;
226 return this->m_Vertices;
231 return this->m_IsClosed;
244 for (; it1 != end; it1++, it2++, counter++)
247 it2 = this->m_Vertices->begin();
252 const float l2 = v1.SquaredEuclideanDistanceTo(v2);
257 double tc = (p_v1 * v2_v1) / l2;
267 double distance = point.SquaredEuclideanDistanceTo(crossPoint);
280 this->m_IsClosed =
true;
285 this->m_IsClosed =
false;
290 isClosed ? this->Close() : this->Open();
297 auto it = this->m_Vertices->begin();
298 auto end = this->m_Vertices->end();
302 if ((*it)->IsControlPoint)
304 newVertices->push_back((*it));
318 while (otherIt != otherEnd)
326 while (thisIt != thisEnd)
328 if ((*thisIt)->Coordinates == (*otherIt)->Coordinates)
337 this->m_Vertices->push_back(*otherIt);
341 this->m_Vertices->push_back(*otherIt);
350 auto it = this->m_Vertices->begin();
352 auto end = this->m_Vertices->end();
359 this->m_Vertices->erase(it);
371 auto it = this->m_Vertices->begin();
373 auto end = this->m_Vertices->end();
394 if (index >= 0 && static_cast<VertexListType::size_type>(index) < this->m_Vertices->size())
396 this->m_Vertices->erase(this->m_Vertices->begin() + index);
411 auto it = this->m_Vertices->begin();
413 auto end = this->m_Vertices->end();
419 if (currentPoint.EuclideanDistanceTo(point) <
eps)
423 this->m_Vertices->erase(it);
435 this->m_Vertices->clear();
441 auto _where = this->m_Vertices->begin();
443 if (selected !=
nullptr)
445 while (_where != this->m_Vertices->end())
447 if ((*_where) == selected)
456 while (_iter != this->m_Vertices->end())
459 divresult = div(counter, period);
460 (*_iter)->IsControlPoint = (divresult.rem == 0);
467 while (_iter != this->m_Vertices->begin())
470 divresult = div(counter, period);
471 (*_iter)->IsControlPoint = (divresult.rem == 0);
VertexListType * GetControlVertices()
Returns the approximate nearest vertex a given posoition in 3D space.
VertexType * BruteForceGetVertexAt(const mitk::Point3D &point, float eps)
Returns the approximate nearest vertex a given posoition in 3D space.
bool IsEmpty()
Returns whether the contour element is empty.
std::deque< VertexType * > VertexListType
virtual void Clear()
Clear the storage container.
virtual ~ContourElement()
mitk::Point3D Coordinates
Coordinates in 3D space.
virtual void Open()
Open the contour. Disconnect first and last element.
void RedistributeControlVertices(const VertexType *vertex, int period)
Uniformly redistribute control points with a given period (in number of vertices) ...
Represents a contour in 3D space. A ContourElement is consisting of linked vertices implicitely defin...
virtual void SetVertexAt(int pointId, const mitk::Point3D &point)
Set coordinates a given index.
virtual void AddVertex(mitk::Point3D &point, bool isControlPoint)
Add a vertex at the end of the contour.
virtual bool IsClosed()
Returns if the conour is closed or not.
bool IsControlPoint
Treat point special.
virtual bool RemoveVertex(const VertexType *vertex)
Remove the given vertex from the container if exists.
virtual void Close()
Close the contour. Connect first with last element.
virtual VertexType * GetVertexAt(int index)
Returns the vertex a given index.
VertexListType::const_iterator ConstVertexIterator
VertexListType * GetVertexList()
Returns the container of the vertices.
virtual void InsertVertexAtIndex(mitk::Point3D &point, bool isControlPoint, int index)
Add a vertex at a given index of the contour.
virtual bool IsNearContour(const mitk::Point3D &point, float eps)
Returns whether a given point is near a contour, according to eps.
void Concatenate(mitk::ContourElement *other, bool check)
Concatenate the contuor with a another contour. All vertices of the other contour will be added after...
virtual int GetIndex(const VertexType *vertex)
Returns the index of the given vertex within the contour.
virtual void SetClosed(bool isClosed)
Set the contours IsClosed property.
virtual void AddVertexAtFront(mitk::Point3D &point, bool isControlPoint)
Add a vertex at the front of the contour.
MITKCORE_EXPORT const ScalarType eps
virtual bool RemoveVertexAt(int index)
Remove a vertex at given index within the container if exists.
Represents a single vertex of contour.
virtual int GetSize()
Returns the number of contained vertices.
VertexListType * m_Vertices