00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00055 #ifndef __vtkOBBTree_h
00056 #define __vtkOBBTree_h
00057
00058 #include "vtkCellLocator.h"
00059
00060 class vtkMatrix4x4;
00061
00062
00063
00064
00065
00066 class vtkOBBNode {
00067 public:
00068 vtkOBBNode();
00069 ~vtkOBBNode();
00070
00071 double Corner[3];
00072 double Axes[3][3];
00073 vtkOBBNode *Parent;
00074 vtkOBBNode **Kids;
00075 vtkIdList *Cells;
00076 void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00077 int *maxCells );
00078 };
00079
00080
00081
00082 class VTK_GRAPHICS_EXPORT vtkOBBTree : public vtkCellLocator
00083 {
00084 public:
00085 vtkTypeRevisionMacro(vtkOBBTree,vtkCellLocator);
00086
00089 static vtkOBBTree *New();
00090
00092
00095 void ComputeOBB(vtkPoints *pts, double corner[3], double max[3],
00096 double mid[3], double min[3], double size[3]);
00098
00100
00104 void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
00105 double mid[3], double min[3], double size[3]);
00107
00112 int InsideOrOutside(const double point[3]);
00113
00115
00123 int IntersectWithLine(const double a0[3], const double a1[3],
00124 vtkPoints *points, vtkIdList *cellIds);
00126
00128
00131 int IntersectWithLine(double a0[3], double a1[3], double tol,
00132 double& t, double x[3], double pcoords[3],
00133 int &subId);
00135
00136 int IntersectWithLine(double a0[3], double a1[3], double tol,
00137 double& t, double x[3], double pcoords[3],
00138 int &subId, vtkIdType &cellId);
00139
00140 int IntersectWithLine(double a0[3], double a1[3], double tol,
00141 double& t, double x[3], double pcoords[3],
00142 int &subId, vtkIdType &cellId, vtkGenericCell *cell);
00143
00144
00145
00147
00149 int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00150 vtkMatrix4x4 *XformBtoA );
00152
00154 int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
00155
00157
00158 int TriangleIntersectsNode( vtkOBBNode *pA,
00159 double p0[3], double p1[3],
00160 double p2[3], vtkMatrix4x4 *XformBtoA );
00162
00164
00166 int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00167 int(*function)( vtkOBBNode *nodeA,
00168 vtkOBBNode *nodeB,
00169 vtkMatrix4x4 *Xform,
00170 void *arg ),
00171 void *data_arg );
00172
00174
00176
00177 void FreeSearchStructure();
00178 void BuildLocator();
00180
00189 void GenerateRepresentation(int level, vtkPolyData *pd);
00190
00191
00192 protected:
00193 vtkOBBTree();
00194 ~vtkOBBTree();
00195
00196
00197
00198
00199 void ComputeOBB(vtkIdList *cells, double corner[3], double max[3],
00200 double mid[3], double min[3], double size[3]);
00201
00202 vtkOBBNode *Tree;
00203 void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00204 vtkPoints *PointsList;
00205 int *InsertedPoints;
00206 int OBBCount;
00207 int DeepestLevel;
00208
00209 void DeleteTree(vtkOBBNode *OBBptr);
00210 void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel,
00211 vtkPoints* pts, vtkCellArray *polys);
00212
00213
00214 private:
00215 vtkOBBTree(const vtkOBBTree&);
00216 void operator=(const vtkOBBTree&);
00217 };
00218
00219 #endif