From cbd16ba821f73ba455f23e3d472b1d710a7fb97b Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Fri, 24 Jan 2020 09:03:57 +0100 Subject: [PATCH] [MeL/ME] Add an opt. node map. to copyElementVector. --- MeshLib/MeshEditing/DuplicateMeshComponents.cpp | 12 ++++++------ MeshLib/MeshEditing/DuplicateMeshComponents.h | 13 ++++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp index 4e1cbbf8f36..f50f5ae4183 100644 --- a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp +++ b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp @@ -34,15 +34,15 @@ std::vector<MeshLib::Node*> copyNodeVector( } std::vector<MeshLib::Element*> copyElementVector( - const std::vector<MeshLib::Element*>& elements, - const std::vector<MeshLib::Node*>& nodes) + std::vector<MeshLib::Element*> const& elements, + std::vector<MeshLib::Node*> const& new_nodes, + std::vector<std::size_t> const* const node_id_map) { - const std::size_t nElements(elements.size()); std::vector<MeshLib::Element*> new_elements; - new_elements.reserve(nElements); - for (std::size_t k = 0; k < nElements; ++k) + new_elements.reserve(elements.size()); + for (auto element : elements) { - new_elements.push_back(copyElement(elements[k], nodes)); + new_elements.push_back(copyElement(element, new_nodes, node_id_map)); } return new_elements; } diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.h b/MeshLib/MeshEditing/DuplicateMeshComponents.h index 764cb88839d..4671984427f 100644 --- a/MeshLib/MeshEditing/DuplicateMeshComponents.h +++ b/MeshLib/MeshEditing/DuplicateMeshComponents.h @@ -28,16 +28,19 @@ std::vector<MeshLib::Node*> copyNodeVector( /** Creates a deep copy of an element vector using the given Node vector. * @param elements The element vector that should be duplicated. - * @param nodes The new node vector used for the duplicated element vector. - * This should be consistent with the original node vector. + * @param new_nodes The new node vector used for the duplicated element vector. + * @param node_id_map An optional mapping from the nodes the 'old' elements + * based on to the new nodes. This should be consistent with the original node + * vector. * @return A deep copy of the elements vector using the new nodes vector. */ std::vector<MeshLib::Element*> copyElementVector( - const std::vector<MeshLib::Element*>& elements, - const std::vector<MeshLib::Node*>& nodes); + std::vector<MeshLib::Element*> const& elements, + std::vector<MeshLib::Node*> const& new_nodes, + std::vector<std::size_t> const* const node_id_map = nullptr); /// Copies an element without change, using the nodes vector from the result -/// mesh. +/// mesh and an optional mapping from the nodes the 'old' elements. MeshLib::Element* copyElement( MeshLib::Element const* const element, const std::vector<MeshLib::Node*>& nodes, -- GitLab