From 46038e55fc7ea1cb35ea4af57c7f4fb5bdfa7ccd Mon Sep 17 00:00:00 2001
From: Norihiro Watanabe <norihiro.watanabe@ufz.de>
Date: Tue, 25 Oct 2016 16:46:13 +0200
Subject: [PATCH] [Mesh/Properties] add the second version of
 excludeCopyProperties() with mesh item types

---
 MeshLib/Properties.cpp | 20 ++++++++++++++++++++
 MeshLib/Properties.h   |  6 ++++++
 2 files changed, 26 insertions(+)

diff --git a/MeshLib/Properties.cpp b/MeshLib/Properties.cpp
index 0d4c2a24015..3c29f8605d6 100644
--- a/MeshLib/Properties.cpp
+++ b/MeshLib/Properties.cpp
@@ -72,6 +72,26 @@ Properties Properties::excludeCopyProperties(
     return exclude_copy;
 }
 
+Properties Properties::excludeCopyProperties(
+    std::vector<MeshItemType> const& exclude_mesh_item_types) const
+{
+    Properties new_properties;
+    for (auto property_vector : _properties) {
+        if (std::find(exclude_mesh_item_types.begin(),
+                      exclude_mesh_item_types.end(),
+                      property_vector.second->getMeshItemType()) !=
+            exclude_mesh_item_types.end())
+            continue;
+
+        std::vector<std::size_t> const exclude_positions;
+        new_properties._properties.insert(
+            std::make_pair(property_vector.first,
+            property_vector.second->clone(exclude_positions))
+        );
+    }
+    return new_properties;
+}
+
 Properties::Properties(Properties const& properties)
     : _properties(properties._properties)
 {
diff --git a/MeshLib/Properties.h b/MeshLib/Properties.h
index 1dacf08e7d5..a5ea25de6b0 100644
--- a/MeshLib/Properties.h
+++ b/MeshLib/Properties.h
@@ -107,6 +107,12 @@ public:
         std::vector<std::size_t> const& exclude_elem_ids,
         std::vector<std::size_t> const& exclude_node_ids) const;
 
+    /** copy all PropertyVector objects stored in the (internal) map but
+     * PropertyVector objects with the given MeshItemType are excluded.
+     */
+    Properties excludeCopyProperties(
+        std::vector<MeshItemType> const& exclude_mesh_item_types) const;
+
     Properties() {}
 
     Properties(Properties const& properties);
-- 
GitLab