VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkOctreePointLocator.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*---------------------------------------------------------------------------- 00016 Copyright (c) Sandia Corporation 00017 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details. 00018 ----------------------------------------------------------------------------*/ 00019 00039 #ifndef __vtkOctreePointLocator_h 00040 #define __vtkOctreePointLocator_h 00041 00042 #include "vtkAbstractPointLocator.h" 00043 00044 class vtkCellArray; 00045 class vtkIdTypeArray; 00046 class vtkOctreePointLocatorNode; 00047 class vtkPoints; 00048 class vtkPolyData; 00049 00050 class VTK_FILTERING_EXPORT vtkOctreePointLocator : public vtkAbstractPointLocator 00051 { 00052 public: 00053 vtkTypeMacro(vtkOctreePointLocator, vtkAbstractPointLocator); 00054 void PrintSelf(ostream& os, vtkIndent indent); 00055 00056 static vtkOctreePointLocator *New(); 00057 00059 00060 vtkSetMacro(MaximumPointsPerRegion, int); 00061 vtkGetMacro(MaximumPointsPerRegion, int); 00063 00065 00066 vtkSetMacro(CreateCubicOctants, int); 00067 vtkGetMacro(CreateCubicOctants, int); 00069 00071 00075 vtkGetMacro(FudgeFactor, double); 00076 vtkSetMacro(FudgeFactor, double); 00078 00080 00082 virtual double *GetBounds(); 00083 virtual void GetBounds(double *bounds); 00085 00087 00088 vtkGetMacro(NumberOfLeafNodes, int); 00090 00092 void GetRegionBounds(int regionID, double bounds[6]); 00093 00095 void GetRegionDataBounds(int leafNodeID, double bounds[6]); 00096 00098 int GetRegionContainingPoint(double x, double y, double z); 00099 00103 virtual void BuildLocator(); 00104 00106 00108 virtual vtkIdType FindClosestPoint(const double x[3]); 00109 vtkIdType FindClosestPoint(double x, double y, double z, double &dist2); 00111 00113 00116 virtual vtkIdType FindClosestPointWithinRadius( 00117 double radius, const double x[3], double& dist2); 00119 00121 00124 vtkIdType FindClosestPointInRegion(int regionId, double *x, double &dist2); 00125 vtkIdType FindClosestPointInRegion(int regionId, double x, double y, 00126 double z, double &dist2); 00128 00130 00132 virtual void FindPointsWithinRadius( 00133 double radius, const double x[3], vtkIdList *result); 00135 00142 void FindClosestNPoints(int N, const double x[3], vtkIdList *result); 00143 00145 vtkIdTypeArray *GetPointsInRegion(int leafNodeId); 00146 00148 virtual void FreeSearchStructure(); 00149 00152 void GenerateRepresentation(int level, vtkPolyData *pd); 00153 00158 void FindPointsInArea(double* area, vtkIdTypeArray* ids, bool clearArray = true); 00159 00160 protected: 00161 00162 vtkOctreePointLocator(); 00163 ~vtkOctreePointLocator(); 00164 00165 vtkOctreePointLocatorNode *Top; 00166 vtkOctreePointLocatorNode **LeafNodeList; // indexed by region/node ID 00167 00168 void BuildLeafNodeList(vtkOctreePointLocatorNode* node, int & index); 00169 00171 00173 int FindRegion(vtkOctreePointLocatorNode* node, float x, float y, float z); 00174 int FindRegion(vtkOctreePointLocatorNode* node, double x, double y, double z); 00176 00177 static void SetDataBoundsToSpatialBounds(vtkOctreePointLocatorNode *node); 00178 00179 static void DeleteAllDescendants(vtkOctreePointLocatorNode* octant); 00180 00181 //BTX 00183 00186 void FindPointsWithinRadius(vtkOctreePointLocatorNode* node, double radiusSquared, 00187 const double x[3], vtkIdList* ids); 00189 00190 // Recursive helper for public FindPointsWithinRadius 00191 void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdList* ids); 00192 00193 // Recursive helper for public FindPointsInArea 00194 void FindPointsInArea(vtkOctreePointLocatorNode* node, double* area, vtkIdTypeArray* ids); 00195 00196 // Recursive helper for public FindPointsInArea 00197 void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdTypeArray* ids); 00198 00199 void DivideRegion(vtkOctreePointLocatorNode *node, int* ordering, int level); 00200 00201 int DivideTest(int size, int level); 00202 00203 //ETX 00204 00205 void AddPolys(vtkOctreePointLocatorNode *node, vtkPoints *pts, vtkCellArray *polys); 00206 00208 00210 int _FindClosestPointInRegion(int leafNodeId, double x, double y, 00211 double z, double &dist2); 00213 00215 00220 int FindClosestPointInSphere(double x, double y, double z, double radius, 00221 int skipRegion, double &dist2); 00223 00225 00227 int MaximumPointsPerRegion; 00228 int NumberOfLeafNodes; 00230 00231 double FudgeFactor; // a very small distance, relative to the dataset's size 00232 int NumberOfLocatorPoints; 00233 float *LocatorPoints; 00234 int *LocatorIds; 00235 00236 float MaxWidth; 00237 00243 int CreateCubicOctants; 00244 00245 vtkOctreePointLocator(const vtkOctreePointLocator&); // Not implemented 00246 void operator=(const vtkOctreePointLocator&); // Not implemented 00247 }; 00248 #endif