swh:1:snp:6088ab52ef49920e01e3f334cdf4d5d6c8a822b9
Raw File
Tip revision: 35ea153a962408d9ba530abb9d1ad2d635cd2a4a authored by Lars Bilke on 07 October 2021, 09:58:43 UTC
Merge branch 'update-xdmf' into 'master'
Tip revision: 35ea153
readGeometryFromFile.cpp
/**
 *
 * \copyright
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#include "readGeometryFromFile.h"

#include <vector>

#include "BaseLib/Error.h"
#include "BaseLib/FileTools.h"
#include "GeoLib/GEOObjects.h"
#include "GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h"
#include "Legacy/OGSIOVer4.h"

namespace FileIO
{
void readGeometryFromFile(std::string const& fname,
                          GeoLib::GEOObjects& geo_objs,
                          std::string const& gmsh_path)
{
    if (BaseLib::getFileExtension(fname) == ".gml")
    {
        GeoLib::IO::BoostXmlGmlInterface xml(geo_objs);
        xml.readFile(fname);
    }
    else
    {
        std::vector<std::string> errors;
        std::string geo_name;  // geo_name is output of the reading function
        FileIO::Legacy::readGLIFileV4(
            fname, geo_objs, geo_name, errors, gmsh_path);
    }

    if (geo_objs.getGeometryNames().empty())
    {
        OGS_FATAL(
            "GEOObjects has no geometry name after reading the geometry file. "
            "Something is wrong in the reading function.");
    }
}
}  // namespace FileIO
back to top