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 =========================================================================*/
47 #ifndef vtkHyperTreeGrid_h
48 #define vtkHyperTreeGrid_h
49 
50 #include "vtkCommonDataModelModule.h" // For export macro
51 #include "vtkDataSet.h"
52 #include <map> // STL header for dual point coordinates ajustment
53 
54 class vtkHyperTreeCursor;
55 class vtkHyperTree;
56 
57 class vtkBitArray;
58 class vtkCellLinks;
59 class vtkCollection;
60 class vtkDataArray;
62 class vtkIdTypeArray;
63 class vtkLine;
64 class vtkPixel;
65 class vtkPoints;
66 class vtkVoxel;
67 
68 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet
69 {
70 public:
71 
75 
76  static vtkInformationIntegerKey* LEVELS();
77  static vtkInformationIntegerKey* DIMENSION();
78  static vtkInformationDoubleVectorKey* SIZES();
79  static vtkHyperTreeGrid* New();
80 
81  vtkTypeMacro(vtkHyperTreeGrid, vtkDataSet);
82  void PrintSelf( ostream&, vtkIndent ) VTK_OVERRIDE;
83 
87  int GetDataObjectType() VTK_OVERRIDE;
88 
93  void CopyStructure( vtkDataSet* ) VTK_OVERRIDE;
94 
96 
99  void SetGridSize( unsigned int[3] );
100  void SetGridSize( unsigned int i, unsigned int j, unsigned int k );
101  vtkGetVector3Macro(GridSize, unsigned int);
103 
105 
108  void SetGridExtent(int extent[6]);
109  void SetGridExtent(int iMin, int iMax, int jMin, int jMax,
110  int kMin, int kMax);
112 
114 
118  vtkSetMacro(TransposedRootIndexing, bool);
119  vtkGetMacro(TransposedRootIndexing, bool);
120  void SetIndexingModeToKJI()
121  { this->SetTransposedRootIndexing( false ); }
123  { this->SetTransposedRootIndexing( true ); }
125 
127 
131  void SetBranchFactor( unsigned int );
132  vtkGetMacro(BranchFactor, unsigned int);
134 
136 
140  void SetDimension( unsigned int );
141  vtkGetMacro(Dimension, unsigned int);
143 
147  vtkIdType GetNumberOfCells() VTK_OVERRIDE;
148 
152  vtkIdType GetNumberOfPoints() VTK_OVERRIDE;
153 
157  vtkIdType GetNumberOfLeaves();
158 
162  vtkIdType GetNumberOfLevels( vtkIdType );
163 
167  vtkIdType GetNumberOfTrees();
168 
170 
173  void SetXCoordinates( vtkDataArray* );
174  vtkGetObjectMacro(XCoordinates, vtkDataArray);
176 
178 
181  void SetYCoordinates( vtkDataArray* );
182  vtkGetObjectMacro(YCoordinates, vtkDataArray);
184 
186 
189  void SetZCoordinates( vtkDataArray* );
190  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
192 
194 
197  void SetMaterialMask( vtkBitArray* );
198  vtkGetObjectMacro(MaterialMask, vtkBitArray);
200 
202 
205  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
206  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
208 
212  virtual void GenerateTrees();
213 
219  vtkHyperTreeCursor* NewCursor( vtkIdType );
220 
227  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
228 
235  double* GetPoint( vtkIdType ) VTK_OVERRIDE;
236 
245  void GetPoint( vtkIdType, double[3] ) VTK_OVERRIDE;
246 
253  vtkCell* GetCell( vtkIdType ) VTK_OVERRIDE;
254 
264  void GetCell( vtkIdType, vtkGenericCell* ) VTK_OVERRIDE;
265 
272  int GetCellType( vtkIdType ) VTK_OVERRIDE;
273 
281  void GetCellPoints( vtkIdType, vtkIdList* ) VTK_OVERRIDE;
282 
287  virtual void GetCellPoints( vtkIdType, vtkIdType&, vtkIdType*& );
288 
296  void GetPointCells( vtkIdType, vtkIdList* ) VTK_OVERRIDE;
297 
308  void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) VTK_OVERRIDE;
309 
316  vtkIdType FindPoint( double x[3] ) VTK_OVERRIDE;
317 
331  vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
332  double tol2, int& subId, double pcoords[3],
333  double *weights ) VTK_OVERRIDE;
334 
342  vtkIdType FindCell( double x[3], vtkCell *cell,
343  vtkGenericCell *gencell, vtkIdType cellId,
344  double tol2, int& subId, double pcoords[3],
345  double *weights ) VTK_OVERRIDE;
346 
351  void Initialize() VTK_OVERRIDE;
352 
356  void InitializeTreeIterator( vtkHyperTreeIterator& );
357 
364  int GetMaxCellSize() VTK_OVERRIDE;
365 
367 
370  void ShallowCopy( vtkDataObject* ) VTK_OVERRIDE;
371  void DeepCopy( vtkDataObject* ) VTK_OVERRIDE;
373 
377  int GetExtentType() VTK_OVERRIDE { return VTK_3D_EXTENT; }
378 
387  unsigned long GetActualMemorySize() VTK_OVERRIDE;
388 
392  void GenerateSuperCursorTraversalTable();
393 
394 #ifndef __VTK_WRAP__
395 
396 
401  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
402  unsigned int,
403  unsigned int,
404  unsigned int,
405  vtkIdType );
406  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
407  vtkIdType );
409 
413  void InitializeSuperCursorChild( vtkHyperTreeGridSuperCursor* parent,
414  vtkHyperTreeGridSuperCursor* child,
415  unsigned int childIdx );
416 #endif
417 
419 
422  vtkGetMacro(NumberOfChildren, unsigned int);
424 
428  void GetLevelZeroCoordsFromIndex( vtkIdType index,
429  unsigned int &i,
430  unsigned int &j,
431  unsigned int &k );
432 
433 protected:
434  // Constructor with default bounds (0,1, 0,1, 0,1).
436  ~vtkHyperTreeGrid() VTK_OVERRIDE;
437 
438  void ComputeBounds() VTK_OVERRIDE;
439 
440  void GetCell( vtkIdType, vtkCell* );
441 
442  void ComputeDualGrid();
443  vtkPoints* GetPoints();
444  vtkIdTypeArray* GetConnectivity();
445 
446  unsigned int Dimension; // 1, 2 or 3.
447  unsigned int GridSize[3];
448  int Extent[6];
449  unsigned int BranchFactor;
450  unsigned int NumberOfChildren;
451  bool TransposedRootIndexing;
452 
453  vtkBitArray* MaterialMask;
454  vtkIdTypeArray* MaterialMaskIndex;
455 
456  vtkDataArray* XCoordinates;
457  vtkDataArray* YCoordinates;
458  vtkDataArray* ZCoordinates;
459 
460  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
461 
462  vtkPoints* Points;
463  vtkIdTypeArray* Connectivity;
464  std::map<vtkIdType, bool> PointShifted;
465  std::map<vtkIdType, double> PointShifts[3];
466  std::map<vtkIdType, double> ReductionFactors;
467 
468  void DeleteInternalArrays();
469  void DeleteTrees();
470 
471 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__)
472  void TraverseDualRecursively( vtkHyperTreeGridSuperCursor*, unsigned int );
473 
474  void TraverseDualMaskedLeaf( vtkHyperTreeGridSuperCursor* );
475 
476  void TraverseDualLeaf( vtkHyperTreeGridSuperCursor* );
477 
478  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
479 #endif
480 
481  // Used to advance the super cursor; One Entry per cursor node.
482  // Private.
484  {
485  // For the new node, start with the node in super cursor as parent.
486  unsigned char Parent;
487  // Traverse to this child.
488  unsigned char Child;
489  };
490 
491  // Generalizing for 27 tree. Cannot use 3 bits to encode the child to move to.
492  // Input: root in supercursor(3x3x3=27), child(3x3x3=27)
493  // Output: root, child
494  // It is easier to abstract dimensions when we use a single array.
495  vtkSuperCursorEntry SuperCursorTraversalTable[27*27];
496 
497  // for the GetCell method
501 
502  // I would like to get rid of this.
503  // Is it a part of the vtkDataSet API?
505  void BuildLinks();
506 
507  vtkIdType RecursiveFindPoint( double x[3],
508  vtkHyperTreeSimpleCursor* cursor,
509  double* origin, double* size);
510 
511 public:
512 
513  // A simplified hyper tree cursor, to be used by the hyper tree
514  // grid supercursor.
515  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
516  {
517  public:
519 
520  void Clear();
521  void Initialize( vtkHyperTreeGrid*, vtkIdType, int[3] );
522  void ToRoot();
523  void ToChild( int );
524  bool IsLeaf();
525  vtkHyperTree* GetTree() { return this->Tree; }
526  vtkIdType GetLeafIndex() { return this->Index; } // Only valid for leaves.
527  vtkIdType GetGlobalNodeIndex();
528  unsigned short GetLevel() { return this->Level; }
529 
530  private:
531  vtkHyperTree* Tree;
532  vtkIdType Index;
533  unsigned short Level;
534  bool Leaf;
535  };
536 
537  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeIterator
538  {
539  public:
541 
545  void Initialize( vtkHyperTreeGrid* );
546 
551  vtkHyperTree* GetNextTree( vtkIdType &index );
552 
557  vtkHyperTree* GetNextTree();
558 
559  protected:
560  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
562  };
563 
564  // Public structure filters use to move around the tree.
565  // The super cursor keeps neighbor cells so filters can
566  // easily access neighbor to leaves.
567  // The super cursor is 'const'. Methods in vtkHyperTreeGrid
568  // initialize and compute children for moving toward leaves.
570  {
571  double Origin[3];
572  double Size[3];
575  vtkHyperTreeSimpleCursor Cursors[3*3*3];
576 
578  {
579  return this->Cursors + this->MiddleCursorId + idx;
580  }
581  };
582 
583 private:
584  vtkHyperTreeGrid(const vtkHyperTreeGrid&) VTK_DELETE_FUNCTION;
585  void operator=(const vtkHyperTreeGrid&) VTK_DELETE_FUNCTION;
586 };
587 
588 #endif
virtual vtkIdType GetNumberOfCells()=0
Determine the number of cells composing the dataset.
static vtkDataObject * New()
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
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:287
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
void GetPoint(const int i, const int j, const int k, double pnt[3])
Objects that can traverse hypertree nodes.
cell represents a 1D line
Definition: vtkLine.h:35
abstract class to specify cell behavior
Definition: vtkCell.h:59
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:44
Key for double vector values.
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
list of point or cell ids
Definition: vtkIdList.h:36
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
represent and manipulate attribute data in a dataset
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:36
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:51
An object structured as a tree where each node has exactly either 2^n or 3^n children.
Definition: vtkHyperTree.h:134
vtkHyperTreeSimpleCursor * GetCursor(int idx)
vtkCellLinks * Links
general representation of visualization data
Definition: vtkDataObject.h:64
std::map< vtkIdType, vtkHyperTree * >::iterator Iterator
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.