Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkPointSet.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 
13 #ifndef mitkPointSet_h
14 #define mitkPointSet_h
15 
16 #include <mitkBaseData.h>
17 
18 #include <itkDefaultDynamicMeshTraits.h>
19 #include <itkMesh.h>
20 
21 namespace mitk
22 {
71  {
72  public:
74 
75  itkFactorylessNewMacro(Self);
76 
77  itkCloneMacro(Self);
78 
81 
84 
86  static const unsigned int PointDimension = 3;
87 
89  static const unsigned int MaxTopologicalDimension = 3;
90 
98  {
99  unsigned int id;
100  bool selected;
108  bool operator==(const PointDataType &other) const;
109  };
110 
117  typedef std::vector<unsigned int> SelectedLinesType;
118 
120  typedef SelectedLinesType::iterator SelectedLinesIter;
121 
126  {
127  bool selected;
129  bool closed;
130  };
131 
132  typedef itk::DefaultDynamicMeshTraits<PointDataType,
133  PointDimension,
134  MaxTopologicalDimension,
137  CellDataType>
139  typedef itk::Mesh<PointDataType, PointDimension, MeshTraits> MeshType;
140 
143  typedef DataType::PointIdentifier PointIdentifier;
144  typedef DataType::PointsContainer PointsContainer;
145  typedef DataType::PointsContainerIterator PointsIterator;
146  typedef DataType::PointsContainer::ConstIterator PointsConstIterator;
147  typedef DataType::PointDataContainer PointDataContainer;
148  typedef DataType::PointDataContainerIterator PointDataIterator;
149  typedef DataType::PointDataContainerIterator PointDataConstIterator;
150 
158  void Expand(unsigned int timeSteps) override;
159 
169  void ExecuteOperation(Operation *operation) override;
170 
177  virtual int GetSize(unsigned int t = 0) const;
178 
184  virtual unsigned int GetPointSetSeriesSize() const;
185 
192  virtual DataType::Pointer GetPointSet(int t = 0) const;
193 
201  PointsIterator Begin(int t = 0);
202 
204  PointsConstIterator Begin(int t = 0) const;
205 
212  PointsIterator End(int t = 0);
213 
215  PointsConstIterator End(int t = 0) const;
216 
225 
235  PointType GetPoint(PointIdentifier id, int t = 0) const;
236 
248  bool GetPointIfExists(PointIdentifier id, PointType *point, int t = 0) const;
249 
260  void SetPoint(PointIdentifier id, PointType point, int t = 0);
261 
270  void SetPoint(PointIdentifier id, PointType point, PointSpecificationType spec, int t = 0);
271 
282  void InsertPoint(PointIdentifier id, PointType point, int t = 0);
283 
298 
307 
316 
324 
337  bool SwapPointPosition(PointIdentifier id, bool moveUpwards, int t = 0);
338 
345  virtual int SearchSelectedPoint(int t = 0) const;
346 
350  virtual void ClearSelection();
351 
359  virtual bool IndexExists(int position, int t = 0) const;
360 
368  virtual bool GetSelectInfo(int position, int t = 0) const;
369 
377  virtual void SetSelectInfo(int position, bool selected, int t = 0);
378 
386  virtual PointSpecificationType GetSpecificationTypeInfo(int position, int t) const;
387 
394  virtual int GetNumberOfSelected(int t = 0) const;
395 
405  int SearchPoint(Point3D point, ScalarType distance, int t = 0) const;
406 
413  bool IsEmptyTimeStep(unsigned int t) const override;
414 
418  void UpdateOutputInformation() override;
419 
424 
431 
437  bool VerifyRequestedRegion() override;
438 
444  void SetRequestedRegion(const itk::DataObject *data) override;
445 
451  virtual void OnPointSetChange(){};
452 
453  protected:
455 
457  PointSet(const PointSet &other);
458  ~PointSet() override;
459 
460  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
461 
462  void ClearData() override;
463 
464  void InitializeEmpty() override;
465 
468 
469  typedef std::vector<DataType::Pointer> PointSetSeries;
470 
472 
473  DataType::PointsContainer::Pointer m_EmptyPointsContainer;
474 
479  };
480 
497  MITKCORE_EXPORT bool Equal(const mitk::PointSet &leftHandSide,
498  const mitk::PointSet &rightHandSide,
500  bool verbose,
501  bool checkGeometry = true);
502 
503  itkEventMacroDeclaration(PointSetEvent, itk::AnyEvent);
504  itkEventMacroDeclaration(PointSetMoveEvent, PointSetEvent);
505  itkEventMacroDeclaration(PointSetSizeChangeEvent, PointSetEvent);
506  itkEventMacroDeclaration(PointSetAddEvent, PointSetSizeChangeEvent);
507  itkEventMacroDeclaration(PointSetRemoveEvent, PointSetSizeChangeEvent);
508  itkEventMacroDeclaration(PointSetExtendTimeRangeEvent, PointSetEvent);
509 
510 } // namespace mitk
511 
512 #endif
#define MITKCORE_EXPORT
Base class of all data objects.
Definition: mitkBaseData.h:60
Base class for all operations in the undo/redo framework.
Definition: mitkOperation.h:38
Data structure which stores a set of points.
Definition: mitkPointSet.h:71
void UpdateOutputInformation() override
Update the output information (bounding box, geometry).
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Check whether the requested region is outside the buffered region.
bool SwapPointPosition(PointIdentifier id, bool moveUpwards, int t=0)
Swap a point with its neighbor in the ordered container.
itk::Mesh< PointDataType, PointDimension, MeshTraits > MeshType
Definition: mitkPointSet.h:139
PointType GetPoint(PointIdentifier id, int t=0) const
Get the point with the given ID in world coordinates.
bool m_CalculateBoundingBox
flag to indicate the right time to call SetBounds
Definition: mitkPointSet.h:478
virtual void SetSelectInfo(int position, bool selected, int t=0)
Set the selection state of the point at the given position.
virtual int SearchSelectedPoint(int t=0) const
Search for a selected point and return its ID.
PointsConstIterator Begin(int t=0) const
Get an iterator pointing to the first point at time step t.
PointsConstIterator End(int t=0) const
Get an iterator pointing past the last point at time step t.
Point3D PointType
Definition: mitkPointSet.h:142
DataType::PointDataContainer PointDataContainer
Definition: mitkPointSet.h:147
PointSetSeries m_PointSetSeries
Definition: mitkPointSet.h:471
DataType::PointsContainer::Pointer m_EmptyPointsContainer
Definition: mitkPointSet.h:473
void PrintSelf(std::ostream &os, itk::Indent indent) const override
print content of the object to os
DataType::PointsContainer::ConstIterator PointsConstIterator
Definition: mitkPointSet.h:146
void Expand(unsigned int timeSteps) override
Expand the PointSet to the given number of time steps.
PointSet(const PointSet &other)
DataType::PointDataContainerIterator PointDataIterator
Definition: mitkPointSet.h:148
itk::DefaultDynamicMeshTraits< PointDataType, PointDimension, MaxTopologicalDimension, CoordinateType, InterpolationWeightType, CellDataType > MeshTraits
Definition: mitkPointSet.h:138
void InitializeEmpty() override
Pure virtual; Must be used in subclasses to get a data object to a valid state. Should at least creat...
virtual void OnPointSetChange()
Hook method called when the point set content changes.
Definition: mitkPointSet.h:451
void SetRequestedRegion(const itk::DataObject *data) override
Set the requested region from another data object (no-op for PointSet).
DataType::PointIdentifier PointIdentifier
Definition: mitkPointSet.h:143
mitk::ScalarType InterpolationWeightType
Scalar type for interpolation weights.
Definition: mitkPointSet.h:83
std::vector< unsigned int > SelectedLinesType
Type for storing indices of selected lines between points.
Definition: mitkPointSet.h:117
virtual bool IndexExists(int position, int t=0) const
Check whether a point exists at the given position (index).
virtual int GetNumberOfSelected(int t=0) const
Get the number of selected points at time step t.
std::vector< DataType::Pointer > PointSetSeries
Definition: mitkPointSet.h:469
bool IsEmptyTimeStep(unsigned int t) const override
Check whether the point set is empty at time step t.
virtual void ClearSelection()
Deselect all points in all time steps.
PointsIterator RemovePointAtEnd(int t=0)
Remove the point with the maximum ID at time step t.
DataType::PointDataContainerIterator PointDataConstIterator
Definition: mitkPointSet.h:149
virtual int GetSize(unsigned int t=0) const
Get the number of points at time step t.
PointsIterator End(int t=0)
Get an iterator pointing past the last point at time step t.
void ClearData() override
reset to non-initialized state, release memory
bool RemovePointIfExists(PointIdentifier id, int t=0)
Remove the point with the given ID at time step t, if it exists.
void SetRequestedRegionToLargestPossibleRegion() override
Set the requested region to the largest possible region (no-op for PointSet).
DataType::PointsContainerIterator PointsIterator
Definition: mitkPointSet.h:145
bool VerifyRequestedRegion() override
Verify that the requested region is valid.
mitkCloneMacro(Self)
void SetPoint(PointIdentifier id, PointType point, PointSpecificationType spec, int t=0)
Set (overwrite) the point with the given ID and PointSpecificationType.
PointIdentifier InsertPoint(PointType point, int t=0)
Insert a point with an automatically assigned ID (max ID + 1).
bool SwapPointContents(PointIdentifier id1, PointIdentifier id2, int t=0)
swaps point coordinates and point data of the points with identifiers id1 and id2
int SearchPoint(Point3D point, ScalarType distance, int t=0) const
Search for the closest point within a given distance.
virtual unsigned int GetPointSetSeriesSize() const
Get the number of time steps in the point set series.
virtual PointSpecificationType GetSpecificationTypeInfo(int position, int t) const
Get the PointSpecificationType of the point at the given position.
void SetPoint(PointIdentifier id, PointType point, int t=0)
Set (overwrite) the point with the given ID in world coordinates.
void InsertPoint(PointIdentifier id, PointType point, PointSpecificationType spec, int t)
Insert a point with the given ID, world coordinates, and PointSpecificationType.
~PointSet() override
PointsIterator GetMaxId(int t=0)
Get an iterator to the element with the maximum ID at time step t.
mitk::ScalarType CoordinateType
Scalar type for point coordinates.
Definition: mitkPointSet.h:77
virtual DataType::Pointer GetPointSet(int t=0) const
Get the underlying itk::Mesh at time step t.
MeshType DataType
Definition: mitkPointSet.h:141
DataType::PointsContainer PointsContainer
Definition: mitkPointSet.h:144
void InsertPoint(PointIdentifier id, PointType point, int t=0)
Insert a point with the given ID in world coordinates.
bool GetPointIfExists(PointIdentifier id, PointType *point, int t=0) const
Get the point with the given ID if it exists.
mitkClassMacro(PointSet, BaseData)
PointsIterator Begin(int t=0)
Get an iterator pointing to the first point at time step t.
void ExecuteOperation(Operation *operation) override
Execute an operation on this PointSet.
SelectedLinesType::iterator SelectedLinesIter
Iterator for SelectedLinesType.
Definition: mitkPointSet.h:120
virtual bool GetSelectInfo(int position, int t=0) const
Get the selection state of the point at the given position.
Find image slices visible on a given plane.
MITKCORE_EXPORT const ScalarType eps
Epsilon value for floating point comparison (vnl_math::eps * 100).
PointSpecificationType
Enumeration of point specification types.
Definition: mitkPoint.h:31
double ScalarType
Scalar type used throughout MITK for geometric computations.
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
itkEventMacroDeclaration(BoundingShapeInteractionEvent, itk::AnyEvent)
Data associated with a cell in the mesh.
Definition: mitkPointSet.h:126
SelectedLinesType selectedLines
Indices of selected lines within the cell.
Definition: mitkPointSet.h:128
bool selected
Whether the entire cell is selected.
Definition: mitkPointSet.h:127
bool closed
Whether the polygon is finished and closed.
Definition: mitkPointSet.h:129
Data associated with each point in the PointSet.
Definition: mitkPointSet.h:98
unsigned int id
Unique identifier for this point.
Definition: mitkPointSet.h:99
mitk::PointSpecificationType pointSpec
Type specification of the point.
Definition: mitkPointSet.h:101
bool selected
Whether the point is selected.
Definition: mitkPointSet.h:100
bool operator==(const PointDataType &other) const
Equality comparison operator.