From 82b2778a474fe6fc82e269de1289b7713405a0eb Mon Sep 17 00:00:00 2001
From: Jean-Marie Favreau <J-Marie.Favreau@udamail.fr>
Date: Fri, 15 Feb 2013 18:51:43 +0100
Subject: [PATCH] Correct the way that the radius is computed

---
 .../cylinder/CylinderProjection.cpp                | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/parameterization/cylinder/CylinderProjection.cpp b/src/parameterization/cylinder/CylinderProjection.cpp
index 3989f54..b912aa4 100644
--- a/src/parameterization/cylinder/CylinderProjection.cpp
+++ b/src/parameterization/cylinder/CylinderProjection.cpp
@@ -146,7 +146,7 @@ bool CylinderProjection::compute2DLocation(VertexID vnew, VertexID vknown) {
 
     // the y coordinate corresponds to the one of y plus the angle difference in the base plane
     const bool d = Coord3D::scalarProduct(axis, Coord3D::vectorialProduct(pnew, pknown)) > 0;
-    const double y = mapping[vknown].get2DY() + Coord3D::angleVector(pnew, pknown) * (d ? radius : - radius) * 5;
+    const double y = mapping[vknown].get2DY() + Coord3D::angleVector(pnew, pknown) * (d ? radius : - radius);
     mapping.set2DCoords(vnew, x, y);
     mesh.point(vnew).setFlag(1);
     return true;
@@ -164,8 +164,10 @@ void CylinderProjection::initAxis() {
 
 void CylinderProjection::estimateRadius() {
     assert(axis.norm() != 0.);
-    long double sumDistance = 0.;
-    for(Mesh::const_point_iterator p = mesh.point_begin(); p != mesh.point_end(); ++p)
-        sumDistance += (*p).distance(line);
-    radius = sumDistance / mesh.getNbPoints();
-}
+    radius = 0.;
+    for(Mesh::const_point_iterator p = mesh.point_begin(); p != mesh.point_end(); ++p) {
+        const double d = (*p).distance(line);
+        if (d > radius)
+            radius = d;
+    }
+ }
-- 
GitLab