mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improved infrastructure for writing VTK content
Note: classes are prefixed with 'foamVtk' instead of 'vtk' to avoid potential conflicts with VTK itself. foamVtkCore ~~~~~~~~~~~ - General very low-level functionality. foamVtkPTraits ~~~~~~~~~~~~~~ - Traits type of functionality for VTK foamVtkOutputOptions ~~~~~~~~~~~~~~~~~~~~ - The various format output options as a class that can be passed to formatters etc. foamVtkCells ~~~~~~~~~~~~ - Intended for unifying vtkTopo and PV-Reader code in the future. - Handles polyhedron decompose internally etc foamVtkOutput, foamVtkFormatter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Output helpers. - Selector for individual formatters. Currently write all scalar data a 'float' (not 'double'). Can revisit this in the future.
This commit is contained in:
@ -3,6 +3,8 @@ EXE_INC = \
|
|||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
|
-I$(LIB_SRC)/conversion/lnInclude \
|
||||||
-I$(ParaView_INCLUDE_DIR) \
|
-I$(ParaView_INCLUDE_DIR) \
|
||||||
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
|
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
|
||||||
-I../../vtkPVReaders/lnInclude \
|
-I../../vtkPVReaders/lnInclude \
|
||||||
@ -10,7 +12,7 @@ EXE_INC = \
|
|||||||
|
|
||||||
LIB_LIBS = \
|
LIB_LIBS = \
|
||||||
-ldynamicMesh \
|
-ldynamicMesh \
|
||||||
-ldynamicMesh \
|
-lconversion \
|
||||||
-lgenericPatchFields \
|
-lgenericPatchFields \
|
||||||
-llagrangian \
|
-llagrangian \
|
||||||
-L$(FOAM_LIBBIN) -lvtkPVReaders \
|
-L$(FOAM_LIBBIN) -lvtkPVReaders \
|
||||||
|
|||||||
@ -24,4 +24,7 @@ starcd/STARCDMeshWriter.C
|
|||||||
|
|
||||||
polyDualMesh/polyDualMesh.C
|
polyDualMesh/polyDualMesh.C
|
||||||
|
|
||||||
|
vtk/part/foamVtkCells.C
|
||||||
|
vtk/output/foamVtkOutput.C
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libconversion
|
LIB = $(FOAM_LIBBIN)/libconversion
|
||||||
|
|||||||
126
src/conversion/vtk/output/foamVtkOutput.C
Normal file
126
src/conversion/vtk/output/foamVtkOutput.C
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkOutput.H"
|
||||||
|
#include "foamVtkAsciiFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::word Foam::foamVtkOutput::legacy::EXT = "vtk";
|
||||||
|
|
||||||
|
|
||||||
|
//! \cond fileScope
|
||||||
|
static inline std::ostream& legacyDataHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const char* tag,
|
||||||
|
const Foam::label nItems,
|
||||||
|
const Foam::label nFields
|
||||||
|
)
|
||||||
|
{
|
||||||
|
os << tag << ' ' << nItems << '\n'
|
||||||
|
<< "FIELD attributes " << nFields << '\n';
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
//! \endcond
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::label Foam::foamVtkOutput::writeVtmFile
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const UList<fileName>& files
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const word& content = "vtkMultiBlockDataSet";
|
||||||
|
|
||||||
|
foamVtkAsciiFormatter vtmFile(os);
|
||||||
|
|
||||||
|
vtmFile
|
||||||
|
.xmlHeader()
|
||||||
|
.openTag("VTKFile")
|
||||||
|
( "type", content )
|
||||||
|
( "version", "1.0" )
|
||||||
|
( "byte_order", foamVtkFormatter::byteOrder )
|
||||||
|
( "header_type", foamVtkFormatter::headerType )
|
||||||
|
.closeTag();
|
||||||
|
|
||||||
|
vtmFile.tag(content);
|
||||||
|
|
||||||
|
forAll(files, i)
|
||||||
|
{
|
||||||
|
vtmFile
|
||||||
|
.openTag("DataSet")
|
||||||
|
( "index", i )
|
||||||
|
( "file", files[i] )
|
||||||
|
.closeTag(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
vtmFile.endTag(content).endTag("VTKFile");
|
||||||
|
|
||||||
|
return files.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& Foam::foamVtkOutput::legacy::writeHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const std::string& title,
|
||||||
|
const bool binary
|
||||||
|
)
|
||||||
|
{
|
||||||
|
os << "# vtk DataFile Version 2.0" << nl
|
||||||
|
<< title << nl
|
||||||
|
<< (binary ? "BINARY" : "ASCII") << nl;
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& Foam::foamVtkOutput::legacy::writeCellDataHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const label nCells,
|
||||||
|
const label nFields
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return legacyDataHeader(os, "CELL_DATA", nCells, nFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& Foam::foamVtkOutput::legacy::writePointDataHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const label nPoints,
|
||||||
|
const label nFields
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return legacyDataHeader(os, "POINT_DATA", nPoints, nFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
216
src/conversion/vtk/output/foamVtkOutput.H
Normal file
216
src/conversion/vtk/output/foamVtkOutput.H
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
foamVtkOutput
|
||||||
|
|
||||||
|
Description
|
||||||
|
A collection of functions for writing vtk file content.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkOutput.C
|
||||||
|
foamVtkOutputTemplates.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkOutput_H
|
||||||
|
#define foamVtkOutput_H
|
||||||
|
|
||||||
|
#include "floatScalar.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "foamVtkFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkOutput Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkOutput
|
||||||
|
{
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow construction
|
||||||
|
foamVtkOutput() = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class legacy;
|
||||||
|
|
||||||
|
|
||||||
|
// Static Members
|
||||||
|
|
||||||
|
//- Write vtm datasets for specified files
|
||||||
|
static Foam::label writeVtmFile
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const UList<fileName>& files
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write a value component-wise.
|
||||||
|
template<class Type>
|
||||||
|
inline static void write(foamVtkFormatter&, const Type&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write a list of values.
|
||||||
|
// The output does not include the payload size.
|
||||||
|
template<class Type>
|
||||||
|
static void writeList
|
||||||
|
(
|
||||||
|
foamVtkFormatter&,
|
||||||
|
const UList<Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write a list of values via indirect addressing.
|
||||||
|
// The output does not include the payload size.
|
||||||
|
template<class Type>
|
||||||
|
static void writeList
|
||||||
|
(
|
||||||
|
foamVtkFormatter&,
|
||||||
|
const UList<Type>&,
|
||||||
|
const UList<label>& addressing
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write volField with cell values (including decomposed cells).
|
||||||
|
// The output includes the payload size and flush.
|
||||||
|
template<class Type>
|
||||||
|
static void writeField
|
||||||
|
(
|
||||||
|
foamVtkFormatter&,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||||
|
const UList<label>& superCells
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkOutput::legacy Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//- Basic support for legacy files
|
||||||
|
class foamVtkOutput::legacy
|
||||||
|
{
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow construction
|
||||||
|
legacy() = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Static data members
|
||||||
|
|
||||||
|
//- file extension for legacy files (vtk)
|
||||||
|
static const Foam::word EXT;
|
||||||
|
|
||||||
|
|
||||||
|
// Static Members
|
||||||
|
|
||||||
|
//- Emit header for legacy file
|
||||||
|
static std::ostream& writeHeader
|
||||||
|
(
|
||||||
|
std::ostream&,
|
||||||
|
const std::string& title,
|
||||||
|
const bool binary = false
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Emit header for legacy CELL_DATA
|
||||||
|
static std::ostream& writeCellDataHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const label nCells,
|
||||||
|
const label nFields
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Emit header for legacy POINT_DATA
|
||||||
|
static std::ostream& writePointDataHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const label nPoints,
|
||||||
|
const label nFields
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
//- Template specialization for label
|
||||||
|
template<>
|
||||||
|
inline void Foam::foamVtkOutput::write<label>
|
||||||
|
(
|
||||||
|
foamVtkFormatter& fmt,
|
||||||
|
const label& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fmt.write(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Template specialization for float
|
||||||
|
template<>
|
||||||
|
inline void Foam::foamVtkOutput::write<float>
|
||||||
|
(
|
||||||
|
foamVtkFormatter& fmt,
|
||||||
|
const float& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fmt.write(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Template specialization for double
|
||||||
|
template<>
|
||||||
|
inline void Foam::foamVtkOutput::write<double>
|
||||||
|
(
|
||||||
|
foamVtkFormatter& fmt,
|
||||||
|
const double& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fmt.write(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "foamVtkOutputTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
94
src/conversion/vtk/output/foamVtkOutputTemplates.C
Normal file
94
src/conversion/vtk/output/foamVtkOutputTemplates.C
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline void Foam::foamVtkOutput::write
|
||||||
|
(
|
||||||
|
foamVtkFormatter& fmt,
|
||||||
|
const Type& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; ++cmpt)
|
||||||
|
{
|
||||||
|
fmt.write(component(val, cmpt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::foamVtkOutput::writeList
|
||||||
|
(
|
||||||
|
foamVtkFormatter& fmt,
|
||||||
|
const UList<Type>& lst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
forAll(lst, i)
|
||||||
|
{
|
||||||
|
write(fmt, lst[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::foamVtkOutput::writeList
|
||||||
|
(
|
||||||
|
foamVtkFormatter& fmt,
|
||||||
|
const UList<Type>& lst,
|
||||||
|
const UList<label>& addressing
|
||||||
|
)
|
||||||
|
{
|
||||||
|
forAll(addressing, i)
|
||||||
|
{
|
||||||
|
write(fmt, lst[addressing[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::foamVtkOutput::writeField
|
||||||
|
(
|
||||||
|
foamVtkFormatter& fmt,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||||
|
const UList<label>& superCells
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad =
|
||||||
|
(
|
||||||
|
(vf.size() + superCells.size())
|
||||||
|
* pTraits<Type>::nComponents * sizeof(float)
|
||||||
|
);
|
||||||
|
|
||||||
|
fmt.writeSize(payLoad);
|
||||||
|
writeList(fmt, vf.internalField());
|
||||||
|
writeList(fmt, vf, superCells);
|
||||||
|
|
||||||
|
fmt.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
649
src/conversion/vtk/part/foamVtkCells.C
Normal file
649
src/conversion/vtk/part/foamVtkCells.C
Normal file
@ -0,0 +1,649 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-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 "foamVtkCells.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "cellShape.H"
|
||||||
|
#include "cellModeller.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::foamVtkCells::correct()
|
||||||
|
{
|
||||||
|
// Clear derived data
|
||||||
|
// clearGeom();
|
||||||
|
|
||||||
|
const cellModel& tet = *(cellModeller::lookup("tet"));
|
||||||
|
const cellModel& pyr = *(cellModeller::lookup("pyr"));
|
||||||
|
const cellModel& prism = *(cellModeller::lookup("prism"));
|
||||||
|
const cellModel& wedge = *(cellModeller::lookup("wedge"));
|
||||||
|
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
|
||||||
|
const cellModel& hex = *(cellModeller::lookup("hex"));
|
||||||
|
|
||||||
|
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||||
|
|
||||||
|
// face owner is needed to determine the face orientation
|
||||||
|
const labelList& owner = mesh_.faceOwner();
|
||||||
|
|
||||||
|
// Unique vertex labels per polyhedral
|
||||||
|
HashSet<label> hashUniqId(2*256);
|
||||||
|
|
||||||
|
// =======================
|
||||||
|
// PASS 1: Determine sizes
|
||||||
|
|
||||||
|
label nVertLabels = 0;
|
||||||
|
label nFaceLabels = 0;
|
||||||
|
label nAddPoints = 0;
|
||||||
|
label nAddCells = 0;
|
||||||
|
label nAddVerts = 0;
|
||||||
|
|
||||||
|
forAll(cellShapes, cellI)
|
||||||
|
{
|
||||||
|
const cellShape& shape = cellShapes[cellI];
|
||||||
|
const cellModel& model = shape.model();
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
model == tet
|
||||||
|
|| model == pyr
|
||||||
|
|| model == prism
|
||||||
|
|| model == hex
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// normal primitives
|
||||||
|
nVertLabels += shape.size();
|
||||||
|
}
|
||||||
|
else if (model == tetWedge && decompose_.requested())
|
||||||
|
{
|
||||||
|
// Treat as squeezed prism (VTK_WEDGE)
|
||||||
|
nVertLabels += 6;
|
||||||
|
}
|
||||||
|
else if (model == wedge && decompose_.requested())
|
||||||
|
{
|
||||||
|
// Treat as squeezed hex
|
||||||
|
nVertLabels += 8;
|
||||||
|
}
|
||||||
|
else if (decompose_.requested())
|
||||||
|
{
|
||||||
|
// Polyhedral: Decompose into tets + pyramids.
|
||||||
|
|
||||||
|
// Count vertices in first decomposed cell
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
|
const cell& cFaces = mesh_.cells()[cellI];
|
||||||
|
forAll(cFaces, cFaceI)
|
||||||
|
{
|
||||||
|
const face& f = mesh_.faces()[cFaces[cFaceI]];
|
||||||
|
|
||||||
|
// Face decomposed into triangles and quads
|
||||||
|
// Tri -> Tet, Quad -> Pyr
|
||||||
|
label nTria = 0, nQuad = 0;
|
||||||
|
f.nTrianglesQuads(mesh_.points(), nTria, nQuad);
|
||||||
|
|
||||||
|
nAddCells += nTria + nQuad;
|
||||||
|
nAddVerts += (nTria * 4) + (nQuad * 5);
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
const label nvrt = (nQuad ? 5 : 4);
|
||||||
|
nAddCells--;
|
||||||
|
nAddVerts -= nvrt;
|
||||||
|
nVertLabels += nvrt;
|
||||||
|
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
++nAddPoints;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Polyhedral: Not decomposed.
|
||||||
|
|
||||||
|
const labelList& cFaces = mesh_.cells()[cellI];
|
||||||
|
|
||||||
|
// establish unique node ids used (only needed for XML)
|
||||||
|
hashUniqId.clear();
|
||||||
|
|
||||||
|
// determing sizing for face stream
|
||||||
|
// number of faces, size of each face, vertices per face
|
||||||
|
// [nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
|
||||||
|
|
||||||
|
forAll(cFaces, cFaceI)
|
||||||
|
{
|
||||||
|
const face& f = mesh_.faces()[cFaces[cFaceI]];
|
||||||
|
nFaceLabels += f.size();
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
hashUniqId.insert(f[fp]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nVertLabels += hashUniqId.size();
|
||||||
|
nFaceLabels += 1 + cFaces.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// adjust/reserve sizes
|
||||||
|
//
|
||||||
|
|
||||||
|
// Cell types (including added cells) in vtk numbering
|
||||||
|
cellTypes_.setSize(cellShapes.size() + nAddCells);
|
||||||
|
|
||||||
|
// List of vertex labels in VTK ordering
|
||||||
|
vertLabels_.setSize(nVertLabels + nAddVerts);
|
||||||
|
|
||||||
|
vertOffset_.setSize(cellShapes.size() + nAddCells);
|
||||||
|
|
||||||
|
faceLabels_.clear();
|
||||||
|
faceOffset_.clear();
|
||||||
|
if (nFaceLabels)
|
||||||
|
{
|
||||||
|
faceLabels_.setSize(nFaceLabels);
|
||||||
|
|
||||||
|
// only need nCells (without nAddCells)
|
||||||
|
// set to -1 (primitive)
|
||||||
|
faceOffset_.setSize(cellShapes.size(), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decompose_.requested())
|
||||||
|
{
|
||||||
|
decompose_.addPointCellLabels_.setSize(nAddPoints);
|
||||||
|
decompose_.superCells_.setSize(nAddCells);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ======================
|
||||||
|
// PASS 2: Fill in arrays
|
||||||
|
|
||||||
|
// Need this offset later, but only for decomposed polys
|
||||||
|
const label offsetAddVerts = nVertLabels;
|
||||||
|
|
||||||
|
// Reset counters
|
||||||
|
nVertLabels = 0;
|
||||||
|
nFaceLabels = 0;
|
||||||
|
nAddPoints = 0;
|
||||||
|
nAddCells = 0;
|
||||||
|
nAddVerts = 0;
|
||||||
|
|
||||||
|
forAll(cellShapes, cellI)
|
||||||
|
{
|
||||||
|
const cellShape& shape = cellShapes[cellI];
|
||||||
|
const cellModel& model = shape.model();
|
||||||
|
|
||||||
|
if (model == tet)
|
||||||
|
{
|
||||||
|
cellTypes_[cellI] = foamVtkCore::VTK_TETRA;
|
||||||
|
forAll(shape, i)
|
||||||
|
{
|
||||||
|
vertLabels_[nVertLabels++] = shape[i];
|
||||||
|
}
|
||||||
|
vertOffset_[cellI] = nVertLabels;
|
||||||
|
}
|
||||||
|
else if (model == pyr)
|
||||||
|
{
|
||||||
|
cellTypes_[cellI] = foamVtkCore::VTK_PYRAMID;
|
||||||
|
forAll(shape, i)
|
||||||
|
{
|
||||||
|
vertLabels_[nVertLabels++] = shape[i];
|
||||||
|
}
|
||||||
|
vertOffset_[cellI] = nVertLabels;
|
||||||
|
}
|
||||||
|
else if (model == hex)
|
||||||
|
{
|
||||||
|
cellTypes_[cellI] = foamVtkCore::VTK_HEXAHEDRON;
|
||||||
|
forAll(shape, i)
|
||||||
|
{
|
||||||
|
vertLabels_[nVertLabels++] = shape[i];
|
||||||
|
}
|
||||||
|
vertOffset_[cellI] = nVertLabels;
|
||||||
|
}
|
||||||
|
else if (model == prism)
|
||||||
|
{
|
||||||
|
cellTypes_[cellI] = foamVtkCore::VTK_WEDGE;
|
||||||
|
|
||||||
|
// VTK_WEDGE triangles point outwards (swap 1<->2, 4<->5)
|
||||||
|
vertLabels_[nVertLabels++] = shape[0];
|
||||||
|
vertLabels_[nVertLabels++] = shape[2];
|
||||||
|
vertLabels_[nVertLabels++] = shape[1];
|
||||||
|
vertLabels_[nVertLabels++] = shape[3];
|
||||||
|
vertLabels_[nVertLabels++] = shape[5];
|
||||||
|
vertLabels_[nVertLabels++] = shape[4];
|
||||||
|
|
||||||
|
vertOffset_[cellI] = nVertLabels;
|
||||||
|
}
|
||||||
|
else if (model == tetWedge && decompose_.requested())
|
||||||
|
{
|
||||||
|
// Treat as squeezed prism (VTK_WEDGE)
|
||||||
|
cellTypes_[cellI] = foamVtkCore::VTK_WEDGE;
|
||||||
|
|
||||||
|
vertLabels_[nVertLabels++] = shape[0];
|
||||||
|
vertLabels_[nVertLabels++] = shape[2];
|
||||||
|
vertLabels_[nVertLabels++] = shape[1];
|
||||||
|
vertLabels_[nVertLabels++] = shape[3];
|
||||||
|
vertLabels_[nVertLabels++] = shape[4];
|
||||||
|
vertLabels_[nVertLabels++] = shape[3];
|
||||||
|
|
||||||
|
vertOffset_[cellI] = nVertLabels;
|
||||||
|
}
|
||||||
|
else if (model == wedge && decompose_.requested())
|
||||||
|
{
|
||||||
|
// Treat as squeezed hex
|
||||||
|
cellTypes_[cellI] = foamVtkCore::VTK_HEXAHEDRON;
|
||||||
|
|
||||||
|
vertLabels_[nVertLabels++] = shape[0];
|
||||||
|
vertLabels_[nVertLabels++] = shape[1];
|
||||||
|
vertLabels_[nVertLabels++] = shape[2];
|
||||||
|
vertLabels_[nVertLabels++] = shape[2];
|
||||||
|
vertLabels_[nVertLabels++] = shape[3];
|
||||||
|
vertLabels_[nVertLabels++] = shape[4];
|
||||||
|
vertLabels_[nVertLabels++] = shape[5];
|
||||||
|
vertLabels_[nVertLabels++] = shape[6];
|
||||||
|
|
||||||
|
vertOffset_[cellI] = nVertLabels;
|
||||||
|
}
|
||||||
|
else if (decompose_.requested())
|
||||||
|
{
|
||||||
|
// Polyhedral cell - decompose into tet/pyr.
|
||||||
|
|
||||||
|
// Ensure we have the correct orientation for the base of the
|
||||||
|
// primitive cell shape.
|
||||||
|
// If the cell is face owner, the orientation needs to be flipped
|
||||||
|
// to avoid defining negative cells.
|
||||||
|
// VTK doesn't seem to care, but we'll do it anyhow for safety.
|
||||||
|
|
||||||
|
// The new vertex from the cell-centre
|
||||||
|
const label newVertexLabel = mesh_.nPoints() + nAddPoints;
|
||||||
|
|
||||||
|
// Mapping from additional point to cell
|
||||||
|
decompose_.addPointCellLabels_[nAddPoints++] = cellI;
|
||||||
|
|
||||||
|
// Whether to insert cell in place of original or not.
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
|
const labelList& cFaces = mesh_.cells()[cellI];
|
||||||
|
forAll(cFaces, cFaceI)
|
||||||
|
{
|
||||||
|
const face& f = mesh_.faces()[cFaces[cFaceI]];
|
||||||
|
const bool isOwner = (owner[cFaces[cFaceI]] == cellI);
|
||||||
|
|
||||||
|
// Count triangles/quads in decomposition
|
||||||
|
label nTria = 0;
|
||||||
|
label nQuad = 0;
|
||||||
|
f.nTrianglesQuads(mesh_.points(), nTria, nQuad);
|
||||||
|
|
||||||
|
// Do actual decomposition
|
||||||
|
faceList faces3(nTria);
|
||||||
|
faceList faces4(nQuad);
|
||||||
|
nTria = 0, nQuad = 0;
|
||||||
|
f.trianglesQuads(mesh_.points(), nTria, nQuad, faces3, faces4);
|
||||||
|
|
||||||
|
forAll(faces4, fci)
|
||||||
|
{
|
||||||
|
const face& quad = faces4[fci];
|
||||||
|
|
||||||
|
label celLoc;
|
||||||
|
label vrtLoc;
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
celLoc = cellI;
|
||||||
|
vrtLoc = nVertLabels;
|
||||||
|
nVertLabels += 5;
|
||||||
|
|
||||||
|
vertOffset_[celLoc] = nVertLabels;
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
celLoc = mesh_.nCells() + nAddCells;
|
||||||
|
vrtLoc = offsetAddVerts + nAddVerts;
|
||||||
|
nAddVerts += 5;
|
||||||
|
|
||||||
|
vertOffset_[celLoc] = nAddVerts;
|
||||||
|
decompose_.superCells_[nAddCells++] = celLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
cellTypes_[celLoc] = foamVtkCore::VTK_PYRAMID;
|
||||||
|
|
||||||
|
// See note above about the orientation.
|
||||||
|
if (isOwner)
|
||||||
|
{
|
||||||
|
vertLabels_[vrtLoc++] = quad[3];
|
||||||
|
vertLabels_[vrtLoc++] = quad[2];
|
||||||
|
vertLabels_[vrtLoc++] = quad[1];
|
||||||
|
vertLabels_[vrtLoc++] = quad[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vertLabels_[vrtLoc++] = quad[0];
|
||||||
|
vertLabels_[vrtLoc++] = quad[1];
|
||||||
|
vertLabels_[vrtLoc++] = quad[2];
|
||||||
|
vertLabels_[vrtLoc++] = quad[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
vertLabels_[vrtLoc++] = newVertexLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(faces3, fci)
|
||||||
|
{
|
||||||
|
const face& tria = faces3[fci];
|
||||||
|
|
||||||
|
label celLoc;
|
||||||
|
label vrtLoc;
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
celLoc = cellI;
|
||||||
|
vrtLoc = nVertLabels;
|
||||||
|
nVertLabels += 4;
|
||||||
|
|
||||||
|
vertOffset_[celLoc] = nVertLabels;
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
celLoc = mesh_.nCells() + nAddCells;
|
||||||
|
vrtLoc = offsetAddVerts + nAddVerts;
|
||||||
|
nAddVerts += 4;
|
||||||
|
|
||||||
|
vertOffset_[celLoc] = nAddVerts;
|
||||||
|
decompose_.superCells_[nAddCells++] = celLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
cellTypes_[celLoc] = foamVtkCore::VTK_TETRA;
|
||||||
|
|
||||||
|
// See note above about the orientation.
|
||||||
|
if (isOwner)
|
||||||
|
{
|
||||||
|
vertLabels_[vrtLoc++] = tria[2];
|
||||||
|
vertLabels_[vrtLoc++] = tria[1];
|
||||||
|
vertLabels_[vrtLoc++] = tria[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vertLabels_[vrtLoc++] = tria[0];
|
||||||
|
vertLabels_[vrtLoc++] = tria[1];
|
||||||
|
vertLabels_[vrtLoc++] = tria[2];
|
||||||
|
}
|
||||||
|
vertLabels_[vrtLoc++] = newVertexLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Polyhedral cell - not decomposed
|
||||||
|
|
||||||
|
hashUniqId.clear(); // unique node ids used (only needed for XML)
|
||||||
|
|
||||||
|
// face-stream
|
||||||
|
// [nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
|
||||||
|
|
||||||
|
cellTypes_[cellI] = foamVtkCore::VTK_POLYHEDRON;
|
||||||
|
const labelList& cFaces = mesh_.cells()[cellI];
|
||||||
|
|
||||||
|
faceLabels_[nFaceLabels++] = cFaces.size();
|
||||||
|
|
||||||
|
forAll(cFaces, cFaceI)
|
||||||
|
{
|
||||||
|
const face& f = mesh_.faces()[cFaces[cFaceI]];
|
||||||
|
const bool isOwner = (owner[cFaces[cFaceI]] == cellI);
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
hashUniqId.insert(f[fp]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// number of labels for this face
|
||||||
|
faceLabels_[nFaceLabels++] = f.size();
|
||||||
|
|
||||||
|
if (isOwner)
|
||||||
|
{
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
faceLabels_[nFaceLabels++] = f[fp];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// fairly immaterial if we reverse the list
|
||||||
|
// or use face::reverseFace()
|
||||||
|
forAllReverse(f, fp)
|
||||||
|
{
|
||||||
|
faceLabels_[nFaceLabels++] = f[fp];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
faceOffset_[cellI] = nFaceLabels;
|
||||||
|
|
||||||
|
const labelList uniq = hashUniqId.sortedToc();
|
||||||
|
forAll(uniq, i)
|
||||||
|
{
|
||||||
|
vertLabels_[nVertLabels++] = uniq[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
vertOffset_[cellI] = nVertLabels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================
|
||||||
|
// PASS 3: Repair offsets for additional cells
|
||||||
|
|
||||||
|
// Info<<"vertOffset: " << vertOffset_.size() << " VS. " << (mesh_.nCells()) << endl;
|
||||||
|
// Info<<"nAddCells: " << nAddCells << " VS. " << (mesh_.nCells()) << endl;
|
||||||
|
|
||||||
|
if (nAddCells)
|
||||||
|
{
|
||||||
|
const label beg = mesh_.nCells();
|
||||||
|
const label add = vertOffset_[beg-1];
|
||||||
|
|
||||||
|
for (label i = beg; i < vertOffset_.size(); ++i)
|
||||||
|
{
|
||||||
|
vertOffset_[i] += add;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some basic programming/sanity checks
|
||||||
|
|
||||||
|
if ((nVertLabels + nAddVerts) != vertOffset_[mesh_.nCells()-1 + nAddCells])
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "predicted offsets (" << nVertLabels << " + " << nAddVerts << ") != "
|
||||||
|
<< vertOffset_[mesh_.nCells()-1 + nAddCells]
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offsetAddVerts != vertOffset_[mesh_.nCells()-1])
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "predicted regular offset " << offsetAddVerts
|
||||||
|
<< " != " << vertOffset_[mesh_.nCells()]
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// nFaceLabels = 0;
|
||||||
|
// nAddPoints = 0;
|
||||||
|
// nAddCells = 0;
|
||||||
|
|
||||||
|
// Pout<<"vertLabels: " << vertLabels_.size() << " vs. " << (nVertLabels + nAddVerts) << endl;
|
||||||
|
// Pout<<"faceLabels: " << faceLabels_.size() << " vs. " << nFaceLabels << endl;
|
||||||
|
#if 0
|
||||||
|
if (decompose_.requested())
|
||||||
|
{
|
||||||
|
Pout<< " Original cells:" << mesh_.nCells()
|
||||||
|
<< " points:" << mesh_.nPoints()
|
||||||
|
<< " Additional cells:" << decompose_.superCells_.size()
|
||||||
|
<< " additional points:" << decompose_.addPointCellLabels_.size()
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkCells::decomp::decomp(const bool decomposePoly)
|
||||||
|
:
|
||||||
|
addPointCellLabels_(),
|
||||||
|
superCells_(),
|
||||||
|
pointMap_(),
|
||||||
|
requested_(decomposePoly)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkCells::foamVtkCells
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const bool decomposePoly,
|
||||||
|
const bool lazy
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mesh_(mesh),
|
||||||
|
cellTypes_(),
|
||||||
|
vertLabels_(),
|
||||||
|
vertOffset_(),
|
||||||
|
faceLabels_(),
|
||||||
|
faceOffset_(),
|
||||||
|
decompose_(decomposePoly),
|
||||||
|
needsUpdate_(true)
|
||||||
|
{
|
||||||
|
if (!lazy)
|
||||||
|
{
|
||||||
|
correct();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkCells::decomp::~decomp()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkCells::~foamVtkCells()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkCells::decomp::clear()
|
||||||
|
{
|
||||||
|
superCells_.clear();
|
||||||
|
addPointCellLabels_.clear();
|
||||||
|
pointMap_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::foamVtkCells::nFieldPoints() const
|
||||||
|
{
|
||||||
|
return mesh_.nPoints() + decompose_.addPointCellLabels_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::foamVtkCells::legacyCellPayLoad() const
|
||||||
|
{
|
||||||
|
label payLoad = cellTypes_.size();
|
||||||
|
|
||||||
|
if (faceOffset_.size())
|
||||||
|
{
|
||||||
|
// also has polys with face streams
|
||||||
|
|
||||||
|
label begVert = 0;
|
||||||
|
label begFace = 0;
|
||||||
|
|
||||||
|
forAll(faceOffset_, i)
|
||||||
|
{
|
||||||
|
label endFace = faceOffset_[i];
|
||||||
|
label endVert = vertOffset_[i];
|
||||||
|
|
||||||
|
if (endFace > 0)
|
||||||
|
{
|
||||||
|
// poly with face stream
|
||||||
|
payLoad += endFace - begFace;
|
||||||
|
|
||||||
|
begFace = endFace;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// primitive without face stream
|
||||||
|
payLoad += endVert - begVert;
|
||||||
|
}
|
||||||
|
begVert = endVert;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (vertOffset_.size())
|
||||||
|
{
|
||||||
|
// primitives only, trivial
|
||||||
|
payLoad += vertOffset_[vertOffset_.size()-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return payLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::foamVtkCells::needsUpdate() const
|
||||||
|
{
|
||||||
|
return needsUpdate_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::foamVtkCells::expire()
|
||||||
|
{
|
||||||
|
// Clear any stored topologies
|
||||||
|
|
||||||
|
// Clear derived data
|
||||||
|
// clearGeom();
|
||||||
|
|
||||||
|
// already marked as expired
|
||||||
|
if (needsUpdate_)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
needsUpdate_ = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::foamVtkCells::update()
|
||||||
|
{
|
||||||
|
if (!needsUpdate_)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
correct();
|
||||||
|
|
||||||
|
needsUpdate_ = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
350
src/conversion/vtk/part/foamVtkCells.H
Normal file
350
src/conversion/vtk/part/foamVtkCells.H
Normal file
@ -0,0 +1,350 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-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::foamVtkCells
|
||||||
|
|
||||||
|
Description
|
||||||
|
The deep-copy description of an OpenFOAM volume mesh in data structures
|
||||||
|
corresponding to an VTK UnstructuredGrid, including the possiblity of
|
||||||
|
decomposing polyhedral cells into primitive cell types.
|
||||||
|
|
||||||
|
Knowledge of the vtkUnstructuredGrid and the corresponding \c .vtu
|
||||||
|
xml file-format aids in understanding this class.
|
||||||
|
For flexibilty, support for the legacy vtk file-format is also provided.
|
||||||
|
|
||||||
|
Primitive cell types are straighforward, polyhedral cells are represented
|
||||||
|
by a face stream:
|
||||||
|
\verbatim
|
||||||
|
[nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
For the legacy format, the face stream is simply passed as vertex labels
|
||||||
|
(connectivity).
|
||||||
|
|
||||||
|
For the xml format, the face stream is saved separately:
|
||||||
|
\verbatim
|
||||||
|
"connectivity"
|
||||||
|
== the unique vertex labels used by the cell (optionally sorted).
|
||||||
|
|
||||||
|
"offsets":
|
||||||
|
== offset + sizeof(connectivity)
|
||||||
|
|
||||||
|
"faces":
|
||||||
|
[nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
|
||||||
|
|
||||||
|
"faceoffsets":
|
||||||
|
== faceoffsets + sizeof(faces)
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
The storage of "connectivity" and "offsets" strongly resembles a
|
||||||
|
CompactListList, but the "offsets" point to the end of the respective
|
||||||
|
sub-lists.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkCells.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkCells_H
|
||||||
|
#define foamVtkCells_H
|
||||||
|
|
||||||
|
#include "foamVtkCore.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
|
#include "SubList.H"
|
||||||
|
#include "labelList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration of classes
|
||||||
|
class polyMesh;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkCells Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkCells
|
||||||
|
:
|
||||||
|
public fileFormats::foamVtkCore
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Bookkeeping for polyhedral cell decomposition
|
||||||
|
class decomp
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
friend foamVtkCells;
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Cell-centre labels for additional points of decomposed cells
|
||||||
|
DynamicList<label> addPointCellLabels_;
|
||||||
|
|
||||||
|
//- Label of original cell for decomposed cells
|
||||||
|
DynamicList<label> superCells_;
|
||||||
|
|
||||||
|
//- Point labels for subsetted meshes
|
||||||
|
DynamicList<label> pointMap_;
|
||||||
|
|
||||||
|
//- Track if decomposition was requested
|
||||||
|
const bool requested_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
decomp(const decomp&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const decomp&) = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
decomp(const bool decomposePoly = false);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~decomp();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Polyhedral decomposition requested
|
||||||
|
inline bool requested() const;
|
||||||
|
|
||||||
|
//- Polyhedral decomposition used
|
||||||
|
inline bool used() const;
|
||||||
|
|
||||||
|
//- Label of original cell for decomposed cells
|
||||||
|
inline const labelList& superCells() const;
|
||||||
|
|
||||||
|
//- Cell-centre labels for additional points of decomposed cells
|
||||||
|
inline const labelList& addPointCellLabels() const;
|
||||||
|
|
||||||
|
//- Point labels for subsetted meshes
|
||||||
|
inline const labelList& pointMap() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Clear
|
||||||
|
void clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Reference to underlying mesh or mesh sub-set
|
||||||
|
const polyMesh& mesh_;
|
||||||
|
|
||||||
|
//- Cell types (including added cells) in vtk numbering
|
||||||
|
// Range is 1-255
|
||||||
|
List<uint8_t> cellTypes_;
|
||||||
|
|
||||||
|
//- Vertices per cell (including added cells) in vtk ordering
|
||||||
|
DynamicList<label> vertLabels_;
|
||||||
|
|
||||||
|
//- Vertices per cell (including added cells) in vtk ordering
|
||||||
|
DynamicList<label> vertOffset_;
|
||||||
|
|
||||||
|
//- Face lists per polyhedral cell
|
||||||
|
DynamicList<label> faceLabels_;
|
||||||
|
|
||||||
|
//- Face label offsets
|
||||||
|
DynamicList<label> faceOffset_;
|
||||||
|
|
||||||
|
//- Bookkeeping for polyhedral cell decomposition
|
||||||
|
decomp decompose_;
|
||||||
|
|
||||||
|
//- Needs update
|
||||||
|
bool needsUpdate_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Create the geometry
|
||||||
|
void correct();
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
foamVtkCells(const foamVtkCells&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const foamVtkCells&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components.
|
||||||
|
// Optionally with polyhedral decomposition and/or lazy evaluation.
|
||||||
|
// A 'lazy' evaluation avoids fully creation within the constructor.
|
||||||
|
foamVtkCells
|
||||||
|
(
|
||||||
|
const polyMesh&,
|
||||||
|
const bool decomposePoly = false,
|
||||||
|
const bool lazy = false
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~foamVtkCells();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Query the poly decompose flag.
|
||||||
|
inline bool decomposeRequested() const;
|
||||||
|
|
||||||
|
//- Values for "connectivity" (XML) or basis for "CELLS" (legacy)
|
||||||
|
// In the legacy format, the size (offset) must be prefixed.
|
||||||
|
inline const labelList& vertLabels() const;
|
||||||
|
|
||||||
|
//- Values for "offsets" (XML)
|
||||||
|
// or sizes to prefix for for "CELLS" (legacy)
|
||||||
|
inline const labelList& vertOffsets() const;
|
||||||
|
|
||||||
|
//- Values for "types" (XML) and "CELL_TYPES" (legacy)
|
||||||
|
inline const List<uint8_t>& cellTypes() const;
|
||||||
|
|
||||||
|
//- Values for "faces" (XML)
|
||||||
|
inline const labelList& faceLabels() const;
|
||||||
|
|
||||||
|
//- Values for "faceoffsets" (XML)
|
||||||
|
inline const labelList& faceOffsets() const;
|
||||||
|
|
||||||
|
//- Additional point addressing (from added point to original cell)
|
||||||
|
inline const labelList& addPointCellLabels() const;
|
||||||
|
|
||||||
|
//- Additional cells mapping (from added cell to original cell)
|
||||||
|
inline const labelList& superCells() const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Number of field cells
|
||||||
|
inline label nFieldCells() const;
|
||||||
|
|
||||||
|
//- Number of field points
|
||||||
|
label nFieldPoints() const;
|
||||||
|
|
||||||
|
//- The field size for legacy "CELLS".
|
||||||
|
// In the legacy format, the size (offset) must be prefixed.
|
||||||
|
label legacyCellPayLoad() const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Does the mapping need an update?
|
||||||
|
bool needsUpdate() const;
|
||||||
|
|
||||||
|
//- Mark as needing an update.
|
||||||
|
// May also free up unneeded data.
|
||||||
|
// Return false if it was already marked as expired.
|
||||||
|
bool expire();
|
||||||
|
|
||||||
|
//- Update the description (and decomposition) as required.
|
||||||
|
// Do nothing (and return false) if no update was required
|
||||||
|
bool update();
|
||||||
|
|
||||||
|
|
||||||
|
//- The const_iterator for foamVtkCells
|
||||||
|
class const_iterator
|
||||||
|
{
|
||||||
|
friend class foamVtkCells;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Data
|
||||||
|
|
||||||
|
//- Reference to parent list
|
||||||
|
const foamVtkCells& parent_;
|
||||||
|
|
||||||
|
//- Element index
|
||||||
|
label index_;
|
||||||
|
|
||||||
|
//- Begin of connectivity sub-list
|
||||||
|
mutable label begVert_;
|
||||||
|
|
||||||
|
//- Begin of faces sub-list
|
||||||
|
mutable label begFace_;
|
||||||
|
|
||||||
|
//- On-demand legacy pointer
|
||||||
|
mutable autoPtr<SubList<label>> legacy_;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct begin/end iterator
|
||||||
|
inline const_iterator
|
||||||
|
(
|
||||||
|
const foamVtkCells&,
|
||||||
|
bool isEnd = false
|
||||||
|
);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Member operators
|
||||||
|
|
||||||
|
//- On-demand legacy cell labels (primitive or faces)
|
||||||
|
inline const labelUList& legacyCell() const;
|
||||||
|
|
||||||
|
//- Compare position
|
||||||
|
inline bool operator!=(const const_iterator&) const;
|
||||||
|
|
||||||
|
//- Pre-increment iterator
|
||||||
|
inline const_iterator& operator++();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//- const_iterator set to the beginning
|
||||||
|
inline const_iterator begin() const;
|
||||||
|
|
||||||
|
//- const_iterator set to beyond the end
|
||||||
|
inline const_iterator end() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "foamVtkCellsI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
239
src/conversion/vtk/part/foamVtkCellsI.H
Normal file
239
src/conversion/vtk/part/foamVtkCellsI.H
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkCells.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkCells::decomp::requested() const
|
||||||
|
{
|
||||||
|
return requested_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkCells::decomp::used() const
|
||||||
|
{
|
||||||
|
return !superCells_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::decomp::superCells() const
|
||||||
|
{
|
||||||
|
return superCells_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::decomp::addPointCellLabels() const
|
||||||
|
{
|
||||||
|
return addPointCellLabels_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::decomp::pointMap() const
|
||||||
|
{
|
||||||
|
return pointMap_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkCells::decomposeRequested() const
|
||||||
|
{
|
||||||
|
return decompose_.requested();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::vertLabels() const
|
||||||
|
{
|
||||||
|
return vertLabels_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::vertOffsets() const
|
||||||
|
{
|
||||||
|
return vertOffset_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::List<uint8_t>&
|
||||||
|
Foam::foamVtkCells::cellTypes() const
|
||||||
|
{
|
||||||
|
return cellTypes_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::faceLabels() const
|
||||||
|
{
|
||||||
|
return faceLabels_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::faceOffsets() const
|
||||||
|
{
|
||||||
|
return faceOffset_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::addPointCellLabels() const
|
||||||
|
{
|
||||||
|
return decompose_.addPointCellLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::labelList&
|
||||||
|
Foam::foamVtkCells::superCells() const
|
||||||
|
{
|
||||||
|
return decompose_.superCells();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label
|
||||||
|
Foam::foamVtkCells::nFieldCells() const
|
||||||
|
{
|
||||||
|
return cellTypes_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::foamVtkCells::const_iterator
|
||||||
|
Foam::foamVtkCells::begin() const
|
||||||
|
{
|
||||||
|
return const_iterator(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::foamVtkCells::const_iterator
|
||||||
|
Foam::foamVtkCells::end() const
|
||||||
|
{
|
||||||
|
return const_iterator(*this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::foamVtkCells::const_iterator::const_iterator
|
||||||
|
(
|
||||||
|
const foamVtkCells& cells,
|
||||||
|
bool isEnd
|
||||||
|
)
|
||||||
|
:
|
||||||
|
parent_(cells),
|
||||||
|
index_(0),
|
||||||
|
begVert_(0),
|
||||||
|
begFace_(0),
|
||||||
|
legacy_()
|
||||||
|
{
|
||||||
|
if (isEnd)
|
||||||
|
{
|
||||||
|
index_ = parent_.vertOffsets().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
Foam::foamVtkCells::const_iterator&
|
||||||
|
Foam::foamVtkCells::const_iterator::operator++()
|
||||||
|
{
|
||||||
|
++index_;
|
||||||
|
legacy_.clear();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
const Foam::UList<Foam::label>&
|
||||||
|
Foam::foamVtkCells::const_iterator::legacyCell() const
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
legacy_.valid()
|
||||||
|
|| index_ >= parent_.vertOffsets().size()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return legacy_();
|
||||||
|
}
|
||||||
|
|
||||||
|
const label endVert = parent_.vertOffsets()[index_];
|
||||||
|
|
||||||
|
const label endFace =
|
||||||
|
(
|
||||||
|
parent_.faceOffsets().size()
|
||||||
|
? parent_.faceOffsets()[index_]
|
||||||
|
: -1
|
||||||
|
);
|
||||||
|
|
||||||
|
if (endFace > 0)
|
||||||
|
{
|
||||||
|
// poly with face stream
|
||||||
|
|
||||||
|
legacy_.reset
|
||||||
|
(
|
||||||
|
new SubList<label>
|
||||||
|
(
|
||||||
|
parent_.faceLabels(),
|
||||||
|
endFace - begFace_,
|
||||||
|
begFace_
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
begFace_ = endFace;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// primitive without face stream
|
||||||
|
legacy_.reset
|
||||||
|
(
|
||||||
|
new SubList<label>
|
||||||
|
(
|
||||||
|
parent_.vertLabels(),
|
||||||
|
endVert - begVert_,
|
||||||
|
begVert_
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
begVert_ = endVert;
|
||||||
|
|
||||||
|
return legacy_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
Foam::foamVtkCells::const_iterator::operator!=
|
||||||
|
(
|
||||||
|
const const_iterator& rhs
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return (index_ != rhs.index_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -11,7 +11,16 @@ nas/NASCore.C
|
|||||||
fire/FIRECore.C
|
fire/FIRECore.C
|
||||||
starcd/STARCDCore.C
|
starcd/STARCDCore.C
|
||||||
|
|
||||||
vtk/vtkUnstructuredReader.C
|
vtk/foamVtkCore.C
|
||||||
|
vtk/format/foamVtkAppendBase64Formatter.C
|
||||||
|
vtk/format/foamVtkAppendRawFormatter.C
|
||||||
|
vtk/format/foamVtkAsciiFormatter.C
|
||||||
|
vtk/format/foamVtkBase64Formatter.C
|
||||||
|
vtk/format/foamVtkLegacyFormatter.C
|
||||||
|
vtk/format/foamVtkFormatter.C
|
||||||
|
vtk/format/foamVtkOutputOptions.C
|
||||||
|
vtk/read/vtkUnstructuredReader.C
|
||||||
|
vtk/type/foamVtkPTraits.C
|
||||||
|
|
||||||
coordSet/coordSet.C
|
coordSet/coordSet.C
|
||||||
|
|
||||||
|
|||||||
54
src/fileFormats/vtk/foamVtkCore.C
Normal file
54
src/fileFormats/vtk/foamVtkCore.C
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
109
src/fileFormats/vtk/foamVtkCore.H
Normal file
109
src/fileFormats/vtk/foamVtkCore.H
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
65
src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C
Normal file
65
src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkAppendBase64Formatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAppendBase64Formatter::name_ = "append";
|
||||||
|
const char* Foam::foamVtkAppendBase64Formatter::encoding_ = "base64";
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkAppendBase64Formatter::foamVtkAppendBase64Formatter
|
||||||
|
(
|
||||||
|
std::ostream& os
|
||||||
|
)
|
||||||
|
:
|
||||||
|
foamVtkBase64Formatter(os)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkAppendBase64Formatter::~foamVtkAppendBase64Formatter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAppendBase64Formatter::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAppendBase64Formatter::encoding() const
|
||||||
|
{
|
||||||
|
return encoding_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
99
src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H
Normal file
99
src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
foamVtkAppendBase64Formatter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Appended base-64 encoded binary output.
|
||||||
|
Uses an output filter layer to write base-64 encoded content.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkAppendBase64Formatter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkAppendBase64Formatter_H
|
||||||
|
#define foamVtkAppendBase64Formatter_H
|
||||||
|
|
||||||
|
#include "foamVtkBase64Formatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkAppendBase64Formatter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkAppendBase64Formatter
|
||||||
|
:
|
||||||
|
public foamVtkBase64Formatter
|
||||||
|
{
|
||||||
|
// Private Data Members
|
||||||
|
|
||||||
|
static const char* name_;
|
||||||
|
static const char* encoding_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
foamVtkAppendBase64Formatter(const foamVtkAppendBase64Formatter&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const foamVtkAppendBase64Formatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream
|
||||||
|
foamVtkAppendBase64Formatter(std::ostream&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~foamVtkAppendBase64Formatter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Output name for XML type ("append")
|
||||||
|
virtual const char* name() const;
|
||||||
|
|
||||||
|
//- Name for the XML append encoding ("base64").
|
||||||
|
virtual const char* encoding() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
112
src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C
Normal file
112
src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkAppendRawFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAppendRawFormatter::name_ = "append";
|
||||||
|
const char* Foam::foamVtkAppendRawFormatter::encoding_ = "raw";
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::foamVtkAppendRawFormatter::write
|
||||||
|
(
|
||||||
|
const char* s,
|
||||||
|
std::streamsize n
|
||||||
|
)
|
||||||
|
{
|
||||||
|
os().write(s, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkAppendRawFormatter::foamVtkAppendRawFormatter(std::ostream& os)
|
||||||
|
:
|
||||||
|
foamVtkFormatter(os)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkAppendRawFormatter::~foamVtkAppendRawFormatter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAppendRawFormatter::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAppendRawFormatter::encoding() const
|
||||||
|
{
|
||||||
|
return encoding_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t val)
|
||||||
|
{
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAppendRawFormatter::write(const uint8_t val)
|
||||||
|
{
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(uint8_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAppendRawFormatter::write(const label val)
|
||||||
|
{
|
||||||
|
// std::cerr<<"label is:" << sizeof(val) << '\n';
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAppendRawFormatter::write(const float val)
|
||||||
|
{
|
||||||
|
// std::cerr<<"float is:" << sizeof(val) << '\n';
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAppendRawFormatter::write(const double val)
|
||||||
|
{
|
||||||
|
// std::cerr<<"write double as float:" << val << '\n';
|
||||||
|
float copy(val);
|
||||||
|
write(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAppendRawFormatter::flush()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
115
src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H
Normal file
115
src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
foamVtkAppendRawFormatter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Appended raw binary output.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkAppendRawFormatter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkAppendRawFormatter_H
|
||||||
|
#define foamVtkAppendRawFormatter_H
|
||||||
|
|
||||||
|
#include "foamVtkFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkAppendRawFormatter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkAppendRawFormatter
|
||||||
|
:
|
||||||
|
public foamVtkFormatter
|
||||||
|
{
|
||||||
|
// Private Data Members
|
||||||
|
|
||||||
|
static const char* name_;
|
||||||
|
static const char* encoding_;
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
foamVtkAppendRawFormatter(const foamVtkAppendRawFormatter&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const foamVtkAppendRawFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
void write(const char* s, std::streamsize n);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream
|
||||||
|
foamVtkAppendRawFormatter(std::ostream&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~foamVtkAppendRawFormatter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Output name for XML type ("append")
|
||||||
|
virtual const char* name() const;
|
||||||
|
|
||||||
|
//- Output name for append encoding type ("raw")
|
||||||
|
virtual const char* encoding() const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Write leading size for binary output
|
||||||
|
virtual void writeSize(const uint64_t);
|
||||||
|
|
||||||
|
virtual void write(const uint8_t);
|
||||||
|
virtual void write(const label);
|
||||||
|
virtual void write(const float);
|
||||||
|
virtual void write(const double);
|
||||||
|
virtual void flush();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
136
src/fileFormats/vtk/format/foamVtkAsciiFormatter.C
Normal file
136
src/fileFormats/vtk/format/foamVtkAsciiFormatter.C
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkAsciiFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAsciiFormatter::name_ = "ascii";
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline void Foam::foamVtkAsciiFormatter::next()
|
||||||
|
{
|
||||||
|
if (pos_ == 6)
|
||||||
|
{
|
||||||
|
os()<< '\n';
|
||||||
|
pos_ = 0;
|
||||||
|
}
|
||||||
|
else if (pos_)
|
||||||
|
{
|
||||||
|
os()<< ' ';
|
||||||
|
}
|
||||||
|
++pos_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter(std::ostream& os)
|
||||||
|
:
|
||||||
|
foamVtkFormatter(os),
|
||||||
|
pos_(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
unsigned precision
|
||||||
|
)
|
||||||
|
:
|
||||||
|
foamVtkFormatter(os),
|
||||||
|
pos_(0)
|
||||||
|
{
|
||||||
|
os.precision(precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkAsciiFormatter::~foamVtkAsciiFormatter()
|
||||||
|
{
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAsciiFormatter::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* Foam::foamVtkAsciiFormatter::encoding() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t)
|
||||||
|
{/*nop*/}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAsciiFormatter::write(const uint8_t val)
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
os()<< int(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAsciiFormatter::write(const label val)
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
os()<< val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAsciiFormatter::write(const float val)
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
os()<< val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAsciiFormatter::write(const double val)
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
os()<< float(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkAsciiFormatter::flush()
|
||||||
|
{
|
||||||
|
if (pos_)
|
||||||
|
{
|
||||||
|
os()<< '\n';
|
||||||
|
}
|
||||||
|
pos_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
120
src/fileFormats/vtk/format/foamVtkAsciiFormatter.H
Normal file
120
src/fileFormats/vtk/format/foamVtkAsciiFormatter.H
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
foamVtkAsciiFormatter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Inline ASCII binary output.
|
||||||
|
Adds spaces between entries and a newline every 6 items
|
||||||
|
(for consistency with what VTK itself outputs).
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkAsciiFormatter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkAsciiFormatter_H
|
||||||
|
#define foamVtkAsciiFormatter_H
|
||||||
|
|
||||||
|
#include "foamVtkFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkAsciiFormatter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkAsciiFormatter
|
||||||
|
:
|
||||||
|
public foamVtkFormatter
|
||||||
|
{
|
||||||
|
// Private Data Members
|
||||||
|
|
||||||
|
static const char* name_;
|
||||||
|
|
||||||
|
//- Track the current output position
|
||||||
|
unsigned short pos_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Advance to next position, adding space or newline as required
|
||||||
|
inline void next();
|
||||||
|
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
foamVtkAsciiFormatter(const foamVtkAsciiFormatter&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const foamVtkAsciiFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream, use default precision
|
||||||
|
foamVtkAsciiFormatter(std::ostream&);
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream, use specified precision
|
||||||
|
foamVtkAsciiFormatter(std::ostream&, unsigned precision);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~foamVtkAsciiFormatter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Name for the XML output type ("ascii")
|
||||||
|
// The legacy output type is an uppercase version of this.
|
||||||
|
virtual const char* name() const;
|
||||||
|
|
||||||
|
//- Name for the XML append encoding - unused.
|
||||||
|
// Currently simply "ASCII", but this should not be relied upon.
|
||||||
|
virtual const char* encoding() const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Write leading size - this is a no-op for ascii output
|
||||||
|
virtual void writeSize(const uint64_t);
|
||||||
|
|
||||||
|
virtual void write(const uint8_t);
|
||||||
|
virtual void write(const label);
|
||||||
|
virtual void write(const float);
|
||||||
|
virtual void write(const double);
|
||||||
|
virtual void flush();
|
||||||
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
120
src/fileFormats/vtk/format/foamVtkBase64Formatter.C
Normal file
120
src/fileFormats/vtk/format/foamVtkBase64Formatter.C
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkBase64Formatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkBase64Formatter::name_ = "binary";
|
||||||
|
const char* Foam::foamVtkBase64Formatter::encoding_ = "base64";
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::foamVtkBase64Formatter::write
|
||||||
|
(
|
||||||
|
const char* s,
|
||||||
|
std::streamsize n
|
||||||
|
)
|
||||||
|
{
|
||||||
|
base64Layer::write(s, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
|
||||||
|
:
|
||||||
|
foamVtkFormatter(os),
|
||||||
|
base64Layer(os)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkBase64Formatter::~foamVtkBase64Formatter()
|
||||||
|
{
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkBase64Formatter::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* Foam::foamVtkBase64Formatter::encoding() const
|
||||||
|
{
|
||||||
|
return encoding_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkBase64Formatter::writeSize(const uint64_t val)
|
||||||
|
{
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkBase64Formatter::write(const uint8_t val)
|
||||||
|
{
|
||||||
|
base64Layer::add(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkBase64Formatter::write(const label val)
|
||||||
|
{
|
||||||
|
// std::cerr<<"label is:" << sizeof(val) << '\n';
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkBase64Formatter::write(const float val)
|
||||||
|
{
|
||||||
|
// std::cerr<<"float is:" << sizeof(val) << '\n';
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkBase64Formatter::write(const double val)
|
||||||
|
{
|
||||||
|
// std::cerr<<"write double as float:" << val << '\n';
|
||||||
|
float copy(val);
|
||||||
|
write(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkBase64Formatter::flush()
|
||||||
|
{
|
||||||
|
if (base64Layer::close())
|
||||||
|
{
|
||||||
|
os().put('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
116
src/fileFormats/vtk/format/foamVtkBase64Formatter.H
Normal file
116
src/fileFormats/vtk/format/foamVtkBase64Formatter.H
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
foamVtkBase64Formatter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Inline base-64 encoded binary output.
|
||||||
|
Uses an output filter layer to write base-64 encoded content.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkBase64Formatter_H
|
||||||
|
#define foamVtkBase64Formatter_H
|
||||||
|
|
||||||
|
#include "foamVtkFormatter.H"
|
||||||
|
#include "base64Layer.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkBase64Formatter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkBase64Formatter
|
||||||
|
:
|
||||||
|
public foamVtkFormatter,
|
||||||
|
private base64Layer
|
||||||
|
{
|
||||||
|
// Private Data Members
|
||||||
|
|
||||||
|
static const char* name_;
|
||||||
|
static const char* encoding_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
foamVtkBase64Formatter(const foamVtkBase64Formatter&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const foamVtkBase64Formatter&) = delete;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
void write(const char* s, std::streamsize n);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream
|
||||||
|
foamVtkBase64Formatter(std::ostream&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~foamVtkBase64Formatter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Name for the XML output type ("binary")
|
||||||
|
// The lowercase version of the Legacy output type.
|
||||||
|
virtual const char* name() const;
|
||||||
|
|
||||||
|
//- Name for the XML append encoding.
|
||||||
|
virtual const char* encoding() const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Write leading size for binary output
|
||||||
|
virtual void writeSize(const uint64_t);
|
||||||
|
|
||||||
|
virtual void write(const uint8_t);
|
||||||
|
virtual void write(const label);
|
||||||
|
virtual void write(const float);
|
||||||
|
virtual void write(const double);
|
||||||
|
virtual void flush();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
315
src/fileFormats/vtk/format/foamVtkFormatter.C
Normal file
315
src/fileFormats/vtk/format/foamVtkFormatter.C
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkFormatter.H"
|
||||||
|
#include "foamVtkPTraits.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* const Foam::foamVtkFormatter::byteOrder
|
||||||
|
= Foam::foamVtkPTraits<endian>::typeName;
|
||||||
|
|
||||||
|
const char* const Foam::foamVtkFormatter::headerType =
|
||||||
|
Foam::foamVtkPTraits<uint64_t>::typeName;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter::foamVtkFormatter(std::ostream& os)
|
||||||
|
:
|
||||||
|
os_(os),
|
||||||
|
xmlTags_(),
|
||||||
|
inTag_(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter::~foamVtkFormatter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::foamVtkFormatter::indent()
|
||||||
|
{
|
||||||
|
label n = xmlTags_.size() * 2;
|
||||||
|
while (n--)
|
||||||
|
{
|
||||||
|
os_ << ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::xmlHeader()
|
||||||
|
{
|
||||||
|
if (inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "xml header, but already within a tag!"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_ << "<?xml version='1.0'?>" << nl;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::comment(const std::string& text)
|
||||||
|
{
|
||||||
|
if (inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "adding xml comment inside a tag??"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
indent();
|
||||||
|
os_ << "<!-- " << text << " -->" << nl;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::openTag(const word& tag)
|
||||||
|
{
|
||||||
|
if (inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "open XML tag '" << tag << "', but already within a tag!"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
indent();
|
||||||
|
os_ << '<' << tag;
|
||||||
|
|
||||||
|
xmlTags_.push(tag);
|
||||||
|
inTag_ = true;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::closeTag(bool isEmpty)
|
||||||
|
{
|
||||||
|
if (!inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "close XML tag, but not within a tag!"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEmpty)
|
||||||
|
{
|
||||||
|
// eg, <tag ... />
|
||||||
|
xmlTags_.pop();
|
||||||
|
os_ << " /";
|
||||||
|
}
|
||||||
|
os_ << '>' << nl;
|
||||||
|
|
||||||
|
inTag_ = false;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::tag(const word& tag)
|
||||||
|
{
|
||||||
|
openTag(tag);
|
||||||
|
closeTag();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::endTag(const word& tag)
|
||||||
|
{
|
||||||
|
const word curr = xmlTags_.pop();
|
||||||
|
indent();
|
||||||
|
|
||||||
|
if (inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "adding XML endTag '" << curr
|
||||||
|
<< "' but already in another tag!"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify inTag_
|
||||||
|
if (!tag.empty() && tag != curr)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "expected to end xml-tag '" << tag
|
||||||
|
<< "' but found '" << curr << "' instead"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_ << "</" << curr << '>' << nl;
|
||||||
|
|
||||||
|
inTag_ = false;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::xmlAttr
|
||||||
|
(
|
||||||
|
const word& k,
|
||||||
|
const std::string& v,
|
||||||
|
const char quote
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "xml attribute '" << k << "' but not within a tag!"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_ << ' ' << k << '=' << quote << v.c_str() << quote;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::xmlAttr
|
||||||
|
(
|
||||||
|
const word& k,
|
||||||
|
const label v,
|
||||||
|
const char quote
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "xml attribute '" << k << "' but not within a tag!"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_ << ' ' << k << '=' << quote << v << quote;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::xmlAttr
|
||||||
|
(
|
||||||
|
const word& k,
|
||||||
|
const uint64_t v,
|
||||||
|
const char quote
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "xml attribute '" << k << "' but not within a tag!"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_ << ' ' << k << '=' << quote << v << quote;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::xmlAttr
|
||||||
|
(
|
||||||
|
const word& k,
|
||||||
|
const scalar v,
|
||||||
|
const char quote
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!inTag_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "xml attribute '" << k << "' but not within a tag!"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_ << ' ' << k << '=' << quote << v << quote;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::operator()
|
||||||
|
(
|
||||||
|
const word& k,
|
||||||
|
const std::string& v
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return xmlAttr(k, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::operator()
|
||||||
|
(
|
||||||
|
const word& k,
|
||||||
|
const label v
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return xmlAttr(k, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::operator()
|
||||||
|
(
|
||||||
|
const word& k,
|
||||||
|
const uint64_t v
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return xmlAttr(k, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkFormatter&
|
||||||
|
Foam::foamVtkFormatter::operator()
|
||||||
|
(
|
||||||
|
const word& k,
|
||||||
|
const scalar v
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return xmlAttr(k, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
233
src/fileFormats/vtk/format/foamVtkFormatter.H
Normal file
233
src/fileFormats/vtk/format/foamVtkFormatter.H
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
foamVtkFormatter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Abstract class for a VTK output stream formatter.
|
||||||
|
|
||||||
|
Includes very simple support for writing XML tags.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkFormatter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkFormatter_H
|
||||||
|
#define foamVtkFormatter_H
|
||||||
|
|
||||||
|
#include "int.H"
|
||||||
|
#include "uint64.H"
|
||||||
|
#include "label.H"
|
||||||
|
#include "word.H"
|
||||||
|
#include "UList.H"
|
||||||
|
#include "LIFOStack.H"
|
||||||
|
#include "foamVtkPTraits.H"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkFormatter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkFormatter
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- The output stream for the formatter
|
||||||
|
std::ostream& os_;
|
||||||
|
|
||||||
|
//- Stack of current XML tags
|
||||||
|
LIFOStack<word> xmlTags_;
|
||||||
|
|
||||||
|
//- Tag open/closed/ended state
|
||||||
|
mutable bool inTag_;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream
|
||||||
|
foamVtkFormatter(std::ostream& os);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Static Data
|
||||||
|
|
||||||
|
//- VTK name for the 'byte_order' attribute
|
||||||
|
static const char* const byteOrder;
|
||||||
|
|
||||||
|
//- VTK name for the 'header_type' attribute (UInt64)
|
||||||
|
static const char* const headerType;
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~foamVtkFormatter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Access to the underlying output stream
|
||||||
|
inline std::ostream& os()
|
||||||
|
{
|
||||||
|
return os_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Name for the XML output type.
|
||||||
|
// Possibly the lowercase version of the Legacy output type
|
||||||
|
virtual const char* name() const = 0;
|
||||||
|
|
||||||
|
//- Name for the XML append encoding
|
||||||
|
virtual const char* encoding() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
//- Write leading size for binary output
|
||||||
|
virtual void writeSize(const uint64_t) = 0;
|
||||||
|
|
||||||
|
virtual void write(const uint8_t) = 0;
|
||||||
|
virtual void write(const label) = 0;
|
||||||
|
virtual void write(const float) = 0;
|
||||||
|
virtual void write(const double) = 0;
|
||||||
|
virtual void flush() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Indent according to the currently nested XML tags
|
||||||
|
void indent();
|
||||||
|
|
||||||
|
//- Write XML header
|
||||||
|
foamVtkFormatter& xmlHeader();
|
||||||
|
|
||||||
|
//- Write XML comment (at the current indentation level)
|
||||||
|
foamVtkFormatter& comment(const std::string&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Open XML tag
|
||||||
|
foamVtkFormatter& openTag(const word& tag);
|
||||||
|
|
||||||
|
//- Close XML tag, optional as an empty container.
|
||||||
|
// Always adds a trailing newline.
|
||||||
|
foamVtkFormatter& closeTag(bool isEmpty = false);
|
||||||
|
|
||||||
|
//- End XML tag, optional with sanity check
|
||||||
|
// Always adds a trailing newline.
|
||||||
|
foamVtkFormatter& endTag(const word& tag = word::null);
|
||||||
|
|
||||||
|
//- Write XML tag without any attributes. Combines openTag/closeTag.
|
||||||
|
foamVtkFormatter& tag(const word& tag);
|
||||||
|
|
||||||
|
|
||||||
|
//- Open "DataArray" XML tag
|
||||||
|
template<class Type, int nComp=0>
|
||||||
|
foamVtkFormatter& openDataArray(const word& dataName);
|
||||||
|
|
||||||
|
|
||||||
|
//- Insert a single "PDataArray" XML entry tag.
|
||||||
|
// For some entries, the name is optional.
|
||||||
|
template<class Type, int nComp=0>
|
||||||
|
foamVtkFormatter& PDataArray(const word& dataName);
|
||||||
|
|
||||||
|
|
||||||
|
//- End "DataArray" XML tag
|
||||||
|
foamVtkFormatter& endDataArray()
|
||||||
|
{
|
||||||
|
return endTag("DataArray");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//- Write XML attribute
|
||||||
|
foamVtkFormatter& xmlAttr
|
||||||
|
(
|
||||||
|
const word&,
|
||||||
|
const std::string&,
|
||||||
|
const char quote='\''
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write XML attribute
|
||||||
|
foamVtkFormatter& xmlAttr
|
||||||
|
(
|
||||||
|
const word&,
|
||||||
|
const label,
|
||||||
|
const char quote='\''
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write XML attribute
|
||||||
|
foamVtkFormatter& xmlAttr
|
||||||
|
(
|
||||||
|
const word&,
|
||||||
|
const uint64_t,
|
||||||
|
const char quote='\''
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write XML attribute
|
||||||
|
foamVtkFormatter& xmlAttr
|
||||||
|
(
|
||||||
|
const word&,
|
||||||
|
const scalar,
|
||||||
|
const char quote='\''
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Write XML attribute
|
||||||
|
foamVtkFormatter& operator()(const word&, const std::string&);
|
||||||
|
|
||||||
|
//- Write XML attribute
|
||||||
|
foamVtkFormatter& operator()(const word&, const label);
|
||||||
|
|
||||||
|
//- Write XML attribute
|
||||||
|
foamVtkFormatter& operator()(const word&, const uint64_t);
|
||||||
|
|
||||||
|
//- Write XML attribute
|
||||||
|
foamVtkFormatter& operator()(const word&, const scalar);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "foamVtkFormatterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
70
src/fileFormats/vtk/format/foamVtkFormatterTemplates.C
Normal file
70
src/fileFormats/vtk/format/foamVtkFormatterTemplates.C
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkPTraits.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type, int nComp>
|
||||||
|
Foam::foamVtkFormatter& Foam::foamVtkFormatter::openDataArray
|
||||||
|
(
|
||||||
|
const word& dataName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
openTag("DataArray");
|
||||||
|
xmlAttr("type", foamVtkPTraits<Type>::typeName);
|
||||||
|
xmlAttr("Name", dataName);
|
||||||
|
if (nComp > 1)
|
||||||
|
{
|
||||||
|
xmlAttr("NumberOfComponents", nComp);
|
||||||
|
}
|
||||||
|
xmlAttr("format", name());
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, int nComp>
|
||||||
|
Foam::foamVtkFormatter& Foam::foamVtkFormatter::PDataArray
|
||||||
|
(
|
||||||
|
const word& dataName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
openTag("PDataArray");
|
||||||
|
xmlAttr("type", foamVtkPTraits<Type>::typeName);
|
||||||
|
if (dataName.size())
|
||||||
|
{
|
||||||
|
xmlAttr("Name", dataName);
|
||||||
|
}
|
||||||
|
if (nComp > 1)
|
||||||
|
{
|
||||||
|
xmlAttr("NumberOfComponents", nComp);
|
||||||
|
}
|
||||||
|
|
||||||
|
closeTag(true);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
139
src/fileFormats/vtk/format/foamVtkLegacyFormatter.C
Normal file
139
src/fileFormats/vtk/format/foamVtkLegacyFormatter.C
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkLegacyFormatter.H"
|
||||||
|
#include "endian.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkLegacyFormatter::name_ = "BINARY";
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::foamVtkLegacyFormatter::write
|
||||||
|
(
|
||||||
|
const char* s,
|
||||||
|
std::streamsize n
|
||||||
|
)
|
||||||
|
{
|
||||||
|
os().write(s, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkLegacyFormatter::foamVtkLegacyFormatter(std::ostream& os)
|
||||||
|
:
|
||||||
|
foamVtkFormatter(os)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkLegacyFormatter::~foamVtkLegacyFormatter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkLegacyFormatter::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* Foam::foamVtkLegacyFormatter::encoding() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkLegacyFormatter::write(const uint8_t val)
|
||||||
|
{
|
||||||
|
// Can only handle integers
|
||||||
|
int copy(val);
|
||||||
|
write(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkLegacyFormatter::write(const label val)
|
||||||
|
{
|
||||||
|
// std::cerr<<"label is:" << sizeof(val) << '\n';
|
||||||
|
|
||||||
|
// Not entirely correct: the legacy format only supports 32-bit integers.
|
||||||
|
// Either limit size for 64-bit label, or simply do not support for 64-bit.
|
||||||
|
#ifdef WM_LITTLE_ENDIAN
|
||||||
|
# if WM_LABEL_SIZE == 32
|
||||||
|
uint32_t swapped = endian::swap32(val);
|
||||||
|
write(reinterpret_cast<const char*>(&swapped), sizeof(uint32_t));
|
||||||
|
# elif WM_LABEL_SIZE == 64
|
||||||
|
uint64_t swapped = endian::swap64(val);
|
||||||
|
write(reinterpret_cast<const char*>(&swapped), sizeof(uint64_t));
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkLegacyFormatter::write(const float val)
|
||||||
|
{
|
||||||
|
// std::cerr<<"float is:" << sizeof(val) << '\n';
|
||||||
|
|
||||||
|
#ifdef WM_LITTLE_ENDIAN
|
||||||
|
// De-reference in two stages to avoid the warning
|
||||||
|
// dereferencing type-punned pointer will break strict-aliasing rules
|
||||||
|
// [-Wstrict-aliasing]
|
||||||
|
|
||||||
|
const uint32_t* ptr = reinterpret_cast<const uint32_t*>(&val);
|
||||||
|
uint32_t swapped = endian::swap32(*ptr);
|
||||||
|
write(reinterpret_cast<const char*>(&swapped), sizeof(uint32_t));
|
||||||
|
#else
|
||||||
|
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkLegacyFormatter::write(const double val)
|
||||||
|
{
|
||||||
|
// Legacy cannot support Float64 anyhow.
|
||||||
|
// std::cerr<<"write double as float:" << val << '\n';
|
||||||
|
float copy(val);
|
||||||
|
write(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkLegacyFormatter::flush()
|
||||||
|
{
|
||||||
|
os()<< '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
119
src/fileFormats/vtk/format/foamVtkLegacyFormatter.H
Normal file
119
src/fileFormats/vtk/format/foamVtkLegacyFormatter.H
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
foamVtkLegacyFormatter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Binary output for the VTK legacy format, always written as big-endian.
|
||||||
|
|
||||||
|
The legacy files are always written as big endian.
|
||||||
|
Since integers in the legacy format are limited to 32-bit,
|
||||||
|
this format should not be used for OpenFOAM with 64-bit label sizes.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkLegacyFormatter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkLegacyFormatter_H
|
||||||
|
#define foamVtkLegacyFormatter_H
|
||||||
|
|
||||||
|
#include "foamVtkFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkLegacyFormatter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkLegacyFormatter
|
||||||
|
:
|
||||||
|
public foamVtkFormatter
|
||||||
|
{
|
||||||
|
// Private Data Members
|
||||||
|
|
||||||
|
static const char* name_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
foamVtkLegacyFormatter(const foamVtkLegacyFormatter&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const foamVtkLegacyFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
void write(const char* s, std::streamsize n);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream
|
||||||
|
foamVtkLegacyFormatter(std::ostream&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~foamVtkLegacyFormatter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Name for the Legacy output type ("BINARY")
|
||||||
|
virtual const char* name() const;
|
||||||
|
|
||||||
|
//- Name for the XML append encoding (unused)
|
||||||
|
// Currently simply "BINARY", but this should not be relied upon.
|
||||||
|
virtual const char* encoding() const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Write leading size - a no-op for legacy binary output
|
||||||
|
virtual void writeSize(const uint64_t);
|
||||||
|
|
||||||
|
virtual void write(const uint8_t);
|
||||||
|
virtual void write(const label);
|
||||||
|
virtual void write(const float);
|
||||||
|
virtual void write(const double);
|
||||||
|
virtual void flush();
|
||||||
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
240
src/fileFormats/vtk/format/foamVtkOutputOptions.C
Normal file
240
src/fileFormats/vtk/format/foamVtkOutputOptions.C
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkOutputOptions.H"
|
||||||
|
|
||||||
|
#include "foamVtkAppendBase64Formatter.H"
|
||||||
|
#include "foamVtkAppendRawFormatter.H"
|
||||||
|
#include "foamVtkAsciiFormatter.H"
|
||||||
|
#include "foamVtkBase64Formatter.H"
|
||||||
|
#include "foamVtkLegacyFormatter.H"
|
||||||
|
|
||||||
|
#include "IOstream.H"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkOutputOptions::foamVtkOutputOptions()
|
||||||
|
:
|
||||||
|
type_(ASCII),
|
||||||
|
style_(NONE),
|
||||||
|
precision_(IOstream::defaultPrecision())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::foamVtkFormatter>
|
||||||
|
Foam::foamVtkOutputOptions::newFormatter
|
||||||
|
(
|
||||||
|
std::ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
switch (type_)
|
||||||
|
{
|
||||||
|
case (LEGACY | BINARY):
|
||||||
|
return autoPtr<foamVtkFormatter>
|
||||||
|
(
|
||||||
|
new foamVtkLegacyFormatter(os)
|
||||||
|
);
|
||||||
|
|
||||||
|
case BASE64: // xml insitu
|
||||||
|
return autoPtr<foamVtkFormatter>
|
||||||
|
(
|
||||||
|
new foamVtkBase64Formatter(os)
|
||||||
|
);
|
||||||
|
|
||||||
|
case (APPEND | BASE64):
|
||||||
|
return autoPtr<foamVtkFormatter>
|
||||||
|
(
|
||||||
|
new foamVtkAppendBase64Formatter(os)
|
||||||
|
);
|
||||||
|
|
||||||
|
case (APPEND | BINARY):
|
||||||
|
return autoPtr<foamVtkFormatter>
|
||||||
|
(
|
||||||
|
new foamVtkAppendRawFormatter(os)
|
||||||
|
);
|
||||||
|
|
||||||
|
default: // ASCII (legacy or xml) must always work
|
||||||
|
return autoPtr<foamVtkFormatter>
|
||||||
|
(
|
||||||
|
new foamVtkAsciiFormatter(os, precision_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::foamVtkOutputOptions::ascii(bool b)
|
||||||
|
{
|
||||||
|
if (b)
|
||||||
|
{
|
||||||
|
// Force ASCII:
|
||||||
|
|
||||||
|
if (type_ & APPEND)
|
||||||
|
{
|
||||||
|
// Append: ascii = base64 (vs raw binary)
|
||||||
|
type_ = (APPEND | BASE64);
|
||||||
|
}
|
||||||
|
else if (type_ & LEGACY)
|
||||||
|
{
|
||||||
|
// Legacy: ascii = ascii
|
||||||
|
type_ = (LEGACY | ASCII);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// XML: ascii = ascii
|
||||||
|
type_ = ASCII;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Non-ASCII:
|
||||||
|
|
||||||
|
if (type_ & APPEND)
|
||||||
|
{
|
||||||
|
// Append: binary == (raw) binary
|
||||||
|
type_ = APPEND | BINARY;
|
||||||
|
}
|
||||||
|
else if (type_ & LEGACY)
|
||||||
|
{
|
||||||
|
// Legacy: binary = binary
|
||||||
|
type_ = LEGACY | BINARY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// XML: binary == (inline) binary == base64
|
||||||
|
type_ = BASE64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkOutputOptions::append(bool b)
|
||||||
|
{
|
||||||
|
if (b)
|
||||||
|
{
|
||||||
|
if (!(type_ & APPEND))
|
||||||
|
{
|
||||||
|
// XML: base64 -> raw binary, ascii -> base64
|
||||||
|
// Legacy: binary -> raw binary, ascii -> base64
|
||||||
|
type_ = APPEND | ((type_ & (BASE64 | BINARY)) ? BINARY : BASE64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type_ & APPEND)
|
||||||
|
{
|
||||||
|
// Only revert back to inline XML base64 versions
|
||||||
|
// ASCII needs another step.
|
||||||
|
|
||||||
|
type_ = BASE64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkOutputOptions::legacy(bool b)
|
||||||
|
{
|
||||||
|
if (b)
|
||||||
|
{
|
||||||
|
if (type_ & APPEND)
|
||||||
|
{
|
||||||
|
// Append: base64 -> ascii, binary -> binary
|
||||||
|
type_ = (LEGACY | ((type_ & BINARY) ? BINARY : ASCII));
|
||||||
|
}
|
||||||
|
else if (type_ & LEGACY)
|
||||||
|
{
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// XML: ascii -> ascii, base64 -> binary
|
||||||
|
type_ = (LEGACY | ((type_ & BASE64) ? BINARY : ASCII));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type_ & LEGACY)
|
||||||
|
{
|
||||||
|
// Legacy: ascii -> xml ascii, binary -> xml base64
|
||||||
|
type_ = (type_ & BINARY) ? BASE64 : ASCII;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::foamVtkOutputOptions::precision(unsigned val) const
|
||||||
|
{
|
||||||
|
precision_ = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Ostream&
|
||||||
|
Foam::foamVtkOutputOptions::info(Ostream& os) const
|
||||||
|
{
|
||||||
|
os << "type: " << type_;
|
||||||
|
|
||||||
|
switch (type_)
|
||||||
|
{
|
||||||
|
case (LEGACY | ASCII):
|
||||||
|
os << " legacy ascii";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (LEGACY | BINARY):
|
||||||
|
os << " legacy binary";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BASE64:
|
||||||
|
os << " xml insitu base64";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (APPEND | BASE64):
|
||||||
|
os << " xml-append base64";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (APPEND | BINARY):
|
||||||
|
os << " xml-append binary";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ASCII:
|
||||||
|
os << " xml insitu ascii";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BINARY:
|
||||||
|
os << " xml insitu binary - WRONG";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
os << " unknown";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (legacy()) os << " legacy";
|
||||||
|
if (xml()) os << " xml";
|
||||||
|
if (append()) os << " append";
|
||||||
|
if (ascii()) os << " ascii";
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
156
src/fileFormats/vtk/format/foamVtkOutputOptions.H
Normal file
156
src/fileFormats/vtk/format/foamVtkOutputOptions.H
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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
|
||||||
|
foamVtkOutputOptions
|
||||||
|
|
||||||
|
Description
|
||||||
|
Encapsulate combinations of output format options.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkOutputOptions.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkOutputOptions_H
|
||||||
|
#define foamVtkOutputOptions_H
|
||||||
|
|
||||||
|
#include "autoPtr.H"
|
||||||
|
#include "foamVtkFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
class Ostream;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkOutputOptions Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class foamVtkOutputOptions
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- The supported output/format types
|
||||||
|
enum foamVtkOptionTypes
|
||||||
|
{
|
||||||
|
ASCII = 0x0000, //!< ASCII formatting for data
|
||||||
|
BINARY = 0x0001, //!< Raw binary formatting for data
|
||||||
|
BASE64 = 0x0002, //!< Base64 encoding for data
|
||||||
|
LEGACY = 0x0100, //!< Legacy vtk file format
|
||||||
|
APPEND = 0x0200 //!< XML append format
|
||||||
|
};
|
||||||
|
|
||||||
|
//- The output style tuning
|
||||||
|
enum foamVtkStyleOptions
|
||||||
|
{
|
||||||
|
NONE = 0x0000, //!< Normal
|
||||||
|
HEADER = 0x0001 //!< Emit xml header
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//- The output format type
|
||||||
|
unsigned short type_;
|
||||||
|
|
||||||
|
//- The output style tuning
|
||||||
|
unsigned short style_;
|
||||||
|
|
||||||
|
|
||||||
|
//- ASCII write precision
|
||||||
|
mutable unsigned precision_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null - XML insitu ASCII format with default precision
|
||||||
|
foamVtkOutputOptions();
|
||||||
|
|
||||||
|
|
||||||
|
// Selectors
|
||||||
|
|
||||||
|
//- Return new data formatter based on the writer options
|
||||||
|
autoPtr<foamVtkFormatter> newFormatter(std::ostream&) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- True if writer uses legacy file format
|
||||||
|
inline bool legacy() const;
|
||||||
|
|
||||||
|
//- True if writer uses XML file format (non-legacy)
|
||||||
|
inline bool xml() const;
|
||||||
|
|
||||||
|
//- True if output format uses an append mode
|
||||||
|
inline bool append() const;
|
||||||
|
|
||||||
|
//- True if output format does not use an append mode
|
||||||
|
inline bool insitu() const;
|
||||||
|
|
||||||
|
//- True if output format is ASCII
|
||||||
|
inline bool ascii() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Toggle ASCII mode on/off.
|
||||||
|
// In append mode, this switches between base64 and raw binary.
|
||||||
|
// In XML mode, this switches between ASCII and base64.
|
||||||
|
// In legacy mode, this switches between ASCII and binary.
|
||||||
|
void ascii(bool);
|
||||||
|
|
||||||
|
//- Toggle append mode on/off.
|
||||||
|
void append(bool);
|
||||||
|
|
||||||
|
//- Toggle legacy mode on/off.
|
||||||
|
void legacy(bool);
|
||||||
|
|
||||||
|
//- Set the write precision to be used for new ASCII formatters
|
||||||
|
void precision(unsigned val) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Other
|
||||||
|
|
||||||
|
//- Report information about the options
|
||||||
|
Ostream& info(Ostream&) const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "foamVtkOutputOptionsI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
56
src/fileFormats/vtk/format/foamVtkOutputOptionsI.H
Normal file
56
src/fileFormats/vtk/format/foamVtkOutputOptionsI.H
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutputOptions::legacy() const
|
||||||
|
{
|
||||||
|
return (type_ & LEGACY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutputOptions::xml() const
|
||||||
|
{
|
||||||
|
return !legacy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutputOptions::append() const
|
||||||
|
{
|
||||||
|
return (type_ & APPEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutputOptions::insitu() const
|
||||||
|
{
|
||||||
|
return !(type_ & APPEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutputOptions::ascii() const
|
||||||
|
{
|
||||||
|
return !(type_ & (BINARY | BASE64));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -136,7 +136,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
{
|
{
|
||||||
switch (cellTypes[i])
|
switch (cellTypes[i])
|
||||||
{
|
{
|
||||||
case VTK_VERTEX:
|
case foamVtkCore::VTK_VERTEX:
|
||||||
{
|
{
|
||||||
warnUnhandledType(inFile, cellTypes[i], warningGiven);
|
warnUnhandledType(inFile, cellTypes[i], warningGiven);
|
||||||
label nRead = cellVertData[dataIndex++];
|
label nRead = cellVertData[dataIndex++];
|
||||||
@ -152,7 +152,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_POLY_VERTEX:
|
case foamVtkCore::VTK_POLY_VERTEX:
|
||||||
{
|
{
|
||||||
warnUnhandledType(inFile, cellTypes[i], warningGiven);
|
warnUnhandledType(inFile, cellTypes[i], warningGiven);
|
||||||
label nRead = cellVertData[dataIndex++];
|
label nRead = cellVertData[dataIndex++];
|
||||||
@ -160,7 +160,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_LINE:
|
case foamVtkCore::VTK_LINE:
|
||||||
{
|
{
|
||||||
//warnUnhandledType(inFile, cellTypes[i], warningGiven);
|
//warnUnhandledType(inFile, cellTypes[i], warningGiven);
|
||||||
label nRead = cellVertData[dataIndex++];
|
label nRead = cellVertData[dataIndex++];
|
||||||
@ -180,7 +180,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_POLY_LINE:
|
case foamVtkCore::VTK_POLY_LINE:
|
||||||
{
|
{
|
||||||
//warnUnhandledType(inFile, cellTypes[i], warningGiven);
|
//warnUnhandledType(inFile, cellTypes[i], warningGiven);
|
||||||
label nRead = cellVertData[dataIndex++];
|
label nRead = cellVertData[dataIndex++];
|
||||||
@ -194,7 +194,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_TRIANGLE:
|
case foamVtkCore::VTK_TRIANGLE:
|
||||||
{
|
{
|
||||||
faceMap_[facei] = i;
|
faceMap_[facei] = i;
|
||||||
face& f = faces_[facei++];
|
face& f = faces_[facei++];
|
||||||
@ -214,7 +214,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_QUAD:
|
case foamVtkCore::VTK_QUAD:
|
||||||
{
|
{
|
||||||
faceMap_[facei] = i;
|
faceMap_[facei] = i;
|
||||||
face& f = faces_[facei++];
|
face& f = faces_[facei++];
|
||||||
@ -235,7 +235,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_POLYGON:
|
case foamVtkCore::VTK_POLYGON:
|
||||||
{
|
{
|
||||||
faceMap_[facei] = i;
|
faceMap_[facei] = i;
|
||||||
face& f = faces_[facei++];
|
face& f = faces_[facei++];
|
||||||
@ -248,7 +248,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_TETRA:
|
case foamVtkCore::VTK_TETRA:
|
||||||
{
|
{
|
||||||
label nRead = cellVertData[dataIndex++];
|
label nRead = cellVertData[dataIndex++];
|
||||||
if (nRead != 4)
|
if (nRead != 4)
|
||||||
@ -268,7 +268,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_PYRAMID:
|
case foamVtkCore::VTK_PYRAMID:
|
||||||
{
|
{
|
||||||
label nRead = cellVertData[dataIndex++];
|
label nRead = cellVertData[dataIndex++];
|
||||||
if (nRead != 5)
|
if (nRead != 5)
|
||||||
@ -289,7 +289,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_WEDGE:
|
case foamVtkCore::VTK_WEDGE:
|
||||||
{
|
{
|
||||||
label nRead = cellVertData[dataIndex++];
|
label nRead = cellVertData[dataIndex++];
|
||||||
if (nRead != 6)
|
if (nRead != 6)
|
||||||
@ -311,7 +311,7 @@ void Foam::vtkUnstructuredReader::extractCells
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VTK_HEXAHEDRON:
|
case foamVtkCore::VTK_HEXAHEDRON:
|
||||||
{
|
{
|
||||||
label nRead = cellVertData[dataIndex++];
|
label nRead = cellVertData[dataIndex++];
|
||||||
if (nRead != 8)
|
if (nRead != 8)
|
||||||
@ -25,8 +25,8 @@ Class
|
|||||||
Foam::vtkUnstructuredReader
|
Foam::vtkUnstructuredReader
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Reader for vtk unstructured_grid legacy files. Supports single CELLS, POINTS
|
Reader for vtk UNSTRUCTURED_GRID legacy files.
|
||||||
etc. entry only.
|
Supports single CELLS, POINTS etc. entry only.
|
||||||
|
|
||||||
- all integer types (int, unsigned_int, long etc.) become Foam::label
|
- all integer types (int, unsigned_int, long etc.) become Foam::label
|
||||||
- all real types (float, double) become Foam::scalar
|
- all real types (float, double) become Foam::scalar
|
||||||
@ -47,6 +47,7 @@ SourceFiles
|
|||||||
#ifndef vtkUnstructuredReader_H
|
#ifndef vtkUnstructuredReader_H
|
||||||
#define vtkUnstructuredReader_H
|
#define vtkUnstructuredReader_H
|
||||||
|
|
||||||
|
#include "foamVtkCore.H"
|
||||||
#include "objectRegistry.H"
|
#include "objectRegistry.H"
|
||||||
#include "cellShapeList.H"
|
#include "cellShapeList.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
@ -62,6 +63,8 @@ namespace Foam
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class vtkUnstructuredReader
|
class vtkUnstructuredReader
|
||||||
|
:
|
||||||
|
public fileFormats::foamVtkCore
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -108,29 +111,6 @@ public:
|
|||||||
static const NamedEnum<parseMode, 5> parseModeNames;
|
static const NamedEnum<parseMode, 5> parseModeNames;
|
||||||
|
|
||||||
|
|
||||||
//- Enumeration defining the cell types
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//- Header
|
//- Header
|
||||||
@ -56,7 +56,7 @@ void Foam::vtkUnstructuredReader::printFieldStats
|
|||||||
{
|
{
|
||||||
wordList fieldNames(obj.names(Type::typeName));
|
wordList fieldNames(obj.names(Type::typeName));
|
||||||
|
|
||||||
if (fieldNames.size() > 0)
|
if (fieldNames.size())
|
||||||
{
|
{
|
||||||
Info<< "Read " << fieldNames.size() << " " << Type::typeName
|
Info<< "Read " << fieldNames.size() << " " << Type::typeName
|
||||||
<< " fields:" << endl;
|
<< " fields:" << endl;
|
||||||
70
src/fileFormats/vtk/type/foamVtkPTraits.C
Normal file
70
src/fileFormats/vtk/type/foamVtkPTraits.C
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "foamVtkPTraits.H"
|
||||||
|
#include "endian.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const
|
||||||
|
Foam::foamVtkPTraits<uint8_t>::typeName = "UInt8";
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char * const
|
||||||
|
Foam::foamVtkPTraits<int32_t>::typeName = "Int32";
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char * const
|
||||||
|
Foam::foamVtkPTraits<uint32_t>::typeName = "UInt32";
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char * const
|
||||||
|
Foam::foamVtkPTraits<int64_t>::typeName = "Int64";
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char * const
|
||||||
|
Foam::foamVtkPTraits<uint64_t>::typeName = "UInt64";
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char * const
|
||||||
|
Foam::foamVtkPTraits<float>::typeName = "Float32";
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char * const
|
||||||
|
Foam::foamVtkPTraits<double>::typeName = "Float64";
|
||||||
|
|
||||||
|
#ifdef WM_LITTLE_ENDIAN
|
||||||
|
template<>
|
||||||
|
const char* const
|
||||||
|
Foam::foamVtkPTraits<::Foam::endian>::typeName = "LittleEndian";
|
||||||
|
#else
|
||||||
|
template<>
|
||||||
|
const char* const
|
||||||
|
Foam::foamVtkPTraits<::Foam::endian>::typeName = "BigEndian";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
93
src/fileFormats/vtk/type/foamVtkPTraits.H
Normal file
93
src/fileFormats/vtk/type/foamVtkPTraits.H
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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::foamVtkPTraits
|
||||||
|
|
||||||
|
Description
|
||||||
|
Names for VTK primitive types.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkPTraits_H
|
||||||
|
#define foamVtkPTraits_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class endian;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class foamVtkPTraits Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class PrimitiveType>
|
||||||
|
class foamVtkPTraits
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Static data members
|
||||||
|
|
||||||
|
static const char* const typeName;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const foamVtkPTraits<uint8_t>::typeName; // = UInt8
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const foamVtkPTraits<int32_t>::typeName; // = Int32
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const foamVtkPTraits<int32_t>::typeName; // = UInt32
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const foamVtkPTraits<int32_t>::typeName; // = Int64
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const foamVtkPTraits<int64_t>::typeName; // = UInt64
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const foamVtkPTraits<float>::typeName; // = Float32
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const foamVtkPTraits<double>::typeName; // = Float64
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* const foamVtkPTraits<::Foam::endian>::typeName;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user