Medical Imaging Interaction Toolkit  2021.02.99-c7792db0
Medical Imaging Interaction Toolkit
mitkContourModel.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 _MITK_CONTOURMODEL_H_
13 #define _MITK_CONTOURMODEL_H_
14 
15 #include "mitkBaseData.h"
16 #include "mitkCommon.h"
18 
19 #include <mitkContourElement.h>
20 
21 namespace mitk
22 {
48  {
49  public:
51 
52  itkFactorylessNewMacro(Self);
53 
54  itkCloneMacro(Self);
55 
56  /*+++++++++++++++ typedefs +++++++++++++++++++++++++++++++*/
61  typedef std::vector<ContourElement::Pointer> ContourModelSeries;
62  /*+++++++++++++++ END typedefs ++++++++++++++++++++++++++++*/
63 
66  {
68  B_SPLINE
69  };
70 
71  /*++++++++++++++++ inline methods +++++++++++++++++++++++*/
72 
75  VertexType *GetSelectedVertex() { return this->m_SelectedVertex; }
78  void Deselect() { this->m_SelectedVertex = nullptr; }
81  void SetSelectedVertexAsControlPoint(bool isControlPoint = true)
82  {
83  if (this->m_SelectedVertex)
84  {
85  m_SelectedVertex->IsControlPoint = isControlPoint;
86  this->Modified();
87  }
88  }
89 
93  {
94  this->m_lineInterpolation = interpolation;
95  this->Modified();
96  }
97 
100  LineSegmentInterpolation GetLineSegmentInterpolation() { return this->m_lineInterpolation; }
101  /*++++++++++++++++ END inline methods +++++++++++++++++++++++*/
102 
112  void AddVertex(const Point3D &vertex, TimeStepType timestep = 0);
113 
121  void AddVertex(const VertexType &vertex, TimeStepType timestep = 0);
122 
131  void AddVertex(const Point3D& vertex, bool isControlPoint, TimeStepType timestep = 0);
132 
140  void UpdateContour(const ContourModel* sourceModel, TimeStepType destinationTimeStep, TimeStepType sourceTimeStep);
141 
151  void AddVertexAtFront(const Point3D &vertex, TimeStepType timestep = 0);
152 
162  void AddVertexAtFront(const VertexType &vertex, TimeStepType timestep = 0);
163 
175  void AddVertexAtFront(const Point3D &vertex, bool isControlPoint, TimeStepType timestep = 0);
176 
179  void InsertVertexAtIndex(const Point3D &vertex, int index, bool isControlPoint = false, TimeStepType timestep = 0);
180 
183  bool SetVertexAt(int pointId, const Point3D &point, TimeStepType timestep = 0);
184 
187  bool SetVertexAt(int pointId, const VertexType *vertex, TimeStepType timestep = 0);
188 
191  bool IsClosed(int timestep = 0) const;
192 
199  void Concatenate(ContourModel *other, TimeStepType timestep = 0, bool check = false);
200 
204  VertexIterator Begin(TimeStepType timestep = 0) const;
205 
209  VertexIterator IteratorBegin(TimeStepType timestep = 0) const;
210 
214  VertexIterator End(TimeStepType timestep = 0) const;
215 
219  VertexIterator IteratorEnd(TimeStepType timestep = 0) const;
220 
224  virtual void Close(TimeStepType timestep = 0);
225 
229  virtual void Open(TimeStepType timestep = 0);
230 
236  virtual void SetClosed(bool isClosed, TimeStepType timestep = 0);
237 
241  int GetNumberOfVertices(TimeStepType timestep = 0) const;
242 
246  virtual bool IsEmpty(TimeStepType timestep) const;
247 
250  bool IsEmpty() const override;
251 
255  virtual const VertexType *GetVertexAt(int index, TimeStepType timestep = 0) const;
256 
261  int GetIndex(const VertexType *vertex, TimeStepType timestep = 0);
262 
265  bool IsEmptyTimeStep(unsigned int t) const override;
266 
269  virtual bool IsNearContour(Point3D &point, float eps, TimeStepType timestep);
270 
273  bool SelectVertexAt(int index, TimeStepType timestep = 0);
274 
277  bool SetControlVertexAt(int index, TimeStepType timestep = 0);
278 
287  bool SelectVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
288  /*
289  \pararm point - query point in 3D space
290  \pararm eps - radius for nearest neighbour search (error bound).
291  \pararm timestep - search at this timestep
292 
293  @return true = vertex found; false = no vertex found
294  */
295  bool SetControlVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
296 
301  bool RemoveVertexAt(int index, TimeStepType timestep = 0);
302 
307  bool RemoveVertex(const VertexType *vertex, TimeStepType timestep = 0);
308 
317  bool RemoveVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
318 
323  void ShiftSelectedVertex(Vector3D &translate);
324 
330  void ShiftContour(Vector3D &translate, TimeStepType timestep = 0);
331 
337  virtual void Clear(TimeStepType timestep);
338 
341  void Initialize() override;
342 
346  void Initialize(const ContourModel &other);
347 
348  /*++++++++++++++++++ method inherit from base data +++++++++++++++++++++++++++*/
352  void SetRequestedRegionToLargestPossibleRegion() override;
353 
357  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
358 
362  bool VerifyRequestedRegion() override;
363 
367  void SetRequestedRegion(const itk::DataObject *data) override;
368 
372  void Expand(unsigned int timeSteps) override;
373 
379  void UpdateOutputInformation() override;
380 
387  void Clear() override;
388 
392  void ExecuteOperation(Operation *operation) override;
393 
398  virtual void RedistributeControlVertices(int period, TimeStepType timestep);
399 
400  protected:
402 
403  ContourModel();
404  ContourModel(const ContourModel &other);
405  ~ContourModel() override;
406 
407  // inherit from BaseData. called by Clear()
408  void ClearData() override;
409 
410  // inherit from BaseData. Initial state of a contour with no vertices and a single timestep.
411  void InitializeEmpty() override;
412 
413  // Shift a vertex
414  static void ShiftVertex(VertexType *vertex, Vector3D &vector);
415 
416  // Storage with time resolved support.
417  ContourModelSeries m_ContourSeries;
418 
419  // The currently selected vertex.
420  VertexType *m_SelectedVertex;
421 
422  // The interpolation of the line segment between control points.
424 
425  // only update the bounding geometry if necessary
427  };
428 
429  itkEventMacro(ContourModelEvent, itk::AnyEvent);
430  itkEventMacro(ContourModelShiftEvent, ContourModelEvent);
431  itkEventMacro(ContourModelSizeChangeEvent, ContourModelEvent);
432  itkEventMacro(ContourModelAddEvent, ContourModelSizeChangeEvent);
433  itkEventMacro(ContourModelRemoveEvent, ContourModelSizeChangeEvent);
434  itkEventMacro(ContourModelExpandTimeBoundsEvent, ContourModelEvent);
435  itkEventMacro(ContourModelClosedEvent, ContourModelEvent);
436 }
437 #endif
VertexListType::const_iterator ConstVertexIterator
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
MITKCORE_EXPORT const ScalarType eps
itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent)
VertexListType::iterator VertexIterator
ContourElement::VertexListType VertexListType
Base of all data objects.
Definition: mitkBaseData.h:42
Base class of all Operation-classes.
Definition: mitkOperation.h:29
void Deselect()
Deselect vertex.
#define MITKCONTOURMODEL_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
VertexType * GetSelectedVertex()
Get the current selected vertex.
ContourModelSeries m_ContourSeries
LineSegmentInterpolation
Possible interpolation of the line segments between control points.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
ContourElement::VertexType VertexType
void SetSelectedVertexAsControlPoint(bool isControlPoint=true)
Set selected vertex as control point.
std::vector< ContourElement::Pointer > ContourModelSeries
std::vcl_size_t TimeStepType
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:158
std::deque< VertexType * > VertexListType
ContourElement::ConstVertexIterator ConstVertexIterator
VertexType * m_SelectedVertex
LineSegmentInterpolation m_lineInterpolation
ContourElement::VertexIterator VertexIterator
LineSegmentInterpolation GetLineSegmentInterpolation()
Get the interpolation of the line segments between control points.
Represents a single vertex of a contour.
void SetLineSegmentInterpolation(LineSegmentInterpolation interpolation)
Set the interpolation of the line segments between control points.