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 "vtkCommonDataModelModule.h" // For export macro 00043 #include "vtkAbstractPointLocator.h" 00044 00045 class vtkCellArray; 00046 class vtkIdTypeArray; 00047 class vtkOctreePointLocatorNode; 00048 class vtkPoints; 00049 class vtkPolyData; 00050 00051 class VTKCOMMONDATAMODEL_EXPORT vtkOctreePointLocator : public vtkAbstractPointLocator 00052 { 00053 public: 00054 vtkTypeMacro(vtkOctreePointLocator, vtkAbstractPointLocator); 00055 void PrintSelf(ostream& os, vtkIndent indent); 00056 00057 static vtkOctreePointLocator *New(); 00058 00060 00061 vtkSetMacro(MaximumPointsPerRegion, int); 00062 vtkGetMacro(MaximumPointsPerRegion, int); 00064 00066 00067 vtkSetMacro(CreateCubicOctants, int); 00068 vtkGetMacro(CreateCubicOctants, int); 00070 00072 00076 vtkGetMacro(FudgeFactor, double); 00077 vtkSetMacro(FudgeFactor, double); 00079 00081 00083 virtual double *GetBounds(); 00084 virtual void GetBounds(double *bounds); 00086 00088 00089 vtkGetMacro(NumberOfLeafNodes, int); 00091 00093 void GetRegionBounds(int regionID, double bounds[6]); 00094 00096 void GetRegionDataBounds(int leafNodeID, double bounds[6]); 00097 00099 int GetRegionContainingPoint(double x, double y, double z); 00100 00104 virtual void BuildLocator(); 00105 00107 00109 virtual vtkIdType FindClosestPoint(const double x[3]); 00110 vtkIdType FindClosestPoint(double x, double y, double z, double &dist2); 00112 00114 00117 virtual vtkIdType FindClosestPointWithinRadius( 00118 double radius, const double x[3], double& dist2); 00120 00122 00125 vtkIdType FindClosestPointInRegion(int regionId, double *x, double &dist2); 00126 vtkIdType FindClosestPointInRegion(int regionId, double x, double y, 00127 double z, double &dist2); 00129 00131 00133 virtual void FindPointsWithinRadius( 00134 double radius, const double x[3], vtkIdList *result); 00136 00143 void FindClosestNPoints(int N, const double x[3], vtkIdList *result); 00144 00146 vtkIdTypeArray *GetPointsInRegion(int leafNodeId); 00147 00149 virtual void FreeSearchStructure(); 00150 00153 void GenerateRepresentation(int level, vtkPolyData *pd); 00154 00159 void FindPointsInArea(double* area, vtkIdTypeArray* ids, bool clearArray = true); 00160 00161 protected: 00162 00163 vtkOctreePointLocator(); 00164 ~vtkOctreePointLocator(); 00165 00166 vtkOctreePointLocatorNode *Top; 00167 vtkOctreePointLocatorNode **LeafNodeList; // indexed by region/node ID 00168 00169 void BuildLeafNodeList(vtkOctreePointLocatorNode* node, int & index); 00170 00172 00174 int FindRegion(vtkOctreePointLocatorNode* node, float x, float y, float z); 00175 int FindRegion(vtkOctreePointLocatorNode* node, double x, double y, double z); 00177 00178 static void SetDataBoundsToSpatialBounds(vtkOctreePointLocatorNode *node); 00179 00180 static void DeleteAllDescendants(vtkOctreePointLocatorNode* octant); 00181 00182 //BTX 00184 00187 void FindPointsWithinRadius(vtkOctreePointLocatorNode* node, double radiusSquared, 00188 const double x[3], vtkIdList* ids); 00190 00191 // Recursive helper for public FindPointsWithinRadius 00192 void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdList* ids); 00193 00194 // Recursive helper for public FindPointsInArea 00195 void FindPointsInArea(vtkOctreePointLocatorNode* node, double* area, vtkIdTypeArray* ids); 00196 00197 // Recursive helper for public FindPointsInArea 00198 void AddAllPointsInRegion(vtkOctreePointLocatorNode* node, vtkIdTypeArray* ids); 00199 00200 void DivideRegion(vtkOctreePointLocatorNode *node, int* ordering, int level); 00201 00202 int DivideTest(int size, int level); 00203 00204 //ETX 00205 00206 void AddPolys(vtkOctreePointLocatorNode *node, vtkPoints *pts, vtkCellArray *polys); 00207 00209 00211 int _FindClosestPointInRegion(int leafNodeId, double x, double y, 00212 double z, double &dist2); 00214 00216 00221 int FindClosestPointInSphere(double x, double y, double z, double radius, 00222 int skipRegion, double &dist2); 00224 00226 00228 int MaximumPointsPerRegion; 00229 int NumberOfLeafNodes; 00231 00232 double FudgeFactor; // a very small distance, relative to the dataset's size 00233 int NumberOfLocatorPoints; 00234 float *LocatorPoints; 00235 int *LocatorIds; 00236 00237 float MaxWidth; 00238 00244 int CreateCubicOctants; 00245 00246 vtkOctreePointLocator(const vtkOctreePointLocator&); // Not implemented 00247 void operator=(const vtkOctreePointLocator&); // Not implemented 00248 }; 00249 #endif