OGS
scaleMeshPropertyVector.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <range/v3/algorithm/transform.hpp>
7
8#include "MeshLib/Mesh.h"
9
10namespace MeshLib
11{
13 std::string const& property_name,
14 double factor)
15{
16 if (!mesh.getProperties().existsPropertyVector<double>(property_name))
17 {
18 WARN("Did not find PropertyVector '{:s}' for scaling.", property_name);
19 return;
20 }
21 auto& pv = *mesh.getProperties().getPropertyVector<double>(property_name);
22 ranges::transform(pv, pv.begin(),
23 [factor](auto const& v) { return v * factor; });
24}
25} // namespace MeshLib
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
Properties & getProperties()
Definition Mesh.h:125
bool existsPropertyVector(std::string_view name) const
PropertyVector< T > const * getPropertyVector(std::string_view name) const
void scaleMeshPropertyVector(MeshLib::Mesh &mesh, std::string const &property_name, double factor)