An update will be applied January 25th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit 9ee5fe8d authored by Joachim Pouderoux's avatar Joachim Pouderoux
Browse files

Add depth and coordinates on each non leaf points.

Change-Id: Ib73de685956f4ef4d2b9dfb9ce8e4561ae9df945
parent 34d55b7f
......@@ -1304,39 +1304,21 @@ void vtkHyperTreeGrid::TraverseDualRecursively( vtkHyperTreeGridSuperCursor* sup
{
// Get cursor at super cursor center
vtkHyperTreeSimpleCursor* cursor0 = superCursor->GetCursor( 0 );
//if ( !cursor0->IsLeaf() )
// {
// // Initialize dual point coordinates and D-face adjustment flag
// double pt[3] = { 0., 0., 0. };
// for ( unsigned int d = 0; d < this->Dimension; ++ d )
// {
// double s = superCursor->Size[d] / 2.;
// pt[d] = superCursor->Origin[d] + s;
// }
// // Retrieve global index of center cursor
// int idx = cursor0->GetOffset();
// int lf = cursor0->GetGlobalLeafIndex();
// int id0 = level > 0 ? ((level == 1 && cursor0->GetLeafIndex() == 2 ) ? lf -1 : lf ) : idx;
// //cout << "node " << idx << " : " << lf << " detected at " << id0 << endl;
// //this->Points->SetPoint( id0, pt );
// }
if ( cursor0->IsLeaf() )
// Retrieve global index of center cursor
vtkIdType id0 = cursor0->GetGlobalLeafIndex();
if ( !cursor0->IsLeaf() )
{
// Center is a leaf, create a dual point
// Retrieve global index of center cursor
vtkIdType id0 = cursor0->GetGlobalLeafIndex();
if ( this->GetMaterialMask()->GetTuple1( id0 ) )
{
this->TraverseDualMaskedLeaf( superCursor );
}
else
// Initialize non leaf point coordinate
double pt[3] = { 0., 0., 0. };
for ( unsigned int d = 0; d < this->Dimension; ++ d )
{
this->TraverseDualLeaf( superCursor );
pt[d] = superCursor->Origin[d] + superCursor->Size[d] / 2.;
}
}
else
{
// Retrieve global index of center cursor
this->Points->SetPoint( id0 - 1, pt );
// If cursor 0 is not at leaf, recurse to all children
for ( unsigned int child = 0; child < this->NumberOfChildren; ++ child )
{
......@@ -1345,6 +1327,18 @@ void vtkHyperTreeGrid::TraverseDualRecursively( vtkHyperTreeGridSuperCursor* sup
this->TraverseDualRecursively( &newSuperCursor, level + 1 );
}
}
else
{
// Center is a leaf, create a dual point
if ( this->GetMaterialMask()->GetTuple1( id0 ) )
{
this->TraverseDualMaskedLeaf( superCursor );
}
else
{
this->TraverseDualLeaf( superCursor );
}
}
}
//-----------------------------------------------------------------------------
......
......@@ -30,7 +30,8 @@
// vtkHyperTree vtkRectilinearGrid
//
// .SECTION Thanks
// This class was written by Philippe Pebay and Charles Law, Kitware 2013
// This class was written by Philippe Pebay, Joachim Pouderoux and Charles Law,
// Kitware 2013
// This work was supported in part by Commissariat a l'Energie Atomique (CEA/DIF)
#ifndef __vtkHyperTreeGrid_h
......@@ -337,7 +338,8 @@ public:
// Description:
// Convert a level 0 index to its ijk coordinates according the grid size.
void GetLevelZeroCoordsFromIndex( vtkIdType index, vtkIdType &i, vtkIdType &j, vtkIdType &k );
void GetLevelZeroCoordsFromIndex( vtkIdType index,
vtkIdType &i, vtkIdType &j, vtkIdType &k );
protected:
// Constructor with default bounds (0,1, 0,1, 0,1).
......@@ -445,7 +447,8 @@ public:
vtkHyperTree* GetTree() { return this->Tree; }
vtkIdType GetLeafIndex() { return this->Index; } // Only valid for leaves.
vtkIdType GetGlobalLeafIndex() { return ( this->Offset >= 0 ) ? this->Offset + this->Index : -1; }
vtkIdType GetGlobalLeafIndex() { return ( this->Offset >= 0 ) ?
this->Offset + this->Index : -1; }
vtkIdType GetOffset() { return this->Offset; }
unsigned short GetLevel() { return this->Level; }
......
......@@ -114,8 +114,8 @@ int TestHyperTreeGridTernary2DFullMaterialBits( int argc, char* argv[] )
int sx = 10;
int sy = 10;
int sz = 1;
int depth = 3;
int branch = 2;
int depth = 2;
int branch = 3;
vtkNew<vtkTimerLog> timer;
......@@ -153,15 +153,14 @@ int TestHyperTreeGridTernary2DFullMaterialBits( int argc, char* argv[] )
vtkIdType nbCells = htGrid->GetOutput()->GetNumberOfCells();
timer->StopTimer();
cout << "#cells " << nbCells << endl;
//vtkDataArray* depthArray = htGrid->GetOutput()->GetPointData()->GetArray( "Depth" );
/*vtkDataArray* depthArray = htGrid->GetOutput()->GetPointData()->GetArray( "Depth" );
for ( int i = 0; i < htGrid->GetOutput()->GetNumberOfPoints(); i++ )
{
double x[3];
htGrid->GetOutput()->GetPoint( i, x );
//cout << "pt " << i << " : " << x[0] << ", " << x[1] << " : " << depthArray->GetTuple1( i ) << endl;
}
//depthArray->SetTuple1(25,4);
cout << "pt " << i << " : " << x[0] << ", " << x[1] << " : " << depthArray->GetTuple1( i ) << endl;
}*/
// Geometry
cout << "Constructing geometry..." << endl;
......
......@@ -884,6 +884,12 @@ void vtkHyperTreeGridSource::SubdivideFromBitsDescriptor( vtkHyperTreeCursor* cu
// Subdivide hyper tree grid leaf
this->Output->SubdivideLeaf( cursor, treeIdx );
// We are at a non-leaf cell, calculate its global index
vtkIdType id = cellIdOffset + childIdx + ( level == 0 ? 0 : 1 );
// Cell value: depth level
depthArray->InsertTuple1( id, level );
// Now traverse to children
int xDim = ( this->Dimension >= 1 ) ? this->BranchFactor : 1;
int yDim = ( this->Dimension >= 2 ) ? this->BranchFactor : 1;
......
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