diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index bb5e356a0e..2e21915df2 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -173,6 +173,7 @@ triSurface/triSurfaceSearch/triSurfaceSearch.C triSurface/triSurfaceSearch/triSurfaceRegionSearch.C triSurface/triangleFuncs/triangleFuncs.C triSurface/surfaceFeatures/surfaceFeatures.C +triSurface/triSurfaceLoader/triSurfaceLoader.C triSurface/triSurfaceTools/triSurfaceTools.C triSurface/triSurfaceTools/geompack/geompack.C triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C diff --git a/src/meshTools/triSurface/triSurfaceLoader/triSurfaceLoader.C b/src/meshTools/triSurface/triSurfaceLoader/triSurfaceLoader.C new file mode 100644 index 0000000000..d5e6d4d8e7 --- /dev/null +++ b/src/meshTools/triSurface/triSurfaceLoader/triSurfaceLoader.C @@ -0,0 +1,262 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "triSurfaceLoader.H" +#include "fileNameList.H" +#include "Time.H" +#include "OSspecific.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::triSurfaceLoader::triSurfaceLoader(const fileName& directory) +: + directory_(directory), + available_(), + selected_() +{ + readDir(); +} + + +Foam::triSurfaceLoader::triSurfaceLoader(const Time& runTime) +: + directory_(runTime.constantPath()/"triSurface"), + available_(), + selected_() +{ + readDir(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::triSurfaceLoader::~triSurfaceLoader() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::label Foam::triSurfaceLoader::readDir() +{ + fileNameList files = Foam::readDir(directory_, fileName::FILE); + + // Will be using triSurface + // + // - filter according to what is supported + // + // Transform from fileName to word and eliminate duplicates + // (eg, files with/without .gz) + wordHashSet names(2*files.size()); + + forAll(files, filei) + { + const fileName& f = files[filei]; + if (triSurface::canRead(f)) + { + names.insert(f.name()); + } + } + available_ = names.sortedToc(); // Also hashes the names + + return available_.size(); +} + + +Foam::label Foam::triSurfaceLoader::selectAll() +{ + selected_ = available_; + return selected_.size(); +} + + +Foam::label Foam::triSurfaceLoader::select(const word& name) +{ + if (available_.found(name)) + { + selected_ = wordList{name}; // hashedWordList::operator[] is hidden! + } + else + { + selected_.clear(); + } + + return selected_.size(); +} + + +Foam::label Foam::triSurfaceLoader::select(const wordRe& mat) +{ + DynamicList