VTK  9.5.2
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
59#ifndef vtkHyperTreeGrid_h
60#define vtkHyperTreeGrid_h
61
62#include "vtkCommonDataModelModule.h" // For export macro
63#include "vtkDataObject.h"
64
65#include "vtkNew.h" // vtkSmartPointer
66#include "vtkSmartPointer.h" // vtkSmartPointer
67
68#include <cassert> // std::assert
69#include <map> // std::map
70#include <memory> // std::shared_ptr
71
72VTK_ABI_NAMESPACE_BEGIN
73class vtkBitArray;
74class vtkBoundingBox;
75class vtkCellLinks;
76class vtkCollection;
77class vtkDataArray;
78class vtkHyperTree;
89class vtkDoubleArray;
91class vtkIdTypeArray;
92class vtkLine;
93class vtkPixel;
94class vtkPoints;
95class vtkCellData;
97
98class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
99{
100public:
106
108 void PrintSelf(ostream& os, vtkIndent indent) override;
109
114 static constexpr vtkIdType InvalidIndex = ~0;
115
119 vtkSetStringMacro(ModeSqueeze); // By copy
120 vtkGetStringMacro(ModeSqueeze);
121
125 virtual void Squeeze();
126
130 int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_HYPER_TREE_GRID; }
131
137
142
143 // --------------------------------------------------------------------------
144 // RectilinearGrid common API
145 // --------------------------------------------------------------------------
146
148
151 void SetDimensions(const unsigned int dims[3]);
152 void SetDimensions(const int dims[3]);
153 void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
154 void SetDimensions(int i, int j, int k);
156
158
162 const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
163 void GetDimensions(int dim[3]) const;
164 void GetDimensions(unsigned int dim[3]) const;
166
168
174 void SetExtent(const int extent[6]);
175 void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
176 vtkGetVector6Macro(Extent, int);
178
180
185 const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
186 void GetCellDims(int cellDims[3]) const;
187 void GetCellDims(unsigned int cellDims[3]) const;
189
190 // --------------------------------------------------------------------------
191
193
196 unsigned int GetDimension() const { return this->Dimension; }
198
200
203 void Get1DAxis(unsigned int& axis) const
204 {
205 assert("pre: valid_dim" && this->GetDimension() == 1);
206 axis = this->Axis[0];
207 }
209
211
214 void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
215 {
216 assert("pre: valid_dim" && this->GetDimension() == 2);
217 axis1 = this->Axis[0];
218 axis2 = this->Axis[1];
219 }
221
223
226 const unsigned int* GetAxes() const { return this->Axis; }
228
230
233 // vtkGetMacro(NumberOfChildren, unsigned int); not const
234 unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
236
238
242 vtkSetMacro(TransposedRootIndexing, bool);
243 vtkGetMacro(TransposedRootIndexing, bool);
244 void SetIndexingModeToKJI() { this->SetTransposedRootIndexing(false); }
245 void SetIndexingModeToIJK() { this->SetTransposedRootIndexing(true); }
247
249
255 unsigned int GetOrientation() const { return this->Orientation; }
257
259
262 vtkGetMacro(FreezeState, bool);
264
266
269 void SetBranchFactor(unsigned int);
270 unsigned int GetBranchFactor() const { return this->BranchFactor; }
272
277
282
287
292
296 unsigned int GetNumberOfLevels();
297
299
303 vtkGetObjectMacro(XCoordinates, vtkDataArray);
305
307
311 vtkGetObjectMacro(YCoordinates, vtkDataArray);
313
315
319 vtkGetObjectMacro(ZCoordinates, vtkDataArray);
321
323
326 virtual void CopyCoordinates(const vtkHyperTreeGrid* output);
327 virtual void SetFixedCoordinates(unsigned int axis, double value);
329
331
335 vtkGetObjectMacro(Mask, vtkBitArray);
337
341 bool HasMask();
342
344
347 vtkSetMacro(HasInterface, bool);
348 vtkGetMacro(HasInterface, bool);
349 vtkBooleanMacro(HasInterface, bool);
351
353
356 vtkSetStringMacro(InterfaceNormalsName);
357 vtkGetStringMacro(InterfaceNormalsName);
359
361
364 vtkSetStringMacro(InterfaceInterceptsName);
365 vtkGetStringMacro(InterfaceInterceptsName);
367
369
372 vtkSetMacro(DepthLimiter, unsigned int);
373 vtkGetMacro(DepthLimiter, unsigned int);
375
377
387 vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
390
392 vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
395 vtkIdType index, bool create = false);
396
398 vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
401
403 vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
406 vtkIdType index, bool create = false);
407
410 bool create = false);
413 vtkIdType index, bool create = false);
415
420
421private:
422 unsigned int RecurseDichotomic(
423 double value, vtkDoubleArray* coord, double tol, unsigned int ideb, unsigned int ifin) const;
424
425 unsigned int FindDichotomic(double value, vtkDataArray* coord, double tol) const;
426
427public:
428 virtual unsigned int FindDichotomicX(double value, double tol = 0.0) const;
429 virtual unsigned int FindDichotomicY(double value, double tol = 0.0) const;
430 virtual unsigned int FindDichotomicZ(double value, double tol = 0.0) const;
431
433
443 vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* cursor, vtkIdType index, bool create = false);
446 vtkIdType index, bool create = false);
447
450 bool create = false);
453 vtkIdType index, bool create = false);
454
456 vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, vtkIdType index, bool create = false);
459 vtkIdType index, bool create = false);
460
462 vtkHyperTreeGridNonOrientedMooreSuperCursorLight* cursor, vtkIdType index, bool create = false);
465 vtkIdType index, bool create = false);
466
469 bool create = false);
472 vtkIdType index, bool create = false);
474
478 void Initialize() override;
479
484 virtual vtkHyperTree* GetTree(vtkIdType, bool create = false);
485
491
496 size_t RemoveTree(vtkIdType index);
497
501 void ShallowCopy(vtkDataObject*) override;
502
506 void DeepCopy(vtkDataObject*) override;
507
511 int GetExtentType() VTK_FUTURE_CONST override { return VTK_3D_EXTENT; }
512
521 virtual unsigned long GetActualMemorySizeBytes();
522
531 unsigned long GetActualMemorySize() override;
532
536 bool SupportsGhostArray(int type) override;
537
538private:
542 bool RecursivelyInitializePureMask(vtkHyperTreeGridNonOrientedCursor*, vtkDataArray*);
543
550 void CleanPureMask();
551
552public:
575
626 unsigned int GetChildMask(unsigned int);
627
631 void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
632
644
649 vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
650
654 virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
655
660
666
671
675 bool HasAnyGhostCells() const;
676
682
689
694
698 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
699 {
700 public:
702
707
713
719
720 protected:
721 std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
723 };
724
730
732
738
743 virtual void ComputeBounds();
744
746
754 virtual double* GetBounds() VTK_SIZEHINT(6);
755 void GetBounds(double bounds[6]);
757
763 virtual void GetGridBounds(double bounds[6]);
764
769 double* GetCenter() VTK_SIZEHINT(3);
770
775 void GetCenter(double center[3]);
776
781 vtkCellData* GetCellData();
782
788 vtkFieldData* GetAttributesAsFieldData(int type) override;
789
795 vtkIdType GetNumberOfElements(int type) override;
796
801 vtkIdType GetNumberOfCells();
802
803protected:
808
812 ~vtkHyperTreeGrid() override;
813
817 char* ModeSqueeze;
818
819 double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
820 double Center[3]; // geometric center
821
822 bool FreezeState;
823 unsigned int BranchFactor; // 2 or 3
824 unsigned int Dimension; // 1, 2, or 3
825
827
831 vtkUnsignedCharArray* TreeGhostArray;
832 bool TreeGhostArrayCached;
834private:
835 unsigned int Orientation; // 0, 1, or 2
836 unsigned int Axis[2];
837
838 vtkTimeStamp ComputeTime;
839
840protected:
841 unsigned int NumberOfChildren;
842 bool TransposedRootIndexing;
843
844 // --------------------------------
845 // RectilinearGrid common fields
846 // --------------------------------
847private:
848 unsigned int Dimensions[3]; // Just for GetDimensions
849 unsigned int CellDims[3]; // Just for GetCellDims
850protected:
851 int DataDescription;
852 int Extent[6];
853
854 bool WithCoordinates;
855 vtkDataArray* XCoordinates;
856 vtkDataArray* YCoordinates;
857 vtkDataArray* ZCoordinates;
858 // --------------------------------
859
861 vtkBitArray* PureMask;
862
863 bool HasInterface;
864 char* InterfaceNormalsName;
865 char* InterfaceInterceptsName;
866
868
869 vtkNew<vtkCellData> CellData; // Scalars, vectors, etc. associated w/ each point
870
871 unsigned int DepthLimiter;
872
873private:
874 vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
875 void operator=(const vtkHyperTreeGrid&) = delete;
876};
877
878VTK_ABI_NAMESPACE_END
879#endif
dynamic, self-adjusting array of bits
Definition vtkBitArray.h:29
Fast, simple class for representing and operating on 3D bounds.
represent and manipulate cell attribute data
create and manipulate ordered lists of objects
abstract superclass for arrays of numeric data
general representation of visualization data
represent and manipulate attribute data in a dataset
dynamic, self-adjusting array of double
represent and manipulate fields of data
Objects for traversal a HyperTreeGrid.
Objects for traversal a HyperTreeGrid.
An iterator object to iteratively access trees in the 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.
void Initialize(vtkHyperTreeGrid *)
Initialize the iterator on the tree set of the given grid.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
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.
vtkHyperTreeGridNonOrientedCursor * NewNonOrientedCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
virtual vtkHyperTree * GetTree(vtkIdType, bool create=false)
Return tree located at given index of hyper tree grid NB: This will construct a new HyperTree if grid...
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.
virtual void Squeeze()
Squeeze this representation.
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.
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.
static vtkInformationIntegerKey * ORIENTATION()
virtual unsigned int FindDichotomicY(double value, double tol=0.0) const
size_t RemoveTree(vtkIdType index)
Remove the tree at the given index.
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:
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
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.
void InitializeNonOrientedMooreSuperCursor(vtkHyperTreeGridNonOrientedMooreSuperCursor *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
void InitializeTreeIterator(vtkHyperTreeGridIterator &)
Initialize an iterator to browse level 0 trees.
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.
static vtkInformationIntegerKey * DIMENSION()
static vtkInformationIntegerKey * LEVELS()
virtual unsigned int FindDichotomicZ(double value, double tol=0.0) const
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()
vtkBitArray * GetPureMask()
Get or create pure material mask.
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.
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,...
static vtkInformationDoubleVectorKey * SIZES()
unsigned int GetBranchFactor() const
Set/Get the subdivision factor in the grid refinement scheme.
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 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.
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
Key for integer values in vtkInformation.
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:167
a cell that represents an orthogonal quadrilateral
Definition vtkPixel.h:66
represent and manipulate 3D points
Definition vtkPoints.h:139
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
#define VTK_3D_EXTENT
int vtkIdType
Definition vtkType.h:332
@ VTK_HYPER_TREE_GRID
Definition vtkType.h:112
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE