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 =========================================================================*/
00086 #ifndef __vtkOBBTree_h
00087 #define __vtkOBBTree_h
00088 
00089 #include "vtkCellLocator.h"
00090 #include "vtkMatrix4x4.h"
00091 
00092 // Special class defines node for the OBB tree
00093 //
00094 //BTX
00095 //
00096 class vtkOBBNode { //;prevent man page generation
00097 public:
00098   vtkOBBNode();
00099   ~vtkOBBNode();
00100 
00101   float Corner[3]; //center point of this node
00102   float Axes[3][3]; //the axes defining the OBB - ordered from long->short
00103   vtkOBBNode *Parent; //parent node; NULL if root
00104   vtkOBBNode **Kids; //two children of this node; NULL if leaf
00105   vtkIdList *Cells; //list of cells in node
00106   void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00107                        int *maxCells );
00108 };
00109 //ETX
00110 //
00111 
00112 class VTK_GRAPHICS_EXPORT vtkOBBTree : public vtkCellLocator
00113 {
00114 public:
00115   vtkTypeMacro(vtkOBBTree,vtkCellLocator);
00116 
00119   static vtkOBBTree *New();
00120 
00122 
00125   void ComputeOBB(vtkPoints *pts, float corner[3], float max[3], 
00126                   float mid[3], float min[3], float size[3]);
00128 
00130 
00134   void ComputeOBB(vtkDataSet *input, float corner[3], float max[3],
00135                   float mid[3], float min[3], float size[3]);
00137 
00142   int InsideOrOutside(const float point[3]);
00143 
00145 
00153   int IntersectWithLine(const float a0[3], const float a1[3],
00154                         vtkPoints *points, vtkIdList *cellIds);
00156 
00158 
00161   int IntersectWithLine(float a0[3], float a1[3], float tol,
00162                         float& t, float x[3], float pcoords[3],
00163                         int &subId);
00165 
00166   int IntersectWithLine(float a0[3], float a1[3], float tol,
00167                         float& t, float x[3], float pcoords[3],
00168                         int &subId, vtkIdType &cellId);
00169   
00170   int IntersectWithLine(float a0[3], float a1[3], float tol,
00171                         float& t, float x[3], float pcoords[3],
00172                         int &subId, vtkIdType &cellId, vtkGenericCell *cell);
00173 
00174   //BTX
00175 
00177 
00179   int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00180                         vtkMatrix4x4 *XformBtoA );
00182 
00184   int LineIntersectsNode( vtkOBBNode *pA, float B0[3], float B1[3] );
00185 
00187 
00188   int TriangleIntersectsNode( vtkOBBNode *pA,
00189                               float p0[3], float p1[3],
00190                               float p2[3], vtkMatrix4x4 *XformBtoA );
00192 
00194 
00196   int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00197                             int(*function)( vtkOBBNode *nodeA,
00198                                             vtkOBBNode *nodeB,
00199                                             vtkMatrix4x4 *Xform,
00200                                             void *arg ),
00201                             void *data_arg );
00202   //ETX
00204 
00206   /*! Satisfy locator's abstract interface, see vtkLocator. */
00207   void FreeSearchStructure();
00208   void BuildLocator();
00210 
00219   void GenerateRepresentation(int level, vtkPolyData *pd);
00220 
00221   //BTX
00222 protected:
00223   vtkOBBTree();
00224   ~vtkOBBTree();
00225 
00226   // Compute an OBB from the list of cells given.  This used to be
00227   // public but should not have been.  A public call has been added
00228   // so that the functionality can be accessed.
00229   void ComputeOBB(vtkIdList *cells, float corner[3], float max[3], 
00230                        float mid[3], float min[3], float size[3]);
00231 
00232   vtkOBBNode *Tree;
00233   void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00234   vtkPoints *PointsList;
00235   int *InsertedPoints;
00236   int OBBCount;
00237   int DeepestLevel;
00238 
00239   void DeleteTree(vtkOBBNode *OBBptr);
00240   void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, 
00241                         vtkPoints* pts, vtkCellArray *polys);
00242 
00243   //ETX
00244 private:
00245   vtkOBBTree(const vtkOBBTree&);  // Not implemented.
00246   void operator=(const vtkOBBTree&);  // Not implemented.
00247 };
00248 
00249 #endif

Generated on Thu Mar 28 14:19:21 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001