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 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 =========================================================================*/ 00059 #ifndef __vtkOBBTree_h 00060 #define __vtkOBBTree_h 00061 00062 #include "vtkCellLocator.h" 00063 00064 class vtkMatrix4x4; 00065 00066 // Special class defines node for the OBB tree 00067 // 00068 //BTX 00069 // 00070 class vtkOBBNode { //;prevent man page generation 00071 public: 00072 vtkOBBNode(); 00073 ~vtkOBBNode(); 00074 00075 float Corner[3]; //center point of this node 00076 float Axes[3][3]; //the axes defining the OBB - ordered from long->short 00077 vtkOBBNode *Parent; //parent node; NULL if root 00078 vtkOBBNode **Kids; //two children of this node; NULL if leaf 00079 vtkIdList *Cells; //list of cells in node 00080 void DebugPrintTree( int level, double *leaf_vol, int *minCells, 00081 int *maxCells ); 00082 }; 00083 //ETX 00084 // 00085 00086 class VTK_GRAPHICS_EXPORT vtkOBBTree : public vtkCellLocator 00087 { 00088 public: 00089 vtkTypeRevisionMacro(vtkOBBTree,vtkCellLocator); 00090 00093 static vtkOBBTree *New(); 00094 00096 00099 void ComputeOBB(vtkPoints *pts, float corner[3], float max[3], 00100 float mid[3], float min[3], float size[3]); 00102 00104 00108 void ComputeOBB(vtkDataSet *input, float corner[3], float max[3], 00109 float mid[3], float min[3], float size[3]); 00111 00116 int InsideOrOutside(const float point[3]); 00117 00119 00127 int IntersectWithLine(const float a0[3], const float a1[3], 00128 vtkPoints *points, vtkIdList *cellIds); 00130 00132 00135 int IntersectWithLine(float a0[3], float a1[3], float tol, 00136 float& t, float x[3], float pcoords[3], 00137 int &subId); 00139 00140 int IntersectWithLine(float a0[3], float a1[3], float tol, 00141 float& t, float x[3], float pcoords[3], 00142 int &subId, vtkIdType &cellId); 00143 00144 int IntersectWithLine(float a0[3], float a1[3], float tol, 00145 float& t, float x[3], float pcoords[3], 00146 int &subId, vtkIdType &cellId, vtkGenericCell *cell); 00147 00148 //BTX 00149 00151 00153 int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB, 00154 vtkMatrix4x4 *XformBtoA ); 00156 00158 int LineIntersectsNode( vtkOBBNode *pA, float B0[3], float B1[3] ); 00159 00161 00162 int TriangleIntersectsNode( vtkOBBNode *pA, 00163 float p0[3], float p1[3], 00164 float p2[3], vtkMatrix4x4 *XformBtoA ); 00166 00168 00170 int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA, 00171 int(*function)( vtkOBBNode *nodeA, 00172 vtkOBBNode *nodeB, 00173 vtkMatrix4x4 *Xform, 00174 void *arg ), 00175 void *data_arg ); 00176 //ETX 00178 00180 00181 void FreeSearchStructure(); 00182 void BuildLocator(); 00184 00193 void GenerateRepresentation(int level, vtkPolyData *pd); 00194 00195 //BTX 00196 protected: 00197 vtkOBBTree(); 00198 ~vtkOBBTree(); 00199 00200 // Compute an OBB from the list of cells given. This used to be 00201 // public but should not have been. A public call has been added 00202 // so that the functionality can be accessed. 00203 void ComputeOBB(vtkIdList *cells, float corner[3], float max[3], 00204 float mid[3], float min[3], float size[3]); 00205 00206 vtkOBBNode *Tree; 00207 void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level); 00208 vtkPoints *PointsList; 00209 int *InsertedPoints; 00210 int OBBCount; 00211 int DeepestLevel; 00212 00213 void DeleteTree(vtkOBBNode *OBBptr); 00214 void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, 00215 vtkPoints* pts, vtkCellArray *polys); 00216 00217 //ETX 00218 private: 00219 vtkOBBTree(const vtkOBBTree&); // Not implemented. 00220 void operator=(const vtkOBBTree&); // Not implemented. 00221 }; 00222 00223 #endif