VTK
dox/Filtering/vtkIncrementalOctreePointLocator.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkIncrementalOctreePointLocator.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 =========================================================================*/
00050 #ifndef __vtkIncrementalOctreePointLocator_h
00051 #define __vtkIncrementalOctreePointLocator_h
00052 
00053 #include "vtkIncrementalPointLocator.h"
00054 
00055 class vtkPoints;
00056 class vtkIdList;
00057 class vtkPolyData;
00058 class vtkCellArray;
00059 class vtkIncrementalOctreeNode;
00060 
00061 class VTK_FILTERING_EXPORT vtkIncrementalOctreePointLocator : public vtkIncrementalPointLocator
00062 {
00063 public:
00064  
00065   vtkTypeMacro( vtkIncrementalOctreePointLocator, vtkIncrementalPointLocator );
00066   void PrintSelf( ostream & os, vtkIndent indent );
00067 
00068   static vtkIncrementalOctreePointLocator * New();
00069   
00071 
00079   vtkSetClampMacro( MaxPointsPerLeaf, int, 16, 256 );
00080   vtkGetMacro( MaxPointsPerLeaf, int );
00082   
00084 
00085   vtkSetMacro( BuildCubicOctree, int );
00086   vtkGetMacro( BuildCubicOctree, int );
00087   vtkBooleanMacro( BuildCubicOctree, int );
00089   
00091 
00093   vtkGetObjectMacro( LocatorPoints, vtkPoints );
00095   
00097   virtual void Initialize() { this->FreeSearchStructure(); }
00098   
00100   virtual void FreeSearchStructure();
00101   
00103   virtual void GetBounds( double * bounds );
00104   
00106 
00107   virtual double * GetBounds()
00108     { this->GetBounds( this->Bounds );  return this->Bounds; }
00110   
00112   int GetNumberOfPoints();
00113   
00120   virtual vtkIdType FindClosestInsertedPoint( const double x[3] );
00121   
00124   virtual void GenerateRepresentation( int nodeLevel, vtkPolyData * polysData );
00125   
00126   // -------------------------------------------------------------------------
00127   // ---------------------------- Point  Location ----------------------------
00128   // -------------------------------------------------------------------------
00129   
00133   virtual void BuildLocator();
00134   
00139   virtual vtkIdType FindClosestPoint( const double x[3] );
00140   
00145   virtual vtkIdType FindClosestPoint( double x, double y, double z );
00146   
00152   virtual vtkIdType FindClosestPoint( const double x[3], double * miniDist2 );
00153   
00159   virtual vtkIdType FindClosestPoint( double x, double y, double z, double * miniDist2 );
00160   
00162 
00168   virtual vtkIdType FindClosestPointWithinRadius
00169     ( double radius, const double x[3], double & dist2 );
00171     
00173 
00179   vtkIdType FindClosestPointWithinSquaredRadius
00180     ( double radius2, const double x[3], double & dist2 );
00182     
00184 
00189   virtual void FindPointsWithinRadius
00190     ( double R, const double x[3], vtkIdList * result );
00192   
00194 
00199   void FindPointsWithinSquaredRadius
00200     ( double R2, const double x[3], vtkIdList * result );
00202                                       
00204 
00209   virtual void FindClosestNPoints
00210     ( int N, const double x[3], vtkIdList * result );
00212                        
00213   // -------------------------------------------------------------------------
00214   // ---------------------------- Point Insertion ----------------------------
00215   // -------------------------------------------------------------------------
00216   
00224   virtual int InitPointInsertion( vtkPoints * points, const double bounds[6] );
00225 
00227 
00235   virtual int InitPointInsertion( vtkPoints * points, const double bounds[6], 
00236                                   vtkIdType estSize );                            
00238   
00243   virtual vtkIdType IsInsertedPoint( const double x[3] );
00244   
00249   virtual vtkIdType IsInsertedPoint( double x, double  y, double z );
00250   
00258   virtual int InsertUniquePoint( const double point[3], vtkIdType & pntId );
00259   
00267   virtual void InsertPoint( vtkIdType ptId, const double x[3] );
00268   
00276   virtual vtkIdType InsertNextPoint( const double x[3] );
00277   
00279 
00286   void InsertPointWithoutChecking
00287     ( const double point[3], vtkIdType  & pntId, int insert );
00289 
00290 //BTX
00291 protected:
00292 
00293   vtkIncrementalOctreePointLocator();
00294   virtual ~vtkIncrementalOctreePointLocator();
00295   
00296 private:
00297 
00298   int         BuildCubicOctree;
00299   int         MaxPointsPerLeaf;
00300   double      InsertTolerance2;
00301   double      OctreeMaxDimSize;
00302   double      FudgeFactor;
00303   vtkPoints * LocatorPoints;
00304   vtkIncrementalOctreeNode * OctreeRootNode;
00305   
00307   static void DeleteAllDescendants( vtkIncrementalOctreeNode * node );
00308   
00310 
00312   static void AddPolys( vtkIncrementalOctreeNode * node, 
00313                         vtkPoints * points, vtkCellArray * polygs );
00315   
00317 
00320   vtkIncrementalOctreeNode * GetLeafContainer( vtkIncrementalOctreeNode * node,
00321     const double pnt[3] ); 
00323   
00325 
00331   vtkIdType FindClosestPointInLeafNode( vtkIncrementalOctreeNode * leafNode, 
00332                                         const double point[3], double * dist2 );
00334 
00336 
00347   vtkIdType FindClosestPointInSphere
00348     ( const double point[3], double radius2, vtkIncrementalOctreeNode * maskNode,
00349       double * minDist2, const double * refDist2 );
00351       
00352       
00353   // -------------------------------------------------------------------------
00354   // ---------------------------- Point  Location ----------------------------
00355   // -------------------------------------------------------------------------
00356   
00358 
00367   vtkIdType FindClosestPointInSphereWithoutTolerance( const double point[3],
00368     double radius2, vtkIncrementalOctreeNode * maskNode, double * minDist2 );
00370     
00372 
00376   void FindPointsWithinSquaredRadius( vtkIncrementalOctreeNode * node, 
00377     double radius2, const double point[3], vtkIdList * idList );
00379   
00380   // -------------------------------------------------------------------------
00381   // ---------------------------- Point Insertion ----------------------------
00382   // -------------------------------------------------------------------------
00383   
00385 
00395   vtkIdType FindClosestPointInSphereWithTolerance( const double point[3],
00396     double radius2, vtkIncrementalOctreeNode * maskNode, double * minDist2 );
00398     
00400 
00408   vtkIdType IsInsertedPoint( const double x[3], 
00409                              vtkIncrementalOctreeNode ** leafContainer );
00411   
00413 
00420   vtkIdType IsInsertedPointForZeroTolerance
00421     ( const double x[3], vtkIncrementalOctreeNode ** leafContainer );
00423     
00425 
00433   vtkIdType IsInsertedPointForNonZeroTolerance
00434     ( const double x[3], vtkIncrementalOctreeNode ** leafContainer );
00436                               
00438 
00443   vtkIdType FindDuplicatePointInLeafNode( vtkIncrementalOctreeNode * leafNode, 
00444                                           const double point[3] );
00446 
00448 
00454   vtkIdType FindDuplicateFloatTypePointInVisitedLeafNode
00455     ( vtkIncrementalOctreeNode * leafNode, const double point[3] );
00457 
00459 
00465   vtkIdType FindDuplicateDoubleTypePointInVisitedLeafNode
00466     ( vtkIncrementalOctreeNode * leafNode, const double point[3] );
00468                          
00469   vtkIncrementalOctreePointLocator
00470     ( const vtkIncrementalOctreePointLocator & ); // Not implemented
00471   void operator = ( const vtkIncrementalOctreePointLocator & );// Not implemented
00472 //ETX
00473 };
00474 #endif