VTK  9.2.6
vtkHyperTreeGrid.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkHyperTreeGrid.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
62 #ifndef vtkHyperTreeGrid_h
63 #define vtkHyperTreeGrid_h
64 
65 #include "vtkCommonDataModelModule.h" // For export macro
66 #include "vtkDataObject.h"
67 
68 #include "vtkDeprecation.h" // for deprecation macro
69 #include "vtkNew.h" // vtkSmartPointer
70 #include "vtkSmartPointer.h" // vtkSmartPointer
71 
72 #include <cassert> // std::assert
73 #include <map> // std::map
74 #include <memory> // std::shared_ptr
75 
76 class vtkBitArray;
77 class vtkBoundingBox;
78 class vtkCellLinks;
79 class vtkCollection;
80 class vtkDataArray;
81 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:
102  static vtkInformationIntegerKey* LEVELS();
103  static vtkInformationIntegerKey* DIMENSION();
104  static vtkInformationIntegerKey* ORIENTATION();
105  static vtkInformationDoubleVectorKey* SIZES();
106  static vtkHyperTreeGrid* New();
107 
109  void PrintSelf(ostream& os, vtkIndent indent) override;
110 
115  static constexpr vtkIdType InvalidIndex = ~0;
116 
120  vtkSetStringMacro(ModeSqueeze); // By copy
121  vtkGetStringMacro(ModeSqueeze);
122 
126  virtual void Squeeze();
127 
131  int GetDataObjectType() override { return VTK_HYPER_TREE_GRID; }
132 
137  virtual void CopyStructure(vtkDataObject*);
138 
142  virtual void CopyEmptyStructure(vtkDataObject*);
143 
144  // --------------------------------------------------------------------------
145  // RectilinearGrid common API
146  // --------------------------------------------------------------------------
147 
149 
152  void SetDimensions(const unsigned int dims[3]);
153  void SetDimensions(const int dims[3]);
154  void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
155  void SetDimensions(int i, int j, int k);
157 
159 
163  const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
164  // JB Dommage, car vtkGetVectorMacro(Dimensions,int,3); not const function
165  void GetDimensions(int dim[3]) const;
166  void GetDimensions(unsigned int dim[3]) const;
168 
170 
176  void SetExtent(const int extent[6]);
177  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
178  vtkGetVector6Macro(Extent, int);
180 
182 
187  const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
188  void GetCellDims(int cellDims[3]) const;
189  void GetCellDims(unsigned int cellDims[3]) const;
191 
192  // --------------------------------------------------------------------------
193 
195 
199  unsigned int GetDimension() const { return this->Dimension; }
201 
203 
206  void Get1DAxis(unsigned int& axis) const
207  {
208  assert("pre: valid_dim" && this->GetDimension() == 1);
209  axis = this->Axis[0];
210  }
212 
214 
217  void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
218  {
219  assert("pre: valid_dim" && this->GetDimension() == 2);
220  axis1 = this->Axis[0];
221  axis2 = this->Axis[1];
222  }
224 
226 
229  const unsigned int* GetAxes() const { return this->Axis; }
231 
233 
236  // vtkGetMacro(NumberOfChildren, unsigned int); not const
237  unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
239 
249  // JB ?? virtual void GetNumberOfTreesPerDimension(unsigned int dimsOut[3]);
250 
252 
256  vtkSetMacro(TransposedRootIndexing, bool);
257  vtkGetMacro(TransposedRootIndexing, bool);
258  void SetIndexingModeToKJI() { this->SetTransposedRootIndexing(false); }
259  void SetIndexingModeToIJK() { this->SetTransposedRootIndexing(true); }
261 
263 
269  unsigned int GetOrientation() const { return this->Orientation; }
271 
273 
276  vtkGetMacro(FreezeState, bool);
278 
280 
283  void SetBranchFactor(unsigned int);
284  unsigned int GetBranchFactor() const { return this->BranchFactor; }
286 
290  vtkIdType GetMaxNumberOfTrees();
291 
295  VTK_DEPRECATED_IN_9_2_0("Please use the renamed version, GetNumberOfCells().")
296  vtkIdType GetNumberOfVertices();
297 
301  vtkIdType GetNumberOfNonEmptyTrees();
302 
306  vtkIdType GetNumberOfLeaves();
307 
311  unsigned int GetNumberOfLevels(vtkIdType);
312 
316  unsigned int GetNumberOfLevels();
317 
319 
322  virtual void SetXCoordinates(vtkDataArray*);
323  vtkGetObjectMacro(XCoordinates, vtkDataArray);
325 
327 
330  virtual void SetYCoordinates(vtkDataArray*);
331  vtkGetObjectMacro(YCoordinates, vtkDataArray);
333 
335 
338  virtual void SetZCoordinates(vtkDataArray*);
339  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
341 
343 
346  virtual void CopyCoordinates(const vtkHyperTreeGrid* output);
347  virtual void SetFixedCoordinates(unsigned int axis, double value);
349 
351 
354  void SetMask(vtkBitArray*);
355  vtkGetObjectMacro(Mask, vtkBitArray);
357 
361  bool HasMask();
362 
364 
367  vtkSetMacro(HasInterface, bool);
368  vtkGetMacro(HasInterface, bool);
369  vtkBooleanMacro(HasInterface, bool);
371 
373 
376  vtkSetStringMacro(InterfaceNormalsName);
377  vtkGetStringMacro(InterfaceNormalsName);
379 
381 
384  vtkSetStringMacro(InterfaceInterceptsName);
385  vtkGetStringMacro(InterfaceInterceptsName);
387 
389 
392  vtkSetMacro(DepthLimiter, unsigned int);
393  vtkGetMacro(DepthLimiter, unsigned int);
395 
399  void InitializeOrientedCursor(
400  vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
401  vtkHyperTreeGridOrientedCursor* NewOrientedCursor(vtkIdType index, bool create = false);
402 
406  void InitializeOrientedGeometryCursor(
407  vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
408  vtkHyperTreeGridOrientedGeometryCursor* NewOrientedGeometryCursor(
409  vtkIdType index, bool create = false);
410 
414  void InitializeNonOrientedCursor(
415  vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
416  vtkHyperTreeGridNonOrientedCursor* NewNonOrientedCursor(vtkIdType index, bool create = false);
417 
421  void InitializeNonOrientedGeometryCursor(
422  vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
423  vtkHyperTreeGridNonOrientedGeometryCursor* NewNonOrientedGeometryCursor(
424  vtkIdType index, bool create = false);
425 
429  vtkHyperTreeGridNonOrientedGeometryCursor* FindNonOrientedGeometryCursor(double x[3]);
430 
431 private:
432  unsigned int RecurseDichotomic(
433  double value, vtkDoubleArray* coord, unsigned int ideb, unsigned int ifin) const;
434 
435  unsigned int FindDichotomic(double value, vtkDataArray* coord) const;
436 
437 public:
438  virtual unsigned int FindDichotomicX(double value) const;
439  virtual unsigned int FindDichotomicY(double value) const;
440  virtual unsigned int FindDichotomicZ(double value) const;
441 
445  void InitializeNonOrientedVonNeumannSuperCursor(
446  vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* cursor, vtkIdType index, bool create = false);
447  vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* NewNonOrientedVonNeumannSuperCursor(
448  vtkIdType index, bool create = false);
449 
453  void InitializeNonOrientedVonNeumannSuperCursorLight(
455  bool create = false);
456  vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight* NewNonOrientedVonNeumannSuperCursorLight(
457  vtkIdType index, bool create = false);
458 
462  void InitializeNonOrientedMooreSuperCursor(
463  vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, vtkIdType index, bool create = false);
464  vtkHyperTreeGridNonOrientedMooreSuperCursor* NewNonOrientedMooreSuperCursor(
465  vtkIdType index, bool create = false);
466 
470  void InitializeNonOrientedMooreSuperCursorLight(
471  vtkHyperTreeGridNonOrientedMooreSuperCursorLight* cursor, vtkIdType index, bool create = false);
472  vtkHyperTreeGridNonOrientedMooreSuperCursorLight* NewNonOrientedMooreSuperCursorLight(
473  vtkIdType index, bool create = false);
474 
478  void Initialize() override;
479 
484  virtual vtkHyperTree* GetTree(vtkIdType, bool create = false);
485 
490  void SetTree(vtkIdType, vtkHyperTree*);
491 
495  void ShallowCopy(vtkDataObject*) override;
496 
500  void DeepCopy(vtkDataObject*) override;
501 
505  int GetExtentType() override { return VTK_3D_EXTENT; }
506 
515  virtual unsigned long GetActualMemorySizeBytes();
516 
525  unsigned long GetActualMemorySize() override;
526 
530  bool RecursivelyInitializePureMask(
532 
536  vtkBitArray* GetPureMask();
537 
588  unsigned int GetChildMask(unsigned int);
589 
593  void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
594 
600  vtkIdType GetShiftedLevelZeroIndex(vtkIdType, unsigned int, unsigned int, unsigned int) const;
601 
605  void GetLevelZeroCoordinatesFromIndex(
606  vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
607 
611  virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
612 
616  virtual void GetLevelZeroOriginFromIndex(vtkIdType, double*);
617 
626  vtkIdType GetGlobalNodeIndexMax();
627 
633  void InitializeLocalIndexNode();
634 
638  bool HasAnyGhostCells() const;
639 
644  vtkUnsignedCharArray* GetGhostCells();
645 
651  vtkUnsignedCharArray* GetTreeGhostArray();
652 
656  vtkUnsignedCharArray* AllocateTreeGhostArray();
657 
661  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
662  {
663  public:
664  vtkHyperTreeGridIterator() = default;
665 
669  void Initialize(vtkHyperTreeGrid*);
670 
675  vtkHyperTree* GetNextTree(vtkIdType& index);
676 
681  vtkHyperTree* GetNextTree();
682 
683  protected:
684  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
686  };
687 
692  void InitializeTreeIterator(vtkHyperTreeGridIterator&);
693 
695 
699  static vtkHyperTreeGrid* GetData(vtkInformationVector* v, int i = 0);
701 
707  virtual double* GetBounds() VTK_SIZEHINT(6);
708 
714  void GetBounds(double bounds[6]);
715 
720  double* GetCenter() VTK_SIZEHINT(3);
721 
726  void GetCenter(double center[3]);
727 
732  vtkCellData* GetCellData();
733 
739  vtkFieldData* GetAttributesAsFieldData(int type) override;
740 
746  vtkIdType GetNumberOfElements(int type) override;
747 
752  vtkIdType GetNumberOfCells();
753 
754 protected:
759 
763  ~vtkHyperTreeGrid() override;
764 
768  char* ModeSqueeze;
769 
770  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
771  double Center[3]; // geometric center
772 
773  bool FreezeState;
774  unsigned int BranchFactor; // 2 or 3
775  unsigned int Dimension; // 1, 2, or 3
776 
778 
782  vtkUnsignedCharArray* TreeGhostArray;
783  bool TreeGhostArrayCached;
785 private:
786  unsigned int Orientation; // 0, 1, or 2
787  unsigned int Axis[2];
788 
789 protected:
790  unsigned int NumberOfChildren;
791  bool TransposedRootIndexing;
792 
793  // --------------------------------
794  // RectilinearGrid common fields
795  // --------------------------------
796 private:
797  unsigned int Dimensions[3]; // Just for GetDimensions
798  unsigned int CellDims[3]; // Just for GetCellDims
799 protected:
800  int DataDescription;
801  int Extent[6];
802 
803  bool WithCoordinates;
804  vtkDataArray* XCoordinates;
805  vtkDataArray* YCoordinates;
806  vtkDataArray* ZCoordinates;
807  // --------------------------------
808 
809  vtkBitArray* Mask;
810  vtkBitArray* PureMask;
811  bool InitPureMask;
812 
813  bool HasInterface;
814  char* InterfaceNormalsName;
815  char* InterfaceInterceptsName;
816 
817  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>> HyperTrees;
818 
819  vtkNew<vtkCellData> CellData; // Scalars, vectors, etc. associated w/ each point
820 
821  unsigned int DepthLimiter;
822 
823 private:
824  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
825  void operator=(const vtkHyperTreeGrid&) = delete;
826 };
827 
828 #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:62
represent and manipulate cell attribute data
Definition: vtkCellData.h:41
#define VTK_HYPER_TREE_GRID
Definition: vtkType.h:109
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:37
dynamic, self-adjusting array of vtkIdType
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:32
int vtkIdType
Definition: vtkType.h:332
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:33
Key for double vector values.
a simple class to control print indentation
Definition: vtkIndent.h:39
const unsigned int * GetAxes() const
JB Get the axis information (used for CopyStructure)
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
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.
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:36
create and manipulate ordered lists of objects
Definition: vtkCollection.h:55
A data object structured as a tree.
Definition: vtkHyperTree.h:179
Allocate and hold a VTK object.
Definition: vtkMeta.h:30
An iterator object to iteratively access trees in the grid.
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:65
represent and manipulate 3D points
Definition: vtkPoints.h:39
Fast, simple class for representing and operating on 3D bounds.
represent and manipulate fields of data
Definition: vtkFieldData.h:62