mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: update coding for VTK fileFormats, make open() virtual
- add writer support for VERTICES - updated use of globalIndex ENH: add base vtk writer for points/verts/lines STYLE: noexcept, explicit constructors etc
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,7 +52,7 @@ namespace vtk
|
||||
// Enumerations
|
||||
|
||||
//- The context when outputting a VTK file (XML or legacy).
|
||||
enum OutputContext
|
||||
enum OutputContext : uint8_t
|
||||
{
|
||||
INLINE, //!< Generate header and inline data
|
||||
HEADER, //!< Generate header only
|
||||
@ -72,21 +72,21 @@ namespace vtk
|
||||
LEGACY_BINARY = 0x22, //!< Legacy raw binary, legacyRawFormatter
|
||||
};
|
||||
|
||||
//- Test for XML append format
|
||||
inline bool isAppend(enum formatType fmt)
|
||||
//- Test for vtk append format (xml)
|
||||
inline bool isAppend(enum formatType fmt) noexcept
|
||||
{
|
||||
return (uint8_t(fmt) & 0x10);
|
||||
}
|
||||
|
||||
//- Test for vtk legacy format
|
||||
inline bool isLegacy(enum formatType fmt)
|
||||
inline bool isLegacy(enum formatType fmt) noexcept
|
||||
{
|
||||
return (uint8_t(fmt) & 0x20);
|
||||
}
|
||||
|
||||
|
||||
//- Equivalent to enumeration in "vtkCellType.h"
|
||||
enum cellType
|
||||
//- Equivalent to enumeration in "vtkCellType.h" (should be uint8_t)
|
||||
enum cellType : uint8_t
|
||||
{
|
||||
VTK_EMPTY_CELL = 0,
|
||||
VTK_VERTEX = 1,
|
||||
@ -110,7 +110,7 @@ namespace vtk
|
||||
|
||||
|
||||
//- Some common XML tags for vtk files
|
||||
enum class fileTag
|
||||
enum class fileTag : uint8_t
|
||||
{
|
||||
VTK_FILE, //!< "VTKFile"
|
||||
DATA_ARRAY, //!< "DataArray"
|
||||
@ -140,7 +140,7 @@ namespace vtk
|
||||
extern const Foam::Enum<fileTag> fileTagNames;
|
||||
|
||||
//- Some common XML attributes for vtk files
|
||||
enum class fileAttr
|
||||
enum class fileAttr : uint8_t
|
||||
{
|
||||
OFFSET, //!< "offset"
|
||||
NUMBER_OF_COMPONENTS, //!< "NumberOfComponents"
|
||||
@ -156,7 +156,7 @@ namespace vtk
|
||||
extern const Foam::Enum<fileAttr> fileAttrNames;
|
||||
|
||||
//- Some common names for XML DataArray entries
|
||||
enum class dataArrayAttr
|
||||
enum class dataArrayAttr : uint8_t
|
||||
{
|
||||
POINTS, //!< "Points"
|
||||
OFFSETS, //!< "offsets"
|
||||
|
||||
@ -42,17 +42,17 @@ Description
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class endian;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkPTraits Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class PrimitiveType>
|
||||
template<class Type>
|
||||
struct vtkPTraits
|
||||
{
|
||||
// Static data members
|
||||
// Static Data Members
|
||||
static const char* const typeName;
|
||||
};
|
||||
|
||||
|
||||
@ -290,10 +290,10 @@ Foam::vtk::fileWriter::fileWriter
|
||||
const vtk::outputOptions opts
|
||||
)
|
||||
:
|
||||
contentType_(contentType),
|
||||
opts_(opts),
|
||||
parallel_(false),
|
||||
state_(outputState::CLOSED),
|
||||
contentType_(contentType),
|
||||
parallel_(false),
|
||||
opts_(opts),
|
||||
nCellData_(0),
|
||||
nPointData_(0),
|
||||
outputFile_(),
|
||||
@ -360,7 +360,7 @@ bool Foam::vtk::fileWriter::open(const fileName& file, bool parallel)
|
||||
// This means we can always check if format_ is defined to know if output
|
||||
// is desired on any particular process.
|
||||
|
||||
if (Pstream::master() || !parallel_)
|
||||
if (!parallel_ || Pstream::master())
|
||||
{
|
||||
mkDir(outputFile_.path());
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,6 +42,8 @@ Description
|
||||
|
||||
SourceFiles
|
||||
foamVtkFileWriter.C
|
||||
foamVtkFileWriterI.H
|
||||
foamVtkFileWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -71,7 +73,7 @@ protected:
|
||||
// Protected Member Data
|
||||
|
||||
//- Internal tracking of the output state.
|
||||
enum outputState
|
||||
enum outputState : uint8_t
|
||||
{
|
||||
CLOSED = 0, //!< File is closed
|
||||
OPENED, //!< File is opened
|
||||
@ -86,18 +88,18 @@ protected:
|
||||
static const Enum<outputState> stateNames;
|
||||
|
||||
|
||||
//- The content type
|
||||
vtk::fileTag contentType_;
|
||||
|
||||
//- The requested output options
|
||||
outputOptions opts_;
|
||||
|
||||
//- Writing in parallel (via master)
|
||||
bool parallel_;
|
||||
|
||||
//- The output state
|
||||
outputState state_;
|
||||
|
||||
//- The content type (PolyData, UnstructuredGrid ...)
|
||||
vtk::fileTag contentType_;
|
||||
|
||||
//- Parallel writing (via master)
|
||||
bool parallel_;
|
||||
|
||||
//- Requested output options
|
||||
vtk::outputOptions opts_;
|
||||
|
||||
//- The number of CellData written for the Piece thus far.
|
||||
label nCellData_;
|
||||
|
||||
@ -128,7 +130,7 @@ protected:
|
||||
//- The backend ostream in use
|
||||
inline std::ofstream& os() noexcept;
|
||||
|
||||
//- The VTK formatter in use
|
||||
//- The VTK formatter in use. FatalError for off-processor.
|
||||
inline vtk::formatter& format();
|
||||
|
||||
//- True if output state corresponds to the test state.
|
||||
@ -231,16 +233,16 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The content type
|
||||
inline vtk::fileTag contentType() const;
|
||||
inline vtk::fileTag contentType() const noexcept;
|
||||
|
||||
//- The output options in use
|
||||
inline vtk::outputOptions opts() const;
|
||||
inline vtk::outputOptions opts() const noexcept;
|
||||
|
||||
//- File extension for current format type.
|
||||
inline word ext() const;
|
||||
|
||||
//- Commonly used query
|
||||
inline bool legacy() const;
|
||||
inline bool legacy() const noexcept;
|
||||
|
||||
//- Parallel output requested?
|
||||
inline bool parallel() const noexcept;
|
||||
@ -258,7 +260,11 @@ public:
|
||||
// If the file name has an extension, it will be used where if
|
||||
// appropriate or changed to suit the format (legacy/xml) type.
|
||||
// \note Expected calling states: (CLOSED).
|
||||
bool open(const fileName& file, bool parallel=Pstream::parRun());
|
||||
virtual bool open
|
||||
(
|
||||
const fileName& file,
|
||||
bool parallel = Pstream::parRun()
|
||||
);
|
||||
|
||||
//- End the file contents and close the file after writing.
|
||||
// \note Expected calling states: (PIECE | CELL_DATA | POINT_DATA).
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,13 +53,13 @@ inline bool Foam::vtk::fileWriter::notState(outputState test) const noexcept
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::vtk::fileTag Foam::vtk::fileWriter::contentType() const
|
||||
inline Foam::vtk::fileTag Foam::vtk::fileWriter::contentType() const noexcept
|
||||
{
|
||||
return contentType_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::vtk::outputOptions Foam::vtk::fileWriter::opts() const
|
||||
inline Foam::vtk::outputOptions Foam::vtk::fileWriter::opts() const noexcept
|
||||
{
|
||||
return opts_;
|
||||
}
|
||||
@ -71,7 +71,7 @@ inline Foam::word Foam::vtk::fileWriter::ext() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::vtk::fileWriter::legacy() const
|
||||
inline bool Foam::vtk::fileWriter::legacy() const noexcept
|
||||
{
|
||||
return opts_.legacy();
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ void Foam::vtk::vtmWriter::vtmEntry::clear()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::vtk::vtmWriter::vtmEntry::good() const
|
||||
bool Foam::vtk::vtmWriter::vtmEntry::good() const noexcept
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -397,9 +397,7 @@ Foam::label Foam::vtk::vtmWriter::beginBlock(const word& blockName)
|
||||
|
||||
Foam::label Foam::vtk::vtmWriter::endBlock(const word& blockName)
|
||||
{
|
||||
label nblock = blocks_.size();
|
||||
|
||||
if (nblock)
|
||||
if (!blocks_.empty())
|
||||
{
|
||||
const word curr(blocks_.remove());
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ class vtmWriter
|
||||
vtmEntry& operator=(const vtmEntry&) = default;
|
||||
vtmEntry& operator=(vtmEntry&&) = default;
|
||||
|
||||
//- Construct null
|
||||
//- Default construct
|
||||
vtmEntry()
|
||||
:
|
||||
type_(NONE)
|
||||
@ -157,7 +157,7 @@ class vtmWriter
|
||||
// Member Functions
|
||||
|
||||
//- Test the type
|
||||
bool isType(Type what) const
|
||||
bool isType(Type what) const noexcept
|
||||
{
|
||||
return type_ == what;
|
||||
}
|
||||
@ -166,7 +166,7 @@ class vtmWriter
|
||||
void clear();
|
||||
|
||||
//- True if the entry is good.
|
||||
bool good() const;
|
||||
bool good() const noexcept;
|
||||
|
||||
//- Output valid entry as XML
|
||||
bool write(vtk::formatter& format) const;
|
||||
@ -207,7 +207,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null, with autoName on
|
||||
//- Default construct, with autoName on
|
||||
vtmWriter();
|
||||
|
||||
//- Construct with specified behaviour for autoName
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,7 +53,7 @@ namespace vtk
|
||||
|
||||
class appendBase64Formatter
|
||||
:
|
||||
public foamVtkBase64Layer
|
||||
public vtk::foamVtkBase64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -78,7 +78,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
appendBase64Formatter(std::ostream& os);
|
||||
explicit appendBase64Formatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor. Closes/flushes the underlying layer.
|
||||
@ -88,7 +88,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is APPEND_BASE64.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Output name for XML type ("append")
|
||||
virtual const char* name() const;
|
||||
@ -101,6 +101,7 @@ public:
|
||||
virtual uint64_t offset(const uint64_t numbytes);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -54,7 +54,7 @@ void Foam::vtk::appendRawFormatter::write
|
||||
|
||||
Foam::vtk::appendRawFormatter::appendRawFormatter(std::ostream& os)
|
||||
:
|
||||
formatter(os),
|
||||
vtk::formatter(os),
|
||||
offset_(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,7 +52,7 @@ namespace vtk
|
||||
|
||||
class appendRawFormatter
|
||||
:
|
||||
public formatter
|
||||
public vtk::formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -64,7 +64,12 @@ class appendRawFormatter
|
||||
uint64_t offset_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
//- No copy construct
|
||||
appendRawFormatter(const appendRawFormatter&) = delete;
|
||||
@ -73,20 +78,12 @@ class appendRawFormatter
|
||||
void operator=(const appendRawFormatter&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
appendRawFormatter(std::ostream& os);
|
||||
explicit appendRawFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -96,7 +93,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is APPEND_BINARY.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Output name for XML type ("append")
|
||||
virtual const char* name() const;
|
||||
@ -122,9 +119,9 @@ public:
|
||||
|
||||
//- A no-op for this format
|
||||
virtual void flush();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -68,7 +68,7 @@ inline void Foam::vtk::asciiFormatter::done()
|
||||
|
||||
Foam::vtk::asciiFormatter::asciiFormatter(std::ostream& os)
|
||||
:
|
||||
formatter(os),
|
||||
vtk::formatter(os),
|
||||
pos_(0)
|
||||
{}
|
||||
|
||||
@ -76,13 +76,13 @@ Foam::vtk::asciiFormatter::asciiFormatter(std::ostream& os)
|
||||
Foam::vtk::asciiFormatter::asciiFormatter
|
||||
(
|
||||
std::ostream& os,
|
||||
unsigned precision
|
||||
unsigned prec
|
||||
)
|
||||
:
|
||||
formatter(os),
|
||||
vtk::formatter(os),
|
||||
pos_(0)
|
||||
{
|
||||
os.precision(precision);
|
||||
os.precision(prec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,7 +54,7 @@ namespace vtk
|
||||
|
||||
class asciiFormatter
|
||||
:
|
||||
public formatter
|
||||
public vtk::formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -89,10 +89,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream, use default precision
|
||||
asciiFormatter(std::ostream& os);
|
||||
explicit asciiFormatter(std::ostream& os);
|
||||
|
||||
//- Construct and attach to an output stream, use specified precision
|
||||
asciiFormatter(std::ostream& os, unsigned precision);
|
||||
asciiFormatter(std::ostream& os, unsigned prec);
|
||||
|
||||
|
||||
//- Destructor. Finishes the output line as required.
|
||||
@ -102,7 +102,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is INLINE_ASCII.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Name for the XML output type ("ascii")
|
||||
virtual const char* name() const;
|
||||
@ -127,9 +127,9 @@ public:
|
||||
//- The encoded length for ascii output is not applicable.
|
||||
// \return 0
|
||||
virtual std::size_t encodedLength(std::size_t ignored) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -51,7 +51,7 @@ namespace vtk
|
||||
|
||||
class base64Formatter
|
||||
:
|
||||
public foamVtkBase64Layer
|
||||
public vtk::foamVtkBase64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -73,7 +73,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
base64Formatter(std::ostream& os);
|
||||
explicit base64Formatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor. Closes/flushes the underlying layer.
|
||||
@ -83,7 +83,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is INLINE_BASE64.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Name for the XML output type ("binary")
|
||||
virtual const char* name() const;
|
||||
@ -92,9 +92,9 @@ public:
|
||||
//- End the encoding sequence (padding the final characters with '=')
|
||||
// and write a newline to the output if any encoding was done.
|
||||
virtual void flush();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -41,7 +41,7 @@ void Foam::vtk::foamVtkBase64Layer::write
|
||||
std::streamsize n
|
||||
)
|
||||
{
|
||||
base64Layer::write(s, n);
|
||||
Foam::base64Layer::write(s, n);
|
||||
}
|
||||
|
||||
|
||||
@ -49,8 +49,8 @@ void Foam::vtk::foamVtkBase64Layer::write
|
||||
|
||||
Foam::vtk::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
||||
:
|
||||
formatter(os),
|
||||
base64Layer(os)
|
||||
vtk::formatter(os),
|
||||
Foam::base64Layer(os)
|
||||
{}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ Foam::vtk::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
||||
|
||||
Foam::vtk::foamVtkBase64Layer::~foamVtkBase64Layer()
|
||||
{
|
||||
base64Layer::close();
|
||||
Foam::base64Layer::close();
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ bool Foam::vtk::foamVtkBase64Layer::writeSize(const uint64_t numbytes)
|
||||
|
||||
void Foam::vtk::foamVtkBase64Layer::write(const uint8_t val)
|
||||
{
|
||||
base64Layer::add(val);
|
||||
Foam::base64Layer::add(val);
|
||||
}
|
||||
|
||||
|
||||
@ -120,13 +120,13 @@ void Foam::vtk::foamVtkBase64Layer::write(const double val)
|
||||
|
||||
void Foam::vtk::foamVtkBase64Layer::flush()
|
||||
{
|
||||
base64Layer::close();
|
||||
Foam::base64Layer::close();
|
||||
}
|
||||
|
||||
|
||||
std::size_t Foam::vtk::foamVtkBase64Layer::encodedLength(std::size_t n) const
|
||||
{
|
||||
return base64Layer::encodedLength(n);
|
||||
return Foam::base64Layer::encodedLength(n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -50,23 +50,14 @@ namespace vtk
|
||||
|
||||
class foamVtkBase64Layer
|
||||
:
|
||||
public formatter,
|
||||
protected base64Layer
|
||||
public vtk::formatter,
|
||||
protected Foam::base64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
static const char* encoding_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy construct
|
||||
foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
@ -74,11 +65,17 @@ protected:
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
//- No copy construct
|
||||
foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkBase64Layer(std::ostream& os);
|
||||
explicit foamVtkBase64Layer(std::ostream& os);
|
||||
|
||||
public:
|
||||
|
||||
@ -105,9 +102,9 @@ public:
|
||||
|
||||
//- The encoded length for base64 encoded output.
|
||||
virtual std::size_t encodedLength(std::size_t n) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -132,7 +132,7 @@ protected:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
inline formatter(std::ostream& os);
|
||||
inline explicit formatter(std::ostream& os);
|
||||
|
||||
|
||||
public:
|
||||
@ -155,10 +155,10 @@ public:
|
||||
// Access
|
||||
|
||||
//- Access to the underlying output stream
|
||||
inline std::ostream& os();
|
||||
inline std::ostream& os() noexcept;
|
||||
|
||||
//- The format-type / output options.
|
||||
virtual const outputOptions& opts() const = 0;
|
||||
virtual const vtk::outputOptions& opts() const = 0;
|
||||
|
||||
//- Name for the XML output type or the legacy output type.
|
||||
virtual const char* name() const = 0;
|
||||
@ -540,7 +540,6 @@ public:
|
||||
dataName, formatter::npos, true
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ inline Foam::vtk::formatter::formatter(std::ostream& os)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline std::ostream& Foam::vtk::formatter::os()
|
||||
inline std::ostream& Foam::vtk::formatter::os() noexcept
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
@ -50,10 +50,10 @@ Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
|
||||
Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
|
||||
(
|
||||
std::ostream& os,
|
||||
unsigned precision
|
||||
unsigned prec
|
||||
)
|
||||
:
|
||||
asciiFormatter(os, precision)
|
||||
asciiFormatter(os, prec)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,7 +53,7 @@ namespace vtk
|
||||
|
||||
class legacyAsciiFormatter
|
||||
:
|
||||
public asciiFormatter
|
||||
public vtk::asciiFormatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -75,10 +75,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream, use default precision
|
||||
legacyAsciiFormatter(std::ostream& os);
|
||||
explicit legacyAsciiFormatter(std::ostream& os);
|
||||
|
||||
//- Construct and attach to an output stream, use specified precision
|
||||
legacyAsciiFormatter(std::ostream& os, unsigned precision);
|
||||
legacyAsciiFormatter(std::ostream& os, unsigned prec);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -88,7 +88,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is LEGACY_ASCII.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Name for the legacy ascii output type ("ASCII")
|
||||
virtual const char* name() const;
|
||||
@ -107,9 +107,9 @@ public:
|
||||
inline virtual formatter& endPointData() { return *this; }
|
||||
inline virtual formatter& endPiece() { return *this; }
|
||||
inline virtual formatter& endVTKFile() { return *this; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -57,7 +57,7 @@ Foam::vtk::legacyRawFormatter::legacyRawFormatter
|
||||
std::ostream& os
|
||||
)
|
||||
:
|
||||
formatter(os)
|
||||
vtk::formatter(os)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -55,21 +55,12 @@ namespace vtk
|
||||
|
||||
class legacyRawFormatter
|
||||
:
|
||||
public formatter
|
||||
public vtk::formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
static const char* legacyName_;
|
||||
static const outputOptions opts_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy construct
|
||||
legacyRawFormatter(const legacyRawFormatter&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const legacyRawFormatter&) = delete;
|
||||
static const vtk::outputOptions opts_;
|
||||
|
||||
|
||||
protected:
|
||||
@ -79,13 +70,19 @@ protected:
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
//- No copy construct
|
||||
legacyRawFormatter(const legacyRawFormatter&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const legacyRawFormatter&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
legacyRawFormatter(std::ostream& os);
|
||||
explicit legacyRawFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -95,7 +92,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is LEGACY_BINARY.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Name for the legacy binary output type ("BINARY")
|
||||
virtual const char* name() const;
|
||||
@ -127,9 +124,9 @@ public:
|
||||
inline virtual formatter& endPointData() { return *this; }
|
||||
inline virtual formatter& endPiece() { return *this; }
|
||||
inline virtual formatter& endVTKFile() { return *this; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -254,11 +254,29 @@ namespace legacy
|
||||
//- Emit header for POINTS (with trailing newline).
|
||||
inline void beginPoints(std::ostream& os, label nPoints);
|
||||
|
||||
//- Emit header for VERTICES (with trailing newline).
|
||||
// The nConnectivity is the sum of all connectivity points used,
|
||||
// but \b without additional space for the size prefixes.
|
||||
// The additional prefix sizes are added internally.
|
||||
// \note With nConnectivity == 0, assume one point per element
|
||||
inline void beginVerts
|
||||
(
|
||||
std::ostream& os,
|
||||
label nVerts,
|
||||
label nConnectivity = 0
|
||||
);
|
||||
|
||||
//- Emit header for LINES (with trailing newline).
|
||||
// The nConnectivity is the sum of all connectivity points used,
|
||||
// but \b without additional space for the size prefixes.
|
||||
// The additional prefix sizes are added internally.
|
||||
inline void beginLines(std::ostream& os, label nLines, label nConnectivity);
|
||||
// \note With nConnectivity == 0, assume two points per element
|
||||
inline void beginLines
|
||||
(
|
||||
std::ostream& os,
|
||||
label nLines,
|
||||
label nConnectivity = 0
|
||||
);
|
||||
|
||||
//- Emit header for POLYGONS (with trailing newline).
|
||||
// The nConnectivity is the sum of all connectivity points used,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -119,6 +119,24 @@ inline void Foam::vtk::legacy::beginPoints(std::ostream& os, label nPoints)
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::vtk::legacy::beginVerts
|
||||
(
|
||||
std::ostream& os,
|
||||
label nVerts,
|
||||
label nConnectivity
|
||||
)
|
||||
{
|
||||
if (!nConnectivity)
|
||||
{
|
||||
nConnectivity = nVerts;
|
||||
}
|
||||
os << nl
|
||||
<< legacy::fileTagNames[vtk::fileTag::VERTS]
|
||||
<< ' ' << nVerts
|
||||
<< ' ' << (nVerts + nConnectivity) << nl;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::vtk::legacy::beginLines
|
||||
(
|
||||
std::ostream& os,
|
||||
@ -126,6 +144,10 @@ inline void Foam::vtk::legacy::beginLines
|
||||
label nConnectivity
|
||||
)
|
||||
{
|
||||
if (!nConnectivity)
|
||||
{
|
||||
nConnectivity = 2*nLines;
|
||||
}
|
||||
os << nl
|
||||
<< legacy::fileTagNames[vtk::fileTag::LINES]
|
||||
<< ' ' << nLines
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -61,15 +61,15 @@ class outputOptions
|
||||
{
|
||||
// Private Member Data
|
||||
|
||||
//- The output style tuning
|
||||
enum styleType
|
||||
{
|
||||
NONE = 0x00, //!< Normal
|
||||
HEADER = 0x01 //!< Emit xml header
|
||||
};
|
||||
/// //- The output style tuning
|
||||
/// enum styleType
|
||||
/// {
|
||||
/// NONE = 0x00, //!< Normal
|
||||
/// HEADER = 0x01 //!< Emit xml header
|
||||
/// };
|
||||
|
||||
//- The output format type
|
||||
formatType fmtType_;
|
||||
vtk::formatType fmtType_;
|
||||
|
||||
//- ASCII write precision
|
||||
mutable unsigned precision_;
|
||||
@ -79,15 +79,16 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null - XML insitu ASCII format with default precision
|
||||
//- Default construct - XML insitu ASCII format with default precision
|
||||
inline outputOptions();
|
||||
|
||||
//- Construct with specified format and default (ASCII) precision
|
||||
//
|
||||
// \note This constructor should remain non-explicit.
|
||||
inline outputOptions(enum formatType fmtType);
|
||||
inline outputOptions(enum vtk::formatType fmtType);
|
||||
|
||||
//- Construct with specified format and (ASCII) write precision
|
||||
inline outputOptions(enum formatType fmtType, unsigned prec);
|
||||
inline outputOptions(enum vtk::formatType fmtType, unsigned prec);
|
||||
|
||||
|
||||
// Selectors
|
||||
@ -101,28 +102,28 @@ public:
|
||||
// Access
|
||||
|
||||
//- The output format type
|
||||
inline formatType fmt() const;
|
||||
inline vtk::formatType fmt() const noexcept;
|
||||
|
||||
//- The file extension (legacy or xml) for the given content-type
|
||||
inline word ext(vtk::fileTag contentType) const;
|
||||
|
||||
//- True if writer uses legacy file format
|
||||
inline bool legacy() const;
|
||||
inline bool legacy() const noexcept;
|
||||
|
||||
//- True if writer uses XML file format (non-legacy)
|
||||
inline bool xml() const;
|
||||
inline bool xml() const noexcept;
|
||||
|
||||
//- True if output format uses an append mode
|
||||
inline bool append() const;
|
||||
inline bool append() const noexcept;
|
||||
|
||||
//- True if output format does not use an append mode
|
||||
inline bool insitu() const;
|
||||
inline bool insitu() const noexcept;
|
||||
|
||||
//- True if output format is ASCII
|
||||
inline bool ascii() const;
|
||||
inline bool ascii() const noexcept;
|
||||
|
||||
//- Return the ASCII write precision
|
||||
inline unsigned precision() const;
|
||||
inline unsigned precision() const noexcept;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,8 +25,6 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtkOutput.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::vtk::outputOptions::outputOptions()
|
||||
@ -38,7 +36,7 @@ inline Foam::vtk::outputOptions::outputOptions()
|
||||
|
||||
inline Foam::vtk::outputOptions::outputOptions
|
||||
(
|
||||
enum formatType fmtType
|
||||
enum vtk::formatType fmtType
|
||||
)
|
||||
:
|
||||
fmtType_(fmtType),
|
||||
@ -48,7 +46,7 @@ inline Foam::vtk::outputOptions::outputOptions
|
||||
|
||||
inline Foam::vtk::outputOptions::outputOptions
|
||||
(
|
||||
enum formatType fmtType,
|
||||
enum vtk::formatType fmtType,
|
||||
unsigned prec
|
||||
)
|
||||
:
|
||||
@ -68,7 +66,7 @@ Foam::vtk::outputOptions::newFormatter(std::ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::vtk::formatType Foam::vtk::outputOptions::fmt() const
|
||||
inline Foam::vtk::formatType Foam::vtk::outputOptions::fmt() const noexcept
|
||||
{
|
||||
return fmtType_;
|
||||
}
|
||||
@ -85,7 +83,7 @@ inline Foam::word Foam::vtk::outputOptions::ext(vtk::fileTag contentType) const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::vtk::outputOptions::legacy() const
|
||||
inline bool Foam::vtk::outputOptions::legacy() const noexcept
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -95,13 +93,13 @@ inline bool Foam::vtk::outputOptions::legacy() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::vtk::outputOptions::xml() const
|
||||
inline bool Foam::vtk::outputOptions::xml() const noexcept
|
||||
{
|
||||
return !legacy();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::vtk::outputOptions::append() const
|
||||
inline bool Foam::vtk::outputOptions::append() const noexcept
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -111,19 +109,19 @@ inline bool Foam::vtk::outputOptions::append() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::vtk::outputOptions::insitu() const
|
||||
inline bool Foam::vtk::outputOptions::insitu() const noexcept
|
||||
{
|
||||
return !append();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::vtk::outputOptions::ascii() const
|
||||
inline bool Foam::vtk::outputOptions::ascii() const noexcept
|
||||
{
|
||||
return !(unsigned(fmtType_) & 0x0F);
|
||||
}
|
||||
|
||||
|
||||
inline unsigned Foam::vtk::outputOptions::precision() const
|
||||
inline unsigned Foam::vtk::outputOptions::precision() const noexcept
|
||||
{
|
||||
return precision_;
|
||||
}
|
||||
|
||||
@ -67,6 +67,7 @@ void Foam::vtk::polyWriter::beginPiece
|
||||
{
|
||||
// Basic sizes
|
||||
nLocalPoints_ = points.size();
|
||||
nLocalVerts_ = 0;
|
||||
nLocalLines_ = edges.size();
|
||||
nLocalPolys_ = 0;
|
||||
|
||||
@ -104,6 +105,7 @@ void Foam::vtk::polyWriter::beginPiece
|
||||
{
|
||||
// Basic sizes
|
||||
nLocalPoints_ = points.size();
|
||||
nLocalVerts_ = 0;
|
||||
nLocalLines_ = 0;
|
||||
nLocalPolys_ = faces.size();
|
||||
|
||||
@ -568,6 +570,7 @@ Foam::vtk::polyWriter::polyWriter
|
||||
numberOfPoints_(0),
|
||||
numberOfCells_(0),
|
||||
nLocalPoints_(0),
|
||||
nLocalVerts_(0),
|
||||
nLocalLines_(0),
|
||||
nLocalPolys_(0)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -82,6 +82,9 @@ protected:
|
||||
//- Local number of points
|
||||
label nLocalPoints_;
|
||||
|
||||
//- Local number of vertices (points)
|
||||
label nLocalVerts_;
|
||||
|
||||
//- Local number of lines (edges)
|
||||
label nLocalLines_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user