Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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) itkCloneMacro(Self)
53 
54  /*+++++++++++++++ typedefs +++++++++++++++++++++++++++++++*/
60  /*+++++++++++++++ END typedefs ++++++++++++++++++++++++++++*/
61 
64  {
66  B_SPLINE
67  };
68 
69  /*++++++++++++++++ inline methods +++++++++++++++++++++++*/
70 
73  VertexType *GetSelectedVertex() { return this->m_SelectedVertex; }
76  void Deselect() { this->m_SelectedVertex = nullptr; }
79  void SetSelectedVertexAsControlPoint(bool isControlPoint = true)
80  {
81  if (this->m_SelectedVertex)
82  {
83  m_SelectedVertex->IsControlPoint = isControlPoint;
84  this->Modified();
85  }
86  }
87 
91  {
92  this->m_lineInterpolation = interpolation;
93  this->Modified();
94  }
95 
98  LineSegmentInterpolation GetLineSegmentInterpolation() { return this->m_lineInterpolation; }
99  /*++++++++++++++++ END inline methods +++++++++++++++++++++++*/
100 
110  void AddVertex(mitk::Point3D &vertex, int timestep = 0);
111 
121  void AddVertex(VertexType &vertex, int timestep = 0);
122 
132  void AddVertex(const VertexType *vertex, int timestep = 0);
133 
145  void AddVertex(mitk::Point3D &vertex, bool isControlPoint, int timestep = 0);
146 
156  void AddVertexAtFront(mitk::Point3D &vertex, int timestep = 0);
157 
167  void AddVertexAtFront(VertexType &vertex, int timestep = 0);
168 
180  void AddVertexAtFront(mitk::Point3D &vertex, bool isControlPoint, int timestep = 0);
181 
184  void InsertVertexAtIndex(mitk::Point3D &vertex, int index, bool isControlPoint = false, int timestep = 0);
185 
188  bool SetVertexAt(int pointId, const mitk::Point3D &point, unsigned int timestep = 0);
189 
192  bool SetVertexAt(int pointId, const VertexType *vertex, unsigned int timestep = 0);
193 
196  bool IsClosed(int timestep = 0) const;
197 
203  void Concatenate(mitk::ContourModel *other, int timestep = 0, bool check = false);
204 
208  VertexIterator Begin(int timestep = 0) const;
209 
213  VertexIterator IteratorBegin(int timestep = 0) const;
214 
218  VertexIterator End(int timestep = 0) const;
219 
223  VertexIterator IteratorEnd(int timestep = 0) const;
224 
228  virtual void Close(int timestep = 0);
229 
233  virtual void Open(int timestep = 0);
234 
240  virtual void SetClosed(bool isClosed, int timestep = 0);
241 
245  int GetNumberOfVertices(int timestep = 0) const;
246 
250  virtual bool IsEmpty(int timestep) const;
251 
254  bool IsEmpty() const override;
255 
258  virtual const VertexType *GetVertexAt(int index, int timestep = 0) const;
259 
264  int GetIndex(const VertexType *vertex, int timestep = 0);
265 
268  bool IsEmptyTimeStep(unsigned int t) const override;
269 
272  virtual bool IsNearContour(mitk::Point3D &point, float eps, int timestep);
273 
276  bool SelectVertexAt(int index, int timestep = 0);
277 
280  bool SetControlVertexAt(int index, int timestep = 0);
281 
290  bool SelectVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
291  /*
292  \pararm point - query point in 3D space
293  \pararm eps - radius for nearest neighbour search (error bound).
294  \pararm timestep - search at this timestep
295 
296  @return true = vertex found; false = no vertex found
297  */
298  bool SetControlVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
299 
304  bool RemoveVertexAt(int index, int timestep = 0);
305 
310  bool RemoveVertex(const VertexType *vertex, int timestep = 0);
311 
320  bool RemoveVertexAt(mitk::Point3D &point, float eps, int timestep = 0);
321 
326  void ShiftSelectedVertex(mitk::Vector3D &translate);
327 
333  void ShiftContour(mitk::Vector3D &translate, int timestep = 0);
334 
340  virtual void Clear(int timestep);
341 
344  void Initialize() override;
345 
349  void Initialize(mitk::ContourModel &other);
350 
351  /*++++++++++++++++++ method inherit from base data +++++++++++++++++++++++++++*/
355  void SetRequestedRegionToLargestPossibleRegion() override;
356 
360  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
361 
365  bool VerifyRequestedRegion() override;
366 
370  virtual const mitk::BaseGeometry *GetUpdatedGeometry(int t = 0);
371 
375  virtual mitk::BaseGeometry *GetGeometry(int t = 0) const;
376 
380  void SetRequestedRegion(const itk::DataObject *data) override;
381 
385  void Expand(unsigned int timeSteps) override;
386 
392  void UpdateOutputInformation() override;
393 
400  void Clear() override;
401 
405  void ExecuteOperation(Operation *operation) override;
406 
411  virtual void RedistributeControlVertices(int period, int timestep);
412 
413  protected:
415 
416  ContourModel();
417  ContourModel(const mitk::ContourModel &other);
418  ~ContourModel() override;
419 
420  // inherit from BaseData. called by Clear()
421  void ClearData() override;
422 
423  // inherit from BaseData. Initial state of a contour with no vertices and a single timestep.
424  void InitializeEmpty() override;
425 
426  // Shift a vertex
427  void ShiftVertex(VertexType *vertex, mitk::Vector3D &vector);
428 
429  // Storage with time resolved support.
431 
432  // The currently selected vertex.
434 
435  // The interpolation of the line segment between control points.
437 
438  // only update the bounding geometry if necessary
440  };
441 
442  itkEventMacro(ContourModelEvent, itk::AnyEvent);
443  itkEventMacro(ContourModelShiftEvent, ContourModelEvent);
444  itkEventMacro(ContourModelSizeChangeEvent, ContourModelEvent);
445  itkEventMacro(ContourModelAddEvent, ContourModelSizeChangeEvent);
446  itkEventMacro(ContourModelRemoveEvent, ContourModelSizeChangeEvent);
447  itkEventMacro(ContourModelExpandTimeBoundsEvent, ContourModelEvent);
448  itkEventMacro(ContourModelClosedEvent, ContourModelEvent);
449 }
450 #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:37
Base class of all Operation-classes.
Definition: mitkOperation.h:29
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:40
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:158
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.