Medical Imaging Interaction Toolkit  2021.10.99-9c07a326
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 
260  virtual const VertexType *GetNextControlVertexAt(mitk::Point3D &point, float eps, TimeStepType timestep) const;
261 
265  virtual const VertexType *GetPreviousControlVertexAt(mitk::Point3D &point, float eps, TimeStepType timestep) const;
266 
271  int GetIndex(const VertexType *vertex, TimeStepType timestep = 0);
272 
275  bool IsEmptyTimeStep(unsigned int t) const override;
276 
279  virtual bool IsNearContour(Point3D &point, float eps, TimeStepType timestep);
280 
281 
284  bool SelectVertexAt(int index, TimeStepType timestep = 0);
285 
288  bool SetControlVertexAt(int index, TimeStepType timestep = 0);
289 
298  bool SelectControlVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
299 
308  bool SelectVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
309 
310  /*
311  \pararm point - query point in 3D space
312  \pararm eps - radius for nearest neighbour search (error bound).
313  \pararm timestep - search at this timestep
314 
315  @return true = vertex found; false = no vertex found
316  */
317  bool SetControlVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
318 
323  bool RemoveVertexAt(int index, TimeStepType timestep = 0);
324 
329  bool RemoveVertex(const VertexType *vertex, TimeStepType timestep = 0);
330 
339  bool RemoveVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
340 
345  void ShiftSelectedVertex(Vector3D &translate);
346 
352  void ShiftContour(Vector3D &translate, TimeStepType timestep = 0);
353 
359  virtual void Clear(TimeStepType timestep);
360 
363  void Initialize() override;
364 
368  void Initialize(const ContourModel &other);
369 
372  VertexListType GetControlVertices(TimeStepType timestep);
373 
376  VertexListType GetVertexList(TimeStepType timestep);
377 
378  /*++++++++++++++++++ method inherit from base data +++++++++++++++++++++++++++*/
382  void SetRequestedRegionToLargestPossibleRegion() override;
383 
387  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
388 
392  bool VerifyRequestedRegion() override;
393 
397  void SetRequestedRegion(const itk::DataObject *data) override;
398 
402  void Expand(unsigned int timeSteps) override;
403 
409  void UpdateOutputInformation() override;
410 
417  void Clear() override;
418 
422  void ExecuteOperation(Operation *operation) override;
423 
428  virtual void RedistributeControlVertices(int period, TimeStepType timestep);
429 
430  protected:
432 
433  ContourModel();
434  ContourModel(const ContourModel &other);
435  ~ContourModel() override;
436 
437  // inherit from BaseData. called by Clear()
438  void ClearData() override;
439 
440  // inherit from BaseData. Initial state of a contour with no vertices and a single timestep.
441  void InitializeEmpty() override;
442 
443  // Shift a vertex
444  static void ShiftVertex(VertexType *vertex, Vector3D &vector);
445 
446  // Storage with time resolved support.
447  ContourModelSeries m_ContourSeries;
448 
449  // The currently selected vertex.
450  VertexType *m_SelectedVertex;
451 
452  // The interpolation of the line segment between control points.
454 
455  // only update the bounding geometry if necessary
457  };
458 
459  itkEventMacro(ContourModelEvent, itk::AnyEvent);
460  itkEventMacro(ContourModelShiftEvent, ContourModelEvent);
461  itkEventMacro(ContourModelSizeChangeEvent, ContourModelEvent);
462  itkEventMacro(ContourModelAddEvent, ContourModelSizeChangeEvent);
463  itkEventMacro(ContourModelRemoveEvent, ContourModelSizeChangeEvent);
464  itkEventMacro(ContourModelExpandTimeBoundsEvent, ContourModelEvent);
465  itkEventMacro(ContourModelClosedEvent, ContourModelEvent);
466 }
467 #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:36
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:154
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.