18int main(
int argc,
char* argv[])
21 "Adds a layer to an existing mesh."
22 "The documentation is available at "
23 "https://www.opengeosys.org/docs/tools/meshing/addlayer."
25 "OpenGeoSys-6 software, version " +
28 "Copyright (c) 2012-2026, OpenGeoSys Community "
29 "(https://www.opengeosys.org)",
31 TCLAP::ValueArg<std::string> mesh_arg(
"i",
"input-mesh-file",
32 "Input (.vtu). The name of the file "
33 "containing the mesh",
34 true,
"",
"INPUT_FILE");
37 TCLAP::ValueArg<std::string> mesh_out_arg(
38 "o",
"output-mesh-file",
39 "Output (.vtu). The name of the file the mesh should be written to",
40 true,
"",
"OUTPUT_FILE");
41 cmd.add(mesh_out_arg);
43 TCLAP::ValueArg<double> layer_thickness_arg(
44 "t",
"layer-tickness",
45 "the thickness of the new layer, "
47 false, 10,
"LAYER_THICKNESS");
48 cmd.add(layer_thickness_arg);
50 TCLAP::SwitchArg layer_position_arg(
51 "",
"add-layer-on-bottom",
52 "Per default the layer is add on the top, if this argument is set the "
53 "layer is add on the bottom.",
55 cmd.add(layer_position_arg);
57 TCLAP::SwitchArg copy_material_ids_arg(
58 "",
"copy-material-ids",
59 "Copy the existing material distribution of the layer which is to be "
60 "extended. If the switch isn't given a new material id will be "
63 cmd.add(copy_material_ids_arg);
65 TCLAP::ValueArg<int> set_material_arg(
66 "",
"set-material-id",
"the material id of the new layer, (min = 0)",
67 false, 0,
"MATERIAL_ID");
68 cmd.add(set_material_arg);
70 cmd.add(log_level_arg);
71 cmd.parse(argc, argv);
76 if (set_material_arg.isSet() && copy_material_ids_arg.isSet())
78 ERR(
"It is not possible to set both options '--copy-material-ids' and "
79 "'--set-material-id'.");
83 INFO(
"Reading mesh '{:s}' ... ", mesh_arg.getValue());
84 auto subsfc_mesh = std::unique_ptr<MeshLib::Mesh>(
88 ERR(
"Error reading mesh '{:s}'.", mesh_arg.getValue());
93 std::optional<int> layer_id;
94 if (set_material_arg.isSet())
96 layer_id = set_material_arg.getValue();
100 *subsfc_mesh, layer_thickness_arg.getValue(), mesh_out_arg.getValue(),
101 layer_position_arg.getValue(), copy_material_ids_arg.getValue(),
105 ERR(
"Failure while adding layer.");
109 INFO(
"Writing mesh '{:s}' ... ", mesh_out_arg.getValue());