25int main(
int argc,
char* argv[])
28 "Reads Gocad ascii files (*.ts, *.pl, *.mx) and writes TSurf- and PLine"
29 "data into one or more VTU unstructured grids.\n\n"
30 "OpenGeoSys-6 software, version " +
33 "Copyright (c) 2012-2024, OpenGeoSys Community "
34 "(http://www.opengeosys.org)",
37 TCLAP::SwitchArg write_binary_arg(
39 "if set, OGS-Meshes will be written in binary format");
40 cmd.add(write_binary_arg);
42 TCLAP::SwitchArg export_surfaces_arg(
44 "if set, only TSurf datasets will be parsed from the input file");
45 cmd.add(export_surfaces_arg);
47 TCLAP::SwitchArg export_lines_arg(
49 "if set, only PLine datasets will be parsed from the input file");
50 cmd.add(export_lines_arg);
52 TCLAP::ValueArg<std::string> output_arg(
53 "o",
"output-dir",
"output directory",
true,
"",
"output dir");
56 TCLAP::ValueArg<std::string> input_arg(
58 "Gocad triangular surfaces file (*.ts). Provide a file with unix file "
59 "endings under unix. Use dos2unix to convert. ",
60 true,
"",
"filename.ts");
63 cmd.parse(argc, argv);
67 if (export_lines_arg.isSet() && export_surfaces_arg.isSet())
69 ERR(
"Both the 'lines-only'-flag and 'surfaces-only'-flag are set. Only "
70 "one is allowed at a time.");
74 std::string
const file_name(input_arg.getValue());
77 if (export_lines_arg.isSet())
81 if (export_surfaces_arg.isSet())
85 std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
88 ERR(
"Error reading file.");
91 INFO(
"{:d} meshes found.", meshes.size());
92 std::string
const dir = output_arg.getValue();
93 bool const write_binary = write_binary_arg.getValue();
94 std::string
const delim =
getDelim(dir);
95 for (
auto& mesh : meshes)
101 INFO(
"Writing mesh \"{:s}\"", mesh->getName());
102 int data_mode = (write_binary) ? 2 : 0;
103 bool compressed = (write_binary);
105 vtu.
writeToFile(dir + delim + mesh->getName() +
".vtu");