Skip to content
Snippets Groups Projects
Commit fea759ff authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MeL] Add polymorphic construct to Element class.

The existing clone function is a direct copy, but
setting different nodes is required.
parent cf2d96cd
No related branches found
No related tags found
No related merge requests found
...@@ -172,6 +172,14 @@ public: ...@@ -172,6 +172,14 @@ public:
*/ */
virtual Element* clone() const = 0; 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 * 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. * done at initalisation time but can be repeated by calling this function at any time.
......
...@@ -69,6 +69,12 @@ public: ...@@ -69,6 +69,12 @@ public:
return new TemplateElement(*this); 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. /// Get dimension of the mesh element.
unsigned getDimension() const { return dimension; } unsigned getDimension() const { return dimension; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment