+ gp_Pnt2d Pf = C2d->Value(f);
+ gp_Pnt2d Pl = C2d->Value(l);
+ const Standard_Real Um = 0.34*f + 0.66*l;
+ gp_Pnt2d Pm = C2d->Value( Um );
+
+ // sometimes on shpere, pcurve is out of domain by V though S is
+ // UPeriodic, sometimes it is in domain but nontheless it has
+ // wrong position.
+ // Check pcurve position by 3D point
+ if (S->IsKind(STANDARD_TYPE( Geom_SphericalSurface )))
+ {
+ // get point on the surface
+ gp_Pnt Ps = S->Value( Pm.X(), Pm.Y() );
+ // get point on the edge
+ Handle(Geom_Curve) C = BRep_Tool::Curve( E, f, l );
+ gp_Pnt Pc = C->Value( Um );
+ // compare points
+ Standard_Real TolE = BRep_Tool::Tolerance( E );
+ if ( Pc.SquareDistance( Ps ) * 0.95 < TolE * TolE )
+ return; // OK
+
+ // find good UV for Pc: project Pc on S
+ GeomAdaptor_Surface SA (S);
+ Extrema_ExtPS anExtPS (Pc, SA,
+ SA.UResolution( TolE ), SA.VResolution( TolE ));
+ if (anExtPS.IsDone())
+ {
+ Standard_Integer i, nbExt = anExtPS.NbExt();
+ Extrema_POnSurf aPOnSurf;
+ for (i = 1; i <= nbExt; ++i )
+ if (anExtPS.Value( i ) <= TolE) {
+ aPOnSurf = anExtPS.Point( i );
+ break;
+ }
+ if (i <= nbExt) {
+ // a point found
+ Standard_Real u, v;
+ aPOnSurf.Parameter( u, v );
+ gp_Pnt2d aGoodPm ( u, v );
+ C2d->Translate( Pm , aGoodPm );
+ }
+ }
+ }
+
+ //---------------
+ // Recadre en U.
+ //---------------