Commit 142baf23 authored by George Zagaris's avatar George Zagaris
Browse files

BUGFIX: Added box spacing to metadata

parent d4ce0dfd
......@@ -198,85 +198,85 @@ int TestAMRBox(int , char *[])
}
}
// Intersect.
{
vtkAMRBox A(-4,-4,-4,4,4,4);
vtkAMRBox B(-4,-4,-4,-1,-1,-1);
vtkAMRBox C(1,1,1,4,4,4);
vtkAMRBox AA(A);
AA&=A; // ==A
vtkAMRBox AB(A);
AB&=B; // ==B
vtkAMRBox BA(B);
BA&=A; // ==B
vtkAMRBox AC(A);
AC&=C; // ==C
vtkAMRBox CA(C);
CA&=A; // ==C
vtkAMRBox BC(B);
BC&=C; // ==NULL
vtkAMRBox CB(C);
CB&=B; // ==NULL
vtkAMRBox D(-4,-4,4,4);
vtkAMRBox E(-4,-4,-1,-1);
vtkAMRBox F(1,1,4,4);
vtkAMRBox DD(D);
DD&=D; // ==D
vtkAMRBox DE(D);
DE&=E; // ==E
vtkAMRBox ED(E);
ED&=D; // ==E
vtkAMRBox DF(D);
DF&=F; // ==F
vtkAMRBox FD(F);
FD&=D; // ==F
vtkAMRBox EF(E);
EF&=F; // ==NULL
vtkAMRBox FE(F);
FE&=E; // ==NULL
vtkAMRBox AD(A);
AD&=D; // ==NULL
vtkAMRBox DA(D);
DA&=A; // ==NULL
if (!(AA==A)
|| !(AB==B) || !(BA==AB)
|| !(AC==C) || !(AC==CA)
|| !BC.Empty() || !CB.Empty()
|| !(DD==D)
|| !(DE==E) || !(DE==ED)
|| !(DF==F) || !(DF==FD)
|| !EF.Empty() || !FE.Empty()
|| !(AD==A)
|| !(DA==D))
{
A.Print(cerr) << endl;
B.Print(cerr) << endl;
C.Print(cerr) << endl;
AA.Print(cerr) << endl;
AB.Print(cerr) << endl;
BA.Print(cerr) << endl;
AC.Print(cerr) << endl;
CA.Print(cerr) << endl;
BC.Print(cerr) << endl;
CB.Print(cerr) << endl;
D.Print(cerr) << endl;
E.Print(cerr) << endl;
F.Print(cerr) << endl;
DD.Print(cerr) << endl;
DE.Print(cerr) << endl;
ED.Print(cerr) << endl;
DF.Print(cerr) << endl;
FD.Print(cerr) << endl;
FE.Print(cerr) << endl;
EF.Print(cerr) << endl;
AD.Print(cerr) << endl;
DA.Print(cerr) << endl;
cerr << "Failed testing operator&=." << endl;
return 1;
}
}
// {
// vtkAMRBox A(-4,-4,-4,4,4,4);
// vtkAMRBox B(-4,-4,-4,-1,-1,-1);
// vtkAMRBox C(1,1,1,4,4,4);
// vtkAMRBox AA(A);
// AA&=A; // ==A
// vtkAMRBox AB(A);
// AB&=B; // ==B
// vtkAMRBox BA(B);
// BA&=A; // ==B
// vtkAMRBox AC(A);
// AC&=C; // ==C
// vtkAMRBox CA(C);
// CA&=A; // ==C
// vtkAMRBox BC(B);
// BC&=C; // ==NULL
// vtkAMRBox CB(C);
// CB&=B; // ==NULL
//
// vtkAMRBox D(-4,-4,4,4);
// vtkAMRBox E(-4,-4,-1,-1);
// vtkAMRBox F(1,1,4,4);
// vtkAMRBox DD(D);
// DD&=D; // ==D
// vtkAMRBox DE(D);
// DE&=E; // ==E
// vtkAMRBox ED(E);
// ED&=D; // ==E
// vtkAMRBox DF(D);
// DF&=F; // ==F
// vtkAMRBox FD(F);
// FD&=D; // ==F
// vtkAMRBox EF(E);
// EF&=F; // ==NULL
// vtkAMRBox FE(F);
// FE&=E; // ==NULL
//
// vtkAMRBox AD(A);
// AD&=D; // ==NULL
// vtkAMRBox DA(D);
// DA&=A; // ==NULL
//
// if (!(AA==A)
// || !(AB==B) || !(BA==AB)
// || !(AC==C) || !(AC==CA)
// || !BC.Empty() || !CB.Empty()
// || !(DD==D)
// || !(DE==E) || !(DE==ED)
// || !(DF==F) || !(DF==FD)
// || !EF.Empty() || !FE.Empty()
// || !(AD==A)
// || !(DA==D))
// {
// A.Print(cerr) << endl;
// B.Print(cerr) << endl;
// C.Print(cerr) << endl;
// AA.Print(cerr) << endl;
// AB.Print(cerr) << endl;
// BA.Print(cerr) << endl;
// AC.Print(cerr) << endl;
// CA.Print(cerr) << endl;
// BC.Print(cerr) << endl;
// CB.Print(cerr) << endl;
// D.Print(cerr) << endl;
// E.Print(cerr) << endl;
// F.Print(cerr) << endl;
// DD.Print(cerr) << endl;
// DE.Print(cerr) << endl;
// ED.Print(cerr) << endl;
// DF.Print(cerr) << endl;
// FD.Print(cerr) << endl;
// FE.Print(cerr) << endl;
// EF.Print(cerr) << endl;
// AD.Print(cerr) << endl;
// DA.Print(cerr) << endl;
// cerr << "Failed testing operator&=." << endl;
// return 1;
// }
// }
// Serialize/Deserialize
{
vtkAMRBox A( 0,0,0, 9,9,9 );
......
......@@ -166,6 +166,7 @@ vtkAMRBox::vtkAMRBox(
{
// Sanity Check!
vtkAssertUtils::assertInRange( dim, 2, 3, __FILE__, __LINE__ );
vtkAssertUtils::assertTrue( (level>=0), __FILE__, __LINE__ );
this->Dimension = dim;
......@@ -305,7 +306,7 @@ vtkAMRBox &vtkAMRBox::operator=(const vtkAMRBox &other)
other.GetDimensions(lo,hi);
this->SetDimensions(lo,hi);
this->SetGridSpacing(other.GetGridSpacing());
this->SetDataSetOrigin(other.GetDataSetOrigin());
this->SetDataSetOrigin( other.GetDataSetOrigin() );
this->ProcessId = other.ProcessId;
this->BlockId = other.BlockId;
this->BlockLevel = other.BlockLevel;
......@@ -515,6 +516,8 @@ void vtkAMRBox::GetBoxOrigin(double *x0) const
x0[0] = this->X0[0];
x0[1] = this->X0[1];
x0[2] = this->X0[2];
// TODO: ?
// x0[0]=this->X0[0]+this->DX[0]*this->LoCorner[0];
// if (this->Dimension>=2)
// {
......@@ -812,37 +815,37 @@ bool vtkAMRBox::operator==(const vtkAMRBox &other)
}
//-----------------------------------------------------------------------------
void vtkAMRBox::operator&=(const vtkAMRBox &other)
{
if (this->Dimension!=other.Dimension)
{
vtkGenericWarningMacro(
"Can't operate on a " << this->Dimension
<< "D box with a " << other.Dimension << "D box.");
return;
}
if (this->Empty())
{
return;
}
if (other.Empty())
{
this->Invalidate();
return;
}
int otherLo[3];
int otherHi[3];
other.GetDimensions(otherLo,otherHi);
int lo[3];
int hi[3];
for (int q=0; q<this->Dimension; ++q)
{
lo[q]=(this->LoCorner[q]>otherLo[q] ? this->LoCorner[q] : otherLo[q]);
hi[q]=(this->HiCorner[q]<otherHi[q] ? this->HiCorner[q] : otherHi[q]);
}
this->SetDimensions(lo,hi);
}
//void vtkAMRBox::operator&=(const vtkAMRBox &other)
//{
// if (this->Dimension!=other.Dimension)
// {
// vtkGenericWarningMacro(
// "Can't operate on a " << this->Dimension
// << "D box with a " << other.Dimension << "D box.");
// return;
// }
// if (this->Empty())
// {
// return;
// }
// if (other.Empty())
// {
// this->Invalidate();
// return;
// }
//
// int otherLo[3];
// int otherHi[3];
// other.GetDimensions(otherLo,otherHi);
// int lo[3];
// int hi[3];
// for (int q=0; q<this->Dimension; ++q)
// {
// lo[q]=(this->LoCorner[q]>otherLo[q] ? this->LoCorner[q] : otherLo[q]);
// hi[q]=(this->HiCorner[q]<otherHi[q] ? this->HiCorner[q] : otherHi[q]);
// }
// this->SetDimensions(lo,hi);
//}
//-----------------------------------------------------------------------------
bool vtkAMRBox::Contains(int i,int j,int k) const
......@@ -1386,10 +1389,11 @@ void vtkAMRBox::WriteBox(
std::ofstream ofs;
ofs.open( oss.str().c_str( ) );
vtkAssertUtils::assertTrue( ofs.is_open(), __FILE__, __LINE__ );
ofs << "# vtk DataFile Version 3.0\n";
ofs << oss.str( ) << std::endl;
ofs << "ASCII\n";
ofs << "DATA_SET_UNSTUCTURED_GRID\n";
ofs << "DATASET UNSTRUCTURED_GRID\n";
ofs << "POINTS 8 double\n";
ofs << x << " " << y << " " << z << std::endl;
ofs << X << " " << y << " " << z << std::endl;
......@@ -1403,6 +1407,7 @@ void vtkAMRBox::WriteBox(
ofs << "8 0 1 2 3 4 5 6 7\n";
ofs << "CELL_TYPES 1\n";
ofs << "12\n";
ofs.close( );
}
......
......@@ -223,7 +223,7 @@ public:
// Description:
// Intersect this box with another box in place.
void operator&=(const vtkAMRBox &rhs);
//void operator&=(const vtkAMRBox &rhs);
// Description:
// Test to see if a given cell index is inside this box.
......
......@@ -41,6 +41,8 @@ vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,REFINEMENT_RATIO,Integer);
vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,BOX_DIMENSIONALITY,Integer);
vtkInformationKeyRestrictedMacro(
vtkHierarchicalBoxDataSet,BOX_ORIGIN,DoubleVector, 3);
vtkInformationKeyRestrictedMacro(
vtkHierarchicalBoxDataSet,SPACING,DoubleVector, 3);
vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,RANK,Integer);
vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,BLOCK_ID,Integer);
vtkInformationKeyRestrictedMacro(
......@@ -143,7 +145,13 @@ void vtkHierarchicalBoxDataSet::SetDataSet(
this->Superclass::GetChild(level));
if (levelDS)
{
levelDS->SetPiece(id, dataSet);
// If this dataSet != NULL, i.e., it is owned by this process
if( dataSet != NULL )
{
levelDS->SetPiece(id, dataSet);
}
vtkInformation* info = levelDS->GetMetaData(id);
if (info)
{
......@@ -158,6 +166,10 @@ void vtkHierarchicalBoxDataSet::SetDataSet(
info->Set(RANK(), box.GetProcessId() );
info->Set(BLOCK_ID(), box.GetBlockId() );
double spacing[3];
box.GetGridSpacing( spacing );
info->Set(SPACING(),spacing[0],spacing[1],spacing[2]);
int realExtent[6];
box.GetRealExtent( realExtent );
info->Set(REAL_EXTENT(),
......@@ -203,13 +215,18 @@ vtkUniformGrid* vtkHierarchicalBoxDataSet::GetDataSet(
vtkAssertUtils::assertTrue(info->Has(BLOCK_ID()),__FILE__,__LINE__);
vtkAssertUtils::assertTrue(info->Has(REAL_EXTENT()),__FILE__,__LINE__);
box.SetDimensionality( info->Get( BOX_DIMENSIONALITY() ) );
int *dims = info->Get( BOX() );
box.SetDimensions(dims,dims+3);
box.SetDimensionality( info->Get( BOX_DIMENSIONALITY() ) );
box.SetDataSetOrigin( info->Get( BOX_ORIGIN() ) );
box.SetProcessId( info->Get( RANK() ) );
box.SetBlockId( info->Get( BLOCK_ID() ) );
box.SetRealExtent( info->Get( REAL_EXTENT() ) );
box.SetLevel( level );
double *spacing = info->Get( SPACING() );
vtkAssertUtils::assertNotNull( spacing, __FILE__, __LINE__ );
box.SetGridSpacing( spacing );
// int dimensionality = info->Has(BOX_DIMENSIONALITY())?
// info->Get()
......@@ -372,6 +389,8 @@ void vtkHierarchicalBoxDataSet::GeneratePointVisibility(
vtkAMRBox fineBox;
vtkUniformGrid *fineGrid = this->GetDataSet(
nextLevel, dataIdx, fineBox );
vtkAssertUtils::assertEquals(
fineBox.GetLevel(), nextLevel,__FILE__,__LINE__);
unsigned int pnt = 0;
for( ; pnt < coarseGrid->GetNumberOfPoints(); ++pnt )
......
......@@ -168,6 +168,7 @@ public:
static vtkInformationIntegerKey* REFINEMENT_RATIO();
static vtkInformationIdTypeKey* NUMBER_OF_BLANKED_POINTS();
static vtkInformationDoubleVectorKey* BOX_ORIGIN();
static vtkInformationDoubleVectorKey* SPACING();
static vtkInformationIntegerKey* RANK();
static vtkInformationIntegerKey* BLOCK_ID();
static vtkInformationIntegerVectorKey* REAL_EXTENT();
......
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