OGS 6.2.1-97-g73d1aeda3
readGeometryFromFile.cpp
Go to the documentation of this file.
1 
11 #include "readGeometryFromFile.h"
12 
13 #include <vector>
14 
15 #include "BaseLib/Error.h"
16 #include "BaseLib/FileTools.h"
17 
19 #include "Legacy/OGSIOVer4.h"
20 
21 #include "GeoLib/GEOObjects.h"
22 
23 namespace FileIO
24 {
25 void readGeometryFromFile(std::string const& fname,
26  GeoLib::GEOObjects& geo_objs,
27  std::string const& gmsh_path)
28 {
29  if (BaseLib::getFileExtension(fname) == "gml")
30  {
32  xml.readFile(fname);
33  } else {
34  std::vector<std::string> errors;
35  std::string geo_name; // geo_name is output of the reading function
37  fname, geo_objs, geo_name, errors, gmsh_path);
38  }
39 
40  std::vector<std::string> geo_names;
41  geo_objs.getGeometryNames(geo_names);
42  if (geo_names.empty()) {
43  OGS_FATAL("GEOObjects has no geometry name after reading the geometry file. "
44  "Something is wrong in the reading function.");
45  }
46 }
47 } // namespace FileIO
Container class for geometric objects.
Definition: GEOObjects.h:62
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
Definition of the BoostXmlGmlInterface class.
void getGeometryNames(std::vector< std::string > &names) const
Returns the names of all geometry vectors.
Definition: GEOObjects.cpp:412
Definition of the OGSIOVer4 class.
bool readFile(const std::string &fname) override
Reads an xml-file containing OGS geometry.
std::string getFileExtension(const std::string &path)
Definition: FileTools.cpp:132
bool readGLIFileV4(const std::string &fname, GeoLib::GEOObjects &geo, std::string &unique_name, std::vector< std::string > &errors, std::string const &gmsh_path)
Definition: OGSIOVer4.cpp:478
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
Filename manipulation routines.