Skip to content
Snippets Groups Projects
Commit c90c4291 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[MeL] Surface normal computation also for lines

parent 256744ea
No related branches found
No related tags found
No related merge requests found
...@@ -46,19 +46,44 @@ inline Eigen::Vector3d calculateNormalizedSurfaceNormal( ...@@ -46,19 +46,44 @@ inline Eigen::Vector3d calculateNormalizedSurfaceNormal(
MeshLib::Element const& bulk_element) MeshLib::Element const& bulk_element)
{ {
Eigen::Vector3d surface_element_normal; Eigen::Vector3d surface_element_normal;
if (surface_element.getDimension() < 2)
{ switch (surface_element.getDimension())
auto const bulk_element_normal =
MeshLib::FaceRule::getSurfaceNormal(bulk_element);
auto const& v0 = surface_element.getNode(0)->asEigenVector3d();
auto const& v1 = surface_element.getNode(1)->asEigenVector3d();
Eigen::Vector3d const edge_vector = v1 - v0;
surface_element_normal = bulk_element_normal.cross(edge_vector);
}
else
{ {
surface_element_normal = case 2:
MeshLib::FaceRule::getSurfaceNormal(surface_element); surface_element_normal =
MeshLib::FaceRule::getSurfaceNormal(surface_element);
break;
case 1:
{
auto const bulk_element_normal =
MeshLib::FaceRule::getSurfaceNormal(bulk_element);
auto const& v0 = surface_element.getNode(0)->asEigenVector3d();
auto const& v1 = surface_element.getNode(1)->asEigenVector3d();
Eigen::Vector3d const edge_vector = v1 - v0;
surface_element_normal = -bulk_element_normal.cross(edge_vector);
break;
}
case 0:
{
assert(surface_element.getCellType() == CellType::POINT1);
assert(bulk_element.getCellType() == CellType::LINE2 ||
bulk_element.getCellType() == CellType::LINE3);
auto const& x = surface_element.getNode(0)->asEigenVector3d();
// The start of the line element.
auto const& a = bulk_element.getNode(0)->asEigenVector3d();
// The end of the line element is the 2nd base node of the line,
// which is the 2nd node.
auto const& b = bulk_element.getNode(1)->asEigenVector3d();
// x coincides either with the start or with the end of the line.
// a + b - 2 * x evaluates to a - b or to b - a, respectively.
// The formula assumes that the line is perfectly straight, even in
// the LINE3 case.
surface_element_normal = a + b - 2 * x;
}
} }
surface_element_normal.normalize(); surface_element_normal.normalize();
......
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