ITK  5.4.0
Insight Toolkit
itkPointsLocator.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkPointsLocator_h
19 #define itkPointsLocator_h
20 
21 #include "itkObject.h"
22 
23 #include "itkPoint.h"
24 #include "itkIntTypes.h"
25 #include "itkKdTree.h"
26 #include "itkKdTreeGenerator.h"
27 #include "itkVectorContainer.h"
29 
30 namespace itk
31 {
32 
41 template <typename TPointsContainer = VectorContainer<IdentifierType, Point<float, 3>>>
42 class ITK_TEMPLATE_EXPORT PointsLocator : public Object
43 {
44 public:
45  ITK_DISALLOW_COPY_AND_MOVE(PointsLocator);
46 
49  using Superclass = Object;
52 
54  itkNewMacro(Self);
55 
57  itkOverrideGetNameOfClassMacro(PointsLocator);
58 
60  using PointsContainer = TPointsContainer;
63  using PointIdentifier = typename PointsContainer::ElementIdentifier;
64  using PointType = typename PointsContainer::Element;
65 
67  static constexpr unsigned int PointDimension = PointType::PointDimension;
68 
70  using PointsContainerConstIterator = typename PointsContainer::ConstIterator;
71  using PointsContainerIterator = typename PointsContainer::Iterator;
72 
76 
82  using NeighborsIdentifierType = typename TreeType::InstanceIdentifierVectorType;
83 
85  itkSetObjectMacro(Points, PointsContainer);
86 
88  itkGetModifiableObjectMacro(Points, PointsContainer);
89 
91  void
92  Initialize();
93 
96  FindClosestPoint(const PointType & query) const;
97 
99  void
100  FindClosestNPoints(const PointType &, unsigned int, NeighborsIdentifierType &) const;
101 
103  void
104  FindClosestNPoints(const PointType &, unsigned int, NeighborsIdentifierType &, std::vector<double> &) const;
105 
107  void
108  FindPointsWithinRadius(const PointType &, double, NeighborsIdentifierType &) const;
109 
110 protected:
111  PointsLocator();
112  ~PointsLocator() override = default;
113  void
114  PrintSelf(std::ostream & os, Indent indent) const override;
115 
116 private:
118  SampleAdaptorPointer m_SampleAdaptor{};
119  TreeGeneratorPointer m_KdTreeGenerator{};
121 };
122 
123 } // end namespace itk
124 
125 #ifndef ITK_MANUAL_INSTANTIATION
126 # include "itkPointsLocator.hxx"
127 #endif
128 
129 #endif
itk::PointsLocator::TreeGeneratorPointer
typename TreeGeneratorType::Pointer TreeGeneratorPointer
Definition: itkPointsLocator.h:79
itk::PointsLocator::NeighborsIdentifierType
typename TreeType::InstanceIdentifierVectorType NeighborsIdentifierType
Definition: itkPointsLocator.h:82
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::Statistics::KdTree
This class provides methods for k-nearest neighbor search and related data structures for a k-d tree.
Definition: itkKdTree.h:527
itkPoint.h
itk::PointsLocator::PointsContainer
TPointsContainer PointsContainer
Definition: itkPointsLocator.h:60
itk::PointsLocator::SampleAdaptorPointer
typename SampleAdaptorType::Pointer SampleAdaptorPointer
Definition: itkPointsLocator.h:75
itk::PointsLocator::PointIdentifier
typename PointsContainer::ElementIdentifier PointIdentifier
Definition: itkPointsLocator.h:63
itk::PointsLocator::TreeConstPointer
typename TreeType::ConstPointer TreeConstPointer
Definition: itkPointsLocator.h:81
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::PointsLocator
Accelerate geometric searches for points.
Definition: itkPointsLocator.h:42
itk::Statistics::VectorContainerToListSampleAdaptor
This class provides ListSample interface to ITK VectorContainer.
Definition: itkVectorContainerToListSampleAdaptor.h:46
itk::PointsLocator::PointsContainerIterator
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkPointsLocator.h:71
itk::PointsLocator::TreeType
typename TreeGeneratorType::KdTreeType TreeType
Definition: itkPointsLocator.h:80
itk::PointsLocator::PointsContainerPointer
typename PointsContainer::Pointer PointsContainerPointer
Definition: itkPointsLocator.h:61
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::PointsLocator::PointType
typename PointsContainer::Element PointType
Definition: itkPointsLocator.h:64
itkKdTree.h
itkIntTypes.h
itk::PointsLocator::PointsContainerConstPointer
typename PointsContainer::ConstPointer PointsContainerConstPointer
Definition: itkPointsLocator.h:62
itkObject.h
itkVectorContainer.h
itkVectorContainerToListSampleAdaptor.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::PointsLocator::PointsContainerConstIterator
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointsLocator.h:70
itkKdTreeGenerator.h
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::Statistics::KdTreeGenerator
This class generates a KdTree object without centroid information.
Definition: itkKdTreeGenerator.h:71