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 =========================================================================*/
46 #ifndef vtkHyperTreeGrid_h
47 #define vtkHyperTreeGrid_h
48 
49 #include "vtkCommonDataModelModule.h" // For export macro
50 #include "vtkDataSet.h"
51 
52 #include <map> // STL header for dual point coordinates adjustment
53 
54 class vtkHyperTree;
55 class vtkHyperTreeCursor;
57 
58 class vtkBitArray;
59 class vtkBoundingBox;
60 class vtkCellLinks;
61 class vtkCollection;
62 class vtkDataArray;
64 class vtkIdTypeArray;
65 class vtkLine;
66 class vtkPixel;
67 class vtkPoints;
68 class vtkVoxel;
69 
70 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet
71 {
72 public:
74  class vtkHyperTreePositionCursor;
77 
78  static vtkInformationIntegerKey* LEVELS();
79  static vtkInformationIntegerKey* DIMENSION();
80  static vtkInformationIntegerKey* ORIENTATION();
81  static vtkInformationDoubleVectorKey* SIZES();
82  static vtkHyperTreeGrid* New();
83 
84  vtkTypeMacro(vtkHyperTreeGrid, vtkDataSet);
85  void PrintSelf( ostream&, vtkIndent ) override;
86 
90  int GetDataObjectType() override;
91 
96  void CopyStructure( vtkDataSet* ) override;
97 
99 
102  void SetGridSize( unsigned int[3] );
103  void SetGridSize( unsigned int, unsigned int, unsigned int );
104  vtkGetVector3Macro(GridSize, unsigned int);
106 
108 
112  void SetGridExtent(int extent[6]);
113  void SetGridExtent(int, int, int, int, int, int );
115 
117 
121  vtkSetMacro(TransposedRootIndexing, bool);
122  vtkGetMacro(TransposedRootIndexing, bool);
124  { this->SetTransposedRootIndexing( false ); }
126  { this->SetTransposedRootIndexing( true ); }
128 
130 
133  void SetDimension( unsigned int );
134  vtkGetMacro(Dimension, unsigned int);
136 
138 
144  virtual void SetOrientation(unsigned int);
145  vtkGetMacro(Orientation, unsigned int);
147 
149 
152  void SetBranchFactor( unsigned int );
153  vtkGetMacro(BranchFactor, unsigned int);
155 
159  vtkIdType GetNumberOfTrees();
160 
164  vtkIdType GetNumberOfVertices();
165 
169  vtkIdType GetNumberOfLeaves();
170 
174  vtkIdType GetNumberOfCells() override;
175 
179  vtkIdType GetNumberOfPoints() override;
180 
184  vtkIdType GetNumberOfLevels( vtkIdType );
185 
189  vtkIdType GetNumberOfLevels();
190 
192 
195  void SetXCoordinates( vtkDataArray* );
196  vtkGetObjectMacro(XCoordinates, vtkDataArray);
198 
200 
203  void SetYCoordinates( vtkDataArray* );
204  vtkGetObjectMacro(YCoordinates, vtkDataArray);
206 
208 
211  void SetZCoordinates( vtkDataArray* );
212  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
214 
216 
219  void SetMaterialMask( vtkBitArray* );
220  vtkGetObjectMacro(MaterialMask, vtkBitArray);
222 
226  bool HasMaterialMask();
227 
229 
232  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
233  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
235 
237 
240  vtkSetMacro( HasInterface, bool );
241  vtkGetMacro( HasInterface, bool );
242  vtkBooleanMacro( HasInterface, bool );
244 
246 
249  vtkSetStringMacro(InterfaceNormalsName);
250  vtkGetStringMacro(InterfaceNormalsName);
252 
254 
257  vtkSetStringMacro(InterfaceInterceptsName);
258  vtkGetStringMacro(InterfaceInterceptsName);
260 
264  virtual void GenerateTrees();
265 
272  vtkHyperTreeCursor* NewCursor( vtkIdType, bool create=false );
273 
281  vtkHyperTreeGridCursor* NewGridCursor( vtkIdType,
282  bool create=false );
283 
291  vtkHyperTreeGridCursor* NewGeometricCursor( vtkIdType,
292  bool create=false );
293 
302  vtkHyperTreeGridCursor* NewVonNeumannSuperCursor( vtkIdType,
303  bool create=false );
304 
313  vtkHyperTreeGridCursor* NewMooreSuperCursor( vtkIdType,
314  bool create=false );
315 
322  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
323 
330  double* GetPoint( vtkIdType ) override;
331 
340  void GetPoint( vtkIdType, double[3] ) override;
341 
348  vtkCell* GetCell( vtkIdType ) override;
349 
354  vtkCell* GetCell( int i, int j, int k) override {
355  return this->Superclass::GetCell(i,j,k);
356  };
357 
367  void GetCell( vtkIdType, vtkGenericCell* ) override;
368 
375  int GetCellType( vtkIdType ) override;
376 
384  void GetCellPoints( vtkIdType, vtkIdList* ) override;
385 
391 
399  void GetPointCells( vtkIdType, vtkIdList* ) override;
400 
411  void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) override;
412 
419  vtkIdType FindPoint( double x[3] ) override;
420 
434  vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
435  double tol2, int& subId, double pcoords[3],
436  double *weights ) override;
437 
445  vtkIdType FindCell( double x[3], vtkCell *cell,
446  vtkGenericCell *gencell, vtkIdType cellId,
447  double tol2, int& subId, double pcoords[3],
448  double *weights ) override;
449 
453  void Initialize() override;
454 
459  vtkHyperTree* GetTree( vtkIdType );
460 
465  void SetTree( vtkIdType, vtkHyperTree* );
466 
471  void InitializeTreeIterator( vtkHyperTreeGridIterator& );
472 
479  int GetMaxCellSize() override;
480 
484  void ShallowCopy( vtkDataObject* ) override;
485 
489  void DeepCopy( vtkDataObject* ) override;
490 
494  int GetExtentType() override { return VTK_3D_EXTENT; }
495 
504  unsigned long GetActualMemorySize() override;
505 
507 
510  vtkGetMacro(NumberOfChildren, unsigned int);
512 
516  bool RecursivelyInitializePureMaterialMask( vtkHyperTreeGridCursor* cursor );
517 
521  vtkBitArray* GetPureMaterialMask();
522 
573  unsigned int GetChildMask( unsigned int );
574 
578  void GetLevelZeroCoordinatesFromIndex( vtkIdType,
579  unsigned int&,
580  unsigned int&,
581  unsigned int& );
582 
586  void GetIndexFromLevelZeroCoordinates( vtkIdType&,
587  unsigned int,
588  unsigned int,
589  unsigned int );
590 
596  unsigned int GetShiftedLevelZeroIndex( vtkIdType,
597  int,
598  int,
599  int );
600 
602 
606  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
607  {
608  public:
612 
614 
617  vtkHyperTree* GetTree() { return this->Tree; }
619 
623  vtkIdType GetLeafIndex() { return this->Index; }
624 
628  unsigned short GetLevel() { return this->Level; }
629 
630  private:
631  vtkHyperTree* Tree;
632  vtkIdType Index;
633  unsigned short Level;
634  };
635 
643  {
644  double Origin[3];
645  double Size[3];
648  vtkHyperTreeSimpleCursor Cursors[3*3*3];
649  vtkHyperTreeSimpleCursor* GetCursor( int );
650  };
651 
655  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
656  {
657  public:
659 
663  void Initialize( vtkHyperTreeGrid* );
664 
669  vtkHyperTree* GetNextTree( vtkIdType& index );
670 
675  vtkHyperTree* GetNextTree();
676 
677  protected:
678  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
680  };
681 
683 
686  static vtkHyperTreeGrid* GetData( vtkInformation* info );
687  static vtkHyperTreeGrid* GetData( vtkInformationVector* v, int i=0);
689 
690 protected:
695 
699  ~vtkHyperTreeGrid() override;
700 
701  void ComputeBounds() override;
702 
709  void ComputeDualGrid();
710 
711  vtkPoints* GetPoints();
712  vtkIdTypeArray* GetConnectivity();
713 
714  unsigned int BranchFactor; // 2 or 3
715  unsigned int Dimension; // 1, 2, or 3
716  unsigned int Orientation; // 0, 1, or 2
717  unsigned int GridSize[3];
718  int Extent[6];
719  unsigned int NumberOfChildren;
721 
726 
730 
734 
735  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
736 
739  std::map<vtkIdType, bool> PointShifted;
740  std::map<vtkIdType, double> PointShifts[3];
741  std::map<vtkIdType, double> ReductionFactors;
742 
746  void DeepCopyCursors( vtkHyperTreeCursor*, vtkHyperTreeCursor* );
747 
751  void DeleteTrees();
752 
756  void ResetDual();
757 
765  void ResetSuperCursor();
766 
770  void TraverseDualRecursively( vtkHyperTreeGridCursor* );
771 
776  void TraverseDualRecursively( vtkHyperTreeGridCursor*, vtkBitArray* );
777 
781  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor* );
782 
787  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor*, vtkBitArray* );
788 
792  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor* );
793 
798  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
799 
803  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor* );
804 
809  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
810 
814  void ShiftDualCornerFromMaskedLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
815 
819  void ShiftDualCornerFromMaskedLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
820 
824  vtkIdType RecursivelyFindPoint( double x[3],
826  double*,
827  double* );
828 
829 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__)
830  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
831 #endif
832 
834 
841 
843 
847  void BuildLinks();
849 
850 private:
851  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
852  void operator=(const vtkHyperTreeGrid&) = delete;
853 
854  void GetCellImplementation( vtkIdType, vtkCell* );
855 };
856 
857 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkHyperTreeGridCursor
Objects for depth-first traversal HyperTreeGrids.
Definition: vtkHyperTreeGridCursor.h:45
vtkHyperTreeGrid::vtkHyperTreeSimpleCursor::GetLeafIndex
vtkIdType GetLeafIndex()
Only valid for leaves.
Definition: vtkHyperTreeGrid.h:623
vtkDataSet::GetNumberOfPoints
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
vtkDataSet::GetActualMemorySize
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
vtkHyperTreeGrid::Links
vtkCellLinks * Links
Not really needed.
Definition: vtkHyperTreeGrid.h:846
vtkHyperTreeGrid::BranchFactor
unsigned int BranchFactor
Definition: vtkHyperTreeGrid.h:714
vtkHyperTreeGrid::ZCoordinates
vtkDataArray * ZCoordinates
Definition: vtkHyperTreeGrid.h:733
vtkDataSet::ShallowCopy
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkHyperTreeGrid::TransposedRootIndexing
bool TransposedRootIndexing
Definition: vtkHyperTreeGrid.h:720
vtkHyperTreeGrid::Connectivity
vtkIdTypeArray * Connectivity
Definition: vtkHyperTreeGrid.h:738
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:59
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkHyperTreeGrid::Points
vtkPoints * Points
Definition: vtkHyperTreeGrid.h:737
vtkDataSet::GetDataObjectType
int GetDataObjectType() override
Return the type of data object.
Definition: vtkDataSet.h:359
vtkHyperTreeGrid::ReductionFactors
std::map< vtkIdType, double > ReductionFactors
Definition: vtkHyperTreeGrid.h:741
vtkHyperTreeGrid::vtkHyperTreeGridSuperCursor::NumberOfCursors
int NumberOfCursors
Definition: vtkHyperTreeGrid.h:646
vtkHyperTreeGrid::vtkHyperTreeGridIterator::Iterator
std::map< vtkIdType, vtkHyperTree * >::iterator Iterator
Definition: vtkHyperTreeGrid.h:678
vtkDataSet::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkHyperTreeGrid::Line
vtkLine * Line
These are needed by the GetCell() method.
Definition: vtkHyperTreeGrid.h:837
vtkHyperTreeGrid::InterfaceNormalsName
char * InterfaceNormalsName
Definition: vtkHyperTreeGrid.h:728
vtkHyperTreeGrid::vtkHyperTreeGridSuperCursor::MiddleCursorId
int MiddleCursorId
Definition: vtkHyperTreeGrid.h:647
vtkHyperTreeGrid::vtkHyperTreeSimpleCursor
A simplified hyper tree cursor, to be used by the hyper tree.
Definition: vtkHyperTreeGrid.h:606
vtkHyperTreeGrid::InitPureMaterialMask
bool InitPureMaterialMask
Definition: vtkHyperTreeGrid.h:725
vtkHyperTreeGrid::SetIndexingModeToKJI
void SetIndexingModeToKJI()
Definition: vtkHyperTreeGrid.h:123
vtkHyperTreeGrid::Dimension
unsigned int Dimension
Definition: vtkHyperTreeGrid.h:715
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkHyperTreeGrid::vtkHyperTreeGridSuperCursor
Public structure used by filters to move around the hyper tree grid and easily access neighbors to le...
Definition: vtkHyperTreeGrid.h:642
vtkHyperTreeGrid::vtkHyperTreeSimpleCursor::GetTree
vtkHyperTree * GetTree()
Methods that belong to the vtkHyperTreeCursor API.
Definition: vtkHyperTreeGrid.h:617
vtkHyperTreeGrid::vtkHyperTreeSimpleCursor::GetLevel
unsigned short GetLevel()
Return level at which cursor is positioned.
Definition: vtkHyperTreeGrid.h:628
vtkDataSet::FindCell
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.
vtkHyperTreeGrid::vtkHyperTreeGridIterator
An iterator object to iteratively access trees in the grid.
Definition: vtkHyperTreeGrid.h:655
vtkHyperTreeGrid::MaterialMask
vtkBitArray * MaterialMask
Definition: vtkHyperTreeGrid.h:722
vtkHyperTreeGrid::GetExtentType
int GetExtentType() override
Structured extent.
Definition: vtkHyperTreeGrid.h:494
vtkLine
cell represents a 1D line
Definition: vtkLine.h:35
vtkHyperTreeGrid::vtkHyperTreeGridIterator::vtkHyperTreeGridIterator
vtkHyperTreeGridIterator()
Definition: vtkHyperTreeGrid.h:658
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:61
vtkBoundingBox
Fast Simple Class for dealing with 3D bounds.
Definition: vtkBoundingBox.h:35
vtkHyperTreeGrid::NumberOfChildren
unsigned int NumberOfChildren
Definition: vtkHyperTreeGrid.h:719
vtkCollection
create and manipulate ordered lists of objects
Definition: vtkCollection.h:51
vtkDataSet::FindPoint
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:197
vtkDataSet::GetCellNeighbors
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
Topological inquiry to get all cells using list of points exclusive of cell specified (e....
vtkHyperTreeGrid::Pixel
vtkPixel * Pixel
Definition: vtkHyperTreeGrid.h:838
vtkHyperTreeGrid::XCoordinates
vtkDataArray * XCoordinates
Definition: vtkHyperTreeGrid.h:731
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:59
vtkHyperTreeCursor
Objects for depth-first traversal HyperTrees.
Definition: vtkHyperTreeCursor.h:42
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:34
vtkHyperTreeGrid::HyperTrees
std::map< vtkIdType, vtkHyperTree * > HyperTrees
Definition: vtkHyperTreeGrid.h:735
vtkDataSet::GetPointCells
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
Topological inquiry to get cells using point.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkDataSet::Initialize
void Initialize() override
Restore data object to initial state.
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkHyperTree
An object structured as a tree where each node has exactly either 2^d or 3^d children.
Definition: vtkHyperTree.h:142
vtkHyperTreeGrid::GetCell
vtkCell * GetCell(int i, int j, int k) override
Overridden so as no not unintentionally hide parent class.
Definition: vtkHyperTreeGrid.h:354
vtkHyperTreeGrid::PureMaterialMask
vtkBitArray * PureMaterialMask
Definition: vtkHyperTreeGrid.h:723
vtkDataSet.h
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkDataSet::GetCellPoints
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
vtkHyperTreeGrid::HasInterface
bool HasInterface
Definition: vtkHyperTreeGrid.h:727
vtkX3D::info
Definition: vtkX3D.h:376
vtkDataSet::GetPoint
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:41
vtkHyperTreeGrid::Voxel
vtkVoxel * Voxel
Definition: vtkHyperTreeGrid.h:839
vtkPixel
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:40
vtkInformationDoubleVectorKey
Key for double vector values.
Definition: vtkInformationDoubleVectorKey.h:34
vtkHyperTreeGrid::InterfaceInterceptsName
char * InterfaceInterceptsName
Definition: vtkHyperTreeGrid.h:729
vtkHyperTreeGrid::MaterialMaskIndex
vtkIdTypeArray * MaterialMaskIndex
Definition: vtkHyperTreeGrid.h:724
vtkDataSet::CopyStructure
virtual void CopyStructure(vtkDataSet *ds)=0
Copy the geometric and topological structure of an object.
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:39
vtkBitArray
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:36
vtkHyperTreeGrid::vtkHyperTreeGridIterator::Tree
vtkHyperTreeGrid * Tree
Definition: vtkHyperTreeGrid.h:679
vtkX3D::extent
Definition: vtkX3D.h:345
vtkDataSet::GetNumberOfCells
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkDataSet::GetCellType
virtual int GetCellType(vtkIdType cellId)=0
Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
vtkX3D::index
Definition: vtkX3D.h:246
vtkHyperTreeGrid::YCoordinates
vtkDataArray * YCoordinates
Definition: vtkHyperTreeGrid.h:732
vtkHyperTreeGrid::Orientation
unsigned int Orientation
Definition: vtkHyperTreeGrid.h:716
vtkDataSet::GetMaxCellSize
virtual int GetMaxCellSize()=0
Convenience method returns largest cell size in dataset.
vtkDataSet::DeepCopy
void DeepCopy(vtkDataObject *src) override
vtkHyperTreeGrid::PointShifted
std::map< vtkIdType, bool > PointShifted
Definition: vtkHyperTreeGrid.h:739
vtkDataObject::New
static vtkDataObject * New()
vtkHyperTreeGrid
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
Definition: vtkHyperTreeGrid.h:70
vtkDataSet::GetCell
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
vtkHyperTreeGrid::SetIndexingModeToIJK
void SetIndexingModeToIJK()
Definition: vtkHyperTreeGrid.h:125
vtkVoxel
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:44