Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkPointLocator.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 _MITK_POINT_LOCATOR__H__
14 #define _MITK_POINT_LOCATOR__H__
15 
17 #include <itkObject.h>
18 
19 #include "mitkPointSet.h"
20 
21 #include <vtkPoints.h>
22 
23 // forward declarations
24 class vtkPointSet;
25 class ANNkd_tree;
26 
27 namespace mitk
28 {
39  class MITKALGORITHMSEXT_EXPORT PointLocator : public itk::Object
40  {
41  public:
43 
44  itkFactorylessNewMacro(Self);
45 
46  itkCloneMacro(Self);
47 
48  typedef int IdType;
50 
51  typedef float PixelType;
52  typedef double CoordRepType;
53  typedef itk::DefaultStaticMeshTraits<PixelType, 3, 2, CoordRepType, CoordRepType, PixelType> MeshTraits;
54  typedef itk::PointSet<PixelType, 3, MeshTraits> ITKPointSet;
55 
61  void SetPoints(vtkPointSet *points);
62 
68  void SetPoints(mitk::PointSet *points);
69 
75  void SetPoints(ITKPointSet *pointSet);
76 
86  IdType FindClosestPoint(const double point[3]);
87 
99  IdType FindClosestPoint(double x, double y, double z);
100 
110  IdType FindClosestPoint(mitk::PointSet::PointType point);
111 
121  DistanceType GetMinimalDistance(mitk::PointSet::PointType point);
122 
133  bool FindClosestPointAndDistance(mitk::PointSet::PointType point, IdType *id, DistanceType *dist);
134 
135  protected:
136  //
137  // Definition of a vector of ids
138  //
139  typedef std::vector<IdType> IdVectorType;
140 
141  //
142  // ANN related typedefs, to prevent ANN from being in the global include path.
143  // Please note, that these line are prone to failure, if the point type in
144  // ANN changes. Please note also, that these typedefs are only used in the header
145  // file. The implementation always refers to the original types
146  //
147  typedef double *MyANNpoint;
148  typedef int MyANNidx;
149  typedef double MyANNdist;
150  typedef MyANNpoint *MyANNpointArray;
151  typedef MyANNidx *MyANNidxArray;
152  typedef MyANNdist *MyANNdistArray;
153 
157  PointLocator();
158 
162  ~PointLocator() override;
163 
167  void InitANN();
168 
172  void DestroyANN();
173 
183  IdType FindClosestANNPoint(const MyANNpoint &point);
184 
194  DistanceType GetMinimalDistance(const MyANNpoint &point);
195 
197 
199 
200  vtkPoints *m_VtkPoints;
202  ITKPointSet *m_ItkPoints;
203 
204  //
205  // ANN related variables
206  //
207  unsigned int m_ANNK;
208  unsigned int m_ANNDimension;
209  double m_ANNEpsilon;
210  MyANNpointArray m_ANNDataPoints;
211  MyANNpoint m_ANNQueryPoint;
212  MyANNidxArray m_ANNPointIndexes;
213  MyANNdistArray m_ANNDistances;
214  ANNkd_tree *m_ANNTree;
215  };
216 }
217 
218 #endif
unsigned int m_ANNDimension
MyANNdist * MyANNdistArray
MyANNidxArray m_ANNPointIndexes
double ScalarType
MyANNpoint m_ANNQueryPoint
ANNkd_tree * m_ANNTree
mitk::PointSet * m_MitkPoints
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< IdType > IdVectorType
ITKPointSet * m_ItkPoints
IdVectorType m_IndexToPointIdContainer
#define MITKALGORITHMSEXT_EXPORT
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:75
MyANNpointArray m_ANNDataPoints
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
MyANNpoint * MyANNpointArray
MyANNdistArray m_ANNDistances
itk::PointSet< PixelType, 3, MeshTraits > ITKPointSet
itk::DefaultStaticMeshTraits< PixelType, 3, 2, CoordRepType, CoordRepType, PixelType > MeshTraits