Medical Imaging Interaction Toolkit  2023.12.99-101158b3
Medical Imaging Interaction Toolkit
mitk::ContourElement Class Reference

Represents a contour in 3D space. A ContourElement is consisting of linked vertices implicitely defining the contour. They are stored in a double ended queue making it possible to add vertices at front and end of the contour and to iterate in both directions. To mark a vertex as a special one it can be set as a control point. More...

#include <mitkContourElement.h>

Inheritance diagram for mitk::ContourElement:
Collaboration diagram for mitk::ContourElement:

Classes

struct  ContourModelVertex
 Represents a single vertex of a contour. More...
 

Public Types

using VertexType = ContourModelVertex
 
using VertexListType = std::deque< VertexType * >
 
using VertexIterator = VertexListType::iterator
 
using ConstVertexIterator = VertexListType::const_iterator
 
using VertexSizeType = VertexListType::size_type
 

Public Member Functions

 mitkClassMacroItkParent (ContourElement, itk::LightObject)
 
Pointer Clone () const
 
ConstVertexIterator ConstIteratorBegin () const
 Return a const iterator a the front. More...
 
ConstVertexIterator ConstIteratorEnd () const
 Return a const iterator a the end. More...
 
VertexIterator IteratorBegin ()
 Return an iterator a the front. More...
 
VertexIterator IteratorEnd ()
 Return an iterator a the end. More...
 
ConstVertexIterator begin () const
 Return a const iterator a the front. For easier support of stl functionality. More...
 
ConstVertexIterator end () const
 Return a const iterator a the end. For easier support of stl functionality. More...
 
VertexIterator begin ()
 Return an iterator a the front. For easier support of stl functionality. More...
 
VertexIterator end ()
 Return an iterator a the end. For easier support of stl functionality. More...
 
VertexSizeType GetSize () const
 Returns the number of contained vertices. More...
 
void AddVertex (const mitk::Point3D &point, bool isControlPoint)
 Add a vertex at the end of the contour. More...
 
void AddVertexAtFront (const mitk::Point3D &point, bool isControlPoint)
 Add a vertex at the front of the contour. More...
 
void InsertVertexAtIndex (const mitk::Point3D &point, bool isControlPoint, VertexSizeType index)
 Add a vertex at a given index of the contour. More...
 
void SetVertexAt (VertexSizeType pointId, const mitk::Point3D &point)
 Set coordinates a given index. More...
 
void SetVertexAt (VertexSizeType pointId, const VertexType *vertex)
 Set vertex a given index (by copying the values). More...
 
VertexTypeGetVertexAt (VertexSizeType index)
 Returns the vertex a given index. More...
 
const VertexTypeGetVertexAt (VertexSizeType index) const
 
VertexTypeGetVertexAt (const mitk::Point3D &point, float eps)
 Returns the approximate nearest vertex a given position in 3D space. More...
 
VertexTypeGetNextControlVertexAt (const mitk::Point3D &point, float eps)
 Returns the next vertex to the approximate nearest vertex of a given position in 3D space. More...
 
VertexTypeGetPreviousControlVertexAt (const mitk::Point3D &point, float eps)
 Returns the previous vertex to the approximate nearest vertex of a given position in 3D space. More...
 
VertexTypeGetControlVertexAt (const mitk::Point3D &point, float eps)
 Returns the approximate nearest control vertex a given posoition in 3D space, if the clicked position is within a specific range. More...
 
VertexSizeType GetIndex (const VertexType *vertex) const
 Returns the index of the given vertex within the contour. More...
 
const VertexListTypeGetVertexList () const
 Returns the container of the vertices. More...
 
bool IsEmpty () const
 Returns whether the contour element is empty. More...
 
bool IsClosed () const
 Returns if the conour is closed or not. More...
 
bool IsNearContour (const mitk::Point3D &point, float eps) const
 Returns whether a given point is near a contour, according to eps. More...
 
bool GetLineSegmentForPoint (const mitk::Point3D &point, float eps, mitk::ContourElement::VertexType *previousVertex, mitk::ContourElement::VertexType *nextVertex) const
 
bool GetLineSegmentForPoint (const mitk::Point3D &point, float eps, VertexSizeType &segmentStartIndex, VertexSizeType &segmentEndIndex, mitk::Point3D &closestContourPoint, bool findClosest=true) const
 
void Close ()
 Close the contour. Connect first with last element. More...
 
void Open ()
 Open the contour. Disconnect first and last element. More...
 
void SetClosed (bool isClosed)
 Set the contours IsClosed property. More...
 
void Concatenate (const mitk::ContourElement *other, bool check)
 Concatenate the contuor with a another contour. All vertices of the other contour will be cloned and added after last vertex. More...
 
bool RemoveVertex (const VertexType *vertex)
 Remove the given vertex from the container if exists. More...
 
