00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00112 #ifndef __vtkHyperOctree_h
00113 #define __vtkHyperOctree_h
00114
00115 #include "vtkDataSet.h"
00116
00117 class vtkHyperOctreeLightWeightCursor;
00118 class vtkHyperOctreeCursor;
00119 class vtkHyperOctreeInternal;
00120 class vtkHyperOctreePointsGrabber;
00121
00122 class vtkHyperOctreeIdSet;
00123 class vtkPolygon;
00124 class vtkIdTypeArray;
00125 class vtkPoints;
00126 class vtkPointLocator;
00127 class vtkOrderedTriangulator;
00128 class vtkDataSetAttributes;
00129
00130 class vtkLine;
00131 class vtkPixel;
00132 class vtkVoxel;
00133 class vtkCellLinks;
00134
00135 class VTK_FILTERING_EXPORT vtkHyperOctree : public vtkDataSet
00136 {
00137 public:
00138 static vtkInformationIntegerKey* LEVELS();
00139 static vtkInformationIntegerKey* DIMENSION();
00140 static vtkInformationDoubleVectorKey* SIZES();
00141 static vtkHyperOctree *New();
00142
00143 vtkTypeRevisionMacro(vtkHyperOctree,vtkDataSet);
00144 void PrintSelf(ostream& os, vtkIndent indent);
00145
00147 int GetDataObjectType();
00148
00151 void CopyStructure(vtkDataSet *ds);
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 int GetDimension();
00164
00165
00166
00167
00168 void SetDimension(int dim);
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00183 vtkIdType GetNumberOfCells();
00184
00186 vtkIdType GetNumberOfLeaves();
00187
00190 vtkIdType GetNumberOfPoints();
00191
00198 vtkIdType GetMaxNumberOfPoints(int level);
00199
00210 vtkIdType GetMaxNumberOfPointsOnBoundary(int level);
00211
00216 vtkIdType GetMaxNumberOfCellsOnBoundary(int level);
00217
00220 vtkIdType GetNumberOfLevels();
00221
00222
00223
00225
00226 vtkSetVector3Macro(Size,double);
00228
00230
00231 vtkGetVector3Macro(Size,double);
00233
00235
00236 vtkSetVector3Macro(Origin,double);
00237
00238 vtkGetVector3Macro(Origin,double);
00240
00243 vtkHyperOctreeCursor *NewCellCursor();
00244
00248 void SubdivideLeaf(vtkHyperOctreeCursor *leaf);
00249
00254 void CollapseTerminalNode(vtkHyperOctreeCursor *node);
00255
00258 virtual double *GetPoint(vtkIdType ptId);
00259
00263 virtual void GetPoint(vtkIdType id, double x[3]);
00264
00267 virtual vtkCell *GetCell(vtkIdType cellId);
00268
00273 virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00274
00275
00279 virtual int GetCellType(vtkIdType cellId);
00280
00282
00285 virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00286 virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts,
00287 vtkIdType* &pts);
00289
00293 virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
00294
00295
00297
00301 virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00302 vtkIdList *cellIds);
00304
00305 virtual vtkIdType FindPoint(double x[3]);
00306
00308
00316 virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId,
00317 double tol2, int& subId, double pcoords[3],
00318 double *weights);
00320
00322
00327 virtual vtkIdType FindCell(double x[3], vtkCell *cell,
00328 vtkGenericCell *gencell, vtkIdType cellId,
00329 double tol2, int& subId, double pcoords[3],
00330 double *weights);
00332
00334 void Initialize();
00335
00339 virtual int GetMaxCellSize();
00340
00342
00343 void ShallowCopy(vtkDataObject *src);
00344 void DeepCopy(vtkDataObject *src);
00346
00348
00353 void GetPointsOnFace(vtkHyperOctreeCursor *sibling,
00354 int face,
00355 int level,
00356 vtkHyperOctreePointsGrabber *grabber);
00358
00360
00365 void GetPointsOnParentFaces(int faces[3],
00366 int level,
00367 vtkHyperOctreeCursor *cursor,
00368 vtkHyperOctreePointsGrabber *grabber);
00370
00372
00383 void GetPointsOnEdge(vtkHyperOctreeCursor *sibling,
00384 int level,
00385 int axis,
00386 int k,
00387 int j,
00388 vtkHyperOctreePointsGrabber *grabber);
00390
00392
00401 void GetPointsOnParentEdge(vtkHyperOctreeCursor *cursor,
00402 int level,
00403 int axis,
00404 int k,
00405 int j,
00406 vtkHyperOctreePointsGrabber *grabber);
00408
00410
00415 void GetPointsOnEdge2D(vtkHyperOctreeCursor *sibling,
00416 int edge,
00417 int level,
00418 vtkHyperOctreePointsGrabber *grabber);
00420
00422
00427 void GetPointsOnParentEdge2D(vtkHyperOctreeCursor *cursor,
00428 int edge,
00429 int level,
00430 vtkHyperOctreePointsGrabber *grabber);
00432
00435 vtkDataSetAttributes* GetLeafData();
00436
00438
00439 void SetDualGridFlag(int flag);
00440 vtkGetMacro(DualGridFlag,int);
00442
00448 unsigned long GetActualMemorySize();
00449
00450
00452
00453 static vtkHyperOctree* GetData(vtkInformation* info);
00454 static vtkHyperOctree* GetData(vtkInformationVector* v, int i=0);
00455
00457
00458 protected:
00459
00460 vtkHyperOctree();
00461 ~vtkHyperOctree();
00462
00463 void ComputeBounds();
00464
00465 int Dimension;
00466
00467 double Size[3];
00468 double Origin[3];
00469
00470 vtkHyperOctreeInternal *CellTree;
00471
00472 vtkHyperOctreeCursor *TmpChild;
00473
00474
00475 friend class vtkHyperOctreeLightWeightCursor;
00476
00477
00478
00479 void UpdateDualArrays();
00480 vtkPoints* GetLeafCenters();
00481 vtkIdTypeArray* GetCornerLeafIds();
00482 vtkPoints *LeafCenters;
00483 vtkIdTypeArray *CornerLeafIds;
00484
00485 void UpdateGridArrays();
00486 vtkPoints* GetCornerPoints();
00487 vtkIdTypeArray* GetLeafCornerIds();
00488 vtkPoints* CornerPoints;
00489 vtkIdTypeArray* LeafCornerIds;
00490
00491 void DeleteInternalArrays();
00492
00493 void TraverseDualRecursively(vtkHyperOctreeLightWeightCursor* neighborhood,
00494 unsigned short *xyzIds, int level);
00495 void TraverseGridRecursively(vtkHyperOctreeLightWeightCursor* neighborhood,
00496 unsigned char* visited,
00497 double* origin, double* size);
00498 void EvaluateDualCorner(vtkHyperOctreeLightWeightCursor* neighborhood);
00499 vtkIdType EvaluateGridCorner(int level,vtkHyperOctreeLightWeightCursor* neighborhood,
00500 unsigned char* visited, int* cornerNeighborIds);
00501
00502
00503
00504
00505
00506
00507
00508 int NeighborhoodTraversalTable[216];
00509 void GenerateGridNeighborhoodTraversalTable();
00510 void GenerateDualNeighborhoodTraversalTable();
00511
00512
00513 vtkLine *Line;
00514 vtkPixel *Pixel;
00515 vtkVoxel *Voxel;
00516
00517 vtkCellLinks* Links;
00518 void BuildLinks();
00519
00520 vtkIdType RecursiveFindPoint(double x[3],
00521 vtkHyperOctreeLightWeightCursor* cursor,
00522 double *origin, double *size);
00523
00524
00525
00526 int DualGridFlag;
00527
00528 private:
00529 vtkHyperOctree(const vtkHyperOctree&);
00530 void operator=(const vtkHyperOctree&);
00531 };
00532
00533
00534
00535
00536 class VTK_FILTERING_EXPORT vtkHyperOctreeLightWeightCursor
00537 {
00538 public:
00539 vtkHyperOctreeLightWeightCursor();
00540 ~vtkHyperOctreeLightWeightCursor();
00541
00542 void Initialize(vtkHyperOctree* tree);
00543 void ToRoot();
00544 void ToChild(int child);
00545 unsigned short GetIsLeaf();
00546 int GetLeafIndex() {return this->Index;}
00547 vtkHyperOctree* GetTree() { return this->Tree; }
00548 unsigned short GetLevel() {return this->Level;}
00549 private:
00550 vtkHyperOctree* Tree;
00551 int Index;
00552 unsigned short IsLeaf;
00553 unsigned short Level;
00554 };
00555
00556
00557
00558 #endif