From a494b17e98cc8a24f5cba1f2c7991a171bd95391 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 18 Dec 2013 12:08:42 +0000 Subject: [PATCH] ENH: extendedEdgeMesh: check for support --- src/edgeMesh/Make/files | 2 - .../extendedEdgeMesh/extendedEdgeMesh.C | 63 ++++++++++ .../extendedEdgeMesh/extendedEdgeMesh.H | 12 ++ .../obj/OBJextendedEdgeFormat.C | 66 ---------- .../obj/OBJextendedEdgeFormat.H | 119 ------------------ .../obj/OBJextendedEdgeFormatRunTime.C | 60 --------- 6 files changed, 75 insertions(+), 247 deletions(-) delete mode 100644 src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.C delete mode 100644 src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.H delete mode 100644 src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormatRunTime.C diff --git a/src/edgeMesh/Make/files b/src/edgeMesh/Make/files index ed4cec5d95..0438dd204e 100644 --- a/src/edgeMesh/Make/files +++ b/src/edgeMesh/Make/files @@ -35,8 +35,6 @@ eem = $(em)/extendedEdgeMesh $(eem)/extendedEdgeMesh.C $(eem)/extendedEdgeMeshNew.C -$(eem)/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.C -$(eem)/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormatRunTime.C $(eem)/extendedEdgeMeshFormats/extendedEdgeMeshFormat/extendedEdgeMeshFormat.C $(eem)/extendedEdgeMeshFormats/extendedEdgeMeshFormat/extendedEdgeMeshFormatRunTime.C diff --git a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C b/src/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C index 999d2f0651..5ac41224e3 100644 --- a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C +++ b/src/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C @@ -30,6 +30,7 @@ License #include "Time.H" #include "OBJstream.H" #include "DynamicField.H" +#include "edgeMeshFormatsCore.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -104,6 +105,68 @@ Foam::label Foam::extendedEdgeMesh::nPointTypes = 4; Foam::label Foam::extendedEdgeMesh::nEdgeTypes = 5; +Foam::wordHashSet Foam::extendedEdgeMesh::readTypes() +{ + return wordHashSet(*fileExtensionConstructorTablePtr_); +} + + +Foam::wordHashSet Foam::extendedEdgeMesh::writeTypes() +{ + return wordHashSet(*writefileExtensionMemberFunctionTablePtr_); +} + + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +bool Foam::extendedEdgeMesh::canReadType +( + const word& ext, + const bool verbose +) +{ + return edgeMeshFormatsCore::checkSupport + ( + readTypes(), + ext, + verbose, + "reading" + ); +} + + +bool Foam::extendedEdgeMesh::canWriteType +( + const word& ext, + const bool verbose +) +{ + return edgeMeshFormatsCore::checkSupport + ( + writeTypes(), + ext, + verbose, + "writing" + ); +} + + +bool Foam::extendedEdgeMesh::canRead +( + const fileName& name, + const bool verbose +) +{ + word ext = name.ext(); + if (ext == "gz") + { + ext = name.lessExt().ext(); + } + return canReadType(ext, verbose); +} + + // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // Foam::extendedEdgeMesh::pointStatus diff --git a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.H b/src/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.H index 2648321888..58e2ba8cab 100644 --- a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.H +++ b/src/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.H @@ -225,6 +225,18 @@ public: //- Number of possible feature edge types (i.e. number of slices) static label nEdgeTypes; + //- Can we read this file format? + static bool canRead(const fileName&, 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 type? + static bool canWriteType(const word& ext, const bool verbose=false); + + static wordHashSet readTypes(); + static wordHashSet writeTypes(); + // Constructors diff --git a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.C b/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.C deleted file mode 100644 index d63ad27ed9..0000000000 --- a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.C +++ /dev/null @@ -1,66 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation - \\/ 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 "OBJextendedEdgeFormat.H" -#include "OBJedgeFormat.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::fileFormats::OBJextendedEdgeFormat::OBJextendedEdgeFormat -( - const fileName& filename -) -{ - read(filename); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::fileFormats::OBJextendedEdgeFormat::read(const fileName& filename) -{ - edgeMesh em(filename); - - clear(); - - // Note: should transfer here instead - storedPoints() = em.points(); - storedEdges() = em.edges(); - - return true; -} - - -void Foam::fileFormats::OBJextendedEdgeFormat::write -( - const fileName& filename, - const extendedEdgeMesh& mesh -) -{ - OBJedgeFormat::write(filename, mesh); -} - - -// ************************************************************************* // diff --git a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.H b/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.H deleted file mode 100644 index a65409f446..0000000000 --- a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormat.H +++ /dev/null @@ -1,119 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation - \\/ 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::fileFormats::OBJextendedEdgeFormat - -Description - Provide a means of reading/writing Alias/Wavefront OBJ format. - - Does not handle negative vertex indices. - -SourceFiles - OBJextendedEdgeFormat.C - -\*---------------------------------------------------------------------------*/ - -#ifndef OBJextendedEdgeFormat_H -#define OBJextendedEdgeFormat_H - -#include "extendedEdgeMesh.H" -//#include "IFstream.H" -//#include "Ostream.H" -#include "OFstream.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace fileFormats -{ - -/*---------------------------------------------------------------------------*\ - Class OBJextendedEdgeFormat Declaration -\*---------------------------------------------------------------------------*/ - -class OBJextendedEdgeFormat -: - public extendedEdgeMesh -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - OBJextendedEdgeFormat(const OBJextendedEdgeFormat&); - - //- Disallow default bitwise assignment - void operator=(const OBJextendedEdgeFormat&); - - -public: - - // Constructors - - //- Construct from file name - OBJextendedEdgeFormat(const fileName&); - - -// // Selectors -// -// //- Read file and return surface -// static autoPtr New(const fileName& name) -// { -// return autoPtr -// ( -// new OBJextendedEdgeFormat(name) -// ); -// } -// - - //- Destructor - virtual ~OBJextendedEdgeFormat() - {} - - - // Member Functions - - //- Write surface mesh components by proxy - static void write(const fileName&, const extendedEdgeMesh&); - - //- Read from file - virtual bool read(const fileName&); - - //- Write object file - virtual void write(const fileName& name) const - { - write(name, *this); - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fileFormats -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormatRunTime.C b/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormatRunTime.C deleted file mode 100644 index c88513a104..0000000000 --- a/src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/obj/OBJextendedEdgeFormatRunTime.C +++ /dev/null @@ -1,60 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation - \\/ 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 "OBJextendedEdgeFormat.H" - -#include "addToRunTimeSelectionTable.H" -#include "addToMemberFunctionSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -namespace fileFormats -{ - -// read extendedEdgeMesh -addNamedToRunTimeSelectionTable -( - extendedEdgeMesh, - OBJextendedEdgeFormat, - fileExtension, - obj -); - -//// write extendedEdgeMesh -//addNamedToMemberFunctionSelectionTable -//( -// extendedEdgeMesh, -// OBJextendedEdgeFormat, -// write, -// fileExtension, -// obj -//); - -} -} - -// ************************************************************************* //