From 00e98dcad677ea6bced379affeacffe1c60279ca Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Wed, 27 Jan 2016 11:32:40 +0100
Subject: [PATCH] [A/U/ME] ResetPropertyInPolygonalRegion: Generate
 non-existing int-property.

---
 .../MeshEdit/ResetPropertiesInPolygonalRegion.cpp    | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp
index 9986890269b..eb8fe910e7a 100644
--- a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp
+++ b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp
@@ -224,6 +224,18 @@ int main (int argc, char* argv[])
 
 	if (int_property_arg.isSet()) {
 		int int_property_val(int_property_arg.getValue());
+
+		// check if PropertyVector exists
+		boost::optional<MeshLib::PropertyVector<int> &> opt_pv(
+			mesh->getProperties().getPropertyVector<int>(property_name)
+		);
+		if (!opt_pv) {
+			opt_pv = mesh->getProperties().createNewPropertyVector<int>(
+				property_name, MeshLib::MeshItemType::Cell, 1);
+			opt_pv.get().resize(mesh->getElements().size());
+			INFO("Created PropertyVector with name \"%s\".", property_name.c_str());
+		}
+
 		resetMeshElementProperty(*mesh, polygon, property_name, int_property_val);
 	}
 
-- 
GitLab