From de9345f1877c982098b560690f7cf634d5e0aa54 Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Mon, 5 Mar 2007 11:07:14 +0000 Subject: [PATCH] *** empty log message *** --- Geo/GeoInterpolation.cpp | 28 ++++++++++++++++++++-------- Geo/gmshEdge.cpp | 32 +++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/Geo/GeoInterpolation.cpp b/Geo/GeoInterpolation.cpp index 48c7f9139f..b619459c85 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 4cc1414ecc..7e5f0c44a9 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]; -- GitLab