Medical Imaging Interaction Toolkit  2021.10.00
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 
198  void Close();
199 
203  void Open();
204 
208  void SetClosed(bool isClosed);
209 
215  void Concatenate(const mitk::ContourElement *other, bool check);
216 
220  bool RemoveVertex(const VertexType *vertex);
221 
225  bool RemoveVertexAt(VertexSizeType index);
226 
231  bool RemoveVertexAt(const mitk::Point3D &point, double eps);
232 
235  void Clear();
236 
243  VertexType *BruteForceGetVertexAt(const mitk::Point3D &point, double eps, bool isControlPoint = false, int offset = 0);
244 
250  int BruteForceGetVertexIndexAt(const mitk::Point3D &point,
251  double eps,
252  VertexListType verticesList);
253 
261  VertexListType GetControlVertices() const;
262 
267  void RedistributeControlVertices(const VertexType *vertex, int period);
268 
269  protected:
270  mitkCloneMacro(Self);
271 
272  ContourElement() = default;
273  ContourElement(const mitk::ContourElement &other);
274  ~ContourElement();
275 
276  ContourElement& operator = (const ContourElement & other);
277 
282  bool RemoveVertexByIterator(VertexListType::iterator& iter);
283 
284  VertexListType m_Vertices; // double ended queue with vertices
285  bool m_IsClosed = false;
286  };
287 } // namespace mitk
288 
289 #endif // _mitkContourElement_H_
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
VertexListType::const_iterator ConstVertexIterator
MITKCORE_EXPORT const ScalarType eps
VertexListType::iterator VertexIterator
mitk::Point3D Coordinates
Coordinates in 3D space.
Represents a contour in 3D space. A ContourElement is consisting of linked vertices implicitely defin...
#define MITKCONTOURMODEL_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
VertexListType::size_type VertexSizeType
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
ContourModelVertex(const ContourModelVertex &other)
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:154
std::deque< VertexType * > VertexListType
ContourModelVertex(const mitk::Point3D &point, bool active=false)
Represents a single vertex of a contour.