Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00085 #ifndef __vtkOBBTree_h
00086 #define __vtkOBBTree_h
00087 
00088 #include "vtkCellLocator.h"
00089 #include "vtkMatrix4x4.h"
00090 
00091 // Special class defines node for the OBB tree
00092 //
00093 //BTX
00094 //
00095 class vtkOBBNode { //;prevent man page generation
00096 public:
00097   vtkOBBNode();
00098   ~vtkOBBNode();
00099 
00100   float Corner[3]; //center point of this node
00101   float Axes[3][3]; //the axes defining the OBB - ordered from long->short
00102   vtkOBBNode *Parent; //parent node; NULL if root
00103   vtkOBBNode **Kids; //two children of this node; NULL if leaf
00104   vtkIdList *Cells; //list of cells in node
00105   void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00106                        int *maxCells );
00107 };
00108 //ETX
00109 //
00110 
00111 class VTK_EXPORT vtkOBBTree : public vtkCellLocator
00112 {
00113 public:
00114   vtkTypeMacro(vtkOBBTree,vtkCellLocator);
00115 
00118   static vtkOBBTree *New();
00119 
00123   void ComputeOBB(vtkPoints *pts, float corner[3], float max[3], 
00124                   float mid[3], float min[3], float size[3]);
00125 
00130   void ComputeOBB(vtkDataSet *input, float corner[3], float max[3],
00131                             float mid[3], float min[3], float size[3]);
00132 
00133   int IntersectWithLine(float a0[3], float a1[3], float tol,
00134                         float& t, float x[3], float pcoords[3],
00135                         int &subId);
00136 
00137   int IntersectWithLine(float a0[3], float a1[3], float tol,
00138                         float& t, float x[3], float pcoords[3],
00139                         int &subId, int &cellId);
00140   
00141   int IntersectWithLine(float a0[3], float a1[3], float tol,
00142          float& t, float x[3], float pcoords[3],
00143          int &subId, int &cellId, vtkGenericCell *cell);
00144 
00145   //BTX
00148   int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00149                         vtkMatrix4x4 *XformBtoA );
00150 
00152   int LineIntersectsNode( vtkOBBNode *pA, float B0[3], float B1[3] );
00153 
00155   int TriangleIntersectsNode( vtkOBBNode *pA,
00156                                      float p0[3], float p1[3],
00157                                      float p2[3], vtkMatrix4x4 *XformBtoA );
00158 
00161   int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00162                             int(*function)( vtkOBBNode *nodeA,
00163                                             vtkOBBNode *nodeB,
00164                                             vtkMatrix4x4 *Xform,
00165                                             void *arg ),
00166                             void *data_arg );
00167   //ETX
00168 
00170   void FreeSearchStructure();
00171   void BuildLocator();
00172 
00181   void GenerateRepresentation(int level, vtkPolyData *pd);
00182 
00183   //BTX
00184 protected:
00185   vtkOBBTree();
00186   ~vtkOBBTree();
00187   vtkOBBTree(const vtkOBBTree&) {};
00188   void operator=(const vtkOBBTree&) {};
00189 
00190   // Compute an OBB from the list of cells given.  This used to be
00191   // public but should not have been.  A public call has been added
00192   // so that the functionality can be accessed.
00193   void ComputeOBB(vtkIdList *cells, float corner[3], float max[3], 
00194                        float mid[3], float min[3], float size[3]);
00195 
00196   vtkOBBNode *Tree;
00197   void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00198   vtkPoints *PointsList;
00199   int *InsertedPoints;
00200   int OBBCount;
00201   int DeepestLevel;
00202 
00203   void DeleteTree(vtkOBBNode *OBBptr);
00204   void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, 
00205                         vtkPoints* pts, vtkCellArray *polys);
00206 
00207   //ETX
00208 };
00209 
00210 #endif

Generated on Wed Nov 21 12:27:01 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001