bool RemoveVertexAt (VertexSizeType index)
 Remove a vertex at given index within the container if exists. More...
 
bool RemoveVertexAt (const mitk::Point3D &point, double eps)
 Remove the approximate nearest vertex at given position in 3D space if one exists. More...
 
void Clear ()
 Clear the storage container. More...
 
VertexTypeBruteForceGetVertexAt (const mitk::Point3D &point, double eps, bool isControlPoint=false, int offset=0)
 Returns the approximate nearest vertex a given position in 3D space. With the parameter 'isControlPoint', one can decide if any vertex should be returned, or just control vertices. More...
 
int BruteForceGetVertexIndexAt (const mitk::Point3D &point, double eps, VertexListType verticesList)
 Returns the index of the approximate nearest vertex of a given position in 3D space. More...
 
VertexListType GetControlVertices () const
 
void RedistributeControlVertices (const VertexType *vertex, int period)
 Uniformly redistribute control points with a given period (in number of vertices) More...
 

Static Public Member Functions

static Pointer New ()
 

Static Public Attributes

static const VertexSizeType NPOS
 

Protected Member Functions

 mitkCloneMacro (Self)
 
 ContourElement ()=default
 
 ContourElement (const mitk::ContourElement &other)
 
 ~ContourElement ()
 
ContourElementoperator= (const ContourElement &other)
 
bool RemoveVertexByIterator (VertexListType::iterator &iter)
 

Protected Attributes

VertexListType m_Vertices
 
bool m_IsClosed
 

Detailed Description

Represents a contour in 3D space. A ContourElement is consisting of linked vertices implicitely defining the contour. They are stored in a double ended queue making it possible to add vertices at front and end of the contour and to iterate in both directions. To mark a vertex as a special one it can be set as a control point.

Note
This class assumes that it manages its vertices. So if a vertex instance is added to this class the ownership of the vertex is transfered to the ContourElement instance. The ContourElement instance takes care of deleting vertex instances if needed. It is highly not recommend to use this class directly as it is designed as a internal class of ContourModel. Therefore it is adviced to use ContourModel if contour representations are needed in MITK.

Definition at line 36 of file mitkContourElement.h.

Member Typedef Documentation

◆ ConstVertexIterator

using mitk::ContourElement::ConstVertexIterator = VertexListType::const_iterator

Definition at line 67 of file mitkContourElement.h.

◆ VertexIterator

using mitk::ContourElement::VertexIterator = VertexListType::iterator

Definition at line 66 of file mitkContourElement.h.

◆ VertexListType

Definition at line 65 of file mitkContourElement.h.

◆ VertexSizeType

using mitk::ContourElement::VertexSizeType = VertexListType::size_type

Definition at line 68 of file mitkContourElement.h.

◆ VertexType

Constructor & Destructor Documentation

◆ ContourElement() [1/2]

mitk::ContourElement::ContourElement ( )
protecteddefault

◆ ContourElement() [2/2]

mitk::ContourElement::ContourElement ( const mitk::ContourElement other)
protected

◆ ~ContourElement()

mitk::ContourElement::~ContourElement ( )
protected

Member Function Documentation

◆ AddVertex()

void mitk::ContourElement::AddVertex ( const mitk::Point3D point,
bool  isControlPoint 
)

Add a vertex at the end of the contour.

Parameters
point- coordinates in 3D space.
isControlPoint- is the vertex a special control point.

◆ AddVertexAtFront()

void mitk::ContourElement::AddVertexAtFront ( const mitk::Point3D point,
bool  isControlPoint 
)

Add a vertex at the front of the contour.

Parameters
point- coordinates in 3D space.
isControlPoint- is the vertex a control point.

◆ begin() [1/2]

VertexIterator mitk::ContourElement::begin ( )

Return an iterator a the front. For easier support of stl functionality.

◆ begin() [2/2]

ConstVertexIterator mitk::ContourElement::begin ( ) const

Return a const iterator a the front. For easier support of stl functionality.

◆ BruteForceGetVertexAt()

VertexType* mitk::ContourElement::BruteForceGetVertexAt ( const mitk::Point3D point,
double  eps,
bool  isControlPoint = false,
int  offset = 0 
)

Returns the approximate nearest vertex a given position in 3D space. With the parameter 'isControlPoint', one can decide if any vertex should be returned, or just control vertices.

Parameters
point- query position in 3D space.
eps- the error bound for search algorithm. It is an open boundary.
isControlPoint
offset- a offset to the vertex, e.g. 1 if the next vertex should be returned or -1 for the previous vertex

◆ BruteForceGetVertexIndexAt()

int mitk::ContourElement::BruteForceGetVertexIndexAt ( const mitk::Point3D point,
double  eps,
VertexListType  verticesList 
)

