24int main(
int argc,
char* argv[])
27 "Adds a layer to an existing mesh."
28 "The documentation is available at "
29 "https://www.opengeosys.org/docs/tools/meshing/addlayer."
31 "OpenGeoSys-6 software, version " +
34 "Copyright (c) 2012-2024, OpenGeoSys Community "
35 "(https://www.opengeosys.org)",
37 TCLAP::ValueArg<std::string> mesh_arg(
38 "i",
"input-mesh-file",
"the name of the file containing the mesh",
39 true,
"",
"file name");
42 TCLAP::ValueArg<std::string> mesh_out_arg(
43 "o",
"output-mesh-file",
44 "the name of the file the mesh should be written to (vtu format)",
true,
46 cmd.add(mesh_out_arg);
48 TCLAP::ValueArg<double> layer_thickness_arg(
49 "t",
"layer-tickness",
"the thickness of the new layer",
false, 10,
50 "floating point value");
51 cmd.add(layer_thickness_arg);
53 TCLAP::SwitchArg layer_position_arg(
54 "",
"add-layer-on-bottom",
55 "Per default the layer is add on the top, if this argument is set the "
56 "layer is add on the bottom.",
58 cmd.add(layer_position_arg);
60 TCLAP::SwitchArg copy_material_ids_arg(
61 "",
"copy-material-ids",
62 "Copy the existing material distribution of the layer which is to be "
63 "extended. If the switch isn't given a new material id will be "
66 cmd.add(copy_material_ids_arg);
68 TCLAP::ValueArg<int> set_material_arg(
"",
"set-material-id",
69 "the material id of the new layer",
70 false, 0,
"integer value");
71 cmd.add(set_material_arg);
72 cmd.parse(argc, argv);
74 if (set_material_arg.isSet() && copy_material_ids_arg.isSet())
76 ERR(
"It is not possible to set both options '--copy-material-ids' and "
77 "'--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());