21int main(
int argc,
char* argv[])
24 "Reads Gocad ascii files (*.ts, *.pl, *.mx) and writes TSurf- and PLine"
25 "data into one or more VTU unstructured grids.\n\n"
26 "OpenGeoSys-6 software, version " +
29 "Copyright (c) 2012-2026, OpenGeoSys Community "
30 "(http://www.opengeosys.org)",
33 TCLAP::SwitchArg write_binary_arg(
35 "if set, OGS-Meshes will be written in binary format");
36 cmd.add(write_binary_arg);
38 TCLAP::SwitchArg export_surfaces_arg(
40 "if set, only TSurf datasets will be parsed from the input file");
41 cmd.add(export_surfaces_arg);
43 TCLAP::SwitchArg export_lines_arg(
45 "if set, only PLine datasets will be parsed from the input file");
46 cmd.add(export_lines_arg);
48 TCLAP::ValueArg<std::string> output_arg(
49 "o",
"output-dir",
"Output directory",
true,
"",
"OUTPUT_PATH");
52 TCLAP::ValueArg<std::string> input_arg(
54 "Input (.ts | .pl | .mx). Gocad triangular surfaces file"
55 "Provide a file with unix file "
56 "endings under unix. Use dos2unix to convert. ",
57 true,
"",
"INPUT_FILE");
59 cmd.add(log_level_arg);
62 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 const data_mode = write_binary ? 2 : 0;
103 bool const compressed = write_binary;
105 dir + delim + mesh->getName() +
".vtu",
106 {}, compressed, data_mode) != 0)
108 ERR(
"Could not write mesh '{:s}'.", mesh->getName());
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > output_variable_names, bool const use_compression, int const data_mode)