Medical Imaging Interaction Toolkit  2021.02.99-19049835
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_HEADER_INCLUDED
14 #define MITKPointSet_H_HEADER_INCLUDED
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
112  SelectedLinesType selectedLines;
113 
114  // is the polygon already finished and closed
115  bool closed;
116  };
117 
118  typedef itk::DefaultDynamicMeshTraits<PointDataType,
119  PointDimension,
120  MaxTopologicalDimension,
121  CoordinateType,
122  InterpolationWeightType,
123  CellDataType>
125  typedef itk::Mesh<PointDataType, PointDimension, MeshTraits> MeshType;
126 
127  typedef MeshType DataType;
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 
161  PointsIterator GetMaxId(int t = 0);
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 
196  void InsertPoint(PointIdentifier id, PointType point, PointSpecificationType spec, int t);
197 
201  PointIdentifier InsertPoint(PointType point, int t = 0);
202 
206  bool RemovePointIfExists(PointIdentifier id, int t = 0);
207 
211  PointsIterator RemovePointAtEnd(int t = 0);
212 
218  bool SwapPointPosition(PointIdentifier id, bool moveUpwards, int t = 0);
219 
224  virtual int SearchSelectedPoint(int t = 0) const;
225 
227  virtual bool IndexExists(int position, int t = 0) const;
228 
232  virtual bool GetSelectInfo(int position, int t = 0) const;
233 
234  virtual void SetSelectInfo(int position, bool selected, int t = 0);
235 
237  virtual PointSpecificationType GetSpecificationTypeInfo(int position, int t) const;
238 
240  virtual int GetNumberOfSelected(int t = 0) const;
241 
251  int SearchPoint(Point3D point, ScalarType distance, int t = 0) const;
252 
253  bool IsEmptyTimeStep(unsigned int t) const override;
254 
255  // virtual methods, that need to be implemented
256  void UpdateOutputInformation() override;
257  void SetRequestedRegionToLargestPossibleRegion() override;
258  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
259  bool VerifyRequestedRegion() override;
260  void SetRequestedRegion(const itk::DataObject *data) override;
261 
262  // Method for subclasses
263  virtual void OnPointSetChange(){};
264 
265  protected:
267 
268  PointSet();
269  PointSet(const PointSet &other);
270  ~PointSet() override;
271 
272  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
273 
274  void ClearData() override;
275 
276  void InitializeEmpty() override;
277 
279  bool SwapPointContents(PointIdentifier id1, PointIdentifier id2, int t = 0);
280 
281  typedef std::vector<DataType::Pointer> PointSetSeries;
282 
283  PointSetSeries m_PointSetSeries;
284 
285  DataType::PointsContainer::Pointer m_EmptyPointsContainer;
286 
291  };
292 
311  DEPRECATED(MITKCORE_EXPORT bool Equal(const mitk::PointSet *leftHandSide,
312  const mitk::PointSet *rightHandSide,
314  bool verbose,
315  bool checkGeometry = true));
316 
333  MITKCORE_EXPORT bool Equal(const mitk::PointSet &leftHandSide,
334  const mitk::PointSet &rightHandSide,
336  bool verbose,
337  bool checkGeometry = true);
338 
339  itkEventMacro(PointSetEvent, itk::AnyEvent);
340  itkEventMacro(PointSetMoveEvent, PointSetEvent);
341  itkEventMacro(PointSetSizeChangeEvent, PointSetEvent);
342  itkEventMacro(PointSetAddEvent, PointSetSizeChangeEvent);
343  itkEventMacro(PointSetRemoveEvent, PointSetSizeChangeEvent);
344  itkEventMacro(PointSetExtendTimeRangeEvent, PointSetEvent);
345 
346 } // namespace mitk
347 
348 #endif /* MITKPointSet_H_HEADER_INCLUDED */
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
MeshType DataType
Definition: mitkPointSet.h:127
DataType::PointsContainerIterator PointsIterator
Definition: mitkPointSet.h:131
MITKCORE_EXPORT const ScalarType eps
DataType::PointDataContainer PointDataContainer
Definition: mitkPointSet.h:133
#define MITKCORE_EXPORT
itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent)
Base of all data objects.
Definition: mitkBaseData.h:42
Base class of all Operation-classes.
Definition: mitkOperation.h:29
double ScalarType
bool m_CalculateBoundingBox
flag to indicate the right time to call SetBounds
Definition: mitkPointSet.h:290
mitk::ScalarType CoordinateType
Definition: mitkPointSet.h:78
DataCollection - Class to facilitate loading/accessing structured data.
struct for data of a point
Definition: mitkPointSet.h:89
virtual void OnPointSetChange()
Definition: mitkPointSet.h:263
SelectedLinesType::iterator SelectedLinesIter
Definition: mitkPointSet.h:105
mitk::PointSpecificationType pointSpec
Definition: mitkPointSet.h:93
DataType::PointsContainer::ConstIterator PointsConstIterator
Definition: mitkPointSet.h:132
PointSetSeries m_PointSetSeries
Definition: mitkPointSet.h:283
itk::Mesh< PointDataType, PointDimension, MeshTraits > MeshType
Definition: mitkPointSet.h:125
DataType::PointDataContainerIterator PointDataConstIterator
Definition: mitkPointSet.h:135
DataType::PointIdentifier PointIdentifier
Definition: mitkPointSet.h:129
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.
#define DEPRECATED(func)
Definition: mitkCommon.h:175
std::vector< unsigned int > SelectedLinesType
cellDataType, that stores all indexes of the lines, that are selected e.g.: points A...
Definition: mitkPointSet.h:104
Data structure which stores a set of points.
Definition: mitkPointSet.h:71
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
SelectedLinesType selectedLines
Definition: mitkPointSet.h:112
#define mitkCloneMacro(classname)
Definition: mitkCommon.h:154
DataType::PointsContainer PointsContainer
Definition: mitkPointSet.h:130
mitk::ScalarType InterpolationWeightType
Definition: mitkPointSet.h:81
DataType::PointsContainer::Pointer m_EmptyPointsContainer
Definition: mitkPointSet.h:285
itk::DefaultDynamicMeshTraits< PointDataType, PointDimension, MaxTopologicalDimension, CoordinateType, InterpolationWeightType, CellDataType > MeshTraits
Definition: mitkPointSet.h:124
std::vector< DataType::Pointer > PointSetSeries
Definition: mitkPointSet.h:281
DataType::PointDataContainerIterator PointDataIterator
Definition: mitkPointSet.h:134
PointSpecificationType
enumeration of the type a point can be
Definition: mitkPoint.h:26
Point3D PointType
Definition: mitkPointSet.h:128