diff --git a/GeoLib/AnalyticalGeometry.h b/GeoLib/AnalyticalGeometry.h index a8a8cb204efaf7da2527fd755de985cbace1c71e..058eaa50902e0ff2d0393ca833e2b1b57a54a63c 100644 --- a/GeoLib/AnalyticalGeometry.h +++ b/GeoLib/AnalyticalGeometry.h @@ -131,11 +131,14 @@ bool isPointInTriangle(GeoLib::Point const& p, /** * Tests if the given point p is located within a tetrahedron spanned by points a, b, c, d. + * If the tet specified by a, b, c, d is degenerated (i.e. all points are coplanar) the function + * will return false because there is no meaningful concept of "inside" for such elements. * @param p test point * @param a edge node of tetrahedron * @param b edge node of tetrahedron * @param c edge node of tetrahedron - * @param c edge node of tetrahedron + * @param d edge node of tetrahedron + * @param eps Accounts for numerical inaccuracies by allowing a point to be slightly outside of the element and still be regarded as inside. * @return true if the test point p is not located outside of abcd (i.e. inside or on a plane/edge). */ bool isPointInTetrahedron(GeoLib::Point const& p, GeoLib::Point const& a, GeoLib::Point const& b, @@ -191,8 +194,8 @@ double scalarTriple(MathLib::Vector3 const& u, MathLib::Vector3 const& v, MathLi * @param a first point on plane * @param b second point on plane * @param c third point on plane - * @return If the triangle abc is ordered counterclockwise when viewed from p, the method will return a value < 0, - * otherwise it will return > 0. If p is coplanar with abc, the function will return 0. + * @return If the triangle abc is ordered counterclockwise when viewed from p, the method will return a negative value, + * otherwise it will return a positive value. If p is coplanar with abc, the function will return 0. */ double orient3d(GeoLib::Point const& p, GeoLib::Point const& a, GeoLib::Point const& b, GeoLib::Point const& c); diff --git a/MeshLib/Elements/Element.cpp b/MeshLib/Elements/Element.cpp index 8356657fd483f5c0201d57d3dd0faf80f3585534..c53bd07e5120c6dded9a1ecde5a61ee274edb940 100644 --- a/MeshLib/Elements/Element.cpp +++ b/MeshLib/Elements/Element.cpp @@ -165,4 +165,3 @@ bool Element::hasNeighbor(Element* elem) const } - diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 383c3a6d26be9e1c2cf0bbd7855a8a02024c5cd6..ef37e937f6e0b42503d01d6059b73d593df6c09f 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -161,7 +161,7 @@ public: * @param eps tolerance for numerical algorithm used or computing the property * @return true if the point is not outside the element, false otherwise */ - virtual bool isPntInElement(GeoLib::Point const& pnt, double eps) const = 0; + virtual bool isPntInElement(GeoLib::Point const& pnt, double eps = std::numeric_limits<double>::epsilon()) const = 0; /** * Tests if the element is geometrically valid. diff --git a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp index f14311ad3f5691c100a60a8e6a10b69d8d0f65f8..4f9ffafe00a60421aafcbb90b61e46805956b8ae 100644 --- a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp +++ b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp @@ -94,7 +94,7 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh(Mesh *dest_mes for (size_t j(0); j<n_nodes_in_vec; j++) { MeshLib::Node const*const j_th_node((*i_th_vec)[j]); if (elem_aabb.containsPoint(*j_th_node)) { - if (dest_elements[k]->isPntInElement(* dynamic_cast<GeoLib::Point const*>(j_th_node), 30)) { + if (dest_elements[k]->isPntInElement(*j_th_node, 30)) { dest_properties[k] += interpolated_src_node_properties[(*i_th_vec)[j]->getID()]; cnt++; } diff --git a/Tests/MeshLib/TestPntInElement.cpp b/Tests/MeshLib/TestPntInElement.cpp index ecbfcc9a954d47853fe49890c346c1781f12706b..cb94fc0ec6bb65560dc55bb005f380422b403748 100644 --- a/Tests/MeshLib/TestPntInElement.cpp +++ b/Tests/MeshLib/TestPntInElement.cpp @@ -56,6 +56,7 @@ TEST(IsPntInElement, Line) ASSERT_EQ(false, line.isPntInElement(pnt)); deleteNodes(nodes); } + TEST(IsPntInElement, Tri) { GeoLib::Point pnt;