VTK  9.1.0
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 
126 #ifndef vtkOctreePointLocator_h
127 #define vtkOctreePointLocator_h
128 
129 #include "vtkAbstractPointLocator.h"
130 #include "vtkCommonDataModelModule.h" // For export macro
131 
132 class vtkCellArray;
133 class vtkIdTypeArray;
135 class vtkPoints;
136 class vtkPolyData;
137 
138 class VTKCOMMONDATAMODEL_EXPORT vtkOctreePointLocator : public vtkAbstractPointLocator
139 {
140 public:
142  void PrintSelf(ostream& os, vtkIndent indent) override;
143 
145 
147 
150  vtkSetMacro(MaximumPointsPerRegion, int);
151  vtkGetMacro(MaximumPointsPerRegion, int);
153 
155 
158  vtkSetMacro(CreateCubicOctants, int);
159  vtkGetMacro(CreateCubicOctants, int);
161 
163 
169  vtkGetMacro(FudgeFactor, double);
170  vtkSetMacro(FudgeFactor, double);
172 
174 
178  double* GetBounds() override;
179  void GetBounds(double* bounds) override;
181 
183 
186  vtkGetMacro(NumberOfLeafNodes, int);
188 
192  void GetRegionBounds(int regionID, double bounds[6]);
193 
197  void GetRegionDataBounds(int leafNodeID, double bounds[6]);
198 
202  int GetRegionContainingPoint(double x, double y, double z);
203 
209  void BuildLocator() override;
210 
212 
216  vtkIdType FindClosestPoint(const double x[3]) override;
217  vtkIdType FindClosestPoint(double x, double y, double z, double& dist2);
219 
225  vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
226 
228 
233  vtkIdType FindClosestPointInRegion(int regionId, double* x, double& dist2);
234  vtkIdType FindClosestPointInRegion(int regionId, double x, double y, double z, double& dist2);
236 
241  void FindPointsWithinRadius(double radius, const double x[3], vtkIdList* result) override;
242 
251  void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
252 
257 
261  void FreeSearchStructure() override;
262 
267  void GenerateRepresentation(int level, vtkPolyData* pd) override;
268 
275  void FindPointsInArea(double* area, vtkIdTypeArray* ids, bool clearArray = true);
276 
277 protected:
280 
282  vtkOctreePointLocatorNode** LeafNodeList; // indexed by region/node ID
283 
285 
287 
291  int FindRegion(vtkOctreePointLocatorNode* node, float x, float y, float z);
292  int FindRegion(vtkOctreePointLocatorNode* node, double x, double y, double z);
294 
296 
298 
305  vtkOctreePointLocatorNode* node, double radiusSquared, const double x[3], vtkIdList* ids);
306 
307  // Recursive helper for public FindPointsWithinRadius
309 
310  // Recursive helper for public FindPointsInArea
312 
313  // Recursive helper for public FindPointsInArea
315 
316  void DivideRegion(vtkOctreePointLocatorNode* node, int* ordering, int level);
317 
318  int DivideTest(int size, int level);
319 
321 
326  int _FindClosestPointInRegion(int leafNodeId, double x, double y, double z, double& dist2);
327 
336  double x, double y, double z, double radius, int skipRegion, double& dist2);
337 
339 
345 
346  double FudgeFactor; // a very small distance, relative to the dataset's size
350 
351  float MaxWidth;
352 
361 
363  void operator=(const vtkOctreePointLocator&) = delete;
364 };
365 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkOctreePointLocator
an octree spatial decomposition of a set of points
Definition: vtkOctreePointLocator.h:139
vtkOctreePointLocator::BuildLocator
void BuildLocator() override
Create the octree decomposition of the cells of the data set or data sets.
vtkOctreePointLocator::FindClosestPointInSphere
int FindClosestPointInSphere(double x, double y, double z, double radius, int skipRegion, double &dist2)
Given a location and a radiues, find the closest point within this radius.
vtkOctreePointLocator::FindClosestPoint
vtkIdType FindClosestPoint(double x, double y, double z, double &dist2)
Return the Id of the point that is closest to the given point.
vtkOctreePointLocator::operator=
void operator=(const vtkOctreePointLocator &)=delete
vtkOctreePointLocator::LocatorIds
int * LocatorIds
Definition: vtkOctreePointLocator.h:349
vtkOctreePointLocator::~vtkOctreePointLocator
~vtkOctreePointLocator() override
vtkOctreePointLocator::MaxWidth
float MaxWidth
Definition: vtkOctreePointLocator.h:351
vtkOctreePointLocator::FindPointsInArea
void FindPointsInArea(double *area, vtkIdTypeArray *ids, bool clearArray=true)
Fill ids with points found in area.
vtkOctreePointLocator::GenerateRepresentation
void GenerateRepresentation(int level, vtkPolyData *pd) override
Create a polydata representation of the boundaries of the octree regions.
vtkAbstractPointLocator.h
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkOctreePointLocator::FudgeFactor
double FudgeFactor
Definition: vtkOctreePointLocator.h:346
vtkOctreePointLocator::FreeSearchStructure
void FreeSearchStructure() override
Delete the octree data structure.
vtkOctreePointLocator::AddAllPointsInRegion
void AddAllPointsInRegion(vtkOctreePointLocatorNode *node, vtkIdList *ids)
vtkOctreePointLocator::GetRegionDataBounds
void GetRegionDataBounds(int leafNodeID, double bounds[6])
Get the bounds of the data within the leaf node.
vtkOctreePointLocator::FindClosestNPoints
void FindClosestNPoints(int N, const double x[3], vtkIdList *result) override
Find the closest N points to a position.
vtkOctreePointLocator::_FindClosestPointInRegion
int _FindClosestPointInRegion(int leafNodeId, double x, double y, double z, double &dist2)
Given a leaf node id and point, return the local id and the squared distance between the closest poin...
vtkOctreePointLocator::NumberOfLocatorPoints
int NumberOfLocatorPoints
Definition: vtkOctreePointLocator.h:347
vtkOctreePointLocator::FindPointsInArea
void FindPointsInArea(vtkOctreePointLocatorNode *node, double *area, vtkIdTypeArray *ids)
vtkOctreePointLocator::NumberOfLeafNodes
int NumberOfLeafNodes
The maximum number of points in a region/octant before it is subdivided.
Definition: vtkOctreePointLocator.h:343
vtkOctreePointLocatorNode
Octree node that has 8 children each of equal size.
Definition: vtkOctreePointLocatorNode.h:47
vtkOctreePointLocator::vtkOctreePointLocator
vtkOctreePointLocator(const vtkOctreePointLocator &)=delete
vtkOctreePointLocator::DivideTest
int DivideTest(int size, int level)
vtkOctreePointLocator::LeafNodeList
vtkOctreePointLocatorNode ** LeafNodeList
Definition: vtkOctreePointLocator.h:282
vtkOctreePointLocator::FindPointsWithinRadius
void FindPointsWithinRadius(vtkOctreePointLocatorNode *node, double radiusSquared, const double x[3], vtkIdList *ids)
Recursive helper for public FindPointsWithinRadius.
vtkOctreePointLocator::New
static vtkOctreePointLocator * New()
vtkOctreePointLocator::Top
vtkOctreePointLocatorNode * Top
Definition: vtkOctreePointLocator.h:281
vtkX3D::level
@ level
Definition: vtkX3D.h:401
vtkOctreePointLocator::CreateCubicOctants
int CreateCubicOctants
If CreateCubicOctants is non-zero, the bounding box of the points will be expanded such that all octa...
Definition: vtkOctreePointLocator.h:360
vtkOctreePointLocator::DivideRegion
void DivideRegion(vtkOctreePointLocatorNode *node, int *ordering, int level)
vtkOctreePointLocator::SetDataBoundsToSpatialBounds
static void SetDataBoundsToSpatialBounds(vtkOctreePointLocatorNode *node)
vtkOctreePointLocator::FindClosestPointInRegion
vtkIdType FindClosestPointInRegion(int regionId, double x, double y, double z, double &dist2)
Find the Id of the point in the given leaf region which is closest to the given point.
vtkOctreePointLocator::FindClosestPointWithinRadius
vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double &dist2) override
Given a position x and a radius r, return the id of the point closest to the point in that radius.
vtkOctreePointLocator::AddAllPointsInRegion
void AddAllPointsInRegion(vtkOctreePointLocatorNode *node, vtkIdTypeArray *ids)
vtkOctreePointLocator::GetRegionBounds
void GetRegionBounds(int regionID, double bounds[6])
Get the spatial bounds of octree region.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:290
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkOctreePointLocator::DeleteAllDescendants
static void DeleteAllDescendants(vtkOctreePointLocatorNode *octant)
vtkOctreePointLocator::GetBounds
void GetBounds(double *bounds) override
Get the spatial bounds of the entire octree space.
vtkOctreePointLocator::AddPolys
void AddPolys(vtkOctreePointLocatorNode *node, vtkPoints *pts, vtkCellArray *polys)
vtkOctreePointLocator::GetRegionContainingPoint
int GetRegionContainingPoint(double x, double y, double z)
Get the id of the leaf region containing the specified location.
vtkOctreePointLocator::GetPointsInRegion
vtkIdTypeArray * GetPointsInRegion(int leafNodeId)
Get a list of the original IDs of all points in a leaf node.
vtkOctreePointLocator::LocatorPoints
float * LocatorPoints
Definition: vtkOctreePointLocator.h:348
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:145
vtkOctreePointLocator::FindClosestPointInRegion
vtkIdType FindClosestPointInRegion(int regionId, double *x, double &dist2)
Find the Id of the point in the given leaf region which is closest to the given point.
vtkOctreePointLocator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard type and print methods.
vtkOctreePointLocator::vtkOctreePointLocator
vtkOctreePointLocator()
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkOctreePointLocator::FindRegion
int FindRegion(vtkOctreePointLocatorNode *node, float x, float y, float z)
Given a point and a node return the leaf node id that contains the point.
vtkAbstractPointLocator
abstract class to quickly locate points in 3-space
Definition: vtkAbstractPointLocator.h:39
vtkOctreePointLocator::BuildLeafNodeList
void BuildLeafNodeList(vtkOctreePointLocatorNode *node, int &index)
VTK_NEWINSTANCE
#define VTK_NEWINSTANCE
Definition: vtkWrappingHints.h:44
vtkOctreePointLocator::FindClosestPoint
vtkIdType FindClosestPoint(const double x[3]) override
Return the Id of the point that is closest to the given point.
vtkX3D::radius
@ radius
Definition: vtkX3D.h:258
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkOctreePointLocator::FindRegion
int FindRegion(vtkOctreePointLocatorNode *node, double x, double y, double z)
Given a point and a node return the leaf node id that contains the point.
vtkOctreePointLocator::FindPointsWithinRadius
void FindPointsWithinRadius(double radius, const double x[3], vtkIdList *result) override
Find all points within a specified radius of position x.
vtkOctreePointLocator::MaximumPointsPerRegion
int MaximumPointsPerRegion
The maximum number of points in a region/octant before it is subdivided.
Definition: vtkOctreePointLocator.h:342
vtkOctreePointLocator::GetBounds
double * GetBounds() override
Get the spatial bounds of the entire octree space.