Graphics/vtkOBBTree.h Source File

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