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 =========================================================================*/
46 #ifndef vtkHyperTreeGrid_h
47 #define vtkHyperTreeGrid_h
48 
49 #include "vtkCommonDataModelModule.h" // For export macro
50 #include "vtkDataSet.h"
51 #include <map> // STL header for dual point coordinates ajustment
52 
53 class vtkHyperTreeCursor;
54 class vtkHyperTree;
55 
56 class vtkBitArray;
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 
68 {
69 public:
70 //BTX
74 //ETX
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 );
83 
85  int GetDataObjectType();
86 
89  void CopyStructure( vtkDataSet* );
90 
92 
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 
100  void SetGridExtent(int extent[6]);
101  void SetGridExtent(int iMin, int iMax, int jMin, int jMax,
102  int kMin, int kMax);
104 
106 
109  vtkSetMacro(TransposedRootIndexing, bool);
110  vtkGetMacro(TransposedRootIndexing, bool);
112  { this->SetTransposedRootIndexing( false ); }
114  { this->SetTransposedRootIndexing( true ); }
116 
118 
120  void SetBranchFactor( unsigned int );
121  vtkGetMacro(BranchFactor, unsigned int);
123 
125 
126  void SetDimension( unsigned int );
127  vtkGetMacro(Dimension, unsigned int);
129 
132 
135 
137  vtkIdType GetNumberOfLeaves();
138 
140  vtkIdType GetNumberOfLevels( vtkIdType );
141 
143  vtkIdType GetNumberOfTrees();
144 
146 
147  void SetXCoordinates( vtkDataArray* );
148  vtkGetObjectMacro(XCoordinates, vtkDataArray);
150 
152 
153  void SetYCoordinates( vtkDataArray* );
154  vtkGetObjectMacro(YCoordinates, vtkDataArray);
156 
158 
159  void SetZCoordinates( vtkDataArray* );
160  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
162 
164 
165  void SetMaterialMask( vtkBitArray* );
166  vtkGetObjectMacro(MaterialMask, vtkBitArray);
168 
170 
171  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
172  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
174 
176  virtual void GenerateTrees();
177 
180  vtkHyperTreeCursor* NewCursor( vtkIdType );
181 
185  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
186 
191  virtual double* GetPoint( vtkIdType );
192 
198  virtual void GetPoint( vtkIdType, double[3] );
199 
204  virtual vtkCell* GetCell( vtkIdType );
205 
212  virtual void GetCell( vtkIdType, vtkGenericCell* );
213 
218  virtual int GetCellType( vtkIdType );
219 
225  virtual void GetCellPoints( vtkIdType, vtkIdList* );
226 
229  virtual void GetCellPoints( vtkIdType, vtkIdType&, vtkIdType*& );
230 
236  virtual void GetPointCells( vtkIdType, vtkIdList* );
237 
246  virtual void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* );
247 
251  virtual vtkIdType FindPoint( double x[3] );
252 
254 
264  virtual vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
265  double tol2, int& subId, double pcoords[3],
266  double *weights );
268 
270 
275  virtual vtkIdType FindCell( double x[3], vtkCell *cell,
276  vtkGenericCell *gencell, vtkIdType cellId,
277  double tol2, int& subId, double pcoords[3],
278  double *weights );
280 
282  void Initialize();
283 
285  void InitializeTreeIterator( vtkHyperTreeIterator& );
286 
290  virtual int GetMaxCellSize();
291 
293 
294  void ShallowCopy( vtkDataObject* );
295  void DeepCopy( vtkDataObject* );
297 
299  int GetExtentType() { return VTK_3D_EXTENT; }
300 
306  unsigned long GetActualMemorySize();
307 
309  void GenerateSuperCursorTraversalTable();
310 
311 //BTX
312 #ifndef __WRAP__
313 
314 
317  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
318  unsigned int,
319  unsigned int,
320  unsigned int,
321  vtkIdType );
322  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
323  vtkIdType );
325 
326 
328  void InitializeSuperCursorChild( vtkHyperTreeGridSuperCursor* parent,
329  vtkHyperTreeGridSuperCursor* child,
330  unsigned int childIdx );
331 #endif
332 //ETX
334 
336 
337  vtkGetMacro(NumberOfChildren, unsigned int);
339 
341 
343  void GetLevelZeroCoordsFromIndex( vtkIdType index,
344  unsigned int &i,
345  unsigned int &j,
346  unsigned int &k );
348 
349 protected:
350  // Constructor with default bounds (0,1, 0,1, 0,1).
352  ~vtkHyperTreeGrid();
353 
354  void ComputeBounds();
355 
356  void GetCell( vtkIdType, vtkCell* );
357 
358  void ComputeDualGrid();
359  vtkPoints* GetPoints();
360  vtkIdTypeArray* GetConnectivity();
361 
362  unsigned int Dimension; // 1, 2 or 3.
363  unsigned int GridSize[3];
364  int Extent[6];
365  unsigned int BranchFactor;
366  unsigned int NumberOfChildren;
368 
371 
375 
376  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
377 
380  std::map<vtkIdType, bool> PointShifted;
381  std::map<vtkIdType, double> PointShifts[3];
382  std::map<vtkIdType, double> ReductionFactors;
383 
384  void DeleteInternalArrays();
385  void DeleteTrees();
386 
387 //BTX
388 #if !defined(__WRAP__) && !defined(__WRAP_GCCXML__)
389  void TraverseDualRecursively( vtkHyperTreeGridSuperCursor*, unsigned int );
390 
391  void TraverseDualMaskedLeaf( vtkHyperTreeGridSuperCursor* );
392 
393  void TraverseDualLeaf( vtkHyperTreeGridSuperCursor* );
394 
395  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
396 #endif
397 //ETX
398 
399  // Used to advance the super cursor; One Entry per cursor node.
400  // Private.
402  {
403  // For the new node, start with the node in super cursor as parent.
404  unsigned char Parent;
405  // Traverse to this child.
406  unsigned char Child;
407  };
408 
409  // Generalizing for 27 tree. Cannot use 3 bits to encode the child to move to.
410  // Input: root in supercursor(3x3x3=27), child(3x3x3=27)
411  // Output: root, child
412  // It is easier to abstract dimensions when we use a single array.
413  vtkSuperCursorEntry SuperCursorTraversalTable[27*27];
414 
415  // for the GetCell method
419 
420  // I would like to get rid of this.
421  // Is it a part of the vtkDataSet API?
423  void BuildLinks();
424 
425 //BTX
426  vtkIdType RecursiveFindPoint( double x[3],
427  vtkHyperTreeSimpleCursor* cursor,
428  double* origin, double* size);
429 //ETX
430 
431 public:
432 
433 //BTX
434  // A simplified hyper tree cursor, to be used by the hyper tree
435  // grid supercursor.
437  {
438  public:
440 
441  void Clear();
442  void Initialize( vtkHyperTreeGrid*, vtkIdType, int[3] );
443  void ToRoot();
444  void ToChild( int );
445  bool IsLeaf();
446  vtkHyperTree* GetTree() { return this->Tree; }
447  vtkIdType GetLeafIndex() { return this->Index; } // Only valid for leaves.
448  vtkIdType GetGlobalNodeIndex();
449  unsigned short GetLevel() { return this->Level; }
450 
451  private:
452  vtkHyperTree* Tree;
453  vtkIdType Index;
454  unsigned short Level;
455  bool Leaf;
456  };
457 
459  {
460  public:
462 
464  void Initialize( vtkHyperTreeGrid* );
465 
468  vtkHyperTree* GetNextTree( vtkIdType &index );
469 
472  vtkHyperTree* GetNextTree();
473 
474  protected:
475  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
477  };
478 
479  // Public structure filters use to move around the tree.
480  // The super cursor keeps neighbor cells so filters can
481  // easily access neighbor to leaves.
482  // The super cursor is 'const'. Methods in vtkHyperTreeGrid
483  // initialize and compute children for moving toward leaves.
485  {
486  double Origin[3];
487  double Size[3];
490  vtkHyperTreeSimpleCursor Cursors[3*3*3];
491 
493  {
494  return this->Cursors + this->MiddleCursorId + idx;
495  }
496  };
497 //ETX
498 
499 private:
500  vtkHyperTreeGrid(const vtkHyperTreeGrid&); // Not implemented.
501  void operator=(const vtkHyperTreeGrid&); // Not implemented.
502 };
503 
504 #endif
std::map< vtkIdType, vtkHyperTree * > HyperTrees
virtual vtkIdType GetNumberOfCells()=0
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
unsigned long GetActualMemorySize()
static vtkDataObject * New()
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
unsigned int NumberOfChildren
virtual vtkIdType GetNumberOfPoints()=0
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
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:39
vtkDataArray * ZCoordinates
virtual void ComputeBounds()
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:275
unsigned int BranchFactor
provides thread-safe access to cells
Objects that can traverse hypertree nodes.
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:61
void PrintSelf(ostream &os, vtkIndent indent)
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:43
Key for double vector values.
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual int GetMaxCellSize()=0
list of point or cell ids
Definition: vtkIdList.h:35
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkDataArray * YCoordinates
int GetDataObjectType()
Definition: vtkDataSet.h:278
vtkIdTypeArray * Connectivity
std::map< vtkIdType, bool > PointShifted
represent and manipulate attribute data in a dataset
vtkIdTypeArray * MaterialMaskIndex
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
unsigned int Dimension
void DeepCopy(vtkDataObject *src)
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:35
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:52
An object structured as a tree where each node has exactly either 2^n or 3^n children.
Definition: vtkHyperTree.h:133
vtkHyperTreeSimpleCursor * GetCursor(int idx)
void Initialize()
virtual void CopyStructure(vtkDataSet *ds)=0
virtual double * GetPoint(vtkIdType ptId)=0
std::map< vtkIdType, double > ReductionFactors
vtkCellLinks * Links
vtkBitArray * MaterialMask
general representation of visualization data
Definition: vtkDataObject.h:64
vtkIdType FindPoint(double x, double y, double z)
Definition: vtkDataSet.h:154
std::map< vtkIdType, vtkHyperTree * >::iterator Iterator
vtkDataArray * XCoordinates
#define VTKCOMMONDATAMODEL_EXPORT
virtual vtkCell * GetCell(vtkIdType cellId)=0
represent and manipulate 3D points
Definition: vtkPoints.h:38
virtual int GetCellType(vtkIdType cellId)=0
void ShallowCopy(vtkDataObject *src)