diff --git a/MeshLib/Elements/Cell.cpp b/MeshLib/Elements/Cell.cpp deleted file mode 100644 index 1c997a85f32f11abf61f1d4af09ef0acb9b5083c..0000000000000000000000000000000000000000 --- a/MeshLib/Elements/Cell.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2012-05-02 - * \brief Implementation of the Cell class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "Cell.h" - -#include "MathLib/Vector3.h" -#include "MeshLib/Node.h" - -namespace MeshLib { - -#ifndef WIN32 -/// \todo Windows compiler does not accept this definition and issues a linking error. -const unsigned Cell::dimension; -#endif // WIN32 - -/* -Cell::Cell(Node** nodes, MeshElemType type, unsigned value) - : Element(nodes, type, value) -{ -} -*/ -Cell::Cell(unsigned value, std::size_t id) - : Element(value, id), _volume(-1.0) // init with invalid value to detect errors -{ -} - -Cell::~Cell() -{} - -bool Cell::testElementNodeOrder() const -{ - const MathLib::Vector3 c (getCenterOfGravity()); - const unsigned nFaces (this->getNFaces()); - for (unsigned j=0; j<nFaces; ++j) - { - MeshLib::Face const*const face (dynamic_cast<const MeshLib::Face*>(this->getFace(j))); - const MeshLib::Node x (*(face->getNode(1))); - const MathLib::Vector3 cx (c, x); - const double s = MathLib::scalarProduct(face->getSurfaceNormal(), cx); - delete face; - if (s >= 0) - return false; - } - return true; -} - -} - diff --git a/MeshLib/Elements/Cell.h b/MeshLib/Elements/Cell.h index d64fe479870d83307108041b9f10a9828835ace3..b143a98359b201ee7452a371aafeef06b83ce3c0 100644 --- a/MeshLib/Elements/Cell.h +++ b/MeshLib/Elements/Cell.h @@ -39,7 +39,7 @@ public: virtual double getVolume() const { return _volume; }; /// Destructor - virtual ~Cell(); + virtual ~Cell() = default; /** * This method is pure virtual and is inherited from class @sa Element. @@ -56,7 +56,22 @@ public: * (non-planar faces, non-convex geometry, possibly zero volume) which causes the calculated * center of gravity to lie outside of the actual element */ - virtual bool testElementNodeOrder() const; + virtual bool testElementNodeOrder() const + { + const MathLib::Vector3 c (getCenterOfGravity()); + const unsigned nFaces (this->getNFaces()); + for (unsigned j=0; j<nFaces; ++j) + { + MeshLib::Face const*const face (dynamic_cast<const MeshLib::Face*>(this->getFace(j))); + const MeshLib::Node x (*(face->getNode(1))); + const MathLib::Vector3 cx (c, x); + const double s = MathLib::scalarProduct(face->getSurfaceNormal(), cx); + delete face; + if (s >= 0) + return false; + } + return true; + } protected: /* @@ -64,7 +79,9 @@ protected: Cell(Node** nodes, MeshElemType type, unsigned value = 0); */ /// Constructor for a generic mesh element without an array of mesh nodes. - Cell(unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()); + Cell(unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()) + : Element(value, id), _volume(-1.0) // init with invalid value to detect errors + { } double _volume; diff --git a/MeshLib/Elements/Face.cpp b/MeshLib/Elements/Face.cpp deleted file mode 100644 index 2f888f157132d054b314cdb96d6a116e51a2fb1c..0000000000000000000000000000000000000000 --- a/MeshLib/Elements/Face.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** - * \file - * \author Karsten Rink - * \date 2012-05-02 - * \brief Implementation of the Face class. - * - * \copyright - * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "Face.h" - -#include "MathLib/MathTools.h" -#include "MathLib/Vector3.h" - -#include "Line.h" - -namespace MeshLib { - -#ifndef WIN32 - /// \todo Windows compiler does not accept this definition and issues a linking error. - const unsigned Face::dimension; -#endif // WIN32 - -/* -Face::Face(Node** nodes, MeshElemType type, unsigned value) - : Element(nodes, type, value) -{ -} -*/ -Face::Face(unsigned value, std::size_t id) - : Element(value, id), _area(-1.0) // init with invalid value to detect errors -{ -} - -Face::~Face() -{} - -MathLib::Vector3 Face::getSurfaceNormal() const -{ - const MathLib::Vector3 u (*_nodes[1], *_nodes[0]); - const MathLib::Vector3 v (*_nodes[1], *_nodes[2]); - return MathLib::crossProduct(u,v); -} - -bool Face::testElementNodeOrder() const -{ - MathLib::Vector3 up_vec (0,0,1); - return (MathLib::scalarProduct(this->getSurfaceNormal(), up_vec) < 0) ? true : false; -} - -} - diff --git a/MeshLib/Elements/Face.h b/MeshLib/Elements/Face.h index 70efd57ba698cd99a926bd68ffcad511528c4644..b8f6c2a10d9c55bfe68a597b061e8013d59b0988 100644 --- a/MeshLib/Elements/Face.h +++ b/MeshLib/Elements/Face.h @@ -20,6 +20,7 @@ #include "GeoLib/Point.h" #include "MathLib/Vector3.h" +#include "MeshLib/Node.h" #include "Element.h" @@ -53,10 +54,15 @@ public: unsigned getNFaces() const { return 0; }; /// Returns the surface normal of a 2D element. - MathLib::Vector3 getSurfaceNormal() const; + MathLib::Vector3 getSurfaceNormal() const + { + const MathLib::Vector3 u (*_nodes[1], *_nodes[0]); + const MathLib::Vector3 v (*_nodes[1], *_nodes[2]); + return MathLib::crossProduct(u,v); + } /// Destructor - virtual ~Face(); + virtual ~Face() = default; /** * This method is pure virtual and is inherited from class @sa Element. @@ -69,7 +75,12 @@ public: * Checks if the node order of an element is correct by testing surface normals. * For 2D elements true is returned if the normal points (roughly) upwards. */ - virtual bool testElementNodeOrder() const; + virtual bool testElementNodeOrder() const + { + MathLib::Vector3 up_vec (0,0,1); + return (MathLib::scalarProduct(this->getSurfaceNormal(), up_vec) < 0) + ? true : false; + } protected: /* @@ -77,7 +88,9 @@ protected: Face(Node** nodes, MeshElemType type, unsigned value = 0); */ /// Constructor for a generic mesh element without an array of mesh nodes. - Face(unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()); + Face(unsigned value = 0, std::size_t id = std::numeric_limits<std::size_t>::max()) + : Element(value, id), _area(-1.0) // init with invalid value to detect errors + { } double _area;