diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp index 4e1cbbf8f360dc285b10264f0d6e9fdc946930a2..f50f5ae41830d8be509dc4a6e891a6f4472cc803 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 764cb88839def46a9f2ac65a4658f91bd32cf22f..4671984427fe2c44427c0bc9dab3c09d4fc6592d 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,