diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp index d1a81b8be94ef4c15dc29dfa4aa2611d0862be26..ab9220e73a789d910a9500d8564c914efa2254ae 100644 --- a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp +++ b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp @@ -19,8 +19,8 @@ namespace MeshLib { - -std::vector<MeshLib::Node*> copyNodeVector(const std::vector<MeshLib::Node*> &nodes) +std::vector<MeshLib::Node*> copyNodeVector( + const std::vector<MeshLib::Node*>& nodes) { const std::size_t nNodes(nodes.size()); std::vector<MeshLib::Node*> new_nodes; @@ -33,7 +33,9 @@ std::vector<MeshLib::Node*> copyNodeVector(const std::vector<MeshLib::Node*> &no return new_nodes; } -std::vector<MeshLib::Element*> copyElementVector(const std::vector<MeshLib::Element*> &elements, const std::vector<MeshLib::Node*> &nodes) +std::vector<MeshLib::Element*> copyElementVector( + const std::vector<MeshLib::Element*>& elements, + const std::vector<MeshLib::Node*>& nodes) { const std::size_t nElements(elements.size()); std::vector<MeshLib::Element*> new_elements; @@ -45,7 +47,8 @@ std::vector<MeshLib::Element*> copyElementVector(const std::vector<MeshLib::Elem return new_elements; } -MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::vector<MeshLib::Node*> &nodes) +MeshLib::Element* copyElement(MeshLib::Element const* const element, + const std::vector<MeshLib::Node*>& nodes) { if (element->getGeomType() == MeshElemType::LINE) { @@ -76,12 +79,13 @@ MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::v return copyElement<MeshLib::Prism>(element, nodes); } - ERR ("Error: Unknown element type."); + ERR("Error: Unknown element type."); return nullptr; } template <typename E> -MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::vector<MeshLib::Node*> &nodes) +MeshLib::Element* copyElement(MeshLib::Element const* const element, + const std::vector<MeshLib::Node*>& nodes) { auto** new_nodes = new MeshLib::Node*[element->getNumberOfNodes()]; for (unsigned i = 0; i < element->getNumberOfNodes(); ++i) @@ -102,4 +106,4 @@ std::vector<MeshLib::Element*> cloneElements( return cloned_elements; } -} // namespace MeshLib +} // namespace MeshLib diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.h b/MeshLib/MeshEditing/DuplicateMeshComponents.h index 29d9232b390628bea701305431921c8554836de9..0214d5d4546b1d849d87d87e7933ccb5dedcee36 100644 --- a/MeshLib/MeshEditing/DuplicateMeshComponents.h +++ b/MeshLib/MeshEditing/DuplicateMeshComponents.h @@ -18,30 +18,36 @@ namespace MeshLib { - - class Mesh; - class Node; - class Element; - - /// Creates a deep copy of a Node vector - std::vector<MeshLib::Node*> copyNodeVector(const std::vector<MeshLib::Node*> &nodes); - - /** 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. - * @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); - - /// Copies an element without change, using the nodes vector from the result mesh. - MeshLib::Element* copyElement(MeshLib::Element const*const element, - const std::vector<MeshLib::Node*> &nodes); - - /// Copies an element without change, using the nodes vector from the result mesh. - template <typename E> - MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::vector<MeshLib::Node*> &nodes); - - /// Clones a vector of elements using the Element::clone() function. - std::vector<MeshLib::Element*> cloneElements( - std::vector<MeshLib::Element*> const& elements); -} // end namespace MeshLib +class Mesh; +class Node; +class Element; + +/// Creates a deep copy of a Node vector +std::vector<MeshLib::Node*> copyNodeVector( + const std::vector<MeshLib::Node*>& nodes); + +/** 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. + * @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); + +/// Copies an element without change, using the nodes vector from the result +/// mesh. +MeshLib::Element* copyElement(MeshLib::Element const* const element, + const std::vector<MeshLib::Node*>& nodes); + +/// Copies an element without change, using the nodes vector from the result +/// mesh. +template <typename E> +MeshLib::Element* copyElement(MeshLib::Element const* const element, + const std::vector<MeshLib::Node*>& nodes); + +/// Clones a vector of elements using the Element::clone() function. +std::vector<MeshLib::Element*> cloneElements( + std::vector<MeshLib::Element*> const& elements); +} // end namespace MeshLib