From 7399650c531e84bf6eb6d13873f808342d15eb45 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Tue, 14 Apr 2015 07:01:48 +0200
Subject: [PATCH] [MeL/ME] ElemValMod: Reimpl. of setByElementType().

ElementValueModification::setByElementType() uses the new Property data structures.
---
 .../MeshEditing/ElementValueModification.cpp  | 27 ++++++++++++++-----
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/MeshLib/MeshEditing/ElementValueModification.cpp b/MeshLib/MeshEditing/ElementValueModification.cpp
index 4b1f0e5d9a4..d1ec306f709 100644
--- a/MeshLib/MeshEditing/ElementValueModification.cpp
+++ b/MeshLib/MeshEditing/ElementValueModification.cpp
@@ -97,16 +97,29 @@ unsigned ElementValueModification::condense(MeshLib::Mesh &mesh)
 
 unsigned ElementValueModification::setByElementType(MeshLib::Mesh &mesh, MeshElemType ele_type, unsigned new_value)
 {
-	std::vector<MeshLib::Element*> &elements (const_cast<std::vector<MeshLib::Element*>&>(mesh.getElements()));
-	unsigned nValues = 0;
-	for (auto e : elements) {
-		if (e->getGeomType()!=ele_type)
+	boost::optional<MeshLib::PropertyVector<unsigned> &>
+		optional_property_value_vec(
+			mesh.getProperties().getPropertyVector<unsigned>("MaterialIDs")
+		);
+
+	if (!optional_property_value_vec) {
+		return 0;
+	}
+
+	MeshLib::PropertyVector<unsigned> & property_value_vector(
+		optional_property_value_vec.get()
+	);
+
+	std::vector<MeshLib::Element*> const& elements(mesh.getElements());
+	std::size_t cnt(0);
+	for (std::size_t k(0); k<elements.size(); k++) {
+		if (elements[k]->getGeomType()!=ele_type)
 			continue;
-		e->setValue(new_value);
-		nValues++;
+		property_value_vector[k] = new_value;
+		cnt++;
 	}
 
-	return nValues;
+	return cnt;
 }
 
 } // end namespace MeshLib
-- 
GitLab