VTK  9.2.6
vtkIncrementalOctreePointLocator.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkIncrementalOctreePointLocator.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=========================================================================*/
47
48#ifndef vtkIncrementalOctreePointLocator_h
49#define vtkIncrementalOctreePointLocator_h
50
51#include "vtkCommonDataModelModule.h" // For export macro
53
54class vtkPoints;
55class vtkIdList;
56class vtkIntArray;
57class vtkPolyData;
58class vtkCellArray;
60
61class VTKCOMMONDATAMODEL_EXPORT vtkIncrementalOctreePointLocator : public vtkIncrementalPointLocator
62{
63public:
65 void PrintSelf(ostream& os, vtkIndent indent) override;
66
68
70
80 vtkSetMacro(MaxPointsPerLeaf, int);
81 vtkGetMacro(MaxPointsPerLeaf, int);
83
85
88 vtkSetMacro(BuildCubicOctree, vtkTypeBool);
89 vtkGetMacro(BuildCubicOctree, vtkTypeBool);
90 vtkBooleanMacro(BuildCubicOctree, vtkTypeBool);
92
94
98 vtkGetObjectMacro(LocatorPoints, vtkPoints);
100
104 void Initialize() override { this->FreeSearchStructure(); }
105
109 void FreeSearchStructure() override;
110
114 void GetBounds(double* bounds) override;
115
119 double* GetBounds() override
120 {
121 this->GetBounds(this->Bounds);
122 return this->Bounds;
123 }
124
132 vtkGetMacro(NumberOfNodes, int);
133
141 vtkIdType FindClosestInsertedPoint(const double x[3]) override;
142
144
156 void GenerateRepresentation(int level, vtkPolyData* polysData) override;
157 void GenerateRepresentation(int level, vtkPolyData* polysData,
158 bool (*UserGetBounds)(void* data, vtkIncrementalOctreeNode* node, double* bounds), void* data);
160
161 // -------------------------------------------------------------------------
162 // ---------------------------- Point Location ----------------------------
163 // -------------------------------------------------------------------------
164
170 void BuildLocator() override;
171
175 void ForceBuildLocator() override;
176
182 vtkIdType FindClosestPoint(const double x[3]) override;
183
190 virtual vtkIdType FindClosestPoint(double x, double y, double z);
191
198 virtual vtkIdType FindClosestPoint(const double x[3], double* miniDist2);
199
206 virtual vtkIdType FindClosestPoint(double x, double y, double z, double* miniDist2);
207
216 vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
217
226 vtkIdType FindClosestPointWithinSquaredRadius(double radius2, const double x[3], double& dist2);
227
234 void FindPointsWithinRadius(double R, const double x[3], vtkIdList* result) override;
235
242 void FindPointsWithinSquaredRadius(double R2, const double x[3], vtkIdList* result);
243
250 void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
251
252 // -------------------------------------------------------------------------
253 // ---------------------------- Point Insertion ----------------------------
254 // -------------------------------------------------------------------------
255
265 int InitPointInsertion(vtkPoints* points, const double bounds[6]) override;
266
277 int InitPointInsertion(vtkPoints* points, const double bounds[6], vtkIdType estSize) override;
278
284 vtkIdType IsInsertedPoint(const double x[3]) override;
285
291 vtkIdType IsInsertedPoint(double x, double y, double z) override;
292
301 int InsertUniquePoint(const double point[3], vtkIdType& pntId) override;
302
311 void InsertPoint(vtkIdType ptId, const double x[3]) override;
312
321 vtkIdType InsertNextPoint(const double x[3]) override;
322
331
332 void InsertPointWithoutChecking(const double point[3], vtkIdType& pntId, int insert);
333
334 vtkIncrementalOctreeNode* GetRoot() const { return OctreeRootNode; }
335
341
342protected:
345
346private:
347 vtkTypeBool BuildCubicOctree;
348 int MaxPointsPerLeaf;
349 double InsertTolerance2;
350 double OctreeMaxDimSize;
351 double FudgeFactor;
352 vtkPoints* LocatorPoints;
353 vtkIncrementalOctreeNode* OctreeRootNode;
354 int NumberOfNodes;
355
356 void BuildLocatorInternal() override;
357
361 static void DeleteAllDescendants(vtkIncrementalOctreeNode* node);
362
367 static void AddPolys(vtkIncrementalOctreeNode* node, vtkPoints* points, vtkCellArray* polygs,
368 vtkIntArray* nodeIndexes, vtkIdType& cellIndex,
369 bool (*GetBounds)(void* data, vtkIncrementalOctreeNode* node, double* bounds), void* data);
370
375 vtkIncrementalOctreeNode* GetLeafContainer(vtkIncrementalOctreeNode* node, const double pnt[3]);
376
384 vtkIdType FindClosestPointInLeafNode(
385 vtkIncrementalOctreeNode* leafNode, const double point[3], double* dist2);
386
399 vtkIdType FindClosestPointInSphere(const double point[3], double radius2,
400 vtkIncrementalOctreeNode* maskNode, double* minDist2, const double* refDist2);
401
402 // -------------------------------------------------------------------------
403 // ---------------------------- Point Location ----------------------------
404 // -------------------------------------------------------------------------
405
416 vtkIdType FindClosestPointInSphereWithoutTolerance(
417 const double point[3], double radius2, vtkIncrementalOctreeNode* maskNode, double* minDist2);
418
425 vtkIncrementalOctreeNode* node, double radius2, const double point[3], vtkIdList* idList);
426
427 // -------------------------------------------------------------------------
428 // ---------------------------- Point Insertion ----------------------------
429 // -------------------------------------------------------------------------
430
442 vtkIdType FindClosestPointInSphereWithTolerance(
443 const double point[3], double radius2, vtkIncrementalOctreeNode* maskNode, double* minDist2);
444
454 vtkIdType IsInsertedPoint(const double x[3], vtkIncrementalOctreeNode** leafContainer);
455
464 vtkIdType IsInsertedPointForZeroTolerance(
465 const double x[3], vtkIncrementalOctreeNode** leafContainer);
466
476 vtkIdType IsInsertedPointForNonZeroTolerance(
477 const double x[3], vtkIncrementalOctreeNode** leafContainer);
478
486 vtkIdType FindDuplicatePointInLeafNode(vtkIncrementalOctreeNode* leafNode, const double point[3]);
487
495 vtkIdType FindDuplicateFloatTypePointInVisitedLeafNode(
496 vtkIncrementalOctreeNode* leafNode, const double point[3]);
497
505 vtkIdType FindDuplicateDoubleTypePointInVisitedLeafNode(
506 vtkIncrementalOctreeNode* leafNode, const double point[3]);
507
509 void operator=(const vtkIncrementalOctreePointLocator&) = delete;
510};
511#endif
virtual double * GetBounds()
Provide an accessor to the bounds.
object to represent cell connectivity
list of point or cell ids
Definition vtkIdList.h:31
Octree node constituting incremental octree (in support of both point location and point insertion)
void GenerateRepresentation(int level, vtkPolyData *polysData, bool(*UserGetBounds)(void *data, vtkIncrementalOctreeNode *node, double *bounds), void *data)
vtkIdType IsInsertedPoint(const double x[3]) override
Determine whether or not a given point has been inserted into the octree.
vtkIncrementalOctreeNode * GetRoot() const
vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double &dist2) override
Given a point x and a radius, return the id of the closest point within the radius and the associated...
virtual vtkIdType FindClosestPoint(const double x[3], double *miniDist2)
Given a point x, return the id of the closest point and the associated minimum squared distance (via ...
int InitPointInsertion(vtkPoints *points, const double bounds[6]) override
Initialize the point insertion process.
void InsertPoint(vtkIdType ptId, const double x[3]) override
Insert a given point into the octree with a specified point index ptId.
void FindClosestNPoints(int N, const double x[3], vtkIdList *result) override
Find the closest N points to a given point.
void FindPointsWithinSquaredRadius(double R2, const double x[3], vtkIdList *result)
Find all points within a squared radius R2 relative to a given point x.
int InsertUniquePoint(const double point[3], vtkIdType &pntId) override
Insert a point to the octree unless there has been a duplicate point.
void Initialize() override
Delete the octree search structure.
void GetBounds(double *bounds) override
Get the spatial bounding box of the octree.
void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result) override
Find all points within a radius R relative to a given point x.
void InsertPointWithoutChecking(const double point[3], vtkIdType &pntId, int insert)
"Insert" a point to the octree without any checking.
double * GetBounds() override
Get the spatial bounding box of the octree.
vtkIdType FindClosestPointWithinSquaredRadius(double radius2, const double x[3], double &dist2)
Given a point x and a squared radius radius2, return the id of the closest point within the radius an...
virtual vtkIdType FindClosestPoint(double x, double y, double z)
Given a point (x, y, z), return the id of the closest point.
vtkIdType InsertNextPoint(const double x[3]) override
Insert a given point into the octree and return the point index.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard type and print methods.
void ForceBuildLocator() override
Build the locator from the input dataset (even if UseExistingSearchStructure is on).
int GetNumberOfPoints()
Get the number of points maintained by the octree.
vtkIdType FindClosestPoint(const double x[3]) override
Given a point x, return the id of the closest point.
void GenerateRepresentation(int level, vtkPolyData *polysData) override
Create a polygonal representation of the octree 'level': for each node on the specified level we gene...
vtkIdType IsInsertedPoint(double x, double y, double z) override
Determine whether or not a given point has been inserted into the octree.
void FreeSearchStructure() override
Delete the octree search structure.
virtual vtkIdType FindClosestPoint(double x, double y, double z, double *miniDist2)
Given a point (x, y, z), return the id of the closest point and the associated minimum squared distan...
int GetNumberOfLevels()
Returns the maximum level of the tree.
vtkIdType FindClosestInsertedPoint(const double x[3]) override
Given a point x assumed to be covered by the octree, return the index of the closest in-octree point ...
static vtkIncrementalOctreePointLocator * New()
int InitPointInsertion(vtkPoints *points, const double bounds[6], vtkIdType estSize) override
Initialize the point insertion process.
void BuildLocator() override
Load points from a dataset to construct an octree for point location.
virtual vtkIdType IsInsertedPoint(double x, double y, double z)=0
Determine whether or not a given point has been inserted.
a simple class to control print indentation
Definition vtkIndent.h:34
dynamic, self-adjusting array of int
Definition vtkIntArray.h:40
virtual void BuildLocatorInternal()
This function is not pure virtual to maintain backwards compatibility.
Definition vtkLocator.h:203
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
represent and manipulate 3D points
Definition vtkPoints.h:34
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:85
int vtkTypeBool
Definition vtkABI.h:69
int vtkIdType
Definition vtkType.h:332