VTK  9.7.20260718
vtkHyperTreeGrid.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
58
59#ifndef vtkHyperTreeGrid_h
60#define vtkHyperTreeGrid_h
61
62#include "vtkCommonDataModelModule.h" // For export macro
63#include "vtkDataObject.h"
64
65#include "vtkDeprecation.h" // for deprecation macro
66#include "vtkNew.h" // vtkSmartPointer
67#include "vtkSmartPointer.h" // vtkSmartPointer
68
69#include <cassert> // std::assert
70#include <limits> // limits
71#include <map> // std::map
72
73VTK_ABI_NAMESPACE_BEGIN
74class vtkBitArray;
75class vtkBoundingBox;
76class vtkCellLinks;
77class vtkCollection;
78class vtkDataArray;
79class vtkHyperTree;
90class vtkDoubleArray;
92class vtkIdTypeArray;
93class vtkLine;
94class vtkPixel;
95class vtkPoints;
96class vtkCellData;
98
99class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
100{
101public:
103
105 void PrintSelf(ostream& os, vtkIndent indent) override;
106
111 static constexpr vtkIdType InvalidIndex = ~0;
112
116 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_HYPER_TREE_GRID; }
117
123
128
129 // --------------------------------------------------------------------------
130 // RectilinearGrid common API
131 // --------------------------------------------------------------------------
132
134
137 void SetDimensions(const unsigned int dims[3]);
138 void SetDimensions(const int dims[3]);
139 void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
140 void SetDimensions(int i, int j, int k);
142
144
148 const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
149 void GetDimensions(int dim[3]) const;
150 void GetDimensions(unsigned int dim[3]) const;
152
154
160 void SetExtent(const int extent[6]);
161 void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
162 vtkGetVector6Macro(Extent, int);
164
166
171 const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
172 void GetCellDims(int cellDims[3]) const;
173 void GetCellDims(unsigned int cellDims[3]) const;
175
176 // --------------------------------------------------------------------------
177
179
182 unsigned int GetDimension() const { return this->Dimension; }
184
186
189 void Get1DAxis(unsigned int& axis) const
190 {
191 assert("pre: valid_dim" && this->GetDimension() == 1);
192 axis = this->Axis[0];
193 }
194
195
197
200 void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
201 {
202 assert("pre: valid_dim" && this->GetDimension() == 2);
203 axis1 = this->Axis[0];
204 axis2 = this->Axis[1];
205 }
206
207
209
212 const unsigned int* GetAxes() const { return this->Axis; }
214
216
219 // vtkGetMacro(NumberOfChildren, unsigned int); not const
220 unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
222
224
228 vtkSetMacro(TransposedRootIndexing, bool);
229 vtkGetMacro(TransposedRootIndexing, bool);
233
235
241 unsigned int GetOrientation() const { return this->Orientation; }
243
245
248 void SetBranchFactor(unsigned int);
249 unsigned int GetBranchFactor() const { return this->BranchFactor; }
251
256
261
266
271
275 unsigned int GetNumberOfLevels();
276
278
284
286
292
294
300
302
305 virtual void CopyCoordinates(const vtkHyperTreeGrid* output);
306 virtual void SetFixedCoordinates(unsigned int axis, double value);
308
310
316
320 bool HasMask();
321
323
326 vtkSetMacro(HasInterface, bool);
327 vtkGetMacro(HasInterface, bool);
328 vtkBooleanMacro(HasInterface, bool);
330
332
335 vtkSetStringMacro(InterfaceNormalsName);
336 vtkGetStringMacro(InterfaceNormalsName);
338
340
343 vtkSetStringMacro(InterfaceInterceptsName);
344 vtkGetStringMacro(InterfaceInterceptsName);
346
348
351 vtkSetMacro(DepthLimiter, unsigned int);
352 vtkGetMacro(DepthLimiter, unsigned int);
354
356
366 vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
369
371 vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
374 vtkIdType index, bool create = false);
375
377 vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
380
382 vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
385 vtkIdType index, bool create = false);
386
389 bool create = false);
392 vtkIdType index, bool create = false);
394
399
404 virtual void GenerateGhostArray(int zeroExt[6]);
405
406private:
407 unsigned int RecurseDichotomic(
408 double value, vtkDoubleArray* coord, double tol, unsigned int ideb, unsigned int ifin) const;
409
410 unsigned int FindDichotomic(double value, vtkDataArray* coord, double tol) const;
411
412public:
413 virtual unsigned int FindDichotomicX(double value, double tol = 0.0) const;
414 virtual unsigned int FindDichotomicY(double value, double tol = 0.0) const;
415 virtual unsigned int FindDichotomicZ(double value, double tol = 0.0) const;
416
418
428 vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* cursor, vtkIdType index, bool create = false);
431 vtkIdType index, bool create = false);
432
435 bool create = false);
438 vtkIdType index, bool create = false);
439
441 vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, vtkIdType index, bool create = false);
444 vtkIdType index, bool create = false);
445
447 vtkHyperTreeGridNonOrientedMooreSuperCursorLight* cursor, vtkIdType index, bool create = false);
450 vtkIdType index, bool create = false);
451
454 bool create = false);
457 vtkIdType index, bool create = false);
459
463 void Initialize() override;
464
469 virtual vtkHyperTree* GetTree(vtkIdType index, bool create = false);
470
476
481 size_t RemoveTree(vtkIdType index);
482
486 void ShallowCopy(vtkDataObject*) override;
487
491 void DeepCopy(vtkDataObject*) override;
492
496 int GetExtentType() VTK_FUTURE_CONST override { return VTK_3D_EXTENT; }
497
506 virtual unsigned long GetActualMemorySizeBytes();
507
516 unsigned long GetActualMemorySize() override;
517
521 bool SupportsGhostArray(int type) override;
522
523private:
527 bool RecursivelyInitializePureMask(vtkHyperTreeGridNonOrientedCursor*, vtkDataArray*);
528
535 void CleanPureMask();
536
537public:
560
611 unsigned int GetChildMask(unsigned int);
612
616 void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
617
629
634 vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
635
639 virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
640
645
651
656
660 bool HasAnyGhostCells() const;
661
667
674
679
683 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
684 {
685 public:
687
692
698
704
705 protected:
706 std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
708 };
709
714
716
722
727 virtual void ComputeBounds();
728
730
738 virtual double* GetBounds() VTK_SIZEHINT(6);
739 void GetBounds(double bounds[6]);
741
747 virtual void GetGridBounds(double bounds[6]);
748
754
759 void GetCenter(double center[3]);
760
766
773
779 vtkIdType GetNumberOfElements(int type) override;
780
786
787protected:
792
793 ~vtkHyperTreeGrid() override;
794
795 double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
796 double Center[3]{ 0.0, 0.0, 0.0 }; // geometric center
797
798 unsigned int BranchFactor = 0; // 2 or 3, 0 for invalid
799 unsigned int Dimension = 0; // 1, 2, or 3, 0 for invalid
800
801private:
802 // Invalid default grid parameters to force actual initialization
803 unsigned int Orientation = std::numeric_limits<unsigned int>::max(); // 0, 1, or 2
804 unsigned int Axis[2] = { std::numeric_limits<unsigned int>::max(),
805 std::numeric_limits<unsigned int>::max() };
806
807 vtkTimeStamp ComputeTime;
808
810
815 bool TreeGhostArrayCached = false;
817
818protected:
819 unsigned int NumberOfChildren = 0;
821
822 // --------------------------------
823 // RectilinearGrid common fields
824 // --------------------------------
825private:
826 unsigned int Dimensions[3] = { 0, 0, 0 }; // Just for GetDimensions
827 unsigned int CellDims[3] = { 0, 0, 0 }; // Just for GetCellDims
828protected:
830 int Extent[6] = { 0, -1, 0, -1, 0, -1 };
831
832 bool WithCoordinates = false;
836 // --------------------------------
837
840
841 bool HasInterface = false;
842 char* InterfaceNormalsName = nullptr;
843 char* InterfaceInterceptsName = nullptr;
844
845 std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>> HyperTrees;
846
847 vtkNew<vtkCellData> CellData; // Scalars, vectors, etc. associated w/ each point
848
849 unsigned int DepthLimiter = std::numeric_limits<unsigned int>::max();
850
851private:
852 vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
853 void operator=(const vtkHyperTreeGrid&) = delete;
854};
855
856VTK_ABI_NAMESPACE_END
857#endif
dynamic, self-adjusting array of bits
Definition vtkBitArray.h:33
Fast, simple class for representing and operating on 3D bounds.
represent and manipulate cell attribute data
create and manipulate ordered lists of objects
represent and manipulate attribute data in a dataset
dynamic, self-adjusting array of double
Represents and manipulates a collection of data arrays.
Objects for traversal a HyperTreeGrid.
Objects for traversal a HyperTreeGrid.
An iterator object to iteratively access trees in the grid.
void Initialize(vtkHyperTreeGrid *grid)
Initialize the iterator on the tree set of the given grid.
std::map< vtkIdType, vtkSmartPointer< vtkHyperTree > >::iterator Iterator
vtkHyperTree * GetNextTree()
Get the next tree and set its index then increment the iterator.
vtkHyperTree * GetNextTree(vtkIdType &index)
Get the next tree and set its index then increment the iterator.
bool HasMask()
Determine whether blanking mask is empty or not.
vtkHyperTreeGridNonOrientedMooreSuperCursorLight * NewNonOrientedMooreSuperCursorLight(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
vtkFieldData * GetAttributesAsFieldData(int type) override
Returns the hypertree node field data stored as cell data.
vtkHyperTreeGridNonOrientedCursor * NewNonOrientedCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
vtkIdType GetNumberOfCells()
Return the number of cells.
const unsigned int * GetCellDims() const
Get grid sizes of this structured cells dataset.
vtkBitArray * PureMask
void InitializeNonOrientedUnlimitedGeometryCursor(vtkHyperTreeGridNonOrientedUnlimitedGeometryCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
void SetMask(vtkBitArray *)
Set/Get the blanking mask of primal leaf cells.
virtual void CopyCoordinates(const vtkHyperTreeGrid *output)
Utility methods to set coordinates.
void InitializeNonOrientedVonNeumannSuperCursorLight(vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
virtual void GetLevelZeroOriginFromIndex(vtkIdType, double *)
Convert the global index of a root to its Spatial coordinates origin and size.
vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight * NewNonOrientedVonNeumannSuperCursorLight(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
vtkHyperTreeGridOrientedCursor * NewOrientedCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
const unsigned int * GetDimensions() const
Get dimensions of this rectilinear grid dataset.
double * GetCenter()
Get the center of the bounding box.
virtual vtkBitArray * GetMask()
Set/Get the blanking mask of primal leaf cells.
std::map< vtkIdType, vtkSmartPointer< vtkHyperTree > > HyperTrees
virtual void SetFixedCoordinates(unsigned int axis, double value)
Utility methods to set coordinates.
virtual void CopyEmptyStructure(vtkDataObject *)
Copy the internal structure with no data associated.
void DeepCopy(vtkDataObject *) override
Create deep copy of hyper tree grid.
void Get1DAxis(unsigned int &axis) const
Return the index of the valid dimension.
static vtkHyperTreeGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
void GetIndexFromLevelZeroCoordinates(vtkIdType &, unsigned int, unsigned int, unsigned int) const
Convert the Cartesian coordinates of a root in the grid to its global index.
void InitializeOrientedGeometryCursor(vtkHyperTreeGridOrientedGeometryCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
virtual void CopyStructure(vtkDataObject *)
Copy the internal geometric and topological structure of a vtkHyperTreeGrid object.
const unsigned int * GetAxes() const
Get the axis information (used for CopyStructure)
unsigned int GetNumberOfLevels(vtkIdType)
Return the number of levels in an individual (primal) tree.
vtkSmartPointer< vtkDataArray > YCoordinates
virtual void SetYCoordinates(vtkDataArray *)
Set/Get the grid coordinates in the y-direction.
vtkIdType GetMaxNumberOfTrees() const
Return the maximum number of trees in the level 0 grid.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetXCoordinates(vtkDataArray *)
Set/Get the grid coordinates in the x-direction.
virtual vtkDataArray * GetZCoordinates()
Set/Get the grid coordinates in the z-direction.
virtual unsigned int FindDichotomicY(double value, double tol=0.0) const
size_t RemoveTree(vtkIdType index)
Remove the tree at the given index.
vtkCellData * GetCellData()
Return a pointer to this dataset's hypertree node data.
vtkIdType GetNumberOfElements(int type) override
Returns the number of nodes.
virtual vtkHyperTree * GetTree(vtkIdType index, bool create=false)
Return tree located at given index of hyper tree grid NB: This will construct a new HyperTree if grid...
vtkHyperTreeGridNonOrientedGeometryCursor * FindNonOrientedGeometryCursor(double x[3])
Return a geometric cursor pointing to one of the nodes at position x
vtkUnsignedCharArray * GetTreeGhostArray()
Gets the array that defines the ghost type of each cell.
void Initialize() override
Restore data object to initial state.
unsigned int GetOrientation() const
Get the orientation of 1D or 2D grids:
static constexpr vtkIdType InvalidIndex
Invalid index that is returned for undefined nodes, for example for nodes that are out of bounds (the...
void SetIndexingModeToKJI()
Specify whether indexing mode of grid root cells must be transposed to x-axis first,...
void SetTree(vtkIdType, vtkHyperTree *)
Assign given tree to given index of hyper tree grid NB: This will create a new slot in the grid if ne...
virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double *, double *)
Convert the global index of a root to its Spatial coordinates origin and size.
int GetExtentType() VTK_FUTURE_CONST override
Structured extent.
void InitializeNonOrientedMooreSuperCursorLight(vtkHyperTreeGridNonOrientedMooreSuperCursorLight *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
virtual unsigned int FindDichotomicX(double value, double tol=0.0) const
unsigned int DepthLimiter
void SetDimensions(unsigned int i, unsigned int j, unsigned int k)
Set/Get sizes of this rectilinear grid dataset.
vtkUnsignedCharArray * AllocateTreeGhostArray()
Allocate ghost array for points.
vtkIdType GetNumberOfNonEmptyTrees()
Get the number of non empty trees in this grid.
virtual unsigned long GetActualMemorySizeBytes()
Return the actual size of the data in bytes.
vtkHyperTreeGridOrientedGeometryCursor * NewOrientedGeometryCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
void Get2DAxes(unsigned int &axis1, unsigned int &axis2) const
Return the indices of the two valid dimensions.
static vtkHyperTreeGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
vtkHyperTreeGridNonOrientedGeometryCursor * NewNonOrientedGeometryCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
vtkIdType GetGlobalNodeIndexMax()
Return the maximum global index value.
int GetDataObjectType() VTK_FUTURE_CONST override
Return what type of dataset this is.
void InitializeOrientedCursor(vtkHyperTreeGridOrientedCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
void InitializeLocalIndexNode()
Initialize local indexes for every individual Hyper Tree after they have been refined.
vtkHyperTreeGridNonOrientedUnlimitedGeometryCursor * NewNonOrientedUnlimitedGeometryCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
virtual void ComputeBounds()
Compute the hyper tree grid bounding box ignoring masked cells.
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
bool SupportsGhostArray(int type) override
Returns true if type is CELL, false otherwise.
vtkSmartPointer< vtkBitArray > Mask
void InitializeNonOrientedMooreSuperCursor(vtkHyperTreeGridNonOrientedMooreSuperCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
virtual vtkDataArray * GetYCoordinates()
Set/Get the grid coordinates in the y-direction.
vtkSmartPointer< vtkDataArray > XCoordinates
unsigned int Dimension
vtkHyperTreeGridNonOrientedUnlimitedMooreSuperCursor * NewNonOrientedUnlimitedMooreSuperCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
unsigned int GetNumberOfLevels()
Return the number of levels in the hyper tree grid.
void SetDimensions(const unsigned int dims[3])
Set/Get sizes of this rectilinear grid dataset.
void SetExtent(const int extent[6])
Different ways to set the extent of the data array.
virtual unsigned int FindDichotomicZ(double value, double tol=0.0) const
virtual void GenerateGhostArray(int zeroExt[6])
Generate the ghost array for this hypertree grid.
vtkIdType GetShiftedLevelZeroIndex(vtkIdType, int, int, int) const
Return the root index of a root cell with given index displaced.
void SetDimensions(int i, int j, int k)
Set/Get sizes of this rectilinear grid dataset.
unsigned int GetChildMask(unsigned int)
Return hard-coded bitcode correspondng to child mask Dimension 1: Factor 2: 0: 100,...
vtkUnsignedCharArray * GetGhostCells()
Gets the array that defines the ghost type of each cell.
virtual void SetZCoordinates(vtkDataArray *)
Set/Get the grid coordinates in the z-direction.
vtkHyperTreeGridNonOrientedVonNeumannSuperCursor * NewNonOrientedVonNeumannSuperCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
void SetIndexingModeToIJK()
Specify whether indexing mode of grid root cells must be transposed to x-axis first,...
static vtkHyperTreeGrid * New()
vtkSmartPointer< vtkDataArray > ZCoordinates
vtkBitArray * GetPureMask()
Get or create pure material mask.
void InitializeTreeIterator(vtkHyperTreeGridIterator &it)
Initialize an iterator to browse level 0 trees.
bool HasAnyGhostCells() const
Returns true if a ghost cell array is defined.
void SetBranchFactor(unsigned int)
Set/Get the subdivision factor in the grid refinement scheme.
virtual vtkDataArray * GetXCoordinates()
Set/Get the grid coordinates in the x-direction.
void InitializeNonOrientedUnlimitedMooreSuperCursor(vtkHyperTreeGridNonOrientedUnlimitedMooreSuperCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
vtkIdType GetNumberOfLeaves()
Get the number of leaves in the primal tree grid.
void ShallowCopy(vtkDataObject *) override
Create shallow copy of hyper tree grid.
virtual double * GetBounds()
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
vtkHyperTreeGrid()
Constructor with default bounds (0,1, 0,1, 0,1).
unsigned int GetBranchFactor() const
Set/Get the subdivision factor in the grid refinement scheme.
vtkNew< vtkCellData > CellData
vtkHyperTreeGridNonOrientedMooreSuperCursor * NewNonOrientedMooreSuperCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
void InitializeNonOrientedGeometryCursor(vtkHyperTreeGridNonOrientedGeometryCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
void InitializeNonOrientedCursor(vtkHyperTreeGridNonOrientedCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
unsigned int GetDimension() const
Get the dimensionality of the grid from the Dimensions/Extent.
unsigned int GetNumberOfChildren() const
The number of children each node can have.
void InitializeNonOrientedVonNeumannSuperCursor(vtkHyperTreeGridNonOrientedVonNeumannSuperCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
void GetLevelZeroCoordinatesFromIndex(vtkIdType, unsigned int &, unsigned int &, unsigned int &) const
Convert the global index of a root to its Cartesian coordinates in the grid.
virtual void GetGridBounds(double bounds[6])
Return a pointer to the grid bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
virtual void SetTransposedRootIndexing(bool)
Specify whether indexing mode of grid root cells must be transposed to x-axis first,...
unsigned int NumberOfChildren
unsigned int BranchFactor
void SetDimensions(const int dims[3])
Set/Get sizes of this rectilinear grid dataset.
A data object structured as a tree.
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
cell represents a 1D line
Definition vtkLine.h:132
Allocate and hold a VTK object.
Definition vtkNew.h:168
a cell that represents an orthogonal quadrilateral
Definition vtkPixel.h:66
represent and manipulate 3D points
Definition vtkPoints.h:140
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
#define vtkDataArray
#define VTK_3D_EXTENT
int vtkIdType
Definition vtkType.h:363
@ VTK_HYPER_TREE_GRID
Definition vtkType.h:141
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE