VTK  9.7.1
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 "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 
73 VTK_ABI_NAMESPACE_BEGIN
74 class vtkBitArray;
75 class vtkBoundingBox;
76 class vtkCellLinks;
77 class vtkCollection;
78 class vtkDataArray;
79 class vtkHyperTree;
90 class vtkDoubleArray;
92 class vtkIdTypeArray;
93 class vtkLine;
94 class vtkPixel;
95 class vtkPoints;
96 class vtkCellData;
98 
99 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
100 {
101 public:
103 
107  VTK_DEPRECATED_IN_9_6_0("Unused key.")
108  static vtkInformationIntegerKey* LEVELS();
109  VTK_DEPRECATED_IN_9_6_0("Unused key.")
110  static vtkInformationIntegerKey* DIMENSION();
111  VTK_DEPRECATED_IN_9_6_0("Unused key.")
112  static vtkInformationIntegerKey* ORIENTATION();
113  VTK_DEPRECATED_IN_9_6_0("Unused key.")
114  static vtkInformationDoubleVectorKey* SIZES();
116 
117  static vtkHyperTreeGrid* New();
118 
120  void PrintSelf(ostream& os, vtkIndent indent) override;
121 
126  static constexpr vtkIdType InvalidIndex = ~0;
127 
128  VTK_DEPRECATED_IN_9_6_0("No effect anymore, do not use.")
129  void SetModeSqueeze(const char* vtkNotUsed(vtksqueeze)) {};
130  VTK_DEPRECATED_IN_9_6_0("No effect anymore, do not use.")
131  char* GetModeSqueeze() { return nullptr; }
132 
133  VTK_DEPRECATED_IN_9_6_0("No effect anymore, do not use.")
134  virtual void Squeeze() {};
135 
139  int GetDataObjectType() VTK_FUTURE_CONST override { return VTK_HYPER_TREE_GRID; }
140 
145  virtual void CopyStructure(vtkDataObject*);
146 
150  virtual void CopyEmptyStructure(vtkDataObject*);
151 
152  // --------------------------------------------------------------------------
153  // RectilinearGrid common API
154  // --------------------------------------------------------------------------
155 
157 
160  void SetDimensions(const unsigned int dims[3]);
161  void SetDimensions(const int dims[3]);
162  void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
163  void SetDimensions(int i, int j, int k);
165 
167 
171  const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
172  void GetDimensions(int dim[3]) const;
173  void GetDimensions(unsigned int dim[3]) const;
175 
177 
183  void SetExtent(const int extent[6]);
184  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
185  vtkGetVector6Macro(Extent, int);
187 
189 
194  const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
195  void GetCellDims(int cellDims[3]) const;
196  void GetCellDims(unsigned int cellDims[3]) const;
198 
199  // --------------------------------------------------------------------------
200 
202 
205  unsigned int GetDimension() const { return this->Dimension; }
207 
209 
212  void Get1DAxis(unsigned int& axis) const
213  {
214  assert("pre: valid_dim" && this->GetDimension() == 1);
215  axis = this->Axis[0];
216  }
218 
220 
223  void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
224  {
225  assert("pre: valid_dim" && this->GetDimension() == 2);
226  axis1 = this->Axis[0];
227  axis2 = this->Axis[1];
228  }
230 
232 
235  const unsigned int* GetAxes() const { return this->Axis; }
237 
239 
242  // vtkGetMacro(NumberOfChildren, unsigned int); not const
243  unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
245 
247 
251  vtkSetMacro(TransposedRootIndexing, bool);
252  vtkGetMacro(TransposedRootIndexing, bool);
253  void SetIndexingModeToKJI() { this->SetTransposedRootIndexing(false); }
254  void SetIndexingModeToIJK() { this->SetTransposedRootIndexing(true); }
256 
258 
264  unsigned int GetOrientation() const { return this->Orientation; }
266 
267  VTK_DEPRECATED_IN_9_6_0("No effect, do not use.")
268  bool GetFreezeState() { return false; };
269 
271 
274  void SetBranchFactor(unsigned int);
275  unsigned int GetBranchFactor() const { return this->BranchFactor; }
277 
281  vtkIdType GetMaxNumberOfTrees() const;
282 
286  vtkIdType GetNumberOfNonEmptyTrees();
287 
291  vtkIdType GetNumberOfLeaves();
292 
296  unsigned int GetNumberOfLevels(vtkIdType);
297 
301  unsigned int GetNumberOfLevels();
302 
304 
307  virtual void SetXCoordinates(vtkDataArray*);
308  virtual vtkDataArray* GetXCoordinates();
310 
312 
315  virtual void SetYCoordinates(vtkDataArray*);
316  virtual vtkDataArray* GetYCoordinates();
318 
320 
323  virtual void SetZCoordinates(vtkDataArray*);
324  virtual vtkDataArray* GetZCoordinates();
326 
328 
331  virtual void CopyCoordinates(const vtkHyperTreeGrid* output);
332  virtual void SetFixedCoordinates(unsigned int axis, double value);
334 
336 
339  void SetMask(vtkBitArray*);
340  virtual vtkBitArray* GetMask();
342 
346  bool HasMask();
347 
349 
352  vtkSetMacro(HasInterface, bool);
353  vtkGetMacro(HasInterface, bool);
354  vtkBooleanMacro(HasInterface, bool);
356 
358 
361  vtkSetStringMacro(InterfaceNormalsName);
362  vtkGetStringMacro(InterfaceNormalsName);
364 
366 
369  vtkSetStringMacro(InterfaceInterceptsName);
370  vtkGetStringMacro(InterfaceInterceptsName);
372 
374 
377  vtkSetMacro(DepthLimiter, unsigned int);
378  vtkGetMacro(DepthLimiter, unsigned int);
380 
382 
391  void InitializeOrientedCursor(
392  vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
394  vtkHyperTreeGridOrientedCursor* NewOrientedCursor(vtkIdType index, bool create = false);
395 
396  void InitializeOrientedGeometryCursor(
397  vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
399  vtkHyperTreeGridOrientedGeometryCursor* NewOrientedGeometryCursor(
400  vtkIdType index, bool create = false);
401 
402  void InitializeNonOrientedCursor(
403  vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
405  vtkHyperTreeGridNonOrientedCursor* NewNonOrientedCursor(vtkIdType index, bool create = false);
406 
407  void InitializeNonOrientedGeometryCursor(
408  vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
410  vtkHyperTreeGridNonOrientedGeometryCursor* NewNonOrientedGeometryCursor(
411  vtkIdType index, bool create = false);
412 
413  void InitializeNonOrientedUnlimitedGeometryCursor(
415  bool create = false);
417  vtkHyperTreeGridNonOrientedUnlimitedGeometryCursor* NewNonOrientedUnlimitedGeometryCursor(
418  vtkIdType index, bool create = false);
420 
424  vtkHyperTreeGridNonOrientedGeometryCursor* FindNonOrientedGeometryCursor(double x[3]);
425 
430  virtual void GenerateGhostArray(int zeroExt[6]);
431 
432 private:
433  unsigned int RecurseDichotomic(
434  double value, vtkDoubleArray* coord, double tol, unsigned int ideb, unsigned int ifin) const;
435 
436  unsigned int FindDichotomic(double value, vtkDataArray* coord, double tol) const;
437 
438 public:
439  virtual unsigned int FindDichotomicX(double value, double tol = 0.0) const;
440  virtual unsigned int FindDichotomicY(double value, double tol = 0.0) const;
441  virtual unsigned int FindDichotomicZ(double value, double tol = 0.0) const;
442 
444 
453  void InitializeNonOrientedVonNeumannSuperCursor(
456  vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* NewNonOrientedVonNeumannSuperCursor(
457  vtkIdType index, bool create = false);
458 
459  void InitializeNonOrientedVonNeumannSuperCursorLight(
461  bool create = false);
463  vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight* NewNonOrientedVonNeumannSuperCursorLight(
464  vtkIdType index, bool create = false);
465 
466  void InitializeNonOrientedMooreSuperCursor(
467  vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, vtkIdType index, bool create = false);
469  vtkHyperTreeGridNonOrientedMooreSuperCursor* NewNonOrientedMooreSuperCursor(
470  vtkIdType index, bool create = false);
471 
472  void InitializeNonOrientedMooreSuperCursorLight(
475  vtkHyperTreeGridNonOrientedMooreSuperCursorLight* NewNonOrientedMooreSuperCursorLight(
476  vtkIdType index, bool create = false);
477 
478  void InitializeNonOrientedUnlimitedMooreSuperCursor(
480  bool create = false);
482  vtkHyperTreeGridNonOrientedUnlimitedMooreSuperCursor* NewNonOrientedUnlimitedMooreSuperCursor(
483  vtkIdType index, bool create = false);
485 
489  void Initialize() override;
490 
495  virtual vtkHyperTree* GetTree(vtkIdType index, bool create = false);
496 
501  void SetTree(vtkIdType, vtkHyperTree*);
502 
507  size_t RemoveTree(vtkIdType index);
508 
512  void ShallowCopy(vtkDataObject*) override;
513 
517  void DeepCopy(vtkDataObject*) override;
518 
522  int GetExtentType() VTK_FUTURE_CONST override { return VTK_3D_EXTENT; }
523 
532  virtual unsigned long GetActualMemorySizeBytes();
533 
542  unsigned long GetActualMemorySize() override;
543 
547  bool SupportsGhostArray(int type) override;
548 
549 private:
553  bool RecursivelyInitializePureMask(vtkHyperTreeGridNonOrientedCursor*, vtkDataArray*);
554 
561  void CleanPureMask();
562 
563 public:
585  vtkBitArray* GetPureMask();
586 
637  unsigned int GetChildMask(unsigned int);
638 
642  void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
643 
654  vtkIdType GetShiftedLevelZeroIndex(vtkIdType, int, int, int) const;
655 
659  void GetLevelZeroCoordinatesFromIndex(
660  vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
661 
665  virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
666 
670  virtual void GetLevelZeroOriginFromIndex(vtkIdType, double*);
671 
676  vtkIdType GetGlobalNodeIndexMax();
677 
681  void InitializeLocalIndexNode();
682 
686  bool HasAnyGhostCells() const;
687 
692  vtkUnsignedCharArray* GetGhostCells();
693 
699  vtkUnsignedCharArray* GetTreeGhostArray();
700 
704  vtkUnsignedCharArray* AllocateTreeGhostArray();
705 
709  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
710  {
711  public:
712  vtkHyperTreeGridIterator() = default;
713 
717  void Initialize(vtkHyperTreeGrid* grid);
718 
723  vtkHyperTree* GetNextTree(vtkIdType& index);
724 
729  vtkHyperTree* GetNextTree();
730 
731  protected:
732  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
733  vtkHyperTreeGrid* Grid = nullptr;
734  };
735 
739  void InitializeTreeIterator(vtkHyperTreeGridIterator& it);
740 
742 
746  static vtkHyperTreeGrid* GetData(vtkInformationVector* v, int i = 0);
748 
753  virtual void ComputeBounds();
754 
756 
764  virtual double* GetBounds() VTK_SIZEHINT(6);
765  void GetBounds(double bounds[6]);
767 
773  virtual void GetGridBounds(double bounds[6]);
774 
779  double* GetCenter() VTK_SIZEHINT(3);
780 
785  void GetCenter(double center[3]);
786 
791  vtkCellData* GetCellData();
792 
798  vtkFieldData* GetAttributesAsFieldData(int type) override;
799 
805  vtkIdType GetNumberOfElements(int type) override;
806 
811  vtkIdType GetNumberOfCells();
812 
813 protected:
818 
819  ~vtkHyperTreeGrid() override;
820 
821  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
822  double Center[3]{ 0.0, 0.0, 0.0 }; // geometric center
823 
824  unsigned int BranchFactor = 0; // 2 or 3, 0 for invalid
825  unsigned int Dimension = 0; // 1, 2, or 3, 0 for invalid
826 
827 private:
828  // Invalid default grid parameters to force actual initialization
829  unsigned int Orientation = std::numeric_limits<unsigned int>::max(); // 0, 1, or 2
830  unsigned int Axis[2] = { std::numeric_limits<unsigned int>::max(),
832 
833  vtkTimeStamp ComputeTime;
834 
836 
841  bool TreeGhostArrayCached = false;
843 
844 protected:
845  unsigned int NumberOfChildren = 0;
846  bool TransposedRootIndexing = false;
847 
848  // --------------------------------
849  // RectilinearGrid common fields
850  // --------------------------------
851 private:
852  unsigned int Dimensions[3] = { 0, 0, 0 }; // Just for GetDimensions
853  unsigned int CellDims[3] = { 0, 0, 0 }; // Just for GetCellDims
854 protected:
856  int Extent[6] = { 0, -1, 0, -1, 0, -1 };
857 
858  bool WithCoordinates = false;
862  // --------------------------------
863 
865  vtkBitArray* PureMask = nullptr;
866 
867  bool HasInterface = false;
868  char* InterfaceNormalsName = nullptr;
869  char* InterfaceInterceptsName = nullptr;
870 
871  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>> HyperTrees;
872 
873  vtkNew<vtkCellData> CellData; // Scalars, vectors, etc. associated w/ each point
874 
875  unsigned int DepthLimiter = std::numeric_limits<unsigned int>::max();
876 
877 private:
878  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
879  void operator=(const vtkHyperTreeGrid&) = delete;
880 };
881 
882 VTK_ABI_NAMESPACE_END
883 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Get2DAxes(unsigned int &axis1, unsigned int &axis2) const
Return the indices of the two valid dimensions.
void GetBounds(T a, double bds[6])
VTKIOHDF_EXPORT std::vector< hsize_t > GetDimensions(hid_t fileID, const char *datasetName)
Returns the dimensions of a HDF dataset of a file.
static vtkDataObject * New()
void SetIndexingModeToKJI()
Specify whether indexing mode of grid root cells must be transposed to x-axis first, z-axis last, instead of the default z-axis first, k-axis last.
Store vtkAlgorithm input/output information.
unsigned int GetBranchFactor() const
Set/Get the subdivision factor in the grid refinement scheme.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:52
record modification and/or execution time
Definition: vtkTimeStamp.h:24
represent and manipulate cell attribute data
Definition: vtkCellData.h:31
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:26
virtual bool SupportsGhostArray(int type)
Returns if this type of data object support ghost array for specified type.
virtual void Initialize()
Restore data object to initial state,.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:363
int GetExtentType() VTK_FUTURE_CONST override
Structured extent.
void SetIndexingModeToIJK()
Specify whether indexing mode of grid root cells must be transposed to x-axis first, z-axis last, instead of the default z-axis first, k-axis last.
Objects for traversal a HyperTreeGrid.
dynamic, self-adjusting array of double
cell represents a 1D line
Definition: vtkLine.h:22
#define VTK_DEPRECATED_IN_9_6_0(reason)
Key for double vector values.
a simple class to control print indentation
Definition: vtkIndent.h:28
const unsigned int * GetAxes() const
Get the axis information (used for CopyStructure)
Key for integer values in vtkInformation.
Specific Moore super cursor that can subdivied neighborhood.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
unsigned int GetOrientation() const
Get the orientation of 1D or 2D grids:
unsigned int GetNumberOfChildren() const
The number of children each node can have.
represent and manipulate attribute data in a dataset
vtkNew< vtkCellData > CellData
#define VTK_SIZEHINT(...)
void Get1DAxis(unsigned int &axis) const
Return the index of the valid dimension.
virtual unsigned long GetActualMemorySize()
Return the actual size of the data in kibibytes (1024 bytes).
vtkSmartPointer< vtkDataArray > GetData(const Ioss::GroupingEntity *entity, const std::string &fieldname, Ioss::Transform *transform=nullptr, Cache *cache=nullptr, const std::string &cachekey=std::string())
Returns a VTK array for a given field (fieldname) on the chosen block (or set) entity.
#define VTK_NEWINSTANCE
Objects for traversal a HyperTreeGrid.
std::map< vtkIdType, vtkSmartPointer< vtkHyperTree > > HyperTrees
dynamic, self-adjusting array of unsigned char
std::map< vtkIdType, vtkSmartPointer< vtkHyperTree > >::iterator Iterator
vtkSmartPointer< vtkDataArray > ZCoordinates
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:32
create and manipulate ordered lists of objects
Definition: vtkCollection.h:39
A data object structured as a tree.
Definition: vtkHyperTree.h:170
vtkSmartPointer< vtkDataArray > XCoordinates
An iterator object to iteratively access trees in the grid.
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:55
vtkSmartPointer< vtkBitArray > Mask
virtual void DeepCopy(vtkDataObject *src)
The goal of the method is to copy the complete data from src into this object.
#define max(a, b)
represent and manipulate 3D points
Definition: vtkPoints.h:30
Fast, simple class for representing and operating on 3D bounds.
virtual void ShallowCopy(vtkDataObject *src)
The goal of the method is to copy the data up to the array pointers only.
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51
vtkSmartPointer< vtkDataArray > YCoordinates
int GetDataObjectType() VTK_FUTURE_CONST override
Return what type of dataset this is.