Commit 219c1c7b authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

Fixed BUG #10615: Issues with 2D AMR blocks.

vtkHierarchicalBoxDataSet didn't save AMR box dimensionality. Nor was it
preserved by readers/writers. This fixes that issue.
parent 24f6a0f8
......@@ -31,10 +31,10 @@
#include <assert.h>
vtkStandardNewMacro(vtkHierarchicalBoxDataSet);
vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,BOX,IntegerVector);
vtkInformationKeyRestrictedMacro(vtkHierarchicalBoxDataSet,BOX,IntegerVector, 6);
vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,NUMBER_OF_BLANKED_POINTS,IdType);
vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,REFINEMENT_RATIO,Integer);
vtkInformationKeyMacro(vtkHierarchicalBoxDataSet,BOX_DIMENSIONALITY,Integer);
typedef vtkstd::vector<vtkAMRBox> vtkAMRBoxList;
//----------------------------------------------------------------------------
......@@ -139,6 +139,7 @@ void vtkHierarchicalBoxDataSet::SetDataSet(
{
const int *loCorner=box.GetLoCorner();
const int *hiCorner=box.GetHiCorner();
info->Set(BOX_DIMENSIONALITY(), box.GetDimensionality());
info->Set(BOX(),
loCorner[0], loCorner[1], loCorner[2],
hiCorner[0], hiCorner[1], hiCorner[2]);
......@@ -165,6 +166,10 @@ vtkUniformGrid* vtkHierarchicalBoxDataSet::GetDataSet(unsigned int level,
vtkInformation* info = levelDS->GetMetaData(id);
if (info)
{
int dimensionality = info->Has(BOX_DIMENSIONALITY())?
info->Get(BOX_DIMENSIONALITY()) : 3;
box.SetDimensionality(dimensionality);
int* boxVec = info->Get(BOX());
if (boxVec)
{
......@@ -287,7 +292,9 @@ void vtkHierarchicalBoxDataSet::GenerateVisibilityArrays()
vtkInformation* info = this->GetMetaData(
levelIdx+1,dataSetIdx);
int* boxVec = info->Get(BOX());
vtkAMRBox coarsebox(3,boxVec,boxVec+3);
int dimensionality = info->Has(BOX_DIMENSIONALITY())?
info->Get(BOX_DIMENSIONALITY()) : 3;
vtkAMRBox coarsebox(dimensionality,boxVec,boxVec+3);
int refinementRatio = this->GetRefinementRatio(levelIdx);
if (refinementRatio == 0)
{
......@@ -356,6 +363,9 @@ vtkAMRBox vtkHierarchicalBoxDataSet::GetAMRBox(vtkCompositeDataIterator* iter)
if (this->HasMetaData(iter))
{
vtkInformation* info = this->GetMetaData(iter);
int dimensionality = info->Has(BOX_DIMENSIONALITY())?
info->Get(BOX_DIMENSIONALITY()) : 3;
box.SetDimensionality(dimensionality);
int* boxVec = info->Get(BOX());
if (boxVec)
{
......
......@@ -164,6 +164,7 @@ public:
void GenerateVisibilityArrays();
static vtkInformationIntegerVectorKey* BOX();
static vtkInformationIntegerKey* BOX_DIMENSIONALITY();
static vtkInformationIntegerKey* REFINEMENT_RATIO();
static vtkInformationIdTypeKey* NUMBER_OF_BLANKED_POINTS();
......
......@@ -200,6 +200,14 @@ void vtkXMLHierarchicalBoxDataReader::ReadComposite(vtkXMLDataElement* element,
vtkWarningMacro("Missing amr box for level " << level << ", dataset " << index);
}
int dimensionality = 3;
if (!datasetXML->GetScalarAttribute("dimensionality", dimensionality))
{
// default.
dimensionality = 3;
}
amrBox.SetDimensionality(dimensionality);
vtkSmartPointer<vtkUniformGrid> childDS = 0;
if (this->ShouldReadDataSet(dataSetIndex))
{
......
......@@ -31,13 +31,17 @@ vtkStandardNewMacro(vtkXMLHierarchicalBoxDataWriter);
vtkXMLHierarchicalBoxDataWriter::vtkXMLHierarchicalBoxDataWriter()
{
this->AMRBoxes = NULL;
this->AMRBoxDims = NULL;
}
//----------------------------------------------------------------------------
vtkXMLHierarchicalBoxDataWriter::~vtkXMLHierarchicalBoxDataWriter()
{
delete this->AMRBoxes;
delete [] this->AMRBoxes;
this->AMRBoxes = NULL;
delete [] this->AMRBoxDims;
this->AMRBoxDims = NULL;
}
//----------------------------------------------------------------------------
......@@ -60,11 +64,15 @@ void vtkXMLHierarchicalBoxDataWriter::FillDataTypes(vtkCompositeDataSet* cdInput
assert("dataset must be vtkHierarchicalBoxDataSet" && hdInput != NULL);
delete [] this->AMRBoxes;
delete [] this->AMRBoxDims;
unsigned int numLeafNodes = this->GetNumberOfDataTypes();
this->AMRBoxes = new int[numLeafNodes * 6];
memset(this->AMRBoxes, 0, numLeafNodes*6*sizeof(int));
this->AMRBoxDims = new int[numLeafNodes];
memset(this->AMRBoxDims, 0, numLeafNodes*sizeof(int));
vtkCompositeDataIterator* iter = hdInput->NewIterator();
iter->SkipEmptyNodesOff();
int leafNo = 0;
......@@ -75,6 +83,7 @@ void vtkXMLHierarchicalBoxDataWriter::FillDataTypes(vtkCompositeDataSet* cdInput
{
vtkAMRBox box = hdInput->GetAMRBox(iter);
box.GetDimensions(&this->AMRBoxes[leafNo*6]);
this->AMRBoxDims[leafNo] = box.GetDimensionality();
}
}
iter->Delete();
......@@ -106,6 +115,8 @@ int vtkXMLHierarchicalBoxDataWriter::WriteComposite(vtkCompositeDataSet* composi
// we use the box from this->AMRBoxes since that datastructure is
// synchronized when running in parallel.
datasetXML->SetVectorAttribute("amr_box", 6, &this->AMRBoxes[writerIdx*6]);
datasetXML->SetIntAttribute("dimensionality",
this->AMRBoxDims[writerIdx]);
vtkStdString fileName = this->CreatePieceFileName(writerIdx);
if (fileName != "")
{
......
......@@ -42,7 +42,7 @@ protected:
virtual int FillInputPortInformation(int port, vtkInformation* info);
// Fills up this->AMRBoxes with boxes for the dataset.
// Fills up this->AMRBoxes, this->AMRBoxDims with boxes for the dataset.
virtual void FillDataTypes(vtkCompositeDataSet*);
// Internal method called recursively to create the xml tree for the children
......@@ -51,6 +51,7 @@ protected:
vtkXMLDataElement* parent, int &writerIdx);
int *AMRBoxes;
int *AMRBoxDims;
private:
vtkXMLHierarchicalBoxDataWriter(const vtkXMLHierarchicalBoxDataWriter&); // Not implemented.
void operator=(const vtkXMLHierarchicalBoxDataWriter&); // Not implemented.
......
......@@ -98,6 +98,7 @@ void vtkXMLPHierarchicalBoxDataWriter::FillDataTypes(
// ratio informations since those are certainly consistent on all processes
// since we expect the same composite structure on all nodes.
assert(this->AMRBoxes != NULL);
assert(this->AMRBoxDims != NULL);
if (myid == 0)
{
......@@ -113,6 +114,8 @@ void vtkXMLPHierarchicalBoxDataWriter::FillDataTypes(
memset(gathered_amx_box_dims, 0, numLeafNodes*6*numProcs*sizeof(int));
this->Controller->Gather(this->AMRBoxes, gathered_amx_box_dims,
numLeafNodes*6, 0);
this->Controller->Gather(this->AMRBoxDims, gathered_amx_box_dims,
numLeafNodes, 0);
for (int procNo=1; procNo<numProcs; procNo++)
{
......@@ -126,6 +129,8 @@ void vtkXMLPHierarchicalBoxDataWriter::FillDataTypes(
memcpy(&this->AMRBoxes[pieceNo*6],
&gathered_amx_box_dims[(procNo*numLeafNodes + pieceNo)*6],
sizeof(int)*6);
this->AMRBoxDims[pieceNo] = gathered_amx_box_dims[
procNo*numLeafNodes + pieceNo];
}
}
}
......@@ -136,6 +141,7 @@ void vtkXMLPHierarchicalBoxDataWriter::FillDataTypes(
{
this->Controller->Gather(myDataTypes, NULL, numLeafNodes, 0);
this->Controller->Gather(this->AMRBoxes, NULL, numLeafNodes*6, 0);
this->Controller->Gather(this->AMRBoxDims, NULL, numLeafNodes, 0);
}
}
Supports Markdown
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