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 
39 #ifndef vtkOctreePointLocator_h
40 #define vtkOctreePointLocator_h
41 
42 #include "vtkCommonDataModelModule.h" // For export macro
44 
45 class vtkCellArray;
46 class vtkIdTypeArray;
48 class vtkPoints;
49 class vtkPolyData;
50 
52 {
53 public:
55  void PrintSelf(ostream& os, vtkIndent indent);
56 
57  static vtkOctreePointLocator *New();
58 
60 
61  vtkSetMacro(MaximumPointsPerRegion, int);
62  vtkGetMacro(MaximumPointsPerRegion, int);
64 
66 
67  vtkSetMacro(CreateCubicOctants, int);
68  vtkGetMacro(CreateCubicOctants, int);
70 
72 
76  vtkGetMacro(FudgeFactor, double);
77  vtkSetMacro(FudgeFactor, double);
79 
81 
83  virtual double *GetBounds();
84  virtual void GetBounds(double *bounds);
86 
88 
89  vtkGetMacro(NumberOfLeafNodes, int);
91 
93  void GetRegionBounds(int regionID, double bounds[6]);
94 
96  void GetRegionDataBounds(int leafNodeID, double bounds[6]);
97 
99  int GetRegionContainingPoint(double x, double y, double z);
100 
104  virtual void BuildLocator();
105 
107 
109  virtual vtkIdType FindClosestPoint(const double x[3]);
110  vtkIdType FindClosestPoint(double x, double y, double z, double &dist2);
112 
114 
118  double radius, const double x[3], double& dist2);
120 
122 
125  vtkIdType FindClosestPointInRegion(int regionId, double *x, double &dist2);
126  vtkIdType FindClosestPointInRegion(int regionId, double x, double y,
127  double z, double &dist2);
129 
131 
133  virtual void FindPointsWithinRadius(
134  double radius, const double x[3], vtkIdList *result);
136 
143  void FindClosestNPoints(int N, const double x[3], vtkIdList *result);
144 
146  vtkIdTypeArray *GetPointsInRegion(int leafNodeId);
147 
149  virtual void FreeSearchStructure();
150 
154 
159  void FindPointsInArea(double* area, vtkIdTypeArray* ids, bool clearArray = true);
160 
161 protected:
162 
165 
167  vtkOctreePointLocatorNode **LeafNodeList; // indexed by region/node ID
168 
169  void BuildLeafNodeList(vtkOctreePointLocatorNode* node, int & index);
170 
172 
174  int FindRegion(vtkOctreePointLocatorNode* node, float x, float y, float z);
175  int FindRegion(vtkOctreePointLocatorNode* node, double x, double y, double z);
177 
178  static void SetDataBoundsToSpatialBounds(vtkOctreePointLocatorNode *node);
179 
180  static void DeleteAllDescendants(vtkOctreePointLocatorNode* octant);
181 
182 //BTX
184 
187  void FindPointsWithinRadius(vtkOctreePointLocatorNode* node, double radiusSquared,
188  const double x[3], vtkIdList* ids);
190 
191  // Recursive helper for public FindPointsWithinRadius
192  void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdList* ids);
193 
194  // Recursive helper for public FindPointsInArea
195  void FindPointsInArea(vtkOctreePointLocatorNode* node, double* area, vtkIdTypeArray* ids);
196 
197  // Recursive helper for public FindPointsInArea
198  void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdTypeArray* ids);
199 
200  void DivideRegion(vtkOctreePointLocatorNode *node, int* ordering, int level);
201 
202  int DivideTest(int size, int level);
203 
204 //ETX
205 
206  void AddPolys(vtkOctreePointLocatorNode *node, vtkPoints *pts, vtkCellArray *polys);
207 
209 
211  int _FindClosestPointInRegion(int leafNodeId, double x, double y,
212  double z, double &dist2);
214 
216 
221  int FindClosestPointInSphere(double x, double y, double z, double radius,
222  int skipRegion, double &dist2);
224 
226 
231 
232  double FudgeFactor; // a very small distance, relative to the dataset's size
236 
237  float MaxWidth;
238 
245 
246  vtkOctreePointLocator(const vtkOctreePointLocator&); // Not implemented
247  void operator=(const vtkOctreePointLocator&); // Not implemented
248 };
249 #endif
virtual void FreeSearchStructure()=0
an octree spatial decomposition of a set of points
virtual vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double &dist2)=0
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:275
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
vtkOctreePointLocatorNode ** LeafNodeList
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:35
void PrintSelf(ostream &os, vtkIndent indent)
virtual void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result)=0
virtual void FindClosestNPoints(int N, const double x[3], vtkIdList *result)=0
object to represent cell connectivity
Definition: vtkCellArray.h:49
Octree node that has 8 children each of equal size.
vtkOctreePointLocatorNode * Top
virtual vtkIdType FindClosestPoint(const double x[3])=0
virtual void BuildLocator()=0
static vtkObject * New()
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
#define VTKCOMMONDATAMODEL_EXPORT
represent and manipulate 3D points
Definition: vtkPoints.h:38