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

Revert "[ML] Move Face/Cell implementations in header file."

This reverts commit 14cdf0c6.
parent 14cdf0c6
No related branches found
No related tags found
No related merge requests found
/**
* \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;
}
}
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
virtual double getVolume() const { return _volume; }; virtual double getVolume() const { return _volume; };
/// Destructor /// Destructor
virtual ~Cell() = default; virtual ~Cell();
/** /**
* This method is pure virtual and is inherited from class @sa Element. * This method is pure virtual and is inherited from class @sa Element.
...@@ -56,22 +56,7 @@ public: ...@@ -56,22 +56,7 @@ public:
* (non-planar faces, non-convex geometry, possibly zero volume) which causes the calculated * (non-planar faces, non-convex geometry, possibly zero volume) which causes the calculated
* center of gravity to lie outside of the actual element * 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: protected:
/* /*
...@@ -79,9 +64,7 @@ protected: ...@@ -79,9 +64,7 @@ protected:
Cell(Node** nodes, MeshElemType type, unsigned value = 0); Cell(Node** nodes, MeshElemType type, unsigned value = 0);
*/ */
/// Constructor for a generic mesh element without an array of mesh nodes. /// 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; double _volume;
......
/**
* \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;
}
}
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "GeoLib/Point.h" #include "GeoLib/Point.h"
#include "MathLib/Vector3.h" #include "MathLib/Vector3.h"
#include "MeshLib/Node.h"
#include "Element.h" #include "Element.h"
...@@ -54,15 +53,10 @@ public: ...@@ -54,15 +53,10 @@ public:
unsigned getNFaces() const { return 0; }; unsigned getNFaces() const { return 0; };
/// Returns the surface normal of a 2D element. /// 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 /// Destructor
virtual ~Face() = default; virtual ~Face();
/** /**
* This method is pure virtual and is inherited from class @sa Element. * This method is pure virtual and is inherited from class @sa Element.
...@@ -75,12 +69,7 @@ public: ...@@ -75,12 +69,7 @@ public:
* Checks if the node order of an element is correct by testing surface normals. * 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. * 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: protected:
/* /*
...@@ -88,9 +77,7 @@ protected: ...@@ -88,9 +77,7 @@ protected:
Face(Node** nodes, MeshElemType type, unsigned value = 0); Face(Node** nodes, MeshElemType type, unsigned value = 0);
*/ */
/// Constructor for a generic mesh element without an array of mesh nodes. /// 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; double _area;
......
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