10#include <tclap/CmdLine.h>
28 std::array<int, 3>
const& new_axes_indices)
30 double new_coords[3] = {};
33 for (
int i = 0; i < 3; i++)
35 new_coords[i] = (*node)[new_axes_indices[i]];
37 for (
int i = 0; i < 3; i++)
39 (*node)[i] = new_coords[i];
45 std::array<int, 3>& new_axes_indices)
47 if (str_order.length() != 3)
49 ERR(
"Invalid argument for the new order. The argument should contain "
54 new_axes_indices.fill(-1);
56 for (
int i = 0; i < 3; i++)
58 if (str_order[i] ==
'x')
60 new_axes_indices[i] = 0;
62 else if (str_order[i] ==
'y')
64 new_axes_indices[i] = 1;
66 else if (str_order[i] ==
'z')
68 new_axes_indices[i] = 2;
72 ERR(
"Invalid argument for the new order. The given argument "
73 "contains a character other than 'x', 'y', 'z'.");
78 bool isAxisSet[3] = {
false};
79 for (
int new_axes_indice : new_axes_indices)
81 if (isAxisSet[new_axes_indice])
83 ERR(
"Invalid argument for the new order. The argument contains "
84 "some character used more than once.");
87 isAxisSet[new_axes_indice] =
true;
93int main(
int argc,
char* argv[])
96 "Swap node coordinate values.\n\n"
97 "OpenGeoSys-6 software, version " +
100 "Copyright (c) 2012-2024, OpenGeoSys Community "
101 "(http://www.opengeosys.org)",
103 TCLAP::ValueArg<std::string> input_arg(
104 "i",
"input-mesh-file",
"input mesh file",
true,
"",
"string");
106 TCLAP::ValueArg<std::string> output_arg(
107 "o",
"output-mesh-file",
"output mesh file",
true,
"",
"string");
109 TCLAP::ValueArg<std::string> new_order_arg(
111 "the new order of swapped coordinate values (e.g. 'xzy' for converting "
112 "XYZ values to XZY values)",
114 cmd.add(new_order_arg);
115 cmd.parse(argc, argv);
118 MPI_Init(&argc, &argv);
121 const std::string str_order = new_order_arg.getValue();
122 std::array<int, 3> new_order = {{}};
131 std::unique_ptr<MeshLib::Mesh> mesh(
141 if (mesh->getDimension() == 3)
144 "Swapping coordinate values of 3D elements can result in incorrect "
148 INFO(
"Exchange node coordinates from xyz to {:s}",
149 new_order_arg.getValue().data());
152 INFO(
"Save the new mesh into a file");
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
Definition of the Node class.
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
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)
Definition of readMeshFromFile function.
int main(int argc, char *argv[])
static bool parseNewOrder(std::string const &str_order, std::array< int, 3 > &new_axes_indices)
static void swapNodeCoordinateAxes(MeshLib::Mesh const &mesh, std::array< int, 3 > const &new_axes_indices)