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