From fb57e52a5957e96594b50b7f188cf3cbdb2592a9 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Mon, 12 Nov 2018 06:12:47 +0100 Subject: [PATCH] [MGTL] Use another version of getPropertyVector. This version checks if the PropertyVector is assigned to the requested mesh item type and has the required number of components. --- MeshGeoToolsLib/AppendLinesAlongPolyline.cpp | 16 +++++++++------- MeshGeoToolsLib/IdentifySubdomainMesh.cpp | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp b/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp index 4e06ff99459..c107c4d1089 100644 --- a/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp +++ b/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp @@ -33,14 +33,16 @@ std::unique_ptr<MeshLib::Mesh> appendLinesAlongPolylines( std::vector<MeshLib::Element*> vec_new_eles = MeshLib::copyElementVector(mesh.getElements(), vec_new_nodes); std::vector<int> new_mat_ids; + try { - if (mesh.getProperties().existsPropertyVector<int>("MaterialIDs")) { - auto ids = - mesh.getProperties().getPropertyVector<int>("MaterialIDs"); - new_mat_ids.reserve(ids->size()); - std::copy(ids->cbegin(), ids->cend(), - std::back_inserter(new_mat_ids)); - } + auto ids = mesh.getProperties().getPropertyVector<int>( + "MaterialIDs", MeshLib::MeshItemType::Cell, 1); + new_mat_ids.reserve(ids->size()); + std::copy(ids->cbegin(), ids->cend(), std::back_inserter(new_mat_ids)); + } + catch (std::runtime_error const& e) + { + WARN("%s", e.what()); } int max_matID(0); if (!new_mat_ids.empty()) diff --git a/MeshGeoToolsLib/IdentifySubdomainMesh.cpp b/MeshGeoToolsLib/IdentifySubdomainMesh.cpp index 5b69d073d90..07c0313b0a7 100644 --- a/MeshGeoToolsLib/IdentifySubdomainMesh.cpp +++ b/MeshGeoToolsLib/IdentifySubdomainMesh.cpp @@ -99,8 +99,8 @@ std::vector<std::vector<std::size_t>> identifySubdomainMeshElements( MeshLib::Mesh const& subdomain_mesh, MeshLib::Mesh const& bulk_mesh) { auto& properties = subdomain_mesh.getProperties(); - auto const& bulk_node_ids = - *properties.getPropertyVector<std::size_t>("bulk_node_ids"); + auto const& bulk_node_ids = *properties.getPropertyVector<std::size_t>( + "bulk_node_ids", MeshLib::MeshItemType::Node, 1); // Allocate space for all elements for random insertion. std::vector<std::vector<std::size_t>> bulk_element_ids_map( -- GitLab