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 =========================================================================*/
41 #ifndef vtkHyperTreeGrid_h
42 #define vtkHyperTreeGrid_h
43 
44 #include "vtkCommonDataModelModule.h" // For export macro
45 #include "vtkDataSet.h"
46 #include <map> // STL header for dual point coordinates ajustment
47 
48 class vtkHyperTreeCursor;
49 class vtkHyperTree;
50 
51 class vtkBitArray;
52 class vtkCellLinks;
53 class vtkCollection;
54 class vtkDataArray;
56 class vtkIdTypeArray;
57 class vtkLine;
58 class vtkPixel;
59 class vtkPoints;
60 class vtkVoxel;
61 
62 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet
63 {
64 public:
65 
69 
70  static vtkInformationIntegerKey* LEVELS();
71  static vtkInformationIntegerKey* DIMENSION();
72  static vtkInformationDoubleVectorKey* SIZES();
73  static vtkHyperTreeGrid* New();
74 
75  vtkTypeMacro(vtkHyperTreeGrid, vtkDataSet);
76  void PrintSelf( ostream&, vtkIndent ) VTK_OVERRIDE;
77 
81  int GetDataObjectType() VTK_OVERRIDE;
82 
87  void CopyStructure( vtkDataSet* ) VTK_OVERRIDE;
88 
90 
93  void SetGridSize( unsigned int[3] );
94  void SetGridSize( unsigned int i, unsigned int j, unsigned int k );
95  vtkGetVector3Macro(GridSize, unsigned int);
97 
99 
102  void SetGridExtent(int extent[6]);
103  void SetGridExtent(int iMin, int iMax, int jMin, int jMax,
104  int kMin, int kMax);
106 
108 
112  vtkSetMacro(TransposedRootIndexing, bool);
113  vtkGetMacro(TransposedRootIndexing, bool);
114  void SetIndexingModeToKJI()
115  { this->SetTransposedRootIndexing( false ); }
117  { this->SetTransposedRootIndexing( true ); }
119 
121 
125  void SetBranchFactor( unsigned int );
126  vtkGetMacro(BranchFactor, unsigned int);
128 
130 
134  void SetDimension( unsigned int );
135  vtkGetMacro(Dimension, unsigned int);
137 
141  vtkIdType GetNumberOfCells() VTK_OVERRIDE;
142 
146  vtkIdType GetNumberOfPoints() VTK_OVERRIDE;
147 
151  vtkIdType GetNumberOfLeaves();
152 
156  vtkIdType GetNumberOfLevels( vtkIdType );
157 
161  vtkIdType GetNumberOfTrees();
162 
164 
167  void SetXCoordinates( vtkDataArray* );
168  vtkGetObjectMacro(XCoordinates, vtkDataArray);
170 
172 
175  void SetYCoordinates( vtkDataArray* );
176  vtkGetObjectMacro(YCoordinates, vtkDataArray);
178 
180 
183  void SetZCoordinates( vtkDataArray* );
184  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
186 
188 
191  void SetMaterialMask( vtkBitArray* );
192  vtkGetObjectMacro(MaterialMask, vtkBitArray);
194 
196 
199  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
200  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
202 
206  virtual void GenerateTrees();
207 
213  vtkHyperTreeCursor* NewCursor( vtkIdType );
214 
221  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
222 
229  double* GetPoint( vtkIdType ) VTK_OVERRIDE;
230 
239  void GetPoint( vtkIdType, double[3] ) VTK_OVERRIDE;
240 
247  using vtkDataSet::GetCell;
248  vtkCell* GetCell( vtkIdType ) VTK_OVERRIDE;
249 
259  void GetCell( vtkIdType, vtkGenericCell* ) VTK_OVERRIDE;
260 
267  int GetCellType( vtkIdType ) VTK_OVERRIDE;
268 
276  void GetCellPoints( vtkIdType, vtkIdList* ) VTK_OVERRIDE;
277 
282  virtual void GetCellPoints( vtkIdType, vtkIdType&, vtkIdType*& );
283 
291  void GetPointCells( vtkIdType, vtkIdList* ) VTK_OVERRIDE;
292 
303  void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* ) VTK_OVERRIDE;
304 
311  vtkIdType FindPoint( double x[3] ) VTK_OVERRIDE;
312 
326  vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
327  double tol2, int& subId, double pcoords[3],
328  double *weights ) VTK_OVERRIDE;
329 
337  vtkIdType FindCell( double x[3], vtkCell *cell,
338  vtkGenericCell *gencell, vtkIdType cellId,
339  double tol2, int& subId, double pcoords[3],
340  double *weights ) VTK_OVERRIDE;
341 
346  void Initialize() VTK_OVERRIDE;
347 
351  void InitializeTreeIterator( vtkHyperTreeIterator& );
352 
359  int GetMaxCellSize() VTK_OVERRIDE;
360 
362 
365  void ShallowCopy( vtkDataObject* ) VTK_OVERRIDE;
366  void DeepCopy( vtkDataObject* ) VTK_OVERRIDE;
368 
372  int GetExtentType() VTK_OVERRIDE { return VTK_3D_EXTENT; }
373 
382  unsigned long GetActualMemorySize() VTK_OVERRIDE;
383 
387  void GenerateSuperCursorTraversalTable();
388 
389 #ifndef __VTK_WRAP__
390 
391 
396  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
397  unsigned int,
398  unsigned int,
399  unsigned int,
400  vtkIdType );
401  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
402  vtkIdType );
404 
408  void InitializeSuperCursorChild( vtkHyperTreeGridSuperCursor* parent,
410  unsigned int childIdx );
411 #endif
412 
414 
417  vtkGetMacro(NumberOfChildren, unsigned int);
419 
423  void GetLevelZeroCoordsFromIndex( vtkIdType index,
424  unsigned int &i,
425  unsigned int &j,
426  unsigned int &k );
427 
428 protected:
429  // Constructor with default bounds (0,1, 0,1, 0,1).
431  ~vtkHyperTreeGrid() VTK_OVERRIDE;
432 
433  void ComputeBounds() VTK_OVERRIDE;
434 
435  void GetCell( vtkIdType, vtkCell* );
436 
437  void ComputeDualGrid();
438  vtkPoints* GetPoints();
439  vtkIdTypeArray* GetConnectivity();
440 
441  unsigned int Dimension; // 1, 2 or 3.
442  unsigned int GridSize[3];
443  int Extent[6];
444  unsigned int BranchFactor;
445  unsigned int NumberOfChildren;
447 
450 
454 
455  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
456 
459  std::map<vtkIdType, bool> PointShifted;
460  std::map<vtkIdType, double> PointShifts[3];
461  std::map<vtkIdType, double> ReductionFactors;
462 
463  void DeleteInternalArrays();
464  void DeleteTrees();
465 
466 #if !defined(__VTK_WRAP__) && !defined(__WRAP_GCCXML__)
467  void TraverseDualRecursively( vtkHyperTreeGridSuperCursor*, unsigned int );
468 
469  void TraverseDualMaskedLeaf( vtkHyperTreeGridSuperCursor* );
470 
471  void TraverseDualLeaf( vtkHyperTreeGridSuperCursor* );
472 
473  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
474 #endif
475 
476  // Used to advance the super cursor; One Entry per cursor node.
477  // Private.
479  {
480  // For the new node, start with the node in super cursor as parent.
481  unsigned char Parent;
482  // Traverse to this child.
483  unsigned char Child;
484  };
485 
486  // Generalizing for 27 tree. Cannot use 3 bits to encode the child to move to.
487  // Input: root in supercursor(3x3x3=27), child(3x3x3=27)
488  // Output: root, child
489  // It is easier to abstract dimensions when we use a single array.
490  vtkSuperCursorEntry SuperCursorTraversalTable[27*27];
491 
492  // for the GetCell method
496 
497  // I would like to get rid of this.
498  // Is it a part of the vtkDataSet API?
500  void BuildLinks();
501 
502  vtkIdType RecursiveFindPoint( double x[3],
503  vtkHyperTreeSimpleCursor* cursor,
504  double* origin, double* size);
505 
506 public:
507 
508  // A simplified hyper tree cursor, to be used by the hyper tree
509  // grid supercursor.
510  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeSimpleCursor
511  {
512  public:
514 
515  void Clear();
516  void Initialize( vtkHyperTreeGrid*, vtkIdType, int[3] );
517  void ToRoot();
518  void ToChild( int );
519  bool IsLeaf();
520  vtkHyperTree* GetTree() { return this->Tree; }
521  vtkIdType GetLeafIndex() { return this->Index; } // Only valid for leaves.
522  vtkIdType GetGlobalNodeIndex();
523  unsigned short GetLevel() { return this->Level; }
524 
525  private:
526  vtkHyperTree* Tree;
527  vtkIdType Index;
528  unsigned short Level;
529  bool Leaf;
530  };
531 
532  class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeIterator
533  {
534  public:
536 
540  void Initialize( vtkHyperTreeGrid* );
541 
546  vtkHyperTree* GetNextTree( vtkIdType &index );
547 
552  vtkHyperTree* GetNextTree();
553 
554  protected:
555  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
557  };
558 
559  // Public structure filters use to move around the tree.
560  // The super cursor keeps neighbor cells so filters can
561  // easily access neighbor to leaves.
562  // The super cursor is 'const'. Methods in vtkHyperTreeGrid
563  // initialize and compute children for moving toward leaves.
565  {
566  double Origin[3];
567  double Size[3];
570  vtkHyperTreeSimpleCursor Cursors[3*3*3];
571 
573  {
574  return this->Cursors + this->MiddleCursorId + idx;
575  }
576  };
577 
578 private:
579  vtkHyperTreeGrid(const vtkHyperTreeGrid&) VTK_DELETE_FUNCTION;
580  void operator=(const vtkHyperTreeGrid&) VTK_DELETE_FUNCTION;
581 };
582 
583 #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: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
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:29
abstract class to specify cell behavior
Definition: vtkCell.h:56
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:38
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: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
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:33
create and manipulate ordered lists of objects
Definition: vtkCollection.h:48
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: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
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: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.