diff --git a/Geo/GModel.h b/Geo/GModel.h index d7ba50aa8a693f03d951d0b62f075c4754b109ca..e03636bb6d92d18605b86bc5bdb55c389941afac 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -101,7 +101,7 @@ class GModel // loop over all vertices connected to elements and associate geo entity void associateEntityWithVertices(); - // Renumber all the mesh vertices in a continuous sequence + // Renumber all the (used) mesh vertices in a continuous sequence int renumberMeshVertices(bool saveAll); // Deletes all invisble mesh elements diff --git a/Geo/GeoInterpolation.cpp b/Geo/GeoInterpolation.cpp index a109c6e8032818cd587ce06d1dbf840a9de833b7..3af64b29f22b310c11f0e0ad4ed3ded5b4b910db 100644 --- a/Geo/GeoInterpolation.cpp +++ b/Geo/GeoInterpolation.cpp @@ -1,4 +1,4 @@ -// $Id: GeoInterpolation.cpp,v 1.25 2007-04-16 09:08:27 remacle Exp $ +// $Id: GeoInterpolation.cpp,v 1.26 2007-04-22 08:46:04 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -130,34 +130,35 @@ SPoint2 InterpolateCubicSpline(Vertex * v[4], double t, double mat[4][4], } // Uniform BSplines -Vertex InterpolateUBS(Curve * Curve, double u, int derivee) { - int NbControlPoints, NbCurves, iCurve; - double t, t1, t2; +Vertex InterpolateUBS(Curve * Curve, double u, int derivee) +{ + bool periodic = (Curve->end == Curve->beg); + int NbControlPoints = List_Nbr(Curve->Control_Points); + int NbCurves = NbControlPoints + (periodic ? -1 : 1); + int iCurve = (int)floor(u * (double)NbCurves); + if(iCurve == NbCurves) iCurve -= 1; // u = 1 + double t1 = (double)(iCurve) / (double)(NbCurves); + double t2 = (double)(iCurve+1) / (double)(NbCurves); + double t = (u - t1) / (t2 - t1); Vertex *v[4]; - Vertex V; - bool periodic=Curve->end==Curve->beg; - NbControlPoints = List_Nbr(Curve->Control_Points); - NbCurves = NbControlPoints +(periodic ? -1:+1) ; - iCurve = (int)floor(u * (double)NbCurves); - if(iCurve==NbCurves)iCurve-=1;//u=1 - t1 = (double)(iCurve) / (double)(NbCurves); - t2 = (double)(iCurve+1) / (double)(NbCurves); - t = (u - t1) / (t2 - t1); - for(int i=0;i<4;i++) { - int k=iCurve - (periodic?1:2) + i; - if (k<0) k=periodic ? k + NbControlPoints - 1 : 0; - if (k>=NbControlPoints) k=periodic ? k-NbControlPoints + 1: 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); + for(int i = 0; i < 4; i++) { + int k = iCurve - (periodic ? 1 : 2) + i; + if(k < 0) k = periodic ? k + NbControlPoints - 1 : 0; + if(k >= NbControlPoints) k = periodic ? k - NbControlPoints + 1: 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); + Vertex V; 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); + } + else + return InterpolateCubicSpline(v, t, Curve->mat, 0, t1, t2); } // Non Uniform BSplines @@ -207,11 +208,11 @@ Vertex InterpolateNurbs(Curve * Curve, double u, int derivee) { static double Nb[1000]; int span = findSpan(u, Curve->degre, List_Nbr(Curve->Control_Points), Curve->k); - Vertex p, *v; - basisFuns(u, span, Curve->degre, Curve->k, Nb); + Vertex p; p.Pos.X = p.Pos.Y = p.Pos.Z = p.w = p.lc = 0.0; for(int i = Curve->degre; i >= 0; --i) { + Vertex *v; List_Read(Curve->Control_Points, span - Curve->degre + i, &v); p.Pos.X += Nb[i] * v->Pos.X; p.Pos.Y += Nb[i] * v->Pos.Y; diff --git a/Mesh/BackgroundMesh.cpp b/Mesh/BackgroundMesh.cpp index 28268bc0c0984622391c54c31f7ee4dae71df014..c9a6de944d5dda3f2b259ddd4d387a71121770a3 100644 --- a/Mesh/BackgroundMesh.cpp +++ b/Mesh/BackgroundMesh.cpp @@ -1,4 +1,4 @@ -// $Id: BackgroundMesh.cpp,v 1.20 2007-04-21 19:40:00 geuzaine Exp $ +// $Id: BackgroundMesh.cpp,v 1.21 2007-04-22 08:46:04 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -131,7 +131,7 @@ double LC_MVertex_PNTS(GEntity *ge, double U, double V) { GVertex *gv = (GVertex *)ge; double lc = gv->prescribedMeshSizeAtVertex(); - if(lc >= MAX_LC) {return CTX.lc / 10.;} + if(lc >= MAX_LC) return CTX.lc / 10.; return lc; } case 1: diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp index 6a3def5bc459f6c5eb2a83c49b2bca25ea0a04de..d0dcae2cf1d9b650290fe62eb29f6ccb93ac8bb9 100644 --- a/Mesh/meshGEdge.cpp +++ b/Mesh/meshGEdge.cpp @@ -1,4 +1,4 @@ -// $Id: meshGEdge.cpp,v 1.34 2007-04-21 22:26:51 geuzaine Exp $ +// $Id: meshGEdge.cpp,v 1.35 2007-04-22 08:46:04 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -189,11 +189,12 @@ void deMeshGEdge::operator() (GEdge *ge) if(ge->meshRep) ge->meshRep->destroy(); } -double GPointDist(GPoint &p1,GPoint &p2){ - double dx=p1.x()-p2.x(); - double dy=p1.y()-p2.y(); - double dz=p1.z()-p2.z(); - return sqrt(dx*dx+dy*dy+dz*dz); +double GPointDist(GPoint &p1, GPoint &p2) +{ + double dx = p1.x() - p2.x(); + double dy = p1.y() - p2.y(); + double dz = p1.z() - p2.z(); + return sqrt(dx * dx + dy * dy + dz * dz); } void meshGEdge::operator() (GEdge *ge) @@ -303,5 +304,4 @@ void meshGEdge::operator() (GEdge *ge) v0->x() = beg_p.x(); v0->y() = beg_p.y(); v0->z() = beg_p.z(); - }