Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::PointLocator Class Reference

Convenience wrapper around ANN (Approximate Nearest Neighbours) for fast nearest-neighbour point searches. More...

#include <mitkPointLocator.h>

Inheritance diagram for mitk::PointLocator:
Collaboration diagram for mitk::PointLocator:

Public Types

typedef int IdType
 
typedef ScalarType DistanceType
 
typedef float PixelType
 
typedef double CoordRepType
 
typedef itk::DefaultStaticMeshTraits< PixelType, 3, 2, CoordRepType, CoordRepType, PixelType > MeshTraits
 
typedef itk::PointSet< PixelType, 3, MeshTraits > ITKPointSet
 

Public Member Functions

 mitkClassMacroItkParent (PointLocator, itk::Object)
 
Pointer Clone () const
 
void SetPoints (vtkPointSet *points)
 
void SetPoints (mitk::PointSet *points)
 
void SetPoints (ITKPointSet *pointSet)
 
IdType FindClosestPoint (const double point[3])
 
IdType FindClosestPoint (double x, double y, double z)
 
IdType FindClosestPoint (mitk::PointSet::PointType point)
 
DistanceType GetMinimalDistance (mitk::PointSet::PointType point)
 
bool FindClosestPointAndDistance (mitk::PointSet::PointType point, IdType *id, DistanceType *dist)
 

Static Public Member Functions

static Pointer New ()
 

Protected Types

typedef std::vector< IdType > IdVectorType
 
typedef double * MyANNpoint
 
typedef int MyANNidx
 
typedef double MyANNdist
 
typedef MyANNpoint * MyANNpointArray
 
typedef MyANNidx * MyANNidxArray
 
typedef MyANNdist * MyANNdistArray
 

Protected Member Functions

 PointLocator ()
 
 ~PointLocator () override
 
void InitANN ()
 
void DestroyANN ()
 
IdType FindClosestANNPoint (const MyANNpoint &point)
 
DistanceType GetMinimalDistance (const MyANNpoint &point)
 

Protected Attributes

bool m_SearchTreeInitialized
 
IdVectorType m_IndexToPointIdContainer
 
vtkPoints * m_VtkPoints
 
mitk::PointSet * m_MitkPoints
 
ITKPointSet * m_ItkPoints
 
unsigned int m_ANNK
 
unsigned int m_ANNDimension
 
double m_ANNEpsilon
 
MyANNpointArray m_ANNDataPoints
 
MyANNpoint m_ANNQueryPoint
 
MyANNidxArray m_ANNPointIndexes
 
MyANNdistArray m_ANNDistances
 
ANNkd_tree * m_ANNTree
 

Detailed Description

Convenience wrapper around ANN (Approximate Nearest Neighbours) for fast nearest-neighbour point searches.

Usage:

  1. Set the point set via SetPoints(vtkPointSet*), SetPoints(mitk::PointSet*), or SetPoints(ITKPointSet*).
  2. Query the closest point to an arbitrary coordinate via FindClosestPoint().

No additional Update() call is needed – the internal kd-tree is built automatically when the points are set.

Currently only single nearest-neighbour queries are supported.

Precondition
At least 1 point must be contained in the point set.
See also
mitk::PointSet

Definition at line 47 of file mitkPointLocator.h.

Member Typedef Documentation

◆ CoordRepType

Definition at line 60 of file mitkPointLocator.h.

◆ DistanceType

◆ IdType

Definition at line 56 of file mitkPointLocator.h.

◆ IdVectorType

typedef std::vector<IdType> mitk::PointLocator::IdVectorType
protected

Definition at line 149 of file mitkPointLocator.h.

◆ ITKPointSet

Definition at line 62 of file mitkPointLocator.h.

◆ MeshTraits

typedef itk::DefaultStaticMeshTraits<PixelType, 3, 2, CoordRepType, CoordRepType, PixelType> mitk::PointLocator::MeshTraits

Definition at line 61 of file mitkPointLocator.h.

◆ MyANNdist

typedef double mitk::PointLocator::MyANNdist
protected

Definition at line 159 of file mitkPointLocator.h.

