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