OGS
readGeometryFromFile.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <vector>
7
8#include "BaseLib/Error.h"
9#include "BaseLib/FileTools.h"
10#include "GeoLib/GEOObjects.h"
12#include "Legacy/OGSIOVer4.h"
13
14namespace FileIO
15{
16void readGeometryFromFile(std::string const& fname,
17 GeoLib::GEOObjects& geo_objs,
18 std::string const& gmsh_path)
19{
20 if (BaseLib::getFileExtension(fname) == ".gml")
21 {
23 xml.readFile(fname);
24 }
25 else
26 {
27 std::vector<std::string> errors;
28 std::string geo_name; // geo_name is output of the reading function
30 fname, geo_objs, geo_name, errors, gmsh_path);
31 }
32
33 if (geo_objs.getGeometryNames().empty())
34 {
36 "GEOObjects has no geometry name after reading the geometry file. "
37 "Something is wrong in the reading function.");
38 }
39}
40} // namespace FileIO
#define OGS_FATAL(...)
Definition Error.h:19
Container class for geometric objects.
Definition GEOObjects.h:46
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
bool readFile(const std::string &fname) override
Reads an xml-file containing OGS geometry.
std::string getFileExtension(const std::string &path)
bool readGLIFileV4(const std::string &fname, GeoLib::GEOObjects &geo, std::string &unique_name, std::vector< std::string > &errors, std::string const &gmsh_path)
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)