Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef _MITK_POINT_LOCATOR__H__
18 #define _MITK_POINT_LOCATOR__H__
19 
21 #include <itkObject.h>
22 
23 #include "mitkPointSet.h"
24 
25 #include <vtkPoints.h>
26 
27 // forward declarations
28 class vtkPointSet;
29 class ANNkd_tree;
30 
31 namespace mitk
32 {
43  class MITKALGORITHMSEXT_EXPORT PointLocator : public itk::Object
44  {
45  public:
47 
48  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
49 
50  typedef int IdType;
52 
53  typedef float PixelType;
54  typedef double CoordRepType;
55  typedef itk::DefaultStaticMeshTraits<PixelType, 3, 2, CoordRepType, CoordRepType, PixelType> MeshTraits;
56  typedef itk::PointSet<PixelType, 3, MeshTraits> ITKPointSet;
57 
63  void SetPoints(vtkPointSet *points);
64 
70  void SetPoints(mitk::PointSet *points);
71 
77  void SetPoints(ITKPointSet *pointSet);
78 
88  IdType FindClosestPoint(const double point[3]);
89 
101  IdType FindClosestPoint(double x, double y, double z);
102 
112  IdType FindClosestPoint(mitk::PointSet::PointType point);
113 
123  DistanceType GetMinimalDistance(mitk::PointSet::PointType point);
124 
135  bool FindClosestPointAndDistance(mitk::PointSet::PointType point, IdType *id, DistanceType *dist);
136 
137  protected:
138  //
139  // Definition of a vector of ids
140  //
141  typedef std::vector<IdType> IdVectorType;
142 
143  //
144  // ANN related typedefs, to prevent ANN from being in the global include path.
145  // Please note, that these line are prone to failure, if the point type in
146  // ANN changes. Please note also, that these typedefs are only used in the header
147  // file. The implementation always refers to the original types
148  //
149  typedef double *MyANNpoint;
150  typedef int MyANNidx;
151  typedef double MyANNdist;
152  typedef MyANNpoint *MyANNpointArray;
153  typedef MyANNidx *MyANNidxArray;
154  typedef MyANNdist *MyANNdistArray;
155 
159  PointLocator();
160 
164  ~PointLocator();
165 
169  void InitANN();
170 
174  void DestroyANN();
175 
185  IdType FindClosestANNPoint(const MyANNpoint &point);
186 
196  DistanceType GetMinimalDistance(const MyANNpoint &point);
197 
198  bool m_SearchTreeInitialized;
199 
200  IdVectorType m_IndexToPointIdContainer;
201 
202  vtkPoints *m_VtkPoints;
203  mitk::PointSet *m_MitkPoints;
204  ITKPointSet *m_ItkPoints;
205 
206  //
207  // ANN related variables
208  //
209  unsigned int m_ANNK;
210  unsigned int m_ANNDimension;
211  double m_ANNEpsilon;
212  MyANNpointArray m_ANNDataPoints;
213  MyANNpoint m_ANNQueryPoint;
214  MyANNidxArray m_ANNPointIndexes;
215  MyANNdistArray m_ANNDistances;
216  ANNkd_tree *m_ANNTree;
217  };
218 }
219 
220 #endif
MyANNdist * MyANNdistArray
double ScalarType
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< IdType > IdVectorType
#define MITKALGORITHMSEXT_EXPORT
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:79
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
MyANNpoint * MyANNpointArray
itk::PointSet< PixelType, 3, MeshTraits > ITKPointSet
itk::DefaultStaticMeshTraits< PixelType, 3, 2, CoordRepType, CoordRepType, PixelType > MeshTraits