Medical Imaging Interaction Toolkit  2018.04.99-3ec0dd08
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  VertexSizeType GetIndex(const VertexType *vertex) const;
158 
161  const VertexListType *GetVertexList() const;
162 
165  bool IsEmpty() const;
166 
169  bool IsClosed() const;
170 
175  bool IsNearContour(const mitk::Point3D &point, float eps) const;
176 
180  void Close();
181 
185  void Open();
186 
190  void SetClosed(bool isClosed);
191 
197  void Concatenate(const mitk::ContourElement *other, bool check);
198 
202  bool RemoveVertex(const VertexType *vertex);
203 
207  bool RemoveVertexAt(VertexSizeType index);
208 
213  bool RemoveVertexAt(const mitk::Point3D &point, double eps);
214 
217  void Clear();
218 
223  VertexType *BruteForceGetVertexAt(const mitk::Point3D &point, double eps);
224 
232  VertexListType GetControlVertices() const;
233 
238  void RedistributeControlVertices(const VertexType *vertex, int period);
239 
240  protected:
241  mitkCloneMacro(Self);
242 
243  ContourElement() = default;
244  ContourElement(const mitk::ContourElement &other);
245  ~ContourElement();
246 
247  ContourElement& operator = (const ContourElement & other);
248 
253  bool RemoveVertexByIterator(VertexListType::iterator& iter);
254 
255  VertexListType m_Vertices; // double ended queue with vertices
256  bool m_IsClosed = false;
257  };
258 } // namespace mitk
259 
260 #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:49
ContourModelVertex(const ContourModelVertex &other)
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:158
std::deque< VertexType * > VertexListType
ContourModelVertex(const mitk::Point3D &point, bool active=false)
Represents a single vertex of a contour.