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 void PrintSelf(ostream& os, vtkIndent indent);
00087
00090 static vtkOBBTree *New();
00091
00093
00096 void ComputeOBB(vtkPoints *pts, double corner[3], double max[3],
00097 double mid[3], double min[3], double size[3]);
00099
00101
00105 void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
00106 double mid[3], double min[3], double size[3]);
00108
00113 int InsideOrOutside(const double point[3]);
00114
00116
00124 int IntersectWithLine(const double a0[3], const double a1[3],
00125 vtkPoints *points, vtkIdList *cellIds);
00127
00129
00132 int IntersectWithLine(double a0[3], double a1[3], double tol,
00133 double& t, double x[3], double pcoords[3],
00134 int &subId);
00136
00137 int IntersectWithLine(double a0[3], double a1[3], double tol,
00138 double& t, double x[3], double pcoords[3],
00139 int &subId, vtkIdType &cellId);
00140
00141 int IntersectWithLine(double a0[3], double a1[3], double tol,
00142 double& t, double x[3], double pcoords[3],
00143 int &subId, vtkIdType &cellId, vtkGenericCell *cell);
00144
00145
00146
00148
00150 int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00151 vtkMatrix4x4 *XformBtoA );
00153
00155 int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
00156
00158
00159 int TriangleIntersectsNode( vtkOBBNode *pA,
00160 double p0[3], double p1[3],
00161 double p2[3], vtkMatrix4x4 *XformBtoA );
00163
00165
00167 int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00168 int(*function)( vtkOBBNode *nodeA,
00169 vtkOBBNode *nodeB,
00170 vtkMatrix4x4 *Xform,
00171 void *arg ),
00172 void *data_arg );
00173
00175
00177
00178 void FreeSearchStructure();
00179 void BuildLocator();
00181
00190 void GenerateRepresentation(int level, vtkPolyData *pd);
00191
00192
00193 protected:
00194 vtkOBBTree();
00195 ~vtkOBBTree();
00196
00197
00198
00199
00200 void ComputeOBB(vtkIdList *cells, double corner[3], double max[3],
00201 double mid[3], double min[3], double size[3]);
00202
00203 vtkOBBNode *Tree;
00204 void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00205 vtkPoints *PointsList;
00206 int *InsertedPoints;
00207 int OBBCount;
00208 int DeepestLevel;
00209
00210 void DeleteTree(vtkOBBNode *OBBptr);
00211 void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel,
00212 vtkPoints* pts, vtkCellArray *polys);
00213
00214
00215 private:
00216 vtkOBBTree(const vtkOBBTree&);
00217 void operator=(const vtkOBBTree&);
00218 };
00219
00220 #endif