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
55class vtkHyperTree;
56
57class vtkBitArray;
58class vtkCellLinks;
59class vtkCollection;
60class vtkDataArray;
62class vtkIdTypeArray;
63class vtkLine;
64class vtkPixel;
65class vtkPoints;
66class vtkVoxel;
67
68class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataSet
69{
70public:
71
75
80
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
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
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__
396
402 unsigned int,
403 unsigned int,
404 unsigned int,
405 vtkIdType );
407 vtkIdType );
409
415 unsigned int childIdx );
416#endif
417
419
422 vtkGetMacro(NumberOfChildren, unsigned int);
424
429 unsigned int &i,
430 unsigned int &j,
431 unsigned int &k );
432
433protected:
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__)
473
475
477
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?
506
509 double* origin, double* size);
510
511public:
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();
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.
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
546
552
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];
576
578 {
579 return this->Cursors + this->MiddleCursorId + idx;
580 }
581 };
582
583private:
584 vtkHyperTreeGrid(const vtkHyperTreeGrid&) VTK_DELETE_FUNCTION;
585 void operator=(const vtkHyperTreeGrid&) VTK_DELETE_FUNCTION;
586};
587
588#endif
void GetPoint(const int i, const int j, const int k, double pnt[3])
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:37
abstract class to specify cell behavior
Definition: vtkCell.h:60
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:52
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
general representation of visualization data
Definition: vtkDataObject.h:65
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
provides thread-safe access to cells
Objects that can traverse hypertree nodes.
std::map< vtkIdType, vtkHyperTree * >::iterator Iterator
vtkHyperTree * GetNextTree(vtkIdType &index)
Get the next tree and set its index then increment the iterator.
void Initialize(vtkHyperTreeGrid *)
Initialize the iterator on the tree set of the given HyperTreeGrid.
vtkHyperTree * GetNextTree()
Get the next tree and set its index then increment the iterator.
void Initialize(vtkHyperTreeGrid *, vtkIdType, int[3])
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
void InitializeSuperCursorChild(vtkHyperTreeGridSuperCursor *parent, vtkHyperTreeGridSuperCursor *child, unsigned int childIdx)
Initialize a cursor to point to a child of an existing super cursor.
void GetLevelZeroCoordsFromIndex(vtkIdType index, unsigned int &i, unsigned int &j, unsigned int &k)
Convert a level 0 index to its ijk coordinates according the grid size.
void EvaluateDualCorner(vtkHyperTreeSimpleCursor *)
void PrintSelf(ostream &, vtkIndent) override
Methods invoked by print to print information about the object including superclasses.
vtkIdType GetNumberOfCells() override
Return the number of cells in the dual grid.
void TraverseDualMaskedLeaf(vtkHyperTreeGridSuperCursor *)
void SetDimension(unsigned int)
Set/Get the dimensionality of the grid NB: Can only be 1, 2 or 3.
void TraverseDualLeaf(vtkHyperTreeGridSuperCursor *)
unsigned long GetActualMemorySize() override
Return the actual size of the data in kibibytes (1024 bytes).
static vtkInformationIntegerKey * DIMENSION()
static vtkInformationIntegerKey * LEVELS()
void TraverseDualRecursively(vtkHyperTreeGridSuperCursor *, unsigned int)
~vtkHyperTreeGrid() override
static vtkHyperTreeGrid * New()
void InitializeSuperCursor(vtkHyperTreeGridSuperCursor *, unsigned int, unsigned int, unsigned int, vtkIdType)
Initialize a super cursor to point to one of the root trees in the grid.
void SetBranchFactor(unsigned int)
Set/Get the subdivision factor in the grid refinement scheme NB: Can only be 2 or 3.
void InitializeSuperCursor(vtkHyperTreeGridSuperCursor *, vtkIdType)
static vtkInformationDoubleVectorKey * SIZES()
vtkIdType RecursiveFindPoint(double x[3], vtkHyperTreeSimpleCursor *cursor, double *origin, double *size)
int GetDataObjectType() override
Return what type of dataset this is.
vtkCellLinks * Links
An object structured as a tree where each node has exactly either 2^n or 3^n children.
Definition: vtkHyperTree.h:135
list of point or cell ids
Definition: vtkIdList.h:37
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:40
Key for integer values in vtkInformation.
cell represents a 1D line
Definition: vtkLine.h:36
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:41
represent and manipulate 3D points
Definition: vtkPoints.h:40
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:45
@ extent
Definition: vtkX3D.h:345
@ size
Definition: vtkX3D.h:253
@ index
Definition: vtkX3D.h:246
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
vtkHyperTreeSimpleCursor * GetCursor(int idx)
#define VTK_3D_EXTENT
Definition: vtkDataObject.h:61
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
int vtkIdType
Definition: vtkType.h:287