ENH: add VTP, VTU output for most vtk writers (insitu only)

- with the xml append format it is possible to write raw binary
  (instead of base64), but the writer becomes more complicated.
  Either needs two passes to create, or need to allocate a block
  of space for the header information (like VTK itself does) and
  write later.

    * internalWriter
    * patchWriter
    * surfaceMeshWriter
    * lagrangianWriter

 Also these special purpose ones:
    * foamVtkWriteSurfFields
This commit is contained in:
Mark Olesen
2017-06-01 18:28:40 +02:00
parent c4f1349496
commit a2e978d43e
25 changed files with 1762 additions and 435 deletions

View File

@ -43,14 +43,15 @@ void Foam::foamVtkOutput::writeCellSetFaces
outputOptions opts(outOpts);
opts.legacy(true); // Legacy only, no append
std::ofstream os((baseName + (opts.legacy() ? ".vtk" : ".vtp")).c_str());
const bool legacy_(opts.legacy());
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os);
if (opts.legacy())
if (legacy_)
{
foamVtkOutput::legacy::fileHeader(format(), set.name())
<< "DATASET POLYDATA" << nl;
legacy::fileHeader(format(), set.name(), vtkFileTag::POLY_DATA);
}
//-------------------------------------------------------------------------
@ -106,30 +107,35 @@ void Foam::foamVtkOutput::writeCellSetFaces
//-------------------------------------------------------------------------
// Write points and faces as polygons
os << "POINTS " << pp.nPoints() << " float" << nl;
legacy::beginPoints(os, pp.nPoints());
foamVtkOutput::writeList(format(), pp.localPoints());
format().flush();
label count = pp.size();
// connectivity count without additional storage (done internally)
uint64_t nConnectivity = 0;
forAll(pp, facei)
{
count += pp.localFaces()[facei].size();
nConnectivity += pp[facei].size();
}
os << "POLYGONS " << pp.size() << ' ' << count << nl;
legacy::beginPolys(os, pp.size(), nConnectivity);
// legacy: size + connectivity together
// [nPts, id1, id2, ..., nPts, id1, id2, ...]
forAll(pp, facei)
{
const face& f = pp.localFaces()[facei];
format().write(f.size());
format().write(f.size()); // The size prefix
foamVtkOutput::writeList(format(), f);
}
format().flush();
// Write data - faceId/cellId
foamVtkOutput::legacy::cellDataHeader(os, pp.size(), 1);
legacy::dataHeader(os, vtkFileTag::CELL_DATA, pp.size(), 1);
os << "cellID 1 " << pp.size() << " int" << nl;

View File

@ -43,14 +43,15 @@ void Foam::foamVtkOutput::writeFaceSet
outputOptions opts(outOpts);
opts.legacy(true); // Legacy only, no append
std::ofstream os((baseName + (opts.legacy() ? ".vtk" : ".vtp")).c_str());
const bool legacy_(opts.legacy());
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os);
if (opts.legacy())
if (legacy_)
{
foamVtkOutput::legacy::fileHeader(format(), set.name())
<< "DATASET POLYDATA" << nl;
legacy::fileHeader(format(), set.name(), vtkFileTag::POLY_DATA);
}
//-------------------------------------------------------------------------
@ -67,28 +68,36 @@ void Foam::foamVtkOutput::writeFaceSet
//-------------------------------------------------------------------------
// Write points and faces as polygons
os << "POINTS " << pp.nPoints() << " float" << nl;
legacy::beginPoints(os, pp.nPoints());
foamVtkOutput::writeList(format(), pp.localPoints());
format().flush();
label count = pp.size();
// connectivity count without additional storage (done internally)
uint64_t nConnectivity = 0;
forAll(pp, facei)
{
count += pp.localFaces()[facei].size();
nConnectivity += pp[facei].size();
}
os << "POLYGONS " << pp.size() << ' ' << count << nl;
legacy::beginPolys(os, pp.size(), nConnectivity);
// legacy: size + connectivity together
// [nPts, id1, id2, ..., nPts, id1, id2, ...]
forAll(pp, facei)
{
const face& f = pp.localFaces()[facei];
format().write(f.size());
format().write(f.size()); // The size prefix
foamVtkOutput::writeList(format(), f);
}
format().flush();
// Write data - faceId/cellId
legacy::dataHeader(os, vtkFileTag::CELL_DATA, pp.size(), 1);
os << "faceID 1 " << pp.size() << " int" << nl;
foamVtkOutput::writeList(format(), faceLabels);

View File

@ -42,14 +42,15 @@ void Foam::foamVtkOutput::writePointSet
outputOptions opts(outOpts);
opts.legacy(true); // Legacy only, no append
std::ofstream os((baseName + (opts.legacy() ? ".vtk" : ".vtp")).c_str());
const bool legacy_(opts.legacy());
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os);
if (opts.legacy())
if (legacy_)
{
foamVtkOutput::legacy::fileHeader(format(), set.name())
<< "DATASET POLYDATA" << nl;
legacy::fileHeader(format(), set.name(), vtkFileTag::POLY_DATA);
}
//-------------------------------------------------------------------------
@ -57,14 +58,13 @@ void Foam::foamVtkOutput::writePointSet
const labelList pointLabels(set.sortedToc());
// Write points
os << "POINTS " << pointLabels.size() << " float" << nl;
legacy::beginPoints(os, pointLabels.size());
foamVtkOutput::writeList(format(), mesh.points(), pointLabels);
format().flush();
// Write data - pointID
foamVtkOutput::legacy::pointDataHeader(os, pointLabels.size(), 1);
legacy::dataHeader(os, vtkFileTag::POINT_DATA, pointLabels.size(), 1);
os << "pointID 1 " << pointLabels.size() << " int" << nl;