23{
24 TCLAP::CmdLine cmd(
25 "Moves the points of a geometry by a given displacement vector\n\n"
26 "OpenGeoSys-6 software, version " +
28 ".\n"
29 "Copyright (c) 2012-2024, OpenGeoSys Community "
30 "(http://www.opengeosys.org)",
32 TCLAP::ValueArg<double> z_arg("z", "z", "displacement in z direction",
33 false, 0.0, "z-displacement");
34 cmd.add(z_arg);
35 TCLAP::ValueArg<double> y_arg("y", "y", "displacement in y direction",
36 false, 0.0, "y-displacement");
37 cmd.add(y_arg);
38 TCLAP::ValueArg<double> x_arg("x", "x", "displacement in x direction",
39 false, 0.0, "x-displacement");
40 cmd.add(x_arg);
41 TCLAP::ValueArg<std::string> geo_output_arg(
42 "o", "output", "output geometry file (*.gml)", true, "", "output file");
43 cmd.add(geo_output_arg);
44 TCLAP::ValueArg<std::string> geo_input_arg(
45 "i", "input", "input geometry file (*.gml)", true, "", "input file");
46 cmd.add(geo_input_arg);
47 cmd.parse(argc, argv);
48
50
53 try
54 {
55 if (!xml.readFile(geo_input_arg.getValue()))
56 {
57 return EXIT_FAILURE;
58 }
59 }
60 catch (std::runtime_error const& err)
61 {
62 ERR(
"Failed to read file `{:s}'.", geo_input_arg.getValue());
63 ERR(
"{:s}", err.what());
64 return EXIT_FAILURE;
65 }
66
67 Eigen::Vector3d displacement = Eigen::Vector3d::Zero();
68 if (x_arg.isSet())
69 {
70 displacement[0] = x_arg.getValue();
71 }
72 if (y_arg.isSet())
73 {
74 displacement[1] = y_arg.getValue();
75 }
76 if (z_arg.isSet())
77 {
78 displacement[2] = z_arg.getValue();
79 }
80
82
83 std::vector<GeoLib::Point*> const* point_vec =
85 std::size_t const n_points = point_vec->size();
86 for (std::size_t i = 0; i < n_points; ++i)
87 {
88 for (std::size_t c = 0;
c < 3; ++
c)
89 {
90 (*(*point_vec)[i])[c] += displacement[c];
91 }
92 }
93
94 xml.export_name = geo_name;
96 geo_output_arg.getValue());
97
98 return EXIT_SUCCESS;
99}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Container class for geometric objects.
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
const std::vector< Point * > * getPointVec(const std::string &name) const
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
GITINFOLIB_EXPORT const std::string ogs_version