Medical Imaging Interaction Toolkit  2018.4.99-b7f3afaa
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<mitk::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(mitk::Point3D &vertex, int timestep = 0);
113 
123  void AddVertex(VertexType &vertex, int timestep = 0);
124 
134  void AddVertex(const VertexType *vertex, int timestep = 0);
135 
147  void AddVertex(mitk::Point3D &vertex, bool isControlPoint, int timestep = 0);
148 
158  void AddVertexAtFront(mitk::Point3D &vertex, int timestep = 0);
159 
169  void AddVertexAtFront(VertexType &vertex, int timestep = 0);
170 
182  void AddVertexAtFront(mitk::Point3D &vertex, bool isControlPoint, int timestep = 0);
183 
186  void InsertVertexAtIndex(mitk::Point3D &vertex, int index, bool isControlPoint = false, int timestep = 0);
187 
190  bool SetVertexAt(int pointId, const mitk::Point3D &point, unsigned int timestep = 0);
191 
194  bool SetVertexAt(int pointId, const VertexType *vertex, unsigned int timestep = 0);
195 
198  bool IsClosed(int timestep = 0) const;
199 
205  void Concatenate(mitk::ContourModel *other, int timestep = 0, bool check = false);
206 
210  VertexIterator Begin(int timestep = 0) const;
211 
215  VertexIterator IteratorBegin(int timestep = 0) const;
216 
220  VertexIterator End(int timestep = 0) const;
221 
225  VertexIterator IteratorEnd(int timestep = 0) const;
226 
230  virtual void Close(int timestep = 0);
231 
235  virtual void Open(int timestep = 0);
236 
242  virtual void SetClosed(bool isClosed, int timestep = 0);
243 
247  int GetNumberOfVertices(int timestep = 0) const;
248 
252  virtual bool IsEmpty(int timestep) const;
253 
256  bool IsEmpty() const override;
257 
260  virtual const VertexType *GetVertexAt(int index, int timestep = 0) const;
261 
266  int GetIndex(const VertexType *vertex, int timestep = 0);
267 
270  bool IsEmptyTimeStep(unsigned int t) const override;
271 
274  virtual bool IsNearContour(mitk::Point3D &point, float eps, int timestep);
275 
278  bool SelectVertexAt(int index, int timestep = 0);
279 
282  bool SetControlVertexAt(int index, int timestep = 0);
283 
292  bool SelectVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
293  /*
294  \pararm point - query point in 3D space
295  \pararm eps - radius for nearest neighbour search (error bound).
296  \pararm timestep - search at this timestep
297 
298  @return true = vertex found; false = no vertex found
299  */
300  bool SetControlVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
301 
306  bool RemoveVertexAt(int index, int timestep = 0);
307 
312  bool RemoveVertex(const VertexType *vertex, int timestep = 0);
313 
322  bool RemoveVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
323 
328  void ShiftSelectedVertex(mitk::Vector3D &translate);
329 
335  void ShiftContour(mitk::Vector3D &translate, int timestep = 0);
336 
342  virtual void Clear(int timestep);
343 
346  void Initialize() override;
347 
351  void Initialize(mitk::ContourModel &other);
352 
353  /*++++++++++++++++++ method inherit from base data +++++++++++++++++++++++++++*/
357  void SetRequestedRegionToLargestPossibleRegion() override;
358 
362  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
363 
367  bool VerifyRequestedRegion() override;
368 
372  virtual const mitk::BaseGeometry *GetUpdatedGeometry(int t = 0);
373 
377  virtual mitk::BaseGeometry *GetGeometry(int t = 0) const;
378 
382  void SetRequestedRegion(const itk::DataObject *data) override;
383 
387  void Expand(unsigned int timeSteps) override;
388 
394  void UpdateOutputInformation() override;
395 
402  void Clear() override;
403 
407  void ExecuteOperation(Operation *operation) override;
408 
413  virtual void RedistributeControlVertices(int period, int timestep);
414 
415  protected:
417 
418  ContourModel();
419  ContourModel(const mitk::ContourModel &other);
420  ~ContourModel() override;
421 
422  // inherit from BaseData. called by Clear()
423  void ClearData() override;
424 
425  // inherit from BaseData. Initial state of a contour with no vertices and a single timestep.
426  void InitializeEmpty() override;
427 
428  // Shift a vertex
429  void ShiftVertex(VertexType *vertex, mitk::Vector3D &vector);
430 
431  // Storage with time resolved support.
432  ContourModelSeries m_ContourSeries;
433 
434  // The currently selected vertex.
435  VertexType *m_SelectedVertex;
436 
437  // The interpolation of the line segment between control points.
439 
440  // only update the bounding geometry if necessary
442  };
443 
444  itkEventMacro(ContourModelEvent, itk::AnyEvent);
445  itkEventMacro(ContourModelShiftEvent, ContourModelEvent);
446  itkEventMacro(ContourModelSizeChangeEvent, ContourModelEvent);
447  itkEventMacro(ContourModelAddEvent, ContourModelSizeChangeEvent);
448  itkEventMacro(ContourModelRemoveEvent, ContourModelSizeChangeEvent);
449  itkEventMacro(ContourModelExpandTimeBoundsEvent, ContourModelEvent);
450  itkEventMacro(ContourModelClosedEvent, ContourModelEvent);
451 }
452 #endif
std::deque< VertexType * > VertexListType
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
mitk::ContourElement::VertexType VertexType
itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent)
Base of all data objects.
Definition: mitkBaseData.h:37
Base class of all Operation-classes.
Definition: mitkOperation.h:29
void Deselect()
Deselect vertex.
#define MITKCONTOURMODEL_EXPORT
mitk::ContourElement::VertexIterator VertexIterator
DataCollection - Class to facilitate loading/accessing structured data.
VertexListType::const_iterator ConstVertexIterator
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
void SetSelectedVertexAsControlPoint(bool isControlPoint=true)
Set selected vertex as control point.
mitk::ContourElement::ConstVertexIterator ConstVertexIterator
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:158
VertexType * m_SelectedVertex
LineSegmentInterpolation m_lineInterpolation
MITKCORE_EXPORT const ScalarType eps
mitk::ContourElement::VertexListType VertexListType
VertexListType::iterator VertexIterator
std::vector< mitk::ContourElement::Pointer > ContourModelSeries
LineSegmentInterpolation GetLineSegmentInterpolation()
Get the interpolation of the line segments between control points.
Represents a single vertex of contour.
void SetLineSegmentInterpolation(LineSegmentInterpolation interpolation)
Set the interpolation of the line segments between control points.
BaseGeometry Describes the geometry of a data object.