mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: construct VTK writers with the outputOptions and adjust internally
- this shifts responsibility away from caller to the individual writers for knowing which file formats are supported and which file ending is appropriate. When the writer receives the output format request, it can elect to downgrade or otherwise adjust it to what it can actually manage (eg, legacy vs xml vs xml-append). But currently still just with legacy format backends.
This commit is contained in:
@ -34,22 +34,24 @@ License
|
||||
|
||||
void Foam::foamVtkOutput::writeCellSetFaces
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const cellSet& set,
|
||||
const fileName& fileName
|
||||
const fileName& baseName,
|
||||
const foamVtkOutput::outputOptions outOpts
|
||||
)
|
||||
{
|
||||
std::ofstream os(fileName.c_str());
|
||||
outputOptions opts(outOpts);
|
||||
opts.legacy(true); // Legacy only, no append
|
||||
|
||||
autoPtr<foamVtkOutput::formatter> format =
|
||||
foamVtkOutput::outputOptions().legacy(true).ascii(!binary).newFormatter
|
||||
(
|
||||
os
|
||||
);
|
||||
std::ofstream os((baseName + (opts.legacy() ? ".vtk" : ".vtp")).c_str());
|
||||
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os);
|
||||
|
||||
if (opts.legacy())
|
||||
{
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@ -87,7 +89,7 @@ void Foam::foamVtkOutput::writeCellSetFaces
|
||||
}
|
||||
}
|
||||
|
||||
labelList faceLabels = cellFaces.sortedToc();
|
||||
const labelList faceLabels = cellFaces.sortedToc();
|
||||
labelList faceValues(cellFaces.size());
|
||||
|
||||
forAll(faceLabels, facei)
|
||||
|
||||
@ -39,6 +39,7 @@ SourceFiles
|
||||
|
||||
#include "primitiveMesh.H"
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
#include "foamVtkOutputOptions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -55,10 +56,10 @@ namespace foamVtkOutput
|
||||
// The data are the original cell ids
|
||||
void writeCellSetFaces
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const cellSet& set,
|
||||
const fileName& fileName
|
||||
const fileName& baseName,
|
||||
const foamVtkOutput::outputOptions outOpts
|
||||
);
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
|
||||
@ -34,27 +34,29 @@ License
|
||||
|
||||
void Foam::foamVtkOutput::writeFaceSet
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const faceSet& set,
|
||||
const fileName& fileName
|
||||
const fileName& baseName,
|
||||
const foamVtkOutput::outputOptions outOpts
|
||||
)
|
||||
{
|
||||
std::ofstream os(fileName.c_str());
|
||||
outputOptions opts(outOpts);
|
||||
opts.legacy(true); // Legacy only, no append
|
||||
|
||||
autoPtr<foamVtkOutput::formatter> format =
|
||||
foamVtkOutput::outputOptions().legacy(true).ascii(!binary).newFormatter
|
||||
(
|
||||
os
|
||||
);
|
||||
std::ofstream os((baseName + (opts.legacy() ? ".vtk" : ".vtp")).c_str());
|
||||
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os);
|
||||
|
||||
if (opts.legacy())
|
||||
{
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// Faces of set with OpenFOAM faceID as value
|
||||
labelList faceLabels = set.sortedToc();
|
||||
const labelList faceLabels = set.sortedToc();
|
||||
|
||||
uindirectPrimitivePatch pp
|
||||
(
|
||||
|
||||
@ -36,6 +36,8 @@ SourceFiles
|
||||
#ifndef foamVtkWriteFaceSet_H
|
||||
#define foamVtkWriteFaceSet_H
|
||||
|
||||
#include "foamVtkOutputOptions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -51,10 +53,10 @@ namespace foamVtkOutput
|
||||
// Only one data which is original pointID.
|
||||
void writeFaceSet
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const faceSet& set,
|
||||
const fileName& fileName
|
||||
const fileName& baseName,
|
||||
const foamVtkOutput::outputOptions outOpts
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -33,22 +33,24 @@ License
|
||||
|
||||
void Foam::foamVtkOutput::writePointSet
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const pointSet& set,
|
||||
const fileName& fileName
|
||||
const fileName& baseName,
|
||||
const foamVtkOutput::outputOptions outOpts
|
||||
)
|
||||
{
|
||||
std::ofstream os(fileName.c_str());
|
||||
outputOptions opts(outOpts);
|
||||
opts.legacy(true); // Legacy only, no append
|
||||
|
||||
autoPtr<foamVtkOutput::formatter> format =
|
||||
foamVtkOutput::outputOptions().legacy(true).ascii(!binary).newFormatter
|
||||
(
|
||||
os
|
||||
);
|
||||
std::ofstream os((baseName + (opts.legacy() ? ".vtk" : ".vtp")).c_str());
|
||||
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os);
|
||||
|
||||
if (opts.legacy())
|
||||
{
|
||||
foamVtkOutput::legacy::fileHeader(format(), set.name())
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -36,6 +36,8 @@ SourceFiles
|
||||
#ifndef foamVtkWritePointSet_H
|
||||
#define foamVtkWritePointSet_H
|
||||
|
||||
#include "foamVtkOutputOptions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -51,10 +53,10 @@ namespace foamVtkOutput
|
||||
// The data are the original point ids.
|
||||
void writePointSet
|
||||
(
|
||||
const bool binary,
|
||||
const primitiveMesh& mesh,
|
||||
const pointSet& set,
|
||||
const fileName& fileName
|
||||
const fileName& baseName,
|
||||
const foamVtkOutput::outputOptions outOpts
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user