mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: rationalize VTK output classes and structures
- relocated to dedicated foamVtkOutput namespace. Make it easier to obtain a formatter directly without a foamVtkOutput::outputOptions. Make the logic clear within outputOptions (avoid previous, cryptic bit masking). foamVtkOutput::legacy also becomes a namespace instead of a class. Relocate commonly used things into src/fileFormats, leave volField-related parts in src/conversion.
This commit is contained in:
@ -15,14 +15,16 @@ stl/STLReader.C
|
||||
stl/STLReaderASCII.L
|
||||
|
||||
vtk/foamVtkCore.C
|
||||
vtk/format/foamVtkAppendBase64Formatter.C
|
||||
vtk/format/foamVtkAppendRawFormatter.C
|
||||
vtk/format/foamVtkFormatter.C
|
||||
vtk/format/foamVtkAsciiFormatter.C
|
||||
vtk/format/foamVtkBase64Formatter.C
|
||||
vtk/format/foamVtkAppendBase64Formatter.C
|
||||
vtk/format/foamVtkAppendRawFormatter.C
|
||||
vtk/format/foamVtkBase64Layer.C
|
||||
vtk/format/foamVtkLegacyFormatter.C
|
||||
vtk/format/foamVtkFormatter.C
|
||||
vtk/format/foamVtkOutputOptions.C
|
||||
vtk/format/foamVtkLegacyAsciiFormatter.C
|
||||
vtk/format/foamVtkLegacyRawFormatter.C
|
||||
vtk/output/foamVtkOutput.C
|
||||
vtk/output/foamVtkOutputOptions.C
|
||||
vtk/read/vtkUnstructuredReader.C
|
||||
vtk/type/foamVtkPTraits.C
|
||||
|
||||
|
||||
@ -27,12 +27,12 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkAppendBase64Formatter::name_ = "append";
|
||||
const char* Foam::foamVtkOutput::appendBase64Formatter::name_ = "append";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkAppendBase64Formatter::foamVtkAppendBase64Formatter
|
||||
Foam::foamVtkOutput::appendBase64Formatter::appendBase64Formatter
|
||||
(
|
||||
std::ostream& os
|
||||
)
|
||||
@ -43,7 +43,7 @@ Foam::foamVtkAppendBase64Formatter::foamVtkAppendBase64Formatter
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkAppendBase64Formatter::~foamVtkAppendBase64Formatter()
|
||||
Foam::foamVtkOutput::appendBase64Formatter::~appendBase64Formatter()
|
||||
{
|
||||
base64Layer::close();
|
||||
}
|
||||
@ -51,7 +51,7 @@ Foam::foamVtkAppendBase64Formatter::~foamVtkAppendBase64Formatter()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkAppendBase64Formatter::name() const
|
||||
const char* Foam::foamVtkOutput::appendBase64Formatter::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
foamVtkAppendBase64Formatter
|
||||
Foam::foamVtkOutput::appendBase64Formatter
|
||||
|
||||
Description
|
||||
Appended base-64 encoded binary output.
|
||||
@ -42,12 +42,14 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkAppendBase64Formatter Declaration
|
||||
Class appendBase64Formatter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkAppendBase64Formatter
|
||||
class appendBase64Formatter
|
||||
:
|
||||
public foamVtkBase64Layer
|
||||
{
|
||||
@ -59,10 +61,10 @@ class foamVtkAppendBase64Formatter
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamVtkAppendBase64Formatter(const foamVtkAppendBase64Formatter&) = delete;
|
||||
appendBase64Formatter(const appendBase64Formatter&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamVtkAppendBase64Formatter&) = delete;
|
||||
void operator=(const appendBase64Formatter&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -70,15 +72,21 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkAppendBase64Formatter(std::ostream& os);
|
||||
appendBase64Formatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~foamVtkAppendBase64Formatter();
|
||||
virtual ~appendBase64Formatter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The output formatType is APPEND_BASE64.
|
||||
virtual enum formatType format() const
|
||||
{
|
||||
return formatType::APPEND_BASE64;
|
||||
}
|
||||
|
||||
//- Output name for XML type ("append")
|
||||
virtual const char* name() const;
|
||||
|
||||
@ -86,6 +94,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,13 +27,13 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkAppendRawFormatter::name_ = "append";
|
||||
const char* Foam::foamVtkAppendRawFormatter::encoding_ = "raw";
|
||||
const char* Foam::foamVtkOutput::appendRawFormatter::name_ = "append";
|
||||
const char* Foam::foamVtkOutput::appendRawFormatter::encoding_ = "raw";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::write
|
||||
void Foam::foamVtkOutput::appendRawFormatter::write
|
||||
(
|
||||
const char* s,
|
||||
std::streamsize n
|
||||
@ -45,59 +45,59 @@ void Foam::foamVtkAppendRawFormatter::write
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkAppendRawFormatter::foamVtkAppendRawFormatter(std::ostream& os)
|
||||
Foam::foamVtkOutput::appendRawFormatter::appendRawFormatter(std::ostream& os)
|
||||
:
|
||||
foamVtkFormatter(os)
|
||||
formatter(os)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkAppendRawFormatter::~foamVtkAppendRawFormatter()
|
||||
Foam::foamVtkOutput::appendRawFormatter::~appendRawFormatter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkAppendRawFormatter::name() const
|
||||
const char* Foam::foamVtkOutput::appendRawFormatter::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
const char* Foam::foamVtkAppendRawFormatter::encoding() const
|
||||
const char* Foam::foamVtkOutput::appendRawFormatter::encoding() const
|
||||
{
|
||||
return encoding_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t nBytes)
|
||||
void Foam::foamVtkOutput::appendRawFormatter::writeSize(const uint64_t nBytes)
|
||||
{
|
||||
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::write(const uint8_t val)
|
||||
void Foam::foamVtkOutput::appendRawFormatter::write(const uint8_t val)
|
||||
{
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(uint8_t));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::write(const label val)
|
||||
void Foam::foamVtkOutput::appendRawFormatter::write(const label val)
|
||||
{
|
||||
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::write(const float val)
|
||||
void Foam::foamVtkOutput::appendRawFormatter::write(const float val)
|
||||
{
|
||||
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::write(const double val)
|
||||
void Foam::foamVtkOutput::appendRawFormatter::write(const double val)
|
||||
{
|
||||
// std::cerr<<"double as float=" << val << '\n';
|
||||
float copy(val);
|
||||
@ -105,7 +105,7 @@ void Foam::foamVtkAppendRawFormatter::write(const double val)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::flush()
|
||||
void Foam::foamVtkOutput::appendRawFormatter::flush()
|
||||
{/*nop*/}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
foamVtkAppendRawFormatter
|
||||
Foam::foamVtkOutput::appendRawFormatter
|
||||
|
||||
Description
|
||||
Appended raw binary output.
|
||||
@ -41,14 +41,16 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkAppendRawFormatter Declaration
|
||||
Class appendRawFormatter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkAppendRawFormatter
|
||||
class appendRawFormatter
|
||||
:
|
||||
public foamVtkFormatter
|
||||
public formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -58,10 +60,10 @@ class foamVtkAppendRawFormatter
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamVtkAppendRawFormatter(const foamVtkAppendRawFormatter&) = delete;
|
||||
appendRawFormatter(const appendRawFormatter&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamVtkAppendRawFormatter&) = delete;
|
||||
void operator=(const appendRawFormatter&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
@ -77,15 +79,21 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkAppendRawFormatter(std::ostream& os);
|
||||
appendRawFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~foamVtkAppendRawFormatter();
|
||||
virtual ~appendRawFormatter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The output formatType is APPEND_BINARY.
|
||||
virtual enum formatType format() const
|
||||
{
|
||||
return formatType::APPEND_BINARY;
|
||||
}
|
||||
|
||||
//- Output name for XML type ("append")
|
||||
virtual const char* name() const;
|
||||
|
||||
@ -108,6 +116,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,12 +27,12 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkAsciiFormatter::name_ = "ascii";
|
||||
const char* Foam::foamVtkOutput::asciiFormatter::name_ = "ascii";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::foamVtkAsciiFormatter::next()
|
||||
inline void Foam::foamVtkOutput::asciiFormatter::next()
|
||||
{
|
||||
if (pos_ == 6)
|
||||
{
|
||||
@ -47,7 +47,7 @@ inline void Foam::foamVtkAsciiFormatter::next()
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::foamVtkAsciiFormatter::done()
|
||||
inline void Foam::foamVtkOutput::asciiFormatter::done()
|
||||
{
|
||||
if (pos_)
|
||||
{
|
||||
@ -59,20 +59,20 @@ inline void Foam::foamVtkAsciiFormatter::done()
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter(std::ostream& os)
|
||||
Foam::foamVtkOutput::asciiFormatter::asciiFormatter(std::ostream& os)
|
||||
:
|
||||
foamVtkFormatter(os),
|
||||
formatter(os),
|
||||
pos_(0)
|
||||
{}
|
||||
|
||||
|
||||
Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter
|
||||
Foam::foamVtkOutput::asciiFormatter::asciiFormatter
|
||||
(
|
||||
std::ostream& os,
|
||||
unsigned precision
|
||||
)
|
||||
:
|
||||
foamVtkFormatter(os),
|
||||
formatter(os),
|
||||
pos_(0)
|
||||
{
|
||||
os.precision(precision);
|
||||
@ -81,7 +81,7 @@ Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkAsciiFormatter::~foamVtkAsciiFormatter()
|
||||
Foam::foamVtkOutput::asciiFormatter::~asciiFormatter()
|
||||
{
|
||||
done();
|
||||
}
|
||||
@ -89,58 +89,58 @@ Foam::foamVtkAsciiFormatter::~foamVtkAsciiFormatter()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkAsciiFormatter::name() const
|
||||
const char* Foam::foamVtkOutput::asciiFormatter::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
const char* Foam::foamVtkAsciiFormatter::encoding() const
|
||||
const char* Foam::foamVtkOutput::asciiFormatter::encoding() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t ignored)
|
||||
void Foam::foamVtkOutput::asciiFormatter::writeSize(const uint64_t ignored)
|
||||
{/*nop*/}
|
||||
|
||||
|
||||
void Foam::foamVtkAsciiFormatter::write(const uint8_t val)
|
||||
void Foam::foamVtkOutput::asciiFormatter::write(const uint8_t val)
|
||||
{
|
||||
next();
|
||||
os()<< int(val);
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAsciiFormatter::write(const label val)
|
||||
void Foam::foamVtkOutput::asciiFormatter::write(const label val)
|
||||
{
|
||||
next();
|
||||
os()<< val;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAsciiFormatter::write(const float val)
|
||||
void Foam::foamVtkOutput::asciiFormatter::write(const float val)
|
||||
{
|
||||
next();
|
||||
os()<< val;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAsciiFormatter::write(const double val)
|
||||
void Foam::foamVtkOutput::asciiFormatter::write(const double val)
|
||||
{
|
||||
next();
|
||||
os()<< float(val);
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAsciiFormatter::flush()
|
||||
void Foam::foamVtkOutput::asciiFormatter::flush()
|
||||
{
|
||||
done();
|
||||
}
|
||||
|
||||
|
||||
std::size_t
|
||||
Foam::foamVtkAsciiFormatter::encodedLength(std::size_t ignored) const
|
||||
Foam::foamVtkOutput::asciiFormatter::encodedLength(std::size_t ignored) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -22,10 +22,10 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
foamVtkAsciiFormatter
|
||||
Foam::foamVtkOutput::asciiFormatter
|
||||
|
||||
Description
|
||||
Inline ASCII binary output.
|
||||
Inline ASCII output.
|
||||
Adds spaces between entries and a newline every 6 items
|
||||
(for consistency with what VTK itself outputs).
|
||||
|
||||
@ -43,14 +43,16 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkAsciiFormatter Declaration
|
||||
Class asciiFormatter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkAsciiFormatter
|
||||
class asciiFormatter
|
||||
:
|
||||
public foamVtkFormatter
|
||||
public formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -70,10 +72,10 @@ class foamVtkAsciiFormatter
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamVtkAsciiFormatter(const foamVtkAsciiFormatter&) = delete;
|
||||
asciiFormatter(const asciiFormatter&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamVtkAsciiFormatter&) = delete;
|
||||
void operator=(const asciiFormatter&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -81,20 +83,25 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream, use default precision
|
||||
foamVtkAsciiFormatter(std::ostream& os);
|
||||
asciiFormatter(std::ostream& os);
|
||||
|
||||
//- Construct and attach to an output stream, use specified precision
|
||||
foamVtkAsciiFormatter(std::ostream& os, unsigned precision);
|
||||
asciiFormatter(std::ostream& os, unsigned precision);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~foamVtkAsciiFormatter();
|
||||
virtual ~asciiFormatter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The output formatType is INLINE_ASCII.
|
||||
virtual enum formatType format() const
|
||||
{
|
||||
return formatType::INLINE_ASCII;
|
||||
}
|
||||
|
||||
//- 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.
|
||||
@ -120,6 +127,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,12 +27,12 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkBase64Formatter::name_ = "binary";
|
||||
const char* Foam::foamVtkOutput::base64Formatter::name_ = "binary";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
|
||||
Foam::foamVtkOutput::base64Formatter::base64Formatter(std::ostream& os)
|
||||
:
|
||||
foamVtkBase64Layer(os)
|
||||
{}
|
||||
@ -40,7 +40,7 @@ Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkBase64Formatter::~foamVtkBase64Formatter()
|
||||
Foam::foamVtkOutput::base64Formatter::~base64Formatter()
|
||||
{
|
||||
if (base64Layer::close())
|
||||
{
|
||||
@ -51,13 +51,13 @@ Foam::foamVtkBase64Formatter::~foamVtkBase64Formatter()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkBase64Formatter::name() const
|
||||
const char* Foam::foamVtkOutput::base64Formatter::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Formatter::flush()
|
||||
void Foam::foamVtkOutput::base64Formatter::flush()
|
||||
{
|
||||
if (base64Layer::close())
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
foamVtkBase64Formatter
|
||||
Foam::foamVtkOutput::base64Formatter
|
||||
|
||||
Description
|
||||
Inline base-64 encoded binary output.
|
||||
@ -39,12 +39,14 @@ Description
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkBase64Formatter Declaration
|
||||
Class base64Formatter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkBase64Formatter
|
||||
class base64Formatter
|
||||
:
|
||||
public foamVtkBase64Layer
|
||||
{
|
||||
@ -57,27 +59,32 @@ class foamVtkBase64Formatter
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamVtkBase64Formatter(const foamVtkBase64Formatter&) = delete;
|
||||
base64Formatter(const base64Formatter&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamVtkBase64Formatter&) = delete;
|
||||
void operator=(const base64Formatter&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkBase64Formatter(std::ostream& os);
|
||||
base64Formatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~foamVtkBase64Formatter();
|
||||
virtual ~base64Formatter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The output formatType is INLINE_BASE64.
|
||||
virtual enum formatType format() const
|
||||
{
|
||||
return formatType::INLINE_BASE64;
|
||||
}
|
||||
|
||||
//- Name for the XML output type ("binary")
|
||||
// The lowercase version of the Legacy output type.
|
||||
virtual const char* name() const;
|
||||
|
||||
|
||||
@ -89,6 +96,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,12 +27,12 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkBase64Layer::encoding_ = "base64";
|
||||
const char* Foam::foamVtkOutput::foamVtkBase64Layer::encoding_ = "base64";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkBase64Layer::write
|
||||
void Foam::foamVtkOutput::foamVtkBase64Layer::write
|
||||
(
|
||||
const char* s,
|
||||
std::streamsize n
|
||||
@ -44,16 +44,16 @@ void Foam::foamVtkBase64Layer::write
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
||||
Foam::foamVtkOutput::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
||||
:
|
||||
foamVtkFormatter(os),
|
||||
formatter(os),
|
||||
base64Layer(os)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkBase64Layer::~foamVtkBase64Layer()
|
||||
Foam::foamVtkOutput::foamVtkBase64Layer::~foamVtkBase64Layer()
|
||||
{
|
||||
base64Layer::close();
|
||||
}
|
||||
@ -61,39 +61,39 @@ Foam::foamVtkBase64Layer::~foamVtkBase64Layer()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkBase64Layer::encoding() const
|
||||
const char* Foam::foamVtkOutput::foamVtkBase64Layer::encoding() const
|
||||
{
|
||||
return encoding_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::writeSize(const uint64_t nBytes)
|
||||
void Foam::foamVtkOutput::foamVtkBase64Layer::writeSize(const uint64_t nBytes)
|
||||
{
|
||||
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::write(const uint8_t val)
|
||||
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const uint8_t val)
|
||||
{
|
||||
base64Layer::add(val);
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::write(const label val)
|
||||
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const label val)
|
||||
{
|
||||
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::write(const float val)
|
||||
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const float val)
|
||||
{
|
||||
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::write(const double val)
|
||||
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const double val)
|
||||
{
|
||||
// std::cerr<<"double as float=" << val << '\n';
|
||||
float copy(val);
|
||||
@ -101,13 +101,16 @@ void Foam::foamVtkBase64Layer::write(const double val)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::flush()
|
||||
void Foam::foamVtkOutput::foamVtkBase64Layer::flush()
|
||||
{
|
||||
base64Layer::close();
|
||||
}
|
||||
|
||||
|
||||
std::size_t Foam::foamVtkBase64Layer::encodedLength(std::size_t n) const
|
||||
std::size_t Foam::foamVtkOutput::foamVtkBase64Layer::encodedLength
|
||||
(
|
||||
std::size_t n
|
||||
) const
|
||||
{
|
||||
return base64Layer::encodedLength(n);
|
||||
}
|
||||
|
||||
@ -22,10 +22,10 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
foamVtkBase64Layer
|
||||
Foam::foamVtkOutput::foamVtkBase64Layer
|
||||
|
||||
Description
|
||||
Base-64 encoded output.
|
||||
Base-64 encoded output layer - normally only used indirectly by formatters.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -39,14 +39,16 @@ Description
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkBase64Layer Declaration
|
||||
Class foamVtkBase64Layer Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkBase64Layer
|
||||
:
|
||||
public foamVtkFormatter,
|
||||
public formatter,
|
||||
protected base64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
@ -105,6 +107,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkFormatter::foamVtkFormatter(std::ostream& os)
|
||||
Foam::foamVtkOutput::formatter::formatter(std::ostream& os)
|
||||
:
|
||||
os_(os),
|
||||
xmlTags_(),
|
||||
@ -36,19 +36,19 @@ Foam::foamVtkFormatter::foamVtkFormatter(std::ostream& os)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkFormatter::~foamVtkFormatter()
|
||||
Foam::foamVtkOutput::formatter::~formatter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
std::size_t Foam::foamVtkFormatter::encodedLength(std::size_t n) const
|
||||
std::size_t Foam::foamVtkOutput::formatter::encodedLength(std::size_t n) const
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkFormatter::indent()
|
||||
void Foam::foamVtkOutput::formatter::indent()
|
||||
{
|
||||
label n = xmlTags_.size() * 2;
|
||||
while (n--)
|
||||
@ -58,8 +58,8 @@ void Foam::foamVtkFormatter::indent()
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::xmlHeader()
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlHeader()
|
||||
{
|
||||
if (inTag_)
|
||||
{
|
||||
@ -74,8 +74,8 @@ Foam::foamVtkFormatter::xmlHeader()
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::comment(const std::string& text)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::comment(const std::string& text)
|
||||
{
|
||||
if (inTag_)
|
||||
{
|
||||
@ -91,8 +91,8 @@ Foam::foamVtkFormatter::comment(const std::string& text)
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::openTag(const word& tag)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::openTag(const word& tag)
|
||||
{
|
||||
if (inTag_)
|
||||
{
|
||||
@ -111,8 +111,8 @@ Foam::foamVtkFormatter::openTag(const word& tag)
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::closeTag(const bool isEmpty)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::closeTag(const bool isEmpty)
|
||||
{
|
||||
if (!inTag_)
|
||||
{
|
||||
@ -135,8 +135,8 @@ Foam::foamVtkFormatter::closeTag(const bool isEmpty)
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::endTag(const word& tag)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::endTag(const word& tag)
|
||||
{
|
||||
const word curr = xmlTags_.pop();
|
||||
indent();
|
||||
@ -166,8 +166,8 @@ Foam::foamVtkFormatter::endTag(const word& tag)
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::tag(const word& tag)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::tag(const word& tag)
|
||||
{
|
||||
openTag(tag);
|
||||
closeTag();
|
||||
@ -176,8 +176,8 @@ Foam::foamVtkFormatter::tag(const word& tag)
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::beginVTKFile
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::beginVTKFile
|
||||
(
|
||||
const word& contentType,
|
||||
const word& contentVersion,
|
||||
@ -201,8 +201,8 @@ Foam::foamVtkFormatter::beginVTKFile
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::beginAppendedData()
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::beginAppendedData()
|
||||
{
|
||||
openTag("AppendedData");
|
||||
xmlAttr("encoding", encoding());
|
||||
@ -213,8 +213,8 @@ Foam::foamVtkFormatter::beginAppendedData()
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::xmlAttr
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const std::string& v,
|
||||
@ -234,8 +234,8 @@ Foam::foamVtkFormatter::xmlAttr
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::xmlAttr
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int32_t v,
|
||||
@ -246,8 +246,8 @@ Foam::foamVtkFormatter::xmlAttr
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::xmlAttr
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int64_t v,
|
||||
@ -258,8 +258,8 @@ Foam::foamVtkFormatter::xmlAttr
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::xmlAttr
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const uint64_t v,
|
||||
@ -270,8 +270,8 @@ Foam::foamVtkFormatter::xmlAttr
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::xmlAttr
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const scalar v,
|
||||
@ -284,36 +284,36 @@ Foam::foamVtkFormatter::xmlAttr
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::operator()(const word& k, const std::string& v)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const std::string& v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::operator()(const word& k, const int32_t v)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const int32_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::operator()(const word& k, const int64_t v)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const int64_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::operator()(const word& k, const uint64_t v)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const uint64_t v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::operator()(const word& k, const scalar v)
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::operator()(const word& k, const scalar v)
|
||||
{
|
||||
return xmlAttr(k, v);
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
foamVtkFormatter
|
||||
Foam::foamVtkOutput::formatter
|
||||
|
||||
Description
|
||||
Abstract class for a VTK output stream formatter.
|
||||
@ -31,6 +31,7 @@ Description
|
||||
|
||||
SourceFiles
|
||||
foamVtkFormatter.C
|
||||
foamVtkFormatterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -44,6 +45,7 @@ SourceFiles
|
||||
#include "UList.H"
|
||||
#include "LIFOStack.H"
|
||||
#include "foamVtkPTraits.H"
|
||||
#include "foamVtkOutputTypes.H"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -51,12 +53,14 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkFormatter Declaration
|
||||
Class formatter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkFormatter
|
||||
class formatter
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -72,7 +76,7 @@ class foamVtkFormatter
|
||||
|
||||
//- Write XML attribute
|
||||
template<class Type>
|
||||
foamVtkFormatter& xmlAttribute
|
||||
formatter& xmlAttribute
|
||||
(
|
||||
const word& k,
|
||||
const Type& v,
|
||||
@ -85,7 +89,7 @@ protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkFormatter(std::ostream& os);
|
||||
formatter(std::ostream& os);
|
||||
|
||||
public:
|
||||
|
||||
@ -96,11 +100,13 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~foamVtkFormatter();
|
||||
virtual ~formatter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Access to the underlying output stream
|
||||
inline std::ostream& os()
|
||||
{
|
||||
@ -108,8 +114,10 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- Name for the XML output type.
|
||||
// Possibly the lowercase version of the Legacy output type
|
||||
//- The output formatType.
|
||||
virtual enum formatType format() const = 0;
|
||||
|
||||
//- Name for the XML output type or the legacy output type.
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
//- Name for the XML append encoding
|
||||
@ -134,64 +142,78 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Output
|
||||
|
||||
//- Indent according to the currently nested XML tags
|
||||
void indent();
|
||||
|
||||
//- Write XML header
|
||||
foamVtkFormatter& xmlHeader();
|
||||
// \return formatter for chaining
|
||||
formatter& xmlHeader();
|
||||
|
||||
//- Write XML comment (at the current indentation level)
|
||||
foamVtkFormatter& comment(const std::string& text);
|
||||
// \return formatter for chaining
|
||||
formatter& comment(const std::string& text);
|
||||
|
||||
|
||||
//- Open XML tag
|
||||
foamVtkFormatter& openTag(const word& tag);
|
||||
// \return formatter for chaining
|
||||
formatter& openTag(const word& tag);
|
||||
|
||||
//- Close XML tag, optional as an empty container.
|
||||
// Always adds a trailing newline.
|
||||
foamVtkFormatter& closeTag(const bool isEmpty = false);
|
||||
// \return formatter for chaining
|
||||
formatter& closeTag(const bool isEmpty = false);
|
||||
|
||||
//- End XML tag, optional with sanity check
|
||||
// Always adds a trailing newline.
|
||||
foamVtkFormatter& endTag(const word& tag = word::null);
|
||||
// \return formatter for chaining
|
||||
formatter& endTag(const word& tag = word::null);
|
||||
|
||||
//- Write XML tag without any attributes. Combines openTag/closeTag.
|
||||
foamVtkFormatter& tag(const word& tag);
|
||||
// \return formatter for chaining
|
||||
formatter& tag(const word& tag);
|
||||
|
||||
//- Add a "VTKFile" XML tag for contentType, followed by a tag for
|
||||
// the contentType itself. Optionally leave the contentType tag
|
||||
// open for adding additional attributes.
|
||||
foamVtkFormatter& beginVTKFile
|
||||
// \return formatter for chaining
|
||||
formatter& beginVTKFile
|
||||
(
|
||||
const word& contentType,
|
||||
const word& contentVersion,
|
||||
const bool leaveOpen = false
|
||||
);
|
||||
|
||||
//- Add a "AppendedData" XML tag with the current encoding and output
|
||||
//- Add a "AppendedData" XML tag with the current encoding and output
|
||||
// the requisite '_' prefix.
|
||||
foamVtkFormatter& beginAppendedData();
|
||||
// \return formatter for chaining
|
||||
formatter& beginAppendedData();
|
||||
|
||||
|
||||
//- Open "DataArray" XML tag
|
||||
// \return formatter for chaining
|
||||
template<class Type, int nComp=0>
|
||||
foamVtkFormatter& openDataArray(const word& dataName);
|
||||
formatter& openDataArray(const word& dataName);
|
||||
|
||||
|
||||
//- Insert a single "PDataArray" XML entry tag.
|
||||
// For some entries, the name is optional.
|
||||
// \return formatter for chaining
|
||||
template<class Type, int nComp=0>
|
||||
foamVtkFormatter& PDataArray(const word& dataName);
|
||||
formatter& PDataArray(const word& dataName);
|
||||
|
||||
|
||||
//- End "DataArray" XML tag
|
||||
inline foamVtkFormatter& endDataArray()
|
||||
// \return formatter for chaining
|
||||
inline formatter& endDataArray()
|
||||
{
|
||||
return endTag("DataArray");
|
||||
}
|
||||
|
||||
//- End "AppendedData" XML tag
|
||||
inline foamVtkFormatter& endAppendedData()
|
||||
// \return formatter for chaining
|
||||
inline formatter& endAppendedData()
|
||||
{
|
||||
flush(); // flush any pending encoded content
|
||||
os_ << '\n'; // clear separation from content.
|
||||
@ -199,14 +221,16 @@ public:
|
||||
}
|
||||
|
||||
//- End "VTKFile" XML tag
|
||||
inline foamVtkFormatter& endVTKFile()
|
||||
// \return formatter for chaining
|
||||
inline formatter& endVTKFile()
|
||||
{
|
||||
return endTag("VTKFile");
|
||||
}
|
||||
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const std::string& v,
|
||||
@ -214,7 +238,8 @@ public:
|
||||
);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int32_t v,
|
||||
@ -222,7 +247,8 @@ public:
|
||||
);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const int64_t v,
|
||||
@ -230,7 +256,8 @@ public:
|
||||
);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const uint64_t v,
|
||||
@ -238,7 +265,8 @@ public:
|
||||
);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
// \return formatter for chaining
|
||||
formatter& xmlAttr
|
||||
(
|
||||
const word& k,
|
||||
const scalar v,
|
||||
@ -246,29 +274,34 @@ public:
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word& k, const std::string& v);
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const std::string& v);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word& k, const int32_t v);
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const int32_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word& k, const int64_t v);
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const int64_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word& k, const uint64_t v);
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const uint64_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word& k, const scalar v);
|
||||
// \return formatter for chaining
|
||||
formatter& operator()(const word& k, const scalar v);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,8 +27,8 @@ License
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::xmlAttribute
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::xmlAttribute
|
||||
(
|
||||
const word& k,
|
||||
const Type& v,
|
||||
@ -49,7 +49,8 @@ Foam::foamVtkFormatter::xmlAttribute
|
||||
|
||||
|
||||
template<class Type, int nComp>
|
||||
Foam::foamVtkFormatter& Foam::foamVtkFormatter::openDataArray
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::openDataArray
|
||||
(
|
||||
const word& dataName
|
||||
)
|
||||
@ -68,7 +69,8 @@ Foam::foamVtkFormatter& Foam::foamVtkFormatter::openDataArray
|
||||
|
||||
|
||||
template<class Type, int nComp>
|
||||
Foam::foamVtkFormatter& Foam::foamVtkFormatter::PDataArray
|
||||
Foam::foamVtkOutput::formatter&
|
||||
Foam::foamVtkOutput::formatter::PDataArray
|
||||
(
|
||||
const word& dataName
|
||||
)
|
||||
@ -89,4 +91,5 @@ Foam::foamVtkFormatter& Foam::foamVtkFormatter::PDataArray
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
74
src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.C
Normal file
74
src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.C
Normal file
@ -0,0 +1,74 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "foamVtkLegacyAsciiFormatter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkOutput::legacyAsciiFormatter::legacyName_ = "ASCII";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkOutput::legacyAsciiFormatter::legacyAsciiFormatter
|
||||
(
|
||||
std::ostream& os
|
||||
)
|
||||
:
|
||||
asciiFormatter(os)
|
||||
{}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::legacyAsciiFormatter::legacyAsciiFormatter
|
||||
(
|
||||
std::ostream& os,
|
||||
unsigned precision
|
||||
)
|
||||
:
|
||||
asciiFormatter(os, precision)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkOutput::legacyAsciiFormatter::~legacyAsciiFormatter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkOutput::legacyAsciiFormatter::name() const
|
||||
{
|
||||
return legacyName_;
|
||||
}
|
||||
|
||||
|
||||
const char* Foam::foamVtkOutput::legacyAsciiFormatter::encoding() const
|
||||
{
|
||||
return legacyName_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
108
src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.H
Normal file
108
src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.H
Normal file
@ -0,0 +1,108 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
Class
|
||||
Foam::foamVtkOutput::legacyAsciiFormatter
|
||||
|
||||
Description
|
||||
Formatting as per Foam::foamVtkOutput::asciiFormatter, but with
|
||||
naming for legacy output.
|
||||
|
||||
SourceFiles
|
||||
foamVtkLegacyAsciiFormatter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkLegacyAsciiFormatter_H
|
||||
#define foamVtkLegacyAsciiFormatter_H
|
||||
|
||||
#include "foamVtkAsciiFormatter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class legacyAsciiFormatter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class legacyAsciiFormatter
|
||||
:
|
||||
public asciiFormatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
static const char* legacyName_;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
legacyAsciiFormatter(const legacyAsciiFormatter&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const legacyAsciiFormatter&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream, use default precision
|
||||
legacyAsciiFormatter(std::ostream& os);
|
||||
|
||||
//- Construct and attach to an output stream, use specified precision
|
||||
legacyAsciiFormatter(std::ostream& os, unsigned precision);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~legacyAsciiFormatter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The output formatType is LEGACY_ASCII.
|
||||
virtual enum formatType format() const
|
||||
{
|
||||
return formatType::LEGACY_ASCII;
|
||||
}
|
||||
|
||||
//- Name for the legacy ascii output type ("ASCII")
|
||||
virtual const char* name() const;
|
||||
|
||||
//- Name for the XML append encoding (unused).
|
||||
// Currently identical to name(), but do not rely on this.
|
||||
virtual const char* encoding() const;
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,17 +23,17 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtkLegacyFormatter.H"
|
||||
#include "foamVtkLegacyRawFormatter.H"
|
||||
#include "endian.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkLegacyFormatter::name_ = "BINARY";
|
||||
const char* Foam::foamVtkOutput::legacyRawFormatter::legacyName_ = "BINARY";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::write
|
||||
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||
(
|
||||
const char* s,
|
||||
std::streamsize n
|
||||
@ -45,37 +45,46 @@ void Foam::foamVtkLegacyFormatter::write
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkLegacyFormatter::foamVtkLegacyFormatter(std::ostream& os)
|
||||
Foam::foamVtkOutput::legacyRawFormatter::legacyRawFormatter
|
||||
(
|
||||
std::ostream& os
|
||||
)
|
||||
:
|
||||
foamVtkFormatter(os)
|
||||
formatter(os)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkLegacyFormatter::~foamVtkLegacyFormatter()
|
||||
Foam::foamVtkOutput::legacyRawFormatter::~legacyRawFormatter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkLegacyFormatter::name() const
|
||||
const char* Foam::foamVtkOutput::legacyRawFormatter::name() const
|
||||
{
|
||||
return name_;
|
||||
return legacyName_;
|
||||
}
|
||||
|
||||
|
||||
const char* Foam::foamVtkLegacyFormatter::encoding() const
|
||||
const char* Foam::foamVtkOutput::legacyRawFormatter::encoding() const
|
||||
{
|
||||
return name_;
|
||||
return legacyName_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t ignored)
|
||||
void Foam::foamVtkOutput::legacyRawFormatter::writeSize
|
||||
(
|
||||
const uint64_t ignored
|
||||
)
|
||||
{/*nop*/}
|
||||
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::write(const uint8_t val)
|
||||
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||
(
|
||||
const uint8_t val
|
||||
)
|
||||
{
|
||||
// Legacy can only handle 32-bit integers.
|
||||
// Nonetheless promote to 'label' (32 or 64 bit) and deal with it later
|
||||
@ -84,7 +93,10 @@ void Foam::foamVtkLegacyFormatter::write(const uint8_t val)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::write(const label val)
|
||||
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||
(
|
||||
const label val
|
||||
)
|
||||
{
|
||||
// std::cerr<<"label is:" << sizeof(val) << '\n';
|
||||
|
||||
@ -104,7 +116,10 @@ void Foam::foamVtkLegacyFormatter::write(const label val)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::write(const float val)
|
||||
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||
(
|
||||
const float val
|
||||
)
|
||||
{
|
||||
// std::cerr<<"float is:" << sizeof(val) << '\n';
|
||||
|
||||
@ -122,7 +137,10 @@ void Foam::foamVtkLegacyFormatter::write(const float val)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::write(const double val)
|
||||
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||
(
|
||||
const double val
|
||||
)
|
||||
{
|
||||
// Legacy cannot support Float64 anyhow.
|
||||
// std::cerr<<"write double as float:" << val << '\n';
|
||||
@ -131,7 +149,7 @@ void Foam::foamVtkLegacyFormatter::write(const double val)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::flush()
|
||||
void Foam::foamVtkOutput::legacyRawFormatter::flush()
|
||||
{
|
||||
os()<< '\n';
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
foamVtkLegacyFormatter
|
||||
Foam::foamVtkOutput::legacyRawFormatter
|
||||
|
||||
Description
|
||||
Binary output for the VTK legacy format, always written as big-endian
|
||||
@ -31,12 +31,12 @@ Description
|
||||
This format should never be used for OpenFOAM with 64-bit label sizes.
|
||||
|
||||
SourceFiles
|
||||
foamVtkLegacyFormatter.C
|
||||
foamVtkLegacyRawFormatter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkLegacyFormatter_H
|
||||
#define foamVtkLegacyFormatter_H
|
||||
#ifndef foamVtkLegacyRawFormatter_H
|
||||
#define foamVtkLegacyRawFormatter_H
|
||||
|
||||
#include "foamVtkFormatter.H"
|
||||
|
||||
@ -44,27 +44,29 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkLegacyFormatter Declaration
|
||||
Class legacyRawFormatter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkLegacyFormatter
|
||||
class legacyRawFormatter
|
||||
:
|
||||
public foamVtkFormatter
|
||||
public formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
static const char* name_;
|
||||
static const char* legacyName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamVtkLegacyFormatter(const foamVtkLegacyFormatter&) = delete;
|
||||
legacyRawFormatter(const legacyRawFormatter&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamVtkLegacyFormatter&) = delete;
|
||||
void operator=(const legacyRawFormatter&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
@ -80,15 +82,21 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkLegacyFormatter(std::ostream& os);
|
||||
legacyRawFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~foamVtkLegacyFormatter();
|
||||
virtual ~legacyRawFormatter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The output formatType is LEGACY_BINARY.
|
||||
virtual enum formatType format() const
|
||||
{
|
||||
return formatType::LEGACY_BINARY;
|
||||
}
|
||||
|
||||
//- Name for the legacy binary output type ("BINARY")
|
||||
virtual const char* name() const;
|
||||
|
||||
@ -112,6 +120,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -1,235 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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),
|
||||
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 on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
// 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 on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
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 on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
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 prec) const
|
||||
{
|
||||
precision_ = prec;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
167
src/fileFormats/vtk/output/foamVtkOutput.C
Normal file
167
src/fileFormats/vtk/output/foamVtkOutput.C
Normal file
@ -0,0 +1,167 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtkOutput.H"
|
||||
|
||||
#include "foamVtkFormatter.H"
|
||||
#include "foamVtkAsciiFormatter.H"
|
||||
#include "foamVtkBase64Formatter.H"
|
||||
#include "foamVtkAppendBase64Formatter.H"
|
||||
#include "foamVtkAppendRawFormatter.H"
|
||||
#include "foamVtkLegacyAsciiFormatter.H"
|
||||
#include "foamVtkLegacyRawFormatter.H"
|
||||
#include "typeInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Static Data * * * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word Foam::foamVtkOutput::legacy::EXT = "vtk";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::foamVtkOutput::formatter>
|
||||
Foam::foamVtkOutput::newFormatter
|
||||
(
|
||||
std::ostream& os,
|
||||
const enum formatType fmtType,
|
||||
unsigned prec
|
||||
)
|
||||
{
|
||||
autoPtr<foamVtkOutput::formatter> fmt;
|
||||
|
||||
switch (fmtType)
|
||||
{
|
||||
case INLINE_ASCII:
|
||||
fmt.set(new foamVtkOutput::asciiFormatter(os, prec));
|
||||
break;
|
||||
|
||||
case INLINE_BASE64:
|
||||
fmt.set(new foamVtkOutput::base64Formatter(os));
|
||||
break;
|
||||
|
||||
case APPEND_BASE64:
|
||||
fmt.set(new foamVtkOutput::appendBase64Formatter(os));
|
||||
break;
|
||||
|
||||
case APPEND_BINARY:
|
||||
fmt.set(new foamVtkOutput::appendRawFormatter(os));
|
||||
break;
|
||||
|
||||
case LEGACY_ASCII:
|
||||
fmt.set(new foamVtkOutput::legacyAsciiFormatter(os, prec));
|
||||
break;
|
||||
|
||||
case LEGACY_BINARY:
|
||||
fmt.set(new foamVtkOutput::legacyRawFormatter(os));
|
||||
break;
|
||||
}
|
||||
|
||||
return fmt;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::foamVtkOutput::writeVtmFile
|
||||
(
|
||||
std::ostream& os,
|
||||
const UList<fileName>& files
|
||||
)
|
||||
{
|
||||
const word& content = "vtkMultiBlockDataSet";
|
||||
|
||||
asciiFormatter vtmFile(os);
|
||||
|
||||
vtmFile
|
||||
.xmlHeader()
|
||||
.beginVTKFile(content, "1.0");
|
||||
|
||||
forAll(files, i)
|
||||
{
|
||||
vtmFile
|
||||
.openTag("DataSet")
|
||||
( "index", i )
|
||||
( "file", files[i] )
|
||||
.closeTag(true);
|
||||
}
|
||||
|
||||
vtmFile.endTag(content).endVTKFile();
|
||||
|
||||
return files.size();
|
||||
}
|
||||
|
||||
|
||||
std::ostream& Foam::foamVtkOutput::legacy::fileHeader
|
||||
(
|
||||
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::fileHeader
|
||||
(
|
||||
foamVtkOutput::formatter& fmt,
|
||||
const std::string& title
|
||||
)
|
||||
{
|
||||
return fileHeader(fmt.os(), title, isType<legacyRawFormatter>(fmt));
|
||||
}
|
||||
|
||||
|
||||
std::ostream& Foam::foamVtkOutput::legacy::cellDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nCells,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
os << "CELL_DATA " << nCells << nl
|
||||
<< "FIELD attributes " << nFields << nl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& Foam::foamVtkOutput::legacy::pointDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nPoints,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
os << "POINT_DATA " << nPoints << nl
|
||||
<< "FIELD attributes " << nFields << nl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
211
src/fileFormats/vtk/output/foamVtkOutput.H
Normal file
211
src/fileFormats/vtk/output/foamVtkOutput.H
Normal file
@ -0,0 +1,211 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Namespace
|
||||
Foam::foamVtkOutput
|
||||
|
||||
Description
|
||||
Namespace for handling VTK output.
|
||||
Contains classes and functions for writing VTK file content.
|
||||
|
||||
Namespace
|
||||
Foam::foamVtkOutput::legacy
|
||||
|
||||
Description
|
||||
Namespace for legacy VTK output functions.
|
||||
|
||||
SourceFiles
|
||||
foamVtkOutput.C
|
||||
foamVtkOutputTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkOutput_H
|
||||
#define foamVtkOutput_H
|
||||
|
||||
#include "autoPtr.H"
|
||||
#include "foamVtkOutputTypes.H"
|
||||
#include "foamVtkFormatter.H"
|
||||
#include "floatScalar.H"
|
||||
#include "IOstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Typedefs
|
||||
|
||||
//- Use UInt64 for header data
|
||||
typedef formatter::headerType headerType;
|
||||
|
||||
|
||||
// General Functions
|
||||
|
||||
//- Return a default asciiFormatter
|
||||
autoPtr<foamVtkOutput::formatter> newFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Return a new formatter based on the specified format type
|
||||
autoPtr<foamVtkOutput::formatter> newFormatter
|
||||
(
|
||||
std::ostream& os,
|
||||
const enum formatType fmtType,
|
||||
unsigned prec = IOstream::defaultPrecision()
|
||||
);
|
||||
|
||||
|
||||
//- Write vtm datasets for specified files
|
||||
label writeVtmFile(std::ostream& os, const UList<fileName>& files);
|
||||
|
||||
|
||||
//- Write a value component-wise.
|
||||
template<class Type>
|
||||
inline void write
|
||||
(
|
||||
foamVtkOutput::formatter& fmt,
|
||||
const Type& val
|
||||
);
|
||||
|
||||
|
||||
//- Write a list of values.
|
||||
// The output does not include the payload size.
|
||||
template<class Type>
|
||||
void writeList
|
||||
(
|
||||
foamVtkOutput::formatter& fmt,
|
||||
const UList<Type>& lst
|
||||
);
|
||||
|
||||
|
||||
//- Write a list of values via indirect addressing.
|
||||
// The output does not include the payload size.
|
||||
template<class Type>
|
||||
void writeList
|
||||
(
|
||||
foamVtkOutput::formatter& fmt,
|
||||
const UList<Type>& lst,
|
||||
const UList<label>& addressing
|
||||
);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Namespace legacy
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Some minimal additional support for writing legacy files
|
||||
namespace legacy
|
||||
{
|
||||
// Constants
|
||||
|
||||
//- File extension for legacy files (vtk)
|
||||
extern const Foam::word EXT;
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
//- Emit header for legacy file.
|
||||
// Writes "ASCII" or "BINARY" depending on specified type.
|
||||
std::ostream& fileHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const std::string& title,
|
||||
const bool binary = false
|
||||
);
|
||||
|
||||
//- Emit header for legacy file.
|
||||
// Writes "ASCII" or "BINARY" depending on the formatter type.
|
||||
std::ostream& fileHeader
|
||||
(
|
||||
foamVtkOutput::formatter& fmt,
|
||||
const std::string& title
|
||||
);
|
||||
|
||||
//- Emit header for legacy CELL_DATA
|
||||
std::ostream& cellDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nCells,
|
||||
const label nFields
|
||||
);
|
||||
|
||||
|
||||
//- Emit header for legacy POINT_DATA
|
||||
std::ostream& pointDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nPoints,
|
||||
const label nFields
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Template specialization for label
|
||||
template<>
|
||||
inline void write<label>(foamVtkOutput::formatter& fmt, const label& val)
|
||||
{
|
||||
fmt.write(val);
|
||||
}
|
||||
|
||||
|
||||
//- Template specialization for float
|
||||
template<>
|
||||
inline void write<float>(foamVtkOutput::formatter& fmt, const float& val)
|
||||
{
|
||||
fmt.write(val);
|
||||
}
|
||||
|
||||
|
||||
//- Template specialization for double
|
||||
template<>
|
||||
inline void write<double>(foamVtkOutput::formatter& fmt, const double& val)
|
||||
{
|
||||
fmt.write(val);
|
||||
}
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "foamVtkOutputTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
131
src/fileFormats/vtk/output/foamVtkOutputOptions.C
Normal file
131
src/fileFormats/vtk/output/foamVtkOutputOptions.C
Normal file
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtkOutputOptions.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkOutput::outputOptions&
|
||||
Foam::foamVtkOutput::outputOptions::ascii(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
switch (fmtType_)
|
||||
{
|
||||
case INLINE_BASE64: fmtType_ = INLINE_ASCII; break;
|
||||
case APPEND_BINARY: fmtType_ = APPEND_BASE64; break;
|
||||
case LEGACY_BINARY: fmtType_ = LEGACY_ASCII; break;
|
||||
default: break; // no change
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (fmtType_)
|
||||
{
|
||||
case INLINE_ASCII: fmtType_ = INLINE_BASE64; break;
|
||||
case APPEND_BASE64: fmtType_ = APPEND_BINARY; break;
|
||||
case LEGACY_ASCII: fmtType_ = LEGACY_BINARY; break;
|
||||
default: break; // no change
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::outputOptions&
|
||||
Foam::foamVtkOutput::outputOptions::append(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
switch (fmtType_)
|
||||
{
|
||||
case INLINE_ASCII: fmtType_ = APPEND_BASE64; break;
|
||||
case LEGACY_ASCII: fmtType_ = APPEND_BASE64; break;
|
||||
case INLINE_BASE64: fmtType_ = APPEND_BINARY; break;
|
||||
case LEGACY_BINARY: fmtType_ = APPEND_BINARY; break;
|
||||
default: break; // no change
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (fmtType_)
|
||||
{
|
||||
case APPEND_BASE64: fmtType_ = INLINE_ASCII; break;
|
||||
case APPEND_BINARY: fmtType_ = INLINE_BASE64; break;
|
||||
default: break; // no change
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::foamVtkOutput::outputOptions&
|
||||
Foam::foamVtkOutput::outputOptions::legacy(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
switch (fmtType_)
|
||||
{
|
||||
case INLINE_ASCII: fmtType_ = LEGACY_ASCII; break;
|
||||
case INLINE_BASE64: fmtType_ = LEGACY_BINARY; break;
|
||||
case APPEND_BASE64: fmtType_ = LEGACY_ASCII; break;
|
||||
case APPEND_BINARY: fmtType_ = LEGACY_BINARY; break;
|
||||
default: break; // no change
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (fmtType_)
|
||||
{
|
||||
case LEGACY_ASCII: fmtType_ = INLINE_ASCII; break;
|
||||
case LEGACY_BINARY: fmtType_ = INLINE_BASE64; break;
|
||||
default: break; // no change
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::foamVtkOutput::outputOptions::description() const
|
||||
{
|
||||
switch (fmtType_)
|
||||
{
|
||||
case INLINE_ASCII: return "xml ascii";
|
||||
case INLINE_BASE64: return "xml base64";
|
||||
case APPEND_BASE64: return "xml-append base64";
|
||||
case APPEND_BINARY: return "xml-append binary";
|
||||
case LEGACY_ASCII: return "legacy ascii";
|
||||
case LEGACY_BINARY: return "legacy binary";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -22,10 +22,12 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
foamVtkOutputOptions
|
||||
Foam::foamVtkOutput::outputOptions
|
||||
|
||||
Description
|
||||
Encapsulate combinations of output format options.
|
||||
Encapsulated combinations of output format options.
|
||||
This is primarily useful when defining the output type based on some
|
||||
command-line arguments or dictionary contents.
|
||||
|
||||
SourceFiles
|
||||
foamVtkOutputOptions.C
|
||||
@ -35,43 +37,36 @@ SourceFiles
|
||||
#ifndef foamVtkOutputOptions_H
|
||||
#define foamVtkOutputOptions_H
|
||||
|
||||
#include "autoPtr.H"
|
||||
#include "foamVtkFormatter.H"
|
||||
#include "foamVtkOutput.H"
|
||||
#include "string.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
class Ostream;
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkOutputOptions Declaration
|
||||
Class outputOptions Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkOutputOptions
|
||||
class outputOptions
|
||||
{
|
||||
// Private data
|
||||
private:
|
||||
|
||||
//- 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
|
||||
};
|
||||
// Private Member Data
|
||||
|
||||
//- The output style tuning
|
||||
enum foamVtkStyleOptions
|
||||
enum styleType
|
||||
{
|
||||
NONE = 0x0000, //!< Normal
|
||||
HEADER = 0x0001 //!< Emit xml header
|
||||
NONE = 0x00, //!< Normal
|
||||
HEADER = 0x01 //!< Emit xml header
|
||||
};
|
||||
|
||||
|
||||
//- The output format type
|
||||
unsigned short type_;
|
||||
formatType fmtType_;
|
||||
|
||||
//- ASCII write precision
|
||||
mutable unsigned precision_;
|
||||
@ -82,18 +77,24 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null - XML insitu ASCII format with default precision
|
||||
foamVtkOutputOptions();
|
||||
inline outputOptions();
|
||||
|
||||
//- Construct with specified format
|
||||
inline outputOptions(enum formatType fmtType);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return new data formatter based on the writer options
|
||||
autoPtr<foamVtkFormatter> newFormatter(std::ostream& os) const;
|
||||
//- Return new formatter based on the selected output options
|
||||
inline autoPtr<formatter> newFormatter(std::ostream& os) const;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- The output format type
|
||||
inline formatType format() const;
|
||||
|
||||
//- True if writer uses legacy file format
|
||||
inline bool legacy() const;
|
||||
@ -111,34 +112,39 @@ public:
|
||||
inline bool ascii() const;
|
||||
|
||||
|
||||
// Edit
|
||||
// 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 XML append mode, this switches between base64 and raw binary.
|
||||
// In XML inline mode, this switches between ASCII and base64.
|
||||
// In legacy mode, this switches between ASCII and binary.
|
||||
void ascii(bool on);
|
||||
// \return outputOptions for chaining
|
||||
outputOptions& ascii(bool on);
|
||||
|
||||
//- Toggle append mode on/off.
|
||||
void append(bool on);
|
||||
// \return outputOptions for chaining
|
||||
outputOptions& append(bool on);
|
||||
|
||||
//- Toggle legacy mode on/off.
|
||||
void legacy(bool on);
|
||||
// \return outputOptions for chaining
|
||||
outputOptions& legacy(bool on);
|
||||
|
||||
//- Set the write precision to be used for new ASCII formatters
|
||||
void precision(unsigned prec) const;
|
||||
// \return outputOptions for chaining
|
||||
inline const outputOptions& precision(unsigned prec) const;
|
||||
|
||||
|
||||
// Other
|
||||
|
||||
//- Report information about the options
|
||||
Ostream& info(Ostream&) const;
|
||||
//- Report description about the option selected
|
||||
string description() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
102
src/fileFormats/vtk/output/foamVtkOutputOptionsI.H
Normal file
102
src/fileFormats/vtk/output/foamVtkOutputOptionsI.H
Normal file
@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::foamVtkOutput::outputOptions::outputOptions()
|
||||
:
|
||||
fmtType_(INLINE_ASCII),
|
||||
precision_(IOstream::defaultPrecision())
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::foamVtkOutput::outputOptions::outputOptions
|
||||
(
|
||||
enum formatType fmtType
|
||||
)
|
||||
:
|
||||
fmtType_(fmtType),
|
||||
precision_(IOstream::defaultPrecision())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::autoPtr<Foam::foamVtkOutput::formatter>
|
||||
Foam::foamVtkOutput::outputOptions::newFormatter(std::ostream& os) const
|
||||
{
|
||||
return foamVtkOutput::newFormatter(os, fmtType_, precision_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::foamVtkOutput::formatType
|
||||
Foam::foamVtkOutput::outputOptions::format() const
|
||||
{
|
||||
return fmtType_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutput::outputOptions::legacy() const
|
||||
{
|
||||
return (fmtType_ & formatType::LEGACY_ASCII & formatType::LEGACY_BINARY);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutput::outputOptions::xml() const
|
||||
{
|
||||
return !legacy();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutput::outputOptions::append() const
|
||||
{
|
||||
return (fmtType_ & formatType::APPEND_BASE64 & formatType::APPEND_BINARY);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutput::outputOptions::insitu() const
|
||||
{
|
||||
return !append();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutput::outputOptions::ascii() const
|
||||
{
|
||||
return !(fmtType_ & 0xF);
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::foamVtkOutput::outputOptions&
|
||||
Foam::foamVtkOutput::outputOptions::precision(unsigned prec) const
|
||||
{
|
||||
precision_ = prec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2107 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,33 +23,48 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
inline bool Foam::foamVtkOutputOptions::legacy() const
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline void Foam::foamVtkOutput::write
|
||||
(
|
||||
foamVtkOutput::formatter& fmt,
|
||||
const Type& val
|
||||
)
|
||||
{
|
||||
return (type_ & LEGACY);
|
||||
for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; ++cmpt)
|
||||
{
|
||||
fmt.write(component(val, cmpt));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutputOptions::xml() const
|
||||
template<class Type>
|
||||
void Foam::foamVtkOutput::writeList
|
||||
(
|
||||
foamVtkOutput::formatter& fmt,
|
||||
const UList<Type>& lst
|
||||
)
|
||||
{
|
||||
return !legacy();
|
||||
forAll(lst, i)
|
||||
{
|
||||
write(fmt, lst[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutputOptions::append() const
|
||||
template<class Type>
|
||||
void Foam::foamVtkOutput::writeList
|
||||
(
|
||||
foamVtkOutput::formatter& fmt,
|
||||
const UList<Type>& lst,
|
||||
const UList<label>& addressing
|
||||
)
|
||||
{
|
||||
return (type_ & APPEND);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutputOptions::insitu() const
|
||||
{
|
||||
return !(type_ & APPEND);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::foamVtkOutputOptions::ascii() const
|
||||
{
|
||||
return !(type_ & (BINARY | BASE64));
|
||||
forAll(addressing, i)
|
||||
{
|
||||
write(fmt, lst[addressing[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
77
src/fileFormats/vtk/type/foamVtkOutputTypes.H
Normal file
77
src/fileFormats/vtk/type/foamVtkOutputTypes.H
Normal file
@ -0,0 +1,77 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InNamespace
|
||||
Foam::foamVtkOutput
|
||||
|
||||
Description
|
||||
Enumerations and typedefs for VTK output.
|
||||
|
||||
SourceFiles
|
||||
foamVtkOutputTypes.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkOutputTypes_H
|
||||
#define foamVtkOutputTypes_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace foamVtkOutput
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Enumerations
|
||||
|
||||
//- The output format type for file contents.
|
||||
// Upper bits for output type, lower bits for the format itself.
|
||||
enum formatType
|
||||
{
|
||||
/** XML inline ASCII, using the asciiFormatter */
|
||||
INLINE_ASCII = 0,
|
||||
/** XML inline base64, using the base64Formatter */
|
||||
INLINE_BASE64 = 0x01,
|
||||
/** XML append base64, using the appendBase64Formatter */
|
||||
APPEND_BASE64 = 0x11,
|
||||
/** XML append raw binary, using the appendRawFormatter */
|
||||
APPEND_BINARY = 0x12,
|
||||
/** Legacy ASCII, using the legacyAsciiFormatter */
|
||||
LEGACY_ASCII = 0x20,
|
||||
/** Legacy raw binary, using the legacyRawFormatter */
|
||||
LEGACY_BINARY = 0x22,
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace foamVtkOutput
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user