/*---------------------------------------------------------------------------*\ ========= | \\ / 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" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // const Foam::Enum Foam::triSurfaceLoader::loadingOptionNames ( SINGLE_REGION, { "single", "file", "offset", "merge" } ); // * * * * * * * * * * * * * * * * 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