Medical Imaging Interaction Toolkit  2022.10.99-efe2ad43
Medical Imaging Interaction Toolkit
mitkContourElement.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #ifndef _mitkContourElement_H_
13 #define _mitkContourElement_H_
14 
15 #include "mitkCommon.h"
17 #include <mitkNumericTypes.h>
18 
19 #include <deque>
20 
21 namespace mitk
22 {
36  class MITKCONTOURMODEL_EXPORT ContourElement : public itk::LightObject
37  {
38  public:
39  mitkClassMacroItkParent(ContourElement, itk::LightObject);
40 
41  itkFactorylessNewMacro(Self);
42 
43  itkCloneMacro(Self);
44 
48  {
49  ContourModelVertex(const mitk::Point3D& point, bool active = false) : IsControlPoint(active), Coordinates(point) {};
51  : IsControlPoint(other.IsControlPoint), Coordinates(other.Coordinates)
52  {
53  };
54 
56  bool IsControlPoint;
57 
60 
61  bool operator ==(const ContourModelVertex& other) const;
62  };
63 
65  using VertexListType = std::deque<VertexType*>;
66  using VertexIterator = VertexListType::iterator;
67  using ConstVertexIterator = VertexListType::const_iterator;
68  using VertexSizeType = VertexListType::size_type;
69 
72  static const VertexSizeType NPOS = -1;
73 
76  ConstVertexIterator ConstIteratorBegin() const;
79  ConstVertexIterator ConstIteratorEnd() const;
82  VertexIterator IteratorBegin();
85  VertexIterator IteratorEnd();
86 
90  ConstVertexIterator begin() const;
94  ConstVertexIterator end() const;
98  VertexIterator begin();
102  VertexIterator end();
103 
106  VertexSizeType GetSize() const;
107 
112  void AddVertex(const mitk::Point3D &point, bool isControlPoint);
113 
118  void AddVertexAtFront(const mitk::Point3D &point, bool isControlPoint);
119 
125  void InsertVertexAtIndex(const mitk::Point3D &point, bool isControlPoint, VertexSizeType index);
126 
131  void SetVertexAt(VertexSizeType pointId, const mitk::Point3D &point);
132 
138  void SetVertexAt(VertexSizeType pointId, const VertexType* vertex);
139 
144  VertexType* GetVertexAt(VertexSizeType index);
145  const VertexType* GetVertexAt(VertexSizeType index) const;
146 
151  VertexType *GetVertexAt(const mitk::Point3D &point, float eps);
152 
157  VertexType *GetNextControlVertexAt(const mitk::Point3D &point, float eps);
158 
163  VertexType *GetPreviousControlVertexAt(const mitk::Point3D &point, float eps);
164 
169  VertexType *GetControlVertexAt(const mitk::Point3D &point, float eps);
170 
175  VertexSizeType GetIndex(const VertexType *vertex) const;
176 
179  const VertexListType *GetVertexList() const;
180 
183  bool IsEmpty() const;
184 
187  bool IsClosed() const;
188 
193  bool IsNearContour(const mitk::Point3D &point, float eps) const;
194 
201  bool GetLineSegmentForPoint(const mitk::Point3D &point,
202  float eps,
203  mitk::ContourElement::VertexType *previousVertex,
204  mitk::ContourElement::VertexType *nextVertex) const;
210  bool GetLineSegmentForPoint(const mitk::Point3D& point,
211  float eps, VertexSizeType& segmentStartIndex, VertexSizeType& segmentEndIndex, mitk::Point3D& closestContourPoint, bool findClosest = true) const;
212 
216  void Close();
217 
221  void Open();
222 
226  void SetClosed(bool isClosed);
227 
233  void Concatenate(const mitk::ContourElement *other, bool check);
234 
238  bool RemoveVertex(const VertexType *vertex);
239 
243  bool RemoveVertexAt(VertexSizeType index);
244 
249  bool RemoveVertexAt(const mitk::Point3D &point, double eps);
250 
253  void Clear();
254 
262  VertexType *BruteForceGetVertexAt(const mitk::Point3D &point, double eps, bool isControlPoint = false, int offset = 0);
263 
269  int BruteForceGetVertexIndexAt(const mitk::Point3D &point,
270  double eps,
271  VertexListType verticesList);
272 
280  VertexListType GetControlVertices() const;
281 
286  void RedistributeControlVertices(const VertexType *vertex, int period);
287 
288  protected:
289  mitkCloneMacro(Self);
290 
291  ContourElement() = default;
292  ContourElement(const mitk::ContourElement &other);
293  ~ContourElement();
294 
295  ContourElement& operator = (const ContourElement & other);
296 
301  bool RemoveVertexByIterator(VertexListType::iterator& iter);
302 
303  VertexListType m_Vertices; // double ended queue with vertices
304  bool m_IsClosed = false;
305  };
306 } // namespace mitk
307 
308 #endif // _mitkContourElement_H_
mitk::eps
const MITKCORE_EXPORT ScalarType eps
mitk::ContourElement::ContourModelVertex
Represents a single vertex of a contour.
Definition: mitkContourElement.h:47
mitk::ContourElement::VertexListType
std::deque< VertexType * > VertexListType
Definition: mitkContourElement.h:65
mitk::ContourElement::ContourModelVertex::ContourModelVertex
ContourModelVertex(const mitk::Point3D &point, bool active=false)
Definition: mitkContourElement.h:49
mitk::ContourElement::VertexIterator
VertexListType::iterator VertexIterator
Definition: mitkContourElement.h:66
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
MitkContourModelExports.h
mitk::operator==
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
mitk::Point< ScalarType, 3 >
mitkNumericTypes.h
mitkCommon.h
mitk::ContourElement::ContourModelVertex::ContourModelVertex
ContourModelVertex(const ContourModelVertex &other)
Definition: mitkContourElement.h:50
mitkCloneMacro
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:154
mitk::ContourElement::ConstVertexIterator
VertexListType::const_iterator ConstVertexIterator
Definition: mitkContourElement.h:67
mitk::ContourElement::ContourModelVertex::Coordinates
mitk::Point3D Coordinates
Coordinates in 3D space.
Definition: mitkContourElement.h:59
mitk::ContourElement
Represents a contour in 3D space. A ContourElement is consisting of linked vertices implicitely defin...
Definition: mitkContourElement.h:36
MITKCONTOURMODEL_EXPORT
#define MITKCONTOURMODEL_EXPORT
Definition: MitkContourModelExports.h:15
mitk::ContourElement::VertexSizeType
VertexListType::size_type VertexSizeType
Definition: mitkContourElement.h:68
mitk::ContourElement::m_Vertices
VertexListType m_Vertices
Definition: mitkContourElement.h:303