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
00086 #ifndef __vtkOBBTree_h
00087 #define __vtkOBBTree_h
00088
00089 #include "vtkCellLocator.h"
00090 #include "vtkMatrix4x4.h"
00091
00092
00093
00094
00095
00096 class vtkOBBNode {
00097 public:
00098 vtkOBBNode();
00099 ~vtkOBBNode();
00100
00101 float Corner[3];
00102 float Axes[3][3];
00103 vtkOBBNode *Parent;
00104 vtkOBBNode **Kids;
00105 vtkIdList *Cells;
00106 void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00107 int *maxCells );
00108 };
00109
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
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
00204
00206
00207 void FreeSearchStructure();
00208 void BuildLocator();
00210
00219 void GenerateRepresentation(int level, vtkPolyData *pd);
00220
00221
00222 protected:
00223 vtkOBBTree();
00224 ~vtkOBBTree();
00225
00226
00227
00228
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
00244 private:
00245 vtkOBBTree(const vtkOBBTree&);
00246 void operator=(const vtkOBBTree&);
00247 };
00248
00249 #endif