◆ MyANNdistArray

Definition at line 162 of file mitkPointLocator.h.

◆ MyANNidx

typedef int mitk::PointLocator::MyANNidx
protected

Definition at line 158 of file mitkPointLocator.h.

◆ MyANNidxArray

Definition at line 161 of file mitkPointLocator.h.

◆ MyANNpoint

typedef double* mitk::PointLocator::MyANNpoint
protected

Definition at line 157 of file mitkPointLocator.h.

◆ MyANNpointArray

Definition at line 160 of file mitkPointLocator.h.

◆ PixelType

Definition at line 59 of file mitkPointLocator.h.

Constructor & Destructor Documentation

◆ PointLocator()

mitk::PointLocator::PointLocator ( )
protected

constructor

◆ ~PointLocator()

mitk::PointLocator::~PointLocator ( )
overrideprotected

destructor

Member Function Documentation

◆ Clone()

Pointer mitk::PointLocator::Clone ( ) const

◆ DestroyANN()

void mitk::PointLocator::DestroyANN ( )
protected

releases all memory occupied by the ann search tree and internal point set arrays

◆ FindClosestANNPoint()

IdType mitk::PointLocator::FindClosestANNPoint ( const MyANNpoint &  point)
protected

Finds the nearest neighbour in the point set previously defined by SetPoints(). The Id of the point is returned. Please note, that there is no case, in which no point is found, since as a precondition at least one point has to be contained in the point set.

Parameters
pointthe query point, for whom the nearest neighbour will be determined
Returns
the id of the nearest neighbour of the given point. The id corresponds to the id which is given in the original point set.

◆ FindClosestPoint() [1/3]

IdType mitk::PointLocator::FindClosestPoint ( const double  point[3])

Finds the nearest neighbour in the point set previously defined by SetPoints(). The Id of the point is returned. Please note, that there is no case, in which no point is found, since as a precondition at least one point has to be contained in the point set.

Parameters
pointthe query point, for whom the nearest neighbour will be determined
Returns
the id of the nearest neighbour of the given point. The id corresponds to the id which is given in the original point set.

◆ FindClosestPoint() [2/3]

IdType mitk::PointLocator::FindClosestPoint ( double  x,
double  y,
double  z 
)

Finds the nearest neighbour in the point set previously defined by SetPoints(). The Id of the point is returned. Please note, that there is no case, in which no point is found, since as a precondition at least one point has to be contained in the point set.

Parameters
xthe x coordinated of the query point, for whom the nearest neighbour will be determined
ythe x coordinated of the query point, for whom the nearest neighbour will be determined
zthe x coordinated of the query point, for whom the nearest neighbour will be determined
Returns
the id of the nearest neighbour of the given point. The id corresponds to the id which is given in the original point set.

◆ FindClosestPoint() [3/3]

IdType mitk::PointLocator::FindClosestPoint ( mitk::PointSet::PointType  point)

Finds the nearest neighbour in the point set previously defined by SetPoints(). The Id of the point is returned. Please note, that there is no case, in which no point is found, since as a precondition at least one point has to be contained in the point set.

Parameters
pointthe query point, for whom the nearest neighbour will be determined
Returns
the id of the nearest neighbour of the given point. The id corresponds to the id which is given in the original point set.

◆ FindClosestPointAndDistance()

bool mitk::PointLocator::FindClosestPointAndDistance ( mitk::PointSet::PointType  point,
IdType *  id,
DistanceType *  dist 
)

Finds the nearest neighbour in the point set previously defined by SetPoints(). The Index and minimal distance between this point and the closest point of the point set is returned. Please note, that there is no case, in which no point is found, since as a precondition at least one point has to be contained in the point set.

Parameters
pointthe query point, for whom the minimal distance will be determined
id
dist
Returns
the index of and distance (in world coordinates) between the nearest point in point set and the given point

◆ GetMinimalDistance() [1/2]

DistanceType mitk::PointLocator::GetMinimalDistance ( const MyANNpoint &  point)
protected

Finds the minimal distance between the given point and a point in the previously defined point set. The distance is returned. Please note, that there is no case, in which no distance is found, since as a precondition at least one point has to be contained in the point set.

