From abb9ac2f106e4c7ed7ec6777c2eff9540968d73f Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Wed, 22 Aug 2012 15:26:49 +0200
Subject: [PATCH] changed edge numbering in Quad::_edge_nodes implemented
 Quad::reviseElement() added more documentation to Quad::reviseElement()

---
 MeshLib/Elements/Quad.cpp | 16 +++++++++++++++-
 MeshLib/Elements/Quad.h   | 26 ++++++++++++++++++--------
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/MeshLib/Elements/Quad.cpp b/MeshLib/Elements/Quad.cpp
index a4b632f16ea..922871ddbee 100644
--- a/MeshLib/Elements/Quad.cpp
+++ b/MeshLib/Elements/Quad.cpp
@@ -12,6 +12,7 @@
 
 #include "Quad.h"
 #include "Node.h"
+#include "Tri.h"
 
 #include "MathTools.h"
 
@@ -22,7 +23,7 @@ const unsigned Quad::_edge_nodes[4][2] =
 {
 	{0, 1}, // Edge 0
 	{1, 2}, // Edge 1
-	{0, 2}, // Edge 2
+	{2, 3}, // Edge 2
 	{0, 3}  // Edge 3
 };
 
@@ -79,6 +80,19 @@ Element* Quad::clone() const
 	return new Quad(*this);
 }
 
+Element* Quad::reviseElement() const
+{
+	if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) {
+		return new Tri(_nodes[0], _nodes[2], _nodes[3], _value);
+	}
+
+	if (_nodes[2] == _nodes[3] || _nodes[3] == _nodes[0]) {
+		return new Tri(_nodes[0], _nodes[1], _nodes[2], _value);
+	}
+
+	// this should not happen
+	return NULL;
+}
 
 }
 
diff --git a/MeshLib/Elements/Quad.h b/MeshLib/Elements/Quad.h
index e633c5df7fa..1ccd21b516c 100644
--- a/MeshLib/Elements/Quad.h
+++ b/MeshLib/Elements/Quad.h
@@ -18,19 +18,18 @@
 namespace MeshLib {
 
 /**
- * A 2d Quadliteral Element.
+ * This class represents a 2d quadliteral element. The following sketch shows the node and edge numbering.
+ * @anchor QuadNodeAndEdgeNumbering
  * @code
- *
- *        3           2
- *  Quad: o-----------o
- *        |           |
+ *              2
+ *        3-----------2
  *        |           |
  *        |           |
+ *       3|           |1
  *        |           |
  *        |           |
- *        o-----------o
- *        0           1
- *
+ *        0-----------1
+ *              0
  * @endcode
  */
 class Quad : public Face
@@ -69,6 +68,17 @@ public:
 	 */
 	virtual Element* clone() const;
 
+	/**
+	 * This method should be called after at least two nodes of the quad
+	 * element are collapsed. As a consequence of the node collapsing an edge
+	 * of the quad will be collapsed. If one of the edges (see
+	 * sketch @ref PyramidNodeAndEdgeNumbering) is collapsed we obtain a
+	 * triangle. In this case the method will create the appropriate
+	 * object of class Tri.
+	 * @return a Tri object or NULL
+	 */
+	virtual Element* reviseElement() const;
+
 protected:
 	/// Calculates the area of a convex quadliteral by dividing it into two triangles.
 	double computeArea();
-- 
GitLab