ENH: consolidate vtk classes into 'Foam::vtk' namespace

- elminate the foamVtkFormatter operator() in favour of xmlAttr.
  Improves readability and the purpose is clearer.
This commit is contained in:
Mark Olesen
2017-06-13 14:10:07 +02:00
parent edc1bd2230
commit cde12ad9e5
81 changed files with 1249 additions and 1408 deletions

View File

@ -82,33 +82,33 @@ void writeVTK
if (isA<faceSet>(currentSet)) if (isA<faceSet>(currentSet))
{ {
// Faces of set with OpenFOAM faceID as value // Faces of set with OpenFOAM faceID as value
foamVtkOutput::writeFaceSet vtk::writeFaceSet
( (
mesh, mesh,
currentSet, currentSet,
mesh.time().path()/vtkBaseName, mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY vtk::formatType::LEGACY_BINARY
); );
} }
else if (isA<cellSet>(currentSet)) else if (isA<cellSet>(currentSet))
{ {
// External faces of cellset with OpenFOAM cellID as value // External faces of cellset with OpenFOAM cellID as value
foamVtkOutput::writeCellSetFaces vtk::writeCellSetFaces
( (
mesh, mesh,
currentSet, currentSet,
mesh.time().path()/vtkBaseName, mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY vtk::formatType::LEGACY_BINARY
); );
} }
else if (isA<pointSet>(currentSet)) else if (isA<pointSet>(currentSet))
{ {
foamVtkOutput::writePointSet vtk::writePointSet
( (
mesh, mesh,
currentSet, currentSet,
mesh.time().path()/vtkBaseName, mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY vtk::formatType::LEGACY_BINARY
); );
} }
else else

View File

@ -242,9 +242,9 @@ labelList getSelectedPatches
// Process args for output options // Process args for output options
// Default from foamVtkOutputOptions is inline ASCII xml // Default from foamVtkOutputOptions is inline ASCII xml
// //
foamVtkOutput::outputOptions getOutputOptions(const argList& args) vtk::outputOptions getOutputOptions(const argList& args)
{ {
foamVtkOutput::outputOptions opts; vtk::outputOptions opts;
if (args.optionFound("xml")) if (args.optionFound("xml"))
{ {
@ -421,7 +421,7 @@ int main(int argc, char *argv[])
const bool noLagrangian = args.optionFound("noLagrangian"); const bool noLagrangian = args.optionFound("noLagrangian");
const bool nearCellValue = args.optionFound("nearCellValue"); const bool nearCellValue = args.optionFound("nearCellValue");
const foamVtkOutput::outputOptions fmtType = getOutputOptions(args); const vtk::outputOptions fmtType = getOutputOptions(args);
if (nearCellValue) if (nearCellValue)
{ {
@ -515,7 +515,7 @@ int main(int argc, char *argv[])
meshSubsetHelper meshRef(mesh, meshSubsetHelper::SET, cellSetName); meshSubsetHelper meshRef(mesh, meshSubsetHelper::SET, cellSetName);
// Collect decomposition information etc. // Collect decomposition information etc.
foamVtkCells foamVtkMeshCells(fmtType, decomposePoly); vtk::vtuCells vtuMeshCells(fmtType, decomposePoly);
Info<< "VTK mesh topology: " Info<< "VTK mesh topology: "
<< timer.cpuTimeIncrement() << " s, " << timer.cpuTimeIncrement() << " s, "
@ -544,7 +544,7 @@ int main(int argc, char *argv[])
) )
{ {
// Trigger change for vtk cells too // Trigger change for vtk cells too
foamVtkMeshCells.clear(); vtuMeshCells.clear();
} }
// If faceSet: write faceSet only (as polydata) // If faceSet: write faceSet only (as polydata)
@ -565,7 +565,7 @@ int main(int argc, char *argv[])
Info<< " faceSet : " Info<< " faceSet : "
<< relativeName(runTime, outputName) << nl; << relativeName(runTime, outputName) << nl;
foamVtkOutput::writeFaceSet vtk::writeFaceSet
( (
meshRef.mesh(), meshRef.mesh(),
set, set,
@ -593,7 +593,7 @@ int main(int argc, char *argv[])
Info<< " pointSet : " Info<< " pointSet : "
<< relativeName(runTime, outputName) << nl; << relativeName(runTime, outputName) << nl;
foamVtkOutput::writePointSet vtk::writePointSet
( (
meshRef.mesh(), meshRef.mesh(),
set, set,
@ -830,14 +830,14 @@ int main(int argc, char *argv[])
if (doWriteInternal) if (doWriteInternal)
{ {
if (foamVtkMeshCells.empty()) if (vtuMeshCells.empty())
{ {
foamVtkMeshCells.reset(meshRef.mesh()); vtuMeshCells.reset(meshRef.mesh());
// Convert cellMap, addPointCellLabels to global cell ids // Convert cellMap, addPointCellLabels to global cell ids
if (meshRef.useSubMesh()) if (meshRef.useSubMesh())
{ {
foamVtkMeshCells.renumberCells vtuMeshCells.renumberCells
( (
meshRef.subsetter().cellMap() meshRef.subsetter().cellMap()
); );
@ -855,10 +855,10 @@ int main(int argc, char *argv[])
<< relativeName(runTime, outputName) << endl; << relativeName(runTime, outputName) << endl;
// Write mesh // Write mesh
foamVtkOutput::internalWriter writer vtk::internalWriter writer
( (
meshRef.baseMesh(), meshRef.baseMesh(),
foamVtkMeshCells, vtuMeshCells,
outputName, outputName,
fmtType fmtType
); );
@ -980,7 +980,7 @@ int main(int argc, char *argv[])
+ timeDesc + timeDesc
); );
foamVtkOutput::writeSurfFields vtk::writeSurfFields
( (
meshRef.mesh(), meshRef.mesh(),
outputName, outputName,
@ -1013,7 +1013,7 @@ int main(int argc, char *argv[])
Info<< " Combined patches : " Info<< " Combined patches : "
<< relativeName(runTime, outputName) << nl; << relativeName(runTime, outputName) << nl;
foamVtkOutput::patchWriter writer vtk::patchWriter writer
( (
meshRef.mesh(), meshRef.mesh(),
outputName, outputName,
@ -1083,7 +1083,7 @@ int main(int argc, char *argv[])
Info<< " Patch : " Info<< " Patch : "
<< relativeName(runTime, outputName) << nl; << relativeName(runTime, outputName) << nl;
foamVtkOutput::patchWriter writer vtk::patchWriter writer
( (
meshRef.mesh(), meshRef.mesh(),
outputName, outputName,
@ -1194,7 +1194,7 @@ int main(int argc, char *argv[])
mesh.points() mesh.points()
); );
foamVtkOutput::surfaceMeshWriter writer vtk::surfaceMeshWriter writer
( (
pp, pp,
fz.name(), fz.name(),
@ -1281,7 +1281,7 @@ int main(int argc, char *argv[])
Info<< " tensors :"; Info<< " tensors :";
print(Info, tensorNames); print(Info, tensorNames);
foamVtkOutput::lagrangianWriter writer vtk::lagrangianWriter writer
( (
meshRef.mesh(), meshRef.mesh(),
cloudName, cloudName,
@ -1314,7 +1314,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
foamVtkOutput::lagrangianWriter writer vtk::lagrangianWriter writer
( (
meshRef.mesh(), meshRef.mesh(),
cloudName, cloudName,

View File

@ -29,30 +29,30 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::lagrangianWriter::beginPiece() void Foam::vtk::lagrangianWriter::beginPiece()
{ {
if (!legacy_) if (!legacy_)
{ {
if (useVerts_) if (useVerts_)
{ {
format() format()
.openTag(vtkFileTag::PIECE) .openTag(vtk::fileTag::PIECE)
( "NumberOfPoints", nParcels_ ) .xmlAttr(fileAttr::NUMBER_OF_POINTS, nParcels_)
( "NumberOfVerts", nParcels_ ) .xmlAttr(fileAttr::NUMBER_OF_VERTS, nParcels_)
.closeTag(); .closeTag();
} }
else else
{ {
format() format()
.openTag(vtkFileTag::PIECE) .openTag(vtk::fileTag::PIECE)
( "NumberOfPoints", nParcels_ ) .xmlAttr(fileAttr::NUMBER_OF_POINTS, nParcels_)
.closeTag(); .closeTag();
} }
} }
} }
void Foam::foamVtkOutput::lagrangianWriter::writePoints() void Foam::vtk::lagrangianWriter::writePoints()
{ {
Cloud<passiveParticle> parcels(mesh_, cloudName_, false); Cloud<passiveParticle> parcels(mesh_, cloudName_, false);
nParcels_ = parcels.size(); nParcels_ = parcels.size();
@ -67,8 +67,8 @@ void Foam::foamVtkOutput::lagrangianWriter::writePoints()
{ {
beginPiece(); // Tricky - hide in here beginPiece(); // Tricky - hide in here
format().tag(vtkFileTag::POINTS) format().tag(vtk::fileTag::POINTS)
.openDataArray<float,3>(vtkFileTag::POINTS) .openDataArray<float,3>(vtk::dataArrayAttr::POINTS)
.closeTag(); .closeTag();
} }
@ -78,7 +78,7 @@ void Foam::foamVtkOutput::lagrangianWriter::writePoints()
{ {
const point& pt = iter().position(); const point& pt = iter().position();
foamVtkOutput::write(format(), pt); vtk::write(format(), pt);
} }
format().flush(); format().flush();
@ -86,12 +86,12 @@ void Foam::foamVtkOutput::lagrangianWriter::writePoints()
{ {
format() format()
.endDataArray() .endDataArray()
.endTag(vtkFileTag::POINTS); .endTag(vtk::fileTag::POINTS);
} }
} }
void Foam::foamVtkOutput::lagrangianWriter::writeVertsLegacy() void Foam::vtk::lagrangianWriter::writeVertsLegacy()
{ {
os_ << "VERTICES " << nParcels_ << ' ' << 2*nParcels_ << nl; os_ << "VERTICES " << nParcels_ << ' ' << 2*nParcels_ << nl;
@ -107,9 +107,9 @@ void Foam::foamVtkOutput::lagrangianWriter::writeVertsLegacy()
} }
void Foam::foamVtkOutput::lagrangianWriter::writeVerts() void Foam::vtk::lagrangianWriter::writeVerts()
{ {
format().tag(vtkFileTag::VERTS); format().tag(vtk::fileTag::VERTS);
// Same payload throughout // Same payload throughout
const uint64_t payLoad = (nParcels_ * sizeof(label)); const uint64_t payLoad = (nParcels_ * sizeof(label));
@ -119,7 +119,7 @@ void Foam::foamVtkOutput::lagrangianWriter::writeVerts()
// = linear mapping onto points // = linear mapping onto points
// //
{ {
format().openDataArray<label>("connectivity") format().openDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY)
.closeTag(); .closeTag();
format().writeSize(payLoad); format().writeSize(payLoad);
@ -138,7 +138,7 @@ void Foam::foamVtkOutput::lagrangianWriter::writeVerts()
// = linear mapping onto points (with 1 offset) // = linear mapping onto points (with 1 offset)
// //
{ {
format().openDataArray<label>("offsets") format().openDataArray<label>(vtk::dataArrayAttr::OFFSETS)
.closeTag(); .closeTag();
format().writeSize(payLoad); format().writeSize(payLoad);
@ -151,18 +151,18 @@ void Foam::foamVtkOutput::lagrangianWriter::writeVerts()
format().endDataArray(); format().endDataArray();
} }
format().endTag(vtkFileTag::VERTS); format().endTag(vtk::fileTag::VERTS);
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter Foam::vtk::lagrangianWriter::lagrangianWriter
( (
const fvMesh& mesh, const fvMesh& mesh,
const word& cloudName, const word& cloudName,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const bool dummyCloud const bool dummyCloud
) )
: :
@ -185,7 +185,7 @@ Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter
if (legacy_) if (legacy_)
{ {
legacy::fileHeader(format(), title, vtkFileTag::POLY_DATA); legacy::fileHeader(format(), title, vtk::fileTag::POLY_DATA);
if (dummyCloud) if (dummyCloud)
{ {
@ -204,7 +204,7 @@ Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter
format() format()
.xmlHeader() .xmlHeader()
.xmlComment(title) .xmlComment(title)
.beginVTKFile(vtkFileTag::POLY_DATA, "0.1"); .beginVTKFile(vtk::fileTag::POLY_DATA, "0.1");
if (dummyCloud) if (dummyCloud)
{ {
@ -221,19 +221,19 @@ Foam::foamVtkOutput::lagrangianWriter::lagrangianWriter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::lagrangianWriter::~lagrangianWriter() Foam::vtk::lagrangianWriter::~lagrangianWriter()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::lagrangianWriter::beginParcelData(label nFields) void Foam::vtk::lagrangianWriter::beginParcelData(label nFields)
{ {
const vtkFileTag dataType = const vtk::fileTag dataType =
( (
useVerts_ useVerts_
? vtkFileTag::CELL_DATA ? vtk::fileTag::CELL_DATA
: vtkFileTag::POINT_DATA : vtk::fileTag::POINT_DATA
); );
if (legacy_) if (legacy_)
@ -247,13 +247,13 @@ void Foam::foamVtkOutput::lagrangianWriter::beginParcelData(label nFields)
} }
void Foam::foamVtkOutput::lagrangianWriter::endParcelData() void Foam::vtk::lagrangianWriter::endParcelData()
{ {
const vtkFileTag dataType = const vtk::fileTag dataType =
( (
useVerts_ useVerts_
? vtkFileTag::CELL_DATA ? vtk::fileTag::CELL_DATA
: vtkFileTag::POINT_DATA : vtk::fileTag::POINT_DATA
); );
if (!legacy_) if (!legacy_)
@ -263,14 +263,14 @@ void Foam::foamVtkOutput::lagrangianWriter::endParcelData()
} }
void Foam::foamVtkOutput::lagrangianWriter::writeFooter() void Foam::vtk::lagrangianWriter::writeFooter()
{ {
if (!legacy_) if (!legacy_)
{ {
// slight cheat. </Piece> too // slight cheat. </Piece> too
format().endTag(vtkFileTag::PIECE); format().endTag(vtk::fileTag::PIECE);
format().endTag(vtkFileTag::POLY_DATA) format().endTag(vtk::fileTag::POLY_DATA)
.endVTKFile(); .endVTKFile();
} }
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::lagrangianWriter Foam::vtk::lagrangianWriter
Description Description
Write fields (internal). Write fields (internal).
@ -48,7 +48,7 @@ namespace Foam
{ {
class volPointInterpolation; class volPointInterpolation;
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -68,7 +68,7 @@ class lagrangianWriter
//- Write lagrangian as cell data (verts) or point data? //- Write lagrangian as cell data (verts) or point data?
const bool useVerts_; const bool useVerts_;
autoPtr<foamVtkOutput::formatter> format_; autoPtr<vtk::formatter> format_;
const word cloudName_; const word cloudName_;
@ -109,7 +109,7 @@ public:
const fvMesh& mesh, const fvMesh& mesh,
const word& cloudName, const word& cloudName,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const bool dummyCloud = false const bool dummyCloud = false
); );
@ -125,7 +125,7 @@ public:
return os_; return os_;
} }
inline foamVtkOutput::formatter& format() inline vtk::formatter& format()
{ {
return format_(); return format_();
} }
@ -149,7 +149,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::foamVtkOutput::lagrangianWriter::writeIOField void Foam::vtk::lagrangianWriter::writeIOField
( (
const wordList& objectNames const wordList& objectNames
) )
@ -94,7 +94,7 @@ void Foam::foamVtkOutput::lagrangianWriter::writeIOField
} }
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), fld); vtk::writeList(format(), fld);
} }
format().flush(); format().flush();

View File

@ -119,7 +119,7 @@ vtkSmartPointer<vtkUnstructuredGrid> Foam::vtkPVFoam::volumeVTKMesh
printMemory(); printMemory();
} }
foamVtuSizing sizing(mesh, decompPoly); vtk::vtuSizing sizing(mesh, decompPoly);
auto cellTypes = vtkSmartPointer<vtkUnsignedCharArray>::New(); auto cellTypes = vtkSmartPointer<vtkUnsignedCharArray>::New();
@ -141,28 +141,28 @@ vtkSmartPointer<vtkUnstructuredGrid> Foam::vtkPVFoam::volumeVTKMesh
( (
cells, cells,
sizing.nFieldCells(), sizing.nFieldCells(),
sizing.sizeInternal(foamVtuSizing::slotType::CELLS) sizing.sizeInternal(vtk::vtuSizing::slotType::CELLS)
); );
UList<vtkIdType> cellLocationsUL = UList<vtkIdType> cellLocationsUL =
vtkUList vtkUList
( (
cellLocations, cellLocations,
sizing.sizeInternal(foamVtuSizing::slotType::CELLS_OFFSETS) sizing.sizeInternal(vtk::vtuSizing::slotType::CELLS_OFFSETS)
); );
UList<vtkIdType> facesUL = UList<vtkIdType> facesUL =
vtkUList vtkUList
( (
faces, faces,
sizing.sizeInternal(foamVtuSizing::slotType::FACES) sizing.sizeInternal(vtk::vtuSizing::slotType::FACES)
); );
UList<vtkIdType> faceLocationsUL = UList<vtkIdType> faceLocationsUL =
vtkUList vtkUList
( (
faceLocations, faceLocations,
sizing.sizeInternal(foamVtuSizing::slotType::FACES_OFFSETS) sizing.sizeInternal(vtk::vtuSizing::slotType::FACES_OFFSETS)
); );

View File

@ -29,8 +29,8 @@ vtk/output/foamVtkPatchWriter.H
vtk/output/foamVtkSurfaceMeshWriter.C vtk/output/foamVtkSurfaceMeshWriter.C
vtk/output/foamVtkWriteSurfFields.C vtk/output/foamVtkWriteSurfFields.C
vtk/part/foamVtkCells.C
vtk/part/foamVtkMeshMaps.C vtk/part/foamVtkMeshMaps.C
vtk/part/foamVtuCells.C
vtk/part/foamVtuSizing.C vtk/part/foamVtuSizing.C
LIB = $(FOAM_LIBBIN)/libconversion LIB = $(FOAM_LIBBIN)/libconversion

View File

@ -25,47 +25,46 @@ License
#include "foamVtkInternalWriter.H" #include "foamVtkInternalWriter.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::internalWriter::beginPiece() void Foam::vtk::internalWriter::beginPiece()
{ {
if (!legacy_) if (!legacy_)
{ {
format() format()
.openTag(vtkFileTag::PIECE) .openTag(vtk::fileTag::PIECE)
( "NumberOfPoints", vtkCells_.nFieldPoints() ) .xmlAttr(vtk::fileAttr::NUMBER_OF_POINTS, vtuCells_.nFieldPoints())
( "NumberOfCells", vtkCells_.nFieldCells() ) .xmlAttr(vtk::fileAttr::NUMBER_OF_CELLS, vtuCells_.nFieldCells())
.closeTag(); .closeTag();
} }
} }
void Foam::foamVtkOutput::internalWriter::writePoints() void Foam::vtk::internalWriter::writePoints()
{ {
// payload size // payload size
const uint64_t payLoad = (vtkCells_.nFieldPoints() * 3 * sizeof(float)); const uint64_t payLoad = (vtuCells_.nFieldPoints() * 3 * sizeof(float));
if (legacy_) if (legacy_)
{ {
legacy::beginPoints(os_, vtkCells_.nFieldPoints()); legacy::beginPoints(os_, vtuCells_.nFieldPoints());
} }
else else
{ {
format() format()
.tag(vtkFileTag::POINTS) .tag(vtk::fileTag::POINTS)
.openDataArray<float,3>(vtkFileTag::POINTS) .openDataArray<float,3>(vtk::dataArrayAttr::POINTS)
.closeTag(); .closeTag();
} }
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), mesh_.points()); vtk::writeList(format(), mesh_.points());
foamVtkOutput::writeList vtk::writeList
( (
format(), format(),
mesh_.cellCentres(), mesh_.cellCentres(),
vtkCells_.addPointCellLabels() vtuCells_.addPointCellLabels()
); );
format().flush(); format().flush();
@ -74,25 +73,25 @@ void Foam::foamVtkOutput::internalWriter::writePoints()
{ {
format() format()
.endDataArray() .endDataArray()
.endTag(vtkFileTag::POINTS); .endTag(vtk::fileTag::POINTS);
} }
} }
void Foam::foamVtkOutput::internalWriter::writeCellsLegacy() void Foam::vtk::internalWriter::writeCellsLegacy()
{ {
const List<uint8_t>& cellTypes = vtkCells_.cellTypes(); const List<uint8_t>& cellTypes = vtuCells_.cellTypes();
const labelList& vertLabels = vtkCells_.vertLabels(); const labelList& vertLabels = vtuCells_.vertLabels();
os_ << "CELLS " << vtkCells_.nFieldCells() << ' ' os_ << "CELLS " << vtuCells_.nFieldCells() << ' '
<< vertLabels.size() << nl; << vertLabels.size() << nl;
foamVtkOutput::writeList(format(), vertLabels); vtk::writeList(format(), vertLabels);
format().flush(); format().flush();
os_ << "CELL_TYPES " << cellTypes.size() << nl; os_ << "CELL_TYPES " << cellTypes.size() << nl;
// No nComponents for char, so cannot use foamVtkOutput::writeList // No nComponents for char, so cannot use vtk::writeList
forAll(cellTypes, i) forAll(cellTypes, i)
{ {
format().write(cellTypes[i]); format().write(cellTypes[i]);
@ -101,22 +100,22 @@ void Foam::foamVtkOutput::internalWriter::writeCellsLegacy()
} }
void Foam::foamVtkOutput::internalWriter::writeCells() void Foam::vtk::internalWriter::writeCells()
{ {
format().tag(vtkFileTag::CELLS); format().tag(vtk::fileTag::CELLS);
// //
// 'connectivity' // 'connectivity'
// //
{ {
const labelList& vertLabels = vtkCells_.vertLabels(); const labelList& vertLabels = vtuCells_.vertLabels();
const uint64_t payLoad = vertLabels.size() * sizeof(label); const uint64_t payLoad = vertLabels.size() * sizeof(label);
format().openDataArray<label>("connectivity") format().openDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY)
.closeTag(); .closeTag();
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), vertLabels); vtk::writeList(format(), vertLabels);
format().flush(); format().flush();
format().endDataArray(); format().endDataArray();
@ -127,14 +126,14 @@ void Foam::foamVtkOutput::internalWriter::writeCells()
// 'offsets' (connectivity offsets) // 'offsets' (connectivity offsets)
// //
{ {
const labelList& vertOffsets = vtkCells_.vertOffsets(); const labelList& vertOffsets = vtuCells_.vertOffsets();
const uint64_t payLoad = vertOffsets.size() * sizeof(label); const uint64_t payLoad = vertOffsets.size() * sizeof(label);
format().openDataArray<label>("offsets") format().openDataArray<label>(vtk::dataArrayAttr::OFFSETS)
.closeTag(); .closeTag();
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), vertOffsets); vtk::writeList(format(), vertOffsets);
format().flush(); format().flush();
format().endDataArray(); format().endDataArray();
@ -145,16 +144,16 @@ void Foam::foamVtkOutput::internalWriter::writeCells()
// 'types' (cell types) // 'types' (cell types)
// //
{ {
const List<uint8_t>& cellTypes = vtkCells_.cellTypes(); const List<uint8_t>& cellTypes = vtuCells_.cellTypes();
const uint64_t payLoad = cellTypes.size() * sizeof(uint8_t); const uint64_t payLoad = cellTypes.size() * sizeof(uint8_t);
format().openDataArray<uint8_t>("types") format().openDataArray<uint8_t>(vtk::dataArrayAttr::TYPES)
.closeTag(); .closeTag();
format().writeSize(payLoad); format().writeSize(payLoad);
forAll(cellTypes, i) forAll(cellTypes, i)
{ {
// No nComponents for char, cannot use foamVtkOutput::writeList here // No nComponents for char, cannot use vtk::writeList here
format().write(cellTypes[i]); format().write(cellTypes[i]);
} }
format().flush(); format().flush();
@ -166,9 +165,9 @@ void Foam::foamVtkOutput::internalWriter::writeCells()
// //
// can quit here if there are NO face streams // can quit here if there are NO face streams
// //
if (vtkCells_.faceLabels().empty()) if (vtuCells_.faceLabels().empty())
{ {
format().endTag(vtkFileTag::CELLS); format().endTag(vtk::fileTag::CELLS);
return; return;
} }
@ -180,14 +179,14 @@ void Foam::foamVtkOutput::internalWriter::writeCells()
// 'faces' (face streams) // 'faces' (face streams)
// //
{ {
const labelList& faceLabels = vtkCells_.faceLabels(); const labelList& faceLabels = vtuCells_.faceLabels();
const uint64_t payLoad = faceLabels.size() * sizeof(label); const uint64_t payLoad = faceLabels.size() * sizeof(label);
format().openDataArray<label>("faces") format().openDataArray<label>(vtk::dataArrayAttr::FACES)
.closeTag(); .closeTag();
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), faceLabels); vtk::writeList(format(), faceLabels);
format().flush(); format().flush();
format().endDataArray(); format().endDataArray();
@ -198,24 +197,24 @@ void Foam::foamVtkOutput::internalWriter::writeCells()
// -1 to indicate that the cell is a primitive type that does not // -1 to indicate that the cell is a primitive type that does not
// have a face stream // have a face stream
{ {
const labelList& faceOffsets = vtkCells_.faceOffsets(); const labelList& faceOffsets = vtuCells_.faceOffsets();
const uint64_t payLoad = faceOffsets.size() * sizeof(label); const uint64_t payLoad = faceOffsets.size() * sizeof(label);
format().openDataArray<label>("faceoffsets") format().openDataArray<label>(vtk::dataArrayAttr::FACEOFFSETS)
.closeTag(); .closeTag();
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), faceOffsets); vtk::writeList(format(), faceOffsets);
format().flush(); format().flush();
format().endDataArray(); format().endDataArray();
} }
format().endTag(vtkFileTag::CELLS); format().endTag(vtk::fileTag::CELLS);
} }
void Foam::foamVtkOutput::internalWriter::writeMesh() void Foam::vtk::internalWriter::writeMesh()
{ {
writePoints(); writePoints();
if (legacy_) if (legacy_)
@ -231,18 +230,18 @@ void Foam::foamVtkOutput::internalWriter::writeMesh()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::internalWriter::internalWriter Foam::vtk::internalWriter::internalWriter
( (
const fvMesh& mesh, const fvMesh& mesh,
const foamVtkCells& cells, const vtk::vtuCells& cells,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
) )
: :
mesh_(mesh), mesh_(mesh),
legacy_(outOpts.legacy()), legacy_(outOpts.legacy()),
format_(), format_(),
vtkCells_(cells), vtuCells_(cells),
os_() os_()
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
@ -255,7 +254,7 @@ Foam::foamVtkOutput::internalWriter::internalWriter
if (legacy_) if (legacy_)
{ {
legacy::fileHeader(format(), title, vtkFileTag::UNSTRUCTURED_GRID); legacy::fileHeader(format(), title, vtk::fileTag::UNSTRUCTURED_GRID);
} }
else else
{ {
@ -264,7 +263,7 @@ Foam::foamVtkOutput::internalWriter::internalWriter
format() format()
.xmlHeader() .xmlHeader()
.xmlComment(title) .xmlComment(title)
.beginVTKFile(vtkFileTag::UNSTRUCTURED_GRID, "0.1"); .beginVTKFile(vtk::fileTag::UNSTRUCTURED_GRID, "0.1");
} }
beginPiece(); beginPiece();
@ -274,91 +273,91 @@ Foam::foamVtkOutput::internalWriter::internalWriter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::internalWriter::~internalWriter() Foam::vtk::internalWriter::~internalWriter()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::internalWriter::beginCellData(label nFields) void Foam::vtk::internalWriter::beginCellData(label nFields)
{ {
if (legacy_) if (legacy_)
{ {
legacy::dataHeader legacy::dataHeader
( (
os(), os(),
vtkFileTag::CELL_DATA, vtk::fileTag::CELL_DATA,
vtkCells_.nFieldCells(), vtuCells_.nFieldCells(),
nFields nFields
); );
} }
else else
{ {
format().tag(vtkFileTag::CELL_DATA); format().tag(vtk::fileTag::CELL_DATA);
} }
} }
void Foam::foamVtkOutput::internalWriter::endCellData() void Foam::vtk::internalWriter::endCellData()
{ {
if (!legacy_) if (!legacy_)
{ {
format().endTag(vtkFileTag::CELL_DATA); format().endTag(vtk::fileTag::CELL_DATA);
} }
} }
void Foam::foamVtkOutput::internalWriter::beginPointData(label nFields) void Foam::vtk::internalWriter::beginPointData(label nFields)
{ {
if (legacy_) if (legacy_)
{ {
legacy::dataHeader legacy::dataHeader
( (
os(), os(),
vtkFileTag::POINT_DATA, vtk::fileTag::POINT_DATA,
vtkCells_.nFieldPoints(), vtuCells_.nFieldPoints(),
nFields nFields
); );
} }
else else
{ {
format().tag(vtkFileTag::POINT_DATA); format().tag(vtk::fileTag::POINT_DATA);
} }
} }
void Foam::foamVtkOutput::internalWriter::endPointData() void Foam::vtk::internalWriter::endPointData()
{ {
if (!legacy_) if (!legacy_)
{ {
format().endTag(vtkFileTag::POINT_DATA); format().endTag(vtk::fileTag::POINT_DATA);
} }
} }
void Foam::foamVtkOutput::internalWriter::writeFooter() void Foam::vtk::internalWriter::writeFooter()
{ {
if (!legacy_) if (!legacy_)
{ {
// slight cheat. </Piece> too // slight cheat. </Piece> too
format().endTag(vtkFileTag::PIECE); format().endTag(vtk::fileTag::PIECE);
format().endTag(vtkFileTag::UNSTRUCTURED_GRID) format().endTag(vtk::fileTag::UNSTRUCTURED_GRID)
.endVTKFile(); .endVTKFile();
} }
} }
void Foam::foamVtkOutput::internalWriter::writeCellIDs() void Foam::vtk::internalWriter::writeCellIDs()
{ {
// Cell ids first // Cell ids first
const labelList& cellMap = vtkCells_.cellMap(); const labelList& cellMap = vtuCells_.cellMap();
const uint64_t payLoad = vtkCells_.nFieldCells() * sizeof(label); const uint64_t payLoad = vtuCells_.nFieldCells() * sizeof(label);
if (legacy_) if (legacy_)
{ {
os_ << "cellID 1 " << vtkCells_.nFieldCells() << " int" << nl; os_ << "cellID 1 " << vtuCells_.nFieldCells() << " int" << nl;
} }
else else
{ {
@ -368,7 +367,7 @@ void Foam::foamVtkOutput::internalWriter::writeCellIDs()
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), cellMap); vtk::writeList(format(), cellMap);
format().flush(); format().flush();
if (!legacy_) if (!legacy_)

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::internalWriter Foam::vtk::internalWriter
Description Description
Write fields (internal). Write fields (internal).
@ -40,9 +40,9 @@ SourceFiles
#include "volFields.H" #include "volFields.H"
#include "pointFields.H" #include "pointFields.H"
#include "foamVtkCells.H"
#include "foamVtkOutputFields.H" #include "foamVtkOutputFields.H"
#include "foamVtkOutputOptions.H" #include "foamVtkOutputOptions.H"
#include "foamVtuCells.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,7 +50,7 @@ namespace Foam
{ {
class volPointInterpolation; class volPointInterpolation;
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -67,10 +67,10 @@ class internalWriter
//- Commonly used query //- Commonly used query
const bool legacy_; const bool legacy_;
autoPtr<foamVtkOutput::formatter> format_; autoPtr<vtk::formatter> format_;
//- The volume cells (internalMesh) //- The volume cells (internalMesh)
const foamVtkCells& vtkCells_; const vtuCells& vtuCells_;
std::ofstream os_; std::ofstream os_;
@ -108,9 +108,9 @@ public:
internalWriter internalWriter
( (
const fvMesh& mesh, const fvMesh& mesh,
const foamVtkCells& cells, const vtk::vtuCells& cells,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
); );
@ -125,7 +125,7 @@ public:
return os_; return os_;
} }
inline foamVtkOutput::formatter& format() inline vtk::formatter& format()
{ {
return format_(); return format_();
} }
@ -212,7 +212,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,12 +31,12 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::foamVtkOutput::internalWriter::write void Foam::vtk::internalWriter::write
( (
const UPtrList<const DimensionedField<Type, volMesh>>& flds const UPtrList<const DimensionedField<Type, volMesh>>& flds
) )
{ {
const labelList& cellMap = vtkCells_.cellMap(); const labelList& cellMap = vtuCells_.cellMap();
const int nCmpt(pTraits<Type>::nComponents); const int nCmpt(pTraits<Type>::nComponents);
// const uint64_t payLoad(cellMap.size() * nCmpt * sizeof(float)); // const uint64_t payLoad(cellMap.size() * nCmpt * sizeof(float));
@ -56,7 +56,7 @@ void Foam::foamVtkOutput::internalWriter::write
} }
// writeField includes payload size // writeField includes payload size
foamVtkOutput::writeField(format(), fld, cellMap); vtk::writeField(format(), fld, cellMap);
if (!legacy_) if (!legacy_)
{ {
@ -67,12 +67,12 @@ void Foam::foamVtkOutput::internalWriter::write
template<class Type, template<class> class PatchField> template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::internalWriter::write void Foam::vtk::internalWriter::write
( (
const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds
) )
{ {
const labelList& cellMap = vtkCells_.cellMap(); const labelList& cellMap = vtuCells_.cellMap();
const int nCmpt(pTraits<Type>::nComponents); const int nCmpt(pTraits<Type>::nComponents);
// const uint64_t payLoad(cellMap.size() * nCmpt * sizeof(float)); // const uint64_t payLoad(cellMap.size() * nCmpt * sizeof(float));
@ -92,7 +92,7 @@ void Foam::foamVtkOutput::internalWriter::write
} }
// writeField includes payload size // writeField includes payload size
foamVtkOutput::writeField(format(), fld, cellMap); vtk::writeField(format(), fld, cellMap);
if (!legacy_) if (!legacy_)
{ {
@ -103,15 +103,15 @@ void Foam::foamVtkOutput::internalWriter::write
template<class Type, template<class> class PatchField> template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::internalWriter::write void Foam::vtk::internalWriter::write
( (
const UPtrList<const GeometricField<Type, PatchField, pointMesh>>& flds const UPtrList<const GeometricField<Type, PatchField, pointMesh>>& flds
) )
{ {
const labelList& addPointCellLabels = vtkCells_.addPointCellLabels(); const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
const int nCmpt(pTraits<Type>::nComponents); const int nCmpt(pTraits<Type>::nComponents);
const int nVals(vtkCells_.nFieldPoints()); const int nVals(vtuCells_.nFieldPoints());
// Only needed for non-legacy // Only needed for non-legacy
const uint64_t payLoad(nVals * nCmpt * sizeof(float)); const uint64_t payLoad(nVals * nCmpt * sizeof(float));
@ -131,12 +131,12 @@ void Foam::foamVtkOutput::internalWriter::write
} }
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), fld); vtk::writeList(format(), fld);
forAll(addPointCellLabels, i) forAll(addPointCellLabels, i)
{ {
const Type val = interpolatePointToCell(fld, addPointCellLabels[i]); const Type val = interpolatePointToCell(fld, addPointCellLabels[i]);
foamVtkOutput::write(format(), val); vtk::write(format(), val);
} }
format().flush(); format().flush();
@ -150,16 +150,16 @@ void Foam::foamVtkOutput::internalWriter::write
template<class Type> template<class Type>
void Foam::foamVtkOutput::internalWriter::write void Foam::vtk::internalWriter::write
( (
const volPointInterpolation& pInterp, const volPointInterpolation& pInterp,
const UPtrList<const DimensionedField<Type, volMesh>>& flds const UPtrList<const DimensionedField<Type, volMesh>>& flds
) )
{ {
const labelList& addPointCellLabels = vtkCells_.addPointCellLabels(); const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
const int nCmpt(pTraits<Type>::nComponents); const int nCmpt(pTraits<Type>::nComponents);
const int nVals(vtkCells_.nFieldPoints()); const int nVals(vtuCells_.nFieldPoints());
// Only needed for non-legacy // Only needed for non-legacy
const uint64_t payLoad(nVals * nCmpt * sizeof(float)); const uint64_t payLoad(nVals * nCmpt * sizeof(float));
@ -180,8 +180,8 @@ void Foam::foamVtkOutput::internalWriter::write
} }
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), pfield); vtk::writeList(format(), pfield);
foamVtkOutput::writeList(format(), vfield, addPointCellLabels); vtk::writeList(format(), vfield, addPointCellLabels);
format().flush(); format().flush();
if (!legacy_) if (!legacy_)
@ -193,16 +193,16 @@ void Foam::foamVtkOutput::internalWriter::write
template<class Type, template<class> class PatchField> template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::internalWriter::write void Foam::vtk::internalWriter::write
( (
const volPointInterpolation& pInterp, const volPointInterpolation& pInterp,
const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds
) )
{ {
const labelList& addPointCellLabels = vtkCells_.addPointCellLabels(); const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
const int nCmpt(pTraits<Type>::nComponents); const int nCmpt(pTraits<Type>::nComponents);
const int nVals(vtkCells_.nFieldPoints()); const int nVals(vtuCells_.nFieldPoints());
// Only needed for non-legacy // Only needed for non-legacy
const uint64_t payLoad(nVals * nCmpt * sizeof(float)); const uint64_t payLoad(nVals * nCmpt * sizeof(float));
@ -223,8 +223,8 @@ void Foam::foamVtkOutput::internalWriter::write
} }
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), pfield); vtk::writeList(format(), pfield);
foamVtkOutput::writeList(format(), vfield, addPointCellLabels); vtk::writeList(format(), vfield, addPointCellLabels);
format().flush(); format().flush();
if (!legacy_) if (!legacy_)

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamespace InNamespace
Foam::foamVtkOutput Foam::vtk
Description Description
Additional functions for writing fields in VTK format. Additional functions for writing fields in VTK format.
@ -42,36 +42,17 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Write internalField for mesh
// The output includes the payload size and flush.
template<class Type>
void writeField
(
foamVtkOutput::formatter& fmt,
const GeometricField<Type, fvPatchField, volMesh>& fld
);
//- Write internalField based on the cellMap
// The output includes the payload size and flush.
template<class Type>
void writeField
(
foamVtkOutput::formatter& fmt,
const GeometricField<Type, fvPatchField, volMesh>& fld,
const UList<label>& cellMap
);
//- Write DimensionedField for mesh //- Write DimensionedField for mesh
// The output includes the payload size and flush. // The output includes the payload size and flush.
template<class Type> template<class Type>
void writeField void writeField
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const DimensionedField<Type, volMesh>& fld const DimensionedField<Type, volMesh>& fld
); );
@ -80,15 +61,34 @@ namespace foamVtkOutput
template<class Type> template<class Type>
void writeField void writeField
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const DimensionedField<Type, volMesh>& fld, const DimensionedField<Type, volMesh>& fld,
const UList<label>& cellMap const UList<label>& cellMap
); );
//- Write internalField for mesh
// The output includes the payload size and flush.
template<class Type>
void writeField
(
vtk::formatter& fmt,
const GeometricField<Type, fvPatchField, volMesh>& fld
);
//- Write internalField based on the cellMap
// The output includes the payload size and flush.
template<class Type>
void writeField
(
vtk::formatter& fmt,
const GeometricField<Type, fvPatchField, volMesh>& fld,
const UList<label>& cellMap
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam

View File

@ -25,49 +25,11 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::foamVtkOutput::writeField
(
foamVtkOutput::formatter& fmt,
const GeometricField<Type, fvPatchField, volMesh>& fld
)
{
const uint64_t payLoad =
(
fld.size() * pTraits<Type>::nComponents * sizeof(float)
);
fmt.writeSize(payLoad);
writeList(fmt, fld.internalField());
fmt.flush();
}
template<class Type> template<class Type>
void Foam::foamVtkOutput::writeField void Foam::vtk::writeField
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const GeometricField<Type, fvPatchField, volMesh>& fld,
const UList<label>& cellMap
)
{
const uint64_t payLoad =
(
cellMap.size() * pTraits<Type>::nComponents * sizeof(float)
);
fmt.writeSize(payLoad);
writeList(fmt, fld.internalField(), cellMap);
fmt.flush();
}
template<class Type>
void Foam::foamVtkOutput::writeField
(
foamVtkOutput::formatter& fmt,
const DimensionedField<Type, volMesh>& fld const DimensionedField<Type, volMesh>& fld
) )
{ {
@ -84,9 +46,9 @@ void Foam::foamVtkOutput::writeField
template<class Type> template<class Type>
void Foam::foamVtkOutput::writeField void Foam::vtk::writeField
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const DimensionedField<Type, volMesh>& fld, const DimensionedField<Type, volMesh>& fld,
const UList<label>& cellMap const UList<label>& cellMap
) )
@ -103,4 +65,43 @@ void Foam::foamVtkOutput::writeField
} }
template<class Type>
void Foam::vtk::writeField
(
vtk::formatter& fmt,
const GeometricField<Type, fvPatchField, volMesh>& fld
)
{
const uint64_t payLoad =
(
fld.size() * pTraits<Type>::nComponents * sizeof(float)
);
fmt.writeSize(payLoad);
writeList(fmt, fld.internalField());
fmt.flush();
}
template<class Type>
void Foam::vtk::writeField
(
vtk::formatter& fmt,
const GeometricField<Type, fvPatchField, volMesh>& fld,
const UList<label>& cellMap
)
{
const uint64_t payLoad =
(
cellMap.size() * pTraits<Type>::nComponents * sizeof(float)
);
fmt.writeSize(payLoad);
writeList(fmt, fld.internalField(), cellMap);
fmt.flush();
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,25 +29,24 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::patchWriter::beginPiece() void Foam::vtk::patchWriter::beginPiece()
{ {
if (!legacy_) if (!legacy_)
{ {
format() format()
.openTag(vtkFileTag::PIECE) .openTag(vtk::fileTag::PIECE)
( "NumberOfPoints", nPoints_ ) .xmlAttr(vtk::fileAttr::NUMBER_OF_POINTS, nPoints_)
( "NumberOfPolys", nFaces_ ) .xmlAttr(vtk::fileAttr::NUMBER_OF_POLYS, nFaces_)
.closeTag(); .closeTag();
} }
} }
void Foam::foamVtkOutput::patchWriter::writePoints() void Foam::vtk::patchWriter::writePoints()
{ {
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// payload count const uint64_t payLoad = (nPoints_*3*sizeof(float));
const uint64_t payLoad = (nPoints_*3* sizeof(float));
if (legacy_) if (legacy_)
{ {
@ -55,8 +54,8 @@ void Foam::foamVtkOutput::patchWriter::writePoints()
} }
else else
{ {
format().tag(vtkFileTag::POINTS) format().tag(vtk::fileTag::POINTS)
.openDataArray<float, 3>(vtkFileTag::POINTS) .openDataArray<float, 3>(vtk::dataArrayAttr::POINTS)
.closeTag(); .closeTag();
} }
@ -66,7 +65,7 @@ void Foam::foamVtkOutput::patchWriter::writePoints()
{ {
const polyPatch& pp = patches[patchIDs_[i]]; const polyPatch& pp = patches[patchIDs_[i]];
foamVtkOutput::writeList(format(), pp.localPoints()); vtk::writeList(format(), pp.localPoints());
} }
format().flush(); format().flush();
@ -74,12 +73,12 @@ void Foam::foamVtkOutput::patchWriter::writePoints()
{ {
format() format()
.endDataArray() .endDataArray()
.endTag(vtkFileTag::POINTS); .endTag(vtk::fileTag::POINTS);
} }
} }
void Foam::foamVtkOutput::patchWriter::writePolysLegacy() void Foam::vtk::patchWriter::writePolysLegacy()
{ {
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
@ -123,7 +122,7 @@ void Foam::foamVtkOutput::patchWriter::writePolysLegacy()
} }
void Foam::foamVtkOutput::patchWriter::writePolys() void Foam::vtk::patchWriter::writePolys()
{ {
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
@ -131,7 +130,7 @@ void Foam::foamVtkOutput::patchWriter::writePolys()
// 'connectivity' // 'connectivity'
// //
format().tag(vtkFileTag::POLYS); format().tag(vtk::fileTag::POLYS);
// //
// 'connectivity' // 'connectivity'
@ -150,7 +149,7 @@ void Foam::foamVtkOutput::patchWriter::writePolys()
} }
} }
format().openDataArray<label>("connectivity") format().openDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY)
.closeTag(); .closeTag();
// payload size // payload size
@ -185,7 +184,7 @@ void Foam::foamVtkOutput::patchWriter::writePolys()
// //
{ {
format() format()
.openDataArray<label>("offsets") .openDataArray<label>(vtk::dataArrayAttr::OFFSETS)
.closeTag(); .closeTag();
// payload size // payload size
@ -208,11 +207,11 @@ void Foam::foamVtkOutput::patchWriter::writePolys()
format().endDataArray(); format().endDataArray();
} }
format().endTag(vtkFileTag::POLYS); format().endTag(vtk::fileTag::POLYS);
} }
void Foam::foamVtkOutput::patchWriter::writeMesh() void Foam::vtk::patchWriter::writeMesh()
{ {
writePoints(); writePoints();
if (legacy_) if (legacy_)
@ -228,11 +227,11 @@ void Foam::foamVtkOutput::patchWriter::writeMesh()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::patchWriter::patchWriter Foam::vtk::patchWriter::patchWriter
( (
const fvMesh& mesh, const fvMesh& mesh,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const bool nearCellValue, const bool nearCellValue,
const labelList& patchIDs const labelList& patchIDs
) )
@ -274,7 +273,7 @@ Foam::foamVtkOutput::patchWriter::patchWriter
if (legacy_) if (legacy_)
{ {
legacy::fileHeader(format(), title, vtkFileTag::POLY_DATA); legacy::fileHeader(format(), title, vtk::fileTag::POLY_DATA);
} }
else else
{ {
@ -283,7 +282,7 @@ Foam::foamVtkOutput::patchWriter::patchWriter
format() format()
.xmlHeader() .xmlHeader()
.xmlComment(title) .xmlComment(title)
.beginVTKFile(vtkFileTag::POLY_DATA, "0.1"); .beginVTKFile(vtk::fileTag::POLY_DATA, "0.1");
} }
beginPiece(); beginPiece();
@ -293,82 +292,82 @@ Foam::foamVtkOutput::patchWriter::patchWriter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::patchWriter::~patchWriter() Foam::vtk::patchWriter::~patchWriter()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::patchWriter::beginCellData(label nFields) void Foam::vtk::patchWriter::beginCellData(label nFields)
{ {
if (legacy_) if (legacy_)
{ {
legacy::dataHeader legacy::dataHeader
( (
os(), os(),
vtkFileTag::CELL_DATA, vtk::fileTag::CELL_DATA,
nFaces_, nFaces_,
nFields nFields
); );
} }
else else
{ {
format().tag(vtkFileTag::CELL_DATA); format().tag(vtk::fileTag::CELL_DATA);
} }
} }
void Foam::foamVtkOutput::patchWriter::endCellData() void Foam::vtk::patchWriter::endCellData()
{ {
if (!legacy_) if (!legacy_)
{ {
format().endTag(vtkFileTag::CELL_DATA); format().endTag(vtk::fileTag::CELL_DATA);
} }
} }
void Foam::foamVtkOutput::patchWriter::beginPointData(label nFields) void Foam::vtk::patchWriter::beginPointData(label nFields)
{ {
if (legacy_) if (legacy_)
{ {
legacy::dataHeader legacy::dataHeader
( (
os(), os(),
vtkFileTag::POINT_DATA, vtk::fileTag::POINT_DATA,
nPoints_, nPoints_,
nFields nFields
); );
} }
else else
{ {
format().tag(vtkFileTag::POINT_DATA); format().tag(vtk::fileTag::POINT_DATA);
} }
} }
void Foam::foamVtkOutput::patchWriter::endPointData() void Foam::vtk::patchWriter::endPointData()
{ {
if (!legacy_) if (!legacy_)
{ {
format().endTag(vtkFileTag::POINT_DATA); format().endTag(vtk::fileTag::POINT_DATA);
} }
} }
void Foam::foamVtkOutput::patchWriter::writeFooter() void Foam::vtk::patchWriter::writeFooter()
{ {
if (!legacy_) if (!legacy_)
{ {
// slight cheat. </Piece> too // slight cheat. </Piece> too
format().endTag(vtkFileTag::PIECE); format().endTag(vtk::fileTag::PIECE);
format().endTag(vtkFileTag::POLY_DATA) format().endTag(vtk::fileTag::POLY_DATA)
.endVTKFile(); .endVTKFile();
} }
} }
void Foam::foamVtkOutput::patchWriter::writePatchIDs() void Foam::vtk::patchWriter::writePatchIDs()
{ {
// Patch ids first // Patch ids first
const uint64_t payLoad = nFaces_ * sizeof(label); const uint64_t payLoad = nFaces_ * sizeof(label);

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::patchWriter Foam::vtk::patchWriter
Description Description
Write patch fields Write patch fields
@ -50,7 +50,7 @@ namespace Foam
{ {
class volPointInterpolation; class volPointInterpolation;
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -67,7 +67,7 @@ class patchWriter
//- Commonly used query //- Commonly used query
const bool legacy_; const bool legacy_;
autoPtr<foamVtkOutput::formatter> format_; autoPtr<vtk::formatter> format_;
const bool nearCellValue_; const bool nearCellValue_;
@ -114,7 +114,7 @@ public:
( (
const fvMesh& mesh, const fvMesh& mesh,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const bool nearCellValue, const bool nearCellValue,
const labelList& patchIDs const labelList& patchIDs
); );
@ -131,7 +131,7 @@ public:
return os_; return os_;
} }
inline foamVtkOutput::formatter& format() inline vtk::formatter& format()
{ {
return format_(); return format_();
} }
@ -202,7 +202,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField> template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::patchWriter::write void Foam::vtk::patchWriter::write
( (
const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds const UPtrList<const GeometricField<Type, PatchField, volMesh>>& flds
) )
@ -59,11 +59,11 @@ void Foam::foamVtkOutput::patchWriter::write
if (nearCellValue_) if (nearCellValue_)
{ {
foamVtkOutput::writeList(format(), pfld.patchInternalField()()); vtk::writeList(format(), pfld.patchInternalField()());
} }
else else
{ {
foamVtkOutput::writeList(format(), pfld); vtk::writeList(format(), pfld);
} }
} }
@ -78,7 +78,7 @@ void Foam::foamVtkOutput::patchWriter::write
template<class Type, template<class> class PatchField> template<class Type, template<class> class PatchField>
void Foam::foamVtkOutput::patchWriter::write void Foam::vtk::patchWriter::write
( (
const UPtrList<const GeometricField<Type, PatchField, pointMesh>>& flds const UPtrList<const GeometricField<Type, PatchField, pointMesh>>& flds
) )
@ -106,7 +106,7 @@ void Foam::foamVtkOutput::patchWriter::write
{ {
const auto& pfld = fld.boundaryField()[patchIDs_[i]]; const auto& pfld = fld.boundaryField()[patchIDs_[i]];
foamVtkOutput::writeList(format(), pfld.patchInternalField()()); vtk::writeList(format(), pfld.patchInternalField()());
} }
format().flush(); format().flush();
@ -120,7 +120,7 @@ void Foam::foamVtkOutput::patchWriter::write
template<class Type> template<class Type>
void Foam::foamVtkOutput::patchWriter::write void Foam::vtk::patchWriter::write
( (
const PrimitivePatchInterpolation<primitivePatch>& pInter, const PrimitivePatchInterpolation<primitivePatch>& pInter,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
@ -154,13 +154,13 @@ void Foam::foamVtkOutput::patchWriter::write
auto tfield = auto tfield =
pInter.faceToPointInterpolate(pfld.patchInternalField()()); pInter.faceToPointInterpolate(pfld.patchInternalField()());
foamVtkOutput::writeList(format(), tfield()); vtk::writeList(format(), tfield());
} }
else else
{ {
auto tfield = pInter.faceToPointInterpolate(pfld); auto tfield = pInter.faceToPointInterpolate(pfld);
foamVtkOutput::writeList(format(), tfield()); vtk::writeList(format(), tfield());
} }
} }

View File

@ -29,22 +29,21 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::surfaceMeshWriter::beginPiece() void Foam::vtk::surfaceMeshWriter::beginPiece()
{ {
if (!legacy_) if (!legacy_)
{ {
format() format()
.openTag(vtkFileTag::PIECE) .openTag(vtk::fileTag::PIECE)
( "NumberOfPoints", pp_.nPoints() ) .xmlAttr(vtk::fileAttr::NUMBER_OF_POINTS, pp_.nPoints())
( "NumberOfPolys", pp_.size() ) .xmlAttr(vtk::fileAttr::NUMBER_OF_POLYS, pp_.size())
.closeTag(); .closeTag();
} }
} }
void Foam::foamVtkOutput::surfaceMeshWriter::writePoints() void Foam::vtk::surfaceMeshWriter::writePoints()
{ {
// payload count
const uint64_t payLoad = (pp_.nPoints()*3*sizeof(float)); const uint64_t payLoad = (pp_.nPoints()*3*sizeof(float));
if (legacy_) if (legacy_)
@ -53,26 +52,26 @@ void Foam::foamVtkOutput::surfaceMeshWriter::writePoints()
} }
else else
{ {
format().tag(vtkFileTag::POINTS) format().tag(vtk::fileTag::POINTS)
.openDataArray<float, 3>(vtkFileTag::POINTS) .openDataArray<float, 3>(vtk::dataArrayAttr::POINTS)
.closeTag(); .closeTag();
} }
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), pp_.localPoints()); vtk::writeList(format(), pp_.localPoints());
format().flush(); format().flush();
if (!legacy_) if (!legacy_)
{ {
format() format()
.endDataArray() .endDataArray()
.endTag(vtkFileTag::POINTS); .endTag(vtk::fileTag::POINTS);
} }
} }
void Foam::foamVtkOutput::surfaceMeshWriter::writePolysLegacy() void Foam::vtk::surfaceMeshWriter::writePolysLegacy()
{ {
// connectivity count without additional storage (done internally) // connectivity count without additional storage (done internally)
uint64_t nConnectivity = 0; uint64_t nConnectivity = 0;
@ -92,20 +91,20 @@ void Foam::foamVtkOutput::surfaceMeshWriter::writePolysLegacy()
const face& f = pp_.localFaces()[facei]; const face& f = pp_.localFaces()[facei];
format().write(f.size()); // The size prefix format().write(f.size()); // The size prefix
foamVtkOutput::writeList(format(), f); vtk::writeList(format(), f);
} }
format().flush(); format().flush();
} }
void Foam::foamVtkOutput::surfaceMeshWriter::writePolys() void Foam::vtk::surfaceMeshWriter::writePolys()
{ {
// //
// 'connectivity' // 'connectivity'
// //
format().tag(vtkFileTag::POLYS); format().tag(vtk::fileTag::POLYS);
// //
// 'connectivity' // 'connectivity'
@ -118,7 +117,7 @@ void Foam::foamVtkOutput::surfaceMeshWriter::writePolys()
payLoad += pp_[facei].size(); payLoad += pp_[facei].size();
} }
format().openDataArray<label>("connectivity") format().openDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY)
.closeTag(); .closeTag();
// payload size // payload size
@ -127,7 +126,7 @@ void Foam::foamVtkOutput::surfaceMeshWriter::writePolys()
forAll(pp_, facei) forAll(pp_, facei)
{ {
const face& f = pp_.localFaces()[facei]; const face& f = pp_.localFaces()[facei];
foamVtkOutput::writeList(format(), f); vtk::writeList(format(), f);
} }
format().flush(); format().flush();
@ -142,7 +141,7 @@ void Foam::foamVtkOutput::surfaceMeshWriter::writePolys()
// //
{ {
format() format()
.openDataArray<label>("offsets") .openDataArray<label>(vtk::dataArrayAttr::OFFSETS)
.closeTag(); .closeTag();
// payload size // payload size
@ -160,11 +159,11 @@ void Foam::foamVtkOutput::surfaceMeshWriter::writePolys()
format().endDataArray(); format().endDataArray();
} }
format().endTag(vtkFileTag::POLYS); format().endTag(vtk::fileTag::POLYS);
} }
void Foam::foamVtkOutput::surfaceMeshWriter::writeMesh() void Foam::vtk::surfaceMeshWriter::writeMesh()
{ {
writePoints(); writePoints();
if (legacy_) if (legacy_)
@ -180,12 +179,12 @@ void Foam::foamVtkOutput::surfaceMeshWriter::writeMesh()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::surfaceMeshWriter::surfaceMeshWriter Foam::vtk::surfaceMeshWriter::surfaceMeshWriter
( (
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const word& name, const word& name,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
) )
: :
pp_(pp), pp_(pp),
@ -201,7 +200,7 @@ Foam::foamVtkOutput::surfaceMeshWriter::surfaceMeshWriter
if (legacy_) if (legacy_)
{ {
legacy::fileHeader(format(), name, vtkFileTag::POLY_DATA); legacy::fileHeader(format(), name, vtk::fileTag::POLY_DATA);
} }
else else
{ {
@ -210,7 +209,7 @@ Foam::foamVtkOutput::surfaceMeshWriter::surfaceMeshWriter
format() format()
.xmlHeader() .xmlHeader()
.xmlComment(name) .xmlComment(name)
.beginVTKFile(vtkFileTag::POLY_DATA, "0.1"); .beginVTKFile(vtk::fileTag::POLY_DATA, "0.1");
} }
@ -221,42 +220,42 @@ Foam::foamVtkOutput::surfaceMeshWriter::surfaceMeshWriter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::surfaceMeshWriter::~surfaceMeshWriter() Foam::vtk::surfaceMeshWriter::~surfaceMeshWriter()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::surfaceMeshWriter::beginCellData(label nFields) void Foam::vtk::surfaceMeshWriter::beginCellData(label nFields)
{ {
if (legacy_) if (legacy_)
{ {
legacy::dataHeader(os(), vtkFileTag::CELL_DATA, pp_.size(), nFields); legacy::dataHeader(os(), vtk::fileTag::CELL_DATA, pp_.size(), nFields);
} }
else else
{ {
format().tag(vtkFileTag::CELL_DATA); format().tag(vtk::fileTag::CELL_DATA);
} }
} }
void Foam::foamVtkOutput::surfaceMeshWriter::endCellData() void Foam::vtk::surfaceMeshWriter::endCellData()
{ {
if (!legacy_) if (!legacy_)
{ {
format().endTag(vtkFileTag::CELL_DATA); format().endTag(vtk::fileTag::CELL_DATA);
} }
} }
void Foam::foamVtkOutput::surfaceMeshWriter::writeFooter() void Foam::vtk::surfaceMeshWriter::writeFooter()
{ {
if (!legacy_) if (!legacy_)
{ {
// slight cheat. </Piece> too // slight cheat. </Piece> too
format().endTag(vtkFileTag::PIECE); format().endTag(vtk::fileTag::PIECE);
format().endTag(vtkFileTag::POLY_DATA) format().endTag(vtk::fileTag::POLY_DATA)
.endVTKFile(); .endVTKFile();
} }
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::surfaceMeshWriter Foam::vtk::surfaceMeshWriter
Description Description
Write faces with fields Write faces with fields
@ -49,7 +49,7 @@ namespace Foam
{ {
class volPointInterpolation; class volPointInterpolation;
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -65,7 +65,7 @@ class surfaceMeshWriter
//- Commonly used query //- Commonly used query
const bool legacy_; const bool legacy_;
autoPtr<foamVtkOutput::formatter> format_; autoPtr<vtk::formatter> format_;
std::ofstream os_; std::ofstream os_;
@ -104,7 +104,7 @@ public:
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const word& name, const word& name,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
); );
@ -119,7 +119,7 @@ public:
return os_; return os_;
} }
inline foamVtkOutput::formatter& format() inline vtk::formatter& format()
{ {
return format_(); return format_();
} }
@ -156,7 +156,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -29,7 +29,7 @@ License
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::tmp<Foam::Field<Type>>
Foam::foamVtkOutput::surfaceMeshWriter::getFaceField Foam::vtk::surfaceMeshWriter::getFaceField
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld
) const ) const
@ -60,7 +60,7 @@ Foam::foamVtkOutput::surfaceMeshWriter::getFaceField
template<class Type> template<class Type>
void Foam::foamVtkOutput::surfaceMeshWriter::write void Foam::vtk::surfaceMeshWriter::write
( (
const UPtrList const UPtrList
< <
@ -86,7 +86,7 @@ void Foam::foamVtkOutput::surfaceMeshWriter::write
} }
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), getFaceField(fld)()); vtk::writeList(format(), getFaceField(fld)());
format().flush(); format().flush();

View File

@ -32,11 +32,11 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::writeSurfFields void Foam::vtk::writeSurfFields
( (
const fvMesh& mesh, const fvMesh& mesh,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const UPtrList<const surfaceVectorField>& surfVectorFields const UPtrList<const surfaceVectorField>& surfVectorFields
) )
{ {
@ -46,7 +46,7 @@ void Foam::foamVtkOutput::writeSurfFields
const bool legacy_(opts.legacy()); const bool legacy_(opts.legacy());
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str()); std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os); autoPtr<vtk::formatter> format = opts.newFormatter(os);
// Same payload size for points and vector fields! // Same payload size for points and vector fields!
const int nCmpt(3); // vector const int nCmpt(3); // vector
@ -54,7 +54,7 @@ void Foam::foamVtkOutput::writeSurfFields
if (legacy_) if (legacy_)
{ {
legacy::fileHeader(format(), "surfaceFields", vtkFileTag::POLY_DATA); legacy::fileHeader(format(), "surfaceFields", vtk::fileTag::POLY_DATA);
legacy::beginPoints(os, mesh.nFaces()); legacy::beginPoints(os, mesh.nFaces());
} }
else else
@ -64,30 +64,30 @@ void Foam::foamVtkOutput::writeSurfFields
format() format()
.xmlHeader() .xmlHeader()
.xmlComment("surfaceFields") .xmlComment("surfaceFields")
.beginVTKFile(vtkFileTag::POLY_DATA, "0.1"); .beginVTKFile(vtk::fileTag::POLY_DATA, "0.1");
// Tricky - hide in beginPiece() // Tricky - hide in beginPiece()
format() format()
.openTag(vtkFileTag::PIECE) .openTag(vtk::fileTag::PIECE)
( "NumberOfPoints", mesh.nFaces() ) .xmlAttr(vtk::fileAttr::NUMBER_OF_POINTS, mesh.nFaces())
.closeTag(); .closeTag();
format().tag(vtkFileTag::POINTS) format().tag(vtk::fileTag::POINTS)
.openDataArray<float,3>(vtkFileTag::POINTS) .openDataArray<float,3>(vtk::dataArrayAttr::POINTS)
.closeTag(); .closeTag();
} }
const pointField& fc = mesh.faceCentres(); const pointField& fc = mesh.faceCentres();
format().writeSize(payLoad); format().writeSize(payLoad);
foamVtkOutput::writeList(format(), fc); vtk::writeList(format(), fc);
format().flush(); format().flush();
if (!legacy_) if (!legacy_)
{ {
format() format()
.endDataArray() .endDataArray()
.endTag(vtkFileTag::POINTS); .endTag(vtk::fileTag::POINTS);
} }
@ -97,14 +97,14 @@ void Foam::foamVtkOutput::writeSurfFields
legacy::dataHeader legacy::dataHeader
( (
os, os,
vtkFileTag::POINT_DATA, vtk::fileTag::POINT_DATA,
mesh.nFaces(), mesh.nFaces(),
surfVectorFields.size() surfVectorFields.size()
); );
} }
else else
{ {
format().tag(vtkFileTag::POINT_DATA); format().tag(vtk::fileTag::POINT_DATA);
} }
// surfVectorFields // surfVectorFields
@ -126,7 +126,7 @@ void Foam::foamVtkOutput::writeSurfFields
for (label facei=0; facei < mesh.nInternalFaces(); ++facei) for (label facei=0; facei < mesh.nInternalFaces(); ++facei)
{ {
foamVtkOutput::write(format(), fld[facei]); vtk::write(format(), fld[facei]);
} }
forAll(fld.boundaryField(), patchi) forAll(fld.boundaryField(), patchi)
@ -139,12 +139,12 @@ void Foam::foamVtkOutput::writeSurfFields
// Note: loop over polypatch size, not fvpatch size. // Note: loop over polypatch size, not fvpatch size.
forAll(pp.patch(), i) forAll(pp.patch(), i)
{ {
foamVtkOutput::write(format(), vector::zero); vtk::write(format(), vector::zero);
} }
} }
else else
{ {
foamVtkOutput::writeList(format(), pf); vtk::writeList(format(), pf);
} }
} }
@ -158,12 +158,12 @@ void Foam::foamVtkOutput::writeSurfFields
if (!legacy_) if (!legacy_)
{ {
format().endTag(vtkFileTag::POINT_DATA); format().endTag(vtk::fileTag::POINT_DATA);
// slight cheat. </Piece> too // slight cheat. </Piece> too
format().endTag(vtkFileTag::PIECE); format().endTag(vtk::fileTag::PIECE);
format().endTag(vtkFileTag::POLY_DATA) format().endTag(vtk::fileTag::POLY_DATA)
.endVTKFile(); .endVTKFile();
} }
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamespace InNamespace
Foam::foamVtkOutput Foam::vtk
Description Description
Write surface fields as vectors Write surface fields as vectors
@ -44,7 +44,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
//- Write surface vector fields //- Write surface vector fields
@ -52,11 +52,11 @@ void writeSurfFields
( (
const fvMesh& mesh, const fvMesh& mesh,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const UPtrList<const surfaceVectorField>& surfVectorFields const UPtrList<const surfaceVectorField>& surfVectorFields
); );
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam

View File

@ -26,6 +26,8 @@ Class
Description Description
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Bookkeeping for mesh subsetting and/or polyhedral cell decomposition.
Although the main use case is for handling vtk meshes, it is not specific
to VTK alone.
The cellMap is a local-to-global lookup for normal and decomposed cells. The cellMap is a local-to-global lookup for normal and decomposed cells.
The pointMap is an optional local-to-global lookup for point ids. The pointMap is an optional local-to-global lookup for point ids.
@ -101,17 +103,19 @@ public:
//- Clear //- Clear
inline void clear(); inline void clear();
//- Renumber cell ids to account for subset meshes //- Renumber cell ids (cellMap and additionalIds) to account for
// subset meshes
void renumberCells(const UList<label>& mapping); void renumberCells(const UList<label>& mapping);
//- Renumber point ids to account for subset meshes //- Renumber point ids (pointMap) to account for subset meshes
void renumberPoints(const UList<label>& mapping); void renumberPoints(const UList<label>& mapping);
//- Original cell ids for all cells (regular and decomposed). //- Original cell ids for all cells (regular and decomposed).
// A regular mesh comprising only primitive cell types, this will just // For a regular mesh comprising only primitive cell types, this
// be an identity list. However, for subsetted meshes and decomposed // will simply be an identity list. However, for subsetted meshes
// cells this becomes a useful means of mapping from the original mesh. // and decomposed cells this becomes a useful means of mapping from
// the original mesh.
inline DynamicList<label>& cellMap(); inline DynamicList<label>& cellMap();
//- Point labels for subsetted meshes //- Point labels for subsetted meshes

View File

@ -24,18 +24,18 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "polyMesh.H" #include "polyMesh.H"
#include "foamVtkCells.H" #include "foamVtuCells.H"
#include "foamVtkOutputOptions.H" #include "foamVtkOutputOptions.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkCells::foamVtkCells Foam::vtk::vtuCells::vtuCells
( (
const contentType output, const contentType output,
const bool decompose const bool decompose
) )
: :
foamVtuSizing(), vtk::vtuSizing(),
output_(output), output_(output),
decomposeRequest_(decompose), decomposeRequest_(decompose),
cellTypes_(), cellTypes_(),
@ -47,26 +47,26 @@ Foam::foamVtkCells::foamVtkCells
{} {}
Foam::foamVtkCells::foamVtkCells Foam::vtk::vtuCells::vtuCells
( (
const polyMesh& mesh, const polyMesh& mesh,
const contentType output, const contentType output,
const bool decompose const bool decompose
) )
: :
foamVtkCells(output, decompose) vtuCells(output, decompose)
{ {
reset(mesh); reset(mesh);
} }
Foam::foamVtkCells::foamVtkCells Foam::vtk::vtuCells::vtuCells
( (
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const bool decompose const bool decompose
) )
: :
foamVtkCells vtuCells
( (
(outOpts.legacy() ? contentType::LEGACY : contentType::XML), (outOpts.legacy() ? contentType::LEGACY : contentType::XML),
decompose decompose
@ -74,14 +74,14 @@ Foam::foamVtkCells::foamVtkCells
{} {}
Foam::foamVtkCells::foamVtkCells Foam::vtk::vtuCells::vtuCells
( (
const polyMesh& mesh, const polyMesh& mesh,
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const bool decompose const bool decompose
) )
: :
foamVtkCells(outOpts, decompose) vtuCells(outOpts, decompose)
{ {
reset(mesh); reset(mesh);
} }
@ -89,15 +89,15 @@ Foam::foamVtkCells::foamVtkCells
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkCells::~foamVtkCells() Foam::vtk::vtuCells::~vtuCells()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkCells::clear() void Foam::vtk::vtuCells::clear()
{ {
foamVtuSizing::clear(); vtuSizing::clear();
cellTypes_.clear(); cellTypes_.clear();
vertLabels_.clear(); vertLabels_.clear();
vertOffset_.clear(); vertOffset_.clear();
@ -108,15 +108,15 @@ void Foam::foamVtkCells::clear()
} }
void Foam::foamVtkCells::reset(const polyMesh& mesh) void Foam::vtk::vtuCells::reset(const polyMesh& mesh)
{ {
foamVtuSizing::reset(mesh, decomposeRequest_); vtuSizing::reset(mesh, decomposeRequest_);
cellTypes_.setSize(nFieldCells()); cellTypes_.setSize(nFieldCells());
vertLabels_.setSize(slotSize(output_, slotType::CELLS)); vertLabels_.setSize(sizeOf(output_, slotType::CELLS));
vertOffset_.setSize(slotSize(output_, slotType::CELLS_OFFSETS)); vertOffset_.setSize(sizeOf(output_, slotType::CELLS_OFFSETS));
faceLabels_.setSize(slotSize(output_, slotType::FACES)); faceLabels_.setSize(sizeOf(output_, slotType::FACES));
faceOffset_.setSize(slotSize(output_, slotType::FACES_OFFSETS)); faceOffset_.setSize(sizeOf(output_, slotType::FACES_OFFSETS));
switch (output_) switch (output_)
{ {
@ -157,7 +157,7 @@ void Foam::foamVtkCells::reset(const polyMesh& mesh)
} }
void Foam::foamVtkCells::reset void Foam::vtk::vtuCells::reset
( (
const polyMesh& mesh, const polyMesh& mesh,
const enum contentType output, const enum contentType output,
@ -171,13 +171,13 @@ void Foam::foamVtkCells::reset
} }
void Foam::foamVtkCells::renumberCells(const UList<label>& mapping) void Foam::vtk::vtuCells::renumberCells(const UList<label>& mapping)
{ {
maps_.renumberCells(mapping); maps_.renumberCells(mapping);
} }
void Foam::foamVtkCells::renumberPoints(const UList<label>& mapping) void Foam::vtk::vtuCells::renumberPoints(const UList<label>& mapping)
{ {
maps_.renumberPoints(mapping); maps_.renumberPoints(mapping);
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkCells Foam::vtk::vtuCells
Description Description
A deep-copy description of an OpenFOAM volume mesh in data structures A deep-copy description of an OpenFOAM volume mesh in data structures
@ -36,20 +36,20 @@ Description
related to the xml format, but not entirely. related to the xml format, but not entirely.
SeeAlso SeeAlso
Foam::foamVtuSizing Foam::vtk::vtuSizing
SourceFiles SourceFiles
foamVtkCells.C foamVtuCells.C
foamVtkCellsI.H foamVtuCellsI.H
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef foamVtkCells_H #ifndef foamVtuCells_H
#define foamVtkCells_H #define foamVtuCells_H
#include "foamVtkCore.H"
#include "foamVtkMeshMaps.H" #include "foamVtkMeshMaps.H"
#include "foamVtuSizing.H" #include "foamVtuSizing.H"
#include "foamVtkCore.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "labelList.H" #include "labelList.H"
@ -61,22 +61,20 @@ namespace Foam
// Forward declaration of classes // Forward declaration of classes
class polyMesh; class polyMesh;
namespace foamVtkOutput namespace vtk
{ {
// Forward declaration of classes
class outputOptions; class outputOptions;
}
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class foamVtkCells Declaration Class Foam::vtk::vtuCells Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class foamVtkCells class vtuCells
: :
public fileFormats::foamVtkCore, public vtuSizing
public foamVtuSizing
{ {
// Private data // Private Member Data
// Requested output types // Requested output types
@ -111,10 +109,10 @@ class foamVtkCells
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
foamVtkCells(const foamVtkCells&) = delete; vtuCells(const vtuCells&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const foamVtkCells&) = delete; void operator=(const vtuCells&) = delete;
public: public:
@ -123,7 +121,7 @@ public:
//- Construct from components. //- Construct from components.
// Optionally with polyhedral decomposition. // Optionally with polyhedral decomposition.
foamVtkCells vtuCells
( (
const enum contentType output = contentType::XML, const enum contentType output = contentType::XML,
const bool decompose = false const bool decompose = false
@ -131,7 +129,7 @@ public:
//- Construct from components and create the output information //- Construct from components and create the output information
// immediately // immediately
foamVtkCells vtuCells
( (
const polyMesh& mesh, const polyMesh& mesh,
const enum contentType output = contentType::XML, const enum contentType output = contentType::XML,
@ -140,24 +138,24 @@ public:
//- Construct from components. //- Construct from components.
// Optionally with polyhedral decomposition. // Optionally with polyhedral decomposition.
foamVtkCells vtuCells
( (
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const bool decompose = false const bool decompose = false
); );
//- Construct from components and create the output information //- Construct from components and create the output information
// immediately // immediately
foamVtkCells vtuCells
( (
const polyMesh& mesh, const polyMesh& mesh,
const foamVtkOutput::outputOptions outOpts, const vtk::outputOptions outOpts,
const bool decompose = false const bool decompose = false
); );
//- Destructor //- Destructor
~foamVtkCells(); ~vtuCells();
// Member Functions // Member Functions
@ -230,11 +228,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "foamVtkCellsI.H" #include "foamVtuCellsI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,79 +23,80 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "foamVtkCells.H" #include "foamVtuCells.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline enum Foam::foamVtkCells::contentType Foam::foamVtkCells::content() const inline enum Foam::vtk::vtuCells::contentType
Foam::vtk::vtuCells::content() const
{ {
return output_; return output_;
} }
inline bool Foam::foamVtkCells::decomposeRequested() const inline bool Foam::vtk::vtuCells::decomposeRequested() const
{ {
return decomposeRequest_; return decomposeRequest_;
} }
inline bool Foam::foamVtkCells::empty() const inline bool Foam::vtk::vtuCells::empty() const
{ {
return cellTypes_.empty(); return cellTypes_.empty();
} }
inline Foam::label Foam::foamVtkCells::size() const inline Foam::label Foam::vtk::vtuCells::size() const
{ {
return cellTypes_.size(); return cellTypes_.size();
} }
inline const Foam::List<uint8_t>& inline const Foam::List<uint8_t>&
Foam::foamVtkCells::cellTypes() const Foam::vtk::vtuCells::cellTypes() const
{ {
return cellTypes_; return cellTypes_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::foamVtkCells::vertLabels() const Foam::vtk::vtuCells::vertLabels() const
{ {
return vertLabels_; return vertLabels_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::foamVtkCells::vertOffsets() const Foam::vtk::vtuCells::vertOffsets() const
{ {
return vertOffset_; return vertOffset_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::foamVtkCells::faceLabels() const Foam::vtk::vtuCells::faceLabels() const
{ {
return faceLabels_; return faceLabels_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::foamVtkCells::faceOffsets() const Foam::vtk::vtuCells::faceOffsets() const
{ {
return faceOffset_; return faceOffset_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::foamVtkCells::addPointCellLabels() const Foam::vtk::vtuCells::addPointCellLabels() const
{ {
return maps_.additionalIds(); return maps_.additionalIds();
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::foamVtkCells::cellMap() const Foam::vtk::vtuCells::cellMap() const
{ {
return maps_.cellMap(); return maps_.cellMap();
} }

View File

@ -29,12 +29,12 @@ License
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H" #include "cellModeller.H"
// only used in this file // Only used in this file
#include "foamVtuSizingTemplates.C" #include "foamVtuSizingTemplates.C"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::foamVtuSizing::presizeMaps(foamVtkMeshMaps& maps) const void Foam::vtk::vtuSizing::presizeMaps(foamVtkMeshMaps& maps) const
{ {
maps.cellMap().setSize(this->nFieldCells()); maps.cellMap().setSize(this->nFieldCells());
maps.additionalIds().setSize(this->nAddPoints()); maps.additionalIds().setSize(this->nAddPoints());
@ -43,7 +43,7 @@ void Foam::foamVtuSizing::presizeMaps(foamVtkMeshMaps& maps) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtuSizing::foamVtuSizing Foam::vtk::vtuSizing::vtuSizing
( (
const polyMesh& mesh, const polyMesh& mesh,
const bool decompose const bool decompose
@ -54,7 +54,7 @@ Foam::foamVtuSizing::foamVtuSizing
} }
Foam::foamVtuSizing::foamVtuSizing() Foam::vtk::vtuSizing::vtuSizing()
{ {
clear(); clear();
} }
@ -62,13 +62,13 @@ Foam::foamVtuSizing::foamVtuSizing()
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtuSizing::~foamVtuSizing() Foam::vtk::vtuSizing::~vtuSizing()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtuSizing::reset void Foam::vtk::vtuSizing::reset
( (
const polyMesh& mesh, const polyMesh& mesh,
const bool decompose const bool decompose
@ -160,7 +160,7 @@ void Foam::foamVtuSizing::reset
const labelList& cFaces = mesh.cells()[celli]; const labelList& cFaces = mesh.cells()[celli];
// Unique node ids used (only needed for XML) // Unique node ids used (XML/INTERNAL, not needed for LEGACY)
hashUniqId.clear(); hashUniqId.clear();
// Face stream sizing: // Face stream sizing:
@ -189,7 +189,7 @@ void Foam::foamVtuSizing::reset
} }
Foam::label Foam::foamVtuSizing::slotSize Foam::label Foam::vtk::vtuSizing::sizeOf
( (
const enum contentType output, const enum contentType output,
const enum slotType slot const enum slotType slot
@ -269,7 +269,7 @@ Foam::label Foam::foamVtuSizing::slotSize
} }
void Foam::foamVtuSizing::populateLegacy void Foam::vtk::vtuSizing::populateLegacy
( (
const polyMesh& mesh, const polyMesh& mesh,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
@ -298,7 +298,7 @@ void Foam::foamVtuSizing::populateLegacy
} }
void Foam::foamVtuSizing::populateXml void Foam::vtk::vtuSizing::populateXml
( (
const polyMesh& mesh, const polyMesh& mesh,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
@ -327,7 +327,7 @@ void Foam::foamVtuSizing::populateXml
} }
void Foam::foamVtuSizing::populateInternal void Foam::vtk::vtuSizing::populateInternal
( (
const polyMesh& mesh, const polyMesh& mesh,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
@ -356,7 +356,7 @@ void Foam::foamVtuSizing::populateInternal
} }
void Foam::foamVtuSizing::populateInternal void Foam::vtk::vtuSizing::populateInternal
( (
const polyMesh& mesh, const polyMesh& mesh,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
@ -385,7 +385,7 @@ void Foam::foamVtuSizing::populateInternal
} }
void Foam::foamVtuSizing::populateInternal void Foam::vtk::vtuSizing::populateInternal
( (
const polyMesh& mesh, const polyMesh& mesh,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
@ -414,7 +414,7 @@ void Foam::foamVtuSizing::populateInternal
} }
void Foam::foamVtuSizing::populateInternal void Foam::vtk::vtuSizing::populateInternal
( (
const polyMesh& mesh, const polyMesh& mesh,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
@ -442,7 +442,7 @@ void Foam::foamVtuSizing::populateInternal
} }
void Foam::foamVtuSizing::populateInternal void Foam::vtk::vtuSizing::populateInternal
( (
const polyMesh& mesh, const polyMesh& mesh,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
@ -470,7 +470,7 @@ void Foam::foamVtuSizing::populateInternal
} }
void Foam::foamVtuSizing::populateInternal void Foam::vtk::vtuSizing::populateInternal
( (
const polyMesh& mesh, const polyMesh& mesh,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
@ -498,7 +498,7 @@ void Foam::foamVtuSizing::populateInternal
} }
void Foam::foamVtuSizing::clear() void Foam::vtk::vtuSizing::clear()
{ {
decompose_ = false; decompose_ = false;
nCells_ = 0; nCells_ = 0;
@ -515,7 +515,7 @@ void Foam::foamVtuSizing::clear()
} }
void Foam::foamVtuSizing::info(Ostream& os) const void Foam::vtk::vtuSizing::info(Ostream& os) const
{ {
os << "nFieldCells:" << nFieldCells(); os << "nFieldCells:" << nFieldCells();
if (nAddCells_) if (nAddCells_)
@ -551,7 +551,7 @@ void Foam::foamVtuSizing::info(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
bool Foam::foamVtuSizing::operator==(const foamVtuSizing& rhs) const bool Foam::vtk::vtuSizing::operator==(const vtuSizing& rhs) const
{ {
return return
( (
@ -569,7 +569,7 @@ bool Foam::foamVtuSizing::operator==(const foamVtuSizing& rhs) const
} }
bool Foam::foamVtuSizing::operator!=(const foamVtuSizing& rhs) const bool Foam::vtk::vtuSizing::operator!=(const vtuSizing& rhs) const
{ {
return !operator==(rhs); return !operator==(rhs);
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtuSizing Foam::vtk::vtuSizing
Description Description
Sizing descriptions and routines for transcribing an OpenFOAM volume mesh Sizing descriptions and routines for transcribing an OpenFOAM volume mesh
@ -97,11 +97,14 @@ namespace Foam
// Forward declaration of classes // Forward declaration of classes
class polyMesh; class polyMesh;
namespace vtk
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class foamVtuSizing Declaration Class Foam::vtk::vtuSizing Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class foamVtuSizing class vtuSizing
{ {
public: public:
@ -115,15 +118,16 @@ public:
INTERNAL //!< Internal vtkUnstructuredGrid content INTERNAL //!< Internal vtkUnstructuredGrid content
}; };
//- The storage 'slots' required //- The possible storage 'slots' that can be used
enum slotType enum slotType
{ {
CELLS, //!< Cell connectivity (ALL) CELLS, //!< Cell connectivity (ALL)
CELLS_OFFSETS, //!< Begin (XML) or end (INTERNAL) offsets into cells CELLS_OFFSETS, //!< End-offsets (XML) or locations (INTERNAL) for cells
FACES, //!< Face-stream (XML, INTERNAL) FACES, //!< Face-stream (XML, INTERNAL)
FACES_OFFSETS //!< Begin (XML) or end (INTERNAL) offsets into faces FACES_OFFSETS //!< End-offsets (XML) or locations (INTERNAL) for faces
}; };
private: private:
// Private Member Data // Private Member Data
@ -173,7 +177,7 @@ private:
static void populateArrays static void populateArrays
( (
const polyMesh& mesh, const polyMesh& mesh,
const foamVtuSizing& sizing, const vtk::vtuSizing& sizing,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
UList<LabelType>& vertLabels, UList<LabelType>& vertLabels,
UList<LabelType>& vertOffset, UList<LabelType>& vertOffset,
@ -191,15 +195,15 @@ public:
// Constructors // Constructors
//- Construct null. //- Construct null.
foamVtuSizing(); vtuSizing();
//- Construct sizes by analyzing the mesh, //- Construct sizes by analyzing the mesh,
// optionally with polyhedral decomposition. // optionally with polyhedral decomposition.
foamVtuSizing(const polyMesh& mesh, const bool decompose=false); vtuSizing(const polyMesh& mesh, const bool decompose=false);
//- Destructor //- Destructor
~foamVtuSizing(); ~vtuSizing();
// Member Functions // Member Functions
@ -257,7 +261,7 @@ public:
// Derived sizes // Derived sizes
//- Return the required size for the storage slot //- Return the required size for the storage slot
label slotSize label sizeOf
( (
const enum contentType output, const enum contentType output,
const enum slotType slot const enum slotType slot
@ -385,16 +389,17 @@ public:
// Member Operators // Member Operators
//- Test equality //- Test equality
bool operator==(const foamVtuSizing& rhs) const; bool operator==(const vtuSizing& rhs) const;
//- Test inequality //- Test inequality
bool operator!=(const foamVtuSizing& rhs) const; bool operator!=(const vtuSizing& rhs) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,108 +27,108 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::foamVtuSizing::decompose() const inline bool Foam::vtk::vtuSizing::decompose() const
{ {
return decompose_; return decompose_;
} }
inline Foam::label Foam::foamVtuSizing::nCells() const inline Foam::label Foam::vtk::vtuSizing::nCells() const
{ {
return nCells_; return nCells_;
} }
inline Foam::label Foam::foamVtuSizing::nPoints() const inline Foam::label Foam::vtk::vtuSizing::nPoints() const
{ {
return nPoints_; return nPoints_;
} }
inline Foam::label Foam::foamVtuSizing::nVertLabels() const inline Foam::label Foam::vtk::vtuSizing::nVertLabels() const
{ {
return nVertLabels_; return nVertLabels_;
} }
inline Foam::label Foam::foamVtuSizing::nFaceLabels() const inline Foam::label Foam::vtk::vtuSizing::nFaceLabels() const
{ {
return nFaceLabels_; return nFaceLabels_;
} }
inline Foam::label Foam::foamVtuSizing::nCellsPoly() const inline Foam::label Foam::vtk::vtuSizing::nCellsPoly() const
{ {
return nCellsPoly_; return nCellsPoly_;
} }
inline Foam::label Foam::foamVtuSizing::nVertPoly() const inline Foam::label Foam::vtk::vtuSizing::nVertPoly() const
{ {
return nVertPoly_; return nVertPoly_;
} }
inline Foam::label Foam::foamVtuSizing::nAddCells() const inline Foam::label Foam::vtk::vtuSizing::nAddCells() const
{ {
return nAddCells_; return nAddCells_;
} }
inline Foam::label Foam::foamVtuSizing::nAddPoints() const inline Foam::label Foam::vtk::vtuSizing::nAddPoints() const
{ {
return nAddPoints_; return nAddPoints_;
} }
inline Foam::label Foam::foamVtuSizing::nAddVerts() const inline Foam::label Foam::vtk::vtuSizing::nAddVerts() const
{ {
return nAddVerts_; return nAddVerts_;
} }
inline Foam::label Foam::foamVtuSizing::nFieldCells() const inline Foam::label Foam::vtk::vtuSizing::nFieldCells() const
{ {
return nCells_ + nAddCells_; return nCells_ + nAddCells_;
} }
inline Foam::label Foam::foamVtuSizing::nFieldPoints() const inline Foam::label Foam::vtk::vtuSizing::nFieldPoints() const
{ {
return nPoints_ + nAddPoints_; return nPoints_ + nAddPoints_;
} }
inline Foam::label Foam::foamVtuSizing::sizeLegacy() const inline Foam::label Foam::vtk::vtuSizing::sizeLegacy() const
{ {
return slotSize(contentType::LEGACY, slotType::CELLS); return sizeOf(contentType::LEGACY, slotType::CELLS);
} }
inline Foam::label Foam::foamVtuSizing::sizeLegacy inline Foam::label Foam::vtk::vtuSizing::sizeLegacy
( (
const enum slotType slot const enum slotType slot
) const ) const
{ {
return slotSize(contentType::LEGACY, slot); return sizeOf(contentType::LEGACY, slot);
} }
inline Foam::label Foam::foamVtuSizing::sizeXml inline Foam::label Foam::vtk::vtuSizing::sizeXml
( (
const enum slotType slot const enum slotType slot
) const ) const
{ {
return slotSize(contentType::XML, slot); return sizeOf(contentType::XML, slot);
} }
inline Foam::label Foam::foamVtuSizing::sizeInternal inline Foam::label Foam::vtk::vtuSizing::sizeInternal
( (
const enum slotType slot const enum slotType slot
) const ) const
{ {
return slotSize(contentType::INTERNAL, slot); return sizeOf(contentType::INTERNAL, slot);
} }

View File

@ -32,10 +32,10 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class LabelType, class LabelType2> template<class LabelType, class LabelType2>
void Foam::foamVtuSizing::populateArrays void Foam::vtk::vtuSizing::populateArrays
( (
const polyMesh& mesh, const polyMesh& mesh,
const foamVtuSizing& sizing, const vtk::vtuSizing& sizing,
UList<uint8_t>& cellTypes, UList<uint8_t>& cellTypes,
UList<LabelType>& vertLabels, UList<LabelType>& vertLabels,
UList<LabelType>& vertOffset, UList<LabelType>& vertOffset,
@ -46,8 +46,6 @@ void Foam::foamVtuSizing::populateArrays
UList<LabelType2>& addPointsIds UList<LabelType2>& addPointsIds
) )
{ {
using vtkTypes = fileFormats::foamVtkCore::vtkTypes;
// STAGE 1: Verify storage sizes // STAGE 1: Verify storage sizes
if (cellTypes.size() != sizing.nFieldCells()) if (cellTypes.size() != sizing.nFieldCells())
@ -275,7 +273,7 @@ void Foam::foamVtuSizing::populateArrays
if (model == tet) if (model == tet)
{ {
cellTypes[celli] = vtkTypes::VTK_TETRA; cellTypes[celli] = vtk::cellType::VTK_TETRA;
if (vertOffset.size()) if (vertOffset.size())
{ {
vertOffset[celli] = shape.size(); vertOffset[celli] = shape.size();
@ -292,7 +290,7 @@ void Foam::foamVtuSizing::populateArrays
} }
else if (model == pyr) else if (model == pyr)
{ {
cellTypes[celli] = vtkTypes::VTK_PYRAMID; cellTypes[celli] = vtk::cellType::VTK_PYRAMID;
if (vertOffset.size()) if (vertOffset.size())
{ {
vertOffset[celli] = shape.size(); vertOffset[celli] = shape.size();
@ -309,7 +307,7 @@ void Foam::foamVtuSizing::populateArrays
} }
else if (model == hex) else if (model == hex)
{ {
cellTypes[celli] = vtkTypes::VTK_HEXAHEDRON; cellTypes[celli] = vtk::cellType::VTK_HEXAHEDRON;
if (vertOffset.size()) if (vertOffset.size())
{ {
vertOffset[celli] = shape.size(); vertOffset[celli] = shape.size();
@ -326,7 +324,7 @@ void Foam::foamVtuSizing::populateArrays
} }
else if (model == prism) else if (model == prism)
{ {
cellTypes[celli] = vtkTypes::VTK_WEDGE; cellTypes[celli] = vtk::cellType::VTK_WEDGE;
if (vertOffset.size()) if (vertOffset.size())
{ {
vertOffset[celli] = shape.size(); vertOffset[celli] = shape.size();
@ -347,7 +345,7 @@ void Foam::foamVtuSizing::populateArrays
else if (model == tetWedge && sizing.decompose()) else if (model == tetWedge && sizing.decompose())
{ {
// Treat as squeezed prism // Treat as squeezed prism
cellTypes[celli] = vtkTypes::VTK_WEDGE; cellTypes[celli] = vtk::cellType::VTK_WEDGE;
if (vertOffset.size()) if (vertOffset.size())
{ {
vertOffset[celli] = 6; vertOffset[celli] = 6;
@ -367,7 +365,7 @@ void Foam::foamVtuSizing::populateArrays
else if (model == wedge && sizing.decompose()) else if (model == wedge && sizing.decompose())
{ {
// Treat as squeezed hex // Treat as squeezed hex
cellTypes[celli] = vtkTypes::VTK_HEXAHEDRON; cellTypes[celli] = vtk::cellType::VTK_HEXAHEDRON;
if (vertOffset.size()) if (vertOffset.size())
{ {
vertOffset[celli] = 8; vertOffset[celli] = 8;
@ -443,7 +441,7 @@ void Foam::foamVtuSizing::populateArrays
} }
cellMap[celLoc] = celli; cellMap[celLoc] = celli;
cellTypes[celLoc] = vtkTypes::VTK_PYRAMID; cellTypes[celLoc] = vtk::cellType::VTK_PYRAMID;
if (vertOffset.size()) if (vertOffset.size())
{ {
vertOffset[celLoc] = nShapePoints; vertOffset[celLoc] = nShapePoints;
@ -494,7 +492,7 @@ void Foam::foamVtuSizing::populateArrays
} }
cellMap[celLoc] = celli; cellMap[celLoc] = celli;
cellTypes[celLoc] = vtkTypes::VTK_TETRA; cellTypes[celLoc] = vtk::cellType::VTK_TETRA;
if (vertOffset.size()) if (vertOffset.size())
{ {
vertOffset[celLoc] = nShapePoints; vertOffset[celLoc] = nShapePoints;
@ -504,7 +502,7 @@ void Foam::foamVtuSizing::populateArrays
vertLabels[vrtLoc++] = nShapePoints; vertLabels[vrtLoc++] = nShapePoints;
} }
cellTypes[celLoc] = vtkTypes::VTK_TETRA; cellTypes[celLoc] = vtk::cellType::VTK_TETRA;
// See note above about the orientation. // See note above about the orientation.
if (isOwner) if (isOwner)
@ -530,7 +528,7 @@ void Foam::foamVtuSizing::populateArrays
// face-stream // face-stream
// [nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...] // [nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
cellTypes[celli] = vtkTypes::VTK_POLYHEDRON; cellTypes[celli] = vtk::cellType::VTK_POLYHEDRON;
const labelList& cFaces = mesh.cells()[celli]; const labelList& cFaces = mesh.cells()[celli];
const label startLabel = faceIndexer; const label startLabel = faceIndexer;

View File

@ -14,7 +14,8 @@ stl/STLCore.C
stl/STLReader.C stl/STLReader.C
stl/STLReaderASCII.L stl/STLReaderASCII.L
vtk/foamVtkCore.C vtk/core/foamVtkCore.C
vtk/core/foamVtkPTraits.C
vtk/format/foamVtkFormatter.C vtk/format/foamVtkFormatter.C
vtk/format/foamVtkAsciiFormatter.C vtk/format/foamVtkAsciiFormatter.C
vtk/format/foamVtkBase64Formatter.C vtk/format/foamVtkBase64Formatter.C
@ -26,8 +27,6 @@ vtk/format/foamVtkLegacyRawFormatter.C
vtk/output/foamVtkOutput.C vtk/output/foamVtkOutput.C
vtk/output/foamVtkOutputOptions.C vtk/output/foamVtkOutputOptions.C
vtk/read/vtkUnstructuredReader.C vtk/read/vtkUnstructuredReader.C
vtk/type/foamVtkFileEnums.C
vtk/type/foamVtkPTraits.C
coordSet/coordSet.C coordSet/coordSet.C

View File

@ -0,0 +1,71 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "foamVtkCore.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const Foam::Enum<Foam::vtk::fileTag> Foam::vtk::fileTagNames
{
{ fileTag::VTK_FILE, "VTKFile" },
{ fileTag::DATA_ARRAY, "DataArray" },
{ fileTag::PIECE, "Piece" },
{ fileTag::DATA_SET, "DataSet" },
{ fileTag::POINTS, "Points" },
{ fileTag::CELLS, "Cells" },
{ fileTag::POLYS, "Polys" },
{ fileTag::VERTS, "Verts" },
{ fileTag::LINES, "Lines" },
{ fileTag::CELL_DATA, "CellData" },
{ fileTag::POINT_DATA, "PointData" },
{ fileTag::POLY_DATA, "PolyData" },
{ fileTag::UNSTRUCTURED_GRID, "UnstructuredGrid" },
};
const Foam::Enum<Foam::vtk::fileAttr> Foam::vtk::fileAttrNames
{
{ fileAttr::OFFSET, "offset" },
{ fileAttr::NUMBER_OF_COMPONENTS, "NumberOfComponents" },
{ fileAttr::NUMBER_OF_POINTS, "NumberOfPoints" },
{ fileAttr::NUMBER_OF_CELLS, "NumberOfCells" },
{ fileAttr::NUMBER_OF_POLYS, "NumberOfPolys" },
{ fileAttr::NUMBER_OF_VERTS, "NumberOfVerts" },
{ fileAttr::NUMBER_OF_LINES, "NumberOfLines" },
};
const Foam::Enum<Foam::vtk::dataArrayAttr> Foam::vtk::dataArrayAttrNames
{
{ dataArrayAttr::POINTS, "Points" },
{ dataArrayAttr::OFFSETS, "offsets" },
{ dataArrayAttr::CONNECTIVITY, "connectivity" },
{ dataArrayAttr::TYPES, "types" },
{ dataArrayAttr::FACES, "faces" },
{ dataArrayAttr::FACEOFFSETS, "faceoffsets" },
};
// ************************************************************************* //

View File

@ -0,0 +1,163 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Namespace
Foam::vtk
Description
Namespace for handling VTK input/output.
SourceFiles
foamVtkCore.C
\*---------------------------------------------------------------------------*/
#ifndef foamVtkCore_H
#define foamVtkCore_H
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace vtk
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Enumerations
//- The context when outputting a VTK file (XML or legacy).
enum OutputContext
{
INLINE, //<! Generate header and inline data
HEADER, //<! Generate header only
APPEND //<! Generate append-data
};
//- The output format type for file contents.
// Upper bits for output type, lower bits for the format itself.
enum class formatType
{
/** XML inline ASCII, using the asciiFormatter */
INLINE_ASCII = 0,
/** XML inline base64, using the base64Formatter */
INLINE_BASE64 = 0x01,
/** XML append base64, using the appendBase64Formatter */
APPEND_BASE64 = 0x11,
/** XML append raw binary, using the appendRawFormatter */
APPEND_BINARY = 0x12,
/** Legacy ASCII, using the legacyAsciiFormatter */
LEGACY_ASCII = 0x20,
/** Legacy raw binary, using the legacyRawFormatter */
LEGACY_BINARY = 0x22,
};
//- Equivalent to enumeration in "vtkCellType.h"
enum cellType
{
VTK_EMPTY_CELL = 0,
VTK_VERTEX = 1,
VTK_POLY_VERTEX = 2,
VTK_LINE = 3,
VTK_POLY_LINE = 4,
VTK_TRIANGLE = 5,
VTK_TRIANGLE_STRIP = 6,
VTK_POLYGON = 7,
VTK_PIXEL = 8,
VTK_QUAD = 9,
VTK_TETRA = 10,
VTK_VOXEL = 11,
VTK_HEXAHEDRON = 12,
VTK_WEDGE = 13,
VTK_PYRAMID = 14,
VTK_PENTAGONAL_PRISM = 15,
VTK_HEXAGONAL_PRISM = 16,
VTK_POLYHEDRON = 42
};
//- Some common XML tags for vtk files
enum class fileTag
{
VTK_FILE, //!< "VTKFile"
DATA_ARRAY, //!< "DataArray"
PIECE, //!< "Piece"
DATA_SET, //!< "DataSet"
POINTS, //!< "Points"
CELLS, //!< "Cells"
POLYS, //!< "Polys"
VERTS, //!< "Verts"
LINES, //!< "Lines"
CELL_DATA, //!< "CellData"
POINT_DATA, //!< "PointData"
POLY_DATA, //!< "PolyData"
UNSTRUCTURED_GRID, //!< "UnstructuredGrid"
};
//- Strings corresponding to the vtk xml tags
extern const Foam::Enum<fileTag> fileTagNames;
//- Some common XML attributes for vtk files
enum class fileAttr
{
OFFSET, //!< "offset"
NUMBER_OF_COMPONENTS, //!< "NumberOfComponents"
NUMBER_OF_POINTS, //!< "NumberOfPoints"
NUMBER_OF_CELLS, //!< "NumberOfCells"
NUMBER_OF_POLYS, //!< "NumberOfPolys"
NUMBER_OF_VERTS, //!< "NumberOfVerts"
NUMBER_OF_LINES, //!< "NumberOfLines"
};
//- Strings corresponding to the vtk xml attributes
extern const Foam::Enum<fileAttr> fileAttrNames;
//- Some common names for XML data arrays
enum class dataArrayAttr
{
POINTS, //!< "Points"
OFFSETS, //!< "offsets"
CONNECTIVITY, //!< "connectivity"
TYPES, //!< "types"
FACES, //!< "faces"
FACEOFFSETS, //!< "faceoffsets"
};
//- Strings corresponding to the vtk xml attributes
extern const Foam::Enum<dataArrayAttr> dataArrayAttrNames;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace vtk
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -30,40 +30,40 @@ License
template<> template<>
const char* const const char* const
Foam::foamVtkPTraits<uint8_t>::typeName = "UInt8"; Foam::vtkPTraits<uint8_t>::typeName = "UInt8";
template<> template<>
const char * const const char * const
Foam::foamVtkPTraits<int32_t>::typeName = "Int32"; Foam::vtkPTraits<int32_t>::typeName = "Int32";
template<> template<>
const char * const const char * const
Foam::foamVtkPTraits<uint32_t>::typeName = "UInt32"; Foam::vtkPTraits<uint32_t>::typeName = "UInt32";
template<> template<>
const char * const const char * const
Foam::foamVtkPTraits<int64_t>::typeName = "Int64"; Foam::vtkPTraits<int64_t>::typeName = "Int64";
template<> template<>
const char * const const char * const
Foam::foamVtkPTraits<uint64_t>::typeName = "UInt64"; Foam::vtkPTraits<uint64_t>::typeName = "UInt64";
template<> template<>
const char * const const char * const
Foam::foamVtkPTraits<float>::typeName = "Float32"; Foam::vtkPTraits<float>::typeName = "Float32";
template<> template<>
const char * const const char * const
Foam::foamVtkPTraits<double>::typeName = "Float64"; Foam::vtkPTraits<double>::typeName = "Float64";
#ifdef WM_LITTLE_ENDIAN #ifdef WM_LITTLE_ENDIAN
template<> template<>
const char* const const char* const
Foam::foamVtkPTraits<Foam::endian>::typeName = "LittleEndian"; Foam::vtkPTraits<Foam::endian>::typeName = "LittleEndian";
#else #else
template<> template<>
const char* const const char* const
Foam::foamVtkPTraits<Foam::endian>::typeName = "BigEndian"; Foam::vtkPTraits<Foam::endian>::typeName = "BigEndian";
#endif #endif

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkPTraits Foam::vtkPTraits
Description Description
Names for VTK primitive types. Names for VTK primitive types.
@ -43,11 +43,11 @@ namespace Foam
class endian; class endian;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class foamVtkPTraits Declaration Class vtkPTraits Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class PrimitiveType> template<class PrimitiveType>
class foamVtkPTraits class vtkPTraits
{ {
public: public:
@ -58,28 +58,28 @@ public:
template<> template<>
const char* const foamVtkPTraits<uint8_t>::typeName; // UInt8 const char* const vtkPTraits<uint8_t>::typeName; // UInt8
template<> template<>
const char* const foamVtkPTraits<int32_t>::typeName; // Int32 const char* const vtkPTraits<int32_t>::typeName; // Int32
template<> template<>
const char* const foamVtkPTraits<uint32_t>::typeName; // UInt32 const char* const vtkPTraits<uint32_t>::typeName; // UInt32
template<> template<>
const char* const foamVtkPTraits<int64_t>::typeName; // Int64 const char* const vtkPTraits<int64_t>::typeName; // Int64
template<> template<>
const char* const foamVtkPTraits<uint64_t>::typeName; // UInt64 const char* const vtkPTraits<uint64_t>::typeName; // UInt64
template<> template<>
const char* const foamVtkPTraits<float>::typeName; // Float32 const char* const vtkPTraits<float>::typeName; // Float32
template<> template<>
const char* const foamVtkPTraits<double>::typeName; // Float64 const char* const vtkPTraits<double>::typeName; // Float64
template<> template<>
const char* const foamVtkPTraits<Foam::endian>::typeName; // (Big|Little)Endian const char* const vtkPTraits<Foam::endian>::typeName; // (Big|Little)Endian
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "foamVtkCore.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::foamVtkCore::foamVtkCore()
{}
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
/*
Foam::fileName Foam::fileFormats::foamVtkCore::vtkFileName
(
const fileName& base,
const enum fileExt ext
)
{
return base + '.' + fileExtensions_[ext];
}
*/
// ************************************************************************* //

View File

@ -1,109 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::foamVtkCore
Description
Core routines for dealing with VTK files.
SourceFiles
foamVtkCore.C
\*---------------------------------------------------------------------------*/
#ifndef foamVtkCore_H
#define foamVtkCore_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class fileFormats::foamVtkCore Declaration
\*---------------------------------------------------------------------------*/
class foamVtkCore
{
public:
// Public Data, Declarations
//- The context when outputting a VTK file (XML or legacy).
enum OutputContext
{
INLINE, //<! Generate header and inline data
HEADER, //<! Generate header only
APPEND //<! Generate append-data
};
//- Equivalent to enumeration in "vtkCellType.h"
enum vtkTypes
{
VTK_EMPTY_CELL = 0,
VTK_VERTEX = 1,
VTK_POLY_VERTEX = 2,
VTK_LINE = 3,
VTK_POLY_LINE = 4,
VTK_TRIANGLE = 5,
VTK_TRIANGLE_STRIP = 6,
VTK_POLYGON = 7,
VTK_PIXEL = 8,
VTK_QUAD = 9,
VTK_TETRA = 10,
VTK_VOXEL = 11,
VTK_HEXAHEDRON = 12,
VTK_WEDGE = 13,
VTK_PYRAMID = 14,
VTK_PENTAGONAL_PRISM = 15,
VTK_HEXAGONAL_PRISM = 16,
VTK_POLYHEDRON = 42
};
protected:
// Constructors
//- Construct null
foamVtkCore();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -28,15 +28,15 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::appendBase64Formatter::name_ = "append"; const char* Foam::vtk::appendBase64Formatter::name_ = "append";
const Foam::foamVtkOutput::outputOptions const Foam::vtk::outputOptions
Foam::foamVtkOutput::appendBase64Formatter::opts_(formatType::APPEND_BASE64); Foam::vtk::appendBase64Formatter::opts_(formatType::APPEND_BASE64);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::appendBase64Formatter::appendBase64Formatter Foam::vtk::appendBase64Formatter::appendBase64Formatter
( (
std::ostream& os std::ostream& os
) )
@ -47,7 +47,7 @@ Foam::foamVtkOutput::appendBase64Formatter::appendBase64Formatter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::appendBase64Formatter::~appendBase64Formatter() Foam::vtk::appendBase64Formatter::~appendBase64Formatter()
{ {
base64Layer::close(); base64Layer::close();
} }
@ -55,14 +55,14 @@ Foam::foamVtkOutput::appendBase64Formatter::~appendBase64Formatter()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::foamVtkOutput::outputOptions& const Foam::vtk::outputOptions&
Foam::foamVtkOutput::appendBase64Formatter::opts() const Foam::vtk::appendBase64Formatter::opts() const
{ {
return opts_; return opts_;
} }
const char* Foam::foamVtkOutput::appendBase64Formatter::name() const const char* Foam::vtk::appendBase64Formatter::name() const
{ {
return name_; return name_;
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::appendBase64Formatter Foam::vtk::appendBase64Formatter
Description Description
Appended base-64 encoded binary output. Appended base-64 encoded binary output.
@ -42,7 +42,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -92,7 +92,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,16 +28,16 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::appendRawFormatter::name_ = "append"; const char* Foam::vtk::appendRawFormatter::name_ = "append";
const char* Foam::foamVtkOutput::appendRawFormatter::encoding_ = "raw"; const char* Foam::vtk::appendRawFormatter::encoding_ = "raw";
const Foam::foamVtkOutput::outputOptions const Foam::vtk::outputOptions
Foam::foamVtkOutput::appendRawFormatter::opts_(formatType::APPEND_BINARY); Foam::vtk::appendRawFormatter::opts_(formatType::APPEND_BINARY);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::appendRawFormatter::write void Foam::vtk::appendRawFormatter::write
( (
const char* s, const char* s,
std::streamsize n std::streamsize n
@ -49,7 +49,7 @@ void Foam::foamVtkOutput::appendRawFormatter::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::appendRawFormatter::appendRawFormatter(std::ostream& os) Foam::vtk::appendRawFormatter::appendRawFormatter(std::ostream& os)
: :
formatter(os) formatter(os)
{} {}
@ -57,58 +57,58 @@ Foam::foamVtkOutput::appendRawFormatter::appendRawFormatter(std::ostream& os)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::appendRawFormatter::~appendRawFormatter() Foam::vtk::appendRawFormatter::~appendRawFormatter()
{} {}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::foamVtkOutput::outputOptions& const Foam::vtk::outputOptions&
Foam::foamVtkOutput::appendRawFormatter::opts() const Foam::vtk::appendRawFormatter::opts() const
{ {
return opts_; return opts_;
} }
const char* Foam::foamVtkOutput::appendRawFormatter::name() const const char* Foam::vtk::appendRawFormatter::name() const
{ {
return name_; return name_;
} }
const char* Foam::foamVtkOutput::appendRawFormatter::encoding() const const char* Foam::vtk::appendRawFormatter::encoding() const
{ {
return encoding_; return encoding_;
} }
void Foam::foamVtkOutput::appendRawFormatter::writeSize(const uint64_t nBytes) void Foam::vtk::appendRawFormatter::writeSize(const uint64_t nBytes)
{ {
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t)); write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
} }
void Foam::foamVtkOutput::appendRawFormatter::write(const uint8_t val) void Foam::vtk::appendRawFormatter::write(const uint8_t val)
{ {
write(reinterpret_cast<const char*>(&val), sizeof(uint8_t)); write(reinterpret_cast<const char*>(&val), sizeof(uint8_t));
} }
void Foam::foamVtkOutput::appendRawFormatter::write(const label val) void Foam::vtk::appendRawFormatter::write(const label val)
{ {
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n'; // std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(label)); write(reinterpret_cast<const char*>(&val), sizeof(label));
} }
void Foam::foamVtkOutput::appendRawFormatter::write(const float val) void Foam::vtk::appendRawFormatter::write(const float val)
{ {
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n'; // std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(float)); write(reinterpret_cast<const char*>(&val), sizeof(float));
} }
void Foam::foamVtkOutput::appendRawFormatter::write(const double val) void Foam::vtk::appendRawFormatter::write(const double val)
{ {
// std::cerr<<"double as float=" << val << '\n'; // std::cerr<<"double as float=" << val << '\n';
float copy(val); float copy(val);
@ -116,7 +116,7 @@ void Foam::foamVtkOutput::appendRawFormatter::write(const double val)
} }
void Foam::foamVtkOutput::appendRawFormatter::flush() void Foam::vtk::appendRawFormatter::flush()
{/*nop*/} {/*nop*/}

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::appendRawFormatter Foam::vtk::appendRawFormatter
Description Description
Appended raw binary output. Appended raw binary output.
@ -41,7 +41,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -115,7 +115,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,15 +28,15 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::asciiFormatter::name_ = "ascii"; const char* Foam::vtk::asciiFormatter::name_ = "ascii";
const Foam::foamVtkOutput::outputOptions const Foam::vtk::outputOptions
Foam::foamVtkOutput::asciiFormatter::opts_(formatType::INLINE_ASCII); Foam::vtk::asciiFormatter::opts_(formatType::INLINE_ASCII);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline void Foam::foamVtkOutput::asciiFormatter::next() inline void Foam::vtk::asciiFormatter::next()
{ {
if (pos_ == 6) if (pos_ == 6)
{ {
@ -51,7 +51,7 @@ inline void Foam::foamVtkOutput::asciiFormatter::next()
} }
inline void Foam::foamVtkOutput::asciiFormatter::done() inline void Foam::vtk::asciiFormatter::done()
{ {
if (pos_) if (pos_)
{ {
@ -63,14 +63,14 @@ inline void Foam::foamVtkOutput::asciiFormatter::done()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::asciiFormatter::asciiFormatter(std::ostream& os) Foam::vtk::asciiFormatter::asciiFormatter(std::ostream& os)
: :
formatter(os), formatter(os),
pos_(0) pos_(0)
{} {}
Foam::foamVtkOutput::asciiFormatter::asciiFormatter Foam::vtk::asciiFormatter::asciiFormatter
( (
std::ostream& os, std::ostream& os,
unsigned precision unsigned precision
@ -85,7 +85,7 @@ Foam::foamVtkOutput::asciiFormatter::asciiFormatter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::asciiFormatter::~asciiFormatter() Foam::vtk::asciiFormatter::~asciiFormatter()
{ {
done(); done();
} }
@ -93,65 +93,65 @@ Foam::foamVtkOutput::asciiFormatter::~asciiFormatter()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::foamVtkOutput::outputOptions& const Foam::vtk::outputOptions&
Foam::foamVtkOutput::asciiFormatter::opts() const Foam::vtk::asciiFormatter::opts() const
{ {
return opts_; return opts_;
} }
const char* Foam::foamVtkOutput::asciiFormatter::name() const const char* Foam::vtk::asciiFormatter::name() const
{ {
return name_; return name_;
} }
const char* Foam::foamVtkOutput::asciiFormatter::encoding() const const char* Foam::vtk::asciiFormatter::encoding() const
{ {
return name_; return name_;
} }
void Foam::foamVtkOutput::asciiFormatter::writeSize(const uint64_t ignored) void Foam::vtk::asciiFormatter::writeSize(const uint64_t ignored)
{/*nop*/} {/*nop*/}
void Foam::foamVtkOutput::asciiFormatter::write(const uint8_t val) void Foam::vtk::asciiFormatter::write(const uint8_t val)
{ {
next(); next();
os()<< int(val); os()<< int(val);
} }
void Foam::foamVtkOutput::asciiFormatter::write(const label val) void Foam::vtk::asciiFormatter::write(const label val)
{ {
next(); next();
os()<< val; os()<< val;
} }
void Foam::foamVtkOutput::asciiFormatter::write(const float val) void Foam::vtk::asciiFormatter::write(const float val)
{ {
next(); next();
os()<< val; os()<< val;
} }
void Foam::foamVtkOutput::asciiFormatter::write(const double val) void Foam::vtk::asciiFormatter::write(const double val)
{ {
next(); next();
os()<< float(val); os()<< float(val);
} }
void Foam::foamVtkOutput::asciiFormatter::flush() void Foam::vtk::asciiFormatter::flush()
{ {
done(); done();
} }
std::size_t std::size_t
Foam::foamVtkOutput::asciiFormatter::encodedLength(std::size_t ignored) const Foam::vtk::asciiFormatter::encodedLength(std::size_t ignored) const
{ {
return 0; return 0;
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::asciiFormatter Foam::vtk::asciiFormatter
Description Description
Inline ASCII output. Inline ASCII output.
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -125,7 +125,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,15 +28,15 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::base64Formatter::name_ = "binary"; const char* Foam::vtk::base64Formatter::name_ = "binary";
const Foam::foamVtkOutput::outputOptions const Foam::vtk::outputOptions
Foam::foamVtkOutput::base64Formatter::opts_(formatType::INLINE_BASE64); Foam::vtk::base64Formatter::opts_(formatType::INLINE_BASE64);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::base64Formatter::base64Formatter(std::ostream& os) Foam::vtk::base64Formatter::base64Formatter(std::ostream& os)
: :
foamVtkBase64Layer(os) foamVtkBase64Layer(os)
{} {}
@ -44,7 +44,7 @@ Foam::foamVtkOutput::base64Formatter::base64Formatter(std::ostream& os)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::base64Formatter::~base64Formatter() Foam::vtk::base64Formatter::~base64Formatter()
{ {
if (base64Layer::close()) if (base64Layer::close())
{ {
@ -55,20 +55,20 @@ Foam::foamVtkOutput::base64Formatter::~base64Formatter()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::foamVtkOutput::outputOptions& const Foam::vtk::outputOptions&
Foam::foamVtkOutput::base64Formatter::opts() const Foam::vtk::base64Formatter::opts() const
{ {
return opts_; return opts_;
} }
const char* Foam::foamVtkOutput::base64Formatter::name() const const char* Foam::vtk::base64Formatter::name() const
{ {
return name_; return name_;
} }
void Foam::foamVtkOutput::base64Formatter::flush() void Foam::vtk::base64Formatter::flush()
{ {
if (base64Layer::close()) if (base64Layer::close())
{ {

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::base64Formatter Foam::vtk::base64Formatter
Description Description
Inline base-64 encoded binary output. Inline base-64 encoded binary output.
@ -40,7 +40,7 @@ Description
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -95,7 +95,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,12 +27,12 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::foamVtkBase64Layer::encoding_ = "base64"; const char* Foam::vtk::foamVtkBase64Layer::encoding_ = "base64";
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::foamVtkBase64Layer::write void Foam::vtk::foamVtkBase64Layer::write
( (
const char* s, const char* s,
std::streamsize n std::streamsize n
@ -44,7 +44,7 @@ void Foam::foamVtkOutput::foamVtkBase64Layer::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os) Foam::vtk::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
: :
formatter(os), formatter(os),
base64Layer(os) base64Layer(os)
@ -53,7 +53,7 @@ Foam::foamVtkOutput::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::foamVtkBase64Layer::~foamVtkBase64Layer() Foam::vtk::foamVtkBase64Layer::~foamVtkBase64Layer()
{ {
base64Layer::close(); base64Layer::close();
} }
@ -61,39 +61,39 @@ Foam::foamVtkOutput::foamVtkBase64Layer::~foamVtkBase64Layer()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::foamVtkBase64Layer::encoding() const const char* Foam::vtk::foamVtkBase64Layer::encoding() const
{ {
return encoding_; return encoding_;
} }
void Foam::foamVtkOutput::foamVtkBase64Layer::writeSize(const uint64_t nBytes) void Foam::vtk::foamVtkBase64Layer::writeSize(const uint64_t nBytes)
{ {
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t)); write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
} }
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const uint8_t val) void Foam::vtk::foamVtkBase64Layer::write(const uint8_t val)
{ {
base64Layer::add(val); base64Layer::add(val);
} }
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const label val) void Foam::vtk::foamVtkBase64Layer::write(const label val)
{ {
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n'; // std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(label)); write(reinterpret_cast<const char*>(&val), sizeof(label));
} }
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const float val) void Foam::vtk::foamVtkBase64Layer::write(const float val)
{ {
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n'; // std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
write(reinterpret_cast<const char*>(&val), sizeof(float)); write(reinterpret_cast<const char*>(&val), sizeof(float));
} }
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const double val) void Foam::vtk::foamVtkBase64Layer::write(const double val)
{ {
// std::cerr<<"double as float=" << val << '\n'; // std::cerr<<"double as float=" << val << '\n';
float copy(val); float copy(val);
@ -101,13 +101,13 @@ void Foam::foamVtkOutput::foamVtkBase64Layer::write(const double val)
} }
void Foam::foamVtkOutput::foamVtkBase64Layer::flush() void Foam::vtk::foamVtkBase64Layer::flush()
{ {
base64Layer::close(); base64Layer::close();
} }
std::size_t Foam::foamVtkOutput::foamVtkBase64Layer::encodedLength std::size_t Foam::vtk::foamVtkBase64Layer::encodedLength
( (
std::size_t n std::size_t n
) const ) const

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::foamVtkBase64Layer Foam::vtk::foamVtkBase64Layer
Description Description
Base-64 encoded output layer - normally only used indirectly by formatters. Base-64 encoded output layer - normally only used indirectly by formatters.
@ -39,7 +39,7 @@ Description
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -108,7 +108,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,19 +26,19 @@ License
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::formatter::~formatter() Foam::vtk::formatter::~formatter()
{} {}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
std::size_t Foam::foamVtkOutput::formatter::encodedLength(std::size_t n) const std::size_t Foam::vtk::formatter::encodedLength(std::size_t n) const
{ {
return n; return n;
} }
void Foam::foamVtkOutput::formatter::indent() void Foam::vtk::formatter::indent()
{ {
label n = xmlTags_.size() * 2; label n = xmlTags_.size() * 2;
while (n--) while (n--)
@ -48,8 +48,8 @@ void Foam::foamVtkOutput::formatter::indent()
} }
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::xmlHeader() Foam::vtk::formatter::xmlHeader()
{ {
if (inTag_) if (inTag_)
{ {
@ -64,8 +64,8 @@ Foam::foamVtkOutput::formatter::xmlHeader()
} }
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::xmlComment(const std::string& comment) Foam::vtk::formatter::xmlComment(const std::string& comment)
{ {
if (inTag_) if (inTag_)
{ {
@ -81,8 +81,8 @@ Foam::foamVtkOutput::formatter::xmlComment(const std::string& comment)
} }
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::openTag(const word& tagName) Foam::vtk::formatter::openTag(const word& tagName)
{ {
if (inTag_) if (inTag_)
{ {
@ -102,8 +102,8 @@ Foam::foamVtkOutput::formatter::openTag(const word& tagName)
} }
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::closeTag(const bool isEmpty) Foam::vtk::formatter::closeTag(const bool isEmpty)
{ {
if (!inTag_) if (!inTag_)
{ {
@ -126,8 +126,8 @@ Foam::foamVtkOutput::formatter::closeTag(const bool isEmpty)
} }
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::endTag(const word& tagName) Foam::vtk::formatter::endTag(const word& tagName)
{ {
const word curr = xmlTags_.pop(); const word curr = xmlTags_.pop();
indent(); indent();
@ -140,11 +140,11 @@ Foam::foamVtkOutput::formatter::endTag(const word& tagName)
<< endl; << endl;
} }
// verify inTag_ // verify expected end tag
if (!tagName.empty() && tagName != curr) if (!tagName.empty() && tagName != curr)
{ {
WarningInFunction WarningInFunction
<< "expected to end xml-tag '" << tagName << "expecting to end xml-tag '" << tagName
<< "' but found '" << curr << "' instead" << "' but found '" << curr << "' instead"
<< endl; << endl;
} }
@ -157,19 +157,19 @@ Foam::foamVtkOutput::formatter::endTag(const word& tagName)
} }
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::beginVTKFile Foam::vtk::formatter::beginVTKFile
( (
const word& contentType, const word& contentType,
const word& contentVersion, const word& contentVersion,
const bool leaveOpen const bool leaveOpen
) )
{ {
openTag(vtkFileTag::VTK_FILE); openTag(vtk::fileTag::VTK_FILE);
xmlAttr("type", contentType); xmlAttr("type", contentType);
xmlAttr("version", contentVersion); xmlAttr("version", contentVersion);
xmlAttr("byte_order", foamVtkPTraits<Foam::endian>::typeName); xmlAttr("byte_order", vtkPTraits<Foam::endian>::typeName);
xmlAttr("header_type", foamVtkPTraits<headerType>::typeName); xmlAttr("header_type", vtkPTraits<headerType>::typeName);
closeTag(); closeTag();
openTag(contentType); openTag(contentType);
@ -182,8 +182,15 @@ Foam::foamVtkOutput::formatter::beginVTKFile
} }
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::beginAppendedData() Foam::vtk::formatter::endVTKFile()
{
return endTag(vtk::fileTag::VTK_FILE);
}
Foam::vtk::formatter&
Foam::vtk::formatter::beginAppendedData()
{ {
openTag("AppendedData"); openTag("AppendedData");
xmlAttr("encoding", encoding()); xmlAttr("encoding", encoding());
@ -194,8 +201,17 @@ Foam::foamVtkOutput::formatter::beginAppendedData()
} }
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::xmlAttr Foam::vtk::formatter::endAppendedData()
{
flush(); // flush any pending encoded content
os_ << nl; // ensure clear separation from content.
return endTag("AppendedData");
}
Foam::vtk::formatter&
Foam::vtk::formatter::xmlAttr
( (
const word& k, const word& k,
const std::string& v, const std::string& v,

View File

@ -22,12 +22,12 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::formatter Foam::vtk::formatter
Description Description
Abstract class for a VTK output stream formatter. Abstract class for a VTK output stream formatter.
Includes very simple support for writing XML tags. Includes very simple support for writing XML elements.
SourceFiles SourceFiles
foamVtkFormatter.C foamVtkFormatter.C
@ -44,9 +44,8 @@ SourceFiles
#include "word.H" #include "word.H"
#include "UList.H" #include "UList.H"
#include "LIFOStack.H" #include "LIFOStack.H"
#include "foamVtkFileEnums.H" #include "foamVtkCore.H"
#include "foamVtkPTraits.H" #include "foamVtkPTraits.H"
#include "foamVtkOutputTypes.H"
#include <iostream> #include <iostream>
@ -54,7 +53,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
class outputOptions; class outputOptions;
@ -77,13 +76,15 @@ class formatter
mutable bool inTag_; mutable bool inTag_;
//- Write XML attribute // Private Member Functions
//- Write XML attribute key/value pair
template<class Type> template<class Type>
formatter& xmlAttribute formatter& writeAttribute
( (
const word& k, const word& k,
const Type& v, const Type& v,
const char quote const char quote = '\''
); );
@ -161,7 +162,7 @@ public:
//- Open XML tag //- Open XML tag
// \return formatter for chaining // \return formatter for chaining
inline formatter& openTag(const vtkFileTag& tagEnum); inline formatter& openTag(const vtk::fileTag& tagEnum);
//- Close XML tag, optional as an empty container. //- Close XML tag, optional as an empty container.
// Always adds a trailing newline. // Always adds a trailing newline.
@ -176,7 +177,7 @@ public:
//- End XML tag with sanity check //- End XML tag with sanity check
// Always adds a trailing newline. // Always adds a trailing newline.
// \return formatter for chaining // \return formatter for chaining
inline formatter& endTag(const vtkFileTag& tagEnum); inline formatter& endTag(const vtk::fileTag& tagEnum);
//- Write XML tag without any attributes. Combines openTag/closeTag. //- Write XML tag without any attributes. Combines openTag/closeTag.
// \return formatter for chaining // \return formatter for chaining
@ -184,7 +185,7 @@ public:
//- Write XML tag without any attributes. Combines openTag/closeTag. //- Write XML tag without any attributes. Combines openTag/closeTag.
// \return formatter for chaining // \return formatter for chaining
inline formatter& tag(const vtkFileTag& tagEnum); inline formatter& tag(const vtk::fileTag& tagEnum);
//- Add a "VTKFile" XML tag for contentType, followed by a tag for //- Add a "VTKFile" XML tag for contentType, followed by a tag for
// the contentType itself. Optionally leave the contentType tag // the contentType itself. Optionally leave the contentType tag
@ -203,7 +204,7 @@ public:
// \return formatter for chaining // \return formatter for chaining
inline formatter& beginVTKFile inline formatter& beginVTKFile
( (
const vtkFileTag& contentType, const vtk::fileTag& contentType,
const word& contentVersion, const word& contentVersion,
const bool leaveOpen = false const bool leaveOpen = false
); );
@ -222,7 +223,7 @@ public:
//- Open "DataArray" XML tag //- Open "DataArray" XML tag
// \return formatter for chaining // \return formatter for chaining
template<class Type, int nComp=0> template<class Type, int nComp=0>
formatter& openDataArray(const vtkFileTag& tagEnum); formatter& openDataArray(const vtk::dataArrayAttr& attrEnum);
//- Insert a single "PDataArray" XML entry tag. //- Insert a single "PDataArray" XML entry tag.
@ -238,11 +239,11 @@ public:
//- End "AppendedData" XML tag //- End "AppendedData" XML tag
// \return formatter for chaining // \return formatter for chaining
inline formatter& endAppendedData(); formatter& endAppendedData();
//- End "VTKFile" XML tag //- End "VTKFile" XML tag
// \return formatter for chaining // \return formatter for chaining
inline formatter& endVTKFile(); formatter& endVTKFile();
//- Write XML attribute //- Write XML attribute
@ -290,35 +291,39 @@ public:
const char quote = '\'' const char quote = '\''
); );
//- Write XML attribute
// Member Operators // \return formatter for chaining
inline formatter& xmlAttr
(
const vtk::fileAttr& attrEnum,
const int32_t v,
const char quote = '\''
);
//- Write XML attribute //- Write XML attribute
// \return formatter for chaining // \return formatter for chaining
inline formatter& operator()(const word& k, const std::string& v); inline formatter& xmlAttr
(
const vtk::fileAttr& attrEnum,
const int64_t v,
const char quote = '\''
);
//- Write XML attribute //- Write XML attribute
// \return formatter for chaining // \return formatter for chaining
inline formatter& operator()(const word& k, const int32_t v); inline formatter& xmlAttr
(
//- Write XML attribute const vtk::fileAttr& attrEnum,
// \return formatter for chaining const uint64_t v,
inline formatter& operator()(const word& k, const int64_t v); const char quote = '\''
);
//- Write XML attribute
// \return formatter for chaining
inline formatter& operator()(const word& k, const uint64_t v);
//- Write XML attribute
// \return formatter for chaining
inline formatter& operator()(const word& k, const scalar v);
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,7 +25,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::foamVtkOutput::formatter::formatter(std::ostream& os) inline Foam::vtk::formatter::formatter(std::ostream& os)
: :
os_(os), os_(os),
xmlTags_(), xmlTags_(),
@ -35,28 +35,28 @@ inline Foam::foamVtkOutput::formatter::formatter(std::ostream& os)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline std::ostream& Foam::foamVtkOutput::formatter::os() inline std::ostream& Foam::vtk::formatter::os()
{ {
return os_; return os_;
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::openTag(const vtkFileTag& tagEnum) Foam::vtk::formatter::openTag(const vtk::fileTag& tagEnum)
{ {
return openTag(vtkFileTagNames[tagEnum]); return openTag(vtk::fileTagNames[tagEnum]);
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::endTag(const vtkFileTag& tagEnum) Foam::vtk::formatter::endTag(const vtk::fileTag& tagEnum)
{ {
return endTag(vtkFileTagNames[tagEnum]); return endTag(vtk::fileTagNames[tagEnum]);
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::tag(const word& tagName) Foam::vtk::formatter::tag(const word& tagName)
{ {
openTag(tagName); openTag(tagName);
closeTag(); closeTag();
@ -65,135 +65,118 @@ Foam::foamVtkOutput::formatter::tag(const word& tagName)
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::tag(const vtkFileTag& tagEnum) Foam::vtk::formatter::tag(const vtk::fileTag& tagEnum)
{ {
return tag(vtkFileTagNames[tagEnum]); return tag(vtk::fileTagNames[tagEnum]);
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::beginVTKFile Foam::vtk::formatter::beginVTKFile
( (
const vtkFileTag& contentType, const vtk::fileTag& contentType,
const word& contentVersion, const word& contentVersion,
const bool leaveOpen const bool leaveOpen
) )
{ {
return beginVTKFile return beginVTKFile
( (
vtkFileTagNames[contentType], vtk::fileTagNames[contentType],
contentVersion, contentVersion,
leaveOpen leaveOpen
); );
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::endDataArray() Foam::vtk::formatter::endDataArray()
{ {
return endTag("DataArray"); return endTag("DataArray");
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::endAppendedData() Foam::vtk::formatter::xmlAttr
{
flush(); // flush any pending encoded content
os_ << '\n'; // clear separation from content.
return endTag("AppendedData");
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::endVTKFile()
{
return endTag(vtkFileTag::VTK_FILE);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::xmlAttr
( (
const word& k, const word& k,
const int32_t v, const int32_t v,
const char quote const char quote
) )
{ {
return xmlAttribute(k, v, quote); return writeAttribute(k, v, quote);
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::xmlAttr Foam::vtk::formatter::xmlAttr
( (
const word& k, const word& k,
const int64_t v, const int64_t v,
const char quote const char quote
) )
{ {
return xmlAttribute(k, v, quote); return writeAttribute(k, v, quote);
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::xmlAttr Foam::vtk::formatter::xmlAttr
( (
const word& k, const word& k,
const uint64_t v, const uint64_t v,
const char quote const char quote
) )
{ {
return xmlAttribute(k, v, quote); return writeAttribute(k, v, quote);
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::xmlAttr Foam::vtk::formatter::xmlAttr
( (
const word& k, const word& k,
const scalar v, const scalar v,
const char quote const char quote
) )
{ {
return xmlAttribute(k, v, quote); return writeAttribute(k, v, quote);
} }
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // inline Foam::vtk::formatter&
Foam::vtk::formatter::xmlAttr
inline Foam::foamVtkOutput::formatter& (
Foam::foamVtkOutput::formatter::operator()(const word& k, const std::string& v) const vtk::fileAttr& attrEnum,
const int32_t v,
const char quote
)
{ {
return xmlAttr(k, v); return xmlAttr(vtk::fileAttrNames[attrEnum], v, quote);
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::operator()(const word& k, const int32_t v) Foam::vtk::formatter::xmlAttr
(
const vtk::fileAttr& attrEnum,
const int64_t v,
const char quote
)
{ {
return xmlAttr(k, v); return xmlAttr(vtk::fileAttrNames[attrEnum], v, quote);
} }
inline Foam::foamVtkOutput::formatter& inline Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::operator()(const word& k, const int64_t v) Foam::vtk::formatter::xmlAttr
(
const vtk::fileAttr& attrEnum,
const uint64_t v,
const char quote
)
{ {
return xmlAttr(k, v); return xmlAttr(vtk::fileAttrNames[attrEnum], v, quote);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::operator()(const word& k, const uint64_t v)
{
return xmlAttr(k, v);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::operator()(const word& k, const scalar v)
{
return xmlAttr(k, v);
} }

View File

@ -27,8 +27,8 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::xmlAttribute Foam::vtk::formatter::writeAttribute
( (
const word& k, const word& k,
const Type& v, const Type& v,
@ -49,18 +49,18 @@ Foam::foamVtkOutput::formatter::xmlAttribute
template<class Type, int nComp> template<class Type, int nComp>
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::openDataArray Foam::vtk::formatter::openDataArray
( (
const word& dataName const word& dataName
) )
{ {
openTag("DataArray"); openTag("DataArray");
xmlAttr("type", foamVtkPTraits<Type>::typeName); xmlAttr("type", vtkPTraits<Type>::typeName);
xmlAttr("Name", dataName); xmlAttr("Name", dataName);
if (nComp > 1) if (nComp > 1)
{ {
xmlAttr("NumberOfComponents", nComp); xmlAttr(fileAttr::NUMBER_OF_COMPONENTS, nComp);
} }
xmlAttr("format", name()); xmlAttr("format", name());
@ -69,32 +69,32 @@ Foam::foamVtkOutput::formatter::openDataArray
template<class Type, int nComp> template<class Type, int nComp>
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::openDataArray Foam::vtk::formatter::openDataArray
( (
const vtkFileTag& tagEnum const vtk::dataArrayAttr& attrEnum
) )
{ {
return openDataArray<Type, nComp>(vtkFileTagNames[tagEnum]); return openDataArray<Type, nComp>(vtk::dataArrayAttrNames[attrEnum]);
} }
template<class Type, int nComp> template<class Type, int nComp>
Foam::foamVtkOutput::formatter& Foam::vtk::formatter&
Foam::foamVtkOutput::formatter::PDataArray Foam::vtk::formatter::PDataArray
( (
const word& dataName const word& dataName
) )
{ {
openTag("PDataArray"); openTag("PDataArray");
xmlAttr("type", foamVtkPTraits<Type>::typeName); xmlAttr("type", vtkPTraits<Type>::typeName);
if (dataName.size()) if (dataName.size())
{ {
xmlAttr("Name", dataName); xmlAttr("Name", dataName);
} }
if (nComp > 1) if (nComp > 1)
{ {
xmlAttr("NumberOfComponents", nComp); xmlAttr(fileAttr::NUMBER_OF_COMPONENTS, nComp);
} }
closeTag(true); closeTag(true);

View File

@ -28,15 +28,15 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::legacyAsciiFormatter::legacyName_ = "ASCII"; const char* Foam::vtk::legacyAsciiFormatter::legacyName_ = "ASCII";
const Foam::foamVtkOutput::outputOptions const Foam::vtk::outputOptions
Foam::foamVtkOutput::legacyAsciiFormatter::opts_(formatType::LEGACY_ASCII); Foam::vtk::legacyAsciiFormatter::opts_(formatType::LEGACY_ASCII);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::legacyAsciiFormatter::legacyAsciiFormatter Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
( (
std::ostream& os std::ostream& os
) )
@ -45,7 +45,7 @@ Foam::foamVtkOutput::legacyAsciiFormatter::legacyAsciiFormatter
{} {}
Foam::foamVtkOutput::legacyAsciiFormatter::legacyAsciiFormatter Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
( (
std::ostream& os, std::ostream& os,
unsigned precision unsigned precision
@ -57,26 +57,26 @@ Foam::foamVtkOutput::legacyAsciiFormatter::legacyAsciiFormatter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::legacyAsciiFormatter::~legacyAsciiFormatter() Foam::vtk::legacyAsciiFormatter::~legacyAsciiFormatter()
{} {}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::foamVtkOutput::outputOptions& const Foam::vtk::outputOptions&
Foam::foamVtkOutput::legacyAsciiFormatter::opts() const Foam::vtk::legacyAsciiFormatter::opts() const
{ {
return opts_; return opts_;
} }
const char* Foam::foamVtkOutput::legacyAsciiFormatter::name() const const char* Foam::vtk::legacyAsciiFormatter::name() const
{ {
return legacyName_; return legacyName_;
} }
const char* Foam::foamVtkOutput::legacyAsciiFormatter::encoding() const const char* Foam::vtk::legacyAsciiFormatter::encoding() const
{ {
return legacyName_; return legacyName_;
} }

View File

@ -22,10 +22,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::legacyAsciiFormatter Foam::vtk::legacyAsciiFormatter
Description Description
Formatting as per Foam::foamVtkOutput::asciiFormatter, but with Formatting as per Foam::vtk::asciiFormatter, but with
naming for legacy output. naming for legacy output.
SourceFiles SourceFiles
@ -42,7 +42,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -99,7 +99,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -29,15 +29,15 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::legacyRawFormatter::legacyName_ = "BINARY"; const char* Foam::vtk::legacyRawFormatter::legacyName_ = "BINARY";
const Foam::foamVtkOutput::outputOptions const Foam::vtk::outputOptions
Foam::foamVtkOutput::legacyRawFormatter::opts_(formatType::LEGACY_BINARY); Foam::vtk::legacyRawFormatter::opts_(formatType::LEGACY_BINARY);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::legacyRawFormatter::write void Foam::vtk::legacyRawFormatter::write
( (
const char* s, const char* s,
std::streamsize n std::streamsize n
@ -49,7 +49,7 @@ void Foam::foamVtkOutput::legacyRawFormatter::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::legacyRawFormatter::legacyRawFormatter Foam::vtk::legacyRawFormatter::legacyRawFormatter
( (
std::ostream& os std::ostream& os
) )
@ -60,39 +60,39 @@ Foam::foamVtkOutput::legacyRawFormatter::legacyRawFormatter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::legacyRawFormatter::~legacyRawFormatter() Foam::vtk::legacyRawFormatter::~legacyRawFormatter()
{} {}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::foamVtkOutput::outputOptions& const Foam::vtk::outputOptions&
Foam::foamVtkOutput::legacyRawFormatter::opts() const Foam::vtk::legacyRawFormatter::opts() const
{ {
return opts_; return opts_;
} }
const char* Foam::foamVtkOutput::legacyRawFormatter::name() const const char* Foam::vtk::legacyRawFormatter::name() const
{ {
return legacyName_; return legacyName_;
} }
const char* Foam::foamVtkOutput::legacyRawFormatter::encoding() const const char* Foam::vtk::legacyRawFormatter::encoding() const
{ {
return legacyName_; return legacyName_;
} }
void Foam::foamVtkOutput::legacyRawFormatter::writeSize void Foam::vtk::legacyRawFormatter::writeSize
( (
const uint64_t ignored const uint64_t ignored
) )
{/*nop*/} {/*nop*/}
void Foam::foamVtkOutput::legacyRawFormatter::write void Foam::vtk::legacyRawFormatter::write
( (
const uint8_t val const uint8_t val
) )
@ -104,7 +104,7 @@ void Foam::foamVtkOutput::legacyRawFormatter::write
} }
void Foam::foamVtkOutput::legacyRawFormatter::write void Foam::vtk::legacyRawFormatter::write
( (
const label val const label val
) )
@ -127,7 +127,7 @@ void Foam::foamVtkOutput::legacyRawFormatter::write
} }
void Foam::foamVtkOutput::legacyRawFormatter::write void Foam::vtk::legacyRawFormatter::write
( (
const float val const float val
) )
@ -148,7 +148,7 @@ void Foam::foamVtkOutput::legacyRawFormatter::write
} }
void Foam::foamVtkOutput::legacyRawFormatter::write void Foam::vtk::legacyRawFormatter::write
( (
const double val const double val
) )
@ -160,7 +160,7 @@ void Foam::foamVtkOutput::legacyRawFormatter::write
} }
void Foam::foamVtkOutput::legacyRawFormatter::flush() void Foam::vtk::legacyRawFormatter::flush()
{ {
os()<< '\n'; os()<< '\n';
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::legacyRawFormatter Foam::vtk::legacyRawFormatter
Description Description
Binary output for the VTK legacy format, always written as big-endian Binary output for the VTK legacy format, always written as big-endian
@ -44,7 +44,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -118,7 +118,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -36,58 +36,58 @@ License
// * * * * * * * * * * * * * * * Static Data * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Static Data * * * * * * * * * * * * * * * * //
const Foam::Enum<Foam::vtkFileTag> const Foam::Enum<Foam::vtk::fileTag>
Foam::foamVtkOutput::legacy::contentNames Foam::vtk::legacy::contentNames
{ {
{ vtkFileTag::POLY_DATA, "POLYDATA" }, { vtk::fileTag::POLY_DATA, "POLYDATA" },
{ vtkFileTag::UNSTRUCTURED_GRID, "UNSTRUCTURED_GRID" }, { vtk::fileTag::UNSTRUCTURED_GRID, "UNSTRUCTURED_GRID" },
}; };
const Foam::Enum<Foam::vtkFileTag> const Foam::Enum<Foam::vtk::fileTag>
Foam::foamVtkOutput::legacy::dataTypeNames Foam::vtk::legacy::dataTypeNames
{ {
{ vtkFileTag::CELL_DATA, "CELL_DATA" }, { vtk::fileTag::CELL_DATA, "CELL_DATA" },
{ vtkFileTag::POINT_DATA, "POINT_DATA" } { vtk::fileTag::POINT_DATA, "POINT_DATA" }
}; };
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::foamVtkOutput::formatter> Foam::autoPtr<Foam::vtk::formatter>
Foam::foamVtkOutput::newFormatter Foam::vtk::newFormatter
( (
std::ostream& os, std::ostream& os,
const enum formatType fmtType, const enum formatType fmtType,
unsigned prec unsigned prec
) )
{ {
autoPtr<foamVtkOutput::formatter> fmt; autoPtr<vtk::formatter> fmt;
switch (fmtType) switch (fmtType)
{ {
case formatType::INLINE_ASCII: case formatType::INLINE_ASCII:
fmt.set(new foamVtkOutput::asciiFormatter(os, prec)); fmt.set(new vtk::asciiFormatter(os, prec));
break; break;
case formatType::INLINE_BASE64: case formatType::INLINE_BASE64:
fmt.set(new foamVtkOutput::base64Formatter(os)); fmt.set(new vtk::base64Formatter(os));
break; break;
case formatType::APPEND_BASE64: case formatType::APPEND_BASE64:
fmt.set(new foamVtkOutput::appendBase64Formatter(os)); fmt.set(new vtk::appendBase64Formatter(os));
break; break;
case formatType::APPEND_BINARY: case formatType::APPEND_BINARY:
fmt.set(new foamVtkOutput::appendRawFormatter(os)); fmt.set(new vtk::appendRawFormatter(os));
break; break;
case formatType::LEGACY_ASCII: case formatType::LEGACY_ASCII:
fmt.set(new foamVtkOutput::legacyAsciiFormatter(os, prec)); fmt.set(new vtk::legacyAsciiFormatter(os, prec));
break; break;
case formatType::LEGACY_BINARY: case formatType::LEGACY_BINARY:
fmt.set(new foamVtkOutput::legacyRawFormatter(os)); fmt.set(new vtk::legacyRawFormatter(os));
break; break;
} }
@ -95,7 +95,7 @@ Foam::foamVtkOutput::newFormatter
} }
Foam::label Foam::foamVtkOutput::writeVtmFile Foam::label Foam::vtk::writeVtmFile
( (
std::ostream& os, std::ostream& os,
const UList<fileName>& files const UList<fileName>& files
@ -112,9 +112,9 @@ Foam::label Foam::foamVtkOutput::writeVtmFile
forAll(files, i) forAll(files, i)
{ {
vtmFile vtmFile
.openTag(vtkFileTag::DATA_SET) .openTag(vtk::fileTag::DATA_SET)
( "index", i ) .xmlAttr("index", i)
( "file", files[i] ) .xmlAttr("file", files[i])
.closeTag(true); .closeTag(true);
} }
@ -124,9 +124,9 @@ Foam::label Foam::foamVtkOutput::writeVtmFile
} }
std::ostream& Foam::foamVtkOutput::legacy::fileHeader std::ostream& Foam::vtk::legacy::fileHeader
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const std::string& title, const std::string& title,
const std::string& contentType const std::string& contentType
) )

View File

@ -22,14 +22,14 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Namespace Namespace
Foam::foamVtkOutput Foam::vtk
Description Description
Namespace for handling VTK output. Namespace for handling VTK output.
Contains classes and functions for writing VTK file content. Contains classes and functions for writing VTK file content.
Namespace Namespace
Foam::foamVtkOutput::legacy Foam::vtk::legacy
Description Description
Namespace for legacy VTK output constants and functions. Namespace for legacy VTK output constants and functions.
@ -45,7 +45,7 @@ SourceFiles
#include "autoPtr.H" #include "autoPtr.H"
#include "Enum.H" #include "Enum.H"
#include "foamVtkOutputTypes.H" #include "foamVtkCore.H"
#include "foamVtkFormatter.H" #include "foamVtkFormatter.H"
#include "floatScalar.H" #include "floatScalar.H"
#include "IOstream.H" #include "IOstream.H"
@ -54,27 +54,20 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Typedefs
//- Use UInt64 for header data
typedef formatter::headerType headerType;
// Constants // Constants
// General Functions // General Functions
//- Return a default asciiFormatter //- Return a default asciiFormatter
autoPtr<foamVtkOutput::formatter> newFormatter(std::ostream& os); autoPtr<vtk::formatter> newFormatter(std::ostream& os);
//- Return a new formatter based on the specified format type //- Return a new formatter based on the specified format type
autoPtr<foamVtkOutput::formatter> newFormatter autoPtr<vtk::formatter> newFormatter
( (
std::ostream& os, std::ostream& os,
const enum formatType fmtType, const enum formatType fmtType,
@ -90,7 +83,7 @@ namespace foamVtkOutput
template<class Type> template<class Type>
inline void write inline void write
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const Type& val const Type& val
); );
@ -100,7 +93,7 @@ namespace foamVtkOutput
template<class Type> template<class Type>
void writeList void writeList
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const UList<Type>& lst const UList<Type>& lst
); );
@ -109,7 +102,7 @@ namespace foamVtkOutput
template<class Type, unsigned Size> template<class Type, unsigned Size>
void writeList void writeList
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const FixedList<Type, Size>& lst const FixedList<Type, Size>& lst
); );
@ -119,7 +112,7 @@ namespace foamVtkOutput
template<class Type> template<class Type>
void writeList void writeList
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const UList<Type>& lst, const UList<Type>& lst,
const UList<label>& addressing const UList<label>& addressing
); );
@ -136,10 +129,10 @@ namespace legacy
// Constants // Constants
//- Strings corresponding to the (POLYDATA, UNSTRUCTURED_GRID) elements //- Strings corresponding to the (POLYDATA, UNSTRUCTURED_GRID) elements
extern const Foam::Enum<vtkFileTag> contentNames; extern const Foam::Enum<vtk::fileTag> contentNames;
//- Strings corresponding to the (CELL_DATA, POINT_DATA) elements //- Strings corresponding to the (CELL_DATA, POINT_DATA) elements
extern const Foam::Enum<vtkFileTag> dataTypeNames; extern const Foam::Enum<vtk::fileTag> dataTypeNames;
// Functions // Functions
@ -158,9 +151,9 @@ namespace legacy
// Includes "DATASET" with the specified dataset type. // Includes "DATASET" with the specified dataset type.
inline void fileHeader inline void fileHeader
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const std::string& title, const std::string& title,
const vtkFileTag& contentTypeTag const vtk::fileTag& contentTypeTag
); );
//- Emit header for legacy file, with "ASCII" or "BINARY" depending on //- Emit header for legacy file, with "ASCII" or "BINARY" depending on
@ -168,7 +161,7 @@ namespace legacy
// If the contentType is non-empty, it is used for "DATASET" line. // If the contentType is non-empty, it is used for "DATASET" line.
std::ostream& fileHeader std::ostream& fileHeader
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const std::string& title, const std::string& title,
const std::string& contentType const std::string& contentType
); );
@ -189,14 +182,14 @@ namespace legacy
); );
//- Use the enumerations vtkFileTag::CELL_DATA, vtkFileTag::POINT_DATA, //- Use the enumerations vtk::fileTag::CELL_DATA, vtk::fileTag::POINT_DATA,
// to emit a legacy CELL_DATA, POINT_DATA element. // to emit a legacy CELL_DATA, POINT_DATA element.
// The nEntries corresponds similarly to the number of cells or points, // The nEntries corresponds similarly to the number of cells or points,
// respectively. // respectively.
inline void dataHeader inline void dataHeader
( (
std::ostream& os, std::ostream& os,
const vtkFileTag& dataTypeTag, const vtk::fileTag& dataTypeTag,
const label nEntries, const label nEntries,
const label nFields const label nFields
); );
@ -219,11 +212,12 @@ namespace legacy
const label nEntries const label nEntries
); );
}; } // End namespace legacy
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam

View File

@ -27,12 +27,12 @@ License
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
//- Template specialization for label //- Template specialization for label
template<> template<>
inline void write<label>(foamVtkOutput::formatter& fmt, const label& val) inline void write<label>(vtk::formatter& fmt, const label& val)
{ {
fmt.write(val); fmt.write(val);
} }
@ -40,7 +40,7 @@ inline void write<label>(foamVtkOutput::formatter& fmt, const label& val)
//- Template specialization for float //- Template specialization for float
template<> template<>
inline void write<float>(foamVtkOutput::formatter& fmt, const float& val) inline void write<float>(vtk::formatter& fmt, const float& val)
{ {
fmt.write(val); fmt.write(val);
} }
@ -48,18 +48,18 @@ inline void write<float>(foamVtkOutput::formatter& fmt, const float& val)
//- Template specialization for double //- Template specialization for double
template<> template<>
inline void write<double>(foamVtkOutput::formatter& fmt, const double& val) inline void write<double>(vtk::formatter& fmt, const double& val)
{ {
fmt.write(val); fmt.write(val);
} }
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
inline std::ostream& Foam::foamVtkOutput::legacy::fileHeader inline std::ostream& Foam::vtk::legacy::fileHeader
( (
std::ostream& os, std::ostream& os,
const std::string& title, const std::string& title,
@ -74,18 +74,18 @@ inline std::ostream& Foam::foamVtkOutput::legacy::fileHeader
} }
inline void Foam::foamVtkOutput::legacy::fileHeader inline void Foam::vtk::legacy::fileHeader
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const std::string& title, const std::string& title,
const vtkFileTag& contentTypeTag const vtk::fileTag& contentTypeTag
) )
{ {
fileHeader(fmt, title, contentNames[contentTypeTag]); fileHeader(fmt, title, contentNames[contentTypeTag]);
} }
inline void Foam::foamVtkOutput::legacy::beginPoints inline void Foam::vtk::legacy::beginPoints
( (
std::ostream& os, std::ostream& os,
const label nPoints const label nPoints
@ -95,7 +95,7 @@ inline void Foam::foamVtkOutput::legacy::beginPoints
} }
inline void Foam::foamVtkOutput::legacy::beginPolys inline void Foam::vtk::legacy::beginPolys
( (
std::ostream& os, std::ostream& os,
const label nPolys, const label nPolys,
@ -106,10 +106,10 @@ inline void Foam::foamVtkOutput::legacy::beginPolys
} }
inline void Foam::foamVtkOutput::legacy::dataHeader inline void Foam::vtk::legacy::dataHeader
( (
std::ostream& os, std::ostream& os,
const vtkFileTag& dataTypeTag, const vtk::fileTag& dataTypeTag,
const label nEntries, const label nEntries,
const label nFields const label nFields
) )
@ -119,7 +119,7 @@ inline void Foam::foamVtkOutput::legacy::dataHeader
} }
inline void Foam::foamVtkOutput::legacy::floatField inline void Foam::vtk::legacy::floatField
( (
std::ostream& os, std::ostream& os,
const word& fieldName, const word& fieldName,
@ -131,7 +131,7 @@ inline void Foam::foamVtkOutput::legacy::floatField
} }
inline void Foam::foamVtkOutput::legacy::intField inline void Foam::vtk::legacy::intField
( (
std::ostream& os, std::ostream& os,
const word& fieldName, const word& fieldName,

View File

@ -28,8 +28,8 @@ License
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::foamVtkOutput::outputOptions& Foam::vtk::outputOptions&
Foam::foamVtkOutput::outputOptions::ascii(bool on) Foam::vtk::outputOptions::ascii(bool on)
{ {
if (on) if (on)
{ {
@ -76,8 +76,8 @@ Foam::foamVtkOutput::outputOptions::ascii(bool on)
} }
Foam::foamVtkOutput::outputOptions& Foam::vtk::outputOptions&
Foam::foamVtkOutput::outputOptions::append(bool on) Foam::vtk::outputOptions::append(bool on)
{ {
if (on) if (on)
{ {
@ -118,8 +118,8 @@ Foam::foamVtkOutput::outputOptions::append(bool on)
} }
Foam::foamVtkOutput::outputOptions& Foam::vtk::outputOptions&
Foam::foamVtkOutput::outputOptions::legacy(bool on) Foam::vtk::outputOptions::legacy(bool on)
{ {
if (on) if (on)
{ {
@ -160,15 +160,15 @@ Foam::foamVtkOutput::outputOptions::legacy(bool on)
} }
Foam::foamVtkOutput::outputOptions& Foam::vtk::outputOptions&
Foam::foamVtkOutput::outputOptions::precision(unsigned prec) Foam::vtk::outputOptions::precision(unsigned prec)
{ {
precision_ = prec; precision_ = prec;
return *this; return *this;
} }
Foam::string Foam::foamVtkOutput::outputOptions::description() const Foam::string Foam::vtk::outputOptions::description() const
{ {
switch (fmtType_) switch (fmtType_)
{ {

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::foamVtkOutput::outputOptions Foam::vtk::outputOptions
Description Description
Encapsulated combinations of output format options. Encapsulated combinations of output format options.
@ -47,7 +47,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace foamVtkOutput namespace vtk
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -148,7 +148,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,14 +28,14 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::foamVtkOutput::outputOptions::outputOptions() inline Foam::vtk::outputOptions::outputOptions()
: :
fmtType_(formatType::INLINE_ASCII), fmtType_(formatType::INLINE_ASCII),
precision_(IOstream::defaultPrecision()) precision_(IOstream::defaultPrecision())
{} {}
inline Foam::foamVtkOutput::outputOptions::outputOptions inline Foam::vtk::outputOptions::outputOptions
( (
enum formatType fmtType enum formatType fmtType
) )
@ -47,23 +47,23 @@ inline Foam::foamVtkOutput::outputOptions::outputOptions
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
inline Foam::autoPtr<Foam::foamVtkOutput::formatter> inline Foam::autoPtr<Foam::vtk::formatter>
Foam::foamVtkOutput::outputOptions::newFormatter(std::ostream& os) const Foam::vtk::outputOptions::newFormatter(std::ostream& os) const
{ {
return foamVtkOutput::newFormatter(os, fmtType_, precision_); return vtk::newFormatter(os, fmtType_, precision_);
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
inline Foam::foamVtkOutput::formatType inline Foam::vtk::formatType
Foam::foamVtkOutput::outputOptions::fmt() const Foam::vtk::outputOptions::fmt() const
{ {
return fmtType_; return fmtType_;
} }
inline bool Foam::foamVtkOutput::outputOptions::legacy() const inline bool Foam::vtk::outputOptions::legacy() const
{ {
return return
( (
@ -73,13 +73,13 @@ inline bool Foam::foamVtkOutput::outputOptions::legacy() const
} }
inline bool Foam::foamVtkOutput::outputOptions::xml() const inline bool Foam::vtk::outputOptions::xml() const
{ {
return !legacy(); return !legacy();
} }
inline bool Foam::foamVtkOutput::outputOptions::append() const inline bool Foam::vtk::outputOptions::append() const
{ {
return return
( (
@ -89,19 +89,19 @@ inline bool Foam::foamVtkOutput::outputOptions::append() const
} }
inline bool Foam::foamVtkOutput::outputOptions::insitu() const inline bool Foam::vtk::outputOptions::insitu() const
{ {
return !append(); return !append();
} }
inline bool Foam::foamVtkOutput::outputOptions::ascii() const inline bool Foam::vtk::outputOptions::ascii() const
{ {
return !(unsigned(fmtType_) & 0x0F); return !(unsigned(fmtType_) & 0x0F);
} }
inline unsigned Foam::foamVtkOutput::outputOptions::precision() const inline unsigned Foam::vtk::outputOptions::precision() const
{ {
return precision_; return precision_;
} }

View File

@ -26,9 +26,9 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
inline void Foam::foamVtkOutput::write inline void Foam::vtk::write
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const Type& val const Type& val
) )
{ {
@ -40,9 +40,9 @@ inline void Foam::foamVtkOutput::write
template<class Type> template<class Type>
void Foam::foamVtkOutput::writeList void Foam::vtk::writeList
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const UList<Type>& lst const UList<Type>& lst
) )
{ {
@ -54,9 +54,9 @@ void Foam::foamVtkOutput::writeList
template<class Type, unsigned Size> template<class Type, unsigned Size>
void Foam::foamVtkOutput::writeList void Foam::vtk::writeList
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const FixedList<Type, Size>& lst const FixedList<Type, Size>& lst
) )
{ {
@ -68,9 +68,9 @@ void Foam::foamVtkOutput::writeList
template<class Type> template<class Type>
void Foam::foamVtkOutput::writeList void Foam::vtk::writeList
( (
foamVtkOutput::formatter& fmt, vtk::formatter& fmt,
const UList<Type>& lst, const UList<Type>& lst,
const UList<label>& addressing const UList<label>& addressing
) )

View File

@ -125,7 +125,7 @@ void Foam::vtkUnstructuredReader::extractCells
{ {
switch (cellTypes[i]) switch (cellTypes[i])
{ {
case foamVtkCore::VTK_VERTEX: case vtk::cellType::VTK_VERTEX:
{ {
warnUnhandledType(inFile, cellTypes[i], warningGiven); warnUnhandledType(inFile, cellTypes[i], warningGiven);
label nRead = cellVertData[dataIndex++]; label nRead = cellVertData[dataIndex++];
@ -141,7 +141,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_POLY_VERTEX: case vtk::cellType::VTK_POLY_VERTEX:
{ {
warnUnhandledType(inFile, cellTypes[i], warningGiven); warnUnhandledType(inFile, cellTypes[i], warningGiven);
label nRead = cellVertData[dataIndex++]; label nRead = cellVertData[dataIndex++];
@ -149,7 +149,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_LINE: case vtk::cellType::VTK_LINE:
{ {
//warnUnhandledType(inFile, cellTypes[i], warningGiven); //warnUnhandledType(inFile, cellTypes[i], warningGiven);
label nRead = cellVertData[dataIndex++]; label nRead = cellVertData[dataIndex++];
@ -169,7 +169,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_POLY_LINE: case vtk::cellType::VTK_POLY_LINE:
{ {
//warnUnhandledType(inFile, cellTypes[i], warningGiven); //warnUnhandledType(inFile, cellTypes[i], warningGiven);
label nRead = cellVertData[dataIndex++]; label nRead = cellVertData[dataIndex++];
@ -183,7 +183,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_TRIANGLE: case vtk::cellType::VTK_TRIANGLE:
{ {
faceMap_[facei] = i; faceMap_[facei] = i;
face& f = faces_[facei++]; face& f = faces_[facei++];
@ -203,7 +203,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_QUAD: case vtk::cellType::VTK_QUAD:
{ {
faceMap_[facei] = i; faceMap_[facei] = i;
face& f = faces_[facei++]; face& f = faces_[facei++];
@ -224,7 +224,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_POLYGON: case vtk::cellType::VTK_POLYGON:
{ {
faceMap_[facei] = i; faceMap_[facei] = i;
face& f = faces_[facei++]; face& f = faces_[facei++];
@ -237,7 +237,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_TETRA: case vtk::cellType::VTK_TETRA:
{ {
label nRead = cellVertData[dataIndex++]; label nRead = cellVertData[dataIndex++];
if (nRead != 4) if (nRead != 4)
@ -257,7 +257,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_PYRAMID: case vtk::cellType::VTK_PYRAMID:
{ {
label nRead = cellVertData[dataIndex++]; label nRead = cellVertData[dataIndex++];
if (nRead != 5) if (nRead != 5)
@ -278,7 +278,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_WEDGE: case vtk::cellType::VTK_WEDGE:
{ {
label nRead = cellVertData[dataIndex++]; label nRead = cellVertData[dataIndex++];
if (nRead != 6) if (nRead != 6)
@ -300,7 +300,7 @@ void Foam::vtkUnstructuredReader::extractCells
} }
break; break;
case foamVtkCore::VTK_HEXAHEDRON: case vtk::cellType::VTK_HEXAHEDRON:
{ {
label nRead = cellVertData[dataIndex++]; label nRead = cellVertData[dataIndex++];
if (nRead != 8) if (nRead != 8)

View File

@ -63,8 +63,6 @@ namespace Foam
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class vtkUnstructuredReader class vtkUnstructuredReader
:
public fileFormats::foamVtkCore
{ {
public: public:
@ -206,7 +204,7 @@ private:
void read(ISstream& inFile); void read(ISstream& inFile);
//- Dissallow assignment //- Disallow assignment
void operator=(const vtkUnstructuredReader&); void operator=(const vtkUnstructuredReader&);
@ -220,6 +218,7 @@ public:
//- Construct from Istream, read all //- Construct from Istream, read all
vtkUnstructuredReader(const objectRegistry& obr, ISstream&); vtkUnstructuredReader(const objectRegistry& obr, ISstream&);
// Member Functions // Member Functions
//- Header //- Header

View File

@ -1,64 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "foamVtkFileEnums.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const Foam::Enum<Foam::vtkFileTag> Foam::vtkFileTagNames
(
vtkFileTag::VTK_FILE,
{
"VTKFile",
"DataArray",
"Piece",
"DataSet",
"Points",
"Cells",
"Polys",
"Verts",
"CellData",
"PointData",
"PolyData",
"UnstructuredGrid",
}
);
const Foam::Enum<Foam::vtkFileAttr> Foam::vtkFileAttrNames
(
vtkFileAttr::OFFSET,
{
"offset",
"NumberOfPoints",
"NumberOfCells",
"NumberOfPolys",
"NumberOfVerts"
}
);
// ************************************************************************* //

View File

@ -1,90 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamespace
Foam::foam
Description
Enumerations for commonly used VTK file items.
SourceFiles
foamVtkFileEnums.C
\*---------------------------------------------------------------------------*/
#ifndef foamVtkFileEnums_H
#define foamVtkFileEnums_H
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Some common XML tags for vtk files
enum class vtkFileTag
{
VTK_FILE, //!< "VTKFile"
DATA_ARRAY, //!< "DataArray"
PIECE, //!< "Piece"
DATA_SET, //!< "DataSet"
POINTS, //!< "Points"
CELLS, //!< "Cells"
POLYS, //!< "Polys"
VERTS, //!< "Verts"
CELL_DATA, //!< "CellData"
POINT_DATA, //!< "PointData"
POLY_DATA, //!< "PolyData"
UNSTRUCTURED_GRID, //!< "UnstructuredGrid"
};
//- Strings corresponding to the elements
extern const Foam::Enum<vtkFileTag> vtkFileTagNames;
//- Some common XML attributes for vtk files
enum class vtkFileAttr
{
OFFSET, //!< "offset"
NUMBER_OF_POINTS, //!< "NumberOfPoints"
NUMBER_OF_CELLS, //!< "NumberOfCells"
NUMBER_OF_POLYS, //!< "NumberOfPolys"
NUMBER_OF_VERTS, //!< "NumberOfVerts"
};
//- Strings corresponding to the elements
extern const Foam::Enum<vtkFileAttr> vtkFileAttrNames;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,77 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamespace
Foam::foamVtkOutput
Description
Enumerations and typedefs for VTK output.
SourceFiles
foamVtkOutputTypes.H
\*---------------------------------------------------------------------------*/
#ifndef foamVtkOutputTypes_H
#define foamVtkOutputTypes_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace foamVtkOutput
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Enumerations
//- The output format type for file contents.
// Upper bits for output type, lower bits for the format itself.
enum class formatType
{
/** XML inline ASCII, using the asciiFormatter */
INLINE_ASCII = 0,
/** XML inline base64, using the base64Formatter */
INLINE_BASE64 = 0x01,
/** XML append base64, using the appendBase64Formatter */
APPEND_BASE64 = 0x11,
/** XML append raw binary, using the appendRawFormatter */
APPEND_BINARY = 0x12,
/** Legacy ASCII, using the legacyAsciiFormatter */
LEGACY_ASCII = 0x20,
/** Legacy raw binary, using the legacyRawFormatter */
LEGACY_BINARY = 0x22,
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -115,20 +115,20 @@ bool Foam::functionObjects::writeVTK::write()
Info<< " Internal : " << outputName << endl; Info<< " Internal : " << outputName << endl;
foamVtkCells foamVtkMeshCells vtk::vtuCells meshCells
( (
mesh_, mesh_,
foamVtkCells::contentType::LEGACY, vtk::vtuCells::contentType::LEGACY,
true // decompose true // decompose
); );
// Write mesh // Write mesh
foamVtkOutput::internalWriter writer vtk::internalWriter writer
( (
mesh_, mesh_,
foamVtkMeshCells, meshCells,
outputName, outputName,
foamVtkOutput::formatType::LEGACY_ASCII vtk::formatType::LEGACY_ASCII
); );

View File

@ -32,12 +32,12 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::writeCellSetFaces void Foam::vtk::writeCellSetFaces
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
const cellSet& set, const cellSet& set,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
) )
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
@ -47,11 +47,11 @@ void Foam::foamVtkOutput::writeCellSetFaces
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str()); std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os); autoPtr<vtk::formatter> format = opts.newFormatter(os);
if (legacy_) if (legacy_)
{ {
legacy::fileHeader(format(), set.name(), vtkFileTag::POLY_DATA); legacy::fileHeader(format(), set.name(), vtk::fileTag::POLY_DATA);
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -109,7 +109,7 @@ void Foam::foamVtkOutput::writeCellSetFaces
// Write points and faces as polygons // Write points and faces as polygons
legacy::beginPoints(os, pp.nPoints()); legacy::beginPoints(os, pp.nPoints());
foamVtkOutput::writeList(format(), pp.localPoints()); vtk::writeList(format(), pp.localPoints());
format().flush(); format().flush();
// connectivity count without additional storage (done internally) // connectivity count without additional storage (done internally)
@ -129,17 +129,17 @@ void Foam::foamVtkOutput::writeCellSetFaces
const face& f = pp.localFaces()[facei]; const face& f = pp.localFaces()[facei];
format().write(f.size()); // The size prefix format().write(f.size()); // The size prefix
foamVtkOutput::writeList(format(), f); vtk::writeList(format(), f);
} }
format().flush(); format().flush();
// Write data - faceId/cellId // Write data - faceId/cellId
legacy::dataHeader(os, vtkFileTag::CELL_DATA, pp.size(), 1); legacy::dataHeader(os, vtk::fileTag::CELL_DATA, pp.size(), 1);
os << "cellID 1 " << pp.size() << " int" << nl; os << "cellID 1 " << pp.size() << " int" << nl;
foamVtkOutput::writeList(format(), faceValues); vtk::writeList(format(), faceValues);
format().flush(); format().flush();
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamespace InNamespace
Foam::foamVtkOutput Foam::vtk
Description Description
Write faces of cellSet to vtk polydata file. Write faces of cellSet to vtk polydata file.
@ -45,11 +45,11 @@ SourceFiles
namespace Foam namespace Foam
{ {
class primitiveMesh; class primitiveMesh;
class cellSet; class cellSet;
class fileName; class fileName;
namespace foamVtkOutput namespace vtk
{ {
//- Write perimeter faces of cellset to vtk polydata file. //- Write perimeter faces of cellset to vtk polydata file.
@ -59,10 +59,10 @@ void writeCellSetFaces
const primitiveMesh& mesh, const primitiveMesh& mesh,
const cellSet& set, const cellSet& set,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
); );
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam

View File

@ -32,12 +32,12 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::writeFaceSet void Foam::vtk::writeFaceSet
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
const faceSet& set, const faceSet& set,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
) )
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
@ -47,11 +47,11 @@ void Foam::foamVtkOutput::writeFaceSet
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str()); std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os); autoPtr<vtk::formatter> format = opts.newFormatter(os);
if (legacy_) if (legacy_)
{ {
legacy::fileHeader(format(), set.name(), vtkFileTag::POLY_DATA); legacy::fileHeader(format(), set.name(), vtk::fileTag::POLY_DATA);
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -70,7 +70,7 @@ void Foam::foamVtkOutput::writeFaceSet
// Write points and faces as polygons // Write points and faces as polygons
legacy::beginPoints(os, pp.nPoints()); legacy::beginPoints(os, pp.nPoints());
foamVtkOutput::writeList(format(), pp.localPoints()); vtk::writeList(format(), pp.localPoints());
format().flush(); format().flush();
// connectivity count without additional storage (done internally) // connectivity count without additional storage (done internally)
@ -89,18 +89,18 @@ void Foam::foamVtkOutput::writeFaceSet
const face& f = pp.localFaces()[facei]; const face& f = pp.localFaces()[facei];
format().write(f.size()); // The size prefix format().write(f.size()); // The size prefix
foamVtkOutput::writeList(format(), f); vtk::writeList(format(), f);
} }
format().flush(); format().flush();
// Write data - faceId/cellId // Write data - faceId/cellId
legacy::dataHeader(os, vtkFileTag::CELL_DATA, pp.size(), 1); legacy::dataHeader(os, vtk::fileTag::CELL_DATA, pp.size(), 1);
os << "faceID 1 " << pp.size() << " int" << nl; os << "faceID 1 " << pp.size() << " int" << nl;
foamVtkOutput::writeList(format(), faceLabels); vtk::writeList(format(), faceLabels);
format().flush(); format().flush();
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamespace InNamespace
Foam::foamVtkOutput Foam::vtk
Description Description
Write faceSet to vtk polydata file. Write faceSet to vtk polydata file.
@ -46,7 +46,7 @@ class primitiveMesh;
class faceSet; class faceSet;
class fileName; class fileName;
namespace foamVtkOutput namespace vtk
{ {
//- Write pointSet to vtk polydata file. //- Write pointSet to vtk polydata file.
@ -56,11 +56,11 @@ void writeFaceSet
const primitiveMesh& mesh, const primitiveMesh& mesh,
const faceSet& set, const faceSet& set,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
); );
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam

View File

@ -31,12 +31,12 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::writePointSet void Foam::vtk::writePointSet
( (
const primitiveMesh& mesh, const primitiveMesh& mesh,
const pointSet& set, const pointSet& set,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
) )
{ {
outputOptions opts(outOpts); outputOptions opts(outOpts);
@ -46,11 +46,11 @@ void Foam::foamVtkOutput::writePointSet
std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str()); std::ofstream os((baseName + (legacy_ ? ".vtk" : ".vtp")).c_str());
autoPtr<foamVtkOutput::formatter> format = opts.newFormatter(os); autoPtr<vtk::formatter> format = opts.newFormatter(os);
if (legacy_) if (legacy_)
{ {
legacy::fileHeader(format(), set.name(), vtkFileTag::POLY_DATA); legacy::fileHeader(format(), set.name(), vtk::fileTag::POLY_DATA);
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -60,15 +60,15 @@ void Foam::foamVtkOutput::writePointSet
// Write points // Write points
legacy::beginPoints(os, pointLabels.size()); legacy::beginPoints(os, pointLabels.size());
foamVtkOutput::writeList(format(), mesh.points(), pointLabels); vtk::writeList(format(), mesh.points(), pointLabels);
format().flush(); format().flush();
// Write data - pointID // Write data - pointID
legacy::dataHeader(os, vtkFileTag::POINT_DATA, pointLabels.size(), 1); legacy::dataHeader(os, vtk::fileTag::POINT_DATA, pointLabels.size(), 1);
os << "pointID 1 " << pointLabels.size() << " int" << nl; os << "pointID 1 " << pointLabels.size() << " int" << nl;
foamVtkOutput::writeList(format(), pointLabels); vtk::writeList(format(), pointLabels);
format().flush(); format().flush();
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamespace InNamespace
Foam::foamVtkOutput Foam::vtk
Description Description
Write pointSet to vtk polydata file. Write pointSet to vtk polydata file.
@ -46,7 +46,7 @@ class primitiveMesh;
class pointSet; class pointSet;
class fileName; class fileName;
namespace foamVtkOutput namespace vtk
{ {
//- Write pointSet to vtk polydata file. //- Write pointSet to vtk polydata file.
@ -56,11 +56,11 @@ void writePointSet
const primitiveMesh& mesh, const primitiveMesh& mesh,
const pointSet& set, const pointSet& set,
const fileName& baseName, const fileName& baseName,
const foamVtkOutput::outputOptions outOpts const vtk::outputOptions outOpts
); );
} // End namespace foamVtkOutput } // End namespace vtk
} // End namespace Foam } // End namespace Foam

View File

@ -37,9 +37,9 @@ License
// TODO: make this run-time selectable (ASCII | BINARY) // TODO: make this run-time selectable (ASCII | BINARY)
// - Legacy mode only // - Legacy mode only
static const Foam::foamVtkOutput::formatType fmtType = static const Foam::vtk::formatType fmtType =
Foam::foamVtkOutput::formatType::LEGACY_ASCII; Foam::vtk::formatType::LEGACY_ASCII;
// Foam::foamVtkOutput::formatType::LEGACY_BASE64; // Foam::vtk::formatType::LEGACY_BINARY;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -47,7 +47,7 @@ static const Foam::foamVtkOutput::formatType fmtType =
template<class Face> template<class Face>
void Foam::fileFormats::VTKsurfaceFormat<Face>::writePolys void Foam::fileFormats::VTKsurfaceFormat<Face>::writePolys
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const UList<Face>& faces const UList<Face>& faces
) )
{ {
@ -58,7 +58,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::writePolys
nConnectivity += f.size(); nConnectivity += f.size();
} }
foamVtkOutput::legacy::beginPolys vtk::legacy::beginPolys
( (
format.os(), format.os(),
faces.size(), faces.size(),
@ -72,7 +72,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::writePolys
for (const Face& f : faces) for (const Face& f : faces)
{ {
format.write(f.size()); // The size prefix format.write(f.size()); // The size prefix
foamVtkOutput::writeList(format, f); vtk::writeList(format, f);
} }
format.flush(); format.flush();
@ -276,8 +276,8 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
std::ofstream os(filename.c_str()); std::ofstream os(filename.c_str());
autoPtr<foamVtkOutput::formatter> format = autoPtr<vtk::formatter> format =
foamVtkOutput::newFormatter(os, fmtType); vtk::newFormatter(os, fmtType);
writeHeader(format(), pointLst); writeHeader(format(), pointLst);
@ -290,7 +290,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
nConnectivity += f.size(); nConnectivity += f.size();
} }
foamVtkOutput::legacy::beginPolys vtk::legacy::beginPolys
( (
format().os(), format().os(),
faceLst.size(), faceLst.size(),
@ -305,7 +305,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
const Face& f = faceLst[faceMap[faceIndex++]]; const Face& f = faceLst[faceMap[faceIndex++]];
format().write(f.size()); // The size prefix format().write(f.size()); // The size prefix
foamVtkOutput::writeList(format(), f); vtk::writeList(format(), f);
} }
} }
@ -334,8 +334,8 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
{ {
std::ofstream os(filename.c_str()); std::ofstream os(filename.c_str());
autoPtr<foamVtkOutput::formatter> format = autoPtr<vtk::formatter> format =
foamVtkOutput::newFormatter(os, fmtType); vtk::newFormatter(os, fmtType);
writeHeader(format(), surf.points()); writeHeader(format(), surf.points());

View File

@ -63,7 +63,7 @@ class VTKsurfaceFormat
//- Write polygons //- Write polygons
static void writePolys static void writePolys
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const UList<Face>& faces const UList<Face>& faces
); );

View File

@ -31,27 +31,27 @@ License
void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader void Foam::fileFormats::VTKsurfaceFormatCore::writeHeader
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const pointField& pts const pointField& pts
) )
{ {
foamVtkOutput::legacy::fileHeader vtk::legacy::fileHeader
( (
format, format,
("surface written " + clock::dateTime()), ("surface written " + clock::dateTime()),
vtkFileTag::POLY_DATA vtk::fileTag::POLY_DATA
); );
foamVtkOutput::legacy::beginPoints(format.os(), pts.size()); vtk::legacy::beginPoints(format.os(), pts.size());
foamVtkOutput::writeList(format, pts); vtk::writeList(format, pts);
format.flush(); format.flush();
} }
void Foam::fileFormats::VTKsurfaceFormatCore::writeCellData void Foam::fileFormats::VTKsurfaceFormatCore::writeCellData
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const UList<surfZone>& zones const UList<surfZone>& zones
) )
{ {
@ -64,15 +64,15 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeCellData
nFaces += z.size(); nFaces += z.size();
} }
foamVtkOutput::legacy::dataHeader vtk::legacy::dataHeader
( (
format.os(), format.os(),
vtkFileTag::CELL_DATA, vtk::fileTag::CELL_DATA,
nFaces, nFaces,
1 // Only one field 1 // Only one field
); );
foamVtkOutput::legacy::intField vtk::legacy::intField
( (
format.os(), format.os(),
"region", "region",
@ -95,7 +95,7 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeCellData
void Foam::fileFormats::VTKsurfaceFormatCore::writeCellData void Foam::fileFormats::VTKsurfaceFormatCore::writeCellData
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const labelUList& zoneIds const labelUList& zoneIds
) )
{ {
@ -104,15 +104,15 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeCellData
// Number of faces // Number of faces
const label nFaces = zoneIds.size(); const label nFaces = zoneIds.size();
foamVtkOutput::legacy::dataHeader vtk::legacy::dataHeader
( (
format.os(), format.os(),
vtkFileTag::CELL_DATA, vtk::fileTag::CELL_DATA,
nFaces, nFaces,
1 // Only one field 1 // Only one field
); );
foamVtkOutput::legacy::intField vtk::legacy::intField
( (
format.os(), format.os(),
"region", "region",
@ -120,7 +120,7 @@ void Foam::fileFormats::VTKsurfaceFormatCore::writeCellData
nFaces nFaces
); );
foamVtkOutput::writeList(format, zoneIds); vtk::writeList(format, zoneIds);
format.flush(); format.flush();
} }

View File

@ -58,21 +58,21 @@ protected:
//- Write header information with points //- Write header information with points
static void writeHeader static void writeHeader
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const pointField& pts const pointField& pts
); );
//- Write regions (zones) information as CellData //- Write regions (zones) information as CellData
static void writeCellData static void writeCellData
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const UList<surfZone>& zones const UList<surfZone>& zones
); );
//- Write regions (zones) information as CellData //- Write regions (zones) information as CellData
static void writeCellData static void writeCellData
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const labelUList& zoneIds const labelUList& zoneIds
); );

View File

@ -35,9 +35,9 @@ License
// - No append mode supported // - No append mode supported
// - Legacy mode is dispatched via 'VTKsurfaceFormat' instead // - Legacy mode is dispatched via 'VTKsurfaceFormat' instead
static const Foam::foamVtkOutput::formatType fmtType = static const Foam::vtk::formatType fmtType =
Foam::foamVtkOutput::formatType::INLINE_ASCII; Foam::vtk::formatType::INLINE_ASCII;
// Foam::foamVtkOutput::formatType::INLINE_BASE64; // Foam::vtk::formatType::INLINE_BASE64;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -45,11 +45,11 @@ static const Foam::foamVtkOutput::formatType fmtType =
template<class Face> template<class Face>
void Foam::fileFormats::VTPsurfaceFormat<Face>::writePolys void Foam::fileFormats::VTPsurfaceFormat<Face>::writePolys
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const UList<Face>& faces const UList<Face>& faces
) )
{ {
format.tag(vtkFileTag::POLYS); format.tag(vtk::fileTag::POLYS);
// //
// 'connectivity' // 'connectivity'
@ -61,14 +61,14 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::writePolys
payLoad += f.size(); payLoad += f.size();
} }
format.openDataArray<label>("connectivity") format.openDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY)
.closeTag(); .closeTag();
format.writeSize(payLoad * sizeof(label)); format.writeSize(payLoad * sizeof(label));
for (const Face& f : faces) for (const Face& f : faces)
{ {
foamVtkOutput::writeList(format, f); vtk::writeList(format, f);
} }
format.flush(); format.flush();
@ -83,7 +83,7 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::writePolys
const uint64_t payLoad(faces.size() * sizeof(label)); const uint64_t payLoad(faces.size() * sizeof(label));
format format
.openDataArray<label>("offsets") .openDataArray<label>(vtk::dataArrayAttr::OFFSETS)
.closeTag(); .closeTag();
format.writeSize(payLoad); format.writeSize(payLoad);
@ -100,7 +100,7 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::writePolys
format.endDataArray(); format.endDataArray();
} }
format.endTag(vtkFileTag::POLYS); format.endTag(vtk::fileTag::POLYS);
} }
@ -135,14 +135,14 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::write
std::ofstream os(filename.c_str(), std::ios::binary); std::ofstream os(filename.c_str(), std::ios::binary);
autoPtr<foamVtkOutput::formatter> format = autoPtr<vtk::formatter> format =
foamVtkOutput::newFormatter(os, fmtType); vtk::newFormatter(os, fmtType);
writeHeader(format(), pointLst, faceLst.size()); writeHeader(format(), pointLst, faceLst.size());
if (useFaceMap) if (useFaceMap)
{ {
format().tag(vtkFileTag::POLYS); format().tag(vtk::fileTag::POLYS);
// //
// 'connectivity' // 'connectivity'
@ -154,7 +154,7 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::write
payLoad += f.size(); payLoad += f.size();
} }
format().openDataArray<label>("connectivity") format().openDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY)
.closeTag(); .closeTag();
format().writeSize(payLoad * sizeof(label)); format().writeSize(payLoad * sizeof(label));
@ -166,7 +166,7 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::write
{ {
const Face& f = faceLst[faceMap[faceIndex++]]; const Face& f = faceLst[faceMap[faceIndex++]];
foamVtkOutput::writeList(format(), f); vtk::writeList(format(), f);
} }
} }
@ -182,7 +182,7 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::write
const uint64_t payLoad(faceLst.size() * sizeof(label)); const uint64_t payLoad(faceLst.size() * sizeof(label));
format() format()
.openDataArray<label>("offsets") .openDataArray<label>(vtk::dataArrayAttr::OFFSETS)
.closeTag(); .closeTag();
format().writeSize(payLoad); format().writeSize(payLoad);
@ -204,7 +204,7 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::write
format().endDataArray(); format().endDataArray();
} }
format().endTag(vtkFileTag::POLYS); format().endTag(vtk::fileTag::POLYS);
} }
else else
{ {
@ -231,8 +231,8 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::write
{ {
std::ofstream os(filename.c_str(), std::ios::binary); std::ofstream os(filename.c_str(), std::ios::binary);
autoPtr<foamVtkOutput::formatter> format = autoPtr<vtk::formatter> format =
foamVtkOutput::newFormatter(os, fmtType); vtk::newFormatter(os, fmtType);
const List<Face>& faceLst = surf.surfFaces(); const List<Face>& faceLst = surf.surfFaces();

View File

@ -63,7 +63,7 @@ class VTPsurfaceFormat
//- Write polygons //- Write polygons
static void writePolys static void writePolys
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const UList<Face>& faces const UList<Face>& faces
); );

View File

@ -31,7 +31,7 @@ License
void Foam::fileFormats::VTPsurfaceFormatCore::writeHeader void Foam::fileFormats::VTPsurfaceFormatCore::writeHeader
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const pointField& pts, const pointField& pts,
const label nFaces const label nFaces
) )
@ -41,13 +41,13 @@ void Foam::fileFormats::VTPsurfaceFormatCore::writeHeader
format format
.xmlHeader() .xmlHeader()
.xmlComment("surface written " + clock::dateTime()) .xmlComment("surface written " + clock::dateTime())
.beginVTKFile(vtkFileTag::POLY_DATA, "0.1"); .beginVTKFile(vtk::fileTag::POLY_DATA, "0.1");
// <Piece> // <Piece>
format format
.openTag(vtkFileTag::PIECE) .openTag(vtk::fileTag::PIECE)
( "NumberOfPoints", pts.size() ) .xmlAttr(vtk::fileAttr::NUMBER_OF_POINTS, pts.size())
( "NumberOfPolys", nFaces ) .xmlAttr(vtk::fileAttr::NUMBER_OF_POLYS, nFaces)
.closeTag(); .closeTag();
@ -55,29 +55,29 @@ void Foam::fileFormats::VTPsurfaceFormatCore::writeHeader
const uint64_t payLoad = (pts.size()*3* sizeof(float)); const uint64_t payLoad = (pts.size()*3* sizeof(float));
format.tag(vtkFileTag::POINTS) format.tag(vtk::fileTag::POINTS)
.openDataArray<float, 3>(vtkFileTag::POINTS) .openDataArray<float, 3>(vtk::dataArrayAttr::POINTS)
.closeTag(); .closeTag();
format.writeSize(payLoad); format.writeSize(payLoad);
foamVtkOutput::writeList(format, pts); vtk::writeList(format, pts);
format.flush(); format.flush();
format format
.endDataArray() .endDataArray()
.endTag(vtkFileTag::POINTS); .endTag(vtk::fileTag::POINTS);
} }
void Foam::fileFormats::VTPsurfaceFormatCore::writeFooter void Foam::fileFormats::VTPsurfaceFormatCore::writeFooter
( (
foamVtkOutput::formatter& format vtk::formatter& format
) )
{ {
// Slight cheat. </Piece> too // Slight cheat. </Piece> too
format.endTag(Foam::vtkFileTag::PIECE); format.endTag(Foam::vtk::fileTag::PIECE);
format.endTag(vtkFileTag::POLY_DATA) format.endTag(vtk::fileTag::POLY_DATA)
.endVTKFile(); .endVTKFile();
} }
@ -85,7 +85,7 @@ void Foam::fileFormats::VTPsurfaceFormatCore::writeFooter
void Foam::fileFormats::VTPsurfaceFormatCore::writeCellData void Foam::fileFormats::VTPsurfaceFormatCore::writeCellData
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const UList<surfZone>& zones const UList<surfZone>& zones
) )
{ {
@ -98,7 +98,7 @@ void Foam::fileFormats::VTPsurfaceFormatCore::writeCellData
payLoad += z.size(); payLoad += z.size();
} }
format.tag(vtkFileTag::CELL_DATA); format.tag(vtk::fileTag::CELL_DATA);
format.openDataArray<label>("region") format.openDataArray<label>("region")
.closeTag(); .closeTag();
@ -117,31 +117,31 @@ void Foam::fileFormats::VTPsurfaceFormatCore::writeCellData
format.flush(); format.flush();
format.endDataArray(); format.endDataArray();
format.endTag(vtkFileTag::CELL_DATA); format.endTag(vtk::fileTag::CELL_DATA);
} }
void Foam::fileFormats::VTPsurfaceFormatCore::writeCellData void Foam::fileFormats::VTPsurfaceFormatCore::writeCellData
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const labelUList& zoneIds const labelUList& zoneIds
) )
{ {
// Zone ids as CellData // Zone ids as CellData
format.tag(vtkFileTag::CELL_DATA); format.tag(vtk::fileTag::CELL_DATA);
format.openDataArray<label>("region") format.openDataArray<label>("region")
.closeTag(); .closeTag();
const uint64_t payLoad(zoneIds.size() * sizeof(label)); const uint64_t payLoad(zoneIds.size() * sizeof(label));
format.writeSize(payLoad); format.writeSize(payLoad);
foamVtkOutput::writeList(format, zoneIds); vtk::writeList(format, zoneIds);
format.flush(); format.flush();
format.endDataArray(); format.endDataArray();
format.endTag(vtkFileTag::CELL_DATA); format.endTag(vtk::fileTag::CELL_DATA);
} }

View File

@ -58,26 +58,26 @@ protected:
//- Write file header information with points //- Write file header information with points
static void writeHeader static void writeHeader
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const pointField& pts, const pointField& pts,
const label nFaces const label nFaces
); );
//- Write file footer //- Write file footer
static void writeFooter(foamVtkOutput::formatter& format); static void writeFooter(vtk::formatter& format);
//- Write regions (zones) information as CellData //- Write regions (zones) information as CellData
static void writeCellData static void writeCellData
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const UList<surfZone>& zones const UList<surfZone>& zones
); );
//- Write regions (zones) information as CellData //- Write regions (zones) information as CellData
static void writeCellData static void writeCellData
( (
foamVtkOutput::formatter& format, vtk::formatter& format,
const labelUList& zoneIds const labelUList& zoneIds
); );
}; };

View File

@ -33,9 +33,9 @@ License
// TODO: make this run-time selectable (ASCII | BINARY) // TODO: make this run-time selectable (ASCII | BINARY)
// - Legacy mode only // - Legacy mode only
static const Foam::foamVtkOutput::formatType fmtType = static const Foam::vtk::formatType fmtType =
Foam::foamVtkOutput::formatType::LEGACY_ASCII; Foam::vtk::formatType::LEGACY_ASCII;
// Foam::foamVtkOutput::formatType::LEGACY_BASE64; // Foam::vtk::formatType::LEGACY_BINARY;
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -46,15 +46,15 @@ void Foam::triSurface::writeVTK
std::ostream& os std::ostream& os
) const ) const
{ {
autoPtr<foamVtkOutput::formatter> format = autoPtr<vtk::formatter> format =
foamVtkOutput::newFormatter(os, fmtType); vtk::newFormatter(os, fmtType);
// Header // Header
foamVtkOutput::legacy::fileHeader vtk::legacy::fileHeader
( (
format(), format(),
"triSurface", "triSurface",
vtkFileTag::POLY_DATA vtk::fileTag::POLY_DATA
); );
const pointField& pts = this->points(); const pointField& pts = this->points();
@ -63,15 +63,15 @@ void Foam::triSurface::writeVTK
const label nFaces = faceLst.size(); const label nFaces = faceLst.size();
// Points // Points
foamVtkOutput::legacy::beginPoints(os, pts.size()); vtk::legacy::beginPoints(os, pts.size());
foamVtkOutput::writeList(format(), pts); vtk::writeList(format(), pts);
format().flush(); format().flush();
// connectivity count (without additional storage) // connectivity count (without additional storage)
// is simply 3 * nFaces // is simply 3 * nFaces
foamVtkOutput::legacy::beginPolys(os, nFaces, 3*nFaces); vtk::legacy::beginPolys(os, nFaces, 3*nFaces);
labelList faceMap; labelList faceMap;
surfacePatchList patches(calcPatches(faceMap)); surfacePatchList patches(calcPatches(faceMap));
@ -88,7 +88,7 @@ void Foam::triSurface::writeVTK
const Face& f = faceLst[faceMap[faceIndex++]]; const Face& f = faceLst[faceMap[faceIndex++]];
format().write(3); // The size prefix format().write(3); // The size prefix
foamVtkOutput::writeList(format(), f); vtk::writeList(format(), f);
} }
} }
format().flush(); format().flush();
@ -97,15 +97,15 @@ void Foam::triSurface::writeVTK
// Write regions (zones) as CellData // Write regions (zones) as CellData
if (patches.size() > 1) if (patches.size() > 1)
{ {
foamVtkOutput::legacy::dataHeader vtk::legacy::dataHeader
( (
os, os,
vtkFileTag::CELL_DATA, vtk::fileTag::CELL_DATA,
nFaces, nFaces,
1 // Only one field 1 // Only one field
); );
foamVtkOutput::legacy::intField vtk::legacy::intField
( (
os, os,
"region", "region",
@ -132,22 +132,22 @@ void Foam::triSurface::writeVTK
for (const Face& f : faceLst) for (const Face& f : faceLst)
{ {
format().write(3); // The size prefix format().write(3); // The size prefix
foamVtkOutput::writeList(format(), f); vtk::writeList(format(), f);
} }
format().flush(); format().flush();
// Write regions (zones) as CellData // Write regions (zones) as CellData
foamVtkOutput::legacy::dataHeader vtk::legacy::dataHeader
( (
os, os,
vtkFileTag::CELL_DATA, vtk::fileTag::CELL_DATA,
faceLst.size(), faceLst.size(),
1 // Only one field 1 // Only one field
); );
foamVtkOutput::legacy::intField vtk::legacy::intField
( (
os, os,
"region", "region",