From 1cb47d2a322795c7019ee3423fb05207c2b7a714 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 21 Nov 2013 14:23:50 +0000
Subject: [PATCH] when reparamOnFace fails, try to find the closest point
 before resorting to simply using the linear interpolation

---
 Mesh/HighOrder.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Mesh/HighOrder.cpp b/Mesh/HighOrder.cpp
index 050123290f..b9f3e0255a 100644
--- a/Mesh/HighOrder.cpp
+++ b/Mesh/HighOrder.cpp
@@ -344,7 +344,11 @@ static void getFaceVertices(GFace *gf, MElement *incomplete, MElement *ele,
             }
           }
           else{
-            v = new MVertex(X, Y, Z, gf);
+            GPoint gp = gf->closestPoint(SPoint3(X, Y, Z), GUESS);
+            if(gp.succeeded())
+              v = new MVertex(gp.x(), gp.y(), gp.z(), gf);
+            else
+              v = new MVertex(X, Y, Z, gf);
           }
         }
         // should be expensive -> induces a new search each time
-- 
GitLab