VTK  9.0.1
vtkOctreePointLocator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOctreePointLocator.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*----------------------------------------------------------------------------
16  Copyright (c) Sandia Corporation
17  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18 ----------------------------------------------------------------------------*/
19 
37 #ifndef vtkOctreePointLocator_h
38 #define vtkOctreePointLocator_h
39 
41 #include "vtkCommonDataModelModule.h" // For export macro
42 
43 class vtkCellArray;
44 class vtkIdTypeArray;
46 class vtkPoints;
47 class vtkPolyData;
48 
49 class VTKCOMMONDATAMODEL_EXPORT vtkOctreePointLocator : public vtkAbstractPointLocator
50 {
51 public:
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
55  static vtkOctreePointLocator* New();
56 
58 
61  vtkSetMacro(MaximumPointsPerRegion, int);
62  vtkGetMacro(MaximumPointsPerRegion, int);
64 
66 
69  vtkSetMacro(CreateCubicOctants, int);
70  vtkGetMacro(CreateCubicOctants, int);
72 
74 
80  vtkGetMacro(FudgeFactor, double);
81  vtkSetMacro(FudgeFactor, double);
83 
85 
89  double* GetBounds() override;
90  void GetBounds(double* bounds) override;
92 
94 
97  vtkGetMacro(NumberOfLeafNodes, int);
99 
103  void GetRegionBounds(int regionID, double bounds[6]);
104 
108  void GetRegionDataBounds(int leafNodeID, double bounds[6]);
109 
113  int GetRegionContainingPoint(double x, double y, double z);
114 
120  void BuildLocator() override;
121 
123 
127  vtkIdType FindClosestPoint(const double x[3]) override;
128  vtkIdType FindClosestPoint(double x, double y, double z, double& dist2);
130 
136  vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
137 
139 
144  vtkIdType FindClosestPointInRegion(int regionId, double* x, double& dist2);
145  vtkIdType FindClosestPointInRegion(int regionId, double x, double y, double z, double& dist2);
147 
152  void FindPointsWithinRadius(double radius, const double x[3], vtkIdList* result) override;
153 
162  void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
163 
167  vtkIdTypeArray* GetPointsInRegion(int leafNodeId);
168 
172  void FreeSearchStructure() override;
173 
178  void GenerateRepresentation(int level, vtkPolyData* pd) override;
179 
186  void FindPointsInArea(double* area, vtkIdTypeArray* ids, bool clearArray = true);
187 
188 protected:
190  ~vtkOctreePointLocator() override;
191 
193  vtkOctreePointLocatorNode** LeafNodeList; // indexed by region/node ID
194 
195  void BuildLeafNodeList(vtkOctreePointLocatorNode* node, int& index);
196 
198 
202  int FindRegion(vtkOctreePointLocatorNode* node, float x, float y, float z);
203  int FindRegion(vtkOctreePointLocatorNode* node, double x, double y, double z);
205 
206  static void SetDataBoundsToSpatialBounds(vtkOctreePointLocatorNode* node);
207 
208  static void DeleteAllDescendants(vtkOctreePointLocatorNode* octant);
209 
216  vtkOctreePointLocatorNode* node, double radiusSquared, const double x[3], vtkIdList* ids);
217 
218  // Recursive helper for public FindPointsWithinRadius
219  void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdList* ids);
220 
221  // Recursive helper for public FindPointsInArea
222  void FindPointsInArea(vtkOctreePointLocatorNode* node, double* area, vtkIdTypeArray* ids);
223 
224  // Recursive helper for public FindPointsInArea
225  void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdTypeArray* ids);
226 
227  void DivideRegion(vtkOctreePointLocatorNode* node, int* ordering, int level);
228 
229  int DivideTest(int size, int level);
230 
231  void AddPolys(vtkOctreePointLocatorNode* node, vtkPoints* pts, vtkCellArray* polys);
232 
237  int _FindClosestPointInRegion(int leafNodeId, double x, double y, double z, double& dist2);
238 
246  int FindClosestPointInSphere(
247  double x, double y, double z, double radius, int skipRegion, double& dist2);
248 
250 
256 
257  double FudgeFactor; // a very small distance, relative to the dataset's size
261 
262  float MaxWidth;
263 
272 
274  void operator=(const vtkOctreePointLocator&) = delete;
275 };
276 #endif
virtual void BuildLocator()=0
Build the locator from the input dataset.
an octree spatial decomposition of a set of points
virtual vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double &dist2)=0
Given a position x and a radius r, return the id of the point closest to the point in that radius...
int CreateCubicOctants
If CreateCubicOctants is non-zero, the bounding box of the points will be expanded such that all octa...
virtual double * GetBounds()
Provide an accessor to the bounds.
int MaximumPointsPerRegion
The maximum number of points in a region/octant before it is subdivided.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:338
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
int NumberOfLeafNodes
The maximum number of points in a region/octant before it is subdivided.
vtkOctreePointLocatorNode ** LeafNodeList
a simple class to control print indentation
Definition: vtkIndent.h:33
void PrintSelf(ostream &os, vtkIndent indent) override
Standard type and print methods.
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:30
virtual void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result)=0
Find all points within a specified radius R of position x.
virtual void FindClosestNPoints(int N, const double x[3], vtkIdList *result)=0
Find the closest N points to a position.
object to represent cell connectivity
Definition: vtkCellArray.h:179
Octree node that has 8 children each of equal size.
vtkOctreePointLocatorNode * Top
virtual vtkIdType FindClosestPoint(const double x[3])=0
Given a position x, return the id of the point closest to it.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
Method to build a representation at a particular level.
represent and manipulate 3D points
Definition: vtkPoints.h:33