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  using vtkDataSet::GetCell;
254  vtkCell* GetCell( vtkIdType ) VTK_OVERRIDE;
255 
265  void GetCell( vtkIdType, vtkGenericCell* ) VTK_OVERRIDE;
266 
273  int GetCellType( vtkIdType ) VTK_OVERRIDE;
274 
282  void GetCellPoints( vtkIdType, vtkIdList* ) VTK_OVERRIDE;
283 
288  virtual void GetCellPoints( vtkIdType, vtkIdType&, vtkIdType*& );
289 
297  void GetPointCells( vtkIdType, vtkIdList* ) VTK_OVERRIDE;
298 
309  void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) VTK_OVERRIDE;
310 
317  vtkIdType FindPoint( double x[3] ) VTK_OVERRIDE;
318 
332  vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
333  double tol2, int& subId, double pcoords[3],
334  double *weights ) VTK_OVERRIDE;
335 
343  vtkIdType FindCell( double x[3], vtkCell *cell,
344  vtkGenericCell *gencell, vtkIdType cellId,
345  double tol2, int& subId, double pcoords[3],
346  double *weights ) VTK_OVERRIDE;
347 
352  void Initialize() VTK_OVERRIDE;
353 
357  void InitializeTreeIterator( vtkHyperTreeIterator& );
358 
365  int GetMaxCellSize() VTK_OVERRIDE;
366 
368 
371  void ShallowCopy( vtkDataObject* ) VTK_OVERRIDE;
372  void DeepCopy( vtkDataObject* ) VTK_OVERRIDE;
374 
378  int GetExtentType() VTK_OVERRIDE { return VTK_3D_EXTENT; }
379 
388  unsigned long GetActualMemorySize() VTK_OVERRIDE;
389 
393  void GenerateSuperCursorTraversalTable();
394 
395 #ifndef __VTK_WRAP__
396 
397 
402  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
403  unsigned int,
404  unsigned int,
405  unsigned int,
406  vtkIdType );
407  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
408  vtkIdType );
410 
414  void InitializeSuperCursorChild( vtkHyperTreeGridSuperCursor* parent,
416  unsigned int childIdx );
417 #endif
418 
420 
423  vtkGetMacro(NumberOfChildren, unsigned int);
425 
429  void GetLevelZeroCoordsFromIndex( vtkIdType index,
430  unsigned int &i,
431  unsigned int &j,
432  unsigned int &k );
433 
434 protected:
435  // Constructor with default bounds (0,1, 0,1, 0,1).
437  ~vtkHyperTreeGrid() VTK_OVERRIDE;
438 
439  void ComputeBounds() VTK_OVERRIDE;
440 
441  void GetCell( vtkIdType, vtkCell* );
442 
443  void ComputeDualGrid();
444  vtkPoints* GetPoints();
445  vtkIdTypeArray* GetConnectivity();
446 
447  unsigned int Dimension; // 1, 2 or 3.
448  unsigned int GridSize[3];
449  int Extent[6];
450  unsigned int BranchFactor;
451  unsigned int NumberOfChildren;
453 
456 
460 
461  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
462 
465  std::map<vtkIdType, bool> PointShifted;
466  std::map<vtkIdType, double> PointShifts[3];
467  std::map<vtkIdType, double> ReductionFactors;
468 
469  void DeleteInternalArrays();
470  void DeleteTrees();
471 
472 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__)
473  void TraverseDualRecursively( vtkHyperTreeGridSuperCursor*, unsigned int );
474 
475  void TraverseDualMaskedLeaf( vtkHyperTreeGridSuperCursor* );
476 
477  void TraverseDualLeaf( vtkHyperTreeGridSuperCursor* );
478 
479  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
480 #endif
481 
482  // Used to advance the super cursor; One Entry per cursor node.
483  // Private.
485  {
486  // For the new node, start with the node in super cursor as parent.
487  unsigned char Parent;
488  // Traverse to this child.
489  unsigned char Child;
490  };
491 
492  // Generalizing for 27 tree. Cannot use 3 bits to encode the child to move to.
493  // Input: root in supercursor(3x3x3=27), child(3x3x3=27)
494  // Output: root, child
495  // It is easier to abstract dimensions when we use a single array.
496  vtkSuperCursorEntry SuperCursorTraversalTable[27*27];
497 
498  // for the GetCell method
502 
503  // I would like to get rid of this.
504  // Is it a part of the vtkDataSet API?
506  void BuildLinks();
507 
508  vtkIdType RecursiveFindPoint( double x[3],
509  vtkHyperTreeSimpleCursor* cursor,
510  double* origin, double* size);
511 
512 public:
513 
514  // A simplified hyper tree cursor, to be used by the hyper tree
515  // grid supercursor.
516  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
517  {
518  public:
520 
521  void Clear();
522  void Initialize( vtkHyperTreeGrid*, vtkIdType, int[3] );
523  void ToRoot();
524  void ToChild( int );
525  bool IsLeaf();
526  vtkHyperTree* GetTree() { return this->Tree; }
527  vtkIdType GetLeafIndex() { return this->Index; } // Only valid for leaves.
528  vtkIdType GetGlobalNodeIndex();
529  unsigned short GetLevel() { return this->Level; }
530 
531  private:
532  vtkHyperTree* Tree;
533  vtkIdType Index;
534  unsigned short Level;
535  bool Leaf;
536  };
537 
538  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeIterator
539  {
540  public:
542 
546  void Initialize( vtkHyperTreeGrid* );
547 
552  vtkHyperTree* GetNextTree( vtkIdType &index );
553 
558  vtkHyperTree* GetNextTree();
559 
560  protected:
561  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
563  };
564 
565  // Public structure filters use to move around the tree.
566  // The super cursor keeps neighbor cells so filters can
567  // easily access neighbor to leaves.
568  // The super cursor is 'const'. Methods in vtkHyperTreeGrid
569  // initialize and compute children for moving toward leaves.
571  {
572  double Origin[3];
573  double Size[3];
576  vtkHyperTreeSimpleCursor Cursors[3*3*3];
577 
579  {
580  return this->Cursors + this->MiddleCursorId + idx;
581  }
582  };
583 
584 private:
585  vtkHyperTreeGrid(const vtkHyperTreeGrid&) VTK_DELETE_FUNCTION;
586  void operator=(const vtkHyperTreeGrid&) VTK_DELETE_FUNCTION;
587 };
588 
589 #endif
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.
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
virtual void ComputeBounds()
Compute the data bounding box from data points.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
unsigned int BranchFactor
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
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
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
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void Initialize() override
Restore data object to initial state.
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:36
create and manipulate ordered 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)
void ShallowCopy(vtkDataObject *src) override
Shallow and Deep copy.
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
std::map< vtkIdType, double > ReductionFactors
vtkCellLinks * Links
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
std::map< vtkIdType, vtkHyperTree * >::iterator Iterator
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.