VTK
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 
37 #ifndef vtkOctreePointLocator_h
38 #define vtkOctreePointLocator_h
39 
40 #include "vtkCommonDataModelModule.h" // For export macro
42 
43 class vtkCellArray;
44 class vtkIdTypeArray;
46 class vtkPoints;
47 class vtkPolyData;
48 
49 class VTKCOMMONDATAMODEL_EXPORT vtkOctreePointLocator : public vtkAbstractPointLocator
50 {
51 public:
53  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
54 
55  static vtkOctreePointLocator *New();
56 
58 
61  vtkSetMacro(MaximumPointsPerRegion, int);
62  vtkGetMacro(MaximumPointsPerRegion, int);
64 
66 
69  vtkSetMacro(CreateCubicOctants, int);
70  vtkGetMacro(CreateCubicOctants, int);
72 
74 
80  vtkGetMacro(FudgeFactor, double);
81  vtkSetMacro(FudgeFactor, double);
83 
85 
89  double *GetBounds() VTK_OVERRIDE;
90  void GetBounds(double *bounds) VTK_OVERRIDE;
92 
94 
97  vtkGetMacro(NumberOfLeafNodes, int);
99 
103  void GetRegionBounds(int regionID, double bounds[6]);
104 
108  void GetRegionDataBounds(int leafNodeID, double bounds[6]);
109 
113  int GetRegionContainingPoint(double x, double y, double z);
114 
120  void BuildLocator() VTK_OVERRIDE;
121 
123 
127  vtkIdType FindClosestPoint(const double x[3]) VTK_OVERRIDE;
128  vtkIdType FindClosestPoint(double x, double y, double z, double &dist2);
130 
136  vtkIdType FindClosestPointWithinRadius(
137  double radius, const double x[3], double& dist2) VTK_OVERRIDE;
138 
140 
145  vtkIdType FindClosestPointInRegion(int regionId, double *x, double &dist2);
146  vtkIdType FindClosestPointInRegion(int regionId, double x, double y,
147  double z, double &dist2);
149 
154  void FindPointsWithinRadius(
155  double radius, const double x[3], vtkIdList *result) VTK_OVERRIDE;
156 
165  void FindClosestNPoints(int N, const double x[3],
166  vtkIdList *result) VTK_OVERRIDE;
167 
171  vtkIdTypeArray *GetPointsInRegion(int leafNodeId);
172 
176  void FreeSearchStructure() VTK_OVERRIDE;
177 
182  void GenerateRepresentation(int level, vtkPolyData *pd) VTK_OVERRIDE;
183 
190  void FindPointsInArea(double* area, vtkIdTypeArray* ids, bool clearArray = true);
191 
192 protected:
193 
195  ~vtkOctreePointLocator() VTK_OVERRIDE;
196 
198  vtkOctreePointLocatorNode **LeafNodeList; // indexed by region/node ID
199 
200  void BuildLeafNodeList(vtkOctreePointLocatorNode* node, int & index);
201 
203 
207  int FindRegion(vtkOctreePointLocatorNode* node, float x, float y, float z);
208  int FindRegion(vtkOctreePointLocatorNode* node, double x, double y, double z);
210 
211  static void SetDataBoundsToSpatialBounds(vtkOctreePointLocatorNode *node);
212 
213  static void DeleteAllDescendants(vtkOctreePointLocatorNode* octant);
214 
220  void FindPointsWithinRadius(vtkOctreePointLocatorNode* node, double radiusSquared,
221  const double x[3], vtkIdList* ids);
222 
223  // Recursive helper for public FindPointsWithinRadius
224  void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdList* ids);
225 
226  // Recursive helper for public FindPointsInArea
227  void FindPointsInArea(vtkOctreePointLocatorNode* node, double* area, vtkIdTypeArray* ids);
228 
229  // Recursive helper for public FindPointsInArea
230  void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdTypeArray* ids);
231 
232  void DivideRegion(vtkOctreePointLocatorNode *node, int* ordering, int level);
233 
234  int DivideTest(int size, int level);
235 
236  void AddPolys(vtkOctreePointLocatorNode *node, vtkPoints *pts, vtkCellArray *polys);
237 
242  int _FindClosestPointInRegion(int leafNodeId, double x, double y,
243  double z, double &dist2);
244 
252  int FindClosestPointInSphere(double x, double y, double z, double radius,
253  int skipRegion, double &dist2);
254 
256 
259  int MaximumPointsPerRegion;
260  int NumberOfLeafNodes;
262 
263  double FudgeFactor; // a very small distance, relative to the dataset's size
264  int NumberOfLocatorPoints;
265  float *LocatorPoints;
266  int *LocatorIds;
267 
268  float MaxWidth;
269 
277  int CreateCubicOctants;
278 
279  vtkOctreePointLocator(const vtkOctreePointLocator&) VTK_DELETE_FUNCTION;
280  void operator=(const vtkOctreePointLocator&) VTK_DELETE_FUNCTION;
281 };
282 #endif
an octree spatial decomposition of a set of points
virtual double * GetBounds()
Provide an accessor to the bounds.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
a simple class to control print indentation
Definition: vtkIndent.h:33
void PrintSelf(ostream &os, vtkIndent indent) override
Standard type and print methods.
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:30
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
object to represent cell connectivity
Definition: vtkCellArray.h:44
Octree node that has 8 children each of equal size.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
represent and manipulate 3D points
Definition: vtkPoints.h:33