diff --git a/applications/utilities/surface/surfaceFeatureExtract/Make/options b/applications/utilities/surface/surfaceFeatureExtract/Make/options index e57de43f22..b79e3e27c5 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/Make/options +++ b/applications/utilities/surface/surfaceFeatureExtract/Make/options @@ -1,9 +1,11 @@ EXE_INC = \ + -IextractionMethod/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude EXE_LIBS = \ + -lsurfaceFeatureExtract \ -lmeshTools \ -lsampling diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/Make/files b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/Make/files new file mode 100644 index 0000000000..29dd2b73eb --- /dev/null +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/Make/files @@ -0,0 +1,6 @@ +method = . +$(method)/surfaceFeaturesExtraction.C +$(method)/extractFromSurface.C +$(method)/extractFromFile.C + +LIB = $(FOAM_LIBBIN)/libsurfaceFeatureExtract diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/Make/options b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/Make/options new file mode 100644 index 0000000000..322709bfff --- /dev/null +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/Make/options @@ -0,0 +1,11 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/edgeMesh/lnInclude \ + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude + +LIB_LIBS = \ + -lmeshTools \ + -ledgeMesh \ + -ltriSurface diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromFile.C b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromFile.C new file mode 100644 index 0000000000..437024fbac --- /dev/null +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromFile.C @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ 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 "extractFromFile.H" +#include "ListOps.H" +#include "edgeMesh.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace surfaceFeaturesExtraction +{ + addNamedToRunTimeSelectionTable + ( + method, + extractFromFile, + dictionary, + extractFromFile + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::surfaceFeaturesExtraction::extractFromFile::extractFromFile +( + const dictionary& dict +) +: + method() +{ + const dictionary& coeffDict = dict.subDict("extractFromFileCoeffs"); + + coeffDict.lookup("featureEdgeFile") >> featureEdgeFile_; + coeffDict.readIfPresent("geometricTestOnly", geometricTestOnly_); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::surfaceFeaturesExtraction::extractFromFile::~extractFromFile() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +Foam::autoPtr +Foam::surfaceFeaturesExtraction::extractFromFile::features +( + const triSurface& surf +) const +{ + edgeMesh eMesh(featureEdgeFile_); + + // Sometimes duplicate edges are present. Remove them. + eMesh.mergeEdges(); + + Info<< nl << "Reading existing feature edges from file " + << featureEdgeFile_ << nl + << "Selecting edges based purely on geometric tests: " + << geometricTestOnly().asText() << endl; + + return autoPtr + ( + new surfaceFeatures + ( + surf, + eMesh.points(), + eMesh.edges(), + 1e-6, // mergeTol + geometricTestOnly() + ) + ); +} + + +// ************************************************************************* // diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromFile.H b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromFile.H new file mode 100644 index 0000000000..bca148439f --- /dev/null +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromFile.H @@ -0,0 +1,90 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ 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::surfaceFeaturesExtraction::extractFromFile + +Description + Run-time selectable surface feature extraction. + +SourceFiles + extractionMethod.C + +\*---------------------------------------------------------------------------*/ + +#ifndef surfaceFeaturesExtraction_extractFromFile_H +#define surfaceFeaturesExtraction_extractFromFile_H + +#include "surfaceFeaturesExtraction.H" +#include "dictionary.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace surfaceFeaturesExtraction +{ + +/*---------------------------------------------------------------------------*\ + Class surfaceFeaturesExtraction::extractFromFile Declaration +\*---------------------------------------------------------------------------*/ + +class extractFromFile +: + public method +{ + fileName featureEdgeFile_; + + +public: + + // Constructors + + //- Construct from dictionary + extractFromFile(const dictionary& dict); + + + //- Destructor + virtual ~extractFromFile(); + + + //- Extracted features from surface + virtual autoPtr features + ( + const triSurface& surf + ) const override; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace surfaceFeaturesExtraction +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromSurface.C b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromSurface.C new file mode 100644 index 0000000000..f590bb707a --- /dev/null +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromSurface.C @@ -0,0 +1,102 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ 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 "extractFromSurface.H" +#include "addToRunTimeSelectionTable.H" + +#include "triSurface.H" +#include "triSurfaceSearch.H" +#include "scalarField.H" +#include "edgeIntersections.H" + + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace surfaceFeaturesExtraction +{ + addNamedToRunTimeSelectionTable + ( + method, + extractFromSurface, + dictionary, + extractFromSurface + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::surfaceFeaturesExtraction::extractFromSurface::extractFromSurface +( + const dictionary& dict +) +: + method() +{ + const dictionary& coeffDict = dict.subDict("extractFromSurfaceCoeffs"); + + coeffDict.lookup("includedAngle") >> includedAngle_; + coeffDict.readIfPresent("geometricTestOnly", geometricTestOnly_); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::surfaceFeaturesExtraction::extractFromSurface::~extractFromSurface() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +Foam::autoPtr +Foam::surfaceFeaturesExtraction::extractFromSurface::features +( + const triSurface& surf +) const +{ + Info<< nl << "Constructing feature set from included angle " + << includedAngle() << nl + << "Selecting edges based purely on geometric tests: " + << geometricTestOnly().asText() << endl; + + return autoPtr + ( + new surfaceFeatures + ( + surf, + includedAngle(), + 0, // minLen + 0, // minElems + geometricTestOnly() + ) + ); +} + + +// ************************************************************************* // diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromSurface.H b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromSurface.H new file mode 100644 index 0000000000..980db47b14 --- /dev/null +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/extractFromSurface.H @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ 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::surfaceFeaturesExtraction::extractFromSurface + +Description + Run-time selectable surface feature extraction. + +SourceFiles + extractionMethod.C + +\*---------------------------------------------------------------------------*/ + +#ifndef surfaceFeaturesExtraction_extractFromSurface_H +#define surfaceFeaturesExtraction_extractFromSurface_H + +#include "surfaceFeaturesExtraction.H" +#include "dictionary.H" +#include "Switch.H" +#include "triSurface.H" +#include "edgeIntersections.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace surfaceFeaturesExtraction +{ + +/*---------------------------------------------------------------------------*\ + Class surfaceFeaturesExtraction::extractFromSurface Declaration +\*---------------------------------------------------------------------------*/ + +class extractFromSurface +: + public method +{ + + bool selfIntersection_; + + +public: + + // Constructors + + //- Construct from dictionary + extractFromSurface(const dictionary& dict); + + + //- Destructor + virtual ~extractFromSurface(); + + + //- Extracted features from surface + virtual autoPtr features + ( + const triSurface& surf + ) const override; + + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace surfaceFeaturesExtraction +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.C b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.C new file mode 100644 index 0000000000..95a1c1b028 --- /dev/null +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.C @@ -0,0 +1,92 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ 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 "surfaceFeaturesExtraction.H" +#include "dictionary.H" +#include "ListOps.H" +#include "error.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace surfaceFeaturesExtraction +{ + defineTypeName(method); + defineRunTimeSelectionTable + ( + method, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::surfaceFeaturesExtraction::method::method() +: + includedAngle_(0), + geometricTestOnly_(Switch::NO) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::surfaceFeaturesExtraction::method::~method() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::autoPtr +Foam::surfaceFeaturesExtraction::method::New +( + const dictionary& dict +) +{ + const word methodName = dict.lookup("extractionMethod"); + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(methodName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorInFunction + ( + dict + ) << "Unknown extractionMethod " + << methodName << nl << nl + << "Valid extraction methods: :" << nl + << flatOutput(dictionaryConstructorTablePtr_->sortedToc()) + << exit(FatalIOError); + } + + return autoPtr(cstrIter()(dict)); +} + + +// ************************************************************************* // diff --git a/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.H b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.H new file mode 100644 index 0000000000..6f9482144f --- /dev/null +++ b/applications/utilities/surface/surfaceFeatureExtract/extractionMethod/surfaceFeaturesExtraction.H @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ 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::surfaceFeaturesExtraction::method + +Description + Run-time selectable surface feature extraction methods. + +SourceFiles + surfaceFeaturesExtraction.C + +\*---------------------------------------------------------------------------*/ + +#ifndef surfaceFeaturesExtraction_method_H +#define surfaceFeaturesExtraction_method_H + +#include "surfaceFeatures.H" +#include "dictionary.H" +#include "Switch.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace surfaceFeaturesExtraction +{ + +/*---------------------------------------------------------------------------*\ + Class surfaceFeaturesExtraction::method Declaration +\*---------------------------------------------------------------------------*/ + +class method +{ +protected: + + scalar includedAngle_; + Switch geometricTestOnly_; + + //- Construct null + method(); + + +public: + + //- Runtime type information + ClassNameNoDebug("method"); + + + // Constructors + + //- Construct from dictionary + method(const dictionary& dict); + + + // Declare run-time constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + method, + dictionary, + ( + const dictionary& dict + ), + (dict) + ); + + + // Selectors + + //- Select constructed from dictionary + static autoPtr New + ( + const dictionary& dict + ); + + + //- Destructor + virtual ~method(); + + + // Member Functions + + //- The included angle, if set + inline scalar includedAngle() const + { + return includedAngle_; + } + + //- Use geometric test only + inline Switch geometricTestOnly() const + { + return geometricTestOnly_; + } + + //- Extracted features + virtual autoPtr features + ( + const triSurface& surf + ) const = 0; + +}; + + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace surfaceFeaturesExtraction +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index a91ed5140a..9dcaae6b63 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +41,8 @@ Description #include "argList.H" #include "Time.H" #include "triSurface.H" -#include "surfaceFeatures.H" +#include "surfaceFeaturesExtraction.H" +#include "surfaceIntersection.H" #include "featureEdgeMesh.H" #include "extendedFeatureEdgeMesh.H" #include "treeBoundBox.H" @@ -865,6 +866,61 @@ void writeStats(const extendedFeatureEdgeMesh& fem, Ostream& os) } +// Read and combine all surfaces into a single one + +autoPtr loadSurfaces(Time& runTime, const wordList& surfNames) +{ + List faces; + pointField points; + label regoff = 0; // region offset + + forAll(surfNames, surfi) + { + const word& surfName = surfNames[surfi]; + + triSurface addsurf(runTime.constantPath()/"triSurface"/surfName); + + List addfaces(addsurf.xferFaces()); + List addpoints(addsurf.xferPoints()); + + if (surfi) + { + const label ptoff = points.size(); // point offset + + forAll(addfaces, facei) + { + labelledTri& f = addfaces[facei]; + forAll(f, fi) + { + f[fi] += ptoff; + } + f.region() += regoff; + } + + faces.append(addfaces); + points.append(addpoints); + } + else + { + faces.transfer(addfaces); + points.transfer(addpoints); + } + + regoff += addsurf.patches().size(); + } + + return autoPtr + ( + new triSurface + ( + faces, + geometricSurfacePatchList(), + points, + true + ) + ); +} + int main(int argc, char *argv[]) { @@ -873,6 +929,7 @@ int main(int argc, char *argv[]) "extract and write surface features to file" ); argList::noParallel(); + argList::noFunctionObjects(); #include "addDictOption.H" @@ -882,6 +939,21 @@ int main(int argc, char *argv[]) const word dictName("surfaceFeatureExtractDict"); #include "setSystemRunTimeDictionaryIO.H" + // Will be using triSurface, so filter according to what is supported + fileNameList validSurfaceFiles = readDir + ( + runTime.path()/runTime.constant()/"triSurface", + fileName::FILE + ); + inplaceSubsetList + ( + validSurfaceFiles, + [](const fileName& f){ return triSurface::canRead(f); } + ); + + // sort and eliminate duplicates (eg, files with/without .gz) + inplaceUniqueSort(validSurfaceFiles); + Info<< "Reading " << dictName << nl << endl; const IOdictionary dict(dictIO); @@ -900,132 +972,132 @@ int main(int argc, char *argv[]) continue; } - const word extractionMethod = surfaceDict.lookup("extractionMethod"); + autoPtr extractPtr = + surfaceFeaturesExtraction::method::New + ( + surfaceDict + ); - const fileName surfFileName = iter().keyword(); - const fileName sFeatFileName = surfFileName.lessExt().name(); + const surfaceFeaturesExtraction::method& extract = extractPtr(); - Info<< "Surface : " << surfFileName << nl << endl; + // Output name, cleansed of extensions + const word sFeatFileName = + fileName + ( + surfaceDict.lookupOrDefault("output", iter().keyword()) + ).lessExt(); - const Switch writeVTK = - surfaceDict.lookupOrDefault("writeVTK", "off"); - const Switch writeObj = - surfaceDict.lookupOrDefault("writeObj", "off"); + wordList surfFileNames; - const Switch curvature = - surfaceDict.lookupOrDefault("curvature", "off"); - const Switch featureProximity = - surfaceDict.lookupOrDefault("featureProximity", "off"); - const Switch closeness = - surfaceDict.lookupOrDefault("closeness", "off"); + if + ( + iter().keyword() == "surfaces" // mandatory + || surfaceDict.found("surfaces") // or optional + ) + { + wordReList regexs(surfaceDict.lookup("surfaces")); + labelList selected = findStrings(regexs, validSurfaceFiles); + surfFileNames.setSize(selected.size()); + forAll(selected, i) + { + surfFileNames[i] = validSurfaceFiles[selected[i]].name(); + } + + if (surfFileNames.empty()) + { + FatalErrorInFunction + << "No surfaces specified/found for entry: " + << iter().keyword() + << exit(FatalError); + } + } + else + { + surfFileNames.setSize(1); + surfFileNames[0] = iter().keyword(); + + const fileName file + ( + runTime.constantPath()/"triSurface"/surfFileNames[0] + ); + + if (!isFile(file)) + { + FatalErrorInFunction + << "No surface: " << file.name() + << exit(FatalError); + } + } + + // DebugVar(surfFileNames); + // DebugVar(sFeatFileName); + + Info<< "Surfaces : "; + if (surfFileNames.size() == 1) + { + Info<< surfFileNames[0] << nl; + } + else + { + Info<< flatOutput(surfFileNames) << nl; + } + + Info<< "Output : " << sFeatFileName << nl; + + const Switch writeVTK = surfaceDict.lookupOrDefault + ( + "writeVTK", Switch::OFF + ); + const Switch writeObj = surfaceDict.lookupOrDefault + ( + "writeObj", Switch::OFF + ); + + const Switch curvature = surfaceDict.lookupOrDefault + ( + "curvature", Switch::OFF + ); + const Switch featureProximity = surfaceDict.lookupOrDefault + ( + "featureProximity", Switch::OFF + ); + const Switch closeness = surfaceDict.lookupOrDefault + ( + "closeness", Switch::OFF + ); + + Info<< "write VTK: " << writeVTK << nl; Info<< nl << "Feature line extraction is only valid on closed manifold " << "surfaces." << endl; - // Read - // ~~~~ - triSurface surf(runTime.constantPath()/"triSurface"/surfFileName); + // Read and combine all surfaces into a single one + + autoPtr surfPtr = loadSurfaces(runTime, surfFileNames); + triSurface surf = surfPtr(); Info<< "Statistics:" << endl; surf.writeStats(Info); Info<< endl; - faceList faces(surf.size()); - - forAll(surf, fI) + // need plain faces if outputting VTK format + faceList faces; + if (writeVTK) { - faces[fI] = surf[fI].triFaceFace(); + faces.setSize(surf.size()); + forAll(surf, fi) + { + faces[fi] = surf[fi].triFaceFace(); + } } // Either construct features from surface & featureAngle or read set. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - autoPtr set; - - scalar includedAngle = 0.0; - - if (extractionMethod == "extractFromFile") - { - const dictionary& extractFromFileDict = - surfaceDict.subDict("extractFromFileCoeffs"); - - const fileName featureEdgeFile = - extractFromFileDict.lookup("featureEdgeFile"); - - const Switch geometricTestOnly = - extractFromFileDict.lookupOrDefault - ( - "geometricTestOnly", - "no" - ); - - edgeMesh eMesh(featureEdgeFile); - - // Sometimes duplicate edges are present. Remove them. - eMesh.mergeEdges(); - - Info<< nl << "Reading existing feature edges from file " - << featureEdgeFile << nl - << "Selecting edges purely based on geometric tests: " - << geometricTestOnly.asText() << endl; - - set.set - ( - new surfaceFeatures - ( - surf, - eMesh.points(), - eMesh.edges(), - 1e-6, - geometricTestOnly - ) - ); - } - else if (extractionMethod == "extractFromSurface") - { - const dictionary& extractFromSurfaceDict = - surfaceDict.subDict("extractFromSurfaceCoeffs"); - - includedAngle = - readScalar(extractFromSurfaceDict.lookup("includedAngle")); - - const Switch geometricTestOnly = - extractFromSurfaceDict.lookupOrDefault - ( - "geometricTestOnly", - "no" - ); - - Info<< nl - << "Constructing feature set from included angle " - << includedAngle << nl - << "Selecting edges purely based on geometric tests: " - << geometricTestOnly.asText() << endl; - - set.set - ( - new surfaceFeatures - ( - surf, - includedAngle, - 0, - 0, - geometricTestOnly - ) - ); - } - else - { - FatalErrorInFunction - << "No initial feature set. Provide either one" - << " of extractFromFile (to read existing set)" << nl - << " or extractFromSurface (to construct new set from angle)" - << exit(FatalError); - } - + autoPtr set = extract.features(surf); // Trim set // ~~~~~~~~ @@ -1033,21 +1105,27 @@ int main(int argc, char *argv[]) if (surfaceDict.isDict("trimFeatures")) { dictionary trimDict = surfaceDict.subDict("trimFeatures"); - - scalar minLen = + const scalar minLen = trimDict.lookupOrAddDefault("minLen", -GREAT); - label minElem = trimDict.lookupOrAddDefault