54 if (index >= 0 && this->
GetSize() > index)
64 if (pointId >= 0 && this->
GetSize() > pointId)
66 this->
m_Vertices->at(pointId)->Coordinates = point;
72 if (pointId >= 0 && this->
GetSize() > pointId)
105 std::deque<std::pair<double, VertexType *>> nearestlist;
115 double distance = currentPoint.EuclideanDistanceTo(point);
119 if (nearestlist.size() < 1)
121 nearestlist.push_front(std::pair<double, VertexType *>((*it)->Coordinates.EuclideanDistanceTo(point), (*it)));
124 else if (distance < nearestlist.front().first)
127 nearestlist.push_front(std::pair<double, VertexType *>((*it)->Coordinates.EuclideanDistanceTo(point), (*it)));
133 if (nearestlist.size() > 0)
136 auto it = nearestlist.begin();
137 auto end = nearestlist.end();
140 if ((*it).second->IsControlPoint)
149 return nearestlist.front().second;
240 for (; it1 != end; it1++, it2++, counter++)
248 const float l2 = v1.SquaredEuclideanDistanceTo(v2);
253 double tc = (p_v1 * v2_v1) / l2;
263 double distance = point.SquaredEuclideanDistanceTo(crossPoint);
298 if ((*it)->IsControlPoint)
300 newVertices->push_back((*it));
314 while (otherIt != otherEnd)
322 while (thisIt != thisEnd)
324 if ((*thisIt)->Coordinates == (*otherIt)->Coordinates)
390 if (index >= 0 && static_cast<VertexListType::size_type>(index) < this->
m_Vertices->size())
415 if (currentPoint.EuclideanDistanceTo(point) <
eps)
439 if (selected !=
nullptr)
443 if ((*_where) == selected)
455 divresult = div(counter, period);
456 (*_iter)->IsControlPoint = (divresult.rem == 0);
466 divresult = div(counter, period);
467 (*_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.
mitk::Point3D Coordinates
Coordinates in 3D space.
virtual void Open()
Open the contour. Disconnect first and last element.
ContourModelVertex VertexType
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.
~ContourElement() override
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