From dc5e1db778a33e6440b57afe685225406f712e06 Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Mon, 14 May 2007 10:34:55 +0000 Subject: [PATCH] *** empty log message *** --- Geo/gmshEdge.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/Geo/gmshEdge.cpp b/Geo/gmshEdge.cpp index be39b4f685..2f9a3eb1b3 100644 --- a/Geo/gmshEdge.cpp +++ b/Geo/gmshEdge.cpp @@ -1,4 +1,4 @@ -// $Id: gmshEdge.cpp,v 1.33 2007-03-13 16:11:43 remacle Exp $ +// $Id: gmshEdge.cpp,v 1.34 2007-05-14 10:34:55 remacle Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -144,6 +144,7 @@ SPoint2 gmshEdge::reparamOnFace(GFace *face, double epar,int dir) const { Surface *s = (Surface*) face->getNativePtr(); + bool periodic = (c->end == c->beg); if(s->geometry){ switch (c->Typ) { case MSH_SEGM_LINE: @@ -161,28 +162,21 @@ SPoint2 gmshEdge::reparamOnFace(GFace *face, double epar,int dir) const int NbControlPoints, NbCurves, iCurve; double t, t1, t2; Vertex *v[4]; - NbControlPoints = List_Nbr(c->Control_Points); - NbCurves = NbControlPoints - (c->beg==c->end ? 1 : 3); - - iCurve = (int)(epar * (double)NbCurves) + 1; - - if(iCurve > NbCurves) - iCurve = NbCurves; - else if (iCurve < 1) - iCurve = 1; - - t1 = (double)(iCurve - 1) / (double)(NbCurves); - t2 = (double)(iCurve) / (double)(NbCurves); + NbCurves = NbControlPoints + (periodic ? -1 : 1); + iCurve = (int)floor(epar * (double)NbCurves); + if(iCurve >= NbCurves) + iCurve = NbCurves-1; + else if (iCurve < 0) // ? does it happen ? + iCurve = 0; + t1 = (double)(iCurve) / (double)(NbCurves); + t2 = (double)(iCurve+1) / (double)(NbCurves); t = (epar - t1) / (t2 - t1); - for(int j = 0; j < 4; j ++ ){ - int k=iCurve - (c->beg==c->end ? 2 : 1) + j; - if(k<0) - k += NbControlPoints - 1; - if(k>=NbControlPoints) - k -= NbControlPoints - 1; + int k=iCurve - (periodic ? 1 : 2) + j; + if(k < 0) k = periodic ? k + NbControlPoints - 1 : 0; + if(k >= NbControlPoints) k = periodic ? k - NbControlPoints + 1: NbControlPoints - 1; List_Read(c->Control_Points,k, &v[j]); } return InterpolateCubicSpline(v, t, c->mat, 0, t1, t2,c->geometry); -- GitLab