00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00072 #ifndef __vtkOBBTree_h
00073 #define __vtkOBBTree_h
00074
00075 #include "vtkCellLocator.h"
00076
00077 class vtkMatrix4x4;
00078
00079
00080
00081
00082
00083 class vtkOBBNode {
00084 public:
00085 vtkOBBNode();
00086 ~vtkOBBNode();
00087
00088 float Corner[3];
00089 float Axes[3][3];
00090 vtkOBBNode *Parent;
00091 vtkOBBNode **Kids;
00092 vtkIdList *Cells;
00093 void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00094 int *maxCells );
00095 };
00096
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
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
00191
00193
00194 void FreeSearchStructure();
00195 void BuildLocator();
00197
00206 void GenerateRepresentation(int level, vtkPolyData *pd);
00207
00208
00209 protected:
00210 vtkOBBTree();
00211 ~vtkOBBTree();
00212
00213
00214
00215
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
00231 private:
00232 vtkOBBTree(const vtkOBBTree&);
00233 void operator=(const vtkOBBTree&);
00234 };
00235
00236 #endif