Returns the index of the approximate nearest vertex of a given position in 3D space.

Parameters
point- query position in 3D space.
eps- the error bound for search algorithm. It is an open boundary.
verticesList- the vertex list to search the index in, either only control vertices or all vertices

◆ Clear()

void mitk::ContourElement::Clear ( )

Clear the storage container.

◆ Clone()

Pointer mitk::ContourElement::Clone ( ) const

◆ Close()

void mitk::ContourElement::Close ( )

Close the contour. Connect first with last element.

◆ Concatenate()

void mitk::ContourElement::Concatenate ( const mitk::ContourElement other,
bool  check 
)

Concatenate the contuor with a another contour. All vertices of the other contour will be cloned and added after last vertex.

Parameters
other- the other contour
check- set it true to avoid adding of vertices that are already in the source contour

◆ ConstIteratorBegin()

ConstVertexIterator mitk::ContourElement::ConstIteratorBegin ( ) const

Return a const iterator a the front.

◆ ConstIteratorEnd()

ConstVertexIterator mitk::ContourElement::ConstIteratorEnd ( ) const

Return a const iterator a the end.

◆ end() [1/2]

VertexIterator mitk::ContourElement::end ( )

Return an iterator a the end. For easier support of stl functionality.

◆ end() [2/2]

ConstVertexIterator mitk::ContourElement::end ( ) const

Return a const iterator a the end. For easier support of stl functionality.

◆ GetControlVertexAt()

VertexType* mitk::ContourElement::GetControlVertexAt ( const mitk::Point3D point,
float  eps 
)

Returns the approximate nearest control vertex a given posoition in 3D space, if the clicked position is within a specific range.

Parameters
point- query position in 3D space.
eps- the error bound for search algorithm.

◆ GetControlVertices()

VertexListType mitk::ContourElement::GetControlVertices ( ) const

Returns a list pointing to all vertices that are indicated to be control points.

Remarks
It is important to note, that the vertex pointers in the returned list directly point to the vertices stored interanlly. So they are still owned by the ContourElement instance that returns the list. If one wants to take over ownership, one has to clone the vertex instances.

◆ GetIndex()

VertexSizeType mitk::ContourElement::GetIndex ( const VertexType vertex) const

Returns the index of the given vertex within the contour.

Parameters
vertex- the vertex to be searched.
Returns
index of vertex. Returns ContourElement::NPOS if not found.

◆ GetLineSegmentForPoint() [1/2]

bool mitk::ContourElement::GetLineSegmentForPoint ( const mitk::Point3D point,
float  eps,
mitk::ContourElement::VertexType previousVertex,
mitk::ContourElement::VertexType nextVertex 
) const

Function that searches for the line segment of the contour that is closest to the passed point and close enough (distance between point and line segment <= eps). If such an line segment exist, the starting vertex and closing vertex of the found segment are passed back.

Returns
True indicates that a line segment was found. False indicates that no segment of the contour is close enough to the passed point.
Remarks
previousVertex and nextVertex are only valid if return is true.

◆ GetLineSegmentForPoint() [2/2]

bool mitk::ContourElement::GetLineSegmentForPoint ( const mitk::Point3D point,
float  eps,
VertexSizeType segmentStartIndex,
VertexSizeType segmentEndIndex,
mitk::Point3D closestContourPoint,
bool  findClosest = true 
) const

Overloaded version that offers additional options when searching for the line segment. In contrast to the other version it returns the index of the segment start and end as well as the point on the line segment closest to the passed point. Further one can decide if the function should search for the first segment that is close enough (see eps) or for the segment that is really the closest (findClosest==true).

Remarks
segmentStartIndex, segmentEndIndex and closestContourPoint are only valid if return is true.

◆ GetNextControlVertexAt()

VertexType* mitk::ContourElement::GetNextControlVertexAt ( const mitk::Point3D point,
float  eps 
)

Returns the next vertex to the approximate nearest vertex of a given position in 3D space.

Parameters
point- query position in 3D space.
eps- the error bound for search algorithm.

◆ GetPreviousControlVertexAt()

VertexType* mitk::ContourElement::GetPreviousControlVertexAt ( const mitk::Point3D point,
float  eps 
)

Returns the previous vertex to the approximate nearest vertex of a given position in 3D space.

Parameters
point- query position in 3D space.
eps- the error bound for search algorithm.

◆ GetSize()

VertexSizeType mitk::ContourElement::GetSize ( ) const

Returns the number of contained vertices.

◆ GetVertexAt() [1/3]

VertexType* mitk::ContourElement::GetVertexAt ( const mitk::Point3D point,
float  eps 
)

Returns the approximate nearest vertex a given position in 3D space.

Parameters
point- query position in 3D space.
eps- the error bound for search algorithm.

