Skip to content
Snippets Groups Projects
Commit f674a490 authored by Tom Fischer's avatar Tom Fischer
Browse files

[MeL] Impl. of isPointInElementXY().

parent 727a3982
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@
#include <logog/include/logog.hpp>
#include "MathLib/GeometricBasics.h"
#include "MathLib/MathTools.h"
#include "MeshLib/Node.h"
......@@ -205,4 +206,40 @@ std::ostream& operator<<(std::ostream& os, Element const& e)
}
#endif // NDEBUG
bool isPointInElementXY(MathLib::Point3d const& p, Element const& e)
{
for(std::size_t i(0); i<e.getNumberOfBaseNodes(); ++i) {
if (MathLib::sqrDist2d(p, *e.getNode(i)) <
std::numeric_limits<double>::epsilon())
{
return true;
}
}
if (e.getGeomType() == MeshElemType::TRIANGLE)
{
MathLib::Point3d const& n0(*e.getNode(0));
MathLib::Point3d const& n1(*e.getNode(1));
MathLib::Point3d const& n2(*e.getNode(2));
return MathLib::isPointInTriangleXY(p, n0, n1, n2);
}
else if (e.getGeomType() == MeshElemType::QUAD)
{
MathLib::Point3d const& n0(*e.getNode(0));
MathLib::Point3d const& n1(*e.getNode(1));
MathLib::Point3d const& n2(*e.getNode(2));
MathLib::Point3d const& n3(*e.getNode(3));
return MathLib::isPointInTriangleXY(p, n0, n1, n2) ||
MathLib::isPointInTriangleXY(p, n0, n2, n3);
}
else
{
WARN("isPointInElementXY: element type \"%s\" is not supported.",
MeshLib::MeshElemType2String(e.getGeomType()).c_str());
return false;
}
}
}
......@@ -213,6 +213,16 @@ protected:
}; /* class */
/// Let \f$p'\f$ the orthogonal projection to the \f$x\f$-\f$y\f$ plane of the
/// point \c p and \f$e'\f$ the orthogonal projection to the \f$x\f$-\f$y\f$
/// plane of the element \c e.
/// The method checks if \f$p'\f$ is located in \f$e'\f$. \todo At the moment
/// the test works only for triangle and quad elements.
/// @param p \c MathLib::Point3d is the test point
/// @param e the element that is used for the request
/// @return true if the \f$p' \in e'\f$ and false if \f$p' \notin e'\f$
bool isPointInElementXY(MathLib::Point3d const& p, Element const& e);
} /* namespace */
#endif /* ELEMENT_H_ */
......
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