OGS
convertGEO.cpp
Go to the documentation of this file.
1 
10 #include <tclap/CmdLine.h>
11 
12 #include <string>
13 #include <vector>
14 
17 #include "GeoLib/GEOObjects.h"
18 #include "InfoLib/GitInfo.h"
19 
20 int main(int argc, char* argv[])
21 {
22  TCLAP::CmdLine cmd(
23  "Converts OGS geometry file into another file format. "
24  "Currently *.gml (OGS6 XML-based format) and *.gli (OGS5 format) "
25  "formats are supported.\n\n"
26  "OpenGeoSys-6 software, version " +
28  ".\n"
29  "Copyright (c) 2012-2022, OpenGeoSys Community "
30  "(http://www.opengeosys.org)",
32  TCLAP::ValueArg<std::string> argInputFileName(
33  "i", "input-file", "the name of the geometry file to be converted",
34  true, "", "file name");
35  cmd.add(argInputFileName);
36  TCLAP::ValueArg<std::string> argOutputFileName(
37  "o", "output-file",
38  "the name of the new geometry file whose file format is guessed from "
39  "its file extension",
40  true, "", "file name");
41  cmd.add(argOutputFileName);
42 
43  TCLAP::ValueArg<std::string> gmsh_path_arg("g", "gmsh-path",
44  "the path to the gmsh binary",
45  false, "", "path as string");
46  cmd.add(gmsh_path_arg);
47  cmd.parse(argc, argv);
48 
49  GeoLib::GEOObjects geoObjects;
50  FileIO::readGeometryFromFile(argInputFileName.getValue(), geoObjects,
51  gmsh_path_arg.getValue());
52  auto const geo_names = geoObjects.getGeometryNames();
53  assert(geo_names.size() == 1);
54 
55  FileIO::writeGeometryToFile(geo_names[0], geoObjects,
56  argOutputFileName.getValue());
57 
58  return EXIT_SUCCESS;
59 }
Definition of the GEOObjects class.
Git information.
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:342
int main(int argc, char *argv[])
Definition: convertGEO.cpp:20
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
void writeGeometryToFile(std::string const &geo_name, GeoLib::GEOObjects &geo_objs, std::string const &fname)
GITINFOLIB_EXPORT const std::string ogs_version