Parameters
pointthe query point, for whom the minimal distance to a point in the previously defined point set will be determined
Returns
the squared distance in world coordinates between the given point and the nearest neighbour.

◆ GetMinimalDistance() [2/2]

DistanceType mitk::PointLocator::GetMinimalDistance ( mitk::PointSet::PointType  point)

Finds the nearest neighbour in the point set previously defined by SetPoints(). The minimal distance between this point and the closest point of the point set is returned. Please note, that there is no case, in which no point is found, since as a precondition at least one point has to be contained in the point set.

Parameters
pointthe query point, for whom the minimal distance will be determined
Returns
the distance in world coordinates between the nearest point in point set and the given point

◆ InitANN()

void mitk::PointLocator::InitANN ( )
protected

Initializes the ann search tree using previously defined points

◆ mitkClassMacroItkParent()

mitk::PointLocator::mitkClassMacroItkParent ( PointLocator  ,
itk::Object   
)

◆ New()

static Pointer mitk::PointLocator::New ( )
static

◆ SetPoints() [1/3]

void mitk::PointLocator::SetPoints ( ITKPointSet *  pointSet)

Sets the point which will be used for nearest-neighbour searches. Note there must be at least one point in the point set.

Parameters
pointSetthe point set containing points for nearest neighbours searches.

◆ SetPoints() [2/3]

void mitk::PointLocator::SetPoints ( mitk::PointSet *  points)

Sets the point which will be used for nearest-neighbour searches. Note there must be at least one point in the point set.

Parameters
pointsthe point set containing points for nearest neighbours searches.

◆ SetPoints() [3/3]

void mitk::PointLocator::SetPoints ( vtkPointSet *  points)

Sets the point which will be used for nearest-neighbour searches. Note there must be at least one point in the point set.

Parameters
pointsthe point set containing points for nearest neighbours searches.

Member Data Documentation

◆ m_ANNDataPoints

MyANNpointArray mitk::PointLocator::m_ANNDataPoints
protected

Definition at line 220 of file mitkPointLocator.h.

◆ m_ANNDimension

unsigned int mitk::PointLocator::m_ANNDimension
protected

Definition at line 218 of file mitkPointLocator.h.

◆ m_ANNDistances

MyANNdistArray mitk::PointLocator::m_ANNDistances
protected

Definition at line 223 of file mitkPointLocator.h.

◆ m_ANNEpsilon

double mitk::PointLocator::m_ANNEpsilon
protected

Definition at line 219 of file mitkPointLocator.h.

◆ m_ANNK

unsigned int mitk::PointLocator::m_ANNK
protected

Definition at line 217 of file mitkPointLocator.h.

◆ m_ANNPointIndexes

MyANNidxArray mitk::PointLocator::m_ANNPointIndexes
protected

Definition at line 222 of file mitkPointLocator.h.

◆ m_ANNQueryPoint

MyANNpoint mitk::PointLocator::m_ANNQueryPoint
protected

Definition at line 221 of file mitkPointLocator.h.

◆ m_ANNTree

ANNkd_tree* mitk::PointLocator::m_ANNTree
protected

Definition at line 224 of file mitkPointLocator.h.

◆ m_IndexToPointIdContainer

IdVectorType mitk::PointLocator::m_IndexToPointIdContainer
protected

Definition at line 208 of file mitkPointLocator.h.

◆ m_ItkPoints

ITKPointSet* mitk::PointLocator::m_ItkPoints
protected

Definition at line 212 of file mitkPointLocator.h.

◆ m_MitkPoints

mitk::PointSet* mitk::PointLocator::m_MitkPoints
protected

Definition at line 211 of file mitkPointLocator.h.

◆ m_SearchTreeInitialized

bool mitk::PointLocator::m_SearchTreeInitialized
protected

Definition at line 206 of file mitkPointLocator.h.

◆ m_VtkPoints

vtkPoints* mitk::PointLocator::m_VtkPoints
protected

Definition at line 210 of file mitkPointLocator.h.


The documentation for this class was generated from the following file: