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

dox/Graphics/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 00089 static vtkOBBTree *New(); 00090 00092 00095 void ComputeOBB(vtkPoints *pts, double corner[3], double max[3], 00096 double mid[3], double min[3], double size[3]); 00098 00100 00104 void ComputeOBB(vtkDataSet *input, double corner[3], double max[3], 00105 double mid[3], double min[3], double size[3]); 00107 00112 int InsideOrOutside(const double point[3]); 00113 00115 00123 int IntersectWithLine(const double a0[3], const double a1[3], 00124 vtkPoints *points, vtkIdList *cellIds); 00126 00128 00131 int IntersectWithLine(double a0[3], double a1[3], double tol, 00132 double& t, double x[3], double pcoords[3], 00133 int &subId); 00135 00136 int IntersectWithLine(double a0[3], double a1[3], double tol, 00137 double& t, double x[3], double pcoords[3], 00138 int &subId, vtkIdType &cellId); 00139 00140 int IntersectWithLine(double a0[3], double a1[3], double tol, 00141 double& t, double x[3], double pcoords[3], 00142 int &subId, vtkIdType &cellId, vtkGenericCell *cell); 00143 00144 //BTX 00145 00147 00149 int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB, 00150 vtkMatrix4x4 *XformBtoA ); 00152 00154 int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] ); 00155 00157 00158 int TriangleIntersectsNode( vtkOBBNode *pA, 00159 double p0[3], double p1[3], 00160 double p2[3], vtkMatrix4x4 *XformBtoA ); 00162 00164 00166 int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA, 00167 int(*function)( vtkOBBNode *nodeA, 00168 vtkOBBNode *nodeB, 00169 vtkMatrix4x4 *Xform, 00170 void *arg ), 00171 void *data_arg ); 00172 //ETX 00174 00176 00177 void FreeSearchStructure(); 00178 void BuildLocator(); 00180 00189 void GenerateRepresentation(int level, vtkPolyData *pd); 00190 00191 //BTX 00192 protected: 00193 vtkOBBTree(); 00194 ~vtkOBBTree(); 00195 00196 // Compute an OBB from the list of cells given. This used to be 00197 // public but should not have been. A public call has been added 00198 // so that the functionality can be accessed. 00199 void ComputeOBB(vtkIdList *cells, double corner[3], double max[3], 00200 double mid[3], double min[3], double size[3]); 00201 00202 vtkOBBNode *Tree; 00203 void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level); 00204 vtkPoints *PointsList; 00205 int *InsertedPoints; 00206 int OBBCount; 00207 int DeepestLevel; 00208 00209 void DeleteTree(vtkOBBNode *OBBptr); 00210 void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, 00211 vtkPoints* pts, vtkCellArray *polys); 00212 00213 //ETX 00214 private: 00215 vtkOBBTree(const vtkOBBTree&); // Not implemented. 00216 void operator=(const vtkOBBTree&); // Not implemented. 00217 }; 00218 00219 #endif