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 =========================================================================*/
42 #ifndef vtkHyperTreeGrid_h
43 #define vtkHyperTreeGrid_h
44 
45 #include "vtkCommonDataModelModule.h" // For export macro
46 #include "vtkDataSet.h"
47 
48 #include <map> // STL header for dual point coordinates ajustment
49 
50 class vtkHyperTree;
51 class vtkHyperTreeCursor;
53 
54 class vtkBitArray;
55 class vtkBoundingBox;
56 class vtkCellLinks;
57 class vtkCollection;
58 class vtkDataArray;
60 class vtkIdTypeArray;
61 class vtkLine;
62 class vtkPixel;
63 class vtkPoints;
64 class vtkVoxel;
65 
66 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet
67 {
68 public:
70  class vtkHyperTreePositionCursor;
73 
74  static vtkInformationIntegerKey* LEVELS();
75  static vtkInformationIntegerKey* DIMENSION();
76  static vtkInformationIntegerKey* ORIENTATION();
77  static vtkInformationDoubleVectorKey* SIZES();
78  static vtkHyperTreeGrid* New();
79 
80  vtkTypeMacro(vtkHyperTreeGrid, vtkDataSet);
81  void PrintSelf( ostream&, vtkIndent ) override;
82 
86  int GetDataObjectType() override;
87 
92  void CopyStructure( vtkDataSet* ) override;
93 
95 
98  void SetGridSize( unsigned int[3] );
99  void SetGridSize( unsigned int, unsigned int, unsigned int );
100  vtkGetVector3Macro(GridSize, unsigned int);
102 
104 
107  void SetGridExtent(int extent[6]);
108  void SetGridExtent(int, int, int, int, int, int );
110 
112 
116  vtkSetMacro(TransposedRootIndexing, bool);
117  vtkGetMacro(TransposedRootIndexing, bool);
119  { this->SetTransposedRootIndexing( false ); }
121  { this->SetTransposedRootIndexing( true ); }
123 
125 
128  void SetDimension( unsigned int );
129  vtkGetMacro(Dimension, unsigned int);
131 
133 
139  virtual void SetOrientation(unsigned int);
140  vtkGetMacro(Orientation, unsigned int);
142 
144 
147  void SetBranchFactor( unsigned int );
148  vtkGetMacro(BranchFactor, unsigned int);
150 
154  vtkIdType GetNumberOfTrees();
155 
159  vtkIdType GetNumberOfVertices();
160 
164  vtkIdType GetNumberOfLeaves();
165 
169  vtkIdType GetNumberOfCells() override;
170 
174  vtkIdType GetNumberOfPoints() override;
175 
179  vtkIdType GetNumberOfLevels( vtkIdType );
180 
184  vtkIdType GetNumberOfLevels();
185 
187 
190  void SetXCoordinates( vtkDataArray* );
191  vtkGetObjectMacro(XCoordinates, vtkDataArray);
193 
195 
198  void SetYCoordinates( vtkDataArray* );
199  vtkGetObjectMacro(YCoordinates, vtkDataArray);
201 
203 
206  void SetZCoordinates( vtkDataArray* );
207  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
209 
211 
214  void SetMaterialMask( vtkBitArray* );
215  vtkGetObjectMacro(MaterialMask, vtkBitArray);
217 
221  bool HasMaterialMask();
222 
224 
227  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
228  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
230 
232 
235  vtkSetMacro( HasInterface, bool );
236  vtkGetMacro( HasInterface, bool );
237  vtkBooleanMacro( HasInterface, bool );
239 
241 
244  vtkSetStringMacro(InterfaceNormalsName);
245  vtkGetStringMacro(InterfaceNormalsName);
247 
249 
252  vtkSetStringMacro(InterfaceInterceptsName);
253  vtkGetStringMacro(InterfaceInterceptsName);
255 
259  virtual void GenerateTrees();
260 
267  vtkHyperTreeCursor* NewCursor( vtkIdType, bool create=false );
268 
276  vtkHyperTreeGridCursor* NewGridCursor( vtkIdType,
277  bool create=false );
278 
286  vtkHyperTreeGridCursor* NewGeometricCursor( vtkIdType,
287  bool create=false );
288 
297  vtkHyperTreeGridCursor* NewVonNeumannSuperCursor( vtkIdType,
298  bool create=false );
299 
308  vtkHyperTreeGridCursor* NewMooreSuperCursor( vtkIdType,
309  bool create=false );
310 
317  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
318 
325  double* GetPoint( vtkIdType ) override;
326 
335  void GetPoint( vtkIdType, double[3] ) override;
336 
343  vtkCell* GetCell( vtkIdType ) override;
344 
349  vtkCell* GetCell( int i, int j, int k) override {
350  return this->Superclass::GetCell(i,j,k);
351  };
352 
362  void GetCell( vtkIdType, vtkGenericCell* ) override;
363 
370  int GetCellType( vtkIdType ) override;
371 
379  void GetCellPoints( vtkIdType, vtkIdList* ) override;
380 
386 
394  void GetPointCells( vtkIdType, vtkIdList* ) override;
395 
406  void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) override;
407 
414  vtkIdType FindPoint( double x[3] ) override;
415 
429  vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
430  double tol2, int& subId, double pcoords[3],
431  double *weights ) override;
432 
440  vtkIdType FindCell( double x[3], vtkCell *cell,
441  vtkGenericCell *gencell, vtkIdType cellId,
442  double tol2, int& subId, double pcoords[3],
443  double *weights ) override;
444 
448  void Initialize() override;
449 
454  vtkHyperTree* GetTree( vtkIdType );
455 
460  void SetTree( vtkIdType, vtkHyperTree* );
461 
466  void InitializeTreeIterator( vtkHyperTreeGridIterator& );
467 
474  int GetMaxCellSize() override;
475 
479  void ShallowCopy( vtkDataObject* ) override;
480 
484  void DeepCopy( vtkDataObject* ) override;
485 
489  int GetExtentType() override { return VTK_3D_EXTENT; }
490 
499  unsigned long GetActualMemorySize() override;
500 
502 
505  vtkGetMacro(NumberOfChildren, unsigned int);
507 
511  bool RecursivelyInitializePureMaterialMask( vtkHyperTreeGridCursor* cursor );
512 
516  vtkBitArray* GetPureMaterialMask();
517 
568  unsigned int GetChildMask( unsigned int );
569 
573  void GetLevelZeroCoordinatesFromIndex( vtkIdType,
574  unsigned int&,
575  unsigned int&,
576  unsigned int& );
577 
581  void GetIndexFromLevelZeroCoordinates( vtkIdType&,
582  unsigned int,
583  unsigned int,
584  unsigned int );
585 
591  unsigned int GetShiftedLevelZeroIndex( vtkIdType,
592  int,
593  int,
594  int );
595 
597 
601  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
602  {
603  public:
607 
609 
612  vtkHyperTree* GetTree() { return this->Tree; }
614 
618  vtkIdType GetLeafIndex() { return this->Index; }
619 
623  unsigned short GetLevel() { return this->Level; }
624 
625  private:
626  vtkHyperTree* Tree;
627  vtkIdType Index;
628  unsigned short Level;
629  };
630 
638  {
639  double Origin[3];
640  double Size[3];
643  vtkHyperTreeSimpleCursor Cursors[3*3*3];
644  vtkHyperTreeSimpleCursor* GetCursor( int );
645  };
646 
650  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
651  {
652  public:
654 
658  void Initialize( vtkHyperTreeGrid* );
659 
664  vtkHyperTree* GetNextTree( vtkIdType& index );
665 
670  vtkHyperTree* GetNextTree();
671 
672  protected:
673  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
675  };
676 
678 
681  static vtkHyperTreeGrid* GetData( vtkInformation* info );
682  static vtkHyperTreeGrid* GetData( vtkInformationVector* v, int i=0);
684 
685 protected:
690 
694  ~vtkHyperTreeGrid() override;
695 
696  void ComputeBounds() override;
697 
704  void ComputeDualGrid();
705 
706  vtkPoints* GetPoints();
707  vtkIdTypeArray* GetConnectivity();
708 
709  unsigned int BranchFactor; // 2 or 3
710  unsigned int Dimension; // 1, 2, or 3
711  unsigned int Orientation; // 0, 1, or 2
712  unsigned int GridSize[3];
713  int Extent[6];
714  unsigned int NumberOfChildren;
716 
721 
725 
729 
730  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
731 
734  std::map<vtkIdType, bool> PointShifted;
735  std::map<vtkIdType, double> PointShifts[3];
736  std::map<vtkIdType, double> ReductionFactors;
737 
741  void DeepCopyCursors( vtkHyperTreeCursor*, vtkHyperTreeCursor* );
742 
746  void DeleteTrees();
747 
751  void ResetDual();
752 
760  void ResetSuperCursor();
761 
765  void TraverseDualRecursively( vtkHyperTreeGridCursor* );
766 
771  void TraverseDualRecursively( vtkHyperTreeGridCursor*, vtkBitArray* );
772 
776  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor* );
777 
782  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor*, vtkBitArray* );
783 
787  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor* );
788 
793  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
794 
798  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor* );
799 
804  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
805 
809  void ShiftDualCornerFromMaskedLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
810 
814  void ShiftDualCornerFromMaskedLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
815 
819  vtkIdType RecursivelyFindPoint( double x[3],
821  double*,
822  double* );
823 
824 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__)
825  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
826 #endif
827 
829 
836 
838 
842  void BuildLinks();
844 
845 private:
846  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
847  void operator=(const vtkHyperTreeGrid&) = delete;
848 
849  void GetCellImplementation( vtkIdType, vtkCell* );
850 };
851 
852 #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:56
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:55
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:34
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:29
abstract class to specify cell behavior
Definition: vtkCell.h:56
Objects for depth-first traversal HyperTreeGrids.
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:38
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:33
virtual int GetMaxCellSize()=0
Convenience method returns largest cell size in dataset.
list of point or cell ids
Definition: vtkIdList.h:30
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:48
int GetDataObjectType() override
Return the type of data object.
Definition: vtkDataSet.h:353
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:33
create and manipulate ordered lists of objects
Definition: vtkCollection.h:48
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:58
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:191
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:33
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.