Skip to content
Snippets Groups Projects
Commit e9a8f4df authored by Tom Fischer's avatar Tom Fischer
Browse files

[A/U/SimpleMeshCreation] Impl. scaling.

parent 5fd027d5
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,17 @@ ...@@ -36,6 +36,17 @@
#include "MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h" #include "MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h"
#include "MeshLib/MeshEnums.h" #include "MeshLib/MeshEnums.h"
void scaleMeshPropertyVector(MeshLib::Mesh & mesh,
std::string const& property_name,
double factor)
{
boost::optional<MeshLib::PropertyVector<double> &> pv(
mesh.getProperties().getPropertyVector<double>(property_name));
for (auto & v : *pv)
v *= factor;
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
ApplicationsLib::LogogSetup logo_setup; ApplicationsLib::LogogSetup logo_setup;
...@@ -98,6 +109,17 @@ int main(int argc, char* argv[]) ...@@ -98,6 +109,17 @@ int main(int argc, char* argv[])
"file name"); "file name");
cmd.add(mesh_arg); cmd.add(mesh_arg);
std::vector<std::string> allowed_units{ "mm/a", "mm/month", "m/s" };
TCLAP::ValuesConstraint<std::string> allowed_units_constraints{
allowed_units};
TCLAP::ValueArg<std::string> unit_arg("u",
"input-unit",
"input unit of the data",
true,
"m/s",
&allowed_units_constraints);
cmd.add(unit_arg);
cmd.parse(argc, argv); cmd.parse(argc, argv);
// read mesh // read mesh
...@@ -148,6 +170,22 @@ int main(int argc, char* argv[]) ...@@ -148,6 +170,22 @@ int main(int argc, char* argv[])
src_mesh.get(), property_arg.getValue()); src_mesh.get(), property_arg.getValue());
mesh_interpolation.setPropertiesForMesh(dest_mesh.get()); mesh_interpolation.setPropertiesForMesh(dest_mesh.get());
double scale(1.0);
if (unit_arg.getValue() == "m/s")
{
scale = 1.0;
}
else if (unit_arg.getValue() == "mm/a")
{
scale = 1e-3 / (365.25 * 86400);
}
else if (unit_arg.getValue() == "mm/month")
{
scale = 1e-3 * (12.0 / (365.25 * 86400));
}
scaleMeshPropertyVector(*dest_mesh, property_arg.getValue(), scale);
if (!out_mesh_arg.getValue().empty()) if (!out_mesh_arg.getValue().empty())
{ {
MeshLib::IO::writeMeshToFile(*dest_mesh, out_mesh_arg.getValue()); MeshLib::IO::writeMeshToFile(*dest_mesh, out_mesh_arg.getValue());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment