ENH: provide canRead, canWrite tests for triSurface

- for symmetry with MeshedSurface etc.
This commit is contained in:
Mark Olesen
2017-03-08 13:15:28 +01:00
parent 7d3eb76f75
commit 8060792b92
2 changed files with 79 additions and 0 deletions

View File

@ -32,6 +32,7 @@ License
#include "SortableList.H"
#include "PackedBoolList.H"
#include "surfZoneList.H"
#include "surfaceFormatsCore.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -41,6 +42,69 @@ namespace Foam
}
// Note that these lists are a stop-gap measure until the read/write handling
// gets properly updated
const Foam::wordHashSet Foam::triSurface::readTypes_
{
"ftr", "stl", "stlb", "gts", "obj", "off", "tri", "ac", "nas", "vtk"
};
const Foam::wordHashSet Foam::triSurface::writeTypes_
{
"ftr", "stl", "stlb", "gts", "obj", "off", "tri", "ac", "smesh", "vtk"
};
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
bool Foam::triSurface::canReadType(const word& ext, const bool verbose)
{
return fileFormats::surfaceFormatsCore::checkSupport
(
readTypes(),
ext,
verbose,
"reading"
);
}
bool Foam::triSurface::canWriteType(const word& ext, const bool verbose)
{
return fileFormats::surfaceFormatsCore::checkSupport
(
writeTypes(),
ext,
verbose,
"writing"
);
}
bool Foam::triSurface::canRead(const fileName& name, const bool verbose)
{
word ext = name.ext();
if (ext == "gz")
{
ext = name.lessExt().ext();
}
return canReadType(ext, verbose);
}
const Foam::wordHashSet& Foam::triSurface::readTypes()
{
return readTypes_;
}
const Foam::wordHashSet& Foam::triSurface::writeTypes()
{
return writeTypes_;
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::fileName Foam::triSurface::triSurfInstance(const Time& d)

View File

@ -90,6 +90,9 @@ class triSurface
// during reading and writing)
geometricSurfacePatchList patches_;
static const wordHashSet readTypes_;
static const wordHashSet writeTypes_;
// Demand driven private data.
@ -240,6 +243,18 @@ public:
//- Name of triSurface directory to use.
static fileName triSurfInstance(const Time&);
//- Can we read this file format?
static bool canRead(const fileName& name, const bool verbose=false);
//- Can we read this file format?
static bool canReadType(const word& ext, const bool verbose=false);
//- Can we write this file format?
static bool canWriteType(const word& ext, const bool verbose=false);
static const wordHashSet& readTypes();
static const wordHashSet& writeTypes();
// Constructors