1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkHyperTreeGrid.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 /** 16 * @class vtkHyperTreeGrid 17 * @brief A dataset containing a grid of vtkHyperTree instances 18 * arranged as a rectilinear grid. 19 * 20 * 21 * A hypertree grid is a dataset containing a rectilinear grid of root nodes, 22 * each of which can be refined as a vtkHyperTree grid. Each root node 23 * corresponds to a cell of the rectilinear grid. This organization of the 24 * root nodes allows for the definition of tree-based AMR grids that do not have 25 * uniform geometry. 26 * Some filters can be applied on this dataset: contour, outline, geometry. 27 * 28 * @warning 29 * It is not a spatial search object. If you are looking for this kind of 30 * octree see vtkCellLocator instead. 31 * Extent support is not finished yet. 32 * 33 * @sa 34 * vtkHyperTree vtkRectilinearGrid 35 * 36 * @par Thanks: 37 * This class was written by Philippe Pebay, Joachim Pouderoux, and Charles Law, Kitware 2013 38 * This class was modified by Guenole Harel and Jacques-Bernard Lekien 2014 39 * This class was rewritten by Philippe Pebay, 2016 40 * This work was supported by Commissariat a l'Energie Atomique (CEA/DIF) 41 */ 42 43 #ifndef vtkHyperTreeGrid_h 44 #define vtkHyperTreeGrid_h 45 46 #include "vtkCommonDataModelModule.h" // For export macro 47 #include "vtkDataSet.h" 48 49 #include <map> // STL header for dual point coordinates adjustment 50 51 class vtkHyperTree; 52 class vtkHyperTreeCursor; 53 class vtkHyperTreeGridCursor; 54 55 class vtkBitArray; 56 class vtkBoundingBox; 57 class vtkCellLinks; 58 class vtkCollection; 59 class vtkDataArray; 60 class vtkDataSetAttributes; 61 class vtkIdTypeArray; 62 class vtkLine; 63 class vtkPixel; 64 class vtkPoints; 65 class vtkVoxel; 66 67 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet 68 { 69 public: 70 class vtkHyperTreeSimpleCursor; 71 class vtkHyperTreePositionCursor; 72 class vtkHyperTreeGridIterator; 73 struct vtkHyperTreeGridSuperCursor; 74 75 static vtkInformationIntegerKey* LEVELS(); 76 static vtkInformationIntegerKey* DIMENSION(); 77 static vtkInformationIntegerKey* ORIENTATION(); 78 static vtkInformationDoubleVectorKey* SIZES(); 79 static vtkHyperTreeGrid* New(); 80 81 vtkTypeMacro(vtkHyperTreeGrid, vtkDataSet); 82 void PrintSelf( ostream&, vtkIndent ) override; 83 84 /** 85 * Return what type of dataset this is. 86 */ 87 int GetDataObjectType() override; 88 89 /** 90 * Copy the internal geometric and topological structure of a 91 * vtkHyperTreeGrid object. 92 */ 93 void CopyStructure( vtkDataSet* ) override; 94 95 //@{ 96 /** 97 * Set/Get the number of local cells in each direction for the underlying rectilinear grid dataset. 98 */ 99 void SetGridSize( unsigned int[3] ); 100 void SetGridSize( unsigned int, unsigned int, unsigned int ); 101 vtkGetVector3Macro(GridSize, unsigned int); 102 //@} 103 104 //@{ 105 /** 106 * Set/Get extent of the underlying rectilinear grid dataset. This is the local extent 107 * and is with respect to the points. 108 */ 109 void SetGridExtent(int extent[6]); 110 void SetGridExtent(int, int, int, int, int, int ); 111 //@} 112 113 //@{ 114 /** 115 * Specify whether indexing mode of grid root cells must be transposed to 116 * x-axis first, z-axis last, instead of the default z-axis first, k-axis last 117 */ 118 vtkSetMacro(TransposedRootIndexing, bool); 119 vtkGetMacro(TransposedRootIndexing, bool); SetIndexingModeToKJI()120 void SetIndexingModeToKJI() 121 { this->SetTransposedRootIndexing( false ); } SetIndexingModeToIJK()122 void SetIndexingModeToIJK() 123 { this->SetTransposedRootIndexing( true ); } 124 //@} 125 126 //@{ 127 /** 128 * Set/Get the dimensionality of the grid. 129 */ 130 void SetDimension( unsigned int ); 131 vtkGetMacro(Dimension, unsigned int); 132 //@} 133 134 //@{ 135 /** 136 * Set/Get the orientation of 1D or 2D grids: 137 * . in 1D: 0, 1, 2 = aligned along X, Y, Z axis 138 * . in 2D: 0, 1, 2 = normal to X, Y, Z axis 139 * NB: Not used in 3D 140 */ 141 virtual void SetOrientation(unsigned int); 142 vtkGetMacro(Orientation, unsigned int); 143 //@} 144 145 //@{ 146 /** 147 * Set/Get the subdivision factor in the grid refinement scheme 148 */ 149 void SetBranchFactor( unsigned int ); 150 vtkGetMacro(BranchFactor, unsigned int); 151 //@} 152 153 /** 154 * Return the number of trees in the level 0 grid. 155 */ 156 vtkIdType GetNumberOfTrees(); 157 158 /** 159 * Get the number of vertices in the primal tree grid. 160 */ 161 vtkIdType GetNumberOfVertices(); 162 163 /** 164 * Get the number of leaves in the primal tree grid. 165 */ 166 vtkIdType GetNumberOfLeaves(); 167 168 /** 169 * Return the number of cells in the dual grid. 170 */ 171 vtkIdType GetNumberOfCells() override; 172 173 /** 174 * Return the number of points in the dual grid. 175 */ 176 vtkIdType GetNumberOfPoints() override; 177 178 /** 179 * Return the number of levels in an individual (primal) tree. 180 */ 181 vtkIdType GetNumberOfLevels( vtkIdType ); 182 183 /** 184 * Return the number of levels in the hyper tree grid. 185 */ 186 vtkIdType GetNumberOfLevels(); 187 188 //@{ 189 /** 190 * Set/Get the grid coordinates in the x-direction. 191 */ 192 void SetXCoordinates( vtkDataArray* ); 193 vtkGetObjectMacro(XCoordinates, vtkDataArray); 194 //@} 195 196 //@{ 197 /** 198 * Set/Get the grid coordinates in the y-direction. 199 */ 200 void SetYCoordinates( vtkDataArray* ); 201 vtkGetObjectMacro(YCoordinates, vtkDataArray); 202 //@} 203 204 //@{ 205 /** 206 * Set/Get the grid coordinates in the z-direction. 207 */ 208 void SetZCoordinates( vtkDataArray* ); 209 vtkGetObjectMacro(ZCoordinates, vtkDataArray); 210 //@} 211 212 //@{ 213 /** 214 * Set/Get the blanking mask of primal leaf cells 215 */ 216 void SetMaterialMask( vtkBitArray* ); 217 vtkGetObjectMacro(MaterialMask, vtkBitArray); 218 //@} 219 220 /** 221 * Determine whether blanking mask is empty or not 222 */ 223 bool HasMaterialMask(); 224 225 //@{ 226 /** 227 * Set/Get the visibility mask of primal leaf cells 228 */ 229 virtual void SetMaterialMaskIndex( vtkIdTypeArray* ); 230 vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray); 231 //@} 232 233 //@{ 234 /** 235 * Set/Get presence or absence of interface 236 */ 237 vtkSetMacro( HasInterface, bool ); 238 vtkGetMacro( HasInterface, bool ); 239 vtkBooleanMacro( HasInterface, bool ); 240 //@} 241 242 //@{ 243 /** 244 * Set/Get names of interface normal vectors arrays 245 */ 246 vtkSetStringMacro(InterfaceNormalsName); 247 vtkGetStringMacro(InterfaceNormalsName); 248 //@} 249 250 //@{ 251 /** 252 * Set/Get names of interface intercepts arrays 253 */ 254 vtkSetStringMacro(InterfaceInterceptsName); 255 vtkGetStringMacro(InterfaceInterceptsName); 256 //@} 257 258 /** 259 * This method must be called once the tree settings change. 260 */ 261 virtual void GenerateTrees(); 262 263 /** 264 * Create a new hyper tree cursor: an object that can traverse 265 * the cells of an individual hyper tree at given index. 266 * If no hyper tree is present at given location, then one 267 * will be created only if 'create' flag is true. 268 */ 269 vtkHyperTreeCursor* NewCursor( vtkIdType, bool create=false ); 270 271 /** 272 * Create a new hyper tree grid cursor: an object that 273 * can traverse the cells of a hyper tree grid, starting at given 274 * tree root index. 275 * If no hyper tree is present at given location, then one 276 * will be created only if 'create' flag is true. 277 */ 278 vtkHyperTreeGridCursor* NewGridCursor( vtkIdType, 279 bool create=false ); 280 281 /** 282 * Create a new hyper tree grid geometric cursor: an object that 283 * can traverse the cells of a hyper tree grid, starting at given 284 * tree root index, managing the geometric properties. 285 * If no hyper tree is present at given location, then one 286 * will be created only if 'create' flag is true. 287 */ 288 vtkHyperTreeGridCursor* NewGeometricCursor( vtkIdType, 289 bool create=false ); 290 291 /** 292 * Create a new hyper tree grid Von Neumann super cursor: an object that 293 * can traverse the cells of a hyper tree grid, starting at given 294 * tree root index, managing geometric properties and von Neumann 295 * neighborhood with basic hyper tree grid cursors. 296 * If no hyper tree is present at given location, then one 297 * will be created only if 'create' flag is true. 298 */ 299 vtkHyperTreeGridCursor* NewVonNeumannSuperCursor( vtkIdType, 300 bool create=false ); 301 302 /** 303 * Create a new hyper tree grid Moore super cursor: an object that 304 * can traverse the cells of a hyper tree grid, starting at given 305 * tree root index, managing geometric properties and Moore 306 * neighborhood with basic hyper tree grid cursors. 307 * If no hyper tree is present at given location, then one 308 * will be created only if 'create' flag is true. 309 */ 310 vtkHyperTreeGridCursor* NewMooreSuperCursor( vtkIdType, 311 bool create=false ); 312 313 /** 314 * Subdivide node pointed by cursor, only if its a leaf. 315 * At the end, cursor points on the node that used to be leaf. 316 * \pre leaf_exists: leaf!=0 317 * \pre is_a_leaf: leaf->CurrentIsLeaf() 318 */ 319 void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType ); 320 321 /** 322 * This method should be avoided in favor of cell/point iterators. 323 * Random access to points requires that arrays are created explicitly. 324 * Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints. 325 * THIS METHOD IS NOT THREAD SAFE. 326 */ 327 double* GetPoint( vtkIdType ) override; 328 329 /** 330 * This method should be avoided in favor of cell/point iterators. 331 * Random access to points requires that arrays are created explicitly. 332 * Copy point coordinates into user provided array x[3] for specified 333 * point id. 334 * THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD AND 335 * THE DATASET IS NOT MODIFIED 336 */ 337 void GetPoint( vtkIdType, double[3] ) override; 338 339 /** 340 * This method should be avoided in favor of cell/point iterators. 341 * Random access to cells requires that connectivity arrays are created explicitly. 342 * Get cell with cellId such that: 0 <= cellId < NumberOfCells. 343 * THIS METHOD IS NOT THREAD SAFE. 344 */ 345 vtkCell* GetCell( vtkIdType ) override; 346 347 /** 348 * Overridden so as no not unintentionally hide parent class. 349 * See -Woverloaded-virtual 350 */ GetCell(int i,int j,int k)351 vtkCell* GetCell( int i, int j, int k) override { 352 return this->Superclass::GetCell(i,j,k); 353 }; 354 355 /** 356 * This method should be avoided in favor of cell/point iterators. 357 * Random access to cells requires that connectivity arrays are created explicitly. 358 * Get cell with cellId such that: 0 <= cellId < NumberOfCells. 359 * This is a thread-safe alternative to the previous GetCell() 360 * method. 361 * THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD AND 362 * THE DATASET IS NOT MODIFIED 363 */ 364 void GetCell( vtkIdType, vtkGenericCell* ) override; 365 366 /** 367 * All cell types are 2: quadrilaters,3d: hexahedrons. They may be degenerate though. 368 * Get type of cell with cellId such that: 0 <= cellId < NumberOfCells. 369 * THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD AND 370 * THE DATASET IS NOT MODIFIED 371 */ 372 int GetCellType( vtkIdType ) override; 373 374 /** 375 * This method should be avoided in favor of cell/point iterators. 376 * Random access to cells requires that connectivity arrays are created explicitly. 377 * Topological inquiry to get points defining cell. 378 * THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD AND 379 * THE DATASET IS NOT MODIFIED 380 */ 381 void GetCellPoints( vtkIdType, vtkIdList* ) override; 382 383 /** 384 * Return a pointer to a list of point ids defining cell. 385 * NB: More efficient than alternative method. 386 */ 387 void GetCellPoints( vtkIdType, vtkIdType&, vtkIdType*& ); 388 389 /** 390 * This method should be avoided in favor of cell/point iterators. 391 * Random access to cells requires that connectivity arrays are created explicitly. 392 * Topological inquiry to get cells using point. 393 * THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD AND 394 * THE DATASET IS NOT MODIFIED 395 */ 396 void GetPointCells( vtkIdType, vtkIdList* ) override; 397 398 /** 399 * This method should be avoided in favor of cell/point iterators. 400 * Random access to cells requires that connectivity arrays are created explicitly. 401 * Topological inquiry to get all cells using list of points exclusive of 402 * cell specified (e.g., cellId). Note that the list consists of only 403 * cells that use ALL the points provided. 404 * This is exactly the same as GetCellNeighbors in unstructured grid. 405 * THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD AND 406 * THE DATASET IS NOT MODIFIED 407 */ 408 void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) override; 409 410 /** 411 * Find cell to which this point belongs, or at least closest one, 412 * even if the point is outside the grid. 413 * Since dual points are leaves, use the structure of the Tree instead 414 * of a point locator. 415 */ 416 vtkIdType FindPoint( double x[3] ) override; 417 418 /** 419 * Locate cell based on global coordinate x and tolerance 420 * squared. If cell and cellId is non-nullptr, then search starts from 421 * this cell and looks at immediate neighbors. Returns cellId >= 0 422 * if inside, < 0 otherwise. The parametric coordinates are 423 * provided in pcoords[3]. The interpolation weights are returned in 424 * weights[]. (The number of weights is equal to the number of 425 * points in the found cell). Tolerance is used to control how close 426 * the point is to be considered "in" the cell. 427 * NB: There is actually no need for a starting cell, just use the 428 * point, as the tree structure is efficient enough. 429 * THIS METHOD IS NOT THREAD SAFE. 430 */ 431 vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId, 432 double tol2, int& subId, double pcoords[3], 433 double *weights ) override; 434 435 /** 436 * This is a version of the above method that can be used with 437 * multithreaded applications. A vtkGenericCell must be passed in 438 * to be used in internal calls that might be made to GetCell() 439 * THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD AND 440 * THE DATASET IS NOT MODIFIED 441 */ 442 vtkIdType FindCell( double x[3], vtkCell *cell, 443 vtkGenericCell *gencell, vtkIdType cellId, 444 double tol2, int& subId, double pcoords[3], 445 double *weights ) override; 446 447 /** 448 * Restore data object to initial state. 449 */ 450 void Initialize() override; 451 452 /** 453 * Return tree located at given index of hyper tree grid 454 * NB: This will return nullptr if grid slot is empty. 455 */ 456 vtkHyperTree* GetTree( vtkIdType ); 457 458 /** 459 * Assign given tree to given index of hyper tree grid 460 * NB: This will create a new slot in the grid if needed. 461 */ 462 void SetTree( vtkIdType, vtkHyperTree* ); 463 464 /** 465 * Initialize an iterator to browse level 0 trees. 466 * FIXME: this method is completely unnecessary. 467 */ 468 void InitializeTreeIterator( vtkHyperTreeGridIterator& ); 469 470 /** 471 * Convenience method to return largest cell size in dataset. 472 * Generally used to allocate memory for supporting data structures. 473 * This is the number of points of a cell. 474 * THIS METHOD IS THREAD SAFE 475 */ 476 int GetMaxCellSize() override; 477 478 /** 479 * Create shallow copy of hyper tree grid. 480 */ 481 void ShallowCopy( vtkDataObject* ) override; 482 483 /** 484 * Create deep copy of hyper tree grid. 485 */ 486 void DeepCopy( vtkDataObject* ) override; 487 488 /** 489 * Structured extent. The extent type is a 3D extent. 490 */ GetExtentType()491 int GetExtentType() override { return VTK_3D_EXTENT; } 492 493 /** 494 * Return the actual size of the data in kibibytes (1024 bytes). This number 495 * is valid only after the pipeline has updated. The memory size 496 * returned is guaranteed to be greater than or equal to the 497 * memory required to represent the data (e.g., extra space in 498 * arrays, etc. are not included in the return value). THIS METHOD 499 * IS THREAD SAFE. 500 */ 501 unsigned long GetActualMemorySize() override; 502 503 //@{ 504 /** 505 * The number of children each node can have. 506 */ 507 vtkGetMacro(NumberOfChildren, unsigned int); 508 //@} 509 510 /** 511 * Recursively initialize pure material mask 512 */ 513 bool RecursivelyInitializePureMaterialMask( vtkHyperTreeGridCursor* cursor ); 514 515 /** 516 * Get or create pure material mask 517 */ 518 vtkBitArray* GetPureMaterialMask(); 519 520 /** 521 * Return hard-coded bitcode correspondng to child mask 522 * Dimension 1: 523 * Factor 2: 524 * 0: 100, 1: 001 525 * Factor 3: 526 * 0: 100, 1: 010, 2: 001 527 * Dimension 2: 528 * Factor 2: 529 * 0: 1101 0000 0, 1: 0110 0100 0 530 * 2: 0001 0011 0, 3: 0000 0101 1 531 * Factor 3: 532 * 0: 1101 0000 0, 1: 0100 0000 0, 2: 0110 0100 0 533 * 3: 0001 0000 0, 4: 0000 1000 0, 5: 0000 0100 0 534 * 6: 0001 0011 0, 7: 0000 0001 0, 8: 0000 0101 1 535 * Dimension 3: 536 * Factor 2: 537 * 0: 1101 1000 0110 1000 0000 0000 000, 1: 0110 1100 0011 0010 0000 0000 000 538 * 2: 0001 1011 0000 1001 1000 0000 000, 3: 0000 1101 1000 0010 1100 0000 000 539 * 4: 0000 0000 0110 1000 0011 0110 000, 5: 0000 0000 0011 0010 0001 1011 000 540 * 6: 0000 0000 0000 1001 1000 0110 110, 7: 0000 0000 0000 0010 1100 0011 011 541 * Factor 3: 542 * 0: 1101 1000 0110 1000 0000 0000 000 543 * 1: 0100 1000 0010 0000 0000 0000 000 544 * 2: 0110 1100 0011 0010 0000 0000 000 545 * 3: 0001 1000 0000 1000 0000 0000 000 546 * 4: 0000 1000 0000 0000 0000 0000 000 547 * 5: 0000 1100 0000 0010 0000 0000 000 548 * 6: 0001 1011 0000 1001 1000 0000 000 549 * 7: 0000 1001 0000 0000 1000 0000 000 550 * 8: 0000 1101 1000 0010 1100 0000 000 551 * 9: 0000 0000 0110 1000 0000 0000 000 552 * 10: 0000 0000 0010 0000 0000 0000 000 553 * 11: 0000 0000 0011 0010 0000 0000 000 554 * 12: 0000 0000 0000 1000 0000 0000 000 555 * 13: 0000 0000 0000 0100 0000 0000 000 556 * 14: 0000 0000 0000 0010 0000 0000 000 557 * 15: 0000 0000 0000 1001 1000 0000 000 558 * 16: 0000 0000 0000 0000 1000 0000 000 559 * 17: 0000 0000 0000 0010 1100 0000 000 560 * 18: 0000 0000 0110 1000 0011 0110 000 561 * 19: 0000 0000 0010 0000 0001 0010 000 562 * 20: 0000 0000 0011 0010 0001 1011 000 563 * 21: 0000 0000 0000 1000 0000 0110 000 564 * 22: 0000 0000 0000 0000 0000 0010 000 565 * 23: 0000 0000 0000 0010 0000 0011 000 566 * 24: 0000 0000 0000 1001 1000 0110 110 567 * 25: 0000 0000 0000 0000 1000 0010 010 568 * 26: 0000 0000 0000 0010 1100 0011 011 569 */ 570 unsigned int GetChildMask( unsigned int ); 571 572 /** 573 * Convert the global index of a root to its Cartesian coordinates in the grid. 574 */ 575 void GetLevelZeroCoordinatesFromIndex( vtkIdType, 576 unsigned int&, 577 unsigned int&, 578 unsigned int& ); 579 580 /** 581 * Convert the Cartesian coordinates of a root in the grid to its global index. 582 */ 583 void GetIndexFromLevelZeroCoordinates( vtkIdType&, 584 unsigned int, 585 unsigned int, 586 unsigned int ); 587 588 /** 589 * Return the root index of a root cell with given index displaced. 590 * by a Cartesian vector in the grid. 591 * NB: No boundary checks are performed. 592 */ 593 unsigned int GetShiftedLevelZeroIndex( vtkIdType, 594 int, 595 int, 596 int ); 597 598 //@{ 599 /** 600 * A simplified hyper tree cursor, to be used by the hyper tree. 601 * grid supercursor. 602 */ 603 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor 604 { 605 public: 606 vtkHyperTreeSimpleCursor(); 607 ~vtkHyperTreeSimpleCursor(); 608 //@} 609 610 //@{ 611 /** 612 * Methods that belong to the vtkHyperTreeCursor API. 613 */ GetTree()614 vtkHyperTree* GetTree() { return this->Tree; } 615 //@} 616 617 /** 618 * Only valid for leaves. 619 */ GetLeafIndex()620 vtkIdType GetLeafIndex() { return this->Index; } 621 622 /** 623 * Return level at which cursor is positioned. 624 */ GetLevel()625 unsigned short GetLevel() { return this->Level; } 626 627 private: 628 vtkHyperTree* Tree; 629 vtkIdType Index; 630 unsigned short Level; 631 }; 632 633 /** 634 * Public structure used by filters to move around the hyper 635 * tree grid and easily access neighbors to leaves. 636 * The super cursor is 'const'. Methods in vtkHyperTreeGrid 637 * initialize and compute children for moving toward leaves. 638 */ 639 struct vtkHyperTreeGridSuperCursor 640 { 641 double Origin[3]; 642 double Size[3]; 643 int NumberOfCursors; 644 int MiddleCursorId; 645 vtkHyperTreeSimpleCursor Cursors[3*3*3]; 646 vtkHyperTreeSimpleCursor* GetCursor( int ); 647 }; 648 649 /** 650 * An iterator object to iteratively access trees in the grid. 651 */ 652 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator 653 { 654 public: vtkHyperTreeGridIterator()655 vtkHyperTreeGridIterator() {} 656 657 /** 658 * Initialize the iterator on the tree set of the given grid. 659 */ 660 void Initialize( vtkHyperTreeGrid* ); 661 662 /** 663 * Get the next tree and set its index then increment the iterator. 664 * Returns 0 at the end. 665 */ 666 vtkHyperTree* GetNextTree( vtkIdType& index ); 667 668 /** 669 * Get the next tree and set its index then increment the iterator. 670 * Returns 0 at the end. 671 */ 672 vtkHyperTree* GetNextTree(); 673 674 protected: 675 std::map<vtkIdType, vtkHyperTree*>::iterator Iterator; 676 vtkHyperTreeGrid* Tree; 677 }; 678 679 //@{ 680 /** 681 * Retrieve an instance of this class from an information object 682 */ 683 static vtkHyperTreeGrid* GetData( vtkInformation* info ); 684 static vtkHyperTreeGrid* GetData( vtkInformationVector* v, int i=0); 685 //@} 686 687 protected: 688 /** 689 * Constructor with default bounds (0,1, 0,1, 0,1). 690 */ 691 vtkHyperTreeGrid(); 692 693 /** 694 * Destructor 695 */ 696 ~vtkHyperTreeGrid() override; 697 698 void ComputeBounds() override; 699 700 /** 701 * Traverse tree with 3x3x3 super cursor. Center cursor generates dual point. 702 * Smallest leaf (highest level) owns corners/dual cell. Ties are given to 703 * smallest index (z,y,x order) 704 * post: Generate Points and Connectivity. 705 */ 706 void ComputeDualGrid(); 707 708 vtkPoints* GetPoints(); 709 vtkIdTypeArray* GetConnectivity(); 710 711 unsigned int BranchFactor; // 2 or 3 712 unsigned int Dimension; // 1, 2, or 3 713 unsigned int Orientation; // 0, 1, or 2 714 unsigned int GridSize[3]; 715 int Extent[6]; 716 unsigned int NumberOfChildren; 717 bool TransposedRootIndexing; 718 719 vtkBitArray* MaterialMask; 720 vtkBitArray* PureMaterialMask; 721 vtkIdTypeArray* MaterialMaskIndex; 722 bool InitPureMaterialMask; 723 724 bool HasInterface; 725 char* InterfaceNormalsName; 726 char* InterfaceInterceptsName; 727 728 vtkDataArray* XCoordinates; 729 vtkDataArray* YCoordinates; 730 vtkDataArray* ZCoordinates; 731 732 std::map<vtkIdType, vtkHyperTree*> HyperTrees; 733 734 vtkPoints* Points; 735 vtkIdTypeArray* Connectivity; 736 std::map<vtkIdType, bool> PointShifted; 737 std::map<vtkIdType, double> PointShifts[3]; 738 std::map<vtkIdType, double> ReductionFactors; 739 740 /** 741 * Perform left to right deep copy of hyper tree cursors. 742 */ 743 void DeepCopyCursors( vtkHyperTreeCursor*, vtkHyperTreeCursor* ); 744 745 /** 746 * Remove existing trees. 747 */ 748 void DeleteTrees(); 749 750 /** 751 * Reset dual mesh 752 */ 753 void ResetDual(); 754 755 /** 756 * A convenience method to reset all cursors in a super cursor, 757 * either Von Neumann or Moore. 758 * This is to be used by Initialize() and ToRoot(), factoring 759 * out the commonalities shared by these methods, while allowing for 760 * different inheritances. 761 */ 762 void ResetSuperCursor(); 763 764 /** 765 * Recursively descend into tree down to leaves to generate dual. 766 */ 767 void TraverseDualRecursively( vtkHyperTreeGridCursor* ); 768 769 /** 770 * Recursively descend into tree down to leaves to generate dual, 771 * when a mask array is present. 772 */ 773 void TraverseDualRecursively( vtkHyperTreeGridCursor*, vtkBitArray* ); 774 775 /** 776 * Process leaf cell and issue corresponding dual corner point in 1D. 777 */ 778 void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor* ); 779 780 /** 781 * Process leaf cell and issue corresponding dual corner point in 1D, 782 * when a mask array is present. 783 */ 784 void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor*, vtkBitArray* ); 785 786 /** 787 * Process leaf cell and issue corresponding dual corner point in 2D. 788 */ 789 void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor* ); 790 791 /** 792 * Process leaf cell and issue corresponding dual corner point in 2D, 793 * when a mask array is present. 794 */ 795 void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* ); 796 797 /** 798 * Process leaf cell and issue corresponding dual corner point in 3D. 799 */ 800 void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor* ); 801 802 /** 803 * Process leaf cell and issue corresponding dual corner point in 3D, 804 * when a mask array is present. 805 */ 806 void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* ); 807 808 /** 809 * Compute appropriate shifts for dual corners of masked cells in 2D. 810 */ 811 void ShiftDualCornerFromMaskedLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* ); 812 813 /** 814 * Compute appropriate shifts for dual corners of masked cells in 3D. 815 */ 816 void ShiftDualCornerFromMaskedLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* ); 817 818 /** 819 * Recursive method called under the hood by FindPoint(). 820 */ 821 vtkIdType RecursivelyFindPoint( double x[3], 822 vtkHyperTreeGridCursor*, 823 double*, 824 double* ); 825 826 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__) 827 void EvaluateDualCorner( vtkHyperTreeSimpleCursor* ); 828 #endif 829 830 //@{ 831 /** 832 * These are needed by the GetCell() method. 833 */ 834 vtkLine* Line; 835 vtkPixel* Pixel; 836 vtkVoxel* Voxel; 837 //@} 838 839 //@{ 840 /** 841 * Not really needed. Might be removed (is it a part of the vtkDataSet API?). 842 */ 843 vtkCellLinks* Links; 844 void BuildLinks(); 845 //@} 846 847 private: 848 vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete; 849 void operator=(const vtkHyperTreeGrid&) = delete; 850 851 void GetCellImplementation( vtkIdType, vtkCell* ); 852 }; 853 854 #endif 855