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
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:347
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
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
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.
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.