Medical Imaging Interaction Toolkit  2018.04.99-15ecdf8d
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 
206  void Concatenate(mitk::ContourModel *other, int timestep = 0, bool check = false);
207 
211  VertexIterator Begin(int timestep = 0) const;
212 
216  VertexIterator IteratorBegin(int timestep = 0) const;
217 
221  VertexIterator End(int timestep = 0) const;
222 
226  VertexIterator IteratorEnd(int timestep = 0) const;
227 
231  virtual void Close(int timestep = 0);
232 
236  virtual void Open(int timestep = 0);
237 
243  virtual void SetClosed(bool isClosed, int timestep = 0);
244 
248  int GetNumberOfVertices(int timestep = 0) const;
249 
253  virtual bool IsEmpty(int timestep) const;
254 
257  bool IsEmpty() const override;
258 
261  virtual const VertexType *GetVertexAt(int index, int timestep = 0) const;
262 
267  int GetIndex(const VertexType *vertex, int timestep = 0);
268 
271  bool IsEmptyTimeStep(unsigned int t) const override;
272 
275  virtual bool IsNearContour(mitk::Point3D &point, float eps, int timestep);
276 
279  bool SelectVertexAt(int index, int timestep = 0);
280 
283  bool SetControlVertexAt(int index, int timestep = 0);
284 
293  bool SelectVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
294  /*
295  \pararm point - query point in 3D space
296  \pararm eps - radius for nearest neighbour search (error bound).
297  \pararm timestep - search at this timestep
298 
299  @return true = vertex found; false = no vertex found
300  */
301  bool SetControlVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
302 
307  bool RemoveVertexAt(int index, int timestep = 0);
308 
313  bool RemoveVertex(const VertexType *vertex, int timestep = 0);
314 
323  bool RemoveVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
324 
329  void ShiftSelectedVertex(mitk::Vector3D &translate);
330 
336  void ShiftContour(mitk::Vector3D &translate, int timestep = 0);
337 
343  virtual void Clear(int timestep);
344 
347  void Initialize() override;
348 
352  void Initialize(mitk::ContourModel &other);
353 
354  /*++++++++++++++++++ method inherit from base data +++++++++++++++++++++++++++*/
358  void SetRequestedRegionToLargestPossibleRegion() override;
359 
363  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
364 
368  bool VerifyRequestedRegion() override;
369 
373  virtual const mitk::BaseGeometry *GetUpdatedGeometry(int t = 0);
374 
378  virtual mitk::BaseGeometry *GetGeometry(int t = 0) const;
379 
383  void SetRequestedRegion(const itk::DataObject *data) override;
384 
388  void Expand(unsigned int timeSteps) override;
389 
395  void UpdateOutputInformation() override;
396 
403  void Clear() override;
404 
408  void ExecuteOperation(Operation *operation) override;
409 
414  virtual void RedistributeControlVertices(int period, int timestep);
415 
416  protected:
418 
419  ContourModel();
420  ContourModel(const mitk::ContourModel &other);
421  ~ContourModel() override;
422 
423  // inherit from BaseData. called by Clear()
424  void ClearData() override;
425 
426  // inherit from BaseData. Initial state of a contour with no vertices and a single timestep.
427  void InitializeEmpty() override;
428 
429  // Shift a vertex
430  void ShiftVertex(VertexType *vertex, mitk::Vector3D &vector);
431 
432  // Storage with time resolved support.
433  ContourModelSeries m_ContourSeries;
434 
435  // The currently selected vertex.
436  VertexType *m_SelectedVertex;
437 
438  // The interpolation of the line segment between control points.
440 
441  // only update the bounding geometry if necessary
443  };
444 
445  itkEventMacro(ContourModelEvent, itk::AnyEvent);
446  itkEventMacro(ContourModelShiftEvent, ContourModelEvent);
447  itkEventMacro(ContourModelSizeChangeEvent, ContourModelEvent);
448  itkEventMacro(ContourModelAddEvent, ContourModelSizeChangeEvent);
449  itkEventMacro(ContourModelRemoveEvent, ContourModelSizeChangeEvent);
450  itkEventMacro(ContourModelExpandTimeBoundsEvent, ContourModelEvent);
451  itkEventMacro(ContourModelClosedEvent, ContourModelEvent);
452 }
453 #endif
std::deque< VertexType * > VertexListType
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
MITKCORE_EXPORT const ScalarType eps
mitk::ContourElement::VertexType VertexType
itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent)
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
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
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.