VTK
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 "vtkSmartPointer.h" // vtkSmartPointer
69 #include "vtkNew.h" // vtkSmartPointer
70 // #include "vtkPointData.h" // vtkPointData
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;
82 class vtkDoubleArray;
84 class vtkIdTypeArray;
85 class vtkLine;
86 class vtkPixel;
87 class vtkPoints;
88 class vtkPointData;
89 class vtkVoxel;
90 
99 
100 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
101 {
102 public:
103  static vtkInformationIntegerKey* LEVELS();
104  static vtkInformationIntegerKey* DIMENSION();
105  static vtkInformationIntegerKey* ORIENTATION();
106  static vtkInformationDoubleVectorKey* SIZES();
107  static vtkHyperTreeGrid* New();
108 
110  void PrintSelf(ostream& os, vtkIndent indent) override;
111 
115  vtkSetStringMacro(ModeSqueeze); // By copy
116  vtkGetStringMacro(ModeSqueeze);
117 
121  virtual void Squeeze();
122 
126  int GetDataObjectType() override { return VTK_HYPER_TREE_GRID; }
127 
132  virtual void CopyStructure(vtkDataObject*);
133 
134  // --------------------------------------------------------------------------
135  // RectilinearGrid common API
136  // --------------------------------------------------------------------------
137 
139 
142  void SetDimensions(const unsigned int dims[3]);
143  void SetDimensions(const int dims[3]);
144  void SetDimensions(unsigned int i, unsigned int j, unsigned int k);
145  void SetDimensions(int i, int j, int k);
147 
149 
153  const unsigned int* GetDimensions() const VTK_SIZEHINT(3);
154  // JB Dommage, car vtkGetVectorMacro(Dimensions,int,3); not const function
155  void GetDimensions(int dim[3]) const;
156  void GetDimensions(unsigned int dim[3]) const;
158 
160 
166  void SetExtent(const int extent[6]);
167  void SetExtent(int x1, int x2, int y1, int y2, int z1, int z2);
168  vtkGetVector6Macro(Extent, int);
170 
172 
177  const unsigned int* GetCellDims() const VTK_SIZEHINT(3);
178  void GetCellDims(int cellDims[3]) const;
179  void GetCellDims(unsigned int cellDims[3]) const;
181 
182  // --------------------------------------------------------------------------
183 
185 
189  unsigned int GetDimension() const { return this->Dimension; }
191 
193 
196  void Get1DAxis(unsigned int& axis) const
197  {
198  assert("pre: valid_dim" && this->GetDimension() == 1);
199  axis = this->Axis[0];
200  }
202 
204 
207  void Get2DAxes(unsigned int& axis1, unsigned int& axis2) const
208  {
209  assert("pre: valid_dim" && this->GetDimension() == 2);
210  axis1 = this->Axis[0];
211  axis2 = this->Axis[1];
212  }
214 
216 
219  const unsigned int* GetAxes() const { return this->Axis; }
221 
223 
226  // vtkGetMacro(NumberOfChildren, unsigned int); not const
227  unsigned int GetNumberOfChildren() const { return this->NumberOfChildren; }
229 
239  // JB ?? virtual void GetNumberOfTreesPerDimension(unsigned int dimsOut[3]);
240 
242 
246  vtkSetMacro(TransposedRootIndexing, bool);
247  vtkGetMacro(TransposedRootIndexing, bool);
248  void SetIndexingModeToKJI() { this->SetTransposedRootIndexing(false); }
249  void SetIndexingModeToIJK() { this->SetTransposedRootIndexing(true); }
251 
253 
259  unsigned int GetOrientation() const { return this->Orientation; }
261 
263 
266  vtkGetMacro(FreezeState, bool);
268 
270 
273  void SetBranchFactor(unsigned int);
274  unsigned int GetBranchFactor() const { return this->BranchFactor; }
276 
280  vtkIdType GetMaxNumberOfTrees();
281 
285  vtkIdType GetNumberOfVertices();
286 
290  vtkIdType GetNumberOfLeaves();
291 
295  unsigned int GetNumberOfLevels(vtkIdType);
296 
300  unsigned int GetNumberOfLevels();
301 
303 
306  virtual void SetXCoordinates(vtkDataArray*);
307  vtkGetObjectMacro(XCoordinates, vtkDataArray);
309 
311 
314  virtual void SetYCoordinates(vtkDataArray*);
315  vtkGetObjectMacro(YCoordinates, vtkDataArray);
317 
319 
322  virtual void SetZCoordinates(vtkDataArray*);
323  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
325 
327 
330  virtual void CopyCoordinates(const vtkHyperTreeGrid* output);
331  virtual void SetFixedCoordinates(unsigned int axis, double value);
333 
335 
338  void SetMask(vtkBitArray*);
339  vtkGetObjectMacro(Mask, vtkBitArray);
341 
345  bool HasMask();
346 
348 
351  vtkSetMacro(HasInterface, bool);
352  vtkGetMacro(HasInterface, bool);
353  vtkBooleanMacro(HasInterface, bool);
355 
357 
360  vtkSetStringMacro(InterfaceNormalsName);
361  vtkGetStringMacro(InterfaceNormalsName);
363 
365 
368  vtkSetStringMacro(InterfaceInterceptsName);
369  vtkGetStringMacro(InterfaceInterceptsName);
371 
373 
376  vtkSetMacro(DepthLimiter, unsigned int);
377  vtkGetMacro(DepthLimiter, unsigned int);
379 
383  void InitializeOrientedCursor(
384  vtkHyperTreeGridOrientedCursor* cursor, vtkIdType index, bool create = false);
385  vtkHyperTreeGridOrientedCursor* NewOrientedCursor(vtkIdType index, bool create = false);
386 
390  void InitializeOrientedGeometryCursor(
391  vtkHyperTreeGridOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
392  vtkHyperTreeGridOrientedGeometryCursor* NewOrientedGeometryCursor(
393  vtkIdType index, bool create = false);
394 
398  void InitializeNonOrientedCursor(
399  vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType index, bool create = false);
400  vtkHyperTreeGridNonOrientedCursor* NewNonOrientedCursor(vtkIdType index, bool create = false);
401 
405  void InitializeNonOrientedGeometryCursor(
406  vtkHyperTreeGridNonOrientedGeometryCursor* cursor, vtkIdType index, bool create = false);
407  vtkHyperTreeGridNonOrientedGeometryCursor* NewNonOrientedGeometryCursor(
408  vtkIdType index, bool create = false);
409 
413  vtkHyperTreeGridNonOrientedGeometryCursor* FindNonOrientedGeometryCursor(double x[3]);
414 
415 private:
416  unsigned int RecurseDichotomic(
417  double value, vtkDoubleArray* coord, unsigned int ideb, unsigned int ifin) const;
418 
419  unsigned int FindDichotomic(double value, vtkDataArray* coord) const;
420 
421 protected:
422  virtual unsigned int FindDichotomicX(double value) const;
423  virtual unsigned int FindDichotomicY(double value) const;
424  virtual unsigned int FindDichotomicZ(double value) const;
425 
426 public:
430  void InitializeNonOrientedVonNeumannSuperCursor(
431  vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* cursor, vtkIdType index, bool create = false);
432  vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* NewNonOrientedVonNeumannSuperCursor(
433  vtkIdType index, bool create = false);
434 
438  void InitializeNonOrientedVonNeumannSuperCursorLight(
440  bool create = false);
441  vtkHyperTreeGridNonOrientedVonNeumannSuperCursorLight* NewNonOrientedVonNeumannSuperCursorLight(
442  vtkIdType index, bool create = false);
443 
447  void InitializeNonOrientedMooreSuperCursor(
448  vtkHyperTreeGridNonOrientedMooreSuperCursor* cursor, vtkIdType index, bool create = false);
449  vtkHyperTreeGridNonOrientedMooreSuperCursor* NewNonOrientedMooreSuperCursor(
450  vtkIdType index, bool create = false);
451 
455  void InitializeNonOrientedMooreSuperCursorLight(
456  vtkHyperTreeGridNonOrientedMooreSuperCursorLight* cursor, vtkIdType index, bool create = false);
457  vtkHyperTreeGridNonOrientedMooreSuperCursorLight* NewNonOrientedMooreSuperCursorLight(
458  vtkIdType index, bool create = false);
459 
463  void Initialize() override;
464 
469  virtual vtkHyperTree* GetTree(vtkIdType, bool create = false);
470 
475  void SetTree(vtkIdType, vtkHyperTree*);
476 
480  void ShallowCopy(vtkDataObject*) override;
481 
485  void DeepCopy(vtkDataObject*) override;
486 
490  int GetExtentType() override { return VTK_3D_EXTENT; }
491 
500  virtual unsigned long GetActualMemorySizeBytes();
501 
510  unsigned long GetActualMemorySize() override;
511 
515  bool RecursivelyInitializePureMask(
517 
521  vtkBitArray* GetPureMask();
522 
573  unsigned int GetChildMask(unsigned int);
574 
578  void GetIndexFromLevelZeroCoordinates(vtkIdType&, unsigned int, unsigned int, unsigned int) const;
579 
585  vtkIdType GetShiftedLevelZeroIndex(vtkIdType, unsigned int, unsigned int, unsigned int) const;
586 
590  void GetLevelZeroCoordinatesFromIndex(
591  vtkIdType, unsigned int&, unsigned int&, unsigned int&) const;
592 
596  virtual void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*);
597 
601  virtual void GetLevelZeroOriginFromIndex(vtkIdType, double*);
602 
611  vtkIdType GetGlobalNodeIndexMax();
612 
618  void InitializeLocalIndexNode();
619 
621 
625  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
626  {
627  public:
631 
633 
636  vtkHyperTree* GetTree() { return this->Tree; }
638 
642  vtkIdType GetLeafIndex() { return this->Index; }
643 
647  unsigned short GetLevel() { return this->Level; }
648 
649  private:
650  vtkHyperTree* Tree;
651  vtkIdType Index;
652  unsigned short Level;
653  };
654 
662  {
663  double Origin[3];
664  double Size[3];
667  vtkHyperTreeSimpleCursor Cursors[3 * 3 * 3];
668  vtkHyperTreeSimpleCursor* GetCursor(int);
669  };
670 
674  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
675  {
676  public:
678 
682  void Initialize(vtkHyperTreeGrid*);
683 
688  vtkHyperTree* GetNextTree(vtkIdType& index);
689 
694  vtkHyperTree* GetNextTree();
695 
696  protected:
697  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>>::iterator Iterator;
699  };
700 
705  void InitializeTreeIterator(vtkHyperTreeGridIterator&);
706 
708 
711  static vtkHyperTreeGrid* GetData(vtkInformation* info);
712  static vtkHyperTreeGrid* GetData(vtkInformationVector* v, int i = 0);
714 
720  virtual double* GetBounds() VTK_SIZEHINT(6);
721 
727  void GetBounds(double bounds[6]);
728 
733  double* GetCenter() VTK_SIZEHINT(3);
734 
739  void GetCenter(double center[3]);
740 
745  vtkPointData* GetPointData();
746 
747 protected:
752 
756  ~vtkHyperTreeGrid() override;
757 
761  char* ModeSqueeze;
762 
763  double Bounds[6]; // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
764  double Center[3]; // geometric center
765 
766  bool FreezeState;
767  unsigned int BranchFactor; // 2 or 3
768  unsigned int Dimension; // 1, 2, or 3
769 private:
770  unsigned int Orientation; // 0, 1, or 2
771  unsigned int Axis[2];
772 
773 protected:
774  unsigned int NumberOfChildren;
775  bool TransposedRootIndexing;
776 
777  // --------------------------------
778  // RectilinearGrid common fields
779  // --------------------------------
780 private:
781  unsigned int Dimensions[3]; // Just for GetDimensions
782  unsigned int CellDims[3]; // Just for GetCellDims
783 protected:
784  int DataDescription;
785  int Extent[6];
786 
787  bool WithCoordinates;
788  vtkDataArray* XCoordinates;
789  vtkDataArray* YCoordinates;
790  vtkDataArray* ZCoordinates;
791  // --------------------------------
792 
793  vtkBitArray* Mask;
794  vtkBitArray* PureMask;
795  bool InitPureMask;
796 
797  bool HasInterface;
798  char* InterfaceNormalsName;
799  char* InterfaceInterceptsName;
800 
801  std::map<vtkIdType, vtkSmartPointer<vtkHyperTree>> HyperTrees;
802 
803  vtkNew<vtkPointData> PointData; // Scalars, vectors, etc. associated w/ each point
804 
805  unsigned int DepthLimiter;
806 
807 private:
808  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
809  void operator=(const vtkHyperTreeGrid&) = delete;
810 };
811 
812 #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&#39;indice des deux dimensions valides.
unsigned int GetDimension() const
JB Get the dimensionality of the grid deduite a partir de Dimensions/Extent.
represent and manipulate point attribute data
Definition: vtkPointData.h:37
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_3D_EXTENT
Definition: vtkDataObject.h:61
#define VTK_HYPER_TREE_GRID
Definition: vtkType.h:123
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:40
unsigned short GetLevel()
Return level at which cursor is positioned.
virtual void Initialize()
Restore data object to initial state,.
dynamic, self-adjusting array of vtkIdType
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:30
int vtkIdType
Definition: vtkType.h:349
vtkHyperTree * GetTree()
Methods that belong to the vtkHyperTreeCursor API.
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:35
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:44
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&#39;indice de la dimension valide.
virtual unsigned long GetActualMemorySize()
Return the actual size of the data in kibibytes (1024 bytes).
Objects for traversal a HyperTreeGrid.
std::map< vtkIdType, vtkSmartPointer< vtkHyperTree > >::iterator Iterator
A simplified hyper tree cursor, to be used by the hyper tree.
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:36
create and manipulate ordered lists of objects
Definition: vtkCollection.h:51
Public structure used by filters to move around the hyper tree grid and easily access neighbors to le...
An object structured as a tree where each node has exactly either 2^d or 3^d children.
Definition: vtkHyperTree.h:166
Allocate and hold a VTK object.
Definition: vtkMeta.h:29
vtkIdType GetLeafIndex()
Only valid for leaves.
An iterator object to iteratively access trees in the grid.
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:64
int GetExtentType() override
Structured extent.
virtual void DeepCopy(vtkDataObject *src)
Shallow and Deep copy.
represent and manipulate 3D points
Definition: vtkPoints.h:39
Fast Simple Class for dealing with 3D bounds.
virtual void ShallowCopy(vtkDataObject *src)
Shallow and Deep copy.