Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Filtering/vtkCellLocator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkCellLocator.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00044 #ifndef __vtkCellLocator_h
00045 #define __vtkCellLocator_h
00046 
00047 #include "vtkLocator.h"
00048 
00049 class vtkCellArray;
00050 class vtkGenericCell;
00051 class vtkIdList;
00052 class vtkNeighborCells;
00053 class vtkPoints;
00054 
00055 class VTK_FILTERING_EXPORT vtkCellLocator : public vtkLocator
00056 {
00057 public:
00058   vtkTypeRevisionMacro(vtkCellLocator,vtkLocator);
00059   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00063   static vtkCellLocator *New();
00064 
00066 
00067   vtkSetClampMacro(NumberOfCellsPerBucket,int,1,VTK_LARGE_INTEGER);
00068   vtkGetMacro(NumberOfCellsPerBucket,int);
00070 
00072 
00077   vtkSetMacro(CacheCellBounds,int);
00078   vtkGetMacro(CacheCellBounds,int);
00079   vtkBooleanMacro(CacheCellBounds,int);
00081 
00083 
00085   virtual int IntersectWithLine(float a0[3], float a1[3], float tol,
00086                                 float& t, float x[3], float pcoords[3],
00087                                 int &subId);
00089 
00091 
00093   virtual int IntersectWithLine(float a0[3], float a1[3], float tol,
00094                                 float& t, float x[3], float pcoords[3],
00095                                 int &subId, vtkIdType &cellId);
00097 
00099 
00102   virtual int IntersectWithLine(float a0[3], float a1[3], float tol,
00103                                 float& t, float x[3], float pcoords[3],
00104                                 int &subId, vtkIdType &cellId,
00105                                 vtkGenericCell *cell);
00107 
00109 
00112   void FindClosestPoint(float x[3], float closestPoint[3], vtkIdType &cellId,
00113                         int &subId, float& dist2);
00115   
00117 
00126   void FindClosestPoint(float x[3], float closestPoint[3],
00127                         vtkGenericCell *cell, vtkIdType &cellId, int &subId,
00128                         float& dist2);
00130   
00132 
00138   int FindClosestPointWithinRadius(float x[3], float radius,
00139                                    float closestPoint[3], vtkIdType &cellId,
00140                                    int &subId, float& dist2);
00142  
00144 
00157   int FindClosestPointWithinRadius(float x[3], float radius,
00158                                    float closestPoint[3],
00159                                    vtkGenericCell *cell, vtkIdType &cellId,
00160                                    int &subId, float& dist2);
00162 
00164 
00179   int FindClosestPointWithinRadius(float x[3], float radius,
00180                                    float closestPoint[3],
00181                                    vtkGenericCell *cell, vtkIdType &cellId,
00182                                    int &subId, float& dist2, int &inside);
00184   
00186   virtual vtkIdList *GetCells(int bucket);
00187 
00190   virtual int GetNumberOfBuckets(void);
00191 
00193 
00194   void FreeSearchStructure();
00195   void BuildLocator();
00196   void GenerateRepresentation(int level, vtkPolyData *pd);
00198   
00199 protected:
00200   vtkCellLocator();
00201   ~vtkCellLocator();
00202 
00203   void GetBucketNeighbors(int ijk[3], int ndivs, int level);
00204   void GetOverlappingBuckets(float x[3], int ijk[3], float dist, 
00205                              int prevMinLevel[3], int prevMaxLevel[3]);
00206 
00207   void ClearCellHasBeenVisited();
00208   void ClearCellHasBeenVisited(int id);
00209 
00210   float Distance2ToBucket(float x[3], int nei[3]);
00211   float Distance2ToBounds(float x[3], float bounds[6]);
00212   
00213   int NumberOfCellsPerBucket; // cells per octant
00214   int NumberOfOctants; // number of octants in tree
00215   float Bounds[6]; // bounding box root octant
00216   int NumberOfParents; // number of parent octants
00217   float H[3]; // width of leaf octant in x-y-z directions
00218   int NumberOfDivisions; // number of "leaf" octant sub-divisions
00219   vtkIdList **Tree; // octree
00220 
00221   void MarkParents(void*, int, int, int, int, int);
00222   void GetChildren(int idx, int level, int children[8]);
00223   int GenerateIndex(int offset, int numDivs, int i, int j, int k,
00224                     vtkIdType &idx);
00225   void GenerateFace(int face, int numDivs, int i, int j, int k,
00226                     vtkPoints *pts, vtkCellArray *polys);
00227 
00228   vtkNeighborCells *Buckets;
00229   unsigned char *CellHasBeenVisited;
00230   unsigned char QueryNumber;
00231   int CacheCellBounds;
00232 //BTX - begin tcl exclude
00233   float (*CellBounds)[6];
00234 //ETX - end tcl exclude
00235 private:
00236   vtkCellLocator(const vtkCellLocator&);  // Not implemented.
00237   void operator=(const vtkCellLocator&);  // Not implemented.
00238 };
00239 
00240 #endif
00241 
00242