From 6e64b466e1a74937a91fd0ada66e267e598071cf Mon Sep 17 00:00:00 2001
From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be>
Date: Mon, 19 Jan 2009 11:57:29 +0000
Subject: [PATCH] back to old stereo projection

---
 Geo/gmshSurface.cpp | 9 ++++-----
 Mesh/Field.cpp      | 1 +
 Plugin/GSHHS.cpp    | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Geo/gmshSurface.cpp b/Geo/gmshSurface.cpp
index c178318f2c..cebbb00452 100644
--- a/Geo/gmshSurface.cpp
+++ b/Geo/gmshSurface.cpp
@@ -83,14 +83,13 @@ gmshSurface *gmshPolarSphere::NewPolarSphere(int iSphere, double x, double y, do
 
 gmshPolarSphere::gmshPolarSphere(double x, double y, double z, double _r) : r(_r), o(x,y,z) {
 }
-SPoint3 gmshPolarSphere::point(double parA, double parB) const
+SPoint3 gmshPolarSphere::point(double u, double v) const
 {
   //stereographic projection from the south pole, origin of the axis
   //at the center of the sphere 
-  //parA=2rx/(r+z) parB=2ry/(r+z)
-  double rp2 = parA * parA + parB * parB;
-  double z=r*(4*r*r-rp2)/(4*r*r+rp2);
-  SPoint3 p(parA*(r+z)/(2*r),parB*(r+z)/(2*r),z);
+  //u=-x/(r+z) v=-y/(r+z)
+  double rp2 = u*u+v*v;
+  SPoint3 p(-2*r*u/(1+rp2),-2*r*v/(1+rp2),r*(1-rp2)/(1+rp2));
   p += o;
   return p;
 }
diff --git a/Mesh/Field.cpp b/Mesh/Field.cpp
index e86b9beec0..5267d91184 100644
--- a/Mesh/Field.cpp
+++ b/Mesh/Field.cpp
@@ -1346,6 +1346,7 @@ void Field::put_on_view(PView *view, int comp)
   data->setName(oss.str());
   data->finalize();
   view->setChanged(true);
+  data->destroyAdaptiveData();
 }
 #endif
 
diff --git a/Plugin/GSHHS.cpp b/Plugin/GSHHS.cpp
index 83033d7aec..25b2803fc9 100644
--- a/Plugin/GSHHS.cpp
+++ b/Plugin/GSHHS.cpp
@@ -51,7 +51,7 @@ class GMSH_GSHHSPlugin:public GMSH_Post_Plugin
       }
     };
     class reader_gshhs:public reader{
-      /*	$Id: GSHHS.cpp,v 1.23 2009-01-15 13:28:30 remacle Exp $
+      /*	$Id: GSHHS.cpp,v 1.24 2009-01-19 11:57:29 remacle Exp $
        *
        * Include file defining structures used in gshhs.c
        *
@@ -767,7 +767,7 @@ class GMSH_GSHHSPlugin:public GMSH_Post_Plugin
       }
       void add_point(SPoint3 point){
         double r=sqrt(point.x()*point.x()+point.y()*point.y()+point.z()*point.z());
-        SPoint2 stereo(2*r*point.x() / (r + point.z()), 2*r*point.y() / (r + point.z()));
+        SPoint2 stereo(-point.x() / (r + point.z()), -point.y() / (r + point.z()));
         loop_buff << "Point ( IP + " << ip++ << " ) = {" << stereo.
           x() << ", " << stereo.y() << ", " << 0 << " };\n";
       }
-- 
GitLab