diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index f7d8b2820d6ea685fd6c218e84bd8fd3a1b0fd27..d37186059e2d27758325273c7cbe4fc755c2a395 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -172,6 +172,14 @@ public: */ virtual Element* clone() const = 0; + /** + * Constructs a new object polymorphically. This is similar to clone, but + * accepts new nodes and id. + * \pre The length of the \c nodes vector is equal to the derived element's + * total number of nodes. + */ + virtual Element* clone(Node** nodes, std::size_t id) const = 0; + /** * Computes the length / area / volumen of this element. This is automatically * done at initalisation time but can be repeated by calling this function at any time. diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h index 822ff3758e9ec24d512c6f4e2732d8d18dd179cf..8335715c4ec7ee2bc2a07f3bc2288c01700c5a4e 100644 --- a/MeshLib/Elements/TemplateElement.h +++ b/MeshLib/Elements/TemplateElement.h @@ -69,6 +69,12 @@ public: return new TemplateElement(*this); } + /// \copydoc MeshLib::Element::clone(Node*[], std::size_t) + virtual Element* clone(Node** nodes, std::size_t id) const + { + return new TemplateElement(nodes, id); + } + /// Get dimension of the mesh element. unsigned getDimension() const { return dimension; }