27 "Reads Gocad ascii files (*.ts, *.pl, *.mx) and writes TSurf- and PLine"
28 "data into one or more VTU unstructured grids.\n\n"
29 "OpenGeoSys-6 software, version " +
32 "Copyright (c) 2012-2021, OpenGeoSys Community "
33 "(http://www.opengeosys.org)",
36 TCLAP::SwitchArg write_binary_arg(
38 "if set, OGS-Meshes will be written in binary format");
39 cmd.add(write_binary_arg);
41 TCLAP::SwitchArg export_surfaces_arg(
43 "if set, only TSurf datasets will be parsed from the input file");
44 cmd.add(export_surfaces_arg);
46 TCLAP::SwitchArg export_lines_arg(
48 "if set, only PLine datasets will be parsed from the input file");
49 cmd.add(export_lines_arg);
51 TCLAP::ValueArg<std::string> output_arg(
52 "o",
"output-dir",
"output directory",
true,
"",
"output dir");
55 TCLAP::ValueArg<std::string> input_arg(
57 "Gocad triangular surfaces file (*.ts). Provide a file with unix file "
58 "endings under unix. Use dos2unix to convert. ",
59 true,
"",
"filename.ts");
62 cmd.parse(argc, argv);
64 if (export_lines_arg.isSet() && export_surfaces_arg.isSet())
66 ERR(
"Both the 'lines-only'-flag and 'surfaces-only'-flag are set. Only "
67 "one is allowed at a time.");
71 std::string
const file_name(input_arg.getValue());
74 if (export_lines_arg.isSet())
78 if (export_surfaces_arg.isSet())
82 std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
85 ERR(
"Error reading file.");
88 INFO(
"{:d} meshes found.", meshes.size());
89 std::string
const dir = output_arg.getValue();
90 bool const write_binary = write_binary_arg.getValue();
91 std::string
const delim =
getDelim(dir);
92 for (
auto& mesh : meshes)
98 INFO(
"Writing mesh \"{:s}\"", mesh->getName());
99 int data_mode = (write_binary) ? 2 : 0;
100 bool compressed = (write_binary);
102 vtu.writeToFile(dir + delim + mesh->getName() +
".vtu");
std::string getDelim(std::string const &str)
void INFO(char const *fmt, Args const &... args)
void ERR(char const *fmt, Args const &... args)
Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures....
bool readFile(std::string const &file_name, std::vector< std::unique_ptr< MeshLib::Mesh >> &meshes, DataType const export_type)
Reads the specified file and writes data into internal mesh vector.
GITINFOLIB_EXPORT const std::string ogs_version