diff --git a/src/triSurface/triSurface/triSurface.C b/src/triSurface/triSurface/triSurface.C index 2ea0e6eea8..a95013c858 100644 --- a/src/triSurface/triSurface/triSurface.C +++ b/src/triSurface/triSurface/triSurface.C @@ -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) diff --git a/src/triSurface/triSurface/triSurface.H b/src/triSurface/triSurface/triSurface.H index e320bbfdfd..33265d95d3 100644 --- a/src/triSurface/triSurface/triSurface.H +++ b/src/triSurface/triSurface/triSurface.H @@ -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