26int main(
int argc,
char* argv[])
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 " +
35 "Copyright (c) 2012-2025, OpenGeoSys Community "
36 "(http://www.opengeosys.org)",
41 TCLAP::ValueArg<std::string> mesh_arg(
"m",
"mesh",
"Input (.vtu) mesh file",
42 true,
"",
"INPUT_FILE");
48 TCLAP::ValueArg<double> x_arg(
"x",
"x",
"displacement in x direction",
49 false, 0.0,
"DISPLACEMENT_X");
51 TCLAP::ValueArg<double> y_arg(
"y",
"y",
"displacement in y direction",
52 false, 0.0,
"DISPLACEMENT_Y");
54 TCLAP::ValueArg<double> z_arg(
"z",
"z",
"displacement in z direction",
55 false, 0.0,
"DISPLACEMENT_Z");
58 TCLAP::ValueArg<std::string> mesh_out_arg(
"o",
"output-mesh",
59 "Output (.vtu) mesh file",
false,
61 cmd.add(mesh_out_arg);
63 cmd.parse(argc, argv);
66 std::string fname(mesh_arg.getValue());
72 ERR(
"Could not read mesh from file '{:s}'.", fname);
76 Eigen::Vector3d displacement{x_arg.getValue(), y_arg.getValue(),
78 if (fabs(x_arg.getValue()) < std::numeric_limits<double>::epsilon() &&
79 fabs(y_arg.getValue()) < std::numeric_limits<double>::epsilon() &&
80 fabs(z_arg.getValue()) < std::numeric_limits<double>::epsilon())
82 GeoLib::AABB aabb(mesh->getNodes().begin(), mesh->getNodes().end());
84 displacement = -(max + min) / 2.0;
87 INFO(
"translate model ({:f}, {:f}, {:f}).",
92 mesh->getNodes().end(), displacement);
94 std::string out_fname(mesh_out_arg.getValue());
95 if (out_fname.empty())
98 out_fname +=
"_displaced.vtu";