OGS
MeshLib::ProjectPointOnMesh Namespace Reference

Functions

Element const * getProjectedElement (std::vector< const Element * > const &elements, Node const &node)
 
double getElevation (Element const &element, Node const &node)
 

Function Documentation

◆ getElevation()

double MeshLib::ProjectPointOnMesh::getElevation ( Element const &  element,
Node const &  node 
)

Returns the z-coordinate of a point projected onto the plane defined by a mesh element.

Definition at line 58 of file ProjectPointOnMesh.cpp.

59 {
60  Eigen::Vector3d const v =
61  Eigen::Map<Eigen::Vector3d const>(node.getCoords()) -
62  Eigen::Map<Eigen::Vector3d const>(element.getNode(0)->getCoords());
63  auto const n = FaceRule::getSurfaceNormal(element).normalized();
64  return node[2] - n.dot(v) * n[2];
65 }

References MathLib::TemplatePoint< T, DIM >::getCoords(), MeshLib::Element::getNode(), and MeshLib::FaceRule::getSurfaceNormal().

Referenced by main(), and voteMatId().

◆ getProjectedElement()

Element const * MeshLib::ProjectPointOnMesh::getProjectedElement ( std::vector< const Element * > const &  elements,
Node const &  node 
)

Returns the element in which the given node is located when projected onto a mesh, or nullptr if no such element was found.

Definition at line 21 of file ProjectPointOnMesh.cpp.

23 {
24  auto is_right_of = [&node](Node const& a, Node const& b) {
25  return GeoLib::getOrientationFast(node, a, b) ==
27  };
28 
29  for (auto const* e : elements)
30  {
31  auto const* nodes = e->getNodes();
32  if (e->getGeomType() == MeshElemType::TRIANGLE)
33  {
34  auto const& a = *nodes[0];
35  auto const& b = *nodes[1];
36  auto const& c = *nodes[2];
37  if (!is_right_of(a, b) && !is_right_of(b, c) && !is_right_of(c, a))
38  {
39  return e;
40  }
41  }
42  else if (e->getGeomType() == MeshElemType::QUAD)
43  {
44  auto const& a = *nodes[0];
45  auto const& b = *nodes[1];
46  auto const& c = *nodes[2];
47  auto const& d = *nodes[3];
48  if (!is_right_of(a, b) && !is_right_of(b, c) &&
49  !is_right_of(c, d) && !is_right_of(d, a))
50  {
51  return e;
52  }
53  }
54  }
55  return nullptr;
56 }
Orientation getOrientationFast(MathLib::Point3d const &p0, MathLib::Point3d const &p1, MathLib::Point3d const &p2)

References MaterialPropertyLib::c, GeoLib::CW, GeoLib::getOrientationFast(), MeshLib::QUAD, and MeshLib::TRIANGLE.

Referenced by getProjectedElement(), and main().