OGS
convertGEO.cpp File Reference
#include <tclap/CmdLine.h>
#include <string>
#include <vector>
#include "Applications/FileIO/readGeometryFromFile.h"
#include "Applications/FileIO/writeGeometryToFile.h"
#include "GeoLib/GEOObjects.h"
#include "InfoLib/GitInfo.h"
Include dependency graph for convertGEO.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 20 of file convertGEO.cpp.

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-2021, 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 }
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
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

References GeoLib::GEOObjects::getGeometryNames(), GitInfoLib::GitInfo::ogs_version, FileIO::readGeometryFromFile(), and FileIO::writeGeometryToFile().