OGS
CellRule.cpp
Go to the documentation of this file.
1 
11 #include "CellRule.h"
12 
13 #include "Element.h"
14 #include "FaceRule.h"
15 #include "MeshLib/Node.h"
16 
17 namespace MeshLib
18 {
20 {
21  Eigen::Vector3d const cc =
22  Eigen::Map<Eigen::Vector3d const>(getCenterOfGravity(e).getCoords());
23  const unsigned nFaces(e.getNumberOfFaces());
24  for (unsigned j = 0; j < nFaces; ++j)
25  {
26  MeshLib::Element const* const face(e.getFace(j));
27  // Node 1 is checked below because that way all nodes are used for the
28  // test at some point, while for node 0 at least one node in every
29  // element type would be used for checking twice and one wouldn't be
30  // checked at all. (based on the definition of the _face_nodes variable)
31  auto const x =
32  Eigen::Map<Eigen::Vector3d const>(face->getNode(1)->getCoords());
33  Eigen::Vector3d const cx = x - cc;
34  const double s = FaceRule::getSurfaceNormal(*face).dot(cx);
35  delete face;
36  if (s >= 0)
37  {
38  return false;
39  }
40  }
41  return true;
42 }
43 
44 } // namespace MeshLib
Definition of the Element class.
Definition of the Node class.
const T * getCoords() const
Definition: TemplatePoint.h:75
static bool testElementNodeOrder(Element const &e)
Definition: CellRule.cpp:19
virtual const Node * getNode(unsigned idx) const =0
virtual unsigned getNumberOfFaces() const =0
Get the number of faces for this element.
virtual const Element * getFace(unsigned i) const =0
Returns the i-th face of the element.
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition: FaceRule.cpp:40
MeshLib::Node getCenterOfGravity(Element const &element)
Calculates the center of gravity for the mesh element.
Definition: Element.cpp:126