27int main(
int argc,
char* argv[])
30 "Reads Gocad ascii files (*.ts, *.pl, *.mx) and writes TSurf- and PLine"
31 "data into one or more VTU unstructured grids.\n\n"
32 "OpenGeoSys-6 software, version " +
35 "Copyright (c) 2012-2025, OpenGeoSys Community "
36 "(http://www.opengeosys.org)",
39 TCLAP::SwitchArg write_binary_arg(
41 "if set, OGS-Meshes will be written in binary format");
42 cmd.add(write_binary_arg);
44 TCLAP::SwitchArg export_surfaces_arg(
46 "if set, only TSurf datasets will be parsed from the input file");
47 cmd.add(export_surfaces_arg);
49 TCLAP::SwitchArg export_lines_arg(
51 "if set, only PLine datasets will be parsed from the input file");
52 cmd.add(export_lines_arg);
54 TCLAP::ValueArg<std::string> output_arg(
55 "o",
"output-dir",
"Output directory",
true,
"",
"OUTPUT_PATH");
58 TCLAP::ValueArg<std::string> input_arg(
60 "Input (.ts | .pl | .mx). Gocad triangular surfaces file"
61 "Provide a file with unix file "
62 "endings under unix. Use dos2unix to convert. ",
63 true,
"",
"INPUT_FILE");
65 cmd.add(log_level_arg);
68 cmd.parse(argc, argv);
73 if (export_lines_arg.isSet() && export_surfaces_arg.isSet())
75 ERR(
"Both the 'lines-only'-flag and 'surfaces-only'-flag are set. Only "
76 "one is allowed at a time.");
80 std::string
const file_name(input_arg.getValue());
83 if (export_lines_arg.isSet())
87 if (export_surfaces_arg.isSet())
91 std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
94 ERR(
"Error reading file.");
97 INFO(
"{:d} meshes found.", meshes.size());
98 std::string
const dir = output_arg.getValue();
99 bool const write_binary = write_binary_arg.getValue();
100 std::string
const delim =
getDelim(dir);
101 for (
auto& mesh : meshes)
107 INFO(
"Writing mesh \"{:s}\"", mesh->getName());
108 int data_mode = (write_binary) ? 2 : 0;
109 bool compressed = (write_binary);
111 vtu.
writeToFile(dir + delim + mesh->getName() +
".vtu");