From 0bc9114c90fe82f6526f1f73c133b447a3e3d7fa Mon Sep 17 00:00:00 2001
From: Akash Anand <akasha@iitk.ac.in>
Date: Wed, 16 May 2007 01:15:09 +0000
Subject: [PATCH] *** empty log message ***

---
 contrib/FourierModel/FM_Edge.h   |  2 +-
 contrib/FourierModel/FM_Face.cpp | 19 ++++++++++---------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/contrib/FourierModel/FM_Edge.h b/contrib/FourierModel/FM_Edge.h
index 5b411e2e5f..d7ae9da1c1 100644
--- a/contrib/FourierModel/FM_Edge.h
+++ b/contrib/FourierModel/FM_Edge.h
@@ -34,7 +34,7 @@ class FM_Edge {
     if (_curve)
       return true;
     else
-      false;
+      return false;
   }
 
   void F(double t, double &x, double &y, double &z);
diff --git a/contrib/FourierModel/FM_Face.cpp b/contrib/FourierModel/FM_Face.cpp
index 036756168f..7867459b14 100644
--- a/contrib/FourierModel/FM_Face.cpp
+++ b/contrib/FourierModel/FM_Face.cpp
@@ -2,17 +2,15 @@
 #include "Message.h"
 
 void FM_Face::F(double u, double v, double &x, double &y, double &z) {
-  if (_edge.size() == 4) {
-    _patch->F(u,v,x,y,z);
-  }
-  else if (_edge.size() == 1) {
-    // sanity check
+  if (_edge.size() == 1) {
+    double U = sqrt((2*u-1)*(2*u-1)+(2*v-1)*(2*v-1));
+    double V = 0.5 * (atan2(2*v-1,2*u-1)/ M_PI + 1.);
     double cx, cy, cz;
     _patch->F(0.,0.,cx,cy,cz);
     double px, py, pz;
-    _edge[0]->F(v,px,py,pz);
+    _edge[0]->F(V,px,py,pz);
     double R = sqrt((px-cx)*(px-cx)+(py-cy)*(py-cy)+(pz-cz)*(pz-cz));
-    _patch->F(u*R,v,x,y,z);
+    _patch->F(U*R,V,x,y,z);
   }
   else if (_edge.size() == 4) {
     bool isPhysical = (_edge[0]->IsPhysical()) && (_edge[1]->IsPhysical()) &&
@@ -65,12 +63,15 @@ bool FM_Face::Inverse(double x,double y,double z,double &u, double &v)
       xx += r[i] * t[i];
       yy += r[i] * s[i];
     }
-    v = atan2(yy, xx)/(2. * M_PI) +0.5;
+    double U,V;
+    V = atan2(yy, xx)/(2. * M_PI) +0.5;
     double px, py, pz;
     _edge[0]->F(v,px,py,pz);
     double R = sqrt((px-c[0])*(px-c[0])+(py-c[1])*(py-c[1])+
 		    (pz-c[2])*(pz-c[2]));
-    u = norm / R;
+    U = norm / R;
+    u = 0.5 * (1 + U * cos(2*M_PI*(v-0.5)));
+    v = 0.5 * (1 + U * cos(2*M_PI*(v-0.5)));
   }
   else if (_edge.size() == 4) {
     bool isPhysical = (_edge[0]->IsPhysical()) && (_edge[1]->IsPhysical()) &&
-- 
GitLab