00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00085 #ifndef __vtkOBBTree_h
00086 #define __vtkOBBTree_h
00087
00088 #include "vtkCellLocator.h"
00089 #include "vtkMatrix4x4.h"
00090
00091
00092
00093
00094
00095 class vtkOBBNode {
00096 public:
00097 vtkOBBNode();
00098 ~vtkOBBNode();
00099
00100 float Corner[3];
00101 float Axes[3][3];
00102 vtkOBBNode *Parent;
00103 vtkOBBNode **Kids;
00104 vtkIdList *Cells;
00105 void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00106 int *maxCells );
00107 };
00108
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
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
00168
00170 void FreeSearchStructure();
00171 void BuildLocator();
00172
00181 void GenerateRepresentation(int level, vtkPolyData *pd);
00182
00183
00184 protected:
00185 vtkOBBTree();
00186 ~vtkOBBTree();
00187 vtkOBBTree(const vtkOBBTree&) {};
00188 void operator=(const vtkOBBTree&) {};
00189
00190
00191
00192
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
00208 };
00209
00210 #endif