VTK  9.3.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
50 #ifndef vtkHyperTreeGrid_h
51 #define vtkHyperTreeGrid_h
52 
53 #include "vtkCommonDataModelModule.h" // For export macro
54 #include "vtkDataObject.h"
55 
56 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
57 #include "vtkNew.h" // vtkSmartPointer
58 #include "vtkSmartPointer.h" // vtkSmartPointer
59 
60 #include <cassert> // std::assert
61 #include <map> // std::map
62 #include <memory> // std::shared_ptr
63 
64 VTK_ABI_NAMESPACE_BEGIN
65 class vtkBitArray;
66 class vtkBoundingBox;
67 class vtkCellLinks;
68 class vtkCollection;
69 class vtkDataArray;
70 class vtkHyperTree;
81 class vtkDoubleArray;
83 class vtkIdTypeArray;
84 class vtkLine;
85 class vtkPixel;
86 class vtkPoints;
87 class vtkCellData;
89 
90 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
91 {
92 public:
93  static vtkInformationIntegerKey* LEVELS();
94  static vtkInformationIntegerKey* DIMENSION();
95  static vtkInformationIntegerKey* ORIENTATION();
96  static vtkInformationDoubleVectorKey* SIZES();
97  static vtkHyperTreeGrid* New();
98 
100  void PrintSelf(ostream& os, vtkIndent indent) override;
101 
106  static constexpr vtkIdType InvalidIndex = ~0;
107 
111  vtkSetStringMacro(ModeSqueeze); // By copy
112  vtkGetStringMacro(ModeSqueeze);
113 
117  virtual void Squeeze();
118 
122  int GetDataObjectType() override { return VTK_HYPER_TREE_GRID; }
123 
128  virtual void CopyStructure(vtkDataObject*);
129 
133  virtual void CopyEmptyStructure(vtkDataObject*);
134 
135  // --------------------------------------------------------------------------
136  // RectilinearGrid common API
137  // --------------------------------------------------------------------------
138 
140 
143  void SetDimensions(const unsigned int dims[3]);
144  void SetDimensions(const int dims[3]);
145  void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
146  void SetDimensions(int i, int j, int k);
148 
150 
154  const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
155  // JB Dommage, car vtkGetVectorMacro(Dimensions,int,3); not const function
156  void GetDimensions(int dim[3]) const;
157  void GetDimensions(unsigned int dim[3]) const;
159 
161 
167  void SetExtent(const int extent[6]);
168  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
169  vtkGetVector6Macro(Extent, int);
171 
173 
178  const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
179  void GetCellDims(int cellDims[3]) const;
180  void GetCellDims(unsigned int cellDims[3]) const;
182 
183  // --------------------------------------------------------------------------
184 
186 
190  unsigned int GetDimension() const { return this->Dimension; }
192 
194 
197  void Get1DAxis(unsigned int& axis) const
198  {
199  assert("pre: valid_dim" && this->GetDimension() == 1);
200  axis = this->Axis[0];
201  }
203 
205 
208  void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
209  {
210  assert("pre: valid_dim" && this->GetDimension() == 2);
211  axis1 = this->Axis[0];
212  axis2 = this->Axis[1];
213  }
215 
217 
220  const unsigned int* GetAxes() const { return this->Axis; }
222 
224 
227  // vtkGetMacro(NumberOfChildren, unsigned int); not const
228  unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
230 
240  // JB ?? virtual void GetNumberOfTreesPerDimension(unsigned int dimsOut[3]);
241 
243 
247  vtkSetMacro(TransposedRootIndexing, bool);
248  vtkGetMacro(TransposedRootIndexing, bool);
249  void SetIndexingModeToKJI() { this->SetTransposedRootIndexing(false); }
250  void SetIndexingModeToIJK() { this->SetTransposedRootIndexing(true); }
252 
254 
260  unsigned int GetOrientation() const { return this->Orientation; }
262 
264 
267  vtkGetMacro(FreezeState, bool);
269 
271 
274  void SetBranchFactor(unsigned int);
275  unsigned int GetBranchFactor() const { return this->BranchFactor; }
277 
281  vtkIdType GetMaxNumberOfTrees();
282 
286  VTK_DEPRECATED_IN_9_2_0("Please use the renamed version, GetNumberOfCells().")
287  vtkIdType GetNumberOfVertices();
288 
292  vtkIdType GetNumberOfNonEmptyTrees();
293 
297  vtkIdType GetNumberOfLeaves();
298 
302  unsigned int GetNumberOfLevels(vtkIdType);
303 
307  unsigned int GetNumberOfLevels();
308 
310 
313  virtual void SetXCoordinates(vtkDataArray*);
314  vtkGetObjectMacro(XCoordinates, vtkDataArray);
316 
318 
321  virtual void SetYCoordinates(vtkDataArray*);
322  vtkGetObjectMacro(YCoordinates, vtkDataArray);
324 
326 
329  virtual void SetZCoordinates(vtkDataArray*);
330  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
332 
334 
337  virtual void CopyCoordinates(const vtkHyperTreeGrid* output);
338  virtual void SetFixedCoordinates(unsigned int axis, double value);
340 
342 
345  void SetMask(vtkBitArray*);
346  vtkGetObjectMacro(Mask, vtkBitArray);
348 
352  bool HasMask();
353 
355 
358  vtkSetMacro(HasInterface, bool);
359  vtkGetMacro(HasInterface, bool);
360  vtkBooleanMacro(HasInterface, bool);
362 
364 
367  vtkSetStringMacro(InterfaceNormalsName);
368  vtkGetStringMacro(InterfaceNormalsName);
370 
372 
375  vtkSetStringMacro(InterfaceInterceptsName);
376  vtkGetStringMacro(InterfaceInterceptsName);
378 
380 
383  vtkSetMacro(DepthLimiter, unsigned int);
384  vtkGetMacro(DepthLimiter, unsigned int);
386 
388 
397  void InitializeOrientedCursor(
398  vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
400  vtkHyperTreeGridOrientedCursor* NewOrientedCursor(vtkIdType index, bool create = false);
401 
402  void InitializeOrientedGeometryCursor(
403  vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
405  vtkHyperTreeGridOrientedGeometryCursor* NewOrientedGeometryCursor(
406  vtkIdType index, bool create = false);
407 
408  void InitializeNonOrientedCursor(
409  vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
411  vtkHyperTreeGridNonOrientedCursor* NewNonOrientedCursor(vtkIdType index, bool create = false);
412 
413  void InitializeNonOrientedGeometryCursor(
414  vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
416  vtkHyperTreeGridNonOrientedGeometryCursor* NewNonOrientedGeometryCursor(
417  vtkIdType index, bool create = false);
418 
419  void InitializeNonOrientedUnlimitedGeometryCursor(
421  bool create = false);
423  vtkHyperTreeGridNonOrientedUnlimitedGeometryCursor* NewNonOrientedUnlimitedGeometryCursor(
424  vtkIdType index, bool create = false);
426 
430  vtkHyperTreeGridNonOrientedGeometryCursor* FindNonOrientedGeometryCursor(double x[3]);
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(
454  vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* cursor, vtkIdType index, bool create = false);
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(
473  vtkHyperTreeGridNonOrientedMooreSuperCursorLight* cursor, vtkIdType index, bool create = false);
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, bool create = false);
496 
501  void SetTree(vtkIdType, vtkHyperTree*);
502 
506  void ShallowCopy(vtkDataObject*) override;
507 
511  void DeepCopy(vtkDataObject*) override;
512 
516  int GetExtentType() override { return VTK_3D_EXTENT; }
517 
526  virtual unsigned long GetActualMemorySizeBytes();
527 
536  unsigned long GetActualMemorySize() override;
537 
541  bool RecursivelyInitializePureMask(
543 
547  vtkBitArray* GetPureMask();
548 
599  unsigned int GetChildMask(unsigned int);
600 
604  void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
605 
611  vtkIdType GetShiftedLevelZeroIndex(vtkIdType, unsigned int, unsigned int, unsigned int) const;
612 
616  void GetLevelZeroCoordinatesFromIndex(
617  vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
618 
622  virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
623 
627  virtual void GetLevelZeroOriginFromIndex(vtkIdType, double*);
628 
637  vtkIdType GetGlobalNodeIndexMax();
638 
644  void InitializeLocalIndexNode();
645 
649  bool HasAnyGhostCells() const;
650 
655  vtkUnsignedCharArray* GetGhostCells();
656 
662  vtkUnsignedCharArray* GetTreeGhostArray();
663 
667  vtkUnsignedCharArray* AllocateTreeGhostArray();
668 
672  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
673  {
674  public:
675  vtkHyperTreeGridIterator() = default;
676 
680  void Initialize(vtkHyperTreeGrid*);
681 
686  vtkHyperTree* GetNextTree(vtkIdType& index);
687 
692  vtkHyperTree* GetNextTree();
693 
694  protected:
695  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
697  };
698 
703  void InitializeTreeIterator(vtkHyperTreeGridIterator&);
704 
706 
710  static vtkHyperTreeGrid* GetData(vtkInformationVector* v, int i = 0);
712 
718  virtual double* GetBounds() VTK_SIZEHINT(6);
719 
725  void GetBounds(double bounds[6]);
726 
731  double* GetCenter() VTK_SIZEHINT(3);
732 
737  void GetCenter(double center[3]);
738 
743  vtkCellData* GetCellData();
744 
750  vtkFieldData* GetAttributesAsFieldData(int type) override;
751 
757  vtkIdType GetNumberOfElements(int type) override;
758 
763  vtkIdType GetNumberOfCells();
764 
765 protected:
770 
774  ~vtkHyperTreeGrid() override;
775 
779  char* ModeSqueeze;
780 
781  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
782  double Center[3]; // geometric center
783 
784  bool FreezeState;
785  unsigned int BranchFactor; // 2 or 3
786  unsigned int Dimension; // 1, 2, or 3
787 
789 
793  vtkUnsignedCharArray* TreeGhostArray;
794  bool TreeGhostArrayCached;
796 private:
797  unsigned int Orientation; // 0, 1, or 2
798  unsigned int Axis[2];
799 
800 protected:
801  unsigned int NumberOfChildren;
802  bool TransposedRootIndexing;
803 
804  // --------------------------------
805  // RectilinearGrid common fields
806  // --------------------------------
807 private:
808  unsigned int Dimensions[3]; // Just for GetDimensions
809  unsigned int CellDims[3]; // Just for GetCellDims
810 protected:
811  int DataDescription;
812  int Extent[6];
813 
814  bool WithCoordinates;
815  vtkDataArray* XCoordinates;
816  vtkDataArray* YCoordinates;
817  vtkDataArray* ZCoordinates;
818  // --------------------------------
819 
820  vtkBitArray* Mask;
821  vtkBitArray* PureMask;
822  bool InitPureMask;
823 
824  bool HasInterface;
825  char* InterfaceNormalsName;
826  char* InterfaceInterceptsName;
827 
829 
830  vtkNew<vtkCellData> CellData; // Scalars, vectors, etc. associated w/ each point
831 
832  unsigned int DepthLimiter;
833 
834 private:
835  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
836  void operator=(const vtkHyperTreeGrid&) = delete;
837 };
838 
839 VTK_ABI_NAMESPACE_END
840 #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
JB Retourne l'indice des deux dimensions valides.
void GetBounds(T a, double bds[6])
static vtkDataObject * New()
void SetIndexingModeToKJI()
Get the number or trees available along the 3 axis.
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_DEPRECATED_IN_9_2_0(reason)
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:51
represent and manipulate cell attribute data
Definition: vtkCellData.h:30
#define VTK_HYPER_TREE_GRID
Definition: vtkType.h:97
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:26
dynamic, self-adjusting array of vtkIdType
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
int vtkIdType
Definition: vtkType.h:315
void SetIndexingModeToIJK()
Get the number or trees available along the 3 axis.
Objects for traversal a HyperTreeGrid.
dynamic, self-adjusting array of double
cell represents a 1D line
Definition: vtkLine.h:22
Key for double vector values.
a simple class to control print indentation
Definition: vtkIndent.h:28
const unsigned int * GetAxes() const
JB 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.
int GetDataObjectType() override
Return what type of dataset this is.
represent and manipulate attribute data in a dataset
#define VTK_SIZEHINT(...)
void Get1DAxis(unsigned int &axis) const
JB retourne l'indice de la dimension valide.
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.
dynamic, self-adjusting array of unsigned char
std::map< vtkIdType, vtkSmartPointer< vtkHyperTree > >::iterator Iterator
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:28
create and manipulate ordered lists of objects
Definition: vtkCollection.h:44
A data object structured as a tree.
Definition: vtkHyperTree.h:168
Allocate and hold a VTK object.
Definition: vtkMeta.h:21
An iterator object to iteratively access trees in the grid.
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:54
represent and manipulate 3D points
Definition: vtkPoints.h:28
Fast, simple class for representing and operating on 3D bounds.
represent and manipulate fields of data
Definition: vtkFieldData.h:51