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 =========================================================================*/
48 #ifndef vtkHyperTreeGrid_h
49 #define vtkHyperTreeGrid_h
50 
51 #include "vtkCommonDataModelModule.h" // For export macro
52 #include "vtkDataSet.h"
53 
54 #include <map> // STL header for dual point coordinates ajustment
55 
56 class vtkHyperTree;
57 class vtkHyperTreeCursor;
59 
60 class vtkBitArray;
61 class vtkBoundingBox;
62 class vtkCellLinks;
63 class vtkCollection;
64 class vtkDataArray;
66 class vtkIdTypeArray;
67 class vtkLine;
68 class vtkPixel;
69 class vtkPoints;
70 class vtkVoxel;
71 
72 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet
73 {
74 public:
76  class vtkHyperTreePositionCursor;
79 
80  static vtkInformationIntegerKey* LEVELS();
81  static vtkInformationIntegerKey* DIMENSION();
82  static vtkInformationIntegerKey* ORIENTATION();
83  static vtkInformationDoubleVectorKey* SIZES();
84  static vtkHyperTreeGrid* New();
85 
86  vtkTypeMacro(vtkHyperTreeGrid, vtkDataSet);
87  void PrintSelf( ostream&, vtkIndent ) override;
88 
92  int GetDataObjectType() override;
93 
98  void CopyStructure( vtkDataSet* ) override;
99 
101 
104  void SetGridSize( unsigned int[3] );
105  void SetGridSize( unsigned int, unsigned int, unsigned int );
106  vtkGetVector3Macro(GridSize, unsigned int);
108 
110 
113  void SetGridExtent(int extent[6]);
114  void SetGridExtent(int, int, int, int, int, int );
116 
118 
122  vtkSetMacro(TransposedRootIndexing, bool);
123  vtkGetMacro(TransposedRootIndexing, bool);
125  { this->SetTransposedRootIndexing( false ); }
127  { this->SetTransposedRootIndexing( true ); }
129 
131 
134  void SetDimension( unsigned int );
135  vtkGetMacro(Dimension, unsigned int);
137 
139 
145  virtual void SetOrientation(unsigned int);
146  vtkGetMacro(Orientation, unsigned int);
148 
150 
153  void SetBranchFactor( unsigned int );
154  vtkGetMacro(BranchFactor, unsigned int);
156 
160  vtkIdType GetNumberOfTrees();
161 
165  vtkIdType GetNumberOfVertices();
166 
170  vtkIdType GetNumberOfLeaves();
171 
175  vtkIdType GetNumberOfCells() override;
176 
180  vtkIdType GetNumberOfPoints() override;
181 
185  vtkIdType GetNumberOfLevels( vtkIdType );
186 
190  vtkIdType GetNumberOfLevels();
191 
193 
196  void SetXCoordinates( vtkDataArray* );
197  vtkGetObjectMacro(XCoordinates, vtkDataArray);
199 
201 
204  void SetYCoordinates( vtkDataArray* );
205  vtkGetObjectMacro(YCoordinates, vtkDataArray);
207 
209 
212  void SetZCoordinates( vtkDataArray* );
213  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
215 
217 
220  void SetMaterialMask( vtkBitArray* );
221  vtkGetObjectMacro(MaterialMask, vtkBitArray);
223 
227  bool HasMaterialMask();
228 
230 
233  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
234  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
236 
238 
241  vtkSetMacro( HasInterface, bool );
242  vtkGetMacro( HasInterface, bool );
243  vtkBooleanMacro( HasInterface, bool );
245 
247 
250  vtkSetStringMacro(InterfaceNormalsName);
251  vtkGetStringMacro(InterfaceNormalsName);
253 
255 
258  vtkSetStringMacro(InterfaceInterceptsName);
259  vtkGetStringMacro(InterfaceInterceptsName);
261 
265  virtual void GenerateTrees();
266 
273  vtkHyperTreeCursor* NewCursor( vtkIdType, bool create=false );
274 
282  vtkHyperTreeGridCursor* NewGridCursor( vtkIdType,
283  bool create=false );
284 
292  vtkHyperTreeGridCursor* NewGeometricCursor( vtkIdType,
293  bool create=false );
294 
303  vtkHyperTreeGridCursor* NewVonNeumannSuperCursor( vtkIdType,
304  bool create=false );
305 
314  vtkHyperTreeGridCursor* NewMooreSuperCursor( vtkIdType,
315  bool create=false );
316 
323  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
324 
331  double* GetPoint( vtkIdType ) override;
332 
341  void GetPoint( vtkIdType, double[3] ) override;
342 
349  vtkCell* GetCell( vtkIdType ) override;
350 
355  vtkCell* GetCell( int i, int j, int k) override {
356  return this->Superclass::GetCell(i,j,k);
357  };
358 
368  void GetCell( vtkIdType, vtkGenericCell* ) override;
369 
376  int GetCellType( vtkIdType ) override;
377 
385  void GetCellPoints( vtkIdType, vtkIdList* ) override;
386 
392 
400  void GetPointCells( vtkIdType, vtkIdList* ) override;
401 
412  void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) override;
413 
420  vtkIdType FindPoint( double x[3] ) override;
421 
435  vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
436  double tol2, int& subId, double pcoords[3],
437  double *weights ) override;
438 
446  vtkIdType FindCell( double x[3], vtkCell *cell,
447  vtkGenericCell *gencell, vtkIdType cellId,
448  double tol2, int& subId, double pcoords[3],
449  double *weights ) override;
450 
454  void Initialize() override;
455 
460  vtkHyperTree* GetTree( vtkIdType );
461 
466  void SetTree( vtkIdType, vtkHyperTree* );
467 
472  void InitializeTreeIterator( vtkHyperTreeGridIterator& );
473 
480  int GetMaxCellSize() override;
481 
485  void ShallowCopy( vtkDataObject* ) override;
486 
490  void DeepCopy( vtkDataObject* ) override;
491 
495  int GetExtentType() override { return VTK_3D_EXTENT; }
496 
505  unsigned long GetActualMemorySize() override;
506 
508 
511  vtkGetMacro(NumberOfChildren, unsigned int);
513 
517  bool RecursivelyInitializePureMaterialMask( vtkHyperTreeGridCursor* cursor );
518 
522  vtkBitArray* GetPureMaterialMask();
523 
574  unsigned int GetChildMask( unsigned int );
575 
579  void GetLevelZeroCoordinatesFromIndex( vtkIdType,
580  unsigned int&,
581  unsigned int&,
582  unsigned int& );
583 
587  void GetIndexFromLevelZeroCoordinates( vtkIdType&,
588  unsigned int,
589  unsigned int,
590  unsigned int );
591 
597  unsigned int GetShiftedLevelZeroIndex( vtkIdType,
598  int,
599  int,
600  int );
601 
603 
607  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
608  {
609  public:
613 
615 
618  vtkHyperTree* GetTree() { return this->Tree; }
620 
624  vtkIdType GetLeafIndex() { return this->Index; }
625 
629  unsigned short GetLevel() { return this->Level; }
630 
631  private:
632  vtkHyperTree* Tree;
633  vtkIdType Index;
634  unsigned short Level;
635  };
636 
644  {
645  double Origin[3];
646  double Size[3];
649  vtkHyperTreeSimpleCursor Cursors[3*3*3];
650  vtkHyperTreeSimpleCursor* GetCursor( int );
651  };
652 
656  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
657  {
658  public:
660 
664  void Initialize( vtkHyperTreeGrid* );
665 
670  vtkHyperTree* GetNextTree( vtkIdType& index );
671 
676  vtkHyperTree* GetNextTree();
677 
678  protected:
679  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
681  };
682 
684 
687  static vtkHyperTreeGrid* GetData( vtkInformation* info );
688  static vtkHyperTreeGrid* GetData( vtkInformationVector* v, int i=0);
690 
691 protected:
696 
700  ~vtkHyperTreeGrid() override;
701 
702  void ComputeBounds() override;
703 
710  void ComputeDualGrid();
711 
712  vtkPoints* GetPoints();
713  vtkIdTypeArray* GetConnectivity();
714 
715  unsigned int BranchFactor; // 2 or 3
716  unsigned int Dimension; // 1, 2, or 3
717  unsigned int Orientation; // 0, 1, or 2
718  unsigned int GridSize[3];
719  int Extent[6];
720  unsigned int NumberOfChildren;
722 
727 
731 
735 
736  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
737 
740  std::map<vtkIdType, bool> PointShifted;
741  std::map<vtkIdType, double> PointShifts[3];
742  std::map<vtkIdType, double> ReductionFactors;
743 
747  void DeepCopyCursors( vtkHyperTreeCursor*, vtkHyperTreeCursor* );
748 
752  void DeleteTrees();
753 
757  void ResetDual();
758 
766  void ResetSuperCursor();
767 
771  void TraverseDualRecursively( vtkHyperTreeGridCursor* );
772 
777  void TraverseDualRecursively( vtkHyperTreeGridCursor*, vtkBitArray* );
778 
782  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor* );
783 
788  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor*, vtkBitArray* );
789 
793  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor* );
794 
799  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
800 
804  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor* );
805 
810  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
811 
815  void ShiftDualCornerFromMaskedLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
816 
820  void ShiftDualCornerFromMaskedLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
821 
825  vtkIdType RecursivelyFindPoint( double x[3],
827  double*,
828  double* );
829 
830 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__)
831  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
832 #endif
833 
835 
842 
844 
848  void BuildLinks();
850 
851 private:
852  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
853  void operator=(const vtkHyperTreeGrid&) = delete;
854 
855  void GetCellImplementation( vtkIdType, vtkCell* );
856 };
857 
858 #endif
vtkLine * Line
These are needed by the GetCell() method.
std::map< vtkIdType, vtkHyperTree * > HyperTrees
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
Topological inquiry to get cells using point.
static vtkDataObject * New()
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
Locate cell based on global coordinate x and tolerance squared.
void SetIndexingModeToKJI()
Specify whether indexing mode of grid root cells must be transposed to x-axis first, z-axis last, instead of the default z-axis first, k-axis last.
Store vtkAlgorithm input/output information.
unsigned int NumberOfChildren
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:61
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:40
vtkDataArray * ZCoordinates
unsigned short GetLevel()
Return level at which cursor is positioned.
vtkCell * GetCell(int i, int j, int k) override
Overridden so as no not unintentionally hide parent class.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
unsigned int BranchFactor
vtkHyperTree * GetTree()
Methods that belong to the vtkHyperTreeCursor API.
void SetIndexingModeToIJK()
Specify whether indexing mode of grid root cells must be transposed to x-axis first, z-axis last, instead of the default z-axis first, k-axis last.
provides thread-safe access to cells
vtkVoxel * Voxel
These are needed by the GetCell() method.
Objects for depth-first traversal HyperTrees.
cell represents a 1D line
Definition: vtkLine.h:35
abstract class to specify cell behavior
Definition: vtkCell.h:59
Objects for depth-first traversal HyperTreeGrids.
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:44
Key for double vector values.
std::map< vtkIdType, vtkHyperTree * >::iterator Iterator
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual int GetMaxCellSize()=0
Convenience method returns largest cell size in dataset.
list of point or cell ids
Definition: vtkIdList.h:36
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
int GetDataObjectType() override
Return the type of data object.
Definition: vtkDataSet.h:359
vtkDataArray * YCoordinates
vtkIdTypeArray * Connectivity
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
std::map< vtkIdType, bool > PointShifted
void DeepCopy(vtkDataObject *src) override
Shallow and Deep copy.
represent and manipulate attribute data in a dataset
vtkIdTypeArray * MaterialMaskIndex
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e...
unsigned int Dimension
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
unsigned int Orientation
void Initialize() override
Restore data object to initial state.
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:142
vtkIdType GetLeafIndex()
Only valid for leaves.
An iterator object to iteratively access trees in the grid.
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
Store zero or more vtkInformation instances.
vtkBitArray * PureMaterialMask
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
std::map< vtkIdType, double > ReductionFactors
vtkPixel * Pixel
These are needed by the GetCell() method.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkCellLinks * Links
Not really needed.
vtkBitArray * MaterialMask
general representation of visualization data
Definition: vtkDataObject.h:64
int GetExtentType() override
Structured extent.
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:197
char * InterfaceInterceptsName
vtkDataArray * XCoordinates
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
represent and manipulate 3D points
Definition: vtkPoints.h:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
Fast Simple Class for dealing with 3D bounds.