27 std::string
const& property_name,
28 int const old_value,
int const new_value,
29 bool replace_if_exists)
37 catch (std::runtime_error
const& e)
39 ERR(
"{:s}", e.what());
43 const std::size_t n_property_tuples(
46 if (!replace_if_exists)
48 for (std::size_t i = 0; i < n_property_tuples; ++i)
50 if ((*property_value_vec)[i] == new_value)
53 "ElementValueModification::replaceElementValue() - "
54 "Replacement value '{:d}' is already taken, no changes "
62 for (std::size_t i = 0; i < n_property_tuples; ++i)
64 if ((*property_value_vec)[i] == old_value)
66 (*property_value_vec)[i] = new_value;
75 bool replace_if_exists)
77 return replace(mesh,
"MaterialIDs", old_value, new_value,
89 catch (std::runtime_error
const& e)
91 ERR(
"{:s}", e.what());
95 std::vector<int> value_mapping(
98 std::vector<int> reverse_mapping(value_mapping.back() + 1, 0);
99 std::size_t
const nValues(value_mapping.size());
100 for (std::size_t i = 0; i < nValues; ++i)
102 reverse_mapping[value_mapping[i]] = i;
105 std::size_t
const n_property_values(property_value_vector->
size());
106 for (std::size_t i = 0; i < n_property_values; ++i)
108 (*property_value_vector)[i] =
109 reverse_mapping[(*property_value_vector)[i]];
124 catch (std::runtime_error
const& e)
126 ERR(
"{:s}", e.what());
130 std::vector<MeshLib::Element*>
const& elements(mesh.
getElements());
132 for (std::size_t k(0); k < elements.size(); k++)
134 if (elements[k]->getGeomType() != ele_type)
138 (*property_value_vector)[k] = new_value;
Definition of the ElementValueModification class.
Definition of the Element class.
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Properties & getProperties()
PropertyVector< T > const * getPropertyVector(std::string_view name) const
std::size_t getNumberOfTuples() const
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.