Medical Imaging Interaction Toolkit  2025.12.02
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 {
72  {
73  public:
75 
76  itkFactorylessNewMacro(Self);
77 
78  itkCloneMacro(Self);
79 
82 
83  static const unsigned int PointDimension = 3;
84  static const unsigned int MaxTopologicalDimension = 3;
85 
90  {
91  unsigned int id; // to give the point a special ID
92  bool selected; // information about if the point is selected
93  mitk::PointSpecificationType pointSpec; // specifies the type of the point
94 
95  bool operator==(const PointDataType &other) const;
96  };
97 
104  typedef std::vector<unsigned int> SelectedLinesType;
105  typedef SelectedLinesType::iterator SelectedLinesIter;
107  {
108  // used to set the whole cell on selected
109  bool selected;
110 
111  // indexes of selected lines. 0 is between pointId 0 and 1
113 
114  // is the polygon already finished and closed
115  bool closed;
116  };
117 
118  typedef itk::DefaultDynamicMeshTraits<PointDataType,
119  PointDimension,
120  MaxTopologicalDimension,
123  CellDataType>
125  typedef itk::Mesh<PointDataType, PointDimension, MeshTraits> MeshType;
126 
129  typedef DataType::PointIdentifier PointIdentifier;
130  typedef DataType::PointsContainer PointsContainer;
131  typedef DataType::PointsContainerIterator PointsIterator;
132  typedef DataType::PointsContainer::ConstIterator PointsConstIterator;
133  typedef DataType::PointDataContainer PointDataContainer;
134  typedef DataType::PointDataContainerIterator PointDataIterator;
135  typedef DataType::PointDataContainerIterator PointDataConstIterator;
136 
137  void Expand(unsigned int timeSteps) override;
138 
140  void ExecuteOperation(Operation *operation) override;
141 
143  virtual int GetSize(unsigned int t = 0) const;
144 
145  virtual unsigned int GetPointSetSeriesSize() const;
146 
148  virtual DataType::Pointer GetPointSet(int t = 0) const;
149 
150  PointsIterator Begin(int t = 0);
151 
152  PointsConstIterator Begin(int t = 0) const;
153 
154  PointsIterator End(int t = 0);
155 
156  PointsConstIterator End(int t = 0) const;
157 
162 
168  PointType GetPoint(PointIdentifier id, int t = 0) const;
169 
176  bool GetPointIfExists(PointIdentifier id, PointType *point, int t = 0) const;
177 
181  void SetPoint(PointIdentifier id, PointType point, int t = 0);
182 
186  void SetPoint(PointIdentifier id, PointType point, PointSpecificationType spec, int t = 0);
187 
191  void InsertPoint(PointIdentifier id, PointType point, int t = 0);
192 
197 
202 
207 
212 
218  bool SwapPointPosition(PointIdentifier id, bool moveUpwards, int t = 0);
219 
224  virtual int SearchSelectedPoint(int t = 0) const;
225 
229  virtual void ClearSelection();
230 
232  virtual bool IndexExists(int position, int t = 0) const;
233 
237  virtual bool GetSelectInfo(int position, int t = 0) const;
238 
239  virtual void SetSelectInfo(int position, bool selected, int t = 0);
240 
242  virtual PointSpecificationType GetSpecificationTypeInfo(int position, int t) const;
243 
245  virtual int GetNumberOfSelected(int t = 0) const;
246 
256  int SearchPoint(Point3D point, ScalarType distance, int t = 0) const;
257 
258  bool IsEmptyTimeStep(unsigned int t) const override;
259 
260  // virtual methods, that need to be implemented
261  void UpdateOutputInformation() override;
264  bool VerifyRequestedRegion() override;
265  void SetRequestedRegion(const itk::DataObject *data) override;
266 
267  // Method for subclasses
268  virtual void OnPointSetChange(){};
269 
270  protected:
272 
274  PointSet(const PointSet &other);
275  ~PointSet() override;
276 
277  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
278 
279  void ClearData() override;
280 
281  void InitializeEmpty() override;
282 
285 
286  typedef std::vector<DataType::Pointer> PointSetSeries;
287 
289 
290  DataType::PointsContainer::Pointer m_EmptyPointsContainer;
291 
296  };
297 
316  DEPRECATED(MITKCORE_EXPORT bool Equal(const mitk::PointSet *leftHandSide,
317  const mitk::PointSet *rightHandSide,
319  bool verbose,
320  bool checkGeometry = true));
321 
338  MITKCORE_EXPORT bool Equal(const mitk::PointSet &leftHandSide,
339  const mitk::PointSet &rightHandSide,
341  bool verbose,
342  bool checkGeometry = true);
343 
344  itkEventMacroDeclaration(PointSetEvent, itk::AnyEvent);
345  itkEventMacroDeclaration(PointSetMoveEvent, PointSetEvent);
346  itkEventMacroDeclaration(PointSetSizeChangeEvent, PointSetEvent);
347  itkEventMacroDeclaration(PointSetAddEvent, PointSetSizeChangeEvent);
348  itkEventMacroDeclaration(PointSetRemoveEvent, PointSetSizeChangeEvent);
349  itkEventMacroDeclaration(PointSetExtendTimeRangeEvent, PointSetEvent);
350 
351 } // namespace mitk
352 
353 #endif
#define MITKCORE_EXPORT
Base of all data objects.
Definition: mitkBaseData.h:44
Base class of all Operation-classes.
Definition: mitkOperation.h:30
Data structure which stores a set of points.
Definition: mitkPointSet.h:72
void UpdateOutputInformation() override
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Determine whether the RequestedRegion is outside of the BufferedRegion.
bool SwapPointPosition(PointIdentifier id, bool moveUpwards, int t=0)
Swap a point at the given position (id) with the upper point (moveUpwards=true) or with the lower poi...
itk::Mesh< PointDataType, PointDimension, MeshTraits > MeshType
Definition: mitkPointSet.h:125
PointType GetPoint(PointIdentifier id, int t=0) const
Get the point with ID id in world coordinates.
bool m_CalculateBoundingBox
flag to indicate the right time to call SetBounds
Definition: mitkPointSet.h:295
virtual void SetSelectInfo(int position, bool selected, int t=0)
virtual int SearchSelectedPoint(int t=0) const
searches a selected point and returns the id of that point. If no point is found, then -1 is returned
PointsConstIterator Begin(int t=0) const
PointsConstIterator End(int t=0) const
Point3D PointType
Definition: mitkPointSet.h:128
DataType::PointDataContainer PointDataContainer
Definition: mitkPointSet.h:133
PointSetSeries m_PointSetSeries
Definition: mitkPointSet.h:288
DataType::PointsContainer::Pointer m_EmptyPointsContainer
Definition: mitkPointSet.h:290
void PrintSelf(std::ostream &os, itk::Indent indent) const override
print content of the object to os
DataType::PointsContainer::ConstIterator PointsConstIterator
Definition: mitkPointSet.h:132
void Expand(unsigned int timeSteps) override
Expands the TimeGeometry to a number of TimeSteps.
PointSet(const PointSet &other)
DataType::PointDataContainerIterator PointDataIterator
Definition: mitkPointSet.h:134
itk::DefaultDynamicMeshTraits< PointDataType, PointDimension, MaxTopologicalDimension, CoordinateType, InterpolationWeightType, CellDataType > MeshTraits
Definition: mitkPointSet.h:124
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()
Definition: mitkPointSet.h:268
void SetRequestedRegion(const itk::DataObject *data) override
Set the requested region from this data object to match the requested region of the data object passe...
DataType::PointIdentifier PointIdentifier
Definition: mitkPointSet.h:129
mitk::ScalarType InterpolationWeightType
Definition: mitkPointSet.h:81
std::vector< unsigned int > SelectedLinesType
cellDataType, that stores all indexes of the lines, that are selected e.g.: points A,...
Definition: mitkPointSet.h:104
virtual bool IndexExists(int position, int t=0) const
returns true if a point exists at this position
virtual int GetNumberOfSelected(int t=0) const
returns the number of selected points
std::vector< DataType::Pointer > PointSetSeries
Definition: mitkPointSet.h:286
bool IsEmptyTimeStep(unsigned int t) const override
Check whether object contains data (at a specified time), e.g., a set of points may be empty.
virtual void ClearSelection()
Deselect all points in all time steps.
PointsIterator RemovePointAtEnd(int t=0)
Remove max id point at timestep t and return iterator to precedent point.
DataType::PointDataContainerIterator PointDataConstIterator
Definition: mitkPointSet.h:135
virtual int GetSize(unsigned int t=0) const
returns the current size of the point-list
PointsIterator End(int t=0)
void ClearData() override
reset to non-initialized state, release memory
bool RemovePointIfExists(PointIdentifier id, int t=0)
Remove point with given id at timestep t, if existent.
void SetRequestedRegionToLargestPossibleRegion() override
Set the RequestedRegion to the LargestPossibleRegion.
DataType::PointsContainerIterator PointsIterator
Definition: mitkPointSet.h:131
bool VerifyRequestedRegion() override
Verify that the RequestedRegion is within the LargestPossibleRegion.
mitkCloneMacro(Self)
void SetPoint(PointIdentifier id, PointType point, PointSpecificationType spec, int t=0)
Set the given point in world coordinate system with the given PointSpecificationType.
PointIdentifier InsertPoint(PointType point, int t=0)
Insert the given point in world coordinate system with incremented max id at time step t.
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
searches a point in the list == point +/- distance
virtual unsigned int GetPointSetSeriesSize() const
virtual PointSpecificationType GetSpecificationTypeInfo(int position, int t) const
to get the type of the point at the position and the moment
void SetPoint(PointIdentifier id, PointType point, int t=0)
Set the given point in world coordinate system into the itkPointSet.
void InsertPoint(PointIdentifier id, PointType point, PointSpecificationType spec, int t)
Set the given point in world coordinate system with given PointSpecificationType.
~PointSet() override
PointsIterator GetMaxId(int t=0)
Get an iterator to the max ID element if existent. Return End() otherwise.
mitk::ScalarType CoordinateType
Definition: mitkPointSet.h:78
virtual DataType::Pointer GetPointSet(int t=0) const
returns the pointset
MeshType DataType
Definition: mitkPointSet.h:127
DataType::PointsContainer PointsContainer
Definition: mitkPointSet.h:130
void InsertPoint(PointIdentifier id, PointType point, int t=0)
Set the given point in world coordinate system into the itkPointSet.
bool GetPointIfExists(PointIdentifier id, PointType *point, int t=0) const
Get the point with ID id in world coordinates.
mitkClassMacro(PointSet, BaseData)
PointsIterator Begin(int t=0)
void ExecuteOperation(Operation *operation) override
executes the given Operation
SelectedLinesType::iterator SelectedLinesIter
Definition: mitkPointSet.h:105
virtual bool GetSelectInfo(int position, int t=0) const
to get the state selected/unselected of the point on the position
#define DEPRECATED(func)
Definition: mitkCommon.h:175
Find image slices visible on a given plane.
MITKCORE_EXPORT const ScalarType eps
PointSpecificationType
enumeration of the type a point can be
Definition: mitkPoint.h:29
double ScalarType
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)
SelectedLinesType selectedLines
Definition: mitkPointSet.h:112
struct for data of a point
Definition: mitkPointSet.h:90
mitk::PointSpecificationType pointSpec
Definition: mitkPointSet.h:93
bool operator==(const PointDataType &other) const