mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support enumerations for vtk xml file tags and some legacy text elements
This commit is contained in:
@ -26,6 +26,7 @@ vtk/format/foamVtkLegacyRawFormatter.C
|
||||
vtk/output/foamVtkOutput.C
|
||||
vtk/output/foamVtkOutputOptions.C
|
||||
vtk/read/vtkUnstructuredReader.C
|
||||
vtk/type/foamVtkFileEnums.C
|
||||
vtk/type/foamVtkPTraits.C
|
||||
|
||||
coordSet/coordSet.C
|
||||
|
||||
@ -24,16 +24,6 @@ License
|
||||
|
||||
#include "foamVtkFormatter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkOutput::formatter::formatter(std::ostream& os)
|
||||
:
|
||||
os_(os),
|
||||
xmlTags_(),
|
||||
inTag_(false)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkOutput::formatter::~formatter()
|
||||
@ -92,19 +82,20 @@ Foam::foamVtkOutput::formatter::comment(const std::string& text)
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::openTag(const word& tag)
|
||||
Foam::foamVtkOutput::formatter::openTag(const word& tagName)
|
||||
{
|
||||
if (inTag_)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "open XML tag '" << tag << "', but already within a tag!"
|
||||
<< "open XML tag '" << tagName
|
||||
<< "', but already within a tag!"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
indent();
|
||||
os_ << '<' << tag;
|
||||
os_ << '<' << tagName;
|
||||
|
||||
xmlTags_.push(tag);
|
||||
xmlTags_.push(tagName);
|
||||
inTag_ = true;
|
||||
|
||||
return *this;
|
||||
@ -136,7 +127,7 @@ Foam::foamVtkOutput::formatter::closeTag(const bool isEmpty)
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::endTag(const word& tag)
|
||||
Foam::foamVtkOutput::formatter::endTag(const word& tagName)
|
||||
{
|
||||
const word curr = xmlTags_.pop();
|
||||
indent();
|
||||
@ -150,10 +141,10 @@ Foam::foamVtkOutput::formatter::endTag(const word& tag)
|
||||
}
|
||||
|
||||
// verify inTag_
|
||||
if (!tag.empty() && tag != curr)
|
||||
if (!tagName.empty() && tagName != curr)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "expected to end xml-tag '" << tag
|
||||
<< "expected to end xml-tag '" << tagName
|
||||
<< "' but found '" << curr << "' instead"
|
||||
<< endl;
|
||||
}
|
||||
@ -166,16 +157,6 @@ Foam::foamVtkOutput::formatter::endTag(const word& tag)
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::tag(const word& tag)
|
||||
{
|
||||
openTag(tag);
|
||||
closeTag();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::beginVTKFile
|
||||
(
|
||||
@ -184,7 +165,7 @@ Foam::foamVtkOutput::formatter::beginVTKFile
|
||||
const bool leaveOpen
|
||||
)
|
||||
{
|
||||
openTag("VTKFile");
|
||||
openTag(vtkFileTag::VTK_FILE);
|
||||
xmlAttr("type", contentType);
|
||||
xmlAttr("version", contentVersion);
|
||||
xmlAttr("byte_order", foamVtkPTraits<Foam::endian>::typeName);
|
||||
@ -234,89 +215,4 @@ Foam::foamVtkOutput::formatter::xmlAttr
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int32_t v,
|
||||
const char quote
|
||||
)
|
||||
{
|
||||
return xmlAttribute(k, v, quote);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int64_t v,
|
||||
const char quote
|
||||
)
|
||||
{
|
||||
return xmlAttribute(k, v, quote);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const uint64_t v,
|
||||
const char quote
|
||||
)
|
||||
{
|
||||
return xmlAttribute(k, v, quote);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const scalar v,
|
||||
const char quote
|
||||
)
|
||||
{
|
||||
return xmlAttribute(k, v, quote);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const std::string& v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const int32_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const int64_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const uint64_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const scalar v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -44,6 +44,7 @@ SourceFiles
|
||||
#include "word.H"
|
||||
#include "UList.H"
|
||||
#include "LIFOStack.H"
|
||||
#include "foamVtkFileEnums.H"
|
||||
#include "foamVtkPTraits.H"
|
||||
#include "foamVtkOutputTypes.H"
|
||||
|
||||
@ -89,7 +90,7 @@ protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
formatter(std::ostream& os);
|
||||
inline formatter(std::ostream& os);
|
||||
|
||||
public:
|
||||
|
||||
@ -108,11 +109,7 @@ public:
|
||||
// Access
|
||||
|
||||
//- Access to the underlying output stream
|
||||
inline std::ostream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
inline std::ostream& os();
|
||||
|
||||
//- The output formatType.
|
||||
virtual enum formatType format() const = 0;
|
||||
@ -158,7 +155,11 @@ public:
|
||||
|
||||
//- Open XML tag
|
||||
// \return formatter for chaining
|
||||
formatter& openTag(const word& tag);
|
||||
formatter& openTag(const word& tagName);
|
||||
|
||||
//- Open XML tag
|
||||
// \return formatter for chaining
|
||||
inline formatter& openTag(const vtkFileTag& tagEnum);
|
||||
|
||||
//- Close XML tag, optional as an empty container.
|
||||
// Always adds a trailing newline.
|
||||
@ -168,11 +169,20 @@ public:
|
||||
//- End XML tag, optional with sanity check
|
||||
// Always adds a trailing newline.
|
||||
// \return formatter for chaining
|
||||
formatter& endTag(const word& tag = word::null);
|
||||
formatter& endTag(const word& tagName = word::null);
|
||||
|
||||
//- End XML tag with sanity check
|
||||
// Always adds a trailing newline.
|
||||
// \return formatter for chaining
|
||||
inline formatter& endTag(const vtkFileTag& tagEnum);
|
||||
|
||||
//- Write XML tag without any attributes. Combines openTag/closeTag.
|
||||
// \return formatter for chaining
|
||||
formatter& tag(const word& tag);
|
||||
inline formatter& tag(const word& tagName);
|
||||
|
||||
//- Write XML tag without any attributes. Combines openTag/closeTag.
|
||||
// \return formatter for chaining
|
||||
inline formatter& tag(const vtkFileTag& tagEnum);
|
||||
|
||||
//- Add a "VTKFile" XML tag for contentType, followed by a tag for
|
||||
// the contentType itself. Optionally leave the contentType tag
|
||||
@ -206,26 +216,15 @@ public:
|
||||
|
||||
//- End "DataArray" XML tag
|
||||
// \return formatter for chaining
|
||||
inline formatter& endDataArray()
|
||||
{
|
||||
return endTag("DataArray");
|
||||
}
|
||||
inline formatter& endDataArray();
|
||||
|
||||
//- End "AppendedData" XML tag
|
||||
// \return formatter for chaining
|
||||
inline formatter& endAppendedData()
|
||||
{
|
||||
flush(); // flush any pending encoded content
|
||||
os_ << '\n'; // clear separation from content.
|
||||
return endTag("AppendedData");
|
||||
}
|
||||
inline formatter& endAppendedData();
|
||||
|
||||
//- End "VTKFile" XML tag
|
||||
// \return formatter for chaining
|
||||
inline formatter& endVTKFile()
|
||||
{
|
||||
return endTag("VTKFile");
|
||||
}
|
||||
inline formatter& endVTKFile();
|
||||
|
||||
|
||||
//- Write XML attribute
|
||||
@ -239,7 +238,7 @@ public:
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
inline formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int32_t v,
|
||||
@ -248,7 +247,7 @@ public:
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
inline formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int64_t v,
|
||||
@ -257,7 +256,7 @@ public:
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
inline formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const uint64_t v,
|
||||
@ -266,7 +265,7 @@ public:
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
inline formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const scalar v,
|
||||
@ -278,23 +277,23 @@ public:
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const std::string& v);
|
||||
inline formatter& operator()(const word& k, const std::string& v);
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const int32_t v);
|
||||
inline formatter& operator()(const word& k, const int32_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const int64_t v);
|
||||
inline formatter& operator()(const word& k, const int64_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const uint64_t v);
|
||||
inline formatter& operator()(const word& k, const uint64_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const scalar v);
|
||||
inline formatter& operator()(const word& k, const scalar v);
|
||||
|
||||
};
|
||||
|
||||
@ -306,6 +305,8 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "foamVtkFormatterI.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "foamVtkFormatterTemplates.C"
|
||||
#endif
|
||||
|
||||
183
src/fileFormats/vtk/format/foamVtkFormatterI.H
Normal file
183
src/fileFormats/vtk/format/foamVtkFormatterI.H
Normal file
@ -0,0 +1,183 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::foamVtkOutput::formatter::formatter(std::ostream& os)
|
||||
:
|
||||
os_(os),
|
||||
xmlTags_(),
|
||||
inTag_(false)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline std::ostream& Foam::foamVtkOutput::formatter::os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::openTag(const vtkFileTag& tagEnum)
|
||||
{
|
||||
return openTag(vtkFileTagNames[tagEnum]);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::endTag(const vtkFileTag& tagEnum)
|
||||
{
|
||||
return endTag(vtkFileTagNames[tagEnum]);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::tag(const word& tagName)
|
||||
{
|
||||
openTag(tagName);
|
||||
closeTag();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::tag(const vtkFileTag& tagEnum)
|
||||
{
|
||||
return tag(vtkFileTagNames[tagEnum]);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::endDataArray()
|
||||
{
|
||||
return endTag("DataArray");
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::endAppendedData()
|
||||
{
|
||||
flush(); // flush any pending encoded content
|
||||
os_ << '\n'; // clear separation from content.
|
||||
return endTag("AppendedData");
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::endVTKFile()
|
||||
{
|
||||
return endTag(vtkFileTag::VTK_FILE);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int32_t v,
|
||||
const char quote
|
||||
)
|
||||
{
|
||||
return xmlAttribute(k, v, quote);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int64_t v,
|
||||
const char quote
|
||||
)
|
||||
{
|
||||
return xmlAttribute(k, v, quote);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const uint64_t v,
|
||||
const char quote
|
||||
)
|
||||
{
|
||||
return xmlAttribute(k, v, quote);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const scalar v,
|
||||
const char quote
|
||||
)
|
||||
{
|
||||
return xmlAttribute(k, v, quote);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const std::string& v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const int32_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const int64_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const uint64_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const scalar v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -36,7 +36,24 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Static Data * * * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word Foam::foamVtkOutput::legacy::EXT = "vtk";
|
||||
const Foam::Enum<Foam::foamVtkOutput::legacy::textElemType>
|
||||
Foam::foamVtkOutput::legacy::textNames
|
||||
{
|
||||
{ textElemType::POINTS, "POINTS" },
|
||||
{ textElemType::CELLS, "CELLS" },
|
||||
{ textElemType::POLYS, "POLYGONS" },
|
||||
{ textElemType::VERTS, "VERTICES" },
|
||||
{ textElemType::POLY_DATA, "POLYDATA" },
|
||||
{ textElemType::UNSTRUCTURED_GRID, "UNSTRUCTURED_GRID" },
|
||||
};
|
||||
|
||||
|
||||
const Foam::Enum<Foam::vtkFileTag>
|
||||
Foam::foamVtkOutput::legacy::dataTypeNames
|
||||
{
|
||||
{ vtkFileTag::CELL_DATA, "CELL_DATA" },
|
||||
{ vtkFileTag::POINT_DATA, "POINT_DATA" }
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||
@ -99,7 +116,7 @@ Foam::label Foam::foamVtkOutput::writeVtmFile
|
||||
forAll(files, i)
|
||||
{
|
||||
vtmFile
|
||||
.openTag("DataSet")
|
||||
.openTag(vtkFileTag::DATA_SET)
|
||||
( "index", i )
|
||||
( "file", files[i] )
|
||||
.closeTag(true);
|
||||
@ -136,31 +153,40 @@ std::ostream& Foam::foamVtkOutput::legacy::fileHeader
|
||||
}
|
||||
|
||||
|
||||
std::ostream& Foam::foamVtkOutput::legacy::cellDataHeader
|
||||
std::ostream& Foam::foamVtkOutput::legacy::dataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nCells,
|
||||
const vtkFileTag& dataTypeTag,
|
||||
const label nEntries,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
os << "CELL_DATA " << nCells << nl
|
||||
os << dataTypeNames[dataTypeTag] << ' ' << nEntries << nl
|
||||
<< "FIELD attributes " << nFields << nl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& Foam::foamVtkOutput::legacy::cellDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nEntries,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
return dataHeader(os, vtkFileTag::CELL_DATA, nEntries, nFields);
|
||||
}
|
||||
|
||||
|
||||
std::ostream& Foam::foamVtkOutput::legacy::pointDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nPoints,
|
||||
const label nEntries,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
os << "POINT_DATA " << nPoints << nl
|
||||
<< "FIELD attributes " << nFields << nl;
|
||||
|
||||
return os;
|
||||
return dataHeader(os, vtkFileTag::POINT_DATA, nEntries, nFields);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ SourceFiles
|
||||
#define foamVtkOutput_H
|
||||
|
||||
#include "autoPtr.H"
|
||||
#include "Enum.H"
|
||||
#include "foamVtkOutputTypes.H"
|
||||
#include "foamVtkFormatter.H"
|
||||
#include "floatScalar.H"
|
||||
@ -120,10 +121,22 @@ namespace foamVtkOutput
|
||||
//- Some minimal additional support for writing legacy files
|
||||
namespace legacy
|
||||
{
|
||||
// Constants
|
||||
//- Some standard text elements for legacy vtk files
|
||||
enum class textElemType
|
||||
{
|
||||
POINTS, //!< "POINTS"
|
||||
CELLS, //!< "CELLS"
|
||||
POLYS, //!< "POLYGONS"
|
||||
VERTS, //!< "VERTICES"
|
||||
POLY_DATA, //!< "POLYDATA"
|
||||
UNSTRUCTURED_GRID, //!< "UNSTRUCTURED_GRID"
|
||||
};
|
||||
|
||||
//- File extension for legacy files (vtk)
|
||||
extern const Foam::word EXT;
|
||||
//- Strings corresponding to the elements
|
||||
extern const Foam::Enum<textElemType> textNames;
|
||||
|
||||
//- Strings corresponding to the elements
|
||||
extern const Foam::Enum<vtkFileTag> dataTypeNames;
|
||||
|
||||
|
||||
// Functions
|
||||
@ -145,20 +158,34 @@ namespace legacy
|
||||
const std::string& title
|
||||
);
|
||||
|
||||
//- Emit header for legacy CELL_DATA
|
||||
std::ostream& cellDataHeader
|
||||
|
||||
//- Emit header for legacy CELL_DATA or POINT_DATA, corresponding to the
|
||||
// enumeration textElemType::CELLS or textElemType::POINTS, respectively.
|
||||
// The nEntries corresponds similarly to the number of cells or points,
|
||||
// respectively.
|
||||
std::ostream& dataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nCells,
|
||||
const vtkFileTag& dataTypeTag,
|
||||
const label nEntries,
|
||||
const label nFields
|
||||
);
|
||||
|
||||
//- Emit header for legacy CELL_DATA.
|
||||
// The nEntries should normally correspond to the number of cells.
|
||||
std::ostream& cellDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nEntries,
|
||||
const label nFields
|
||||
);
|
||||
|
||||
//- Emit header for legacy POINT_DATA
|
||||
// The nEntries should normally correspond to the number of points.
|
||||
std::ostream& pointDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nPoints,
|
||||
const label nEntries,
|
||||
const label nFields
|
||||
);
|
||||
|
||||
|
||||
64
src/fileFormats/vtk/type/foamVtkFileEnums.C
Normal file
64
src/fileFormats/vtk/type/foamVtkFileEnums.C
Normal file
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtkFileEnums.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::Enum<Foam::vtkFileTag> Foam::vtkFileTagNames
|
||||
(
|
||||
vtkFileTag::VTK_FILE,
|
||||
{
|
||||
"VTKFile",
|
||||
"DataArray",
|
||||
"Piece",
|
||||
"DataSet",
|
||||
"Points",
|
||||
"Cells",
|
||||
"Polys",
|
||||
"Verts",
|
||||
"CellData",
|
||||
"PointData",
|
||||
"PolyData",
|
||||
"UnstructuredGrid",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
const Foam::Enum<Foam::vtkFileAttr> Foam::vtkFileAttrNames
|
||||
(
|
||||
vtkFileAttr::OFFSET,
|
||||
{
|
||||
"offset",
|
||||
"NumberOfPoints",
|
||||
"NumberOfCells",
|
||||
"NumberOfPolys",
|
||||
"NumberOfVerts"
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
90
src/fileFormats/vtk/type/foamVtkFileEnums.H
Normal file
90
src/fileFormats/vtk/type/foamVtkFileEnums.H
Normal file
@ -0,0 +1,90 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InNamespace
|
||||
Foam::foam
|
||||
|
||||
Description
|
||||
Enumerations for commonly used VTK file items.
|
||||
|
||||
SourceFiles
|
||||
foamVtkFileEnums.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkFileEnums_H
|
||||
#define foamVtkFileEnums_H
|
||||
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Some common XML tags for vtk files
|
||||
enum class vtkFileTag
|
||||
{
|
||||
VTK_FILE, //!< "VTKFile"
|
||||
DATA_ARRAY, //!< "DataArray"
|
||||
PIECE, //!< "Piece"
|
||||
DATA_SET, //!< "DataSet"
|
||||
POINTS, //!< "Points"
|
||||
CELLS, //!< "Cells"
|
||||
POLYS, //!< "Polys"
|
||||
VERTS, //!< "Verts"
|
||||
CELL_DATA, //!< "CellData"
|
||||
POINT_DATA, //!< "PointData"
|
||||
POLY_DATA, //!< "PolyData"
|
||||
UNSTRUCTURED_GRID, //!< "UnstructuredGrid"
|
||||
};
|
||||
|
||||
//- Strings corresponding to the elements
|
||||
extern const Foam::Enum<vtkFileTag> vtkFileTagNames;
|
||||
|
||||
|
||||
//- Some common XML attributes for vtk files
|
||||
enum class vtkFileAttr
|
||||
{
|
||||
OFFSET, //!< "offset"
|
||||
NUMBER_OF_POINTS, //!< "NumberOfPoints"
|
||||
NUMBER_OF_CELLS, //!< "NumberOfCells"
|
||||
NUMBER_OF_POLYS, //!< "NumberOfPolys"
|
||||
NUMBER_OF_VERTS, //!< "NumberOfVerts"
|
||||
};
|
||||
|
||||
//- Strings corresponding to the elements
|
||||
extern const Foam::Enum<vtkFileAttr> vtkFileAttrNames;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user