VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
43 #include "vtkAbstractPointLocator.h"
44 
45 class vtkCellArray;
46 class vtkIdTypeArray;
47 class vtkOctreePointLocatorNode;
48 class vtkPoints;
49 class vtkPolyData;
50 
51 class VTKCOMMONDATAMODEL_EXPORT vtkOctreePointLocator : public vtkAbstractPointLocator
52 {
53 public:
54  vtkTypeMacro(vtkOctreePointLocator, vtkAbstractPointLocator);
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 
117  virtual vtkIdType FindClosestPointWithinRadius(
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 
153  void GenerateRepresentation(int level, vtkPolyData *pd);
154 
159  void FindPointsInArea(double* area, vtkIdTypeArray* ids, bool clearArray = true);
160 
161 protected:
162 
165 
166  vtkOctreePointLocatorNode *Top;
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
a octree spatial decomposition of a set of points
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:268
vtkOctreePointLocatorNode ** LeafNodeList
a simple class to control print indentation
Definition: vtkIndent.h:38
list of point or cell ids
Definition: vtkIdList.h:35
vtkOctreePointLocatorNode * Top
represent and manipulate 3D points
Definition: vtkPoints.h:39