From 0d196ef5e005885fd21714521a087a1b5dfd71d9 Mon Sep 17 00:00:00 2001
From: Karsten Rink <karsten.rink@ufz.de>
Date: Mon, 14 May 2012 14:49:41 +0200
Subject: [PATCH] added unified method for length/area/volume of an element

---
 MeshLib/Elements/Cell.h    | 7 +++++--
 MeshLib/Elements/Edge.h    | 3 +++
 MeshLib/Elements/Element.h | 3 +++
 MeshLib/Elements/Face.h    | 3 +++
 MeshLib/Mesh.h             | 5 +++++
 5 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/MeshLib/Elements/Cell.h b/MeshLib/Elements/Cell.h
index b9d54fed1cb..58f9fcbfc2f 100644
--- a/MeshLib/Elements/Cell.h
+++ b/MeshLib/Elements/Cell.h
@@ -18,12 +18,15 @@ namespace MeshLib {
 class Cell : public Element
 {
 public:
-	/// Get the volume of this 3d element.
-	virtual double getVolume() const { return _volume; };
+	/// Returns the length, area or volume of a 1D, 2D or 3D element
+	double getContent() const { return _volume; };
 
 	/// Get dimension of the mesh element.
 	unsigned getDimension() const { return 3; };
 
+	/// Get the volume of this 3d element.
+	virtual double getVolume() const { return _volume; };
+
 	/// Destructor
 	virtual ~Cell();
 
diff --git a/MeshLib/Elements/Edge.h b/MeshLib/Elements/Edge.h
index 5d430ec8486..09854162cc0 100644
--- a/MeshLib/Elements/Edge.h
+++ b/MeshLib/Elements/Edge.h
@@ -38,6 +38,9 @@ public:
 	/// Destructor
 	virtual ~Edge();
 
+	/// Returns the length, area or volume of a 1D, 2D or 3D element
+	double getContent() const { return _length; };
+
 	/// Returns the edge i of the element.
 	const Element* getEdge(unsigned i) const { (void)i; return NULL; };
 
diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h
index e00aa97c405..862a27c8434 100644
--- a/MeshLib/Elements/Element.h
+++ b/MeshLib/Elements/Element.h
@@ -30,6 +30,9 @@ public:
 	/// Compute the minimum and maximum squared edge length for this element
 	virtual void computeSqrEdgeLengthRange(double &min, double &max) const;
 
+	/// Returns the length, area or volume of a 1D, 2D or 3D element
+	virtual double getContent() const = 0;
+
 	/// Get node with local index i.
 	const Node* getNode(unsigned i) const;
 
diff --git a/MeshLib/Elements/Face.h b/MeshLib/Elements/Face.h
index 492b02fa6a4..0bd277a20d0 100644
--- a/MeshLib/Elements/Face.h
+++ b/MeshLib/Elements/Face.h
@@ -21,6 +21,9 @@ public:
 	/// Get the area of this 2d element.
 	virtual double getArea() const { return _area; };
 
+	/// Returns the length, area or volume of a 1D, 2D or 3D element
+	double getContent() const { return _area; };
+
 	/// Get dimension of the mesh element.
 	unsigned getDimension() const { return 2; };
 
diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h
index ba570f99734..89edf6f0048 100644
--- a/MeshLib/Mesh.h
+++ b/MeshLib/Mesh.h
@@ -72,6 +72,11 @@ public:
 	/// Get the element-vector for the mesh.
 	const std::vector<Element*> getElements() const { return _elements; };
 
+	/** 
+	 * Set the minimum and maximum length over the edges of the mesh.
+	 * This should have been previously calcumlated using the Element::computeSqrEdgeLengthRange(min, max) 
+	 * function or by some other means.
+	 */
 	void setEdgeLengthRange(const double &min_length, const double &max_length);
 	
 protected:
-- 
GitLab