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