diff --git a/Geo/GeoInterpolation.cpp b/Geo/GeoInterpolation.cpp index 48c7f9139fde7cc3cb6b2fc79e7b448477f9fc91..b619459c85016cf1b2e3d3b31dae31626b18b530 100644 --- a/Geo/GeoInterpolation.cpp +++ b/Geo/GeoInterpolation.cpp @@ -1,4 +1,4 @@ -// $Id: GeoInterpolation.cpp,v 1.22 2007-03-02 14:54:25 remacle Exp $ +// $Id: GeoInterpolation.cpp,v 1.23 2007-03-05 11:07:14 remacle Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -136,9 +136,10 @@ Vertex InterpolateUBS(Curve * Curve, double u, int derivee) int NbControlPoints, NbCurves, iCurve; double t, t1, t2; Vertex *v[4]; + Vertex V; NbControlPoints = List_Nbr(Curve->Control_Points); - NbCurves = NbControlPoints - 3; + NbCurves = NbControlPoints - (Curve->beg==Curve->end ? 1 : 3); iCurve = (int)(u * (double)NbCurves) + 1; @@ -152,12 +153,23 @@ Vertex InterpolateUBS(Curve * Curve, double u, int derivee) t = (u - t1) / (t2 - t1); - List_Read(Curve->Control_Points, iCurve - 1, &v[0]); - List_Read(Curve->Control_Points, iCurve, &v[1]); - List_Read(Curve->Control_Points, iCurve + 1, &v[2]); - List_Read(Curve->Control_Points, iCurve + 2, &v[3]); - - return InterpolateCubicSpline(v, t, Curve->mat, derivee, t1, t2); + for(int i=0;i<4;i++){ + int k=iCurve - (Curve->beg==Curve->end ? 2 : 1) + i; + if (k<0) k+=NbControlPoints - 1; + if (k>=NbControlPoints) k-=NbControlPoints - 1; + List_Read(Curve->Control_Points, k , &v[i]); + } + if (Curve->geometry) + { + SPoint2 pp = InterpolateCubicSpline(v, t, Curve->mat, 0, t1, t2,Curve->geometry); + SPoint3 pt = Curve->geometry->point(pp); + V.Pos.X = pt.x(); + V.Pos.Y = pt.y(); + V.Pos.Z = pt.z(); + return V; + } + else + return InterpolateCubicSpline(v, t, Curve->mat, 0, t1, t2); } // Non Uniform BSplines diff --git a/Geo/gmshEdge.cpp b/Geo/gmshEdge.cpp index 4cc1414ecceb7fdf57abe431cd8d2f978ecd4a03..7e5f0c44a957a09d24dda76b589946548323ab58 100644 --- a/Geo/gmshEdge.cpp +++ b/Geo/gmshEdge.cpp @@ -1,4 +1,4 @@ -// $Id: gmshEdge.cpp,v 1.31 2007-03-02 18:20:56 remacle Exp $ +// $Id: gmshEdge.cpp,v 1.32 2007-03-05 11:07:14 remacle Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -158,6 +158,36 @@ SPoint2 gmshEdge::reparamOnFace(GFace *face, double epar,int dir) const return p; } break; + case MSH_SEGM_BSPLN: + case MSH_SEGM_BEZIER: + 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); + + 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; + List_Read(c->Control_Points,k, &v[j]); + } + return InterpolateCubicSpline(v, t, c->mat, 0, t1, t2,c->geometry); case MSH_SEGM_SPLN : { Vertex *v[4];