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 =========================================================================*/
43 #ifndef vtkHyperTreeGrid_h
44 #define vtkHyperTreeGrid_h
45 
46 #include "vtkCommonDataModelModule.h" // For export macro
47 #include "vtkDataSet.h"
48 
49 #include <map> // STL header for dual point coordinates adjustment
50 
51 class vtkHyperTree;
52 class vtkHyperTreeCursor;
54 
55 class vtkBitArray;
56 class vtkBoundingBox;
57 class vtkCellLinks;
58 class vtkCollection;
59 class vtkDataArray;
61 class vtkIdTypeArray;
62 class vtkLine;
63 class vtkPixel;
64 class vtkPoints;
65 class vtkVoxel;
66 
67 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet
68 {
69 public:
71  class vtkHyperTreePositionCursor;
74 
75  static vtkInformationIntegerKey* LEVELS();
76  static vtkInformationIntegerKey* DIMENSION();
77  static vtkInformationIntegerKey* ORIENTATION();
78  static vtkInformationDoubleVectorKey* SIZES();
79  static vtkHyperTreeGrid* New();
80 
81  vtkTypeMacro(vtkHyperTreeGrid, vtkDataSet);
82  void PrintSelf( ostream&, vtkIndent ) override;
83 
87  int GetDataObjectType() override;
88 
93  void CopyStructure( vtkDataSet* ) override;
94 
96 
99  void SetGridSize( unsigned int[3] );
100  void SetGridSize( unsigned int, unsigned int, unsigned int );
101  vtkGetVector3Macro(GridSize, unsigned int);
103 
105 
109  void SetGridExtent(int extent[6]);
110  void SetGridExtent(int, int, int, int, int, int );
112 
114 
118  vtkSetMacro(TransposedRootIndexing, bool);
119  vtkGetMacro(TransposedRootIndexing, bool);
121  { this->SetTransposedRootIndexing( false ); }
123  { this->SetTransposedRootIndexing( true ); }
125 
127 
130  void SetDimension( unsigned int );
131  vtkGetMacro(Dimension, unsigned int);
133 
135 
141  virtual void SetOrientation(unsigned int);
142  vtkGetMacro(Orientation, unsigned int);
144 
146 
149  void SetBranchFactor( unsigned int );
150  vtkGetMacro(BranchFactor, unsigned int);
152 
156  vtkIdType GetNumberOfTrees();
157 
161  vtkIdType GetNumberOfVertices();
162 
166  vtkIdType GetNumberOfLeaves();
167 
171  vtkIdType GetNumberOfCells() override;
172 
176  vtkIdType GetNumberOfPoints() override;
177 
181  vtkIdType GetNumberOfLevels( vtkIdType );
182 
186  vtkIdType GetNumberOfLevels();
187 
189 
192  void SetXCoordinates( vtkDataArray* );
193  vtkGetObjectMacro(XCoordinates, vtkDataArray);
195 
197 
200  void SetYCoordinates( vtkDataArray* );
201  vtkGetObjectMacro(YCoordinates, vtkDataArray);
203 
205 
208  void SetZCoordinates( vtkDataArray* );
209  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
211 
213 
216  void SetMaterialMask( vtkBitArray* );
217  vtkGetObjectMacro(MaterialMask, vtkBitArray);
219 
223  bool HasMaterialMask();
224 
226 
229  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
230  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
232 
234 
237  vtkSetMacro( HasInterface, bool );
238  vtkGetMacro( HasInterface, bool );
239  vtkBooleanMacro( HasInterface, bool );
241 
243 
246  vtkSetStringMacro(InterfaceNormalsName);
247  vtkGetStringMacro(InterfaceNormalsName);
249 
251 
254  vtkSetStringMacro(InterfaceInterceptsName);
255  vtkGetStringMacro(InterfaceInterceptsName);
257 
261  virtual void GenerateTrees();
262 
269  vtkHyperTreeCursor* NewCursor( vtkIdType, bool create=false );
270 
278  vtkHyperTreeGridCursor* NewGridCursor( vtkIdType,
279  bool create=false );
280 
288  vtkHyperTreeGridCursor* NewGeometricCursor( vtkIdType,
289  bool create=false );
290 
299  vtkHyperTreeGridCursor* NewVonNeumannSuperCursor( vtkIdType,
300  bool create=false );
301 
310  vtkHyperTreeGridCursor* NewMooreSuperCursor( vtkIdType,
311  bool create=false );
312 
319  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
320 
327  double* GetPoint( vtkIdType ) override;
328 
337  void GetPoint( vtkIdType, double[3] ) override;
338 
345  vtkCell* GetCell( vtkIdType ) override;
346 
351  vtkCell* GetCell( int i, int j, int k) override {
352  return this->Superclass::GetCell(i,j,k);
353  };
354 
364  void GetCell( vtkIdType, vtkGenericCell* ) override;
365 
372  int GetCellType( vtkIdType ) override;
373 
381  void GetCellPoints( vtkIdType, vtkIdList* ) override;
382 
388 
396  void GetPointCells( vtkIdType, vtkIdList* ) override;
397 
408  void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) override;
409 
416  vtkIdType FindPoint( double x[3] ) override;
417 
431  vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
432  double tol2, int& subId, double pcoords[3],
433  double *weights ) override;
434 
442  vtkIdType FindCell( double x[3], vtkCell *cell,
443  vtkGenericCell *gencell, vtkIdType cellId,
444  double tol2, int& subId, double pcoords[3],
445  double *weights ) override;
446 
450  void Initialize() override;
451 
456  vtkHyperTree* GetTree( vtkIdType );
457 
462  void SetTree( vtkIdType, vtkHyperTree* );
463 
468  void InitializeTreeIterator( vtkHyperTreeGridIterator& );
469 
476  int GetMaxCellSize() override;
477 
481  void ShallowCopy( vtkDataObject* ) override;
482 
486  void DeepCopy( vtkDataObject* ) override;
487 
491  int GetExtentType() override { return VTK_3D_EXTENT; }
492 
501  unsigned long GetActualMemorySize() override;
502 
504 
507  vtkGetMacro(NumberOfChildren, unsigned int);
509 
513  bool RecursivelyInitializePureMaterialMask( vtkHyperTreeGridCursor* cursor );
514 
518  vtkBitArray* GetPureMaterialMask();
519 
570  unsigned int GetChildMask( unsigned int );
571 
575  void GetLevelZeroCoordinatesFromIndex( vtkIdType,
576  unsigned int&,
577  unsigned int&,
578  unsigned int& );
579 
583  void GetIndexFromLevelZeroCoordinates( vtkIdType&,
584  unsigned int,
585  unsigned int,
586  unsigned int );
587 
593  unsigned int GetShiftedLevelZeroIndex( vtkIdType,
594  int,
595  int,
596  int );
597 
599 
603  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
604  {
605  public:
609 
611 
614  vtkHyperTree* GetTree() { return this->Tree; }
616 
620  vtkIdType GetLeafIndex() { return this->Index; }
621 
625  unsigned short GetLevel() { return this->Level; }
626 
627  private:
628  vtkHyperTree* Tree;
629  vtkIdType Index;
630  unsigned short Level;
631  };
632 
640  {
641  double Origin[3];
642  double Size[3];
645  vtkHyperTreeSimpleCursor Cursors[3*3*3];
646  vtkHyperTreeSimpleCursor* GetCursor( int );
647  };
648 
652  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
653  {
654  public:
656 
660  void Initialize( vtkHyperTreeGrid* );
661 
666  vtkHyperTree* GetNextTree( vtkIdType& index );
667 
672  vtkHyperTree* GetNextTree();
673 
674  protected:
675  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
677  };
678 
680 
683  static vtkHyperTreeGrid* GetData( vtkInformation* info );
684  static vtkHyperTreeGrid* GetData( vtkInformationVector* v, int i=0);
686 
687 protected:
692 
696  ~vtkHyperTreeGrid() override;
697 
698  void ComputeBounds() override;
699 
706  void ComputeDualGrid();
707 
708  vtkPoints* GetPoints();
709  vtkIdTypeArray* GetConnectivity();
710 
711  unsigned int BranchFactor; // 2 or 3
712  unsigned int Dimension; // 1, 2, or 3
713  unsigned int Orientation; // 0, 1, or 2
714  unsigned int GridSize[3];
715  int Extent[6];
716  unsigned int NumberOfChildren;
718 
723 
727 
731 
732  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
733 
736  std::map<vtkIdType, bool> PointShifted;
737  std::map<vtkIdType, double> PointShifts[3];
738  std::map<vtkIdType, double> ReductionFactors;
739 
743  void DeepCopyCursors( vtkHyperTreeCursor*, vtkHyperTreeCursor* );
744 
748  void DeleteTrees();
749 
753  void ResetDual();
754 
762  void ResetSuperCursor();
763 
767  void TraverseDualRecursively( vtkHyperTreeGridCursor* );
768 
773  void TraverseDualRecursively( vtkHyperTreeGridCursor*, vtkBitArray* );
774 
778  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor* );
779 
784  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor*, vtkBitArray* );
785 
789  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor* );
790 
795  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
796 
800  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor* );
801 
806  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
807 
811  void ShiftDualCornerFromMaskedLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
812 
816  void ShiftDualCornerFromMaskedLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
817 
821  vtkIdType RecursivelyFindPoint( double x[3],
823  double*,
824  double* );
825 
826 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__)
827  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
828 #endif
829 
831 
838 
840 
844  void BuildLinks();
846 
847 private:
848  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
849  void operator=(const vtkHyperTreeGrid&) = delete;
850 
851  void GetCellImplementation( vtkIdType, vtkCell* );
852 };
853 
854 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkHyperTreeGridCursor
Objects for depth-first traversal HyperTreeGrids.
Definition: vtkHyperTreeGridCursor.h:45
vtkHyperTreeGrid::vtkHyperTreeSimpleCursor::GetLeafIndex
vtkIdType GetLeafIndex()
Only valid for leaves.
Definition: vtkHyperTreeGrid.h:620
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:843
vtkHyperTreeGrid::BranchFactor
unsigned int BranchFactor
Definition: vtkHyperTreeGrid.h:711
vtkHyperTreeGrid::ZCoordinates
vtkDataArray * ZCoordinates
Definition: vtkHyperTreeGrid.h:730
vtkDataSet::ShallowCopy
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
vtkHyperTreeGrid::TransposedRootIndexing
bool TransposedRootIndexing
Definition: vtkHyperTreeGrid.h:717
vtkHyperTreeGrid::Connectivity
vtkIdTypeArray * Connectivity
Definition: vtkHyperTreeGrid.h:735
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:53
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkHyperTreeGrid::Points
vtkPoints * Points
Definition: vtkHyperTreeGrid.h:734
vtkDataSet::GetDataObjectType
int GetDataObjectType() override
Return the type of data object.
Definition: vtkDataSet.h:353
vtkHyperTreeGrid::ReductionFactors
std::map< vtkIdType, double > ReductionFactors
Definition: vtkHyperTreeGrid.h:738
vtkHyperTreeGrid::vtkHyperTreeGridSuperCursor::NumberOfCursors
int NumberOfCursors
Definition: vtkHyperTreeGrid.h:643
vtkHyperTreeGrid::vtkHyperTreeGridIterator::Iterator
std::map< vtkIdType, vtkHyperTree * >::iterator Iterator
Definition: vtkHyperTreeGrid.h:675
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:834
vtkHyperTreeGrid::InterfaceNormalsName
char * InterfaceNormalsName
Definition: vtkHyperTreeGrid.h:725
vtkHyperTreeGrid::vtkHyperTreeGridSuperCursor::MiddleCursorId
int MiddleCursorId
Definition: vtkHyperTreeGrid.h:644
vtkHyperTreeGrid::vtkHyperTreeSimpleCursor
A simplified hyper tree cursor, to be used by the hyper tree.
Definition: vtkHyperTreeGrid.h:603
vtkHyperTreeGrid::InitPureMaterialMask
bool InitPureMaterialMask
Definition: vtkHyperTreeGrid.h:722
vtkHyperTreeGrid::SetIndexingModeToKJI
void SetIndexingModeToKJI()
Definition: vtkHyperTreeGrid.h:120
vtkHyperTreeGrid::Dimension
unsigned int Dimension
Definition: vtkHyperTreeGrid.h:712
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkHyperTreeGrid::vtkHyperTreeGridSuperCursor
Public structure used by filters to move around the hyper tree grid and easily access neighbors to le...
Definition: vtkHyperTreeGrid.h:639
vtkHyperTreeGrid::vtkHyperTreeSimpleCursor::GetTree
vtkHyperTree * GetTree()
Methods that belong to the vtkHyperTreeCursor API.
Definition: vtkHyperTreeGrid.h:614
vtkHyperTreeGrid::vtkHyperTreeSimpleCursor::GetLevel
unsigned short GetLevel()
Return level at which cursor is positioned.
Definition: vtkHyperTreeGrid.h:625
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:652
vtkHyperTreeGrid::MaterialMask
vtkBitArray * MaterialMask
Definition: vtkHyperTreeGrid.h:719
vtkHyperTreeGrid::GetExtentType
int GetExtentType() override
Structured extent.
Definition: vtkHyperTreeGrid.h:491
vtkLine
cell represents a 1D line
Definition: vtkLine.h:29
vtkHyperTreeGrid::vtkHyperTreeGridIterator::vtkHyperTreeGridIterator
vtkHyperTreeGridIterator()
Definition: vtkHyperTreeGrid.h:655
VTK_3D_EXTENT
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:55
vtkBoundingBox
Fast Simple Class for dealing with 3D bounds.
Definition: vtkBoundingBox.h:32
vtkHyperTreeGrid::NumberOfChildren
unsigned int NumberOfChildren
Definition: vtkHyperTreeGrid.h:716
vtkCollection
create and manipulate ordered lists of objects
Definition: vtkCollection.h:48
vtkDataSet::FindPoint
vtkIdType FindPoint(double x, double y, double z)
Locate the closest point to the global coordinate x.
Definition: vtkDataSet.h:191
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:835
vtkHyperTreeGrid::XCoordinates
vtkDataArray * XCoordinates
Definition: vtkHyperTreeGrid.h:728
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:56
vtkHyperTreeCursor
Objects for depth-first traversal HyperTrees.
Definition: vtkHyperTreeCursor.h:42
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:31
vtkHyperTreeGrid::HyperTrees
std::map< vtkIdType, vtkHyperTree * > HyperTrees
Definition: vtkHyperTreeGrid.h:732
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:33
vtkDataSet::Initialize
void Initialize() override
Restore data object to initial state.
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
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:351
vtkHyperTreeGrid::PureMaterialMask
vtkBitArray * PureMaterialMask
Definition: vtkHyperTreeGrid.h:720
vtkDataSet.h
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkDataSet::GetCellPoints
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Topological inquiry to get points defining cell.
vtkHyperTreeGrid::HasInterface
bool HasInterface
Definition: vtkHyperTreeGrid.h:724
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:35
vtkHyperTreeGrid::Voxel
vtkVoxel * Voxel
Definition: vtkHyperTreeGrid.h:836
vtkPixel
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:34
vtkInformationDoubleVectorKey
Key for double vector values.
Definition: vtkInformationDoubleVectorKey.h:31
vtkHyperTreeGrid::InterfaceInterceptsName
char * InterfaceInterceptsName
Definition: vtkHyperTreeGrid.h:726
vtkHyperTreeGrid::MaterialMaskIndex
vtkIdTypeArray * MaterialMaskIndex
Definition: vtkHyperTreeGrid.h:721
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:36
vtkBitArray
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:33
vtkHyperTreeGrid::vtkHyperTreeGridIterator::Tree
vtkHyperTreeGrid * Tree
Definition: vtkHyperTreeGrid.h:676
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:58
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:729
vtkHyperTreeGrid::Orientation
unsigned int Orientation
Definition: vtkHyperTreeGrid.h:713
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:736
vtkDataObject::New
static vtkDataObject * New()
vtkHyperTreeGrid
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
Definition: vtkHyperTreeGrid.h:67
vtkDataSet::GetCell
virtual vtkCell * GetCell(vtkIdType cellId)=0
Get cell with cellId such that: 0 <= cellId < NumberOfCells.
vtkHyperTreeGrid::SetIndexingModeToIJK
void SetIndexingModeToIJK()
Definition: vtkHyperTreeGrid.h:122
vtkVoxel
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:38