diff --git a/src/conversion/Make/files b/src/conversion/Make/files
index bc77df3454..7e3d56e5df 100644
--- a/src/conversion/Make/files
+++ b/src/conversion/Make/files
@@ -27,6 +27,5 @@ polyDualMesh/polyDualMesh.C
vtk/part/foamVtkCells.C
vtk/part/foamVtkMeshMaps.C
vtk/part/foamVtuSizing.C
-vtk/output/foamVtkOutput.C
LIB = $(FOAM_LIBBIN)/libconversion
diff --git a/src/conversion/vtk/output/foamVtkOutput.H b/src/conversion/vtk/output/foamVtkOutput.H
deleted file mode 100644
index b1cbfb2438..0000000000
--- a/src/conversion/vtk/output/foamVtkOutput.H
+++ /dev/null
@@ -1,231 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2016-2107 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 .
-
-Class
- foamVtkOutput
-
-Description
- A collection of functions for writing vtk file content.
-
-SourceFiles
- foamVtkOutput.C
- foamVtkOutputTemplates.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef foamVtkOutput_H
-#define foamVtkOutput_H
-
-#include "floatScalar.H"
-#include "volFields.H"
-#include "foamVtkFormatter.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-/*---------------------------------------------------------------------------*\
- Class foamVtkOutput Declaration
-\*---------------------------------------------------------------------------*/
-
-class foamVtkOutput
-{
- // Private Member Functions
-
- //- Disallow construction
- foamVtkOutput() = delete;
-
-public:
-
- // Public typedefs
-
- //- Use UInt64 for header data
- typedef foamVtkFormatter::headerType headerType;
-
-
- // Forward declarations
- class legacy;
-
-
- // Static Members
-
- //- Write vtm datasets for specified files
- static Foam::label writeVtmFile
- (
- std::ostream& os,
- const UList& files
- );
-
-
- //- Write a value component-wise.
- template
- inline static void write(foamVtkFormatter& fmt, const Type& val);
-
-
- //- Write a list of values.
- // The output does not include the payload size.
- template
- static void writeList
- (
- foamVtkFormatter& fmt,
- const UList& lst
- );
-
-
- //- Write a list of values via indirect addressing.
- // The output does not include the payload size.
- template
- static void writeList
- (
- foamVtkFormatter& fmt,
- const UList& lst,
- const UList& addressing
- );
-
-
- //- Write internalField for mesh
- // The output includes the payload size and flush.
- template
- static void writeField
- (
- foamVtkFormatter& fmt,
- const GeometricField& vf
- );
-
- //- Write internalField based on the cellMap
- // The output includes the payload size and flush.
- template
- static void writeField
- (
- foamVtkFormatter& fmt,
- const GeometricField& vf,
- const UList& cellMap
- );
-
-};
-
-
-/*---------------------------------------------------------------------------*\
- Class foamVtkOutput::legacy Declaration
-\*---------------------------------------------------------------------------*/
-
-//- Basic support for legacy files
-class foamVtkOutput::legacy
-{
- // Private Member Functions
-
- //- Disallow construction
- legacy() = delete;
-
-public:
-
- // Static data members
-
- //- file extension for legacy files (vtk)
- static const Foam::word EXT;
-
-
- // Static Members
-
- //- Emit header for legacy file
- static std::ostream& writeHeader
- (
- std::ostream&,
- const std::string& title,
- const bool binary = false
- );
-
-
- //- Emit header for legacy CELL_DATA
- static std::ostream& writeCellDataHeader
- (
- std::ostream& os,
- const label nCells,
- const label nFields
- );
-
-
- //- Emit header for legacy POINT_DATA
- static std::ostream& writePointDataHeader
- (
- std::ostream& os,
- const label nPoints,
- const label nFields
- );
-
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-
-//- Template specialization for label
-template<>
-inline void Foam::foamVtkOutput::write
-(
- foamVtkFormatter& fmt,
- const label& val
-)
-{
- fmt.write(val);
-}
-
-
-//- Template specialization for float
-template<>
-inline void Foam::foamVtkOutput::write
-(
- foamVtkFormatter& fmt,
- const float& val
-)
-{
- fmt.write(val);
-}
-
-
-//- Template specialization for double
-template<>
-inline void Foam::foamVtkOutput::write
-(
- foamVtkFormatter& fmt,
- const double& val
-)
-{
- fmt.write(val);
-}
-
-} // End namespace Foam
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#ifdef NoRepository
- #include "foamVtkOutputTemplates.C"
-#endif
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/conversion/vtk/output/foamVtkOutputFields.H b/src/conversion/vtk/output/foamVtkOutputFields.H
new file mode 100644
index 0000000000..52bed6d037
--- /dev/null
+++ b/src/conversion/vtk/output/foamVtkOutputFields.H
@@ -0,0 +1,105 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016-2107 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 .
+
+InNamespace
+ Foam::foamVtkOutput
+
+Description
+ Additional functions for writing fields in VTK format.
+
+SourceFiles
+ foamVtkOutputFieldsTemplates.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef foamVtkOutputFields_H
+#define foamVtkOutputFields_H
+
+#include "foamVtkOutput.H"
+#include "volFields.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace foamVtkOutput
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ //- Write internalField for mesh
+ // The output includes the payload size and flush.
+ template
+ void writeField
+ (
+ foamVtkOutput::formatter& fmt,
+ const GeometricField& fld
+ );
+
+ //- Write internalField based on the cellMap
+ // The output includes the payload size and flush.
+ template
+ void writeField
+ (
+ foamVtkOutput::formatter& fmt,
+ const GeometricField& fld,
+ const UList& cellMap
+ );
+
+ //- Write DimensionedField for mesh
+ // The output includes the payload size and flush.
+ template
+ void writeField
+ (
+ foamVtkOutput::formatter& fmt,
+ const DimensionedField& fld
+ );
+
+ //- Write DimensionedField based on the cellMap
+ // The output includes the payload size and flush.
+ template
+ void writeField
+ (
+ foamVtkOutput::formatter& fmt,
+ const DimensionedField& fld,
+ const UList& cellMap
+ );
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace foamVtkOutput
+} // End namespace Foam
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+ #include "foamVtkOutputFieldsTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/conversion/vtk/output/foamVtkOutputFieldsTemplates.C b/src/conversion/vtk/output/foamVtkOutputFieldsTemplates.C
new file mode 100644
index 0000000000..43f784ae61
--- /dev/null
+++ b/src/conversion/vtk/output/foamVtkOutputFieldsTemplates.C
@@ -0,0 +1,107 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016-2107 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 .
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+
+template
+void Foam::foamVtkOutput::writeField
+(
+ foamVtkOutput::formatter& fmt,
+ const GeometricField& fld
+)
+{
+ const uint64_t payLoad =
+ (
+ fld.size() * pTraits::nComponents * sizeof(float)
+ );
+
+ fmt.writeSize(payLoad);
+ writeList(fmt, fld.internalField());
+
+ fmt.flush();
+}
+
+
+template
+void Foam::foamVtkOutput::writeField
+(
+ foamVtkOutput::formatter& fmt,
+ const GeometricField& fld,
+ const UList& cellMap
+)
+{
+ const uint64_t payLoad =
+ (
+ cellMap.size() * pTraits::nComponents * sizeof(float)
+ );
+
+ fmt.writeSize(payLoad);
+ writeList(fmt, fld.internalField(), cellMap);
+
+ fmt.flush();
+}
+
+
+template
+void Foam::foamVtkOutput::writeField
+(
+ foamVtkOutput::formatter& fmt,
+ const DimensionedField& fld
+)
+{
+ const uint64_t payLoad =
+ (
+ fld.size() * pTraits::nComponents * sizeof(float)
+ );
+
+ fmt.writeSize(payLoad);
+ writeList(fmt, fld);
+
+ fmt.flush();
+}
+
+
+template
+void Foam::foamVtkOutput::writeField
+(
+ foamVtkOutput::formatter& fmt,
+ const DimensionedField& fld,
+ const UList& cellMap
+)
+{
+ const uint64_t payLoad =
+ (
+ cellMap.size() * pTraits::nComponents * sizeof(float)
+ );
+
+ fmt.writeSize(payLoad);
+ writeList(fmt, fld, cellMap);
+
+ fmt.flush();
+}
+
+
+// ************************************************************************* //
diff --git a/src/fileFormats/Make/files b/src/fileFormats/Make/files
index ab7fe26dc2..cff7f7c33f 100644
--- a/src/fileFormats/Make/files
+++ b/src/fileFormats/Make/files
@@ -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
diff --git a/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C b/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C
index 3805b61812..bacc45c1a5 100644
--- a/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.C
+++ b/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.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_;
}
diff --git a/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H b/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H
index db3e1d6694..2cd289b6e4 100644
--- a/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H
+++ b/src/fileFormats/vtk/format/foamVtkAppendBase64Formatter.H
@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see .
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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C b/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C
index ae565323b8..cc587aae50 100644
--- a/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.C
@@ -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(&nBytes), sizeof(uint64_t));
}
-void Foam::foamVtkAppendRawFormatter::write(const uint8_t val)
+void Foam::foamVtkOutput::appendRawFormatter::write(const uint8_t val)
{
write(reinterpret_cast(&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(&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(&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*/}
diff --git a/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H b/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H
index 1dcb9b8d55..11de7e9b64 100644
--- a/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H
+++ b/src/fileFormats/vtk/format/foamVtkAppendRawFormatter.H
@@ -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 .
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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkAsciiFormatter.C b/src/fileFormats/vtk/format/foamVtkAsciiFormatter.C
index 9ed22db233..b19a3762db 100644
--- a/src/fileFormats/vtk/format/foamVtkAsciiFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkAsciiFormatter.C
@@ -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;
}
diff --git a/src/fileFormats/vtk/format/foamVtkAsciiFormatter.H b/src/fileFormats/vtk/format/foamVtkAsciiFormatter.H
index 8b8e06b2a2..6289e0fd83 100644
--- a/src/fileFormats/vtk/format/foamVtkAsciiFormatter.H
+++ b/src/fileFormats/vtk/format/foamVtkAsciiFormatter.H
@@ -22,10 +22,10 @@ License
along with OpenFOAM. If not, see .
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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkBase64Formatter.C b/src/fileFormats/vtk/format/foamVtkBase64Formatter.C
index f87efbb19f..a27d14c129 100644
--- a/src/fileFormats/vtk/format/foamVtkBase64Formatter.C
+++ b/src/fileFormats/vtk/format/foamVtkBase64Formatter.C
@@ -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())
{
diff --git a/src/fileFormats/vtk/format/foamVtkBase64Formatter.H b/src/fileFormats/vtk/format/foamVtkBase64Formatter.H
index e92fa4f9e3..52f7d025f1 100644
--- a/src/fileFormats/vtk/format/foamVtkBase64Formatter.H
+++ b/src/fileFormats/vtk/format/foamVtkBase64Formatter.H
@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see .
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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkBase64Layer.C b/src/fileFormats/vtk/format/foamVtkBase64Layer.C
index d66970d522..32d2d81642 100644
--- a/src/fileFormats/vtk/format/foamVtkBase64Layer.C
+++ b/src/fileFormats/vtk/format/foamVtkBase64Layer.C
@@ -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(&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(&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(&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);
}
diff --git a/src/fileFormats/vtk/format/foamVtkBase64Layer.H b/src/fileFormats/vtk/format/foamVtkBase64Layer.H
index 61527a11bc..da541bbde2 100644
--- a/src/fileFormats/vtk/format/foamVtkBase64Layer.H
+++ b/src/fileFormats/vtk/format/foamVtkBase64Layer.H
@@ -22,10 +22,10 @@ License
along with OpenFOAM. If not, see .
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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkFormatter.C b/src/fileFormats/vtk/format/foamVtkFormatter.C
index 5b9fded769..79a420e585 100644
--- a/src/fileFormats/vtk/format/foamVtkFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkFormatter.C
@@ -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);
}
diff --git a/src/fileFormats/vtk/format/foamVtkFormatter.H b/src/fileFormats/vtk/format/foamVtkFormatter.H
index 9e37f2c625..572316e562 100644
--- a/src/fileFormats/vtk/format/foamVtkFormatter.H
+++ b/src/fileFormats/vtk/format/foamVtkFormatter.H
@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see .
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
@@ -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
- 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
- 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
- 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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkFormatterTemplates.C b/src/fileFormats/vtk/format/foamVtkFormatterTemplates.C
index 1cde34a61e..1c1ec9b35f 100644
--- a/src/fileFormats/vtk/format/foamVtkFormatterTemplates.C
+++ b/src/fileFormats/vtk/format/foamVtkFormatterTemplates.C
@@ -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
-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
-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
-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;
}
+
// ************************************************************************* //
diff --git a/src/fileFormats/vtk/format/foamVtkOutputOptionsI.H b/src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.C
similarity index 53%
rename from src/fileFormats/vtk/format/foamVtkOutputOptionsI.H
rename to src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.C
index 0205f2f98e..226ee3a48f 100644
--- a/src/fileFormats/vtk/format/foamVtkOutputOptionsI.H
+++ b/src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.C
@@ -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) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -23,33 +23,51 @@ License
\*---------------------------------------------------------------------------*/
-inline bool Foam::foamVtkOutputOptions::legacy() const
+#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 (type_ & LEGACY);
+ return legacyName_;
}
-inline bool Foam::foamVtkOutputOptions::xml() const
+const char* Foam::foamVtkOutput::legacyAsciiFormatter::encoding() const
{
- return !legacy();
-}
-
-
-inline bool Foam::foamVtkOutputOptions::append() const
-{
- return (type_ & APPEND);
-}
-
-
-inline bool Foam::foamVtkOutputOptions::insitu() const
-{
- return !(type_ & APPEND);
-}
-
-
-inline bool Foam::foamVtkOutputOptions::ascii() const
-{
- return !(type_ & (BINARY | BASE64));
+ return legacyName_;
}
diff --git a/src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.H b/src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.H
new file mode 100644
index 0000000000..248c848cc1
--- /dev/null
+++ b/src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.H
@@ -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 .
+
+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
+
+// ************************************************************************* //
diff --git a/src/fileFormats/vtk/format/foamVtkLegacyFormatter.C b/src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.C
similarity index 76%
rename from src/fileFormats/vtk/format/foamVtkLegacyFormatter.C
rename to src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.C
index a3e87264f8..733d7a4ab0 100644
--- a/src/fileFormats/vtk/format/foamVtkLegacyFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.C
@@ -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';
}
diff --git a/src/fileFormats/vtk/format/foamVtkLegacyFormatter.H b/src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.H
similarity index 78%
rename from src/fileFormats/vtk/format/foamVtkLegacyFormatter.H
rename to src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.H
index 6ec5ba7e8d..47717a598b 100644
--- a/src/fileFormats/vtk/format/foamVtkLegacyFormatter.H
+++ b/src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.H
@@ -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 .
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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkOutputOptions.C b/src/fileFormats/vtk/format/foamVtkOutputOptions.C
deleted file mode 100644
index c88d334594..0000000000
--- a/src/fileFormats/vtk/format/foamVtkOutputOptions.C
+++ /dev/null
@@ -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 .
-
-\*---------------------------------------------------------------------------*/
-
-#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::foamVtkOutputOptions::newFormatter(std::ostream& os) const
-{
- switch (type_)
- {
- case (LEGACY | BINARY):
- return autoPtr
- (
- new foamVtkLegacyFormatter(os)
- );
-
- case BASE64: // xml insitu
- return autoPtr
- (
- new foamVtkBase64Formatter(os)
- );
-
- case (APPEND | BASE64):
- return autoPtr
- (
- new foamVtkAppendBase64Formatter(os)
- );
-
- case (APPEND | BINARY):
- return autoPtr
- (
- new foamVtkAppendRawFormatter(os)
- );
-
- default: // ASCII (legacy or xml) must always work
- return autoPtr
- (
- 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;
-}
-
-
-// ************************************************************************* //
diff --git a/src/conversion/vtk/output/foamVtkOutput.C b/src/fileFormats/vtk/output/foamVtkOutput.C
similarity index 54%
rename from src/conversion/vtk/output/foamVtkOutput.C
rename to src/fileFormats/vtk/output/foamVtkOutput.C
index fc2d298841..b4577fb948 100644
--- a/src/conversion/vtk/output/foamVtkOutput.C
+++ b/src/fileFormats/vtk/output/foamVtkOutput.C
@@ -24,32 +24,64 @@ License
\*---------------------------------------------------------------------------*/
#include "foamVtkOutput.H"
-#include "foamVtkAsciiFormatter.H"
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+#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";
-//! \cond fileScope
-static inline std::ostream& legacyDataHeader
+// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
+
+Foam::autoPtr
+Foam::foamVtkOutput::newFormatter
(
std::ostream& os,
- const char* tag,
- const Foam::label nItems,
- const Foam::label nFields
+ const enum formatType fmtType,
+ unsigned prec
)
{
- os << tag << ' ' << nItems << '\n'
- << "FIELD attributes " << nFields << '\n';
+ autoPtr fmt;
- return os;
+ 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;
}
-//! \endcond
-// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
-
Foam::label Foam::foamVtkOutput::writeVtmFile
(
std::ostream& os,
@@ -58,7 +90,7 @@ Foam::label Foam::foamVtkOutput::writeVtmFile
{
const word& content = "vtkMultiBlockDataSet";
- foamVtkAsciiFormatter vtmFile(os);
+ asciiFormatter vtmFile(os);
vtmFile
.xmlHeader()
@@ -79,7 +111,7 @@ Foam::label Foam::foamVtkOutput::writeVtmFile
}
-std::ostream& Foam::foamVtkOutput::legacy::writeHeader
+std::ostream& Foam::foamVtkOutput::legacy::fileHeader
(
std::ostream& os,
const std::string& title,
@@ -94,25 +126,41 @@ std::ostream& Foam::foamVtkOutput::legacy::writeHeader
}
-std::ostream& Foam::foamVtkOutput::legacy::writeCellDataHeader
+std::ostream& Foam::foamVtkOutput::legacy::fileHeader
+(
+ foamVtkOutput::formatter& fmt,
+ const std::string& title
+)
+{
+ return fileHeader(fmt.os(), title, isType(fmt));
+}
+
+
+std::ostream& Foam::foamVtkOutput::legacy::cellDataHeader
(
std::ostream& os,
const label nCells,
const label nFields
)
{
- return legacyDataHeader(os, "CELL_DATA", nCells, nFields);
+ os << "CELL_DATA " << nCells << nl
+ << "FIELD attributes " << nFields << nl;
+
+ return os;
}
-std::ostream& Foam::foamVtkOutput::legacy::writePointDataHeader
+std::ostream& Foam::foamVtkOutput::legacy::pointDataHeader
(
std::ostream& os,
const label nPoints,
const label nFields
)
{
- return legacyDataHeader(os, "POINT_DATA", nPoints, nFields);
+ os << "POINT_DATA " << nPoints << nl
+ << "FIELD attributes " << nFields << nl;
+
+ return os;
}
diff --git a/src/fileFormats/vtk/output/foamVtkOutput.H b/src/fileFormats/vtk/output/foamVtkOutput.H
new file mode 100644
index 0000000000..f9d44d15e4
--- /dev/null
+++ b/src/fileFormats/vtk/output/foamVtkOutput.H
@@ -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 .
+
+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 newFormatter(std::ostream& os);
+
+
+ //- Return a new formatter based on the specified format type
+ autoPtr 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& files);
+
+
+ //- Write a value component-wise.
+ template
+ inline void write
+ (
+ foamVtkOutput::formatter& fmt,
+ const Type& val
+ );
+
+
+ //- Write a list of values.
+ // The output does not include the payload size.
+ template
+ void writeList
+ (
+ foamVtkOutput::formatter& fmt,
+ const UList& lst
+ );
+
+
+ //- Write a list of values via indirect addressing.
+ // The output does not include the payload size.
+ template
+ void writeList
+ (
+ foamVtkOutput::formatter& fmt,
+ const UList& lst,
+ const UList& 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(foamVtkOutput::formatter& fmt, const label& val)
+{
+ fmt.write(val);
+}
+
+
+//- Template specialization for float
+template<>
+inline void write(foamVtkOutput::formatter& fmt, const float& val)
+{
+ fmt.write(val);
+}
+
+
+//- Template specialization for double
+template<>
+inline void write(foamVtkOutput::formatter& fmt, const double& val)
+{
+ fmt.write(val);
+}
+
+} // End namespace foamVtkOutput
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+ #include "foamVtkOutputTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/fileFormats/vtk/output/foamVtkOutputOptions.C b/src/fileFormats/vtk/output/foamVtkOutputOptions.C
new file mode 100644
index 0000000000..232ea5f0ab
--- /dev/null
+++ b/src/fileFormats/vtk/output/foamVtkOutputOptions.C
@@ -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 .
+
+\*---------------------------------------------------------------------------*/
+
+#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 "";
+}
+
+
+// ************************************************************************* //
diff --git a/src/fileFormats/vtk/format/foamVtkOutputOptions.H b/src/fileFormats/vtk/output/foamVtkOutputOptions.H
similarity index 65%
rename from src/fileFormats/vtk/format/foamVtkOutputOptions.H
rename to src/fileFormats/vtk/output/foamVtkOutputOptions.H
index 7e0e89b24b..826dc75128 100644
--- a/src/fileFormats/vtk/format/foamVtkOutputOptions.H
+++ b/src/fileFormats/vtk/output/foamVtkOutputOptions.H
@@ -22,10 +22,12 @@ License
along with OpenFOAM. If not, see .
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 newFormatter(std::ostream& os) const;
+ //- Return new formatter based on the selected output options
+ inline autoPtr 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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/output/foamVtkOutputOptionsI.H b/src/fileFormats/vtk/output/foamVtkOutputOptionsI.H
new file mode 100644
index 0000000000..f4a0aafcff
--- /dev/null
+++ b/src/fileFormats/vtk/output/foamVtkOutputOptionsI.H
@@ -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 .
+
+\*---------------------------------------------------------------------------*/
+
+
+// * * * * * * * * * * * * * * * * 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::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;
+}
+
+
+// ************************************************************************* //
diff --git a/src/conversion/vtk/output/foamVtkOutputTemplates.C b/src/fileFormats/vtk/output/foamVtkOutputTemplates.C
similarity index 69%
rename from src/conversion/vtk/output/foamVtkOutputTemplates.C
rename to src/fileFormats/vtk/output/foamVtkOutputTemplates.C
index a05fd4bb0f..9738740b8e 100644
--- a/src/conversion/vtk/output/foamVtkOutputTemplates.C
+++ b/src/fileFormats/vtk/output/foamVtkOutputTemplates.C
@@ -25,11 +25,10 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
template
inline void Foam::foamVtkOutput::write
(
- foamVtkFormatter& fmt,
+ foamVtkOutput::formatter& fmt,
const Type& val
)
{
@@ -43,7 +42,7 @@ inline void Foam::foamVtkOutput::write
template
void Foam::foamVtkOutput::writeList
(
- foamVtkFormatter& fmt,
+ foamVtkOutput::formatter& fmt,
const UList& lst
)
{
@@ -57,7 +56,7 @@ void Foam::foamVtkOutput::writeList
template
void Foam::foamVtkOutput::writeList
(
- foamVtkFormatter& fmt,
+ foamVtkOutput::formatter& fmt,
const UList& lst,
const UList& addressing
)
@@ -69,43 +68,4 @@ void Foam::foamVtkOutput::writeList
}
-template
-void Foam::foamVtkOutput::writeField
-(
- foamVtkFormatter& fmt,
- const GeometricField& vf
-)
-{
- const uint64_t payLoad =
- (
- vf.size() * pTraits::nComponents * sizeof(float)
- );
-
- fmt.writeSize(payLoad);
- writeList(fmt, vf.internalField());
-
- fmt.flush();
-}
-
-
-template
-void Foam::foamVtkOutput::writeField
-(
- foamVtkFormatter& fmt,
- const GeometricField& vf,
- const UList& cellMap
-)
-{
- const uint64_t payLoad =
- (
- cellMap.size() * pTraits::nComponents * sizeof(float)
- );
-
- fmt.writeSize(payLoad);
- writeList(fmt, vf.internalField(), cellMap);
-
- fmt.flush();
-}
-
-
// ************************************************************************* //
diff --git a/src/fileFormats/vtk/type/foamVtkOutputTypes.H b/src/fileFormats/vtk/type/foamVtkOutputTypes.H
new file mode 100644
index 0000000000..d4dbe0d5c8
--- /dev/null
+++ b/src/fileFormats/vtk/type/foamVtkOutputTypes.H
@@ -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 .
+
+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
+
+// ************************************************************************* //