Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #ifndef _MITK_CONTOURMODEL_H_
17 #define _MITK_CONTOURMODEL_H_
18 
19 #include "mitkBaseData.h"
20 #include "mitkCommon.h"
22 
23 #include <mitkContourElement.h>
24 
25 namespace mitk
26 {
52  {
53  public:
55 
56  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
57 
58  /*+++++++++++++++ typedefs +++++++++++++++++++++++++++++++*/
64  /*+++++++++++++++ END typedefs ++++++++++++++++++++++++++++*/
65 
68  {
70  B_SPLINE
71  };
72 
73  /*++++++++++++++++ inline methods +++++++++++++++++++++++*/
74 
77  VertexType *GetSelectedVertex() { return this->m_SelectedVertex; }
80  void Deselect() { this->m_SelectedVertex = nullptr; }
83  void SetSelectedVertexAsControlPoint(bool isControlPoint = true)
84  {
85  if (this->m_SelectedVertex)
86  {
87  m_SelectedVertex->IsControlPoint = isControlPoint;
88  this->Modified();
89  }
90  }
91 
95  {
96  this->m_lineInterpolation = interpolation;
97  this->Modified();
98  }
99 
102  LineSegmentInterpolation GetLineSegmentInterpolation() { return this->m_lineInterpolation; }
103  /*++++++++++++++++ END inline methods +++++++++++++++++++++++*/
104 
114  void AddVertex(mitk::Point3D &vertex, int timestep = 0);
115 
125  void AddVertex(VertexType &vertex, int timestep = 0);
126 
136  void AddVertex(const VertexType *vertex, int timestep = 0);
137 
149  void AddVertex(mitk::Point3D &vertex, bool isControlPoint, int timestep = 0);
150 
160  void AddVertexAtFront(mitk::Point3D &vertex, int timestep = 0);
161 
171  void AddVertexAtFront(VertexType &vertex, int timestep = 0);
172 
184  void AddVertexAtFront(mitk::Point3D &vertex, bool isControlPoint, int timestep = 0);
185 
188  void InsertVertexAtIndex(mitk::Point3D &vertex, int index, bool isControlPoint = false, int timestep = 0);
189 
192  bool SetVertexAt(int pointId, const mitk::Point3D &point, unsigned int timestep = 0);
193 
196  bool SetVertexAt(int pointId, const VertexType *vertex, unsigned int timestep = 0);
197 
200  bool IsClosed(int timestep = 0) const;
201 
207  void Concatenate(mitk::ContourModel *other, int timestep = 0, bool check = false);
208 
212  VertexIterator Begin(int timestep = 0) const;
213 
217  VertexIterator IteratorBegin(int timestep = 0) const;
218 
222  VertexIterator End(int timestep = 0) const;
223 
227  VertexIterator IteratorEnd(int timestep = 0) const;
228 
232  virtual void Close(int timestep = 0);
233 
237  virtual void Open(int timestep = 0);
238 
244  virtual void SetClosed(bool isClosed, int timestep = 0);
245 
249  int GetNumberOfVertices(int timestep = 0) const;
250 
254  virtual bool IsEmpty(int timestep) const;
255 
258  virtual bool IsEmpty() const override;
259 
262  virtual const VertexType *GetVertexAt(int index, int timestep = 0) const;
263 
268  int GetIndex(const VertexType *vertex, int timestep = 0);
269 
272  virtual bool IsEmptyTimeStep(unsigned int t) const override;
273 
276  virtual bool IsNearContour(mitk::Point3D &point, float eps, int timestep);
277 
280  bool SelectVertexAt(int index, int timestep = 0);
281 
284  bool SetControlVertexAt(int index, int timestep = 0);
285 
294  bool SelectVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
295  /*
296  \pararm point - query point in 3D space
297  \pararm eps - radius for nearest neighbour search (error bound).
298  \pararm timestep - search at this timestep
299 
300  @return true = vertex found; false = no vertex found
301  */
302  bool SetControlVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
303 
308  bool RemoveVertexAt(int index, int timestep = 0);
309 
314  bool RemoveVertex(const VertexType *vertex, int timestep = 0);
315 
324  bool RemoveVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
325 
330  void ShiftSelectedVertex(mitk::Vector3D &translate);
331 
337  void ShiftContour(mitk::Vector3D &translate, int timestep = 0);
338 
344  virtual void Clear(int timestep);
345 
348  virtual void Initialize() override;
349 
353  void Initialize(mitk::ContourModel &other);
354 
355  /*++++++++++++++++++ method inherit from base data +++++++++++++++++++++++++++*/
359  virtual void SetRequestedRegionToLargestPossibleRegion() override;
360 
364  virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
365 
369  virtual bool VerifyRequestedRegion() override;
370 
374  virtual const mitk::BaseGeometry *GetUpdatedGeometry(int t = 0);
375 
379  virtual mitk::BaseGeometry *GetGeometry(int t = 0) const;
380 
384  virtual void SetRequestedRegion(const itk::DataObject *data) override;
385 
389  virtual void Expand(unsigned int timeSteps) override;
390 
396  virtual void UpdateOutputInformation() override;
397 
404  virtual void Clear() override;
405 
409  void ExecuteOperation(Operation *operation) override;
410 
415  virtual void RedistributeControlVertices(int period, int timestep);
416 
417  protected:
418  mitkCloneMacro(Self);
419 
420  ContourModel();
421  ContourModel(const mitk::ContourModel &other);
422  virtual ~ContourModel();
423 
424  // inherit from BaseData. called by Clear()
425  virtual void ClearData() override;
426 
427  // inherit from BaseData. Initial state of a contour with no vertices and a single timestep.
428  virtual void InitializeEmpty() override;
429 
430  // Shift a vertex
431  void ShiftVertex(VertexType *vertex, mitk::Vector3D &vector);
432 
433  // Storage with time resolved support.
435 
436  // The currently selected vertex.
438 
439  // The interpolation of the line segment between control points.
441 
442  // only update the bounding geometry if necessary
444  };
445 
446  itkEventMacro(ContourModelEvent, itk::AnyEvent);
447  itkEventMacro(ContourModelShiftEvent, ContourModelEvent);
448  itkEventMacro(ContourModelSizeChangeEvent, ContourModelEvent);
449  itkEventMacro(ContourModelAddEvent, ContourModelSizeChangeEvent);
450  itkEventMacro(ContourModelRemoveEvent, ContourModelSizeChangeEvent);
451  itkEventMacro(ContourModelExpandTimeBoundsEvent, ContourModelEvent);
452  itkEventMacro(ContourModelClosedEvent, ContourModelEvent);
453 }
454 #endif
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
Base of all data objects.
Definition: mitkBaseData.h:39
Base class of all Operation-classes.
Definition: mitkOperation.h:33
void Deselect()
Deselect vertex.
Represents a contour in 3D space. A ContourElement is consisting of linked vertices implicitely defin...
#define MITKCONTOURMODEL_EXPORT
mitk::ContourElement::VertexIterator VertexIterator
STL namespace.
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:44
void SetSelectedVertexAsControlPoint(bool isControlPoint=true)
Set selected vertex as control point.
mitk::ContourElement::ConstVertexIterator ConstVertexIterator
itkEventMacro(ContourModelEvent, itk::AnyEvent)
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:162
VertexType * m_SelectedVertex
LineSegmentInterpolation m_lineInterpolation
MITKCORE_EXPORT const ScalarType eps
mitk::ContourElement::VertexListType VertexListType
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.