21{
22 TCLAP::CmdLine cmd(
23 "Moves the mesh nodes using the given displacement vector or if no "
24 "displacement vector is given, moves the mesh nodes such that the "
25 "centroid of the given mesh is in the origin.\n\n"
26 "OpenGeoSys-6 software, version " +
28 ".\n"
29 "Copyright (c) 2012-2026, OpenGeoSys Community "
30 "(http://www.opengeosys.org)",
32
33
34
35 TCLAP::ValueArg<std::string> mesh_arg("m", "mesh", "Input (.vtu) mesh file",
36 true, "", "INPUT_FILE");
37
38
39
40 cmd.add(mesh_arg);
41
42 TCLAP::ValueArg<double> x_arg("x", "x", "displacement in x direction",
43 false, 0.0, "DISPLACEMENT_X");
44 cmd.add(x_arg);
45 TCLAP::ValueArg<double> y_arg("y", "y", "displacement in y direction",
46 false, 0.0, "DISPLACEMENT_Y");
47 cmd.add(y_arg);
48 TCLAP::ValueArg<double> z_arg("z", "z", "displacement in z direction",
49 false, 0.0, "DISPLACEMENT_Z");
50 cmd.add(z_arg);
51
52 TCLAP::ValueArg<std::string> mesh_out_arg("o", "output-mesh",
53 "Output (.vtu) mesh file", false,
54 "", "OUTPUT_FILE");
55 cmd.add(mesh_out_arg);
56
58 cmd.add(log_level_arg);
59 cmd.parse(argc, argv);
60
63
64 std::string fname(mesh_arg.getValue());
65
67
68 if (!mesh)
69 {
70 ERR(
"Could not read mesh from file '{:s}'.", fname);
71 return EXIT_FAILURE;
72 }
73
74 Eigen::Vector3d displacement{x_arg.getValue(), y_arg.getValue(),
75 z_arg.getValue()};
76 if (fabs(x_arg.getValue()) < std::numeric_limits<double>::epsilon() &&
77 fabs(y_arg.getValue()) < std::numeric_limits<double>::epsilon() &&
78 fabs(z_arg.getValue()) < std::numeric_limits<double>::epsilon())
79 {
80 GeoLib::AABB aabb(mesh->getNodes().begin(), mesh->getNodes().end());
81 auto const [min, max] = aabb.getMinMaxPoints();
82 displacement = -(max + min) / 2.0;
83 }
84
85 INFO(
"translate model ({:f}, {:f}, {:f}).",
86 displacement[0],
87 displacement[1],
88 displacement[2]);
90 mesh->getNodes().end(), displacement);
91
92 std::string out_fname(mesh_out_arg.getValue());
93 if (out_fname.empty())
94 {
96 out_fname += "_displaced.vtu";
97 }
98
100
101 return EXIT_SUCCESS;
102}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
std::string dropFileExtension(std::string const &filename)
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, std::set< std::string > variable_output_names)