Commit f54b5b9f authored by Joachim Pouderoux's avatar Joachim Pouderoux Committed by Code Review

Merge topic 'enh_xdmf3_writer' into master

acb40959 Enhance Xdmf3 writer to save block names.
parents 9f0d0bae acb40959
......@@ -157,7 +157,7 @@ vtkDataArray *vtkXdmf3DataSet::XdmfToVTKArray(
vArray->SetName(attrName.c_str());
std::vector<unsigned int> dims = xArray->getDimensions();
unsigned int ndims = dims.size();
unsigned int ndims = static_cast<unsigned int>(dims.size());
unsigned int ncomp = preferredComponents;
if (preferredComponents == 0) //caller doesn't know what to expect,
{
......@@ -454,7 +454,7 @@ void vtkXdmf3DataSet::XdmfToVTKAttributes(
//figure out how many components in this array
std::vector<unsigned int> dims = xmfAttribute->getDimensions();
unsigned int ndims = dims.size();
unsigned int ndims = static_cast<unsigned int>(dims.size());
unsigned int nvals = 1;
for (unsigned int i = 0; i < dims.size(); i++)
{
......@@ -1086,7 +1086,8 @@ void vtkXdmf3DataSet::CopyShape(
void vtkXdmf3DataSet::VTKToXdmf(
vtkImageData *dataSet,
XdmfDomain *domain,
bool hasTime, double time)
bool hasTime, double time,
const char* name)
{
int whole_extent[6];
dataSet->GetExtent(whole_extent);
......@@ -1102,6 +1103,10 @@ void vtkXdmf3DataSet::VTKToXdmf(
spacing[2], spacing[1], spacing[0],
dims[2], dims[1], dims[0],
origin[2], origin[1], origin[0]);
if (name)
{
grid->setName(std::string(name));
}
vtkXdmf3DataSet::VTKToXdmfAttributes(dataSet, grid.get());
vtkXdmf3DataSet::SetTime(grid.get(), hasTime, time);
......@@ -1201,7 +1206,8 @@ void vtkXdmf3DataSet::CopyShape(
void vtkXdmf3DataSet::VTKToXdmf(
vtkRectilinearGrid *dataSet,
XdmfDomain *domain,
bool hasTime, double time)
bool hasTime, double time,
const char* name)
{
vtkDataArray *vCoords = NULL;
shared_ptr<XdmfArray> xXCoords = XdmfArray::New();
......@@ -1230,6 +1236,11 @@ void vtkXdmf3DataSet::VTKToXdmf(
shared_ptr<XdmfRectilinearGrid> grid = XdmfRectilinearGrid::New(
xXCoords, xYCoords, xZCoords);
if (name)
{
grid->setName(std::string(name));
}
vtkXdmf3DataSet::VTKToXdmfAttributes(dataSet, grid.get());
vtkXdmf3DataSet::SetTime(grid.get(), hasTime, time);
......@@ -1322,7 +1333,8 @@ void vtkXdmf3DataSet::CopyShape(
void vtkXdmf3DataSet::VTKToXdmf(
vtkStructuredGrid *dataSet,
XdmfDomain *domain,
bool hasTime, double time)
bool hasTime, double time,
const char* name)
{
int whole_extent[6];
whole_extent[0] = 0;
......@@ -1355,6 +1367,11 @@ void vtkXdmf3DataSet::VTKToXdmf(
shared_ptr<XdmfCurvilinearGrid> grid = XdmfCurvilinearGrid::New(xdims);
grid->setGeometry(xCoords);
if (name)
{
grid->setName(std::string(name));
}
vtkXdmf3DataSet::VTKToXdmfAttributes(dataSet, grid.get());
vtkXdmf3DataSet::SetTime(grid.get(), hasTime, time);
......@@ -1530,7 +1547,8 @@ void vtkXdmf3DataSet::CopyShape(
void vtkXdmf3DataSet::VTKToXdmf(
vtkPointSet *dataSet,
XdmfDomain *domain,
bool hasTime, double time)
bool hasTime, double time,
const char* name)
{
vtkDataArray *vCoords = dataSet->GetPoints()->GetData();
shared_ptr<XdmfGeometry> xCoords = XdmfGeometry::New();
......@@ -1542,12 +1560,16 @@ void vtkXdmf3DataSet::VTKToXdmf(
xCoords->setType(XdmfGeometryType::XYZ());
shared_ptr<XdmfUnstructuredGrid> grid = XdmfUnstructuredGrid::New();
if (name)
{
grid->setName(std::string(name));
}
grid->setGeometry(xCoords);
shared_ptr<XdmfTopology> xTopology = XdmfTopology::New();
grid->setTopology(xTopology);
//TODO: homogeneous case in old reader _might_ be faster
//for simplicity I am treating all dataSets as having mixed cell types
xTopology->setType(XdmfTopologyType::Mixed());
......@@ -1751,7 +1773,8 @@ void vtkXdmf3DataSet::XdmfToVTK(
void vtkXdmf3DataSet::VTKToXdmf(
vtkDirectedGraph *dataSet,
XdmfDomain *domain,
bool hasTime, double time)
bool hasTime, double time,
const char* name)
{
//get list of vertices
vtkSmartPointer<vtkVertexListIterator> vit =
......@@ -1806,6 +1829,10 @@ void vtkXdmf3DataSet::VTKToXdmf(
grid->setValues(mValues);
grid->setColumnIndex(mColumnIndex);
grid->setRowPointer(mRowPointer);
if (name)
{
grid->setName(std::string(name));
}
vtkFieldData *fd;
shared_ptr<const XdmfAttributeCenter> center;
......@@ -1886,7 +1913,7 @@ void vtkXdmf3DataSet::XdmfToVTKAttributes(
//figure out how many components in this array
std::vector<unsigned int> dims = xmfAttribute->getDimensions();
unsigned int ndims = dims.size();
unsigned int ndims = static_cast<unsigned int>(dims.size());
unsigned int nvals = 1;
for (unsigned int i = 0; i < dims.size(); i++)
{
......
......@@ -126,7 +126,8 @@ public:
static void VTKToXdmf(
vtkImageData *dataSet,
XdmfDomain *domain,
bool hasTime, double time);
bool hasTime, double time,
const char* name = 0);
//vtkXdmf3RectilinearGrid
// Description:
......@@ -151,7 +152,8 @@ public:
static void VTKToXdmf(
vtkRectilinearGrid *dataSet,
XdmfDomain *domain,
bool hasTime, double time);
bool hasTime, double time,
const char* name = 0);
//vtkXdmf3CurvilinearGrid
// Description:
......@@ -176,7 +178,8 @@ public:
static void VTKToXdmf(
vtkStructuredGrid *dataSet,
XdmfDomain *domain,
bool hasTime, double time);
bool hasTime, double time,
const char* name = 0);
//vtkXdmf3UnstructuredGrid
// Description:
......@@ -201,7 +204,8 @@ public:
static void VTKToXdmf(
vtkPointSet *dataSet,
XdmfDomain *domain,
bool hasTime, double time);
bool hasTime, double time,
const char* name = 0);
//vtkXdmf3Graph
// Description:
......@@ -219,7 +223,8 @@ public:
static void VTKToXdmf(
vtkDirectedGraph *dataSet,
XdmfDomain *domain,
bool hasTime, double time);
bool hasTime, double time,
const char* name = 0);
//Side Sets
......
......@@ -18,8 +18,10 @@
#include "vtkXdmf3HeavyDataHandler.h"
#include "vtkCompositeDataSet.h"
#include "vtkDataObject.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkMutableDirectedGraph.h"
#include "vtkRectilinearGrid.h"
......@@ -103,6 +105,8 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
(0,
this->MakeUnsGrid
(unsGrid, child, this->Keeper));
mbds->GetMetaData((unsigned int)0)->Set(vtkCompositeDataSet::NAME(),
unsGrid->getName().c_str());
for (unsigned int i = 0; i < nSets; i++)
{
vtkUnstructuredGrid *sub = vtkUnstructuredGrid::New();
......@@ -110,6 +114,8 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
(i+1,
this->ExtractSet
(i, unsGrid, child, sub, this->Keeper));
mbds->GetMetaData(i+1)->Set(vtkCompositeDataSet::NAME(),
unsGrid->getSet(i)->getName().c_str());
sub->Delete();
}
child->Delete();
......@@ -134,6 +140,8 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
(0,
this->MakeRecGrid
(recGrid, child, this->Keeper));
mbds->GetMetaData((unsigned int)0)->Set(vtkCompositeDataSet::NAME(),
recGrid->getName().c_str());
for (unsigned int i = 0; i < nSets; i++)
{
vtkUnstructuredGrid *sub = vtkUnstructuredGrid::New();
......@@ -141,6 +149,8 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
(i+1,
this->ExtractSet
(i, recGrid, child, sub, this->Keeper));
mbds->GetMetaData(i+1)->Set(vtkCompositeDataSet::NAME(),
recGrid->getSet(i)->getName().c_str());
sub->Delete();
}
child->Delete();
......@@ -165,6 +175,8 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
(0,
this->MakeCrvGrid
(crvGrid, child, this->Keeper));
mbds->GetMetaData((unsigned int)0)->Set(vtkCompositeDataSet::NAME(),
crvGrid->getName().c_str());
for (unsigned int i = 0; i < nSets; i++)
{
vtkUnstructuredGrid *sub = vtkUnstructuredGrid::New();
......@@ -172,6 +184,8 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
(i+1,
this->ExtractSet
(i, crvGrid, child, sub, this->Keeper));
mbds->GetMetaData(i+1)->Set(vtkCompositeDataSet::NAME(),
crvGrid->getSet(i)->getName().c_str());
sub->Delete();
}
child->Delete();
......@@ -196,6 +210,8 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
(0,
this->MakeRegGrid
(regGrid, child, this->Keeper));
mbds->GetMetaData((unsigned int)0)->Set(vtkCompositeDataSet::NAME(),
regGrid->getName().c_str());
for (unsigned int i = 0; i < nSets; i++)
{
vtkUnstructuredGrid *sub = vtkUnstructuredGrid::New();
......@@ -203,6 +219,8 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
(i+1,
this->ExtractSet
(i, regGrid, child, sub, this->Keeper));
mbds->GetMetaData(i+1)->Set(vtkCompositeDataSet::NAME(),
crvGrid->getSet(i)->getName().c_str());
sub->Delete();
}
child->Delete();
......@@ -300,7 +318,10 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
result = this->Populate(group->getUnstructuredGrid(i), child);
if (result)
{
topB->SetBlock(cnt++, result);
topB->SetBlock(cnt, result);
topB->GetMetaData(cnt)->Set(vtkCompositeDataSet::NAME(),
cGrid->getName().c_str());
cnt++;
}
child->Delete();
}
......@@ -326,7 +347,10 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
result = this->Populate(cGrid, child);
if (result)
{
topB->SetBlock(cnt++, result);
topB->SetBlock(cnt, result);
topB->GetMetaData(cnt)->Set(vtkCompositeDataSet::NAME(),
cGrid->getName().c_str());
cnt++;
}
child->Delete();
}
......@@ -352,7 +376,10 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
result = this->Populate(cGrid, child);
if (result)
{
topB->SetBlock(cnt++, result);
topB->SetBlock(cnt, result);
topB->GetMetaData(cnt)->Set(vtkCompositeDataSet::NAME(),
cGrid->getName().c_str());
cnt++;
}
child->Delete();
}
......@@ -378,7 +405,10 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
result = this->Populate(cGrid, child);
if (result)
{
topB->SetBlock(cnt++, result);
topB->SetBlock(cnt, result);
topB->GetMetaData(cnt)->Set(vtkCompositeDataSet::NAME(),
cGrid->getName().c_str());
cnt++;
}
child->Delete();
}
......@@ -394,7 +424,10 @@ vtkDataObject *vtkXdmf3HeavyDataHandler::Populate(
result = this->Populate(group->getGraph(i), child);
if (result)
{
topB->SetBlock(cnt++, result);
topB->SetBlock(cnt, result);
topB->GetMetaData(cnt)->Set(vtkCompositeDataSet::NAME(),
group->getGraph(i)->getName().c_str());
cnt++;
}
child->Delete();
}
......
......@@ -278,7 +278,7 @@ private:
void Init(const char *filename, bool AsTime)
{
vtkTimerLog::MarkStartEvent("X3R::Init");
unsigned int idx = this->FileNames.size();
unsigned int idx = static_cast<unsigned int>(this->FileNames.size());
this->Reader = XdmfReader::New();
......
......@@ -62,7 +62,8 @@ public:
this->Destination = this->DestinationGroups.top();
this->Domain->insert(dest);
}
void WriteDataObject(vtkDataObject *dataSet, bool hasTime, double time)
void WriteDataObject(vtkDataObject *dataSet, bool hasTime, double time,
const char* name = 0)
{
if (!dataSet)
{
......@@ -80,7 +81,8 @@ public:
for (unsigned int i = 0; i< mbds->GetNumberOfBlocks(); i++)
{
vtkDataObject *next = mbds->GetBlock(i);
this->WriteDataObject(next, hasTime, time);
const char* name = mbds->GetMetaData(i)->Get(vtkCompositeDataSet::NAME());
this->WriteDataObject(next, hasTime, time, name);
}
this->DestinationGroups.pop();
this->Destination = this->DestinationGroups.top();
......@@ -93,7 +95,7 @@ public:
vtkXdmf3DataSet::VTKToXdmf(
vtkImageData::SafeDownCast(dataSet),
this->Destination.get(),
hasTime, time);
hasTime, time, name);
break;
}
case VTK_RECTILINEAR_GRID:
......@@ -101,7 +103,7 @@ public:
vtkXdmf3DataSet::VTKToXdmf(
vtkRectilinearGrid::SafeDownCast(dataSet),
this->Destination.get(),
hasTime, time);
hasTime, time, name);
break;
}
case VTK_STRUCTURED_GRID:
......@@ -109,7 +111,7 @@ public:
vtkXdmf3DataSet::VTKToXdmf(
vtkStructuredGrid::SafeDownCast(dataSet),
this->Destination.get(),
hasTime, time);
hasTime, time, name);
break;
}
case VTK_POLY_DATA:
......@@ -118,7 +120,7 @@ public:
vtkXdmf3DataSet::VTKToXdmf(
vtkPointSet::SafeDownCast(dataSet),
this->Destination.get(),
hasTime, time);
hasTime, time, name);
break;
}
//case VTK_GRAPH:
......@@ -128,7 +130,7 @@ public:
vtkXdmf3DataSet::VTKToXdmf(
vtkDirectedGraph::SafeDownCast(dataSet),
this->Destination.get(),
hasTime, time);
hasTime, time, name);
break;
}
default:
......
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