VTK
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 =========================================================================*/
51 #ifndef vtkIncrementalOctreePointLocator_h
52 #define vtkIncrementalOctreePointLocator_h
53 
54 #include "vtkCommonDataModelModule.h" // For export macro
56 
57 class vtkPoints;
58 class vtkIdList;
59 class vtkPolyData;
60 class vtkCellArray;
62 
63 class VTKCOMMONDATAMODEL_EXPORT vtkIncrementalOctreePointLocator : public vtkIncrementalPointLocator
64 {
65 public:
66 
68  void PrintSelf( ostream & os, vtkIndent indent ) override;
69 
71 
73 
83  vtkSetClampMacro( MaxPointsPerLeaf, int, 16, 256 );
84  vtkGetMacro( MaxPointsPerLeaf, int );
86 
88 
91  vtkSetMacro( BuildCubicOctree, vtkTypeBool );
92  vtkGetMacro( BuildCubicOctree, vtkTypeBool );
93  vtkBooleanMacro( BuildCubicOctree, vtkTypeBool );
95 
97 
101  vtkGetObjectMacro( LocatorPoints, vtkPoints );
103 
107  void Initialize() override { this->FreeSearchStructure(); }
108 
112  void FreeSearchStructure() override;
113 
117  void GetBounds( double * bounds ) override;
118 
122  double * GetBounds() override
123  { this->GetBounds( this->Bounds ); return this->Bounds; }
124 
129 
137  vtkIdType FindClosestInsertedPoint( const double x[3] ) override;
138 
143  void GenerateRepresentation( int nodeLevel, vtkPolyData * polysData ) override;
144 
145  // -------------------------------------------------------------------------
146  // ---------------------------- Point Location ----------------------------
147  // -------------------------------------------------------------------------
148 
153  void BuildLocator() override;
154 
160  vtkIdType FindClosestPoint( const double x[3] ) override;
161 
168  virtual vtkIdType FindClosestPoint( double x, double y, double z );
169 
176  virtual vtkIdType FindClosestPoint( const double x[3], double * miniDist2 );
177 
184  virtual vtkIdType FindClosestPoint( double x, double y, double z, double * miniDist2 );
185 
195  ( double radius, const double x[3], double & dist2 ) override;
196 
206  ( double radius2, const double x[3], double & dist2 );
207 
215  ( double R, const double x[3], vtkIdList * result ) override;
216 
224  ( double R2, const double x[3], vtkIdList * result );
225 
233  ( int N, const double x[3], vtkIdList * result ) override;
234 
235  // -------------------------------------------------------------------------
236  // ---------------------------- Point Insertion ----------------------------
237  // -------------------------------------------------------------------------
238 
249  ( vtkPoints * points, const double bounds[6] ) override;
250 
261  int InitPointInsertion( vtkPoints * points, const double bounds[6],
262  vtkIdType estSize ) override;
263 
269  vtkIdType IsInsertedPoint( const double x[3] ) override;
270 
276  vtkIdType IsInsertedPoint( double x, double y, double z ) override;
277 
286  int InsertUniquePoint( const double point[3], vtkIdType & pntId ) override;
287 
296  void InsertPoint( vtkIdType ptId, const double x[3] ) override;
297 
306  vtkIdType InsertNextPoint( const double x[3] ) override;
307 
317  ( const double point[3], vtkIdType & pntId, int insert );
318 
319 protected:
320 
323 
324 private:
325 
326  vtkTypeBool BuildCubicOctree;
327  int MaxPointsPerLeaf;
328  double InsertTolerance2;
329  double OctreeMaxDimSize;
330  double FudgeFactor;
331  vtkPoints * LocatorPoints;
332  vtkIncrementalOctreeNode * OctreeRootNode;
333 
337  static void DeleteAllDescendants( vtkIncrementalOctreeNode * node );
338 
343  static void AddPolys( vtkIncrementalOctreeNode * node,
344  vtkPoints * points, vtkCellArray * polygs );
345 
350  vtkIncrementalOctreeNode * GetLeafContainer( vtkIncrementalOctreeNode * node,
351  const double pnt[3] );
352 
360  vtkIdType FindClosestPointInLeafNode( vtkIncrementalOctreeNode * leafNode,
361  const double point[3], double * dist2 );
362 
375  vtkIdType FindClosestPointInSphere
376  ( const double point[3], double radius2, vtkIncrementalOctreeNode * maskNode,
377  double * minDist2, const double * refDist2 );
378 
379 
380  // -------------------------------------------------------------------------
381  // ---------------------------- Point Location ----------------------------
382  // -------------------------------------------------------------------------
383 
394  vtkIdType FindClosestPointInSphereWithoutTolerance( const double point[3],
395  double radius2, vtkIncrementalOctreeNode * maskNode, double * minDist2 );
396 
402  void FindPointsWithinSquaredRadius( vtkIncrementalOctreeNode * node,
403  double radius2, const double point[3], vtkIdList * idList );
404 
405  // -------------------------------------------------------------------------
406  // ---------------------------- Point Insertion ----------------------------
407  // -------------------------------------------------------------------------
408 
420  vtkIdType FindClosestPointInSphereWithTolerance( const double point[3],
421  double radius2, vtkIncrementalOctreeNode * maskNode, double * minDist2 );
422 
432  vtkIdType IsInsertedPoint( const double x[3],
433  vtkIncrementalOctreeNode ** leafContainer );
434 
443  vtkIdType IsInsertedPointForZeroTolerance
444  ( const double x[3], vtkIncrementalOctreeNode ** leafContainer );
445 
455  vtkIdType IsInsertedPointForNonZeroTolerance
456  ( const double x[3], vtkIncrementalOctreeNode ** leafContainer );
457 
465  vtkIdType FindDuplicatePointInLeafNode( vtkIncrementalOctreeNode * leafNode,
466  const double point[3] );
467 
475  vtkIdType FindDuplicateFloatTypePointInVisitedLeafNode
476  ( vtkIncrementalOctreeNode * leafNode, const double point[3] );
477 
485  vtkIdType FindDuplicateDoubleTypePointInVisitedLeafNode
486  ( vtkIncrementalOctreeNode * leafNode, const double point[3] );
487 
489  ( const vtkIncrementalOctreePointLocator & ) = delete;
490  void operator = ( const vtkIncrementalOctreePointLocator & ) = delete;
491 
492 };
493 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:40
vtkIncrementalOctreePointLocator::FindPointsWithinSquaredRadius
void FindPointsWithinSquaredRadius(double R2, const double x[3], vtkIdList *result)
Find all points within a squared radius R2 relative to a given point x.
vtkIncrementalPointLocator::IsInsertedPoint
virtual vtkIdType IsInsertedPoint(double x, double y, double z)=0
Determine whether or not a given point has been inserted.
vtkIncrementalOctreePointLocator::GetBounds
double * GetBounds() override
Get the spatial bounding box of the octree.
Definition: vtkIncrementalOctreePointLocator.h:122
vtkIncrementalOctreePointLocator::FindClosestPoint
virtual vtkIdType FindClosestPoint(double x, double y, double z)
Given a point (x, y, z), return the id of the closest point.
vtkIncrementalOctreePointLocator::New
static vtkIncrementalOctreePointLocator * New()
vtkIncrementalOctreePointLocator::GetNumberOfPoints
int GetNumberOfPoints()
Get the number of points maintained by the octree.
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkIncrementalOctreePointLocator::InsertPointWithoutChecking
void InsertPointWithoutChecking(const double point[3], vtkIdType &pntId, int insert)
"Insert" a point to the octree without any checking.
vtkAbstractPointLocator::GetBounds
virtual double * GetBounds()
Provide an accessor to the bounds.
Definition: vtkAbstractPointLocator.h:103
vtkIncrementalOctreePointLocator::BuildLocator
void BuildLocator() override
Load points from a dataset to construct an octree for point location.
vtkIncrementalOctreePointLocator::InsertUniquePoint
int InsertUniquePoint(const double point[3], vtkIdType &pntId) override
Insert a point to the octree unless there has been a duplciate point.
vtkAbstractPointLocator::Bounds
double Bounds[6]
Definition: vtkAbstractPointLocator.h:119
vtkIncrementalOctreePointLocator::vtkIncrementalOctreePointLocator
vtkIncrementalOctreePointLocator()
vtkIncrementalOctreePointLocator::GenerateRepresentation
void GenerateRepresentation(int nodeLevel, vtkPolyData *polysData) override
Create a polygonal representation of the octree boundary (from the root node to a specified level).
vtkIncrementalOctreePointLocator::FindClosestPointWithinSquaredRadius
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...
vtkIncrementalOctreePointLocator::InsertPoint
void InsertPoint(vtkIdType ptId, const double x[3]) override
Insert a given point into the octree with a specified point index ptId.
vtkX3D::points
@ points
Definition: vtkX3D.h:446
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkIncrementalOctreePointLocator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIncrementalOctreePointLocator
Incremental octree in support of both point location and point insertion.
Definition: vtkIncrementalOctreePointLocator.h:64
vtkIncrementalPointLocator.h
vtkIncrementalOctreePointLocator::FindClosestPointWithinRadius
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...
vtkIncrementalOctreePointLocator::InitPointInsertion
int InitPointInsertion(vtkPoints *points, const double bounds[6]) override
Initialize the point insertion process.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:51
vtkIncrementalOctreePointLocator::InsertNextPoint
vtkIdType InsertNextPoint(const double x[3]) override
Insert a given point into the octree and return the point index.
vtkIncrementalPointLocator
Abstract class in support of both point location and point insertion.
Definition: vtkIncrementalPointLocator.h:52
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:37
vtkIncrementalOctreePointLocator::GetBounds
void GetBounds(double *bounds) override
Get the spatial bounding box of the octree.
vtkIncrementalOctreePointLocator::IsInsertedPoint
vtkIdType IsInsertedPoint(double x, double y, double z) override
Determine whether or not a given point has been inserted into the octree.
vtkIncrementalOctreeNode
Octree node constituting incremental octree (in support of both point location and point insertion)
Definition: vtkIncrementalOctreeNode.h:69
vtkIncrementalOctreePointLocator::InitPointInsertion
int InitPointInsertion(vtkPoints *points, const double bounds[6], vtkIdType estSize) override
Initialize the point insertion process.
vtkIncrementalOctreePointLocator::~vtkIncrementalOctreePointLocator
~vtkIncrementalOctreePointLocator() override
vtkIncrementalOctreePointLocator::IsInsertedPoint
vtkIdType IsInsertedPoint(const double x[3]) override
Determine whether or not a given point has been inserted into the octree.
vtkIncrementalOctreePointLocator::FindClosestNPoints
void FindClosestNPoints(int N, const double x[3], vtkIdList *result) override
Find the closest N points to a given point.
vtkIncrementalOctreePointLocator::FindPointsWithinRadius
void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result) override
Find all points within a radius R relative to a given point x.
vtkIncrementalOctreePointLocator::FindClosestPoint
vtkIdType FindClosestPoint(const double x[3]) override
Given a point x, return the id of the closest point.
vtkIncrementalOctreePointLocator::FreeSearchStructure
void FreeSearchStructure() override
Delete the octree search structure.
vtkIncrementalOctreePointLocator::FindClosestPoint
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...
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
vtkIncrementalOctreePointLocator::Initialize
void Initialize() override
Delete the octree search structure.
Definition: vtkIncrementalOctreePointLocator.h:107
vtkLocator::FreeSearchStructure
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
vtkX3D::radius
@ radius
Definition: vtkX3D.h:252
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkIncrementalOctreePointLocator::FindClosestPoint
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 ...
vtkIncrementalOctreePointLocator::FindClosestInsertedPoint
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 ...