VTK  9.0.20200706
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 =========================================================================*/
59 #ifndef vtkHyperTreeGrid_h
60 #define vtkHyperTreeGrid_h
61 
62 #include "vtkCommonDataModelModule.h" // For export macro
63 #include "vtkDataObject.h"
64 
65 #include "vtkNew.h" // vtkSmartPointer
66 #include "vtkSmartPointer.h" // vtkSmartPointer
67 
68 #include <cassert> // std::assert
69 #include <map> // std::map
70 #include <memory> // std::shared_ptr
71 
72 class vtkBitArray;
73 class vtkBoundingBox;
74 class vtkCellLinks;
75 class vtkCollection;
76 class vtkDataArray;
77 class vtkHyperTree;
86 class vtkDoubleArray;
88 class vtkIdTypeArray;
89 class vtkLine;
90 class vtkPixel;
91 class vtkPoints;
92 class vtkCellData;
94 
95 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
96 {
97 public:
98  static vtkInformationIntegerKey* LEVELS();
99  static vtkInformationIntegerKey* DIMENSION();
100  static vtkInformationIntegerKey* ORIENTATION();
101  static vtkInformationDoubleVectorKey* SIZES();
102  static vtkHyperTreeGrid* New();
103 
105  void PrintSelf(ostream& os, vtkIndent indent) override;
106 
111  static constexpr vtkIdType InvalidIndex = ~0;
112 
116  vtkSetStringMacro(ModeSqueeze); // By copy
117  vtkGetStringMacro(ModeSqueeze);
118 
122  virtual void Squeeze();
123 
127  int GetDataObjectType() override { return VTK_HYPER_TREE_GRID; }
128 
133  virtual void CopyStructure(vtkDataObject*);
134 
138  virtual void CopyEmptyStructure(vtkDataObject*);
139 
140  // --------------------------------------------------------------------------
141  // RectilinearGrid common API
142  // --------------------------------------------------------------------------
143 
145 
148  void SetDimensions(const unsigned int dims[3]);
149  void SetDimensions(const int dims[3]);
150  void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
151  void SetDimensions(int i, int j, int k);
153 
155 
159  const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
160  // JB Dommage, car vtkGetVectorMacro(Dimensions,int,3); not const function
161  void GetDimensions(int dim[3]) const;
162  void GetDimensions(unsigned int dim[3]) const;
164 
166 
172  void SetExtent(const int extent[6]);
173  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
174  vtkGetVector6Macro(Extent, int);
176 
178 
183  const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
184  void GetCellDims(int cellDims[3]) const;
185  void GetCellDims(unsigned int cellDims[3]) const;
187 
188  // --------------------------------------------------------------------------
189 
191 
195  unsigned int GetDimension() const { return this->Dimension; }
197 
199 
202  void Get1DAxis(unsigned int& axis) const
203  {
204  assert("pre: valid_dim" && this->GetDimension() == 1);
205  axis = this->Axis[0];
206  }
208 
210 
213  void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
214  {
215  assert("pre: valid_dim" && this->GetDimension() == 2);
216  axis1 = this->Axis[0];
217  axis2 = this->Axis[1];
218  }
220 
222 
225  const unsigned int* GetAxes() const { return this->Axis; }
227 
229 
232  // vtkGetMacro(NumberOfChildren, unsigned int); not const
233  unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
235 
245  // JB ?? virtual void GetNumberOfTreesPerDimension(unsigned int dimsOut[3]);
246 
248 
252  vtkSetMacro(TransposedRootIndexing, bool);
253  vtkGetMacro(TransposedRootIndexing, bool);
254  void SetIndexingModeToKJI() { this->SetTransposedRootIndexing(false); }
255  void SetIndexingModeToIJK() { this->SetTransposedRootIndexing(true); }
257 
259 
265  unsigned int GetOrientation() const { return this->Orientation; }
267 
269 
272  vtkGetMacro(FreezeState, bool);
274 
276 
279  void SetBranchFactor(unsigned int);
280  unsigned int GetBranchFactor() const { return this->BranchFactor; }
282 
286  vtkIdType GetMaxNumberOfTrees();
287 
291  vtkIdType GetNumberOfVertices();
292 
296  vtkIdType GetNumberOfLeaves();
297 
301  unsigned int GetNumberOfLevels(vtkIdType);
302 
306  unsigned int GetNumberOfLevels();
307 
309 
312  virtual void SetXCoordinates(vtkDataArray*);
313  vtkGetObjectMacro(XCoordinates, vtkDataArray);
315 
317 
320  virtual void SetYCoordinates(vtkDataArray*);
321  vtkGetObjectMacro(YCoordinates, vtkDataArray);
323 
325 
328  virtual void SetZCoordinates(vtkDataArray*);
329  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
331 
333 
336  virtual void CopyCoordinates(const vtkHyperTreeGrid* output);
337  virtual void SetFixedCoordinates(unsigned int axis, double value);
339 
341 
344  void SetMask(vtkBitArray*);
345  vtkGetObjectMacro(Mask, vtkBitArray);
347 
351  bool HasMask();
352 
354 
357  vtkSetMacro(HasInterface, bool);
358  vtkGetMacro(HasInterface, bool);
359  vtkBooleanMacro(HasInterface, bool);
361 
363 
366  vtkSetStringMacro(InterfaceNormalsName);
367  vtkGetStringMacro(InterfaceNormalsName);
369 
371 
374  vtkSetStringMacro(InterfaceInterceptsName);
375  vtkGetStringMacro(InterfaceInterceptsName);
377 
379 
382  vtkSetMacro(DepthLimiter, unsigned int);
383  vtkGetMacro(DepthLimiter, unsigned int);
385 
389  void InitializeOrientedCursor(
390  vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
391  vtkHyperTreeGridOrientedCursor* NewOrientedCursor(vtkIdType index, bool create = false);
392 
396  void InitializeOrientedGeometryCursor(
397  vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
398  vtkHyperTreeGridOrientedGeometryCursor* NewOrientedGeometryCursor(
399  vtkIdType index, bool create = false);
400 
404  void InitializeNonOrientedCursor(
405  vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
406  vtkHyperTreeGridNonOrientedCursor* NewNonOrientedCursor(vtkIdType index, bool create = false);
407 
411  void InitializeNonOrientedGeometryCursor(
412  vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
413  vtkHyperTreeGridNonOrientedGeometryCursor* NewNonOrientedGeometryCursor(
414  vtkIdType index, bool create = false);
415 
419  vtkHyperTreeGridNonOrientedGeometryCursor* FindNonOrientedGeometryCursor(double x[3]);
420 
421 private:
422  unsigned int RecurseDichotomic(
423  double value, vtkDoubleArray* coord, unsigned int ideb, unsigned int ifin) const;
424 
425  unsigned int FindDichotomic(double value, vtkDataArray* coord) const;
426 
427 public:
428  virtual unsigned int FindDichotomicX(double value) const;
429  virtual unsigned int FindDichotomicY(double value) const;
430  virtual unsigned int FindDichotomicZ(double value) const;
431 
435  void InitializeNonOrientedVonNeumannSuperCursor(
437  vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* NewNonOrientedVonNeumannSuperCursor(
438  vtkIdType index, bool create = false);
439 
443  void InitializeNonOrientedVonNeumannSuperCursorLight(
445  bool create = false);
446  vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight* NewNonOrientedVonNeumannSuperCursorLight(
447  vtkIdType index, bool create = false);
448 
452  void InitializeNonOrientedMooreSuperCursor(
453  vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, vtkIdType index, bool create = false);
454  vtkHyperTreeGridNonOrientedMooreSuperCursor* NewNonOrientedMooreSuperCursor(
455  vtkIdType index, bool create = false);
456 
460  void InitializeNonOrientedMooreSuperCursorLight(
462  vtkHyperTreeGridNonOrientedMooreSuperCursorLight* NewNonOrientedMooreSuperCursorLight(
463  vtkIdType index, bool create = false);
464 
468  void Initialize() override;
469 
474  virtual vtkHyperTree* GetTree(vtkIdType, bool create = false);
475 
480  void SetTree(vtkIdType, vtkHyperTree*);
481 
485  void ShallowCopy(vtkDataObject*) override;
486 
490  void DeepCopy(vtkDataObject*) override;
491 
495  int GetExtentType() override { return VTK_3D_EXTENT; }
496 
505  virtual unsigned long GetActualMemorySizeBytes();
506 
515  unsigned long GetActualMemorySize() override;
516 
520  bool RecursivelyInitializePureMask(
522 
526  vtkBitArray* GetPureMask();
527 
578  unsigned int GetChildMask(unsigned int);
579 
583  void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
584 
590  vtkIdType GetShiftedLevelZeroIndex(vtkIdType, unsigned int, unsigned int, unsigned int) const;
591 
595  void GetLevelZeroCoordinatesFromIndex(
596  vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
597 
601  virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
602 
606  virtual void GetLevelZeroOriginFromIndex(vtkIdType, double*);
607 
616  vtkIdType GetGlobalNodeIndexMax();
617 
623  void InitializeLocalIndexNode();
624 
629  bool HasAnyGhostCells() const;
630 
634  vtkUnsignedCharArray* GetGhostCells();
635 
640  vtkUnsignedCharArray* GetTreeGhostArray();
641 
645  vtkUnsignedCharArray* AllocateTreeGhostArray();
646 
650  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
651  {
652  public:
653  vtkHyperTreeGridIterator() = default;
654 
658  void Initialize(vtkHyperTreeGrid*);
659 
664  vtkHyperTree* GetNextTree(vtkIdType& index);
665 
670  vtkHyperTree* GetNextTree();
671 
672  protected:
673  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
675  };
676 
681  void InitializeTreeIterator(vtkHyperTreeGridIterator&);
682 
684 
688  static vtkHyperTreeGrid* GetData(vtkInformationVector* v, int i = 0);
690 
696  virtual double* GetBounds() VTK_SIZEHINT(6);
697 
703  void GetBounds(double bounds[6]);
704 
709  double* GetCenter() VTK_SIZEHINT(3);
710 
715  void GetCenter(double center[3]);
716 
721  vtkCellData* GetCellData();
722 
728  vtkFieldData* GetAttributesAsFieldData(int type) override;
729 
735  vtkIdType GetNumberOfElements(int type) override;
736 
737 protected:
742 
746  ~vtkHyperTreeGrid() override;
747 
751  char* ModeSqueeze;
752 
753  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
754  double Center[3]; // geometric center
755 
756  bool FreezeState;
757  unsigned int BranchFactor; // 2 or 3
758  unsigned int Dimension; // 1, 2, or 3
759 
761 
765  vtkUnsignedCharArray* TreeGhostArray;
766  bool TreeGhostArrayCached;
768 private:
769  unsigned int Orientation; // 0, 1, or 2
770  unsigned int Axis[2];
771 
772 protected:
773  unsigned int NumberOfChildren;
774  bool TransposedRootIndexing;
775 
776  // --------------------------------
777  // RectilinearGrid common fields
778  // --------------------------------
779 private:
780  unsigned int Dimensions[3]; // Just for GetDimensions
781  unsigned int CellDims[3]; // Just for GetCellDims
782 protected:
783  int DataDescription;
784  int Extent[6];
785 
786  bool WithCoordinates;
787  vtkDataArray* XCoordinates;
788  vtkDataArray* YCoordinates;
789  vtkDataArray* ZCoordinates;
790  // --------------------------------
791 
792  vtkBitArray* Mask;
793  vtkBitArray* PureMask;
794  bool InitPureMask;
795 
796  bool HasInterface;
797  char* InterfaceNormalsName;
798  char* InterfaceInterceptsName;
799 
800  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>> HyperTrees;
801 
802  vtkNew<vtkCellData> CellData; // Scalars, vectors, etc. associated w/ each point
803 
804  unsigned int DepthLimiter;
805 
806 private:
807  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
808  void operator=(const vtkHyperTreeGrid&) = delete;
809 };
810 
811 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkHyperTreeGridNonOrientedGeometryCursor
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedGeometryCursor.h:56
vtkHyperTreeGrid::GetBranchFactor
unsigned int GetBranchFactor() const
Definition: vtkHyperTreeGrid.h:280
vtkDataObject::Initialize
virtual void Initialize()
Restore data object to initial state,.
vtkHyperTreeGridNonOrientedMooreSuperCursor
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedMooreSuperCursor.h:48
vtkX3D::value
Definition: vtkX3D.h:226
vtkIossUtilities::GetData
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.
vtkX3D::type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkDataObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:53
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkSmartPointer
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:32
VTK_HYPER_TREE_GRID
#define VTK_HYPER_TREE_GRID
Definition: vtkType.h:109
vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight.h:45
vtkHyperTreeGrid::SetIndexingModeToKJI
void SetIndexingModeToKJI()
Definition: vtkHyperTreeGrid.h:254
vtkX3D::center
Definition: vtkX3D.h:236
vtkHyperTreeGridNonOrientedCursor
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedCursor.h:50
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkDataObject::DeepCopy
virtual void DeepCopy(vtkDataObject *src)
vtkHyperTreeGrid::vtkHyperTreeGridIterator
An iterator object to iteratively access trees in the grid.
Definition: vtkHyperTreeGrid.h:650
vtkHyperTreeGrid::GetExtentType
int GetExtentType() override
Structured extent.
Definition: vtkHyperTreeGrid.h:495
vtkLine
cell represents a 1D line
Definition: vtkLine.h:29
vtkHyperTreeGrid::GetNumberOfChildren
unsigned int GetNumberOfChildren() const
The number of children each node can have.
Definition: vtkHyperTreeGrid.h:233
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:53
vtkHyperTreeGrid::vtkHyperTreeGridIterator::Grid
vtkHyperTreeGrid * Grid
Definition: vtkHyperTreeGrid.h:674
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:56
vtkBoundingBox
Fast, simple class for representing and operating on 3D bounds.
Definition: vtkBoundingBox.h:35
vtkCollection
create and manipulate ordered lists of objects
Definition: vtkCollection.h:52
vtkHyperTreeGrid::Get1DAxis
void Get1DAxis(unsigned int &axis) const
JB retourne l'indice de la dimension valide.
Definition: vtkHyperTreeGrid.h:202
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:37
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:31
vtkCellData
represent and manipulate cell attribute data
Definition: vtkCellData.h:32
vtkHyperTreeGridOrientedGeometryCursor
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridOrientedGeometryCursor.h:54
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkHyperTreeGrid::vtkHyperTreeGridIterator::Iterator
std::map< vtkIdType, vtkSmartPointer< vtkHyperTree > >::iterator Iterator
Definition: vtkHyperTreeGrid.h:673
vtkSmartPointer.h
vtkHyperTreeGrid::Get2DAxes
void Get2DAxes(unsigned int &axis1, unsigned int &axis2) const
JB Retourne l'indice des deux dimensions valides.
Definition: vtkHyperTreeGrid.h:213
vtkHyperTree
A data object structured as a tree.
Definition: vtkHyperTree.h:176
vtkNew
Allocate and hold a VTK object.
Definition: vtkMeta.h:30
vtkHyperTreeGrid::GetOrientation
unsigned int GetOrientation() const
Get the orientation of 1D or 2D grids:
Definition: vtkHyperTreeGrid.h:265
vtkHyperTreeGrid::GetAxes
const unsigned int * GetAxes() const
JB Get the axis information (used for CopyStructure)
Definition: vtkHyperTreeGrid.h:225
vtkHyperTreeGridOrientedCursor
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridOrientedCursor.h:48
vtkDataObject::GetActualMemorySize
virtual unsigned long GetActualMemorySize()
Return the actual size of the data in kibibytes (1024 bytes).
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkHyperTreeGridNonOrientedVonNeumannSuperCursor
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedVonNeumannSuperCursor.h:45
vtkX3D::info
Definition: vtkX3D.h:382
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:35
vtkNew.h
vtkPixel
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:34
vtkDataObject.h
vtkInformationDoubleVectorKey
Key for double vector values.
Definition: vtkInformationDoubleVectorKey.h:31
vtkBitArray
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:33
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkX3D::extent
Definition: vtkX3D.h:351
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkX3D::index
Definition: vtkX3D.h:252
vtkDataObject::ShallowCopy
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.
vtkHyperTreeGridNonOrientedMooreSuperCursorLight
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedMooreSuperCursorLight.h:49
vtkHyperTreeGrid::GetDataObjectType
int GetDataObjectType() override
Return what type of dataset this is.
Definition: vtkHyperTreeGrid.h:127
vtkDataObject::New
static vtkDataObject * New()
vtkHyperTreeGrid
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
Definition: vtkHyperTreeGrid.h:95
vtkHyperTreeGrid::SetIndexingModeToIJK
void SetIndexingModeToIJK()
Definition: vtkHyperTreeGrid.h:255