From 6303b9d926562b73f7de96d53619329404f9d6b9 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Mon, 18 Nov 2019 11:14:02 +0100 Subject: [PATCH] some default implementations for basegeometry --- libsrc/meshing/basegeom.hpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/libsrc/meshing/basegeom.hpp b/libsrc/meshing/basegeom.hpp index 57e62353..a1ac8ac8 100644 --- a/libsrc/meshing/basegeom.hpp +++ b/libsrc/meshing/basegeom.hpp @@ -39,7 +39,12 @@ namespace netgen const EdgePointGeomInfo& gi1, const EdgePointGeomInfo& gi2, Point<3>& newp, - EdgePointGeomInfo& newgi) const = 0; + EdgePointGeomInfo& newgi) const + { + newp = p1 + secpoint * (p2-p1); + newgi = gi1; + ProjectPoint(newp, &newgi); + } virtual Vec<3> GetTangent(double t) const = 0; }; @@ -54,7 +59,12 @@ namespace netgen // Project point using geo info. Fast if point is close to // parametrization in geo info. virtual bool ProjectPointGI(Point<3>& p, PointGeomInfo& gi) const =0; - virtual bool CalcPointGeomInfo(const Point<3>& p, PointGeomInfo& gi) const = 0; + virtual bool CalcPointGeomInfo(const Point<3>& p, PointGeomInfo& gi) const + { + auto pnew = p; + gi = Project(pnew); + return (p-pnew).Length() < 1e-10 * GetBoundingBox().Diam() ; + } virtual Point<3> GetPoint(const PointGeomInfo& gi) const = 0; virtual void CalcEdgePointGI(const GeometryEdge& edge, double t, @@ -73,7 +83,15 @@ namespace netgen const PointGeomInfo& gi1, const PointGeomInfo& gi2, Point<3>& newp, - PointGeomInfo& newgi) const = 0; + PointGeomInfo& newgi) const + { + newp = p1 + secpoint * (p2-p1); + newgi.trignum = gi1.trignum; + newgi.u = 0.5 * (gi1.u + gi1.u); + newgi.v = 0.5 * (gi1.v + gi2.v); + if(!ProjectPointGI(newp, newgi)) + newgi = Project(newp); + } protected: void RestrictHTrig(Mesh& mesh,