OGS
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 #include "GeoLib/GEOObjects.h"
19 #include "Legacy/OGSIOVer4.h"
20 
21 namespace FileIO
22 {
23 void readGeometryFromFile(std::string const& fname,
24  GeoLib::GEOObjects& geo_objs,
25  std::string const& gmsh_path)
26 {
27  if (BaseLib::getFileExtension(fname) == ".gml")
28  {
30  xml.readFile(fname);
31  }
32  else
33  {
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  if (geo_objs.getGeometryNames().empty())
41  {
42  OGS_FATAL(
43  "GEOObjects has no geometry name after reading the geometry file. "
44  "Something is wrong in the reading function.");
45  }
46 }
47 } // namespace FileIO
Definition of the BoostXmlGmlInterface class.
#define OGS_FATAL(...)
Definition: Error.h:26
Filename manipulation routines.
Definition of the GEOObjects class.
Definition of the OGSIOVer4 class.
Container class for geometric objects.
Definition: GEOObjects.h:61
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
Definition: GEOObjects.cpp:401
bool readFile(const std::string &fname) override
Reads an xml-file containing OGS geometry.
std::string getFileExtension(const std::string &path)
Definition: FileTools.cpp:186
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:506
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)