00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00068 #ifndef __vtkOBBTree_h
00069 #define __vtkOBBTree_h
00070
00071 #include "vtkCellLocator.h"
00072
00073 class vtkMatrix4x4;
00074
00075
00076
00077
00078
00079 class vtkOBBNode {
00080 public:
00081 vtkOBBNode();
00082 ~vtkOBBNode();
00083
00084 double Corner[3];
00085 double Axes[3][3];
00086 vtkOBBNode *Parent;
00087 vtkOBBNode **Kids;
00088 vtkIdList *Cells;
00089 void DebugPrintTree( int level, double *leaf_vol, int *minCells,
00090 int *maxCells );
00091 };
00092
00093
00094
00095 class VTK_GRAPHICS_EXPORT vtkOBBTree : public vtkCellLocator
00096 {
00097 public:
00098 vtkTypeRevisionMacro(vtkOBBTree,vtkCellLocator);
00099 void PrintSelf(ostream& os, vtkIndent indent);
00100
00103 static vtkOBBTree *New();
00104
00106
00109 void ComputeOBB(vtkPoints *pts, double corner[3], double max[3],
00110 double mid[3], double min[3], double size[3]);
00112
00114
00118 void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
00119 double mid[3], double min[3], double size[3]);
00121
00126 int InsideOrOutside(const double point[3]);
00127
00129
00137 int IntersectWithLine(const double a0[3], const double a1[3],
00138 vtkPoints *points, vtkIdList *cellIds);
00140
00142
00145 int IntersectWithLine(double a0[3], double a1[3], double tol,
00146 double& t, double x[3], double pcoords[3],
00147 int &subId);
00149
00150 int IntersectWithLine(double a0[3], double a1[3], double tol,
00151 double& t, double x[3], double pcoords[3],
00152 int &subId, vtkIdType &cellId);
00153
00154 int IntersectWithLine(double a0[3], double a1[3], double tol,
00155 double& t, double x[3], double pcoords[3],
00156 int &subId, vtkIdType &cellId, vtkGenericCell *cell);
00157
00158
00159
00161
00163 int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
00164 vtkMatrix4x4 *XformBtoA );
00166
00168 int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
00169
00171
00172 int TriangleIntersectsNode( vtkOBBNode *pA,
00173 double p0[3], double p1[3],
00174 double p2[3], vtkMatrix4x4 *XformBtoA );
00176
00178
00180 int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
00181 int(*function)( vtkOBBNode *nodeA,
00182 vtkOBBNode *nodeB,
00183 vtkMatrix4x4 *Xform,
00184 void *arg ),
00185 void *data_arg );
00186
00188
00190
00191 void FreeSearchStructure();
00192 void BuildLocator();
00194
00203 void GenerateRepresentation(int level, vtkPolyData *pd);
00204
00205
00206 protected:
00207 vtkOBBTree();
00208 ~vtkOBBTree();
00209
00210
00211
00212
00213 void ComputeOBB(vtkIdList *cells, double corner[3], double max[3],
00214 double mid[3], double min[3], double size[3]);
00215
00216 vtkOBBNode *Tree;
00217 void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
00218 vtkPoints *PointsList;
00219 int *InsertedPoints;
00220 int OBBCount;
00221 int DeepestLevel;
00222
00223 void DeleteTree(vtkOBBNode *OBBptr);
00224 void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel,
00225 vtkPoints* pts, vtkCellArray *polys);
00226
00227
00228 private:
00229 vtkOBBTree(const vtkOBBTree&);
00230 void operator=(const vtkOBBTree&);
00231 };
00232
00233 #endif