00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00059 #ifndef __vtkOBBTree_h
00060 #define __vtkOBBTree_h
00061
00062 #include "vtkCellLocator.h"
00063
00064 class vtkMatrix4x4;
00065
00066
00067
00068
00069
00070 class vtkOBBNode {
00071 public:
00072 vtkOBBNode();
00073 ~vtkOBBNode();
00074
00075 float Corner[3];
00076 float Axes[3][3];
00077 vtkOBBNode *Parent;
00078 vtkOBBNode **Kids;
00079 vtkIdList *Cells;
00080 void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00081 int *maxCells );
00082 };
00083
00084
00085
00086 class VTK_GRAPHICS_EXPORT vtkOBBTree : public vtkCellLocator
00087 {
00088 public:
00089 vtkTypeRevisionMacro(vtkOBBTree,vtkCellLocator);
00090
00093 static vtkOBBTree *New();
00094
00096
00099 void ComputeOBB(vtkPoints *pts, float corner[3], float max[3],
00100 float mid[3], float min[3], float size[3]);
00102
00104
00108 void ComputeOBB(vtkDataSet *input, float corner[3], float max[3],
00109 float mid[3], float min[3], float size[3]);
00111
00116 int InsideOrOutside(const float point[3]);
00117
00119
00127 int IntersectWithLine(const float a0[3], const float a1[3],
00128 vtkPoints *points, vtkIdList *cellIds);
00130
00132
00135 int IntersectWithLine(float a0[3], float a1[3], float tol,
00136 float& t, float x[3], float pcoords[3],
00137 int &subId);
00139
00140 int IntersectWithLine(float a0[3], float a1[3], float tol,
00141 float& t, float x[3], float pcoords[3],
00142 int &subId, vtkIdType &cellId);
00143
00144 int IntersectWithLine(float a0[3], float a1[3], float tol,
00145 float& t, float x[3], float pcoords[3],
00146 int &subId, vtkIdType &cellId, vtkGenericCell *cell);
00147
00148
00149
00151
00153 int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00154 vtkMatrix4x4 *XformBtoA );
00156
00158 int LineIntersectsNode( vtkOBBNode *pA, float B0[3], float B1[3] );
00159
00161
00162 int TriangleIntersectsNode( vtkOBBNode *pA,
00163 float p0[3], float p1[3],
00164 float p2[3], vtkMatrix4x4 *XformBtoA );
00166
00168
00170 int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00171 int(*function)( vtkOBBNode *nodeA,
00172 vtkOBBNode *nodeB,
00173 vtkMatrix4x4 *Xform,
00174 void *arg ),
00175 void *data_arg );
00176
00178
00180
00181 void FreeSearchStructure();
00182 void BuildLocator();
00184
00193 void GenerateRepresentation(int level, vtkPolyData *pd);
00194
00195
00196 protected:
00197 vtkOBBTree();
00198 ~vtkOBBTree();
00199
00200
00201
00202
00203 void ComputeOBB(vtkIdList *cells, float corner[3], float max[3],
00204 float mid[3], float min[3], float size[3]);
00205
00206 vtkOBBNode *Tree;
00207 void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00208 vtkPoints *PointsList;
00209 int *InsertedPoints;
00210 int OBBCount;
00211 int DeepestLevel;
00212
00213 void DeleteTree(vtkOBBNode *OBBptr);
00214 void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel,
00215 vtkPoints* pts, vtkCellArray *polys);
00216
00217
00218 private:
00219 vtkOBBTree(const vtkOBBTree&);
00220 void operator=(const vtkOBBTree&);
00221 };
00222
00223 #endif