VTK  9.0.3
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 =========================================================================*/
48 #ifndef vtkIncrementalOctreePointLocator_h
49 #define vtkIncrementalOctreePointLocator_h
50 
51 #include "vtkCommonDataModelModule.h" // For export macro
53 
54 class vtkPoints;
55 class vtkIdList;
56 class vtkPolyData;
57 class vtkCellArray;
59 
60 class VTKCOMMONDATAMODEL_EXPORT vtkIncrementalOctreePointLocator : public vtkIncrementalPointLocator
61 {
62 public:
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
67 
69 
79  vtkSetClampMacro(MaxPointsPerLeaf, int, 16, 256);
80  vtkGetMacro(MaxPointsPerLeaf, int);
82 
84 
87  vtkSetMacro(BuildCubicOctree, vtkTypeBool);
88  vtkGetMacro(BuildCubicOctree, vtkTypeBool);
89  vtkBooleanMacro(BuildCubicOctree, vtkTypeBool);
91 
93 
97  vtkGetObjectMacro(LocatorPoints, vtkPoints);
99 
103  void Initialize() override { this->FreeSearchStructure(); }
104 
108  void FreeSearchStructure() override;
109 
113  void GetBounds(double* bounds) override;
114 
118  double* GetBounds() override
119  {
120  this->GetBounds(this->Bounds);
121  return this->Bounds;
122  }
123 
128 
136  vtkIdType FindClosestInsertedPoint(const double x[3]) override;
137 
142  void GenerateRepresentation(int nodeLevel, vtkPolyData* polysData) override;
143 
144  // -------------------------------------------------------------------------
145  // ---------------------------- Point Location ----------------------------
146  // -------------------------------------------------------------------------
147 
152  void BuildLocator() override;
153 
159  vtkIdType FindClosestPoint(const double x[3]) override;
160 
167  virtual vtkIdType FindClosestPoint(double x, double y, double z);
168 
175  virtual vtkIdType FindClosestPoint(const double x[3], double* miniDist2);
176 
183  virtual vtkIdType FindClosestPoint(double x, double y, double z, double* miniDist2);
184 
193  vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
194 
203  vtkIdType FindClosestPointWithinSquaredRadius(double radius2, const double x[3], double& dist2);
204 
211  void FindPointsWithinRadius(double R, const double x[3], vtkIdList* result) override;
212 
219  void FindPointsWithinSquaredRadius(double R2, const double x[3], vtkIdList* result);
220 
227  void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
228 
229  // -------------------------------------------------------------------------
230  // ---------------------------- Point Insertion ----------------------------
231  // -------------------------------------------------------------------------
232 
242  int InitPointInsertion(vtkPoints* points, const double bounds[6]) override;
243 
254  int InitPointInsertion(vtkPoints* points, const double bounds[6], vtkIdType estSize) override;
255 
261  vtkIdType IsInsertedPoint(const double x[3]) override;
262 
268  vtkIdType IsInsertedPoint(double x, double y, double z) override;
269 
278  int InsertUniquePoint(const double point[3], vtkIdType& pntId) override;
279 
288  void InsertPoint(vtkIdType ptId, const double x[3]) override;
289 
298  vtkIdType InsertNextPoint(const double x[3]) override;
299 
308  void InsertPointWithoutChecking(const double point[3], vtkIdType& pntId, int insert);
309 
310 protected:
313 
314 private:
315  vtkTypeBool BuildCubicOctree;
316  int MaxPointsPerLeaf;
317  double InsertTolerance2;
318  double OctreeMaxDimSize;
319  double FudgeFactor;
320  vtkPoints* LocatorPoints;
321  vtkIncrementalOctreeNode* OctreeRootNode;
322 
326  static void DeleteAllDescendants(vtkIncrementalOctreeNode* node);
327 
332  static void AddPolys(vtkIncrementalOctreeNode* node, vtkPoints* points, vtkCellArray* polygs);
333 
338  vtkIncrementalOctreeNode* GetLeafContainer(vtkIncrementalOctreeNode* node, const double pnt[3]);
339 
347  vtkIdType FindClosestPointInLeafNode(
348  vtkIncrementalOctreeNode* leafNode, const double point[3], double* dist2);
349 
362  vtkIdType FindClosestPointInSphere(const double point[3], double radius2,
363  vtkIncrementalOctreeNode* maskNode, double* minDist2, const double* refDist2);
364 
365  // -------------------------------------------------------------------------
366  // ---------------------------- Point Location ----------------------------
367  // -------------------------------------------------------------------------
368 
379  vtkIdType FindClosestPointInSphereWithoutTolerance(
380  const double point[3], double radius2, vtkIncrementalOctreeNode* maskNode, double* minDist2);
381 
387  void FindPointsWithinSquaredRadius(
388  vtkIncrementalOctreeNode* node, double radius2, const double point[3], vtkIdList* idList);
389 
390  // -------------------------------------------------------------------------
391  // ---------------------------- Point Insertion ----------------------------
392  // -------------------------------------------------------------------------
393 
405  vtkIdType FindClosestPointInSphereWithTolerance(
406  const double point[3], double radius2, vtkIncrementalOctreeNode* maskNode, double* minDist2);
407 
417  vtkIdType IsInsertedPoint(const double x[3], vtkIncrementalOctreeNode** leafContainer);
418 
427  vtkIdType IsInsertedPointForZeroTolerance(
428  const double x[3], vtkIncrementalOctreeNode** leafContainer);
429 
439  vtkIdType IsInsertedPointForNonZeroTolerance(
440  const double x[3], vtkIncrementalOctreeNode** leafContainer);
441 
449  vtkIdType FindDuplicatePointInLeafNode(vtkIncrementalOctreeNode* leafNode, const double point[3]);
450 
458  vtkIdType FindDuplicateFloatTypePointInVisitedLeafNode(
459  vtkIncrementalOctreeNode* leafNode, const double point[3]);
460 
468  vtkIdType FindDuplicateDoubleTypePointInVisitedLeafNode(
469  vtkIncrementalOctreeNode* leafNode, const double point[3]);
470 
472  void operator=(const vtkIncrementalOctreePointLocator&) = delete;
473 };
474 #endif
virtual double * GetBounds()
Provide an accessor to the bounds.
object to represent cell connectivity
Definition: vtkCellArray.h:180
list of point or cell ids
Definition: vtkIdList.h:31
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.
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 GenerateRepresentation(int nodeLevel, vtkPolyData *polysData) override
Create a polygonal representation of the octree boundary (from the root node to a specified level).
void InsertPointWithoutChecking(const double point[3], vtkIdType &pntId, int insert)
"Insert" a point to the octree without any checking.
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
Methods invoked by print to print information about the object including superclasses.
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.
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...
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:34
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
@ point
Definition: vtkX3D.h:242
@ points
Definition: vtkX3D.h:452
@ radius
Definition: vtkX3D.h:258
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:338