VTK  9.0.1
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 // #include "vtkPointData.h" // vtkPointData
68 
69 #include <cassert> // std::assert
70 #include <map> // std::map
71 #include <memory> // std::shared_ptr
72 
73 class vtkBitArray;
74 class vtkBoundingBox;
75 class vtkCellLinks;
76 class vtkCollection;
77 class vtkDataArray;
78 class vtkHyperTree;
87 class vtkDoubleArray;
89 class vtkIdTypeArray;
90 class vtkLine;
91 class vtkPixel;
92 class vtkPoints;
93 class vtkPointData;
95 
96 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
97 {
98 public:
99  static vtkInformationIntegerKey* LEVELS();
100  static vtkInformationIntegerKey* DIMENSION();
101  static vtkInformationIntegerKey* ORIENTATION();
102  static vtkInformationDoubleVectorKey* SIZES();
103  static vtkHyperTreeGrid* New();
104 
106  void PrintSelf(ostream& os, vtkIndent indent) override;
107 
112  static constexpr vtkIdType InvalidIndex = ~0;
113 
117  vtkSetStringMacro(ModeSqueeze); // By copy
118  vtkGetStringMacro(ModeSqueeze);
119 
123  virtual void Squeeze();
124 
128  int GetDataObjectType() override { return VTK_HYPER_TREE_GRID; }
129 
134  virtual void CopyStructure(vtkDataObject*);
135 
139  virtual void CopyEmptyStructure(vtkDataObject*);
140 
141  // --------------------------------------------------------------------------
142  // RectilinearGrid common API
143  // --------------------------------------------------------------------------
144 
146 
149  void SetDimensions(const unsigned int dims[3]);
150  void SetDimensions(const int dims[3]);
151  void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
152  void SetDimensions(int i, int j, int k);
154 
156 
160  const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
161  // JB Dommage, car vtkGetVectorMacro(Dimensions,int,3); not const function
162  void GetDimensions(int dim[3]) const;
163  void GetDimensions(unsigned int dim[3]) const;
165 
167 
173  void SetExtent(const int extent[6]);
174  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
175  vtkGetVector6Macro(Extent, int);
177 
179 
184  const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
185  void GetCellDims(int cellDims[3]) const;
186  void GetCellDims(unsigned int cellDims[3]) const;
188 
189  // --------------------------------------------------------------------------
190 
192 
196  unsigned int GetDimension() const { return this->Dimension; }
198 
200 
203  void Get1DAxis(unsigned int& axis) const
204  {
205  assert("pre: valid_dim" && this->GetDimension() == 1);
206  axis = this->Axis[0];
207  }
209 
211 
214  void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
215  {
216  assert("pre: valid_dim" && this->GetDimension() == 2);
217  axis1 = this->Axis[0];
218  axis2 = this->Axis[1];
219  }
221 
223 
226  const unsigned int* GetAxes() const { return this->Axis; }
228 
230 
233  // vtkGetMacro(NumberOfChildren, unsigned int); not const
234  unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
236 
246  // JB ?? virtual void GetNumberOfTreesPerDimension(unsigned int dimsOut[3]);
247 
249 
253  vtkSetMacro(TransposedRootIndexing, bool);
254  vtkGetMacro(TransposedRootIndexing, bool);
255  void SetIndexingModeToKJI() { this->SetTransposedRootIndexing(false); }
256  void SetIndexingModeToIJK() { this->SetTransposedRootIndexing(true); }
258 
260 
266  unsigned int GetOrientation() const { return this->Orientation; }
268 
270 
273  vtkGetMacro(FreezeState, bool);
275 
277 
280  void SetBranchFactor(unsigned int);
281  unsigned int GetBranchFactor() const { return this->BranchFactor; }
283 
287  vtkIdType GetMaxNumberOfTrees();
288 
292  vtkIdType GetNumberOfVertices();
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 
390  void InitializeOrientedCursor(
391  vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
392  vtkHyperTreeGridOrientedCursor* NewOrientedCursor(vtkIdType index, bool create = false);
393 
397  void InitializeOrientedGeometryCursor(
398  vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
399  vtkHyperTreeGridOrientedGeometryCursor* NewOrientedGeometryCursor(
400  vtkIdType index, bool create = false);
401 
405  void InitializeNonOrientedCursor(
406  vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
407  vtkHyperTreeGridNonOrientedCursor* NewNonOrientedCursor(vtkIdType index, bool create = false);
408 
412  void InitializeNonOrientedGeometryCursor(
413  vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
414  vtkHyperTreeGridNonOrientedGeometryCursor* NewNonOrientedGeometryCursor(
415  vtkIdType index, bool create = false);
416 
420  vtkHyperTreeGridNonOrientedGeometryCursor* FindNonOrientedGeometryCursor(double x[3]);
421 
422 private:
423  unsigned int RecurseDichotomic(
424  double value, vtkDoubleArray* coord, unsigned int ideb, unsigned int ifin) const;
425 
426  unsigned int FindDichotomic(double value, vtkDataArray* coord) const;
427 
428 public:
429  virtual unsigned int FindDichotomicX(double value) const;
430  virtual unsigned int FindDichotomicY(double value) const;
431  virtual unsigned int FindDichotomicZ(double value) const;
432 
436  void InitializeNonOrientedVonNeumannSuperCursor(
438  vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* NewNonOrientedVonNeumannSuperCursor(
439  vtkIdType index, bool create = false);
440 
444  void InitializeNonOrientedVonNeumannSuperCursorLight(
446  bool create = false);
447  vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight* NewNonOrientedVonNeumannSuperCursorLight(
448  vtkIdType index, bool create = false);
449 
453  void InitializeNonOrientedMooreSuperCursor(
454  vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, vtkIdType index, bool create = false);
455  vtkHyperTreeGridNonOrientedMooreSuperCursor* NewNonOrientedMooreSuperCursor(
456  vtkIdType index, bool create = false);
457 
461  void InitializeNonOrientedMooreSuperCursorLight(
463  vtkHyperTreeGridNonOrientedMooreSuperCursorLight* NewNonOrientedMooreSuperCursorLight(
464  vtkIdType index, bool create = false);
465 
469  void Initialize() override;
470 
475  virtual vtkHyperTree* GetTree(vtkIdType, bool create = false);
476 
481  void SetTree(vtkIdType, vtkHyperTree*);
482 
486  void ShallowCopy(vtkDataObject*) override;
487 
491  void DeepCopy(vtkDataObject*) override;
492 
496  int GetExtentType() override { return VTK_3D_EXTENT; }
497 
506  virtual unsigned long GetActualMemorySizeBytes();
507 
516  unsigned long GetActualMemorySize() override;
517 
521  bool RecursivelyInitializePureMask(
523 
527  vtkBitArray* GetPureMask();
528 
579  unsigned int GetChildMask(unsigned int);
580 
584  void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
585 
591  vtkIdType GetShiftedLevelZeroIndex(vtkIdType, unsigned int, unsigned int, unsigned int) const;
592 
596  void GetLevelZeroCoordinatesFromIndex(
597  vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
598 
602  virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
603 
607  virtual void GetLevelZeroOriginFromIndex(vtkIdType, double*);
608 
617  vtkIdType GetGlobalNodeIndexMax();
618 
624  void InitializeLocalIndexNode();
625 
630  bool HasAnyGhostCells() const;
631 
635  vtkUnsignedCharArray* GetGhostCells();
636 
641  vtkUnsignedCharArray* GetTreeGhostArray();
642 
646  vtkUnsignedCharArray* AllocateTreeGhostArray();
647 
651  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
652  {
653  public:
655 
659  void Initialize(vtkHyperTreeGrid*);
660 
665  vtkHyperTree* GetNextTree(vtkIdType& index);
666 
671  vtkHyperTree* GetNextTree();
672 
673  protected:
674  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree> >::iterator Iterator;
676  };
677 
682  void InitializeTreeIterator(vtkHyperTreeGridIterator&);
683 
685 
688  static vtkHyperTreeGrid* GetData(vtkInformation* info);
689  static vtkHyperTreeGrid* GetData(vtkInformationVector* v, int i = 0);
691 
697  virtual double* GetBounds() VTK_SIZEHINT(6);
698 
704  void GetBounds(double bounds[6]);
705 
710  double* GetCenter() VTK_SIZEHINT(3);
711 
716  void GetCenter(double center[3]);
717 
719 
723  vtkPointData* GetPointData();
725 
726 protected:
731 
735  virtual ~vtkHyperTreeGrid() override;
736 
740  char* ModeSqueeze;
741 
742  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
743  double Center[3]; // geometric center
744 
745  bool FreezeState;
746  unsigned int BranchFactor; // 2 or 3
747  unsigned int Dimension; // 1, 2, or 3
748 
750 
754  vtkUnsignedCharArray* TreeGhostArray;
755  bool TreeGhostArrayCached;
757 private:
758  unsigned int Orientation; // 0, 1, or 2
759  unsigned int Axis[2];
760 
761 protected:
762  unsigned int NumberOfChildren;
763  bool TransposedRootIndexing;
764 
765  // --------------------------------
766  // RectilinearGrid common fields
767  // --------------------------------
768 private:
769  unsigned int Dimensions[3]; // Just for GetDimensions
770  unsigned int CellDims[3]; // Just for GetCellDims
771 protected:
772  int DataDescription;
773  int Extent[6];
774 
775  bool WithCoordinates;
776  vtkDataArray* XCoordinates;
777  vtkDataArray* YCoordinates;
778  vtkDataArray* ZCoordinates;
779  // --------------------------------
780 
781  vtkBitArray* Mask;
782  vtkBitArray* PureMask;
783  bool InitPureMask;
784 
785  bool HasInterface;
786  char* InterfaceNormalsName;
787  char* InterfaceInterceptsName;
788 
789  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree> > HyperTrees;
790 
791  vtkNew<vtkPointData> PointData; // Scalars, vectors, etc. associated w/ each point
792 
793  unsigned int DepthLimiter;
794 
795 private:
796  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
797  void operator=(const vtkHyperTreeGrid&) = delete;
798 };
799 
800 #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:281
vtkDataObject::Initialize
virtual void Initialize()
Restore data object to initial state,.
vtkHyperTreeGridNonOrientedMooreSuperCursor
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedMooreSuperCursor.h:48
vtkPointData
represent and manipulate point attribute data
Definition: vtkPointData.h:31
vtkX3D::value
@ value
Definition: vtkX3D.h:226
vtkIdType
int vtkIdType
Definition: vtkType.h:338
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:117
vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight
Objects for traversal a HyperTreeGrid.
Definition: vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight.h:45
vtkHyperTreeGrid::SetIndexingModeToKJI
void SetIndexingModeToKJI()
Definition: vtkHyperTreeGrid.h:255
vtkX3D::center
@ 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:651
vtkHyperTreeGrid::GetExtentType
int GetExtentType() override
Structured extent.
Definition: vtkHyperTreeGrid.h:496
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:234
vtkHyperTreeGrid::vtkHyperTreeGridIterator::Grid
vtkHyperTreeGrid * Grid
Definition: vtkHyperTreeGrid.h:675
vtkHyperTreeGrid::vtkHyperTreeGridIterator::vtkHyperTreeGridIterator
vtkHyperTreeGridIterator()
Definition: vtkHyperTreeGrid.h:654
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:56
vtkBoundingBox
Fast, simple class for dealing with 3D bounds.
Definition: vtkBoundingBox.h:34
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:203
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:31
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:674
vtkSmartPointer.h
vtkHyperTreeGrid::Get2DAxes
void Get2DAxes(unsigned int &axis1, unsigned int &axis2) const
JB Retourne l'indice des deux dimensions valides.
Definition: vtkHyperTreeGrid.h:214
vtkHyperTree
A data object structured as a tree.
Definition: vtkHyperTree.h:178
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:266
vtkHyperTreeGrid::GetAxes
const unsigned int * GetAxes() const
JB Get the axis information (used for CopyStructure)
Definition: vtkHyperTreeGrid.h:226
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
@ 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
@ extent
Definition: vtkX3D.h:351
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkX3D::index
@ 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:128
vtkDataObject::New
static vtkDataObject * New()
vtkHyperTreeGrid
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
Definition: vtkHyperTreeGrid.h:96
vtkHyperTreeGrid::SetIndexingModeToIJK
void SetIndexingModeToIJK()
Definition: vtkHyperTreeGrid.h:256