27{
28 TCLAP::CmdLine cmd(
29 "Moves the mesh nodes using the given displacement vector or if no "
30 "displacement vector is given, moves the mesh nodes such that the "
31 "centroid of the given mesh is in the origin.\n\n"
32 "OpenGeoSys-6 software, version " +
34 ".\n"
35 "Copyright (c) 2012-2024, OpenGeoSys Community "
36 "(http://www.opengeosys.org)",
38
39
40
41 TCLAP::ValueArg<std::string> mesh_arg("m", "mesh", "input mesh file", true,
42 "", "string");
43
44
45
46 cmd.add(mesh_arg);
47
48 TCLAP::ValueArg<double> x_arg("x", "x", "displacement in x direction",
49 false, 0.0, "floating point number");
50 cmd.add(x_arg);
51 TCLAP::ValueArg<double> y_arg("y", "y", "displacement in y direction",
52 false, 0.0, "floating point number");
53 cmd.add(y_arg);
54 TCLAP::ValueArg<double> z_arg("z", "z", "displacement in z direction",
55 false, 0.0, "floating point number");
56 cmd.add(z_arg);
57
58 TCLAP::ValueArg<std::string> mesh_out_arg(
59 "o", "output-mesh", "output mesh file", false, "", "string");
60 cmd.add(mesh_out_arg);
61
62 cmd.parse(argc, argv);
63
65 std::string fname(mesh_arg.getValue());
66
68
69 if (!mesh)
70 {
71 ERR(
"Could not read mesh from file '{:s}'.", fname);
72 return EXIT_FAILURE;
73 }
74
75 Eigen::Vector3d displacement{x_arg.getValue(), y_arg.getValue(),
76 z_arg.getValue()};
77 if (fabs(x_arg.getValue()) < std::numeric_limits<double>::epsilon() &&
78 fabs(y_arg.getValue()) < std::numeric_limits<double>::epsilon() &&
79 fabs(z_arg.getValue()) < std::numeric_limits<double>::epsilon())
80 {
81 GeoLib::AABB aabb(mesh->getNodes().begin(), mesh->getNodes().end());
82 auto const [min, max] = aabb.getMinMaxPoints();
83 displacement = -(max + min) / 2.0;
84 }
85
86 INFO(
"translate model ({:f}, {:f}, {:f}).",
87 displacement[0],
88 displacement[1],
89 displacement[2]);
91 mesh->getNodes().end(), displacement);
92
93 std::string out_fname(mesh_out_arg.getValue());
94 if (out_fname.empty())
95 {
97 out_fname += "_displaced.vtu";
98 }
99
101
102 return EXIT_SUCCESS;
103}
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 ...
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)