14{
15 TCLAP::CmdLine cmd(
16 "Moves the points of a geometry by a given displacement vector\n\n"
17 "OpenGeoSys-6 software, version " +
19 ".\n"
20 "Copyright (c) 2012-2026, OpenGeoSys Community "
21 "(http://www.opengeosys.org)",
23 TCLAP::ValueArg<double> z_arg("z", "z", "displacement in z direction",
24 false, 0.0, "Z-DISPLACEMENT");
25 cmd.add(z_arg);
26 TCLAP::ValueArg<double> y_arg("y", "y", "displacement in y direction",
27 false, 0.0, "Y-DISPLACEMENT");
28 cmd.add(y_arg);
29 TCLAP::ValueArg<double> x_arg("x", "x", "displacement in x direction",
30 false, 0.0, "X-DISPLACEMENT");
31 cmd.add(x_arg);
32 TCLAP::ValueArg<std::string> geo_output_arg(
33 "o", "output", "Output (.gml) geometry file", true, "", "OUTPUT_FILE");
34 cmd.add(geo_output_arg);
35 TCLAP::ValueArg<std::string> geo_input_arg(
36 "i", "input", "Input (.gml) geometry file", true, "", "INPUT_FILE");
37 cmd.add(geo_input_arg);
39 cmd.add(log_level_arg);
40 cmd.parse(argc, argv);
41
44
47 try
48 {
49 if (!xml.readFile(geo_input_arg.getValue()))
50 {
51 return EXIT_FAILURE;
52 }
53 }
54 catch (std::runtime_error const& err)
55 {
56 ERR(
"Failed to read file `{:s}'.", geo_input_arg.getValue());
57 ERR(
"{:s}", err.what());
58 return EXIT_FAILURE;
59 }
60
61 Eigen::Vector3d displacement = Eigen::Vector3d::Zero();
62 if (x_arg.isSet())
63 {
64 displacement[0] = x_arg.getValue();
65 }
66 if (y_arg.isSet())
67 {
68 displacement[1] = y_arg.getValue();
69 }
70 if (z_arg.isSet())
71 {
72 displacement[2] = z_arg.getValue();
73 }
74
76
77 std::vector<GeoLib::Point*> const* point_vec =
79 std::size_t const n_points = point_vec->size();
80 for (std::size_t i = 0; i < n_points; ++i)
81 {
82 for (std::size_t c = 0;
c < 3; ++
c)
83 {
84 (*(*point_vec)[i])[c] += displacement[c];
85 }
86 }
87
88 xml.export_name = geo_name;
90 geo_output_arg.getValue());
91
92 return EXIT_SUCCESS;
93}
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)
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
GITINFOLIB_EXPORT const std::string ogs_version