From fece418f517d899f8a730d27e5308001d6bc326c Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Wed, 9 Dec 2015 09:36:02 +0100
Subject: [PATCH] [MeL/Elements] TemplateElement: Preparations for removing the
 element value.

---
 MeshLib/Elements/TemplateElement-impl.h | 23 ++++++++++++++++++++++-
 MeshLib/Elements/TemplateElement.h      | 20 ++++++++++++++++++--
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/MeshLib/Elements/TemplateElement-impl.h b/MeshLib/Elements/TemplateElement-impl.h
index cba91a51bb3..6667db0c115 100644
--- a/MeshLib/Elements/TemplateElement-impl.h
+++ b/MeshLib/Elements/TemplateElement-impl.h
@@ -22,6 +22,16 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(Node* nodes[n_all_nodes], unsigne
 	this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
 }
 
+template <class ELEMENT_RULE>
+TemplateElement<ELEMENT_RULE>::TemplateElement(Node* nodes[n_all_nodes], std::size_t id)
+: Element(id)
+{
+	this->_nodes = nodes;
+	this->_neighbors = new Element*[getNNeighbors()];
+	std::fill(this->_neighbors, this->_neighbors + getNNeighbors(), nullptr);
+	this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
+}
+
 template <class ELEMENT_RULE>
 TemplateElement<ELEMENT_RULE>::TemplateElement(std::array<Node*, n_all_nodes> const& nodes, unsigned value, std::size_t id)
 : Element(value, id)
@@ -33,9 +43,20 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(std::array<Node*, n_all_nodes> co
 	this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
 }
 
+template <class ELEMENT_RULE>
+TemplateElement<ELEMENT_RULE>::TemplateElement(std::array<Node*, n_all_nodes> const& nodes, std::size_t id)
+: Element(id)
+{
+	this->_nodes = new Node*[n_all_nodes];
+	std::copy(nodes.begin(), nodes.end(), this->_nodes);
+	this->_neighbors = new Element*[getNNeighbors()];
+	std::fill(this->_neighbors, this->_neighbors + getNNeighbors(), nullptr);
+	this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
+}
+
 template <class ELEMENT_RULE>
 TemplateElement<ELEMENT_RULE>::TemplateElement(const TemplateElement &e)
-: Element(e.getValue(), e.getID())
+: Element(e.getID())
 {
 	this->_nodes = new Node*[n_all_nodes];
 	for (unsigned i=0; i<n_all_nodes; i++)
diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h
index 9fe5b5aaf14..bb50401f5da 100644
--- a/MeshLib/Elements/TemplateElement.h
+++ b/MeshLib/Elements/TemplateElement.h
@@ -48,7 +48,15 @@ public:
 	 * @param value  element value, e.g. material ID
 	 * @param id     element id
 	 */
-	TemplateElement(Node* nodes[n_all_nodes], unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max());
+	TemplateElement(Node* nodes[n_all_nodes], unsigned value, std::size_t id);
+
+	/**
+	 * Constructor with an array of mesh nodes.
+	 *
+	 * @param nodes  an array of pointers of mesh nodes which form this element
+	 * @param id     element id
+	 */
+	TemplateElement(Node* nodes[n_all_nodes], std::size_t id = std::numeric_limits<std::size_t>::max());
 
 	/**
 	 * Constructor with an array of mesh nodes
@@ -57,7 +65,15 @@ public:
 	 * @param value  element value, e.g. material ID
 	 * @param id     element id
 	 */
-	TemplateElement(std::array<Node*, n_all_nodes> const& nodes, unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max());
+	TemplateElement(std::array<Node*, n_all_nodes> const& nodes, unsigned value, std::size_t id);
+
+	/**
+	 * Constructor with an array of mesh nodes
+	 *
+	 * @param nodes  an array of pointers of mesh nodes which form this element
+	 * @param id     element id
+	 */
+	TemplateElement(std::array<Node*, n_all_nodes> const& nodes, std::size_t id = std::numeric_limits<std::size_t>::max());
 
 	/// Copy constructor
 	TemplateElement(const TemplateElement &e);
-- 
GitLab