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