00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00118 #ifndef __vtkHyperOctree_h
00119 #define __vtkHyperOctree_h
00120
00121 #include "vtkDataSet.h"
00122
00123 class vtkHyperOctreeLightWeightCursor;
00124 class vtkHyperOctreeCursor;
00125 class vtkHyperOctreeInternal;
00126 class vtkHyperOctreePointsGrabber;
00127
00128 class vtkHyperOctreeIdSet;
00129 class vtkPolygon;
00130 class vtkIdTypeArray;
00131 class vtkPoints;
00132 class vtkPointLocator;
00133 class vtkOrderedTriangulator;
00134 class vtkDataSetAttributes;
00135
00136 class vtkLine;
00137 class vtkPixel;
00138 class vtkVoxel;
00139 class vtkCellLinks;
00140
00141 class VTK_FILTERING_EXPORT vtkHyperOctree : public vtkDataSet
00142 {
00143 public:
00144 static vtkInformationIntegerKey* LEVELS();
00145 static vtkInformationIntegerKey* DIMENSION();
00146 static vtkInformationDoubleVectorKey* SIZES();
00147 static vtkHyperOctree *New();
00148
00149 vtkTypeMacro(vtkHyperOctree,vtkDataSet);
00150 void PrintSelf(ostream& os, vtkIndent indent);
00151
00153 int GetDataObjectType();
00154
00157 void CopyStructure(vtkDataSet *ds);
00158
00159
00160
00161
00162
00163
00164
00168 int GetDimension();
00169
00173 void SetDimension(int dim);
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00188 vtkIdType GetNumberOfCells();
00189
00191 vtkIdType GetNumberOfLeaves();
00192
00195 vtkIdType GetNumberOfPoints();
00196
00203 vtkIdType GetMaxNumberOfPoints(int level);
00204
00215 vtkIdType GetMaxNumberOfPointsOnBoundary(int level);
00216
00221 vtkIdType GetMaxNumberOfCellsOnBoundary(int level);
00222
00225 vtkIdType GetNumberOfLevels();
00226
00227
00228
00230
00231 vtkSetVector3Macro(Size,double);
00233
00235
00236 vtkGetVector3Macro(Size,double);
00238
00240
00241 vtkSetVector3Macro(Origin,double);
00242
00243 vtkGetVector3Macro(Origin,double);
00245
00248 vtkHyperOctreeCursor *NewCellCursor();
00249
00253 void SubdivideLeaf(vtkHyperOctreeCursor *leaf);
00254
00259 void CollapseTerminalNode(vtkHyperOctreeCursor *node);
00260
00263 virtual double *GetPoint(vtkIdType ptId);
00264
00268 virtual void GetPoint(vtkIdType id, double x[3]);
00269
00272 virtual vtkCell *GetCell(vtkIdType cellId);
00273
00278 virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell);
00279
00280
00284 virtual int GetCellType(vtkIdType cellId);
00285
00287
00290 virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
00291 virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts,
00292 vtkIdType* &pts);
00294
00298 virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
00299
00300
00302
00306 virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00307 vtkIdList *cellIds);
00309
00310 virtual vtkIdType FindPoint(double x[3]);
00311
00313
00321 virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId,
00322 double tol2, int& subId, double pcoords[3],
00323 double *weights);
00325
00327
00332 virtual vtkIdType FindCell(double x[3], vtkCell *cell,
00333 vtkGenericCell *gencell, vtkIdType cellId,
00334 double tol2, int& subId, double pcoords[3],
00335 double *weights);
00337
00339 void Initialize();
00340
00344 virtual int GetMaxCellSize();
00345
00347
00348 void ShallowCopy(vtkDataObject *src);
00349 void DeepCopy(vtkDataObject *src);
00351
00353
00358 void GetPointsOnFace(vtkHyperOctreeCursor *sibling,
00359 int face,
00360 int level,
00361 vtkHyperOctreePointsGrabber *grabber);
00363
00365
00370 void GetPointsOnParentFaces(int faces[3],
00371 int level,
00372 vtkHyperOctreeCursor *cursor,
00373 vtkHyperOctreePointsGrabber *grabber);
00375
00377
00388 void GetPointsOnEdge(vtkHyperOctreeCursor *sibling,
00389 int level,
00390 int axis,
00391 int k,
00392 int j,
00393 vtkHyperOctreePointsGrabber *grabber);
00395
00397
00406 void GetPointsOnParentEdge(vtkHyperOctreeCursor *cursor,
00407 int level,
00408 int axis,
00409 int k,
00410 int j,
00411 vtkHyperOctreePointsGrabber *grabber);
00413
00415
00420 void GetPointsOnEdge2D(vtkHyperOctreeCursor *sibling,
00421 int edge,
00422 int level,
00423 vtkHyperOctreePointsGrabber *grabber);
00425
00427
00432 void GetPointsOnParentEdge2D(vtkHyperOctreeCursor *cursor,
00433 int edge,
00434 int level,
00435 vtkHyperOctreePointsGrabber *grabber);
00437
00440 vtkDataSetAttributes* GetLeafData();
00441
00443
00444 void SetDualGridFlag(int flag);
00445 vtkGetMacro(DualGridFlag,int);
00447
00453 unsigned long GetActualMemorySize();
00454
00455
00457
00458 static vtkHyperOctree* GetData(vtkInformation* info);
00459 static vtkHyperOctree* GetData(vtkInformationVector* v, int i=0);
00460
00462
00463 protected:
00464
00465 vtkHyperOctree();
00466 ~vtkHyperOctree();
00467
00468 void ComputeBounds();
00469
00470 int Dimension;
00471
00472 double Size[3];
00473 double Origin[3];
00474
00475 vtkHyperOctreeInternal *CellTree;
00476
00477 vtkHyperOctreeCursor *TmpChild;
00478
00479
00480 friend class vtkHyperOctreeLightWeightCursor;
00481
00482
00483
00484 void UpdateDualArrays();
00485 vtkPoints* GetLeafCenters();
00486 vtkIdTypeArray* GetCornerLeafIds();
00487 vtkPoints *LeafCenters;
00488 vtkIdTypeArray *CornerLeafIds;
00489
00490 void UpdateGridArrays();
00491 vtkPoints* GetCornerPoints();
00492 vtkIdTypeArray* GetLeafCornerIds();
00493 vtkPoints* CornerPoints;
00494 vtkIdTypeArray* LeafCornerIds;
00495
00496 void DeleteInternalArrays();
00497
00498 void TraverseDualRecursively(vtkHyperOctreeLightWeightCursor* neighborhood,
00499 unsigned short *xyzIds, int level);
00500 void TraverseGridRecursively(vtkHyperOctreeLightWeightCursor* neighborhood,
00501 unsigned char* visited,
00502 double* origin, double* size);
00503 void EvaluateDualCorner(vtkHyperOctreeLightWeightCursor* neighborhood);
00504 vtkIdType EvaluateGridCorner(int level,vtkHyperOctreeLightWeightCursor* neighborhood,
00505 unsigned char* visited, int* cornerNeighborIds);
00506
00507
00508
00509
00510
00511
00512
00513 int NeighborhoodTraversalTable[216];
00514 void GenerateGridNeighborhoodTraversalTable();
00515 void GenerateDualNeighborhoodTraversalTable();
00516
00517
00518 vtkLine *Line;
00519 vtkPixel *Pixel;
00520 vtkVoxel *Voxel;
00521
00522 vtkCellLinks* Links;
00523 void BuildLinks();
00524
00525 vtkIdType RecursiveFindPoint(double x[3],
00526 vtkHyperOctreeLightWeightCursor* cursor,
00527 double *origin, double *size);
00528
00529
00530
00531 int DualGridFlag;
00532
00533 private:
00534 vtkHyperOctree(const vtkHyperOctree&);
00535 void operator=(const vtkHyperOctree&);
00536 };
00537
00538
00539
00540
00541 class VTK_FILTERING_EXPORT vtkHyperOctreeLightWeightCursor
00542 {
00543 public:
00544 vtkHyperOctreeLightWeightCursor();
00545 ~vtkHyperOctreeLightWeightCursor();
00546
00547 void Initialize(vtkHyperOctree* tree);
00548 void ToRoot();
00549 void ToChild(int child);
00550 unsigned short GetIsLeaf();
00551 int GetLeafIndex() {return this->Index;}
00552 vtkHyperOctree* GetTree() { return this->Tree; }
00553 unsigned short GetLevel() {return this->Level;}
00554 private:
00555 vtkHyperOctree* Tree;
00556 int Index;
00557 unsigned short IsLeaf;
00558 unsigned short Level;
00559 };
00560
00561
00562
00563 #endif