VTK  9.3.20240328
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
49 #ifndef vtkHyperTreeGrid_h
50 #define vtkHyperTreeGrid_h
51 
52 #include "vtkCommonDataModelModule.h" // For export macro
53 #include "vtkDataObject.h"
54 
55 #include "vtkNew.h" // vtkSmartPointer
56 #include "vtkSmartPointer.h" // vtkSmartPointer
57 
58 #include <cassert> // std::assert
59 #include <map> // std::map
60 #include <memory> // std::shared_ptr
61 
62 VTK_ABI_NAMESPACE_BEGIN
63 class vtkBitArray;
64 class vtkBoundingBox;
65 class vtkCellLinks;
66 class vtkCollection;
67 class vtkDataArray;
68 class vtkHyperTree;
79 class vtkDoubleArray;
81 class vtkIdTypeArray;
82 class vtkLine;
83 class vtkPixel;
84 class vtkPoints;
85 class vtkCellData;
87 
88 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
89 {
90 public:
95  static vtkHyperTreeGrid* New();
96 
98  void PrintSelf(ostream& os, vtkIndent indent) override;
99 
104  static constexpr vtkIdType InvalidIndex = ~0;
105 
109  vtkSetStringMacro(ModeSqueeze); // By copy
110  vtkGetStringMacro(ModeSqueeze);
111 
115  virtual void Squeeze();
116 
120  int GetDataObjectType() override { return VTK_HYPER_TREE_GRID; }
121 
126  virtual void CopyStructure(vtkDataObject*);
127 
132 
133  // --------------------------------------------------------------------------
134  // RectilinearGrid common API
135  // --------------------------------------------------------------------------
136 
138 
141  void SetDimensions(const unsigned int dims[3]);
142  void SetDimensions(const int dims[3]);
143  void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
144  void SetDimensions(int i, int j, int k);
146 
148 
152  const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
153  void GetDimensions(int dim[3]) const;
154  void GetDimensions(unsigned int dim[3]) const;
156 
158 
164  void SetExtent(const int extent[6]);
165  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
166  vtkGetVector6Macro(Extent, int);
168 
170 
175  const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
176  void GetCellDims(int cellDims[3]) const;
177  void GetCellDims(unsigned int cellDims[3]) const;
179 
180  // --------------------------------------------------------------------------
181 
183 
187  unsigned int GetDimension() const { return this->Dimension; }
189 
191 
194  void Get1DAxis(unsigned int& axis) const
195  {
196  assert("pre: valid_dim" && this->GetDimension() == 1);
197  axis = this->Axis[0];
198  }
200 
202 
205  void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
206  {
207  assert("pre: valid_dim" && this->GetDimension() == 2);
208  axis1 = this->Axis[0];
209  axis2 = this->Axis[1];
210  }
212 
214 
217  const unsigned int* GetAxes() const { return this->Axis; }
219 
221 
224  // vtkGetMacro(NumberOfChildren, unsigned int); not const
225  unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
227 
229 
233  vtkSetMacro(TransposedRootIndexing, bool);
234  vtkGetMacro(TransposedRootIndexing, bool);
235  void SetIndexingModeToKJI() { this->SetTransposedRootIndexing(false); }
236  void SetIndexingModeToIJK() { this->SetTransposedRootIndexing(true); }
238 
240 
246  unsigned int GetOrientation() const { return this->Orientation; }
248 
250 
253  vtkGetMacro(FreezeState, bool);
255 
257 
260  void SetBranchFactor(unsigned int);
261  unsigned int GetBranchFactor() const { return this->BranchFactor; }
263 
268 
273 
278 
283 
287  unsigned int GetNumberOfLevels();
288 
290 
294  vtkGetObjectMacro(XCoordinates, vtkDataArray);
296 
298 
302  vtkGetObjectMacro(YCoordinates, vtkDataArray);
304 
306 
310  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
312 
314 
317  virtual void CopyCoordinates(const vtkHyperTreeGrid* output);
318  virtual void SetFixedCoordinates(unsigned int axis, double value);
320 
322 
326  vtkGetObjectMacro(Mask, vtkBitArray);
328 
332  bool HasMask();
333 
335 
338  vtkSetMacro(HasInterface, bool);
339  vtkGetMacro(HasInterface, bool);
340  vtkBooleanMacro(HasInterface, bool);
342 
344 
347  vtkSetStringMacro(InterfaceNormalsName);
348  vtkGetStringMacro(InterfaceNormalsName);
350 
352 
355  vtkSetStringMacro(InterfaceInterceptsName);
356  vtkGetStringMacro(InterfaceInterceptsName);
358 
360 
363  vtkSetMacro(DepthLimiter, unsigned int);
364  vtkGetMacro(DepthLimiter, unsigned int);
366 
368 
378  vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
381 
383  vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
386  vtkIdType index, bool create = false);
387 
389  vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
392 
394  vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
397  vtkIdType index, bool create = false);
398 
401  bool create = false);
404  vtkIdType index, bool create = false);
406 
411 
412 private:
413  unsigned int RecurseDichotomic(
414  double value, vtkDoubleArray* coord, double tol, unsigned int ideb, unsigned int ifin) const;
415 
416  unsigned int FindDichotomic(double value, vtkDataArray* coord, double tol) const;
417 
418 public:
419  virtual unsigned int FindDichotomicX(double value, double tol = 0.0) const;
420  virtual unsigned int FindDichotomicY(double value, double tol = 0.0) const;
421  virtual unsigned int FindDichotomicZ(double value, double tol = 0.0) const;
422 
424 
437  vtkIdType index, bool create = false);
438 
441  bool create = false);
444  vtkIdType index, bool create = false);
445 
447  vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, vtkIdType index, bool create = false);
450  vtkIdType index, bool create = false);
451 
456  vtkIdType index, bool create = false);
457 
460  bool create = false);
463  vtkIdType index, bool create = false);
465 
469  void Initialize() override;
470 
475  virtual vtkHyperTree* GetTree(vtkIdType, bool create = false);
476 
482 
486  void ShallowCopy(vtkDataObject*) override;
487 
491  void DeepCopy(vtkDataObject*) override;
492 
496  int GetExtentType() 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 
523 private:
527  bool RecursivelyInitializePureMask(vtkHyperTreeGridNonOrientedCursor*, vtkDataArray*);
528 
535  void CleanPureMask();
536 
537 public:
560 
611  unsigned int GetChildMask(unsigned int);
612 
616  void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
617 
623  vtkIdType GetShiftedLevelZeroIndex(vtkIdType, unsigned int, unsigned int, unsigned int) const;
624 
629  vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
630 
634  virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
635 
639  virtual void GetLevelZeroOriginFromIndex(vtkIdType, double*);
640 
646 
651 
655  bool HasAnyGhostCells() const;
656 
662 
669 
674 
678  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
679  {
680  public:
682 
687 
693 
699 
700  protected:
701  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
703  };
704 
710 
712 
718 
723  virtual void ComputeBounds();
724 
726 
734  virtual double* GetBounds() VTK_SIZEHINT(6);
735  void GetBounds(double bounds[6]);
737 
743  virtual void GetGridBounds(double bounds[6]);
744 
749  double* GetCenter() VTK_SIZEHINT(3);
750 
755  void GetCenter(double center[3]);
756 
761  vtkCellData* GetCellData();
762 
768  vtkFieldData* GetAttributesAsFieldData(int type) override;
769 
775  vtkIdType GetNumberOfElements(int type) override;
776 
781  vtkIdType GetNumberOfCells();
782 
783 protected:
788 
792  ~vtkHyperTreeGrid() override;
793 
797  char* ModeSqueeze;
798 
799  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
800  double Center[3]; // geometric center
801 
802  bool FreezeState;
803  unsigned int BranchFactor; // 2 or 3
804  unsigned int Dimension; // 1, 2, or 3
805 
807 
811  vtkUnsignedCharArray* TreeGhostArray;
812  bool TreeGhostArrayCached;
814 private:
815  unsigned int Orientation; // 0, 1, or 2
816  unsigned int Axis[2];
817 
818  vtkTimeStamp ComputeTime;
819 
820 protected:
821  unsigned int NumberOfChildren;
822  bool TransposedRootIndexing;
823 
824  // --------------------------------
825  // RectilinearGrid common fields
826  // --------------------------------
827 private:
828  unsigned int Dimensions[3]; // Just for GetDimensions
829  unsigned int CellDims[3]; // Just for GetCellDims
830 protected:
831  int DataDescription;
832  int Extent[6];
833 
834  bool WithCoordinates;
835  vtkDataArray* XCoordinates;
836  vtkDataArray* YCoordinates;
837  vtkDataArray* ZCoordinates;
838  // --------------------------------
839 
840  vtkBitArray* Mask;
841  vtkBitArray* PureMask;
842 
843  bool HasInterface;
844  char* InterfaceNormalsName;
845  char* InterfaceInterceptsName;
846 
848 
849  vtkNew<vtkCellData> CellData; // Scalars, vectors, etc. associated w/ each point
850 
851  unsigned int DepthLimiter;
852 
853 private:
854  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
855  void operator=(const vtkHyperTreeGrid&) = delete;
856 };
857 
858 VTK_ABI_NAMESPACE_END
859 #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
Definition: vtkCellData.h:140
create and manipulate ordered lists of objects
Definition: vtkCollection.h:45
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
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
Definition: vtkFieldData.h:161
Objects for traversal a HyperTreeGrid.
Objects for traversal a HyperTreeGrid.
An iterator object to iteratively access trees in the grid.
vtkHyperTree * GetNextTree()
Get the next tree and set its index then increment the iterator.
std::map< vtkIdType, vtkSmartPointer< vtkHyperTree > >::iterator Iterator
void Initialize(vtkHyperTreeGrid *)
Initialize the iterator on the tree set of the given grid.
vtkHyperTree * GetNextTree(vtkIdType &index)
Get the next tree and set its index then increment the iterator.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
bool HasMask()
Determine whether blanking mask is empty or not.
int GetExtentType() override
Structured extent.
static vtkHyperTreeGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
vtkHyperTreeGridNonOrientedCursor * NewNonOrientedCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
static vtkInformationIntegerKey * DIMENSION()
vtkIdType GetShiftedLevelZeroIndex(vtkIdType, unsigned int, unsigned int, unsigned int) const
Return the root index of a root cell with given index displaced.
vtkHyperTreeGridOrientedCursor * NewOrientedCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
static vtkInformationDoubleVectorKey * SIZES()
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)
Augented services on Coordinates.
void InitializeNonOrientedVonNeumannSuperCursorLight(vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight *cursor, vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
const unsigned int * GetAxes() const
Get the axis information (used for CopyStructure)
virtual void GetLevelZeroOriginFromIndex(vtkIdType, double *)
Convert the global index of a root to its Spatial coordinates origin and size.
vtkHyperTreeGridNonOrientedVonNeumannSuperCursor * NewNonOrientedVonNeumannSuperCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
vtkUnsignedCharArray * AllocateTreeGhostArray()
Allocate ghost array for points.
virtual void Squeeze()
Squeeze this representation.
vtkHyperTreeGridNonOrientedUnlimitedMooreSuperCursor * NewNonOrientedUnlimitedMooreSuperCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
virtual void SetFixedCoordinates(unsigned int axis, double value)
Augented services on 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
Retourne l'indice de la dimension valide.
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.
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.
virtual double * GetBounds()
Return a pointer to the geometry bounding box in the form (xmin,xmax, ymin,ymax, zmin,...
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 unsigned int FindDichotomicY(double value, double tol=0.0) const
static vtkInformationIntegerKey * ORIENTATION()
static vtkInformationIntegerKey * LEVELS()
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.
vtkHyperTreeGridNonOrientedUnlimitedGeometryCursor * NewNonOrientedUnlimitedGeometryCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
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.
vtkBitArray * GetPureMask()
Get or create pure material mask.
vtkHyperTreeGridNonOrientedGeometryCursor * FindNonOrientedGeometryCursor(double x[3])
Return a geometric cursor pointing to one of the nodes at position x
vtkIdType GetNumberOfNonEmptyTrees()
Get the number of non empty trees in this grid.
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...
virtual unsigned long GetActualMemorySizeBytes()
Return the actual size of the data in bytes.
static vtkHyperTreeGrid * New()
void Get2DAxes(unsigned int &axis1, unsigned int &axis2) const
Retourne l'indice des deux dimensions valides.
vtkIdType GetGlobalNodeIndexMax()
Return the maximum global index value.
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.
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.
vtkHyperTreeGridNonOrientedMooreSuperCursor * NewNonOrientedMooreSuperCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight * NewNonOrientedVonNeumannSuperCursorLight(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.
virtual unsigned int FindDichotomicZ(double value, double tol=0.0) const
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,...
virtual void SetZCoordinates(vtkDataArray *)
Set/Get the grid coordinates in the z-direction.
void SetIndexingModeToIJK()
Specify whether indexing mode of grid root cells must be transposed to x-axis first,...
vtkHyperTreeGridNonOrientedGeometryCursor * NewNonOrientedGeometryCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
vtkUnsignedCharArray * GetGhostCells()
Gets the array that defines the ghost type of each cell.
vtkIdType GetMaxNumberOfTrees()
Return the maximum number of trees in the level 0 grid.
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.
vtkUnsignedCharArray * GetTreeGhostArray()
Gets the array that defines the ghost type of each cell.
static vtkHyperTreeGrid * GetData(vtkInformation *info)
Retrieve an instance of this class from an information object.
vtkIdType GetNumberOfLeaves()
Get the number of leaves in the primal tree grid.
void ShallowCopy(vtkDataObject *) override
Create shallow copy of hyper tree grid.
vtkHyperTreeGridOrientedGeometryCursor * NewOrientedGeometryCursor(vtkIdType index, bool create=false)
Used to initialize a cursor of the given type.
unsigned int GetBranchFactor() const
Set/Get the subdivision factor in the grid refinement scheme.
vtkHyperTreeGridNonOrientedMooreSuperCursorLight * NewNonOrientedMooreSuperCursorLight(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.
int GetDataObjectType() override
Return what type of dataset this is.
const unsigned int * GetDimensions() const
Get dimensions of this rectilinear grid dataset.
void SetDimensions(const int dims[3])
Set/Get sizes of this rectilinear grid dataset.
A data object structured as a tree.
Definition: vtkHyperTree.h:169
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:160
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:66
represent and manipulate 3D points
Definition: vtkPoints.h:138
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
dynamic, self-adjusting array of unsigned char
void GetBounds(T a, double bds[6])
@ info
Definition: vtkX3D.h:376
@ value
Definition: vtkX3D.h:220
@ center
Definition: vtkX3D.h:230
@ extent
Definition: vtkX3D.h:345
@ type
Definition: vtkX3D.h:516
@ index
Definition: vtkX3D.h:246
#define VTK_3D_EXTENT
int vtkIdType
Definition: vtkType.h:315
#define VTK_HYPER_TREE_GRID
Definition: vtkType.h:97
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE