diff --git a/MeshLib/Elements/Cell.cpp b/MeshLib/Elements/Cell.cpp index b4acf4dd00fe242841905bb052ee551ac38e802b..9f3cb64361837e03a968cb5c104fe78dbee30d10 100644 --- a/MeshLib/Elements/Cell.cpp +++ b/MeshLib/Elements/Cell.cpp @@ -47,8 +47,8 @@ bool Cell::testElementNodeOrder() const 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(0))); - const MathLib::Vector3 cx (c[0]-x[0], c[1]-x[1], c[2]-x[2]); + 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) diff --git a/MeshLib/Elements/Face.cpp b/MeshLib/Elements/Face.cpp index 0e54b1e71a6734d62f33dcb8b44bccd82b05123c..10744de3af6f27b253d7778b2a9b9e573be5290c 100644 --- a/MeshLib/Elements/Face.cpp +++ b/MeshLib/Elements/Face.cpp @@ -40,19 +40,15 @@ Face::~Face() MathLib::Vector3 Face::getSurfaceNormal() const { - const MathLib::Vector3 u ((*this->_nodes[0])[0]-(*this->_nodes[1])[0], - (*this->_nodes[0])[1]-(*this->_nodes[1])[1], - (*this->_nodes[0])[2]-(*this->_nodes[1])[2]); - const MathLib::Vector3 v ((*this->_nodes[1])[0]-(*this->_nodes[2])[0], - (*this->_nodes[1])[1]-(*this->_nodes[2])[1], - (*this->_nodes[1])[2]-(*this->_nodes[2])[2]); + 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; + return (MathLib::scalarProduct(this->getSurfaceNormal(), up_vec) < 0) ? true : false; } }