diff --git a/GeoLib/AnalyticalGeometry.h b/GeoLib/AnalyticalGeometry.h index c6c403b8289806012d099eb15ed66f289ae43170..3c11356b5e9a1b791dcf02f0794e93efe8c9f3db 100644 --- a/GeoLib/AnalyticalGeometry.h +++ b/GeoLib/AnalyticalGeometry.h @@ -212,8 +212,7 @@ double orient3d(GeoLib::Point const& p, /// Checks if the four given points are located on a plane. bool isCoplanar(const GeoLib::Point& a, const GeoLib::Point& b, const GeoLib::Point& c, const GeoLib::Point& d); - - + /** * Method first computes the intersection points of line segements of GeoLib::Polyline objects * (@see computeIntersectionPoints()) and pushes each intersection point in the GeoLib::PointVec diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 7e10f07e4044f9045a155d193c49e67f58696574..5e402eff727efe42e9780086457be6ae6f54c881 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -19,10 +19,13 @@ #include <limits> #include <boost/optional.hpp> +#include "Point.h" + #include "MeshLib/MeshEnums.h" #include "MeshLib/Mesh.h" #include "MeshLib/MeshQuality/ElementErrorCode.h" + namespace MeshLib { class Node; @@ -152,6 +155,9 @@ public: /// Returns true if these two indeces form an edge and false otherwise virtual bool isEdge(unsigned i, unsigned j) const = 0; + /// Returns true if the given point is not located outside of the element + virtual bool isPntInElement(GeoLib::Point const& pnt) const = 0; + /** * Tests if the element is geometrically valid. */ diff --git a/MeshLib/Elements/TemplateHex-impl.h b/MeshLib/Elements/TemplateHex-impl.h index 3469c18b60ad7c4b98066b1e6d498d3e76dc9513..1b863420a75175e19ebf5263dc75c61bd700eb2c 100644 --- a/MeshLib/Elements/TemplateHex-impl.h +++ b/MeshLib/Elements/TemplateHex-impl.h @@ -139,6 +139,17 @@ bool TemplateHex<NNODES,CELLHEXTYPE>::isEdge(unsigned idx1, unsigned idx2) const return false; } +template <unsigned NNODES, CellType CELLHEXTYPE> +bool TemplateHex<NNODES,CELLHEXTYPE>::isPntInElement(GeoLib::Point const& pnt) const +{ + return (GeoLib::isPointInTetrahedron(pnt, *_nodes[4], *_nodes[7], *_nodes[5], *_nodes[0]) || + GeoLib::isPointInTetrahedron(pnt, *_nodes[5], *_nodes[3], *_nodes[1], *_nodes[0]) || + GeoLib::isPointInTetrahedron(pnt, *_nodes[5], *_nodes[7], *_nodes[3], *_nodes[0]) || + GeoLib::isPointInTetrahedron(pnt, *_nodes[5], *_nodes[7], *_nodes[6], *_nodes[2]) || + GeoLib::isPointInTetrahedron(pnt, *_nodes[1], *_nodes[3], *_nodes[5], *_nodes[2]) || + GeoLib::isPointInTetrahedron(pnt, *_nodes[3], *_nodes[7], *_nodes[5], *_nodes[2])); +} + template <unsigned NNODES, CellType CELLHEXTYPE> Element* TemplateHex<NNODES,CELLHEXTYPE>::clone() const { diff --git a/MeshLib/Elements/TemplateHex.h b/MeshLib/Elements/TemplateHex.h index 0fcb9bf951c8bfbc17ad95da2772c35510e99831..33b7f6805d36e6eb33d422be0ac8978f85339dc7 100644 --- a/MeshLib/Elements/TemplateHex.h +++ b/MeshLib/Elements/TemplateHex.h @@ -104,6 +104,9 @@ public: /// Returns true if these two indices form an edge and false otherwise bool isEdge(unsigned i, unsigned j) const; + /// Returns true if the given point is not located outside of the hexahedron + bool isPntInElement(GeoLib::Point const& pnt) const; + /** * Tests if the element is geometrically valid. * @param check_zero_volume indicates if volume == 0 should be checked diff --git a/MeshLib/Elements/TemplateLine-impl.h b/MeshLib/Elements/TemplateLine-impl.h index 875cb8ecf29a59a215a515d04bb970ec04f899b7..b954d3e238d9159e99dfa583224f885d60ac4232 100644 --- a/MeshLib/Elements/TemplateLine-impl.h +++ b/MeshLib/Elements/TemplateLine-impl.h @@ -55,6 +55,15 @@ template <unsigned NNODES, CellType CELLLINETYPE> TemplateLine<NNODES,CELLLINETYPE>::~TemplateLine() {} +template <unsigned NNODES, CellType CELLLINETYPE> +bool TemplateLine<NNODES,CELLLINETYPE>::isPntInElement(GeoLib::Point const& pnt) const +{ + double tmp; + double dist(0); + MathLib::calcProjPntToLineAndDists(pnt.getCoords(), _nodes[0]->getCoords(), _nodes[1]->getCoords(), tmp, dist); + return (dist < std::numeric_limits<double>::epsilon()); +} + template <unsigned NNODES, CellType CELLLINETYPE> ElementErrorCode TemplateLine<NNODES,CELLLINETYPE>::validate() const { diff --git a/MeshLib/Elements/TemplateLine.h b/MeshLib/Elements/TemplateLine.h index b3c5bb29e246bdacf2ae45d34411f5d0b82b6971..858ef66944d9aa1cb26d1da9d4f4d5955a95ccc8 100644 --- a/MeshLib/Elements/TemplateLine.h +++ b/MeshLib/Elements/TemplateLine.h @@ -115,6 +115,9 @@ public: return false; } + /// Returns true if pnt is located on the line segment and false otherwise + bool isPntInElement(GeoLib::Point const& pnt) const; + /** * Tests if the element is geometrically valid. * @param check_zero_volume indicates if area == 0 should be checked diff --git a/MeshLib/Elements/TemplatePrism-impl.h b/MeshLib/Elements/TemplatePrism-impl.h index b6c00bf195b6ff47dca1fac979a14ed33e128080..52cf5bb251a24d39b08d695ad58bb05b079d2a36 100644 --- a/MeshLib/Elements/TemplatePrism-impl.h +++ b/MeshLib/Elements/TemplatePrism-impl.h @@ -148,6 +148,14 @@ bool TemplatePrism<NNODES,CELLPRISMTYPE>::isEdge(unsigned idx1, unsigned idx2) c return false; } +template <unsigned NNODES, CellType CELLPRISMTYPE> +bool TemplatePrism<NNODES,CELLPRISMTYPE>::isPntInElement(GeoLib::Point const& pnt) const +{ + return (GeoLib::isPointInTetrahedron(pnt, *_nodes[0], *_nodes[1], *_nodes[2], *_nodes[3]) || + GeoLib::isPointInTetrahedron(pnt, *_nodes[1], *_nodes[4], *_nodes[2], *_nodes[3]) || + GeoLib::isPointInTetrahedron(pnt, *_nodes[2], *_nodes[4], *_nodes[5], *_nodes[3])); +} + template <unsigned NNODES, CellType CELLPRISMTYPE> Element* TemplatePrism<NNODES,CELLPRISMTYPE>::clone() const { diff --git a/MeshLib/Elements/TemplatePrism.h b/MeshLib/Elements/TemplatePrism.h index d91f295402421c6098b989d12c33028fdf1a2c59..c390e99e9cf01a8964a99f95f67bddbca1c5b2d6 100644 --- a/MeshLib/Elements/TemplatePrism.h +++ b/MeshLib/Elements/TemplatePrism.h @@ -102,6 +102,9 @@ public: /// Returns true if these two indeces form an edge and false otherwise bool isEdge(unsigned i, unsigned j) const; + /// Returns true if the given point is not located outside of the prism + bool isPntInElement(GeoLib::Point const& pnt) const; + /** * Tests if the element is geometrically valid. * @param check_zero_volume indicates if volume == 0 should be checked diff --git a/MeshLib/Elements/TemplatePyramid-impl.h b/MeshLib/Elements/TemplatePyramid-impl.h index d21b6b0031a5513e7078d582684acc5de8b4b7df..823562a2995ff41e9d2ebd939b9cf02e58092bb5 100644 --- a/MeshLib/Elements/TemplatePyramid-impl.h +++ b/MeshLib/Elements/TemplatePyramid-impl.h @@ -150,6 +150,13 @@ bool TemplatePyramid<NNODES,CELLPYRAMIDTYPE>::isEdge(unsigned idx1, unsigned idx return false; } +template <unsigned NNODES, CellType CELLPYRAMIDTYPE> +bool TemplatePyramid<NNODES,CELLPYRAMIDTYPE>::isPntInElement(GeoLib::Point const& pnt) const +{ + return (GeoLib::isPointInTetrahedron(pnt, *_nodes[0], *_nodes[1], *_nodes[2], *_nodes[4]) || + GeoLib::isPointInTetrahedron(pnt, *_nodes[0], *_nodes[2], *_nodes[3], *_nodes[4])); +} + template <unsigned NNODES, CellType CELLPYRAMIDTYPE> Element* TemplatePyramid<NNODES,CELLPYRAMIDTYPE>::clone() const { diff --git a/MeshLib/Elements/TemplatePyramid.h b/MeshLib/Elements/TemplatePyramid.h index da8b34f776ea6e5fc6d8080e2c41c58521ed3de2..c12f169cc084833365d454cc09fd51b7ff99e9ea 100644 --- a/MeshLib/Elements/TemplatePyramid.h +++ b/MeshLib/Elements/TemplatePyramid.h @@ -100,6 +100,9 @@ public: /// Returns true if these two indeces form an edge and false otherwise bool isEdge(unsigned i, unsigned j) const; + /// Returns true if the given point is not located outside of the pyramid + bool isPntInElement(GeoLib::Point const& pnt) const; + /** * Tests if the element is geometrically valid. * @param check_zero_volume indicates if volume == 0 should be checked diff --git a/MeshLib/Elements/TemplateQuad.h b/MeshLib/Elements/TemplateQuad.h index 21c4fe4ed3e83dd42330fe245fa1bf0305a6a982..f7fd8e0889c20cc552a5ae0a556bead3013bbe33 100644 --- a/MeshLib/Elements/TemplateQuad.h +++ b/MeshLib/Elements/TemplateQuad.h @@ -89,6 +89,9 @@ public: /// Returns true if these two indeces form an edge and false otherwise bool isEdge(unsigned i, unsigned j) const; + /// Returns true if the given point is not located outside of the quad + bool isPntInElement(GeoLib::Point const& pnt) const { return isPntInside(pnt); } + /** * Check if the 3d GeoLib::Point is inside of the quad element. * @param pnt the 3d GeoLib::Point object diff --git a/MeshLib/Elements/TemplateTet-impl.h b/MeshLib/Elements/TemplateTet-impl.h index 601f5199bcffa76a395aa59fb7e404dfed971bce..c3c990a4409c3b69bb545fea0f604dd0a550cc91 100644 --- a/MeshLib/Elements/TemplateTet-impl.h +++ b/MeshLib/Elements/TemplateTet-impl.h @@ -128,6 +128,12 @@ bool TemplateTet<NNODES,CELLTETTYPE>::isEdge(unsigned idx1, unsigned idx2) const return false; } +template <unsigned NNODES, CellType CELLTETTYPE> +bool TemplateTet<NNODES,CELLTETTYPE>::isPntInElement(GeoLib::Point const& pnt) const +{ + return GeoLib::isPointInTetrahedron(pnt, *_nodes[0], *_nodes[1], *_nodes[2], *_nodes[3]); +} + template <unsigned NNODES, CellType CELLTETTYPE> Element* TemplateTet<NNODES,CELLTETTYPE>::clone() const { diff --git a/MeshLib/Elements/TemplateTet.h b/MeshLib/Elements/TemplateTet.h index b98c1e795802fbc65050cd3f573bdab93bc99cf1..530cbf0971444e374391a75c45e96978fb5257a8 100644 --- a/MeshLib/Elements/TemplateTet.h +++ b/MeshLib/Elements/TemplateTet.h @@ -99,6 +99,9 @@ public: /// Returns true if these two indeces form an edge and false otherwise bool isEdge(unsigned i, unsigned j) const; + /// Returns true if the given point is not located outside of the tetrahedron + bool isPntInElement(GeoLib::Point const& pnt) const; + /** * Tests if the element is geometrically valid. * @param check_zero_volume indicates if volume == 0 should be checked diff --git a/MeshLib/Elements/TemplateTri.h b/MeshLib/Elements/TemplateTri.h index 465a8daed055a51d38ec5f365a8f126f5361db28..325efe914b3e72451ee0cd61e2b0bc678e16c519 100644 --- a/MeshLib/Elements/TemplateTri.h +++ b/MeshLib/Elements/TemplateTri.h @@ -93,6 +93,9 @@ public: /// Returns true if these two indices form an edge and false otherwise bool isEdge(unsigned idx1, unsigned idx2) const; + /// Returns true if the given point is not located outside of the triangle + bool isPntInElement(GeoLib::Point const& pnt) const { return isPntInside(pnt); } + /** * Check if the 3d GeoLib::Point is inside of the element. * @param pnt the 3d GeoLib::Point object