◆ GetVertexAt() [2/3]

VertexType* mitk::ContourElement::GetVertexAt ( VertexSizeType  index)

Returns the vertex a given index.

Parameters
index
Precondition
index must be valid.

◆ GetVertexAt() [3/3]

const VertexType* mitk::ContourElement::GetVertexAt ( VertexSizeType  index) const

◆ GetVertexList()

const VertexListType* mitk::ContourElement::GetVertexList ( ) const

Returns the container of the vertices.

◆ InsertVertexAtIndex()

void mitk::ContourElement::InsertVertexAtIndex ( const mitk::Point3D point,
bool  isControlPoint,
VertexSizeType  index 
)

Add a vertex at a given index of the contour.

Parameters
point- coordinates in 3D space.
isControlPoint- is the vertex a special control point.
index- the index to be inserted at.

◆ IsClosed()

bool mitk::ContourElement::IsClosed ( ) const

Returns if the conour is closed or not.

◆ IsEmpty()

bool mitk::ContourElement::IsEmpty ( ) const

Returns whether the contour element is empty.

◆ IsNearContour()

bool mitk::ContourElement::IsNearContour ( const mitk::Point3D point,
float  eps 
) const

Returns whether a given point is near a contour, according to eps.

Parameters
point- query position in 3D space.
eps- the error bound for search algorithm.

◆ IteratorBegin()

VertexIterator mitk::ContourElement::IteratorBegin ( )

Return an iterator a the front.

◆ IteratorEnd()

VertexIterator mitk::ContourElement::IteratorEnd ( )

Return an iterator a the end.

◆ mitkClassMacroItkParent()

mitk::ContourElement::mitkClassMacroItkParent ( ContourElement  ,
itk::LightObject   
)

◆ mitkCloneMacro()

mitk::ContourElement::mitkCloneMacro ( Self  )
protected

◆ New()

static Pointer mitk::ContourElement::New ( )
static

◆ Open()

void mitk::ContourElement::Open ( )

Open the contour. Disconnect first and last element.

◆ operator=()

ContourElement& mitk::ContourElement::operator= ( const ContourElement other)
protected

◆ RedistributeControlVertices()

void mitk::ContourElement::RedistributeControlVertices ( const VertexType vertex,
int  period 
)

Uniformly redistribute control points with a given period (in number of vertices)

Parameters
vertex- the vertex around which the redistribution is done.
period- number of vertices between control points.

◆ RemoveVertex()

bool mitk::ContourElement::RemoveVertex ( const VertexType vertex)

Remove the given vertex from the container if exists.

Parameters
vertex- the vertex to be removed.

◆ RemoveVertexAt() [1/2]

bool mitk::ContourElement::RemoveVertexAt ( const mitk::Point3D point,
double  eps 
)

Remove the approximate nearest vertex at given position in 3D space if one exists.

Parameters
point- query point in 3D space.
eps- error bound for search algorithm.

◆ RemoveVertexAt() [2/2]

bool mitk::ContourElement::RemoveVertexAt ( VertexSizeType  index)

Remove a vertex at given index within the container if exists.

Parameters
index- the index where the vertex should be removed.

◆ RemoveVertexByIterator()

bool mitk::ContourElement::RemoveVertexByIterator ( VertexListType::iterator &  iter)
protected

Internal helper function to correctly remove the element indicated by the iterator from the list. After the call the iterator is invalid. Caller of the function must ensure that the iterator is valid!.

Returns
Indicates if the element indicated by the iterator was removed. If iterator points to end it returns false.

◆ SetClosed()

void mitk::ContourElement::SetClosed ( bool  isClosed)

Set the contours IsClosed property.

Parameters
isClosed- true = closed; false = open;

◆ SetVertexAt() [1/2]

void mitk::ContourElement::SetVertexAt ( VertexSizeType  pointId,
const mitk::Point3D point 
)

Set coordinates a given index.

Parameters
pointIdIndex of vertex.
pointCoordinates.

◆ SetVertexAt() [2/2]

void mitk::ContourElement::SetVertexAt ( VertexSizeType  pointId,
const VertexType vertex 
)

Set vertex a given index (by copying the values).

Parameters
pointIdIndex of vertex.
vertexVertex.
Precondition
Passed vertex is a valid instance

Member Data Documentation

◆ m_IsClosed

bool mitk::ContourElement::m_IsClosed
protected

Definition at line 304 of file mitkContourElement.h.

◆ m_Vertices

VertexListType mitk::ContourElement::m_Vertices
protected

Definition at line 303 of file mitkContourElement.h.

◆ NPOS

const VertexSizeType mitk::ContourElement::NPOS
static

Indicates an invalid index. It is always the maximum of the unsigned int type.

Definition at line 72 of file mitkContourElement.h.


The documentation for this class was generated from the following file: