VTK  9.3.0
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:
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 
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 
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(
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, 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 
543 
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 
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 
638 
645 
649  bool HasAnyGhostCells() const;
650 
656 
663 
668 
672  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
673  {
674  public:
676 
681 
687 
693 
694  protected:
695  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
697  };
698 
704 
706 
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
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:40
create and manipulate ordered lists of objects
Definition: vtkCollection.h:45
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
general representation of visualization data
Definition: vtkDataObject.h:64
represent and manipulate attribute data in a dataset
dynamic, self-adjusting array of double
represent and manipulate fields of data
Definition: vtkFieldData.h:61
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.
static vtkHyperTreeGrid * GetData(vtkInformationVector *v, int i=0)
Retrieve an instance of this class from an information object.
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.
static vtkInformationDoubleVectorKey * SIZES()
const unsigned int * GetAxes() const
JB Get the axis information (used for CopyStructure)
virtual void GetLevelZeroOriginFromIndex(vtkIdType, double *)
JB Convert the global index of a root to its Spacial coordinates origin and size.
vtkUnsignedCharArray * AllocateTreeGhostArray()
Allocate ghost array for points.
virtual void Squeeze()
Squeeze this representation.
virtual void CopyEmptyStructure(vtkDataObject *)
Copy the internal structure with no data associated.
void Get1DAxis(unsigned int &axis) const
JB 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.
virtual void CopyStructure(vtkDataObject *)
Copy the internal geometric and topological structure of a vtkHyperTreeGrid object.
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.
bool RecursivelyInitializePureMask(vtkHyperTreeGridNonOrientedCursor *cursor, vtkDataArray *normale)
Recursively initialize pure material mask.
static vtkInformationIntegerKey * ORIENTATION()
static vtkInformationIntegerKey * LEVELS()
unsigned int GetOrientation() const
Get the orientation of 1D or 2D grids:
void SetIndexingModeToKJI()
Get the number or trees available along the 3 axis.
virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double *, double *)
Convert the global index of a root to its Spacial coordinates origin and size.
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.
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
JB Retourne l'indice des deux dimensions valides.
vtkIdType GetGlobalNodeIndexMax()
JB Retourne la valeur maximale du global index.
void InitializeLocalIndexNode()
JB Permet d'initialiser les index locaux de chacun des HT de cet HTG une fois que TOUS les HTs aient ...
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
void InitializeTreeIterator(vtkHyperTreeGridIterator &)
Initialize an iterator to browse level 0 trees.
void SetDimensions(const unsigned int dims[3])
Set/Get sizes of this rectilinear grid dataset.
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,...
void SetIndexingModeToIJK()
Get the number or trees available along the 3 axis.
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.
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.
unsigned int GetBranchFactor() const
Set/Get the subdivision factor in the grid refinement scheme.
unsigned int GetNumberOfChildren() const
The number of children each node can have.
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:38
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:32
Allocate and hold a VTK object.
Definition: vtkNew.h:60
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:36
represent and manipulate 3D points
Definition: vtkPoints.h:38
Hold a reference to a vtkObjectBase instance.
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
Definition: vtkDataObject.h:60
#define VTK_DEPRECATED_IN_9_2_0(reason)
int vtkIdType
Definition: vtkType.h:315
#define VTK_HYPER_TREE_GRID
Definition: vtkType.h:97
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE