ENH: update vtk reading to handle new legacy format (#2094)

- with the changes in vtkCellArray, the legacy files now have
  OFFSET, CONNECTIVITY information.

- support reading of both versions.

- continue to generate legacy format 2.0, since this is what
  many programs still expect
This commit is contained in:
Mark Olesen
2021-05-28 21:15:13 +02:00
parent 82cc00b153
commit 6c4a1b17ad
4 changed files with 548 additions and 319 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,50 +27,26 @@ License
\*---------------------------------------------------------------------------*/
#include "vtkUnstructuredReader.H"
#include "labelIOField.H"
#include "scalarIOField.H"
#include "stringIOList.H"
#include "cellModel.H"
#include "vectorIOField.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
void Foam::vtkUnstructuredReader::readBlock
(
Istream& inFile,
const label n,
List<T>& list
) const
{
list.setSize(n);
for (T& val : list)
{
inFile >> val;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkUnstructuredReader::printFieldStats
(
const objectRegistry& obj
) const
void Foam::vtkUnstructuredReader::printFieldStats(const objectRegistry& obj)
{
wordList fieldNames(obj.names(Type::typeName));
const wordList fieldNames(obj.names(Type::typeName));
if (fieldNames.size())
{
Info<< "Read " << fieldNames.size() << " " << Type::typeName
Info<< "Read " << fieldNames.size() << ' ' << Type::typeName
<< " fields:" << nl
<< "Size\tName" << nl
<< "----\t----" << endl;
<< "----\t----" << nl;
for (const word& fieldName : fieldNames)
{
Info<< obj.lookupObject<Type>(fieldName).size()
<< "\t" << fieldName
<< endl;
<< '\t' << fieldName
<< nl;
}
Info<< endl;
}