Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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 =========================================================================*/
00055 #ifndef __vtkOBBTree_h
00056 #define __vtkOBBTree_h
00057 
00058 #include "vtkCellLocator.h"
00059 
00060 class vtkMatrix4x4;
00061 
00062 // Special class defines node for the OBB tree
00063 //
00064 //BTX
00065 //
00066 class vtkOBBNode { //;prevent man page generation
00067 public:
00068   vtkOBBNode();
00069   ~vtkOBBNode();
00070 
00071   double Corner[3]; //center point of this node
00072   double Axes[3][3]; //the axes defining the OBB - ordered from long->short
00073   vtkOBBNode *Parent; //parent node; NULL if root
00074   vtkOBBNode **Kids; //two children of this node; NULL if leaf
00075   vtkIdList *Cells; //list of cells in node
00076   void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00077                        int *maxCells );
00078 };
00079 //ETX
00080 //
00081 
00082 class VTK_GRAPHICS_EXPORT vtkOBBTree : public vtkCellLocator
00083 {
00084 public:
00085   vtkTypeRevisionMacro(vtkOBBTree,vtkCellLocator);
00086   void PrintSelf(ostream& os, vtkIndent indent);
00087 
00090   static vtkOBBTree *New();
00091 
00093 
00096   void ComputeOBB(vtkPoints *pts, double corner[3], double max[3], 
00097                   double mid[3], double min[3], double size[3]);
00099 
00101 
00105   void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
00106                   double mid[3], double min[3], double size[3]);
00108 
00113   int InsideOrOutside(const double point[3]);
00114 
00116 
00124   int IntersectWithLine(const double a0[3], const double a1[3],
00125                         vtkPoints *points, vtkIdList *cellIds);
00127 
00129 
00132   int IntersectWithLine(double a0[3], double a1[3], double tol,
00133                         double& t, double x[3], double pcoords[3],
00134                         int &subId);
00136 
00137   int IntersectWithLine(double a0[3], double a1[3], double tol,
00138                         double& t, double x[3], double pcoords[3],
00139                         int &subId, vtkIdType &cellId);
00140   
00141   int IntersectWithLine(double a0[3], double a1[3], double tol,
00142                         double& t, double x[3], double pcoords[3],
00143                         int &subId, vtkIdType &cellId, vtkGenericCell *cell);
00144 
00145   //BTX
00146 
00148 
00150   int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00151                         vtkMatrix4x4 *XformBtoA );
00153 
00155   int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
00156 
00158 
00159   int TriangleIntersectsNode( vtkOBBNode *pA,
00160                               double p0[3], double p1[3],
00161                               double p2[3], vtkMatrix4x4 *XformBtoA );
00163 
00165 
00167   int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00168                             int(*function)( vtkOBBNode *nodeA,
00169                                             vtkOBBNode *nodeB,
00170                                             vtkMatrix4x4 *Xform,
00171                                             void *arg ),
00172                             void *data_arg );
00173   //ETX
00175 
00177 
00178   void FreeSearchStructure();
00179   void BuildLocator();
00181 
00190   void GenerateRepresentation(int level, vtkPolyData *pd);
00191 
00192   //BTX
00193 protected:
00194   vtkOBBTree();
00195   ~vtkOBBTree();
00196 
00197   // Compute an OBB from the list of cells given.  This used to be
00198   // public but should not have been.  A public call has been added
00199   // so that the functionality can be accessed.
00200   void ComputeOBB(vtkIdList *cells, double corner[3], double max[3], 
00201                        double mid[3], double min[3], double size[3]);
00202 
00203   vtkOBBNode *Tree;
00204   void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00205   vtkPoints *PointsList;
00206   int *InsertedPoints;
00207   int OBBCount;
00208   int DeepestLevel;
00209 
00210   void DeleteTree(vtkOBBNode *OBBptr);
00211   void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, 
00212                         vtkPoints* pts, vtkCellArray *polys);
00213 
00214   //ETX
00215 private:
00216   vtkOBBTree(const vtkOBBTree&);  // Not implemented.
00217   void operator=(const vtkOBBTree&);  // Not implemented.
00218 };
00219 
00220 #endif

Generated on Mon Jan 21 23:07:25 2008 for VTK by  doxygen 1.4.3-20050530