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 =========================================================================*/
45 #ifndef __vtkHyperTreeGrid_h
46 #define __vtkHyperTreeGrid_h
47 
48 #include "vtkCommonDataModelModule.h" // For export macro
49 #include "vtkDataSet.h"
50 #include <map> // STL header for dual point coordinates ajustment
51 
52 class vtkHyperTreeCursor;
53 class vtkHyperTree;
54 
55 class vtkBitArray;
56 class vtkCellLinks;
57 class vtkCollection;
58 class vtkDataArray;
60 class vtkIdTypeArray;
61 class vtkLine;
62 class vtkPixel;
63 class vtkPoints;
64 class vtkVoxel;
65 
67 {
68 public:
69 //BTX
73 //ETX
74 
75  static vtkInformationIntegerKey* LEVELS();
76  static vtkInformationIntegerKey* DIMENSION();
77  static vtkInformationDoubleVectorKey* SIZES();
78  static vtkHyperTreeGrid* New();
79 
81  void PrintSelf( ostream&, vtkIndent );
82 
84  int GetDataObjectType();
85 
88  void CopyStructure( vtkDataSet* );
89 
91 
92  void SetGridSize( unsigned int[3] );
93  vtkGetVector3Macro(GridSize, unsigned int);
95 
97 
100  vtkSetMacro(TransposedRootIndexing, bool);
101  vtkGetMacro(TransposedRootIndexing, bool);
103  { this->SetTransposedRootIndexing( false ); }
105  { this->SetTransposedRootIndexing( true ); }
107 
109 
111  void SetBranchFactor( unsigned int );
112  vtkGetMacro(BranchFactor, unsigned int);
114 
116 
117  void SetDimension( unsigned int );
118  vtkGetMacro(Dimension, unsigned int);
120 
123 
126 
128  vtkIdType GetNumberOfLeaves();
129 
131  vtkIdType GetNumberOfLevels( vtkIdType );
132 
134  vtkIdType GetNumberOfTrees();
135 
137 
138  void SetXCoordinates( vtkDataArray* );
139  vtkGetObjectMacro(XCoordinates, vtkDataArray);
141 
143 
144  void SetYCoordinates( vtkDataArray* );
145  vtkGetObjectMacro(YCoordinates, vtkDataArray);
147 
149 
150  void SetZCoordinates( vtkDataArray* );
151  vtkGetObjectMacro(ZCoordinates, vtkDataArray);
153 
155 
156  void SetMaterialMask( vtkBitArray* );
157  vtkGetObjectMacro(MaterialMask, vtkBitArray);
159 
161 
162  virtual void SetMaterialMaskIndex( vtkIdTypeArray* );
163  vtkGetObjectMacro(MaterialMaskIndex, vtkIdTypeArray);
165 
167  virtual void GenerateTrees();
168 
171  vtkHyperTreeCursor* NewCursor( vtkIdType );
172 
176  void SubdivideLeaf( vtkHyperTreeCursor*, vtkIdType );
177 
182  virtual double* GetPoint( vtkIdType );
183 
189  virtual void GetPoint( vtkIdType, double[3] );
190 
195  virtual vtkCell* GetCell( vtkIdType );
196 
203  virtual void GetCell( vtkIdType, vtkGenericCell* );
204 
209  virtual int GetCellType( vtkIdType );
210 
216  virtual void GetCellPoints( vtkIdType, vtkIdList* );
217 
220  virtual void GetCellPoints( vtkIdType, vtkIdType&, vtkIdType*& );
221 
227  virtual void GetPointCells( vtkIdType, vtkIdList* );
228 
237  virtual void GetCellNeighbors( vtkIdType, vtkIdList*, vtkIdList* );
238 
242  virtual vtkIdType FindPoint( double x[3] );
243 
245 
255  virtual vtkIdType FindCell( double x[3], vtkCell *cell, vtkIdType cellId,
256  double tol2, int& subId, double pcoords[3],
257  double *weights );
259 
261 
266  virtual vtkIdType FindCell( double x[3], vtkCell *cell,
267  vtkGenericCell *gencell, vtkIdType cellId,
268  double tol2, int& subId, double pcoords[3],
269  double *weights );
271 
273  void Initialize();
274 
276  void InitializeTreeIterator( vtkHyperTreeIterator& );
277 
281  virtual int GetMaxCellSize();
282 
284 
285  void ShallowCopy( vtkDataObject* );
286  void DeepCopy( vtkDataObject* );
288 
294  unsigned long GetActualMemorySize();
295 
297  void GenerateSuperCursorTraversalTable();
298 
299 //BTX
300 #ifndef __WRAP__
301 
302 
305  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
306  unsigned int,
307  unsigned int,
308  unsigned int,
309  vtkIdType );
310  void InitializeSuperCursor( vtkHyperTreeGridSuperCursor*,
311  vtkIdType );
313 
314 
316  void InitializeSuperCursorChild( vtkHyperTreeGridSuperCursor* parent,
317  vtkHyperTreeGridSuperCursor* child,
318  unsigned int childIdx );
319 #endif
320 //ETX
322 
324 
325  vtkGetMacro(NumberOfChildren, unsigned int);
327 
329 
331  void GetLevelZeroCoordsFromIndex( vtkIdType index,
332  unsigned int &i,
333  unsigned int &j,
334  unsigned int &k );
336 
337 protected:
338  // Constructor with default bounds (0,1, 0,1, 0,1).
340  ~vtkHyperTreeGrid();
341 
342  void ComputeBounds();
343 
344  void GetCell( vtkIdType, vtkCell* );
345 
346  void ComputeDualGrid();
347  vtkPoints* GetPoints();
348  vtkIdTypeArray* GetConnectivity();
349 
350  unsigned int Dimension; // 1, 2 or 3.
351  unsigned int GridSize[3];
352  unsigned int BranchFactor;
353  unsigned int NumberOfChildren;
355 
358 
362 
363  std::map<vtkIdType, vtkHyperTree*> HyperTrees;
364 
367  std::map<vtkIdType, bool> PointShifted;
368  std::map<vtkIdType, double> PointShifts[3];
369  std::map<vtkIdType, double> ReductionFactors;
370 
371  void DeleteInternalArrays();
372  void DeleteTrees();
373 
374 //BTX
375 #ifndef __WRAP__
376  void TraverseDualRecursively( vtkHyperTreeGridSuperCursor*, unsigned int );
377 
378  void TraverseDualMaskedLeaf( vtkHyperTreeGridSuperCursor* );
379 
380  void TraverseDualLeaf( vtkHyperTreeGridSuperCursor* );
381 
382  void EvaluateDualCorner( vtkHyperTreeSimpleCursor* );
383 #endif
384 //ETX
385 
386  // Used to advance the super cursor; One Entry per cursor node.
387  // Private.
389  {
390  // For the new node, start with the node in super cursor as parent.
391  unsigned char Parent;
392  // Traverse to this child.
393  unsigned char Child;
394  };
395 
396  // Generalizing for 27 tree. Cannot use 3 bits to encode the child to move to.
397  // Input: root in supercursor(3x3x3=27), child(3x3x3=27)
398  // Output: root, child
399  // It is easier to abstract dimensions when we use a single array.
400  vtkSuperCursorEntry SuperCursorTraversalTable[27*27];
401 
402  // for the GetCell method
406 
407  // I would like to get rid of this.
408  // Is it a part of the vtkDataSet API?
410  void BuildLinks();
411 
412 //BTX
413  vtkIdType RecursiveFindPoint( double x[3],
414  vtkHyperTreeSimpleCursor* cursor,
415  double* origin, double* size);
416 //ETX
417 
418 public:
419 
420 //BTX
421  // A simplified hyper tree cursor, to be used by the hyper tree
422  // grid supercursor.
424  {
425  public:
427 
428  void Clear();
429  void Initialize( vtkHyperTreeGrid*, vtkIdType, int[3] );
430  void ToRoot();
431  void ToChild( int );
432  bool IsLeaf();
433  vtkHyperTree* GetTree() { return this->Tree; }
434  vtkIdType GetLeafIndex() { return this->Index; } // Only valid for leaves.
435  vtkIdType GetGlobalNodeIndex();
436  unsigned short GetLevel() { return this->Level; }
437 
438  private:
439  vtkHyperTree* Tree;
440  vtkIdType Index;
441  unsigned short Level;
442  bool Leaf;
443  };
444 
446  {
447  public:
449 
451  void Initialize( vtkHyperTreeGrid* );
452 
455  vtkHyperTree* GetNextTree( vtkIdType &index );
456 
459  vtkHyperTree* GetNextTree();
460 
461  protected:
462  std::map<vtkIdType, vtkHyperTree*>::iterator Iterator;
464  };
465 
466  // Public structure filters use to move around the tree.
467  // The super cursor keeps neighbor cells so filters can
468  // easily access neighbor to leaves.
469  // The super cursor is 'const'. Methods in vtkHyperTreeGrid
470  // initialize and compute children for moving toward leaves.
472  {
473  double Origin[3];
474  double Size[3];
477  vtkHyperTreeSimpleCursor Cursors[3*3*3];
478 
480  {
481  return this->Cursors + this->MiddleCursorId + idx;
482  }
483  };
484 //ETX
485 
486 private:
487  vtkHyperTreeGrid(const vtkHyperTreeGrid&); // Not implemented.
488  void operator=(const vtkHyperTreeGrid&); // Not implemented.
489 };
490 
491 #endif
GLsizeiptr size
Definition: vtkgl.h:11843
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
GLuint index
Definition: vtkgl.h:11983
unsigned int NumberOfChildren
virtual vtkIdType GetNumberOfPoints()=0
abstract class to specify dataset behavior
Definition: vtkDataSet.h:60
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
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:268
unsigned int BranchFactor
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
provides thread-safe access to cells
Objects that can traverse hypertree nodes.
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:58
void PrintSelf(ostream &os, vtkIndent indent)
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:43
Key for double vector values.
const GLbyte * weights
Definition: vtkgl.h:12766
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:53
#define vtkGetVector3Macro(name, type)
Definition: vtkSetGet.h:294
vtkDataArray * YCoordinates
int GetDataObjectType()
Definition: vtkDataSet.h:277
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
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
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:153
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:39
virtual int GetCellType(vtkIdType cellId)=0
void ShallowCopy(vtkDataObject *src)
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69