Commit de9c7a8a authored by Philippe Pébay's avatar Philippe Pébay
Browse files

Implemented IJK/KJI indexing modes for hyper tree grid data set

Change-Id: Iba476de06c3c39ada4308a8960e10367296dede9
parent c3484110
......@@ -751,8 +751,11 @@ vtkIdType vtkHyperTreeGrid::FindPoint( double x[3] )
-- iz;
}
int index = ( iz * this->GridSize[1] + iy ) * this->GridSize[0] + ix;
vtkHyperTreeSimpleCursor cursor;
int index = ( this->IndexingMode ) ?
( ix * this->GridSize[1] + iy ) * this->GridSize[2] + iz :
( iz * this->GridSize[1] + iy ) * this->GridSize[0] + ix;
vtkHyperTreeSimpleCursor cursor;
vtkIdType offsets[3];
int pos[] = { 0, 0, 0 };
cursor.Initialize( this, offsets, index, pos );
......@@ -1138,52 +1141,85 @@ void vtkHyperTreeGrid::ComputeDualGrid()
double scale[] = { 1., 1., 1. };
// Check whether coordinate arrays match grid size
bool coords[3];
coords[0] = static_cast<int>( this->GridSize[0] ) + 1
== this->XCoordinates->GetNumberOfTuples() ? true : false;
coords[1] = static_cast<int>( this->GridSize[1] ) + 1
== this->YCoordinates->GetNumberOfTuples() ? true : false;
coords[2] = static_cast<int>( this->GridSize[2] ) + 1
== this->ZCoordinates->GetNumberOfTuples() ? true : false;
// If coordinates array are complete, compute all tree scales
if ( coords[0] && coords[1] && coords[2] )
if ( static_cast<int>( this->GridSize[0] ) + 1 == this->XCoordinates->GetNumberOfTuples()
&& static_cast<int>( this->GridSize[1] ) + 1 == this->YCoordinates->GetNumberOfTuples()
&& static_cast<int>( this->GridSize[2] ) + 1 == this->ZCoordinates->GetNumberOfTuples() )
{
// Iterate over all hyper trees
// Iterate over all hyper trees depending on indexing mode
vtkCollectionSimpleIterator it;
this->HyperTrees->InitTraversal( it );
for ( unsigned int k = 0; k < this->GridSize[2]; ++ k )
if ( this->IndexingMode )
{
// Compute scale along z-axis
scale[2] = this->ZCoordinates->GetTuple1( k + 1 ) -
this->ZCoordinates->GetTuple1( k );
for ( unsigned int j = 0; j < this->GridSize[1]; ++ j )
// I-J-K indexing
for ( unsigned int i = 0; i < this->GridSize[0]; ++ i )
{
// Compute scale along y-axis
scale[1] = this->YCoordinates->GetTuple1( j + 1 ) -
this->YCoordinates->GetTuple1( j );
// Compute scale along x-axis
scale[0] = this->XCoordinates->GetTuple1( i + 1 ) -
this->XCoordinates->GetTuple1( i );
for ( unsigned int i = 0; i < this->GridSize[0]; ++ i )
for ( unsigned int j = 0; j < this->GridSize[1]; ++ j )
{
// Compute scale along x-axis
scale[0] = this->XCoordinates->GetTuple1( i + 1 ) -
this->XCoordinates->GetTuple1( i );
// Compute scale along y-axis
scale[1] = this->YCoordinates->GetTuple1( j + 1 ) -
this->YCoordinates->GetTuple1( j );
for ( unsigned int k = 0; k < this->GridSize[2]; ++ k )
{
// Compute scale along z-axis
scale[2] = this->ZCoordinates->GetTuple1( k + 1 ) -
this->ZCoordinates->GetTuple1( k );
// Retrieve hyper tree and set its scale
vtkHyperTree* tree = GetNextHyperTreeMacro( it );
tree->SetScale( scale );
// Update hyper tree grid depth
unsigned int treeDepth = tree->GetNumberOfLevels();
if ( treeDepth > gridDepth )
{
gridDepth = treeDepth;
}
} // i
} // j
} // k
} // if ( this->IndexingMode )
else
{
// K-J-I indexing
for ( unsigned int k = 0; k < this->GridSize[2]; ++ k )
{
// Compute scale along z-axis
scale[2] = this->ZCoordinates->GetTuple1( k + 1 ) -
this->ZCoordinates->GetTuple1( k );
// Retrieve hyper tree and set its scale
vtkHyperTree* tree = GetNextHyperTreeMacro( it );
tree->SetScale( scale );
for ( unsigned int j = 0; j < this->GridSize[1]; ++ j )
{
// Compute scale along y-axis
scale[1] = this->YCoordinates->GetTuple1( j + 1 ) -
this->YCoordinates->GetTuple1( j );
// Update hyper tree grid depth
unsigned int treeDepth = tree->GetNumberOfLevels();
if ( treeDepth > gridDepth )
for ( unsigned int i = 0; i < this->GridSize[0]; ++ i )
{
gridDepth = treeDepth;
}
} // i
} // j
} // k
} // if ( coords[0] && coords[1] && coords[2] )q
// Compute scale along x-axis
scale[0] = this->XCoordinates->GetTuple1( i + 1 ) -
this->XCoordinates->GetTuple1( i );
// Retrieve hyper tree and set its scale
vtkHyperTree* tree = GetNextHyperTreeMacro( it );
tree->SetScale( scale );
// Update hyper tree grid depth
unsigned int treeDepth = tree->GetNumberOfLevels();
if ( treeDepth > gridDepth )
{
gridDepth = treeDepth;
}
} // i
} // j
} // k
} // else indexing mode
} // if coordinate cardinalities match
// Compute and store reduction factors for speed
double factor = 1.;
......@@ -1195,34 +1231,44 @@ void vtkHyperTreeGrid::ComputeDualGrid()
// Traverse hyper tree grid and generate dual
unsigned int index = 0;
for ( unsigned int k = 0; k < this->GridSize[2]; ++ k )
if ( this->IndexingMode )
{
// Compute scale along z-axis
scale[2] = this->ZCoordinates->GetTuple1( k + 1 ) -
this->ZCoordinates->GetTuple1( k );
for ( unsigned int j = 0; j < this->GridSize[1]; ++ j )
// I-J-K indexing
for ( unsigned int i = 0; i < this->GridSize[0]; ++ i )
{
// Compute scale along y-axis
scale[1] = this->YCoordinates->GetTuple1( j + 1 ) -
this->YCoordinates->GetTuple1( j );
for ( unsigned int i = 0; i < this->GridSize[0]; ++ i, ++ index )
for ( unsigned int j = 0; j < this->GridSize[1]; ++ j )
{
// Compute scale along x-axis
scale[0] = this->XCoordinates->GetTuple1( i + 1 ) -
this->XCoordinates->GetTuple1( i );
for ( unsigned int k = 0; k < this->GridSize[2]; ++ k, ++ index )
{
// Initialize super cursors
vtkHyperTreeGridSuperCursor superCursor;
this->InitializeSuperCursor( &superCursor, i, j, k, index );
// Initialize super cursors
vtkHyperTreeGridSuperCursor superCursor;
this->InitializeSuperCursor( &superCursor, i, j, k, index );
// Traverse and populate dual recursively
this->TraverseDualRecursively( &superCursor, 0 );
} // i
} // j
} // k
} // if ( this->IndexingMode )
else
{
// K-J-I indexing
for ( unsigned int k = 0; k < this->GridSize[2]; ++ k )
{
for ( unsigned int j = 0; j < this->GridSize[1]; ++ j )
{
for ( unsigned int i = 0; i < this->GridSize[0]; ++ i, ++ index )
{
// Initialize super cursors
vtkHyperTreeGridSuperCursor superCursor;
this->InitializeSuperCursor( &superCursor, i, j, k, index );
// Traverse and populate dual recursively
this->TraverseDualRecursively( &superCursor, 0 );
} // i
} // j
} // k
// Traverse and populate dual recursively
this->TraverseDualRecursively( &superCursor, 0 );
} // i
} // j
} // k
} // else indexing mode
// Adjust dual points as needed to fit the primal boundary
for ( unsigned int d = 0; d < this->Dimension; ++ d )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment