Medical Imaging Interaction Toolkit  2022.10.99-efe2ad43
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 
257  const VertexType *GetVertexAt(mitk::Point3D &point, float eps, TimeStepType timestep) const;
258 
262  virtual const VertexType *GetNextControlVertexAt(mitk::Point3D &point, float eps, TimeStepType timestep) const;
263 
267  virtual const VertexType *GetPreviousControlVertexAt(mitk::Point3D &point, float eps, TimeStepType timestep) const;
268 
273  int GetIndex(const VertexType *vertex, TimeStepType timestep = 0);
274 
277  bool IsEmptyTimeStep(unsigned int t) const override;
278 
281  bool IsNearContour(Point3D &point, float eps, TimeStepType timestep) const;
282 
289  bool GetLineSegmentForPoint(Point3D &point,
290  float eps,
291  TimeStepType timestep,
292  mitk::ContourElement::VertexType *previousVertex = nullptr,
293  mitk::ContourElement::VertexType *nextVertex = nullptr);
294 
299  bool GetLineSegmentForPoint(const mitk::Point3D& point,
300  float eps, TimeStepType timestep, ContourElement::VertexSizeType& segmentStartIndex,
301  ContourElement::VertexSizeType& segmentEndIndex, mitk::Point3D& closestContourPoint,
302  bool findClosest = true) const;
303 
306  bool SelectVertexAt(int index, TimeStepType timestep = 0);
307 
310  bool SetControlVertexAt(int index, TimeStepType timestep = 0);
311 
320  bool SelectControlVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
321 
330  bool SelectVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
331 
332  /*
333  \pararm point - query point in 3D space
334  \pararm eps - radius for nearest neighbour search (error bound).
335  \pararm timestep - search at this timestep
336 
337  @return true = vertex found; false = no vertex found
338  */
339  bool SetControlVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
340 
345  bool RemoveVertexAt(int index, TimeStepType timestep = 0);
346 
351  bool RemoveVertex(const VertexType *vertex, TimeStepType timestep = 0);
352 
361  bool RemoveVertexAt(Point3D &point, float eps, TimeStepType timestep = 0);
362 
367  void ShiftSelectedVertex(Vector3D &translate);
368 
374  void ShiftContour(Vector3D &translate, TimeStepType timestep = 0);
375 
381  virtual void Clear(TimeStepType timestep);
382 
385  void Initialize() override;
386 
390  void Initialize(const ContourModel &other);
391 
394  VertexListType GetControlVertices(TimeStepType timestep);
395 
398  VertexListType GetVertexList(TimeStepType timestep);
399 
400  /*++++++++++++++++++ method inherit from base data +++++++++++++++++++++++++++*/
404  void SetRequestedRegionToLargestPossibleRegion() override;
405 
409  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
410 
414  bool VerifyRequestedRegion() override;
415 
419  void SetRequestedRegion(const itk::DataObject *data) override;
420 
424  void Expand(unsigned int timeSteps) override;
425 
431  void UpdateOutputInformation() override;
432 
439  void Clear() override;
440 
444  void ExecuteOperation(Operation *operation) override;
445 
450  virtual void RedistributeControlVertices(int period, TimeStepType timestep);
451 
452  protected:
453  mitkCloneMacro(Self);
454 
455  ContourModel();
456  ContourModel(const ContourModel &other);
457  ~ContourModel() override;
458 
459  // inherit from BaseData. called by Clear()
460  void ClearData() override;
461 
462  // inherit from BaseData. Initial state of a contour with no vertices and a single timestep.
463  void InitializeEmpty() override;
464 
465  // Shift a vertex
466  static void ShiftVertex(VertexType *vertex, Vector3D &vector);
467 
468  // Storage with time resolved support.
470 
471  // The currently selected vertex.
473 
474  // The interpolation of the line segment between control points.
476 
477  // only update the bounding geometry if necessary
479  };
480 
481  itkEventMacroDeclaration(ContourModelEvent, itk::AnyEvent);
482  itkEventMacroDeclaration(ContourModelShiftEvent, ContourModelEvent);
483  itkEventMacroDeclaration(ContourModelSizeChangeEvent, ContourModelEvent);
484  itkEventMacroDeclaration(ContourModelAddEvent, ContourModelSizeChangeEvent);
485  itkEventMacroDeclaration(ContourModelRemoveEvent, ContourModelSizeChangeEvent);
486  itkEventMacroDeclaration(ContourModelExpandTimeBoundsEvent, ContourModelEvent);
487  itkEventMacroDeclaration(ContourModelClosedEvent, ContourModelEvent);
488 }
489 #endif
mitk::eps
const MITKCORE_EXPORT ScalarType eps
mitk::ContourModel::m_SelectedVertex
VertexType * m_SelectedVertex
Definition: mitkContourModel.h:472
mitk::ContourElement::ContourModelVertex
Represents a single vertex of a contour.
Definition: mitkContourElement.h:47
mitk::ContourModel::VertexListType
ContourElement::VertexListType VertexListType
Definition: mitkContourModel.h:58
mitk::ContourElement::VertexListType
std::deque< VertexType * > VertexListType
Definition: mitkContourElement.h:65
mitk::Operation
Base class of all Operation-classes.
Definition: mitkOperation.h:29
mitk::ContourModel::GetSelectedVertex
VertexType * GetSelectedVertex()
Get the current selected vertex.
Definition: mitkContourModel.h:75
mitkContourElement.h
mitk::ContourElement::VertexIterator
VertexListType::iterator VertexIterator
Definition: mitkContourElement.h:66
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::ContourModel::ContourModelSeries
std::vector< ContourElement::Pointer > ContourModelSeries
Definition: mitkContourModel.h:61
MitkContourModelExports.h
mitk::ContourModel::m_lineInterpolation
LineSegmentInterpolation m_lineInterpolation
Definition: mitkContourModel.h:475
mitk::ContourModel::LINEAR
@ LINEAR
Definition: mitkContourModel.h:67
mitk::Vector< ScalarType, 3 >
mitk::ContourModel::SetSelectedVertexAsControlPoint
void SetSelectedVertexAsControlPoint(bool isControlPoint=true)
Set selected vertex as control point.
Definition: mitkContourModel.h:81
mitk::ContourModel::VertexType
ContourElement::VertexType VertexType
Definition: mitkContourModel.h:54
mitk::Point< ScalarType, 3 >
mitk::ContourModel
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
Definition: mitkContourModel.h:47
mitkCommon.h
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitk::ContourModel::Deselect
void Deselect()
Deselect vertex.
Definition: mitkContourModel.h:78
mitk::ContourModel::GetLineSegmentInterpolation
LineSegmentInterpolation GetLineSegmentInterpolation()
Get the interpolation of the line segments between control points.
Definition: mitkContourModel.h:100
mitk::TimeStepType
std::size_t TimeStepType
Definition: mitkTimeGeometry.h:27
mitkCloneMacro
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:154
mitk::ContourElement::ConstVertexIterator
VertexListType::const_iterator ConstVertexIterator
Definition: mitkContourElement.h:67
mitkBaseData.h
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::ContourModel::ConstVertexIterator
ContourElement::ConstVertexIterator ConstVertexIterator
Definition: mitkContourModel.h:60
MITKCONTOURMODEL_EXPORT
#define MITKCONTOURMODEL_EXPORT
Definition: MitkContourModelExports.h:15
mitk::ContourElement::VertexSizeType
VertexListType::size_type VertexSizeType
Definition: mitkContourElement.h:68
mitk::ContourModel::m_UpdateBoundingBox
bool m_UpdateBoundingBox
Definition: mitkContourModel.h:478
mitk::ContourModel::VertexIterator
ContourElement::VertexIterator VertexIterator
Definition: mitkContourModel.h:59
mitk::ContourModel::SetLineSegmentInterpolation
void SetLineSegmentInterpolation(LineSegmentInterpolation interpolation)
Set the interpolation of the line segments between control points.
Definition: mitkContourModel.h:92
mitk::itkEventMacroDeclaration
itkEventMacroDeclaration(BoundingShapeInteractionEvent, itk::AnyEvent)
mitk::ContourModel::LineSegmentInterpolation
LineSegmentInterpolation
Possible interpolation of the line segments between control points.
Definition: mitkContourModel.h:65
mitk::ContourModel::m_ContourSeries
ContourModelSeries m_ContourSeries
Definition: mitkContourModel.h:469