From ea76524b16deceb926679fb88a5137d53bc88554 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 12 Feb 2009 16:10:09 +0000
Subject: [PATCH] never, *NEVER* interpolate plane surfaces in GeoInterpolation

---
 Geo/GeoInterpolation.cpp |  3 ++-
 Geo/gmshFace.cpp         | 16 ++++++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/Geo/GeoInterpolation.cpp b/Geo/GeoInterpolation.cpp
index 6d2eb6025c..3205e13325 100644
--- a/Geo/GeoInterpolation.cpp
+++ b/Geo/GeoInterpolation.cpp
@@ -656,7 +656,8 @@ Vertex InterpolateSurface(Surface *s, double u, double v, int derivee, int u_v)
     return InterpolateRuledSurface(s, u, v);
   case MSH_SURF_PLAN:
     {
-      Vertex T(u, v, .0);
+      Msg::Error("You should never be here (InterpolateSurface(MSH_PLANE)): contact support ;-)");
+      Vertex T(u, v, 0.);
       Vertex V(s->a, s->b, s->c);
       Projette(&V, s->plan);
       if(V.Pos.Z != 0.)
diff --git a/Geo/gmshFace.cpp b/Geo/gmshFace.cpp
index 596e4e6600..42d197c491 100644
--- a/Geo/gmshFace.cpp
+++ b/Geo/gmshFace.cpp
@@ -160,10 +160,18 @@ SVector3 gmshFace::normal(const SPoint2 &param) const
 
 Pair<SVector3,SVector3> gmshFace::firstDer(const SPoint2 &param) const
 {
-  Vertex vu = InterpolateSurface(s, param[0], param[1], 1, 1);
-  Vertex vv = InterpolateSurface(s, param[0], param[1], 1, 2);
-  return Pair<SVector3, SVector3>(SVector3(vu.Pos.X, vu.Pos.Y, vu.Pos.Z),
-                                  SVector3(vv.Pos.X, vv.Pos.Y, vv.Pos.Z));
+  if(s->Typ == MSH_SURF_PLAN && !s->geometry){
+    double x, y, z, VX[3], VY[3];
+    getMeanPlaneData(VX, VY, x, y, z);
+    return Pair<SVector3, SVector3>(SVector3(VX[0], VX[1], VX[2]),
+                                    SVector3(VY[0], VY[1], VY[2]));
+  }
+  else{
+    Vertex vu = InterpolateSurface(s, param[0], param[1], 1, 1);
+    Vertex vv = InterpolateSurface(s, param[0], param[1], 1, 2);
+    return Pair<SVector3, SVector3>(SVector3(vu.Pos.X, vu.Pos.Y, vu.Pos.Z),
+                                    SVector3(vv.Pos.X, vv.Pos.Y, vv.Pos.Z));
+  }
 }
 
 GPoint gmshFace::point(double par1, double par2) const
-- 
GitLab