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

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 =========================================================================*/
00072 #ifndef __vtkOBBTree_h
00073 #define __vtkOBBTree_h
00074 
00075 #include "vtkCellLocator.h"
00076 
00077 class vtkMatrix4x4;
00078 
00079 // Special class defines node for the OBB tree
00080 //
00081 //BTX
00082 //
00083 class vtkOBBNode { //;prevent man page generation
00084 public:
00085   vtkOBBNode();
00086   ~vtkOBBNode();
00087 
00088   float Corner[3]; //center point of this node
00089   float Axes[3][3]; //the axes defining the OBB - ordered from long->short
00090   vtkOBBNode *Parent; //parent node; NULL if root
00091   vtkOBBNode **Kids; //two children of this node; NULL if leaf
00092   vtkIdList *Cells; //list of cells in node
00093   void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00094                        int *maxCells );
00095 };
00096 //ETX
00097 //
00098 
00099 class VTK_GRAPHICS_EXPORT vtkOBBTree : public vtkCellLocator
00100 {
00101 public:
00102   vtkTypeRevisionMacro(vtkOBBTree,vtkCellLocator);
00103 
00106   static vtkOBBTree *New();
00107 
00109 
00112   void ComputeOBB(vtkPoints *pts, float corner[3], float max[3], 
00113                   float mid[3], float min[3], float size[3]);
00115 
00117 
00121   void ComputeOBB(vtkDataSet *input, float corner[3], float max[3],
00122                   float mid[3], float min[3], float size[3]);
00124 
00129   int InsideOrOutside(const float point[3]);
00130 
00132 
00140   int IntersectWithLine(const float a0[3], const float a1[3],
00141                         vtkPoints *points, vtkIdList *cellIds);
00143 
00145 
00148   int IntersectWithLine(float a0[3], float a1[3], float tol,
00149                         float& t, float x[3], float pcoords[3],
00150                         int &subId);
00152 
00153   int IntersectWithLine(float a0[3], float a1[3], float tol,
00154                         float& t, float x[3], float pcoords[3],
00155                         int &subId, vtkIdType &cellId);
00156   
00157   int IntersectWithLine(float a0[3], float a1[3], float tol,
00158                         float& t, float x[3], float pcoords[3],
00159                         int &subId, vtkIdType &cellId, vtkGenericCell *cell);
00160 
00161   //BTX
00162 
00164 
00166   int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00167                         vtkMatrix4x4 *XformBtoA );
00169 
00171   int LineIntersectsNode( vtkOBBNode *pA, float B0[3], float B1[3] );
00172 
00174 
00175   int TriangleIntersectsNode( vtkOBBNode *pA,
00176                               float p0[3], float p1[3],
00177                               float p2[3], vtkMatrix4x4 *XformBtoA );
00179 
00181 
00183   int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00184                             int(*function)( vtkOBBNode *nodeA,
00185                                             vtkOBBNode *nodeB,
00186                                             vtkMatrix4x4 *Xform,
00187                                             void *arg ),
00188                             void *data_arg );
00189   //ETX
00191 
00193 
00194   void FreeSearchStructure();
00195   void BuildLocator();
00197 
00206   void GenerateRepresentation(int level, vtkPolyData *pd);
00207 
00208   //BTX
00209 protected:
00210   vtkOBBTree();
00211   ~vtkOBBTree();
00212 
00213   // Compute an OBB from the list of cells given.  This used to be
00214   // public but should not have been.  A public call has been added
00215   // so that the functionality can be accessed.
00216   void ComputeOBB(vtkIdList *cells, float corner[3], float max[3], 
00217                        float mid[3], float min[3], float size[3]);
00218 
00219   vtkOBBNode *Tree;
00220   void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00221   vtkPoints *PointsList;
00222   int *InsertedPoints;
00223   int OBBCount;
00224   int DeepestLevel;
00225 
00226   void DeleteTree(vtkOBBNode *OBBptr);
00227   void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, 
00228                         vtkPoints* pts, vtkCellArray *polys);
00229 
00230   //ETX
00231 private:
00232   vtkOBBTree(const vtkOBBTree&);  // Not implemented.
00233   void operator=(const vtkOBBTree&);  // Not implemented.
00234 };
00235 
00236 #endif