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 =========================================================================*/
45 #ifndef vtkHyperTreeGrid_h
46 #define vtkHyperTreeGrid_h
47 
48 #include "vtkCommonDataModelModule.h" // For export macro
49 #include "vtkDataSet.h"
50 
51 #include <map> // STL header for dual point coordinates ajustment
52 
53 class vtkHyperTree;
54 class vtkHyperTreeCursor;
56 
57 class vtkBitArray;
58 class vtkBoundingBox;
59 class vtkCellLinks;
60 class vtkCollection;
61 class vtkDataArray;
63 class vtkIdTypeArray;
64 class vtkLine;
65 class vtkPixel;
66 class vtkPoints;
67 class vtkVoxel;
68 
69 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet
70 {
71 public:
73  class vtkHyperTreePositionCursor;
76 
77  static vtkInformationIntegerKey* LEVELS();
78  static vtkInformationIntegerKey* DIMENSION();
79  static vtkInformationIntegerKey* ORIENTATION();
80  static vtkInformationDoubleVectorKey* SIZES();
81  static vtkHyperTreeGrid* New();
82 
83  vtkTypeMacro(vtkHyperTreeGrid, vtkDataSet);
84  void PrintSelf( ostream&, vtkIndent ) override;
85 
89  int GetDataObjectType() override;
90 
95  void CopyStructure( vtkDataSet* ) override;
96 
98 
101  void SetGridSize( unsigned int[3] );
102  void SetGridSize( unsigned int, unsigned int, unsigned int );
103  vtkGetVector3Macro(GridSize, unsigned int);
105 
107 
110  void SetGridExtent(int extent[6]);
111  void SetGridExtent(int, int, int, int, int, int );
113 
115 
119  vtkSetMacro(TransposedRootIndexing, bool);
120  vtkGetMacro(TransposedRootIndexing, bool);
122  { this->SetTransposedRootIndexing( false ); }
124  { this->SetTransposedRootIndexing( true ); }
126 
128 
131  void SetDimension( unsigned int );
132  vtkGetMacro(Dimension, unsigned int);
134 
136 
142  virtual void SetOrientation(unsigned int);
143  vtkGetMacro(Orientation, unsigned int);
145 
147 
150  void SetBranchFactor( unsigned int );
151  vtkGetMacro(BranchFactor, unsigned int);
153 
157  vtkIdType GetNumberOfTrees();
158 
162  vtkIdType GetNumberOfVertices();
163 
167  vtkIdType GetNumberOfLeaves();
168 
172  vtkIdType GetNumberOfCells() override;
173 
177  vtkIdType GetNumberOfPoints() override;
178 
182  vtkIdType GetNumberOfLevels( vtkIdType );
183 
187  vtkIdType GetNumberOfLevels();
188 
190 
193  void SetXCoordinates( vtkDataArray* );
194  vtkGetObjectMacro(XCoordinates, vtkDataArray);
196 
198 
201  void SetYCoordinates( vtkDataArray* );
202  vtkGetObjectMacro(YCoordinates, vtkDataArray);
204 
206 
209  void SetZCoordinates( vtkDataArray* );
210  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
212 
214 
217  void SetMaterialMask( vtkBitArray* );
218  vtkGetObjectMacro(MaterialMask, vtkBitArray);
220 
224  bool HasMaterialMask();
225 
227 
230  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
231  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
233 
235 
238  vtkSetMacro( HasInterface, bool );
239  vtkGetMacro( HasInterface, bool );
240  vtkBooleanMacro( HasInterface, bool );
242 
244 
247  vtkSetStringMacro(InterfaceNormalsName);
248  vtkGetStringMacro(InterfaceNormalsName);
250 
252 
255  vtkSetStringMacro(InterfaceInterceptsName);
256  vtkGetStringMacro(InterfaceInterceptsName);
258 
262  virtual void GenerateTrees();
263 
270  vtkHyperTreeCursor* NewCursor( vtkIdType, bool create=false );
271 
279  vtkHyperTreeGridCursor* NewGridCursor( vtkIdType,
280  bool create=false );
281 
289  vtkHyperTreeGridCursor* NewGeometricCursor( vtkIdType,
290  bool create=false );
291 
300  vtkHyperTreeGridCursor* NewVonNeumannSuperCursor( vtkIdType,
301  bool create=false );
302 
311  vtkHyperTreeGridCursor* NewMooreSuperCursor( vtkIdType,
312  bool create=false );
313 
320  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
321 
328  double* GetPoint( vtkIdType ) override;
329 
338  void GetPoint( vtkIdType, double[3] ) override;
339 
346  vtkCell* GetCell( vtkIdType ) override;
347 
352  vtkCell* GetCell( int i, int j, int k) override {
353  return this->Superclass::GetCell(i,j,k);
354  };
355 
365  void GetCell( vtkIdType, vtkGenericCell* ) override;
366 
373  int GetCellType( vtkIdType ) override;
374 
382  void GetCellPoints( vtkIdType, vtkIdList* ) override;
383 
389 
397  void GetPointCells( vtkIdType, vtkIdList* ) override;
398 
409  void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) override;
410 
417  vtkIdType FindPoint( double x[3] ) override;
418 
432  vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
433  double tol2, int& subId, double pcoords[3],
434  double *weights ) override;
435 
443  vtkIdType FindCell( double x[3], vtkCell *cell,
444  vtkGenericCell *gencell, vtkIdType cellId,
445  double tol2, int& subId, double pcoords[3],
446  double *weights ) override;
447 
451  void Initialize() override;
452 
457  vtkHyperTree* GetTree( vtkIdType );
458 
463  void SetTree( vtkIdType, vtkHyperTree* );
464 
469  void InitializeTreeIterator( vtkHyperTreeGridIterator& );
470 
477  int GetMaxCellSize() override;
478 
482  void ShallowCopy( vtkDataObject* ) override;
483 
487  void DeepCopy( vtkDataObject* ) override;
488 
492  int GetExtentType() override { return VTK_3D_EXTENT; }
493 
502  unsigned long GetActualMemorySize() override;
503 
505 
508  vtkGetMacro(NumberOfChildren, unsigned int);
510 
514  bool RecursivelyInitializePureMaterialMask( vtkHyperTreeGridCursor* cursor );
515 
519  vtkBitArray* GetPureMaterialMask();
520 
571  unsigned int GetChildMask( unsigned int );
572 
576  void GetLevelZeroCoordinatesFromIndex( vtkIdType,
577  unsigned int&,
578  unsigned int&,
579  unsigned int& );
580 
584  void GetIndexFromLevelZeroCoordinates( vtkIdType&,
585  unsigned int,
586  unsigned int,
587  unsigned int );
588 
594  unsigned int GetShiftedLevelZeroIndex( vtkIdType,
595  int,
596  int,
597  int );
598 
600 
604  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
605  {
606  public:
610 
612 
615  vtkHyperTree* GetTree() { return this->Tree; }
617 
621  vtkIdType GetLeafIndex() { return this->Index; }
622 
626  unsigned short GetLevel() { return this->Level; }
627 
628  private:
629  vtkHyperTree* Tree;
630  vtkIdType Index;
631  unsigned short Level;
632  };
633 
641  {
642  double Origin[3];
643  double Size[3];
646  vtkHyperTreeSimpleCursor Cursors[3*3*3];
647  vtkHyperTreeSimpleCursor* GetCursor( int );
648  };
649 
653  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridIterator
654  {
655  public:
657 
661  void Initialize( vtkHyperTreeGrid* );
662 
667  vtkHyperTree* GetNextTree( vtkIdType& index );
668 
673  vtkHyperTree* GetNextTree();
674 
675  protected:
676  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
678  };
679 
681 
684  static vtkHyperTreeGrid* GetData( vtkInformation* info );
685  static vtkHyperTreeGrid* GetData( vtkInformationVector* v, int i=0);
687 
688 protected:
693 
697  ~vtkHyperTreeGrid() override;
698 
699  void ComputeBounds() override;
700 
707  void ComputeDualGrid();
708 
709  vtkPoints* GetPoints();
710  vtkIdTypeArray* GetConnectivity();
711 
712  unsigned int BranchFactor; // 2 or 3
713  unsigned int Dimension; // 1, 2, or 3
714  unsigned int Orientation; // 0, 1, or 2
715  unsigned int GridSize[3];
716  int Extent[6];
717  unsigned int NumberOfChildren;
719 
724 
728 
732 
733  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
734 
737  std::map<vtkIdType, bool> PointShifted;
738  std::map<vtkIdType, double> PointShifts[3];
739  std::map<vtkIdType, double> ReductionFactors;
740 
744  void DeepCopyCursors( vtkHyperTreeCursor*, vtkHyperTreeCursor* );
745 
749  void DeleteTrees();
750 
754  void ResetDual();
755 
763  void ResetSuperCursor();
764 
768  void TraverseDualRecursively( vtkHyperTreeGridCursor* );
769 
774  void TraverseDualRecursively( vtkHyperTreeGridCursor*, vtkBitArray* );
775 
779  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor* );
780 
785  void GenerateDualCornerFromLeaf1D( vtkHyperTreeGridCursor*, vtkBitArray* );
786 
790  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor* );
791 
796  void GenerateDualCornerFromLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
797 
801  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor* );
802 
807  void GenerateDualCornerFromLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
808 
812  void ShiftDualCornerFromMaskedLeaf2D( vtkHyperTreeGridCursor*, vtkBitArray* );
813 
817  void ShiftDualCornerFromMaskedLeaf3D( vtkHyperTreeGridCursor*, vtkBitArray* );
818 
822  vtkIdType RecursivelyFindPoint( double x[3],
824  double*,
825  double* );
826 
827 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__)
828  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
829 #endif
830 
832 
839 
841 
845  void BuildLinks();
847 
848 private:
849  vtkHyperTreeGrid(const vtkHyperTreeGrid&) = delete;
850  void operator=(const vtkHyperTreeGrid&) = delete;
851 
852  void GetCellImplementation( vtkIdType, vtkCell* );
853 };
854 
855 #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
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.