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 =========================================================================*/
60 #ifndef vtkIncrementalOctreePointLocator_h
61 #define vtkIncrementalOctreePointLocator_h
62 
63 #include "vtkCommonDataModelModule.h" // For export macro
65 
66 class vtkPoints;
67 class vtkIdList;
68 class vtkIntArray;
69 class vtkPolyData;
70 class vtkCellArray;
72 
73 class VTKCOMMONDATAMODEL_EXPORT vtkIncrementalOctreePointLocator : public vtkIncrementalPointLocator
74 {
75 public:
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
80 
82 
92  vtkSetMacro(MaxPointsPerLeaf, int);
93  vtkGetMacro(MaxPointsPerLeaf, int);
95 
97 
100  vtkSetMacro(BuildCubicOctree, vtkTypeBool);
101  vtkGetMacro(BuildCubicOctree, vtkTypeBool);
102  vtkBooleanMacro(BuildCubicOctree, vtkTypeBool);
104 
106 
110  vtkGetObjectMacro(LocatorPoints, vtkPoints);
112 
116  void Initialize() override { this->FreeSearchStructure(); }
117 
121  void FreeSearchStructure() override;
122 
126  void GetBounds(double* bounds) override;
127 
131  double* GetBounds() override
132  {
133  this->GetBounds(this->Bounds);
134  return this->Bounds;
135  }
136 
144  vtkGetMacro(NumberOfNodes, int);
145 
153  vtkIdType FindClosestInsertedPoint(const double x[3]) override;
154 
156 
168  void GenerateRepresentation(int level, vtkPolyData* polysData) override;
170  bool (*UserGetBounds)(void* data, vtkIncrementalOctreeNode* node, double* bounds), void* data);
172 
173  // -------------------------------------------------------------------------
174  // ---------------------------- Point Location ----------------------------
175  // -------------------------------------------------------------------------
176 
182  void BuildLocator() override;
183 
187  void ForceBuildLocator() override;
188 
194  vtkIdType FindClosestPoint(const double x[3]) override;
195 
202  virtual vtkIdType FindClosestPoint(double x, double y, double z);
203 
210  virtual vtkIdType FindClosestPoint(const double x[3], double* miniDist2);
211 
218  virtual vtkIdType FindClosestPoint(double x, double y, double z, double* miniDist2);
219 
228  vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
229 
238  vtkIdType FindClosestPointWithinSquaredRadius(double radius2, const double x[3], double& dist2);
239 
246  void FindPointsWithinRadius(double R, const double x[3], vtkIdList* result) override;
247 
254  void FindPointsWithinSquaredRadius(double R2, const double x[3], vtkIdList* result);
255 
262  void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
263 
264  // -------------------------------------------------------------------------
265  // ---------------------------- Point Insertion ----------------------------
266  // -------------------------------------------------------------------------
267 
277  int InitPointInsertion(vtkPoints* points, const double bounds[6]) override;
278 
289  int InitPointInsertion(vtkPoints* points, const double bounds[6], vtkIdType estSize) override;
290 
296  vtkIdType IsInsertedPoint(const double x[3]) override;
297 
303  vtkIdType IsInsertedPoint(double x, double y, double z) override;
304 
313  int InsertUniquePoint(const double point[3], vtkIdType& pntId) override;
314 
323  void InsertPoint(vtkIdType ptId, const double x[3]) override;
324 
333  vtkIdType InsertNextPoint(const double x[3]) override;
334 
344  void InsertPointWithoutChecking(const double point[3], vtkIdType& pntId, int insert);
345 
346  vtkIncrementalOctreeNode* GetRoot() const { return OctreeRootNode; }
347 
353 
354 protected:
357 
358 private:
359  vtkTypeBool BuildCubicOctree;
360  int MaxPointsPerLeaf;
361  double InsertTolerance2;
362  double OctreeMaxDimSize;
363  double FudgeFactor;
364  vtkPoints* LocatorPoints;
365  vtkIncrementalOctreeNode* OctreeRootNode;
366  int NumberOfNodes;
367 
368  void BuildLocatorInternal() override;
369 
373  static void DeleteAllDescendants(vtkIncrementalOctreeNode* node);
374 
379  static void AddPolys(vtkIncrementalOctreeNode* node, vtkPoints* points, vtkCellArray* polygs,
380  vtkIntArray* nodeIndexes, vtkIdType& cellIndex,
381  bool (*GetBounds)(void* data, vtkIncrementalOctreeNode* node, double* bounds), void* data);
382 
387  vtkIncrementalOctreeNode* GetLeafContainer(vtkIncrementalOctreeNode* node, const double pnt[3]);
388 
396  vtkIdType FindClosestPointInLeafNode(
397  vtkIncrementalOctreeNode* leafNode, const double point[3], double* dist2);
398 
411  vtkIdType FindClosestPointInSphere(const double point[3], double radius2,
412  vtkIncrementalOctreeNode* maskNode, double* minDist2, const double* refDist2);
413 
414  // -------------------------------------------------------------------------
415  // ---------------------------- Point Location ----------------------------
416  // -------------------------------------------------------------------------
417 
428  vtkIdType FindClosestPointInSphereWithoutTolerance(
429  const double point[3], double radius2, vtkIncrementalOctreeNode* maskNode, double* minDist2);
430 
436  void FindPointsWithinSquaredRadius(
437  vtkIncrementalOctreeNode* node, double radius2, const double point[3], vtkIdList* idList);
438 
439  // -------------------------------------------------------------------------
440  // ---------------------------- Point Insertion ----------------------------
441  // -------------------------------------------------------------------------
442 
454  vtkIdType FindClosestPointInSphereWithTolerance(
455  const double point[3], double radius2, vtkIncrementalOctreeNode* maskNode, double* minDist2);
456 
466  vtkIdType IsInsertedPoint(const double x[3], vtkIncrementalOctreeNode** leafContainer);
467 
476  vtkIdType IsInsertedPointForZeroTolerance(
477  const double x[3], vtkIncrementalOctreeNode** leafContainer);
478 
488  vtkIdType IsInsertedPointForNonZeroTolerance(
489  const double x[3], vtkIncrementalOctreeNode** leafContainer);
490 
498  vtkIdType FindDuplicatePointInLeafNode(vtkIncrementalOctreeNode* leafNode, const double point[3]);
499 
507  vtkIdType FindDuplicateFloatTypePointInVisitedLeafNode(
508  vtkIncrementalOctreeNode* leafNode, const double point[3]);
509 
517  vtkIdType FindDuplicateDoubleTypePointInVisitedLeafNode(
518  vtkIncrementalOctreeNode* leafNode, const double point[3]);
519 
521  void operator=(const vtkIncrementalOctreePointLocator&) = delete;
522 };
523 #endif
virtual double * GetBounds()
Provide an accessor to the bounds.
object to represent cell connectivity
Definition: vtkCellArray.h:196
list of point or cell ids
Definition: vtkIdList.h:43
Octree node constituting incremental octree (in support of both point location and point insertion)
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.
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.
double * GetBounds() override
Get the spatial bounding box of the octree.
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.
vtkIncrementalOctreeNode * GetRoot() const
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.
static vtkIncrementalOctreePointLocator * New()
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 ...
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.
Abstract class in support of both point location and point insertion.
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:49
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:55
virtual void BuildLocatorInternal()
This function is not pure virtual to maintain backwards compatibility.
Definition: vtkLocator.h:212
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
represent and manipulate 3D points
Definition: vtkPoints.h:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:100
void GetBounds(T a, double bds[6])
@ point
Definition: vtkX3D.h:242
@ points
Definition: vtkX3D.h:452
@ level
Definition: vtkX3D.h:401
@ radius
Definition: vtkX3D.h:258
@ data
Definition: vtkX3D.h:321
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332