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

vtkOBBTree.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkOBBTree.h,v $
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 =========================================================================*/
00068 #ifndef __vtkOBBTree_h
00069 #define __vtkOBBTree_h
00070 
00071 #include "vtkCellLocator.h"
00072 
00073 class vtkMatrix4x4;
00074 
00075 // Special class defines node for the OBB tree
00076 //
00077 //BTX
00078 //
00079 class vtkOBBNode { //;prevent man page generation
00080 public:
00081   vtkOBBNode();
00082   ~vtkOBBNode();
00083 
00084   double Corner[3]; //center point of this node
00085   double Axes[3][3]; //the axes defining the OBB - ordered from long->short
00086   vtkOBBNode *Parent; //parent node; NULL if root
00087   vtkOBBNode **Kids; //two children of this node; NULL if leaf
00088   vtkIdList *Cells; //list of cells in node
00089   void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00090                        int *maxCells );
00091 };
00092 //ETX
00093 //
00094 
00095 class VTK_GRAPHICS_EXPORT vtkOBBTree : public vtkCellLocator
00096 {
00097 public:
00098   vtkTypeRevisionMacro(vtkOBBTree,vtkCellLocator);
00099   void PrintSelf(ostream& os, vtkIndent indent);
00100 
00103   static vtkOBBTree *New();
00104 
00106 
00109   void ComputeOBB(vtkPoints *pts, double corner[3], double max[3], 
00110                   double mid[3], double min[3], double size[3]);
00112 
00114 
00118   void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
00119                   double mid[3], double min[3], double size[3]);
00121 
00126   int InsideOrOutside(const double point[3]);
00127 
00129 
00137   int IntersectWithLine(const double a0[3], const double a1[3],
00138                         vtkPoints *points, vtkIdList *cellIds);
00140 
00142 
00145   int IntersectWithLine(double a0[3], double a1[3], double tol,
00146                         double& t, double x[3], double pcoords[3],
00147                         int &subId);
00149 
00150   int IntersectWithLine(double a0[3], double a1[3], double tol,
00151                         double& t, double x[3], double pcoords[3],
00152                         int &subId, vtkIdType &cellId);
00153   
00154   int IntersectWithLine(double a0[3], double a1[3], double tol,
00155                         double& t, double x[3], double pcoords[3],
00156                         int &subId, vtkIdType &cellId, vtkGenericCell *cell);
00157 
00158   //BTX
00159 
00161 
00163   int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00164                         vtkMatrix4x4 *XformBtoA );
00166 
00168   int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
00169 
00171 
00172   int TriangleIntersectsNode( vtkOBBNode *pA,
00173                               double p0[3], double p1[3],
00174                               double p2[3], vtkMatrix4x4 *XformBtoA );
00176 
00178 
00180   int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00181                             int(*function)( vtkOBBNode *nodeA,
00182                                             vtkOBBNode *nodeB,
00183                                             vtkMatrix4x4 *Xform,
00184                                             void *arg ),
00185                             void *data_arg );
00186   //ETX
00188 
00190 
00191   void FreeSearchStructure();
00192   void BuildLocator();
00194 
00203   void GenerateRepresentation(int level, vtkPolyData *pd);
00204 
00205   //BTX
00206 protected:
00207   vtkOBBTree();
00208   ~vtkOBBTree();
00209 
00210   // Compute an OBB from the list of cells given.  This used to be
00211   // public but should not have been.  A public call has been added
00212   // so that the functionality can be accessed.
00213   void ComputeOBB(vtkIdList *cells, double corner[3], double max[3], 
00214                        double mid[3], double min[3], double size[3]);
00215 
00216   vtkOBBNode *Tree;
00217   void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00218   vtkPoints *PointsList;
00219   int *InsertedPoints;
00220   int OBBCount;
00221   int DeepestLevel;
00222 
00223   void DeleteTree(vtkOBBNode *OBBptr);
00224   void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, 
00225                         vtkPoints* pts, vtkCellArray *polys);
00226 
00227   //ETX
00228 private:
00229   vtkOBBTree(const vtkOBBTree&);  // Not implemented.
00230   void operator=(const vtkOBBTree&);  // Not implemented.
00231 };
00232 
00233 #endif