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))
{
// Faces of set with OpenFOAM faceID as value
foamVtkOutput::writeFaceSet
vtk::writeFaceSet
(
mesh,
currentSet,
mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY
vtk::formatType::LEGACY_BINARY
);
}
else if (isA<cellSet>(currentSet))
{
// External faces of cellset with OpenFOAM cellID as value
foamVtkOutput::writeCellSetFaces
vtk::writeCellSetFaces
(
mesh,
currentSet,
mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY
vtk::formatType::LEGACY_BINARY
);
}
else if (isA<pointSet>(currentSet))
{
foamVtkOutput::writePointSet
vtk::writePointSet
(
mesh,
currentSet,
mesh.time().path()/vtkBaseName,
foamVtkOutput::formatType::LEGACY_BINARY
vtk::formatType::LEGACY_BINARY
);
}
else

View File

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

View File

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

View File

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

View File

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

View File

@ -119,7 +119,7 @@ vtkSmartPointer<vtkUnstructuredGrid> Foam::vtkPVFoam::volumeVTKMesh
printMemory();
}
foamVtuSizing sizing(mesh, decompPoly);
vtk::vtuSizing sizing(mesh, decompPoly);
auto cellTypes = vtkSmartPointer<vtkUnsignedCharArray>::New();
@ -141,28 +141,28 @@ vtkSmartPointer<vtkUnstructuredGrid> Foam::vtkPVFoam::volumeVTKMesh
(
cells,
sizing.nFieldCells(),
sizing.sizeInternal(foamVtuSizing::slotType::CELLS)
sizing.sizeInternal(vtk::vtuSizing::slotType::CELLS)
);
UList<vtkIdType> cellLocationsUL =
vtkUList
(
cellLocations,
sizing.sizeInternal(foamVtuSizing::slotType::CELLS_OFFSETS)
sizing.sizeInternal(vtk::vtuSizing::slotType::CELLS_OFFSETS)
);
UList<vtkIdType> facesUL =
vtkUList
(
faces,
sizing.sizeInternal(foamVtuSizing::slotType::FACES)
sizing.sizeInternal(vtk::vtuSizing::slotType::FACES)
);
UList<vtkIdType> faceLocationsUL =
vtkUList
(
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/foamVtkWriteSurfFields.C
vtk/part/foamVtkCells.C
vtk/part/foamVtkMeshMaps.C
vtk/part/foamVtuCells.C
vtk/part/foamVtuSizing.C
LIB = $(FOAM_LIBBIN)/libconversion

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamespace
Foam::foamVtkOutput
Foam::vtk
Description
Additional functions for writing fields in VTK format.
@ -42,36 +42,17 @@ SourceFiles
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
// The output includes the payload size and flush.
template<class Type>
void writeField
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const DimensionedField<Type, volMesh>& fld
);
@ -80,15 +61,34 @@ namespace foamVtkOutput
template<class Type>
void writeField
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const DimensionedField<Type, volMesh>& fld,
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

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>
void Foam::foamVtkOutput::writeField
void Foam::vtk::writeField
(
foamVtkOutput::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,
vtk::formatter& fmt,
const DimensionedField<Type, volMesh>& fld
)
{
@ -84,9 +46,9 @@ void Foam::foamVtkOutput::writeField
template<class Type>
void Foam::foamVtkOutput::writeField
void Foam::vtk::writeField
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const DimensionedField<Type, volMesh>& fld,
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 * * * * * * * * * * * //
void Foam::foamVtkOutput::patchWriter::beginPiece()
void Foam::vtk::patchWriter::beginPiece()
{
if (!legacy_)
{
format()
.openTag(vtkFileTag::PIECE)
( "NumberOfPoints", nPoints_ )
( "NumberOfPolys", nFaces_ )
.openTag(vtk::fileTag::PIECE)
.xmlAttr(vtk::fileAttr::NUMBER_OF_POINTS, nPoints_)
.xmlAttr(vtk::fileAttr::NUMBER_OF_POLYS, nFaces_)
.closeTag();
}
}
void Foam::foamVtkOutput::patchWriter::writePoints()
void Foam::vtk::patchWriter::writePoints()
{
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_)
{
@ -55,8 +54,8 @@ void Foam::foamVtkOutput::patchWriter::writePoints()
}
else
{
format().tag(vtkFileTag::POINTS)
.openDataArray<float, 3>(vtkFileTag::POINTS)
format().tag(vtk::fileTag::POINTS)
.openDataArray<float, 3>(vtk::dataArrayAttr::POINTS)
.closeTag();
}
@ -66,7 +65,7 @@ void Foam::foamVtkOutput::patchWriter::writePoints()
{
const polyPatch& pp = patches[patchIDs_[i]];
foamVtkOutput::writeList(format(), pp.localPoints());
vtk::writeList(format(), pp.localPoints());
}
format().flush();
@ -74,12 +73,12 @@ void Foam::foamVtkOutput::patchWriter::writePoints()
{
format()
.endDataArray()
.endTag(vtkFileTag::POINTS);
.endTag(vtk::fileTag::POINTS);
}
}
void Foam::foamVtkOutput::patchWriter::writePolysLegacy()
void Foam::vtk::patchWriter::writePolysLegacy()
{
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();
@ -131,7 +130,7 @@ void Foam::foamVtkOutput::patchWriter::writePolys()
// 'connectivity'
//
format().tag(vtkFileTag::POLYS);
format().tag(vtk::fileTag::POLYS);
//
// 'connectivity'
@ -150,7 +149,7 @@ void Foam::foamVtkOutput::patchWriter::writePolys()
}
}
format().openDataArray<label>("connectivity")
format().openDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY)
.closeTag();
// payload size
@ -185,7 +184,7 @@ void Foam::foamVtkOutput::patchWriter::writePolys()
//
{
format()
.openDataArray<label>("offsets")
.openDataArray<label>(vtk::dataArrayAttr::OFFSETS)
.closeTag();
// payload size
@ -208,11 +207,11 @@ void Foam::foamVtkOutput::patchWriter::writePolys()
format().endDataArray();
}
format().endTag(vtkFileTag::POLYS);
format().endTag(vtk::fileTag::POLYS);
}
void Foam::foamVtkOutput::patchWriter::writeMesh()
void Foam::vtk::patchWriter::writeMesh()
{
writePoints();
if (legacy_)
@ -228,11 +227,11 @@ void Foam::foamVtkOutput::patchWriter::writeMesh()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::patchWriter::patchWriter
Foam::vtk::patchWriter::patchWriter
(
const fvMesh& mesh,
const fileName& baseName,
const foamVtkOutput::outputOptions outOpts,
const vtk::outputOptions outOpts,
const bool nearCellValue,
const labelList& patchIDs
)
@ -274,7 +273,7 @@ Foam::foamVtkOutput::patchWriter::patchWriter
if (legacy_)
{
legacy::fileHeader(format(), title, vtkFileTag::POLY_DATA);
legacy::fileHeader(format(), title, vtk::fileTag::POLY_DATA);
}
else
{
@ -283,7 +282,7 @@ Foam::foamVtkOutput::patchWriter::patchWriter
format()
.xmlHeader()
.xmlComment(title)
.beginVTKFile(vtkFileTag::POLY_DATA, "0.1");
.beginVTKFile(vtk::fileTag::POLY_DATA, "0.1");
}
beginPiece();
@ -293,82 +292,82 @@ Foam::foamVtkOutput::patchWriter::patchWriter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::patchWriter::~patchWriter()
Foam::vtk::patchWriter::~patchWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::patchWriter::beginCellData(label nFields)
void Foam::vtk::patchWriter::beginCellData(label nFields)
{
if (legacy_)
{
legacy::dataHeader
(
os(),
vtkFileTag::CELL_DATA,
vtk::fileTag::CELL_DATA,
nFaces_,
nFields
);
}
else
{
format().tag(vtkFileTag::CELL_DATA);
format().tag(vtk::fileTag::CELL_DATA);
}
}
void Foam::foamVtkOutput::patchWriter::endCellData()
void Foam::vtk::patchWriter::endCellData()
{
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_)
{
legacy::dataHeader
(
os(),
vtkFileTag::POINT_DATA,
vtk::fileTag::POINT_DATA,
nPoints_,
nFields
);
}
else
{
format().tag(vtkFileTag::POINT_DATA);
format().tag(vtk::fileTag::POINT_DATA);
}
}
void Foam::foamVtkOutput::patchWriter::endPointData()
void Foam::vtk::patchWriter::endPointData()
{
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_)
{
// 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();
}
}
void Foam::foamVtkOutput::patchWriter::writePatchIDs()
void Foam::vtk::patchWriter::writePatchIDs()
{
// Patch ids first
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/>.
Class
Foam::foamVtkOutput::patchWriter
Foam::vtk::patchWriter
Description
Write patch fields
@ -50,7 +50,7 @@ namespace Foam
{
class volPointInterpolation;
namespace foamVtkOutput
namespace vtk
{
/*---------------------------------------------------------------------------*\
@ -67,7 +67,7 @@ class patchWriter
//- Commonly used query
const bool legacy_;
autoPtr<foamVtkOutput::formatter> format_;
autoPtr<vtk::formatter> format_;
const bool nearCellValue_;
@ -114,7 +114,7 @@ public:
(
const fvMesh& mesh,
const fileName& baseName,
const foamVtkOutput::outputOptions outOpts,
const vtk::outputOptions outOpts,
const bool nearCellValue,
const labelList& patchIDs
);
@ -131,7 +131,7 @@ public:
return os_;
}
inline foamVtkOutput::formatter& format()
inline vtk::formatter& format()
{
return format_();
}
@ -202,7 +202,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput
} // End namespace vtk
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,6 +26,8 @@ Class
Description
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 pointMap is an optional local-to-global lookup for point ids.
@ -101,17 +103,19 @@ public:
//- 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);
//- Renumber point ids to account for subset meshes
//- Renumber point ids (pointMap) to account for subset meshes
void renumberPoints(const UList<label>& mapping);
//- Original cell ids for all cells (regular and decomposed).
// A regular mesh comprising only primitive cell types, this will just
// be an identity list. However, for subsetted meshes and decomposed
// cells this becomes a useful means of mapping from the original mesh.
// For a regular mesh comprising only primitive cell types, this
// will simply be an identity list. However, for subsetted meshes
// and decomposed cells this becomes a useful means of mapping from
// the original mesh.
inline DynamicList<label>& cellMap();
//- Point labels for subsetted meshes

View File

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

View File

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

View File

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

View File

@ -29,12 +29,12 @@ License
#include "cellShape.H"
#include "cellModeller.H"
// only used in this file
// Only used in this file
#include "foamVtuSizingTemplates.C"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::foamVtuSizing::presizeMaps(foamVtkMeshMaps& maps) const
void Foam::vtk::vtuSizing::presizeMaps(foamVtkMeshMaps& maps) const
{
maps.cellMap().setSize(this->nFieldCells());
maps.additionalIds().setSize(this->nAddPoints());
@ -43,7 +43,7 @@ void Foam::foamVtuSizing::presizeMaps(foamVtkMeshMaps& maps) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtuSizing::foamVtuSizing
Foam::vtk::vtuSizing::vtuSizing
(
const polyMesh& mesh,
const bool decompose
@ -54,7 +54,7 @@ Foam::foamVtuSizing::foamVtuSizing
}
Foam::foamVtuSizing::foamVtuSizing()
Foam::vtk::vtuSizing::vtuSizing()
{
clear();
}
@ -62,13 +62,13 @@ Foam::foamVtuSizing::foamVtuSizing()
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtuSizing::~foamVtuSizing()
Foam::vtk::vtuSizing::~vtuSizing()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamVtuSizing::reset
void Foam::vtk::vtuSizing::reset
(
const polyMesh& mesh,
const bool decompose
@ -160,7 +160,7 @@ void Foam::foamVtuSizing::reset
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();
// 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 slotType slot
@ -269,7 +269,7 @@ Foam::label Foam::foamVtuSizing::slotSize
}
void Foam::foamVtuSizing::populateLegacy
void Foam::vtk::vtuSizing::populateLegacy
(
const polyMesh& mesh,
UList<uint8_t>& cellTypes,
@ -298,7 +298,7 @@ void Foam::foamVtuSizing::populateLegacy
}
void Foam::foamVtuSizing::populateXml
void Foam::vtk::vtuSizing::populateXml
(
const polyMesh& mesh,
UList<uint8_t>& cellTypes,
@ -327,7 +327,7 @@ void Foam::foamVtuSizing::populateXml
}
void Foam::foamVtuSizing::populateInternal
void Foam::vtk::vtuSizing::populateInternal
(
const polyMesh& mesh,
UList<uint8_t>& cellTypes,
@ -356,7 +356,7 @@ void Foam::foamVtuSizing::populateInternal
}
void Foam::foamVtuSizing::populateInternal
void Foam::vtk::vtuSizing::populateInternal
(
const polyMesh& mesh,
UList<uint8_t>& cellTypes,
@ -385,7 +385,7 @@ void Foam::foamVtuSizing::populateInternal
}
void Foam::foamVtuSizing::populateInternal
void Foam::vtk::vtuSizing::populateInternal
(
const polyMesh& mesh,
UList<uint8_t>& cellTypes,
@ -414,7 +414,7 @@ void Foam::foamVtuSizing::populateInternal
}
void Foam::foamVtuSizing::populateInternal
void Foam::vtk::vtuSizing::populateInternal
(
const polyMesh& mesh,
UList<uint8_t>& cellTypes,
@ -442,7 +442,7 @@ void Foam::foamVtuSizing::populateInternal
}
void Foam::foamVtuSizing::populateInternal
void Foam::vtk::vtuSizing::populateInternal
(
const polyMesh& mesh,
UList<uint8_t>& cellTypes,
@ -470,7 +470,7 @@ void Foam::foamVtuSizing::populateInternal
}
void Foam::foamVtuSizing::populateInternal
void Foam::vtk::vtuSizing::populateInternal
(
const polyMesh& mesh,
UList<uint8_t>& cellTypes,
@ -498,7 +498,7 @@ void Foam::foamVtuSizing::populateInternal
}
void Foam::foamVtuSizing::clear()
void Foam::vtk::vtuSizing::clear()
{
decompose_ = false;
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();
if (nAddCells_)
@ -551,7 +551,7 @@ void Foam::foamVtuSizing::info(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
bool Foam::foamVtuSizing::operator==(const foamVtuSizing& rhs) const
bool Foam::vtk::vtuSizing::operator==(const vtuSizing& rhs) const
{
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);
}

View File

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

View File

@ -27,108 +27,108 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::foamVtuSizing::decompose() const
inline bool Foam::vtk::vtuSizing::decompose() const
{
return decompose_;
}
inline Foam::label Foam::foamVtuSizing::nCells() const
inline Foam::label Foam::vtk::vtuSizing::nCells() const
{
return nCells_;
}
inline Foam::label Foam::foamVtuSizing::nPoints() const
inline Foam::label Foam::vtk::vtuSizing::nPoints() const
{
return nPoints_;
}
inline Foam::label Foam::foamVtuSizing::nVertLabels() const
inline Foam::label Foam::vtk::vtuSizing::nVertLabels() const
{
return nVertLabels_;
}
inline Foam::label Foam::foamVtuSizing::nFaceLabels() const
inline Foam::label Foam::vtk::vtuSizing::nFaceLabels() const
{
return nFaceLabels_;
}
inline Foam::label Foam::foamVtuSizing::nCellsPoly() const
inline Foam::label Foam::vtk::vtuSizing::nCellsPoly() const
{
return nCellsPoly_;
}
inline Foam::label Foam::foamVtuSizing::nVertPoly() const
inline Foam::label Foam::vtk::vtuSizing::nVertPoly() const
{
return nVertPoly_;
}
inline Foam::label Foam::foamVtuSizing::nAddCells() const
inline Foam::label Foam::vtk::vtuSizing::nAddCells() const
{
return nAddCells_;
}
inline Foam::label Foam::foamVtuSizing::nAddPoints() const
inline Foam::label Foam::vtk::vtuSizing::nAddPoints() const
{
return nAddPoints_;
}
inline Foam::label Foam::foamVtuSizing::nAddVerts() const
inline Foam::label Foam::vtk::vtuSizing::nAddVerts() const
{
return nAddVerts_;
}
inline Foam::label Foam::foamVtuSizing::nFieldCells() const
inline Foam::label Foam::vtk::vtuSizing::nFieldCells() const
{
return nCells_ + nAddCells_;
}
inline Foam::label Foam::foamVtuSizing::nFieldPoints() const
inline Foam::label Foam::vtk::vtuSizing::nFieldPoints() const
{
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
{
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
{
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
{
return slotSize(contentType::INTERNAL, slot);
return sizeOf(contentType::INTERNAL, slot);
}

View File

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

View File

@ -14,7 +14,8 @@ stl/STLCore.C
stl/STLReader.C
stl/STLReaderASCII.L
vtk/foamVtkCore.C
vtk/core/foamVtkCore.C
vtk/core/foamVtkPTraits.C
vtk/format/foamVtkFormatter.C
vtk/format/foamVtkAsciiFormatter.C
vtk/format/foamVtkBase64Formatter.C
@ -26,8 +27,6 @@ vtk/format/foamVtkLegacyRawFormatter.C
vtk/output/foamVtkOutput.C
vtk/output/foamVtkOutputOptions.C
vtk/read/vtkUnstructuredReader.C
vtk/type/foamVtkFileEnums.C
vtk/type/foamVtkPTraits.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<>
const char* const
Foam::foamVtkPTraits<uint8_t>::typeName = "UInt8";
Foam::vtkPTraits<uint8_t>::typeName = "UInt8";
template<>
const char * const
Foam::foamVtkPTraits<int32_t>::typeName = "Int32";
Foam::vtkPTraits<int32_t>::typeName = "Int32";
template<>
const char * const
Foam::foamVtkPTraits<uint32_t>::typeName = "UInt32";
Foam::vtkPTraits<uint32_t>::typeName = "UInt32";
template<>
const char * const
Foam::foamVtkPTraits<int64_t>::typeName = "Int64";
Foam::vtkPTraits<int64_t>::typeName = "Int64";
template<>
const char * const
Foam::foamVtkPTraits<uint64_t>::typeName = "UInt64";
Foam::vtkPTraits<uint64_t>::typeName = "UInt64";
template<>
const char * const
Foam::foamVtkPTraits<float>::typeName = "Float32";
Foam::vtkPTraits<float>::typeName = "Float32";
template<>
const char * const
Foam::foamVtkPTraits<double>::typeName = "Float64";
Foam::vtkPTraits<double>::typeName = "Float64";
#ifdef WM_LITTLE_ENDIAN
template<>
const char* const
Foam::foamVtkPTraits<Foam::endian>::typeName = "LittleEndian";
Foam::vtkPTraits<Foam::endian>::typeName = "LittleEndian";
#else
template<>
const char* const
Foam::foamVtkPTraits<Foam::endian>::typeName = "BigEndian";
Foam::vtkPTraits<Foam::endian>::typeName = "BigEndian";
#endif

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::foamVtkPTraits
Foam::vtkPTraits
Description
Names for VTK primitive types.
@ -43,11 +43,11 @@ namespace Foam
class endian;
/*---------------------------------------------------------------------------*\
Class foamVtkPTraits Declaration
Class vtkPTraits Declaration
\*---------------------------------------------------------------------------*/
template<class PrimitiveType>
class foamVtkPTraits
class vtkPTraits
{
public:
@ -58,28 +58,28 @@ public:
template<>
const char* const foamVtkPTraits<uint8_t>::typeName; // UInt8
const char* const vtkPTraits<uint8_t>::typeName; // UInt8
template<>
const char* const foamVtkPTraits<int32_t>::typeName; // Int32
const char* const vtkPTraits<int32_t>::typeName; // Int32
template<>
const char* const foamVtkPTraits<uint32_t>::typeName; // UInt32
const char* const vtkPTraits<uint32_t>::typeName; // UInt32
template<>
const char* const foamVtkPTraits<int64_t>::typeName; // Int64
const char* const vtkPTraits<int64_t>::typeName; // Int64
template<>
const char* const foamVtkPTraits<uint64_t>::typeName; // UInt64
const char* const vtkPTraits<uint64_t>::typeName; // UInt64
template<>
const char* const foamVtkPTraits<float>::typeName; // Float32
const char* const vtkPTraits<float>::typeName; // Float32
template<>
const char* const foamVtkPTraits<double>::typeName; // Float64
const char* const vtkPTraits<double>::typeName; // Float64
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 * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::appendBase64Formatter::name_ = "append";
const char* Foam::vtk::appendBase64Formatter::name_ = "append";
const Foam::foamVtkOutput::outputOptions
Foam::foamVtkOutput::appendBase64Formatter::opts_(formatType::APPEND_BASE64);
const Foam::vtk::outputOptions
Foam::vtk::appendBase64Formatter::opts_(formatType::APPEND_BASE64);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::appendBase64Formatter::appendBase64Formatter
Foam::vtk::appendBase64Formatter::appendBase64Formatter
(
std::ostream& os
)
@ -47,7 +47,7 @@ Foam::foamVtkOutput::appendBase64Formatter::appendBase64Formatter
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::appendBase64Formatter::~appendBase64Formatter()
Foam::vtk::appendBase64Formatter::~appendBase64Formatter()
{
base64Layer::close();
}
@ -55,14 +55,14 @@ Foam::foamVtkOutput::appendBase64Formatter::~appendBase64Formatter()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::foamVtkOutput::outputOptions&
Foam::foamVtkOutput::appendBase64Formatter::opts() const
const Foam::vtk::outputOptions&
Foam::vtk::appendBase64Formatter::opts() const
{
return opts_;
}
const char* Foam::foamVtkOutput::appendBase64Formatter::name() const
const char* Foam::vtk::appendBase64Formatter::name() const
{
return name_;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,12 +27,12 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::foamVtkBase64Layer::encoding_ = "base64";
const char* Foam::vtk::foamVtkBase64Layer::encoding_ = "base64";
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::foamVtkOutput::foamVtkBase64Layer::write
void Foam::vtk::foamVtkBase64Layer::write
(
const char* s,
std::streamsize n
@ -44,7 +44,7 @@ void Foam::foamVtkOutput::foamVtkBase64Layer::write
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamVtkOutput::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
Foam::vtk::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
:
formatter(os),
base64Layer(os)
@ -53,7 +53,7 @@ Foam::foamVtkOutput::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamVtkOutput::foamVtkBase64Layer::~foamVtkBase64Layer()
Foam::vtk::foamVtkBase64Layer::~foamVtkBase64Layer()
{
base64Layer::close();
}
@ -61,39 +61,39 @@ Foam::foamVtkOutput::foamVtkBase64Layer::~foamVtkBase64Layer()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const char* Foam::foamVtkOutput::foamVtkBase64Layer::encoding() const
const char* Foam::vtk::foamVtkBase64Layer::encoding() const
{
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));
}
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const uint8_t val)
void Foam::vtk::foamVtkBase64Layer::write(const uint8_t 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';
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';
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';
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();
}
std::size_t Foam::foamVtkOutput::foamVtkBase64Layer::encodedLength
std::size_t Foam::vtk::foamVtkBase64Layer::encodedLength
(
std::size_t n
) const

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::foamVtkOutput::formatter::formatter(std::ostream& os)
inline Foam::vtk::formatter::formatter(std::ostream& os)
:
os_(os),
xmlTags_(),
@ -35,28 +35,28 @@ inline Foam::foamVtkOutput::formatter::formatter(std::ostream& os)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline std::ostream& Foam::foamVtkOutput::formatter::os()
inline std::ostream& Foam::vtk::formatter::os()
{
return os_;
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::openTag(const vtkFileTag& tagEnum)
inline Foam::vtk::formatter&
Foam::vtk::formatter::openTag(const vtk::fileTag& tagEnum)
{
return openTag(vtkFileTagNames[tagEnum]);
return openTag(vtk::fileTagNames[tagEnum]);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::endTag(const vtkFileTag& tagEnum)
inline Foam::vtk::formatter&
Foam::vtk::formatter::endTag(const vtk::fileTag& tagEnum)
{
return endTag(vtkFileTagNames[tagEnum]);
return endTag(vtk::fileTagNames[tagEnum]);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::tag(const word& tagName)
inline Foam::vtk::formatter&
Foam::vtk::formatter::tag(const word& tagName)
{
openTag(tagName);
closeTag();
@ -65,135 +65,118 @@ Foam::foamVtkOutput::formatter::tag(const word& tagName)
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::tag(const vtkFileTag& tagEnum)
inline Foam::vtk::formatter&
Foam::vtk::formatter::tag(const vtk::fileTag& tagEnum)
{
return tag(vtkFileTagNames[tagEnum]);
return tag(vtk::fileTagNames[tagEnum]);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::beginVTKFile
inline Foam::vtk::formatter&
Foam::vtk::formatter::beginVTKFile
(
const vtkFileTag& contentType,
const vtk::fileTag& contentType,
const word& contentVersion,
const bool leaveOpen
)
{
return beginVTKFile
(
vtkFileTagNames[contentType],
vtk::fileTagNames[contentType],
contentVersion,
leaveOpen
);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::endDataArray()
inline Foam::vtk::formatter&
Foam::vtk::formatter::endDataArray()
{
return endTag("DataArray");
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::endAppendedData()
{
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
inline Foam::vtk::formatter&
Foam::vtk::formatter::xmlAttr
(
const word& k,
const int32_t v,
const char quote
)
{
return xmlAttribute(k, v, quote);
return writeAttribute(k, v, quote);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::xmlAttr
inline Foam::vtk::formatter&
Foam::vtk::formatter::xmlAttr
(
const word& k,
const int64_t v,
const char quote
)
{
return xmlAttribute(k, v, quote);
return writeAttribute(k, v, quote);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::xmlAttr
inline Foam::vtk::formatter&
Foam::vtk::formatter::xmlAttr
(
const word& k,
const uint64_t v,
const char quote
)
{
return xmlAttribute(k, v, quote);
return writeAttribute(k, v, quote);
}
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::xmlAttr
inline Foam::vtk::formatter&
Foam::vtk::formatter::xmlAttr
(
const word& k,
const scalar v,
const char quote
)
{
return xmlAttribute(k, v, quote);
return writeAttribute(k, v, quote);
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
inline Foam::foamVtkOutput::formatter&
Foam::foamVtkOutput::formatter::operator()(const word& k, const std::string& v)
inline Foam::vtk::formatter&
Foam::vtk::formatter::xmlAttr
(
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&
Foam::foamVtkOutput::formatter::operator()(const word& k, const int32_t v)
inline Foam::vtk::formatter&
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&
Foam::foamVtkOutput::formatter::operator()(const word& k, const int64_t v)
inline Foam::vtk::formatter&
Foam::vtk::formatter::xmlAttr
(
const vtk::fileAttr& attrEnum,
const uint64_t v,
const char quote
)
{
return xmlAttr(k, v);
}
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);
return xmlAttr(vtk::fileAttrNames[attrEnum], v, quote);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,14 +22,14 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Namespace
Foam::foamVtkOutput
Foam::vtk
Description
Namespace for handling VTK output.
Contains classes and functions for writing VTK file content.
Namespace
Foam::foamVtkOutput::legacy
Foam::vtk::legacy
Description
Namespace for legacy VTK output constants and functions.
@ -45,7 +45,7 @@ SourceFiles
#include "autoPtr.H"
#include "Enum.H"
#include "foamVtkOutputTypes.H"
#include "foamVtkCore.H"
#include "foamVtkFormatter.H"
#include "floatScalar.H"
#include "IOstream.H"
@ -54,27 +54,20 @@ SourceFiles
namespace Foam
{
namespace foamVtkOutput
namespace vtk
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Typedefs
//- Use UInt64 for header data
typedef formatter::headerType headerType;
// Constants
// General Functions
//- 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
autoPtr<foamVtkOutput::formatter> newFormatter
autoPtr<vtk::formatter> newFormatter
(
std::ostream& os,
const enum formatType fmtType,
@ -90,7 +83,7 @@ namespace foamVtkOutput
template<class Type>
inline void write
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const Type& val
);
@ -100,7 +93,7 @@ namespace foamVtkOutput
template<class Type>
void writeList
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const UList<Type>& lst
);
@ -109,7 +102,7 @@ namespace foamVtkOutput
template<class Type, unsigned Size>
void writeList
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const FixedList<Type, Size>& lst
);
@ -119,7 +112,7 @@ namespace foamVtkOutput
template<class Type>
void writeList
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const UList<Type>& lst,
const UList<label>& addressing
);
@ -136,10 +129,10 @@ namespace legacy
// Constants
//- 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
extern const Foam::Enum<vtkFileTag> dataTypeNames;
extern const Foam::Enum<vtk::fileTag> dataTypeNames;
// Functions
@ -158,9 +151,9 @@ namespace legacy
// Includes "DATASET" with the specified dataset type.
inline void fileHeader
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const std::string& title,
const vtkFileTag& contentTypeTag
const vtk::fileTag& contentTypeTag
);
//- 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.
std::ostream& fileHeader
(
foamVtkOutput::formatter& fmt,
vtk::formatter& fmt,
const std::string& title,
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.
// The nEntries corresponds similarly to the number of cells or points,
// respectively.
inline void dataHeader
(
std::ostream& os,
const vtkFileTag& dataTypeTag,
const vtk::fileTag& dataTypeTag,
const label nEntries,
const label nFields
);
@ -219,11 +212,12 @@ namespace legacy
const label nEntries
);
};
} // End namespace legacy
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace foamVtkOutput
} // End namespace vtk
} // End namespace Foam

View File

@ -27,12 +27,12 @@ License
namespace Foam
{
namespace foamVtkOutput
namespace vtk
{
//- Template specialization for label
template<>
inline void write<label>(foamVtkOutput::formatter& fmt, const label& val)
inline void write<label>(vtk::formatter& fmt, const label& val)
{
fmt.write(val);
}
@ -40,7 +40,7 @@ inline void write<label>(foamVtkOutput::formatter& fmt, const label& val)
//- Template specialization for float
template<>
inline void write<float>(foamVtkOutput::formatter& fmt, const float& val)
inline void write<float>(vtk::formatter& fmt, const float& val)
{
fmt.write(val);
}
@ -48,18 +48,18 @@ inline void write<float>(foamVtkOutput::formatter& fmt, const float& val)
//- Template specialization for double
template<>
inline void write<double>(foamVtkOutput::formatter& fmt, const double& val)
inline void write<double>(vtk::formatter& fmt, const double& val)
{
fmt.write(val);
}
} // End namespace foamVtkOutput
} // End namespace vtk
} // End namespace Foam
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
inline std::ostream& Foam::foamVtkOutput::legacy::fileHeader
inline std::ostream& Foam::vtk::legacy::fileHeader
(
std::ostream& os,
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 vtkFileTag& contentTypeTag
const vtk::fileTag& contentTypeTag
)
{
fileHeader(fmt, title, contentNames[contentTypeTag]);
}
inline void Foam::foamVtkOutput::legacy::beginPoints
inline void Foam::vtk::legacy::beginPoints
(
std::ostream& os,
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,
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,
const vtkFileTag& dataTypeTag,
const vtk::fileTag& dataTypeTag,
const label nEntries,
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,
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,
const word& fieldName,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -63,8 +63,6 @@ namespace Foam
\*---------------------------------------------------------------------------*/
class vtkUnstructuredReader
:
public fileFormats::foamVtkCore
{
public:
@ -206,7 +204,7 @@ private:
void read(ISstream& inFile);
//- Dissallow assignment
//- Disallow assignment
void operator=(const vtkUnstructuredReader&);
@ -220,6 +218,7 @@ public:
//- Construct from Istream, read all
vtkUnstructuredReader(const objectRegistry& obr, ISstream&);
// Member Functions
//- 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;
foamVtkCells foamVtkMeshCells
vtk::vtuCells meshCells
(
mesh_,
foamVtkCells::contentType::LEGACY,
vtk::vtuCells::contentType::LEGACY,
true // decompose
);
// Write mesh
foamVtkOutput::internalWriter writer
vtk::internalWriter writer
(
mesh_,
foamVtkMeshCells,
meshCells,
outputName,
foamVtkOutput::formatType::LEGACY_ASCII
vtk::formatType::LEGACY_ASCII
);

View File

@ -32,12 +32,12 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::writeCellSetFaces
void Foam::vtk::writeCellSetFaces
(
const primitiveMesh& mesh,
const cellSet& set,
const fileName& baseName,
const foamVtkOutput::outputOptions outOpts
const vtk::outputOptions outOpts
)
{
outputOptions opts(outOpts);
@ -47,11 +47,11 @@ void Foam::foamVtkOutput::writeCellSetFaces
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_)
{
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
legacy::beginPoints(os, pp.nPoints());
foamVtkOutput::writeList(format(), pp.localPoints());
vtk::writeList(format(), pp.localPoints());
format().flush();
// connectivity count without additional storage (done internally)
@ -129,17 +129,17 @@ void Foam::foamVtkOutput::writeCellSetFaces
const face& f = pp.localFaces()[facei];
format().write(f.size()); // The size prefix
foamVtkOutput::writeList(format(), f);
vtk::writeList(format(), f);
}
format().flush();
// 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;
foamVtkOutput::writeList(format(), faceValues);
vtk::writeList(format(), faceValues);
format().flush();
}

View File

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

View File

@ -32,12 +32,12 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::writeFaceSet
void Foam::vtk::writeFaceSet
(
const primitiveMesh& mesh,
const faceSet& set,
const fileName& baseName,
const foamVtkOutput::outputOptions outOpts
const vtk::outputOptions outOpts
)
{
outputOptions opts(outOpts);
@ -47,11 +47,11 @@ void Foam::foamVtkOutput::writeFaceSet
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_)
{
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
legacy::beginPoints(os, pp.nPoints());
foamVtkOutput::writeList(format(), pp.localPoints());
vtk::writeList(format(), pp.localPoints());
format().flush();
// connectivity count without additional storage (done internally)
@ -89,18 +89,18 @@ void Foam::foamVtkOutput::writeFaceSet
const face& f = pp.localFaces()[facei];
format().write(f.size()); // The size prefix
foamVtkOutput::writeList(format(), f);
vtk::writeList(format(), f);
}
format().flush();
// 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;
foamVtkOutput::writeList(format(), faceLabels);
vtk::writeList(format(), faceLabels);
format().flush();
}

View File

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

View File

@ -31,12 +31,12 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::foamVtkOutput::writePointSet
void Foam::vtk::writePointSet
(
const primitiveMesh& mesh,
const pointSet& set,
const fileName& baseName,
const foamVtkOutput::outputOptions outOpts
const vtk::outputOptions outOpts
)
{
outputOptions opts(outOpts);
@ -46,11 +46,11 @@ void Foam::foamVtkOutput::writePointSet
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_)
{
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
legacy::beginPoints(os, pointLabels.size());
foamVtkOutput::writeList(format(), mesh.points(), pointLabels);
vtk::writeList(format(), mesh.points(), pointLabels);
format().flush();
// 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;
foamVtkOutput::writeList(format(), pointLabels);
vtk::writeList(format(), pointLabels);
format().flush();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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