1 // File: Approx_SameParameter.cxx
2 // Created: Tue Jun 6 09:51:17 1995
3 // Author: Xavier BENVENISTE
6 // Modified by skv - Wed Jun 2 11:49:59 2004 OCC5898
8 #include <Approx_SameParameter.ixx>
9 #include <TColStd_Array1OfReal.hxx>
10 #include <BSplCLib.hxx>
11 #include <Adaptor3d_CurveOnSurface.hxx>
12 #include <Geom2dAdaptor_Curve.hxx>
13 #include <Geom2dAdaptor_HCurve.hxx>
14 #include <GeomAdaptor_Curve.hxx>
15 #include <GeomAdaptor_HCurve.hxx>
16 #include <GeomAdaptor_Surface.hxx>
17 #include <GeomAdaptor_HSurface.hxx>
18 //#include <GCPnts_UniformDeflection.hxx>
19 #include <GCPnts_QuasiUniformDeflection.hxx>
20 #include <Extrema_LocateExtPC.hxx>
21 #include <AdvApprox_ApproxAFunction.hxx>
22 #include <GeomLib_MakeCurvefromApprox.hxx>
23 #include <Precision.hxx>
25 #define MAX_ARRAY_SIZE 1000 // IFV, Jan 2000
29 #include <DrawTrSurf.hxx>
31 #include <Geom2d_BSplineCurve.hxx>
33 static Standard_Boolean Voir = Standard_False;
34 static Standard_Boolean AffichFw = Standard_False;
35 static Standard_Integer NbCurve = 0;
38 // sert a tester si Extrema raconte pas des betises
42 static void ProjectPointOnCurve(const Standard_Real InitValue,
44 const Standard_Real Tolerance,
45 const Standard_Integer NumIteration,
46 const Adaptor3d_Curve& Curve,
47 Standard_Boolean& Status,
48 Standard_Real& Result)
50 Standard_Integer num_iter = 0,
61 Status = Standard_False ;
62 Standard_Real Toler = 1.0e-12;
69 for (ii = 1 ; ii <= 3 ; ii++) {
70 vector.SetCoord(ii, APoint.Coord(ii) - a_point.Coord(ii)) ;
72 func = vector.Dot(d1) ;
73 func_derivative = vector.Dot(d2) ;
74 func_derivative -= d1.Dot(d1) ;
75 if ( Abs(func) < Tolerance * d1.Magnitude()) {
77 Status = Standard_True ;
80 { // fixing a bug PRO18577 : avoid divizion by zero
81 if( Abs(func_derivative) > Toler ) {
82 param -= func / func_derivative ;
84 param = Max(param,Curve.FirstParameter()) ;
85 param = Min(param,Curve.LastParameter()) ;
86 Status = Standard_True ;
89 while (not_done && num_iter <= NumIteration) ;
95 //=======================================================================
96 //class : Approx_SameParameter_Evaluator
98 //=======================================================================
100 class Approx_SameParameter_Evaluator : public AdvApprox_EvaluatorFunction
103 Approx_SameParameter_Evaluator (const TColStd_Array1OfReal& theFlatKnots,
104 const TColStd_Array1OfReal& thePoles,
105 const Handle(Adaptor2d_HCurve2d)& theHCurve2d)
106 : FlatKnots(theFlatKnots), Poles(thePoles), HCurve2d(theHCurve2d) {}
108 virtual void Evaluate (Standard_Integer *Dimension,
109 Standard_Real StartEnd[2],
110 Standard_Real *Parameter,
111 Standard_Integer *DerivativeRequest,
112 Standard_Real *Result, // [Dimension]
113 Standard_Integer *ErrorCode);
116 const TColStd_Array1OfReal& FlatKnots;
117 const TColStd_Array1OfReal& Poles;
118 Handle(Adaptor2d_HCurve2d) HCurve2d;
121 void Approx_SameParameter_Evaluator::Evaluate (Standard_Integer *,/*Dimension*/
122 Standard_Real /*StartEnd*/[2],
123 Standard_Real *Parameter,
124 Standard_Integer *DerivativeRequest,
125 Standard_Real *Result,
126 Standard_Integer *ReturnCode)
130 Standard_Integer extrap_mode[2] ;
131 extrap_mode[0] = extrap_mode[1] = 3;
132 Standard_Real eval_result[2] ;
133 Standard_Real *PolesArray =
134 (Standard_Real *) &Poles(Poles.Lower()) ;
136 // evaluate the 1D bspline that represents the change in parameterization
138 BSplCLib::Eval(*Parameter,
149 if (*DerivativeRequest == 0){
150 HCurve2d->D0(eval_result[0],Point);
151 Point.Coord(Result[0],Result[1]);
153 else if (*DerivativeRequest == 1){
154 HCurve2d->D1(eval_result[0], Point, Vector);
155 Vector.Multiply(eval_result[1]);
156 Vector.Coord(Result[0],Result[1]);
161 static Standard_Real ComputeTolReached(const Handle(Adaptor3d_HCurve)& c3d,
162 const Adaptor3d_CurveOnSurface& cons,
163 const Standard_Integer nbp)
165 Standard_Real d2 = 0.;
166 Standard_Integer nn = nbp;
167 Standard_Real unsurnn = 1./nn;
168 Standard_Real first = c3d->FirstParameter();
169 Standard_Real last = c3d->LastParameter();
170 for(Standard_Integer i = 0; i <= nn; i++){
171 Standard_Real t = unsurnn*i;
172 Standard_Real u = first*(1.-t) + last*t;
173 gp_Pnt Pc3d = c3d->Value(u);
174 gp_Pnt Pcons = cons.Value(u);
175 if (Precision::IsInfinite(Pcons.X()) ||
176 Precision::IsInfinite(Pcons.Y()) ||
177 Precision::IsInfinite(Pcons.Z())) {
178 d2=Precision::Infinite();
181 Standard_Real temp = Pc3d.SquareDistance(Pcons);
182 if(temp > d2) d2 = temp;
185 if(d2<1.e-7) d2 = 1.e-7;
189 static Standard_Boolean Check(const TColStd_Array1OfReal& FlatKnots,
190 const TColStd_Array1OfReal& Poles,
191 const Standard_Integer nbp,
192 const TColStd_Array1OfReal& pc3d,
193 // const TColStd_Array1OfReal& pcons,
194 const TColStd_Array1OfReal& ,
195 const Handle(Adaptor3d_HCurve)& c3d,
196 const Adaptor3d_CurveOnSurface& cons,
198 const Standard_Real oldtol)
200 Standard_Real d = tol;
201 Standard_Integer extrap_mode[2] ;
202 extrap_mode[0] = extrap_mode[1] = 3;
207 cout<<"Controle du changement de variable : "<<endl;
208 cout<<"baillement mesure par projection : "<<d<<endl;
209 cout<<"Nombre de points : "<<nbp<<endl;
213 Standard_Real glis = 0., dglis = 0.;
214 for(i = 1; i <= nbp; i++){
215 Standard_Real tc3d = pc3d(i);
216 gp_Pnt Pc3d = c3d->Value(tc3d);
218 BSplCLib::Eval(tc3d,Standard_False,0,extrap_mode[0],
219 3,FlatKnots,1, (Standard_Real&)Poles(1),tcons);
220 gp_Pnt Pcons = cons.Value(tcons);
221 Standard_Real temp = Pc3d.SquareDistance(Pcons);
222 if(temp >= dglis) dglis = temp;
223 temp = Abs(tcons-pcons(i));
224 if(temp >= glis) glis = temp;
229 cout<<"glissement de parametre aux points imposes : "<<glis<<endl;
230 cout<<"distance de glissement aux points imposes : "<<dglis<<endl;
234 for(i = 1; i < nbp; i++){
235 Standard_Real tc3d = 0.5*(pc3d(i)+pc3d(i+1));
236 gp_Pnt Pc3d = c3d->Value(tc3d);
238 BSplCLib::Eval(tc3d,Standard_False,0,extrap_mode[0],
239 3,FlatKnots,1, (Standard_Real&)Poles(1),tcons);
240 gp_Pnt Pcons = cons.Value(tcons);
241 Standard_Real temp = Pc3d.SquareDistance(Pcons);
242 if(temp >= dglis) dglis = temp;
247 cout<<"distance de glissement en milieu d intervals : "<<dglis<<endl;
251 Standard_Real d2 = 0.;
252 Standard_Integer nn = 2*nbp;
253 Standard_Real unsurnn = 1./nn;
254 // Modified by skv - Wed Jun 2 11:49:59 2004 OCC5898 Begin
255 // Correction of the interval of valid values. This condition has no sensible
256 // grounds. But it is better then the old one (which is commented out) because
257 // it fixes the bug OCC5898. To develop more or less sensible criterion it is
258 // necessary to deeply investigate this problem which is not possible in frames
261 // Standard_Real firstborne= 2*pc3d(1)-pc3d(nbp);
262 // Standard_Real lastborne= 2*pc3d(nbp)-pc3d(1);
263 Standard_Real firstborne= 3.*pc3d(1) - 2.*pc3d(nbp);
264 Standard_Real lastborne = 3.*pc3d(nbp) - 2.*pc3d(1);
265 // Modified by skv - Wed Jun 2 11:50:03 2004 OCC5898 End
266 for(i = 0; i <= nn; i++){
267 Standard_Real t = unsurnn*i;
268 Standard_Real tc3d = pc3d(1)*(1.-t) + pc3d(nbp)*t;
269 gp_Pnt Pc3d = c3d->Value(tc3d);
271 BSplCLib::Eval(tc3d,Standard_False,0,extrap_mode[0],
272 3,FlatKnots,1, (Standard_Real&)Poles(1),tcons);
273 if (tcons < firstborne || tcons > lastborne) {
274 tol=Precision::Infinite();
275 return Standard_False;
277 gp_Pnt Pcons = cons.Value(tcons);
278 Standard_Real temp = Pc3d.SquareDistance(Pcons);
279 if(temp > d2) d2 = temp;
284 cout<<"distance max sur "<<nn<<" points : "<<tol<<endl<<endl;
286 return ((tol <= d) || (tol > 0.8 * oldtol));
290 //=======================================================================
291 //function : Approx_SameParameter
293 //=======================================================================
295 Approx_SameParameter::Approx_SameParameter(const Handle(Geom_Curve)& C3D,
296 const Handle(Geom2d_Curve)& C2D,
297 const Handle(Geom_Surface)& S,
298 const Standard_Real Tol):
299 mySameParameter(Standard_True), myDone(Standard_False)
301 myHCurve2d = new Geom2dAdaptor_HCurve(C2D);
302 myC3d = new GeomAdaptor_HCurve(C3D);
303 mySurf = new GeomAdaptor_HSurface(S);
308 //=======================================================================
309 //function : Approx_SameParameter
311 //=======================================================================
313 Approx_SameParameter::Approx_SameParameter(const Handle(Adaptor3d_HCurve)& C3D,
314 const Handle(Geom2d_Curve)& C2D,
315 const Handle(Adaptor3d_HSurface)& S,
316 const Standard_Real Tol):
317 mySameParameter(Standard_True), myDone(Standard_False)
321 myHCurve2d = new Geom2dAdaptor_HCurve(C2D);
326 //=======================================================================
327 //function : Approx_SameParameter
329 //=======================================================================
331 Approx_SameParameter::Approx_SameParameter(const Handle(Adaptor3d_HCurve)& C3D,
332 const Handle(Adaptor2d_HCurve2d)& C2D,
333 const Handle(Adaptor3d_HSurface)& S,
334 const Standard_Real Tol):
335 mySameParameter(Standard_True), myDone(Standard_False)
344 //=======================================================================
347 //=======================================================================
349 void Approx_SameParameter::Build(const Standard_Real Tolerance)
351 Standard_Integer ii ;
352 Adaptor3d_CurveOnSurface CurveOnSurface(myHCurve2d,mySurf);
353 Standard_Real fcons = CurveOnSurface.FirstParameter();
354 Standard_Real lcons = CurveOnSurface.LastParameter();
355 Standard_Real fc3d = myC3d->FirstParameter();
356 Standard_Real lc3d = myC3d->LastParameter();
358 GeomAbs_Shape Continuity = myHCurve2d->Continuity();
360 if(Continuity > GeomAbs_C1) Continuity = GeomAbs_C1;
362 //On controle les tangentes aux extremites pour savoir si le
363 //reparametrage est possible et on calcule les tangentes aux
364 //extremites de la fonction de changement de variable.
365 Standard_Real tangent[2];
369 Standard_Real Tol = Tolerance;
370 Standard_Real Tol2 = Tol * Tol;
371 Standard_Real Tolp = myC3d->Resolution(Tol), deltamin = 50*Tolp;
373 Standard_Real besttol2 = Tol2;
374 Standard_Boolean extrok = 0;
377 CurveOnSurface.D1(fcons,Pcons,Vcons);
378 myC3d->D1(fc3d,Pc3d,Vc3d);
379 Standard_Real dist2 = Pcons.SquareDistance(Pc3d);
380 Standard_Real dmax2 = dist2;
382 Standard_Real magVcons = Vcons.Magnitude();
383 if (magVcons > 1.e-12){
384 tangent[0] = Vc3d.Magnitude() / magVcons;
388 CurveOnSurface.D1(lcons,Pcons,Vcons);
389 myC3d->D1(lc3d,Pc3d,Vc3d);
390 dist2 = Pcons.SquareDistance(Pc3d);
392 if(dist2 > dmax2) dmax2 = dist2;
393 magVcons = Vcons.Magnitude();
394 if (magVcons > 1.e-12){
395 tangent[1] = Vc3d.Magnitude() / magVcons;
400 if(dmax2 > besttol2) besttol2 = dmax2;
402 //On prend un multiple de l echantillon du CheckShape,
403 //au moins les points de controle seront bons. No comment!!!
405 Standard_Integer NCONTROL = 22;
407 Standard_Integer nbcoups = 0;
410 Standard_Boolean interpolok = 0;
411 Standard_Real tolsov = 1.e200;
412 //On prend des parametres a pas constant sur la curve on surface
413 //et sur la courbe 3d.
414 Standard_Real deltacons = lcons - fcons;
415 deltacons /= (NCONTROL);
416 Standard_Real deltac3d = lc3d - fc3d;
417 deltac3d /= (NCONTROL);
419 Standard_Real wcons = fcons;
420 Standard_Real wc3d = fc3d;
422 Standard_Real qpcons[MAX_ARRAY_SIZE], qnewpcons[MAX_ARRAY_SIZE],
423 qpc3d[MAX_ARRAY_SIZE], qnewpc3d[MAX_ARRAY_SIZE];
424 Standard_Real * pcons = qpcons; Standard_Real * newpcons = qnewpcons;
425 Standard_Real * pc3d = qpc3d; Standard_Real * newpc3d = qnewpc3d;
427 for ( ii = 0 ; ii < NCONTROL; ii++) {
433 pcons[NCONTROL] = lcons;
434 pc3d[NCONTROL] = lc3d;
436 Standard_Integer New_NCONTROL = NCONTROL;
437 if(Continuity < GeomAbs_C1) {
438 Standard_Integer NbInt = myHCurve2d->NbIntervals(GeomAbs_C1) + 1;
439 TColStd_Array1OfReal Param_de_decoupeC1 (1, NbInt);
440 myHCurve2d->Intervals(Param_de_decoupeC1, GeomAbs_C1);
441 TColStd_SequenceOfReal new_par;
442 Standard_Integer inter = 1;
444 new_par.Append(fcons);
446 while(Param_de_decoupeC1(inter) <= fcons + deltamin) inter++;
447 while(Param_de_decoupeC1(NbInt) >= lcons - deltamin) NbInt--;
449 while(inter <= NbInt || ii < NCONTROL) {
450 if(Param_de_decoupeC1(inter) < pcons[ii]) {
451 new_par.Append(Param_de_decoupeC1(inter));
452 if((pcons[ii] - Param_de_decoupeC1(inter)) <= deltamin) {
454 if(ii > NCONTROL) {ii = NCONTROL;}
459 if((Param_de_decoupeC1(inter) - pcons[ii]) > deltamin) {
460 new_par.Append(pcons[ii]);
466 new_par.Append(lcons);
467 New_NCONTROL = new_par.Length() - 1;
468 //simple protection if New_NCONTROL > allocated elements in array
469 if (New_NCONTROL > MAX_ARRAY_SIZE) {
470 mySameParameter = Standard_False;
473 for(ii = 1; ii <= New_NCONTROL; ii++){
474 pcons[ii] = pc3d[ii] = new_par.Value(ii + 1);
476 pc3d[New_NCONTROL] = lc3d;
480 Extrema_LocateExtPC Projector;
481 Projector.Initialize(myC3d->Curve(),fc3d,lc3d,Tol);
483 Standard_Integer count = 1;
484 Standard_Real previousp = fc3d, initp=0, curp;//, deltamin = 50*Tolp;
485 Standard_Real bornesup = lc3d - deltamin;
486 Standard_Boolean projok = 0,
488 for (ii = 1; ii < New_NCONTROL; ii++){
489 CurveOnSurface.D0(pcons[ii],Pcons);
490 myC3d->D0(pc3d[ii],Pc3d);
491 dist2 = Pcons.SquareDistance(Pc3d);
492 use_parameter = (dist2 <= Tol2 && (pc3d[ii] > pc3d[count-1] + deltamin)) ;
495 if(dist2 > dmax2) dmax2 = dist2;
496 initp = previousp = pc3d[count] = pc3d[ii];
497 pcons[count] = pcons[ii];
501 if(!projok) initp = pc3d[ii];
502 projok = mySameParameter = Standard_False;
503 Projector.Perform(Pcons, initp);
504 if (Projector.IsDone()) {
505 curp = Projector.Point().Parameter();
506 Standard_Real dist_2 = Projector.SquareDistance();
507 if(dist_2 > besttol2) besttol2 = dist_2;
511 ProjectPointOnCurve(initp,Pcons,Tol,30,myC3d->Curve(),projok,curp);
514 if(curp > previousp + deltamin && curp < bornesup){
515 initp = previousp = pc3d[count] = curp;
516 pcons[count] = pcons[ii];
523 cout << "Projection not done" << endl;
529 myTolReached = 1.5*sqrt(dmax2);
533 if(!extrok) { // Si pas deja SameP et tgte aux fraise, on abandonne.
534 mySameParameter = Standard_False;
536 cout<<"SameParameter probleme : tangente nulle aux extremites"<<endl;
541 pcons[count] = lcons;
548 TColgp_Array1OfPnt2d DEBP2d (0,count);
549 TColStd_Array1OfInteger DEBMults(0,count);
550 DEBMults.Init(1); DEBMults(0) = 2; DEBMults(count) = 2;
551 TColStd_Array1OfReal DEBKnots(0,count);
552 for (Standard_Integer DEBi = 0; DEBi <= count; DEBi++) {
553 DEBKnots(DEBi) = DEBi;
554 DEBP2d (DEBi) = gp_Pnt2d(pc3d[DEBi],pcons[DEBi]);
556 Handle(Geom2d_BSplineCurve) DEBBS =
557 new Geom2d_BSplineCurve(DEBP2d,DEBKnots,DEBMults,1);
558 sprintf(Name,"DEBC2d_%d",++NbCurve);
560 DrawTrSurf::Set(Name,DEBBS);
566 // Les tableaux et leurs bornes pour l interpolation.
567 Standard_Integer num_knots = count + 7;
568 Standard_Integer num_poles = count + 3;
569 TColStd_Array1OfReal Paramc3d(*pc3d,1,count+1);
570 TColStd_Array1OfReal Paramcons(*pcons,1,count+1);
571 TColStd_Array1OfInteger ContactOrder(1,num_poles) ;
572 TColStd_Array1OfReal Poles(1,num_poles) ;
573 TColStd_Array1OfReal InterpolationParameters(1,num_poles) ;
574 TColStd_Array1OfReal FlatKnots(1,num_knots) ;
576 // On remplit les tableaux en faisant attention aux valeurs des bouts.
577 ContactOrder.Init(0);
578 ContactOrder(2) = ContactOrder(num_poles - 1) = 1;
580 FlatKnots(1) = FlatKnots(2) = FlatKnots(3) = FlatKnots(4) = fc3d;
581 FlatKnots(num_poles + 1) = FlatKnots(num_poles + 2) =
582 FlatKnots(num_poles + 3) = FlatKnots(num_poles + 4) = lc3d;
584 Poles(1) = fcons; Poles(num_poles) = lcons;
585 Poles(2) = tangent[0]; Poles(num_poles - 1) = tangent[1];
587 InterpolationParameters(1) = InterpolationParameters(2) = fc3d;
588 InterpolationParameters(num_poles - 1) = InterpolationParameters(num_poles) = lc3d;
590 for (ii = 3; ii <= num_poles - 2; ii++) {
591 Poles(ii) = Paramcons(ii - 1);
592 InterpolationParameters(ii) = FlatKnots(ii+2) = Paramc3d(ii - 1);
594 Standard_Integer inversion_problem;
595 BSplCLib::Interpolate(3,FlatKnots,InterpolationParameters,ContactOrder,
596 1,Poles(1),inversion_problem);
597 if(inversion_problem) {
598 Standard_ConstructionError::Raise();
601 //-------------------------------------------
607 Standard_Integer nnn = 100;
608 TColgp_Array1OfPnt2d DEBP2d (0,nnn);
609 TColStd_Array1OfInteger DEBMults(0,nnn);
610 DEBMults.Init(1); DEBMults(0) = 2; DEBMults(nnn) = 2;
611 TColStd_Array1OfReal DEBKnots(0,nnn);
612 Standard_Real du = (lc3d - fc3d) / nnn;
613 Standard_Real u3d = fc3d;
614 Standard_Integer extrap_mode[2] ;
615 extrap_mode[0] = extrap_mode[1] = 3;
616 Standard_Real eval_result[2] ;
617 Standard_Integer DerivativeRequest = 0;
618 Standard_Real *PolesArray =
619 (Standard_Real *) &Poles(Poles.Lower()) ;
621 for (Standard_Integer DEBi = 0; DEBi <= nnn; DEBi++) {
622 DEBKnots(DEBi) = DEBi;
633 DEBP2d (DEBi) = gp_Pnt2d(u3d,eval_result[0]);
637 Handle(Geom2d_BSplineCurve) DEBBS =
638 new Geom2d_BSplineCurve(DEBP2d,DEBKnots,DEBMults,1);
639 sprintf(Name,"DEBC2d_%d_%d",NbCurve,nbcoups );
641 DrawTrSurf::Set(Name,DEBBS);
645 //-------------------------------------------
647 //-------------------------------------------
648 // Test if par2d(par3d) is monotonous function or not ----- IFV, Jan 2000
649 // and try to insert new point to improve BSpline interpolation
651 Standard_Integer extrap_mode[2] ;
652 extrap_mode[0] = extrap_mode[1] = 3;
653 Standard_Real eval_result[2] ;
654 Standard_Integer DerivativeRequest = 0;
655 Standard_Real *PolesArray =
656 (Standard_Real *) &Poles(Poles.Lower()) ;
658 Standard_Integer newcount = 0;
659 for (ii = 0; ii < count; ii++) {
661 newpcons[newcount] = pcons[ii];
662 newpc3d[newcount] = pc3d[ii];
665 if(count - ii + newcount == MAX_ARRAY_SIZE) continue;
667 BSplCLib::Eval(.5*(pc3d[ii]+pc3d[ii+1]), Standard_False, DerivativeRequest,
668 extrap_mode[0], 3, FlatKnots, 1, PolesArray[0], eval_result[0]);
670 if(eval_result[0] < pcons[ii] || eval_result[0] > pcons[ii+1]) {
671 Standard_Real ucons = 0.5*(pcons[ii]+pcons[ii+1]);
672 Standard_Real uc3d = 0.5*(pc3d[ii]+pc3d[ii+1]);
674 CurveOnSurface.D0(ucons,Pcons);
675 Projector.Perform(Pcons, uc3d);
676 if (Projector.IsDone()) {
677 curp = Projector.Point().Parameter();
678 Standard_Real dist_2 = Projector.SquareDistance();
679 if(dist_2 > besttol2) besttol2 = dist_2;
683 ProjectPointOnCurve(uc3d,Pcons,Tol,30,myC3d->Curve(),projok,curp);
686 if(curp > pc3d[ii] + deltamin && curp < pc3d[ii+1] - deltamin){
687 newpc3d[newcount] = curp;
688 newpcons[newcount] = ucons;
695 cout << "Projection not done" << endl;
702 newpc3d[newcount] = pc3d[count];
703 newpcons[newcount] = pcons[count];
704 Standard_Real * temp;
712 if((count != newcount) && newcount < MAX_ARRAY_SIZE) { count = newcount; continue;}
716 Standard_Real algtol = sqrt(besttol2);
718 interpolok = Check (FlatKnots, Poles, count+1, Paramc3d, Paramcons,
719 myC3d, CurveOnSurface, algtol, tolsov);
721 if (Precision::IsInfinite(algtol)) {
722 mySameParameter = Standard_False;
724 cout<<"SameParameter probleme : fonction d'interpolation du parametrage aux fraises !!"<<endl;
731 interpolok = (interpolok || count >= MAX_ARRAY_SIZE);
734 Standard_Real besttol = sqrt(besttol2);
737 if(algtol > besttol){
738 cout<<"SameParameter : Tol non atteinte avant approx"<<endl;
742 Handle(TColStd_HArray1OfReal) tol1d,tol2d,tol3d;
743 tol1d = new TColStd_HArray1OfReal(1,2) ;
744 tol1d->SetValue(1, mySurf->UResolution(besttol));
745 tol1d->SetValue(2, mySurf->VResolution(besttol));
747 Approx_SameParameter_Evaluator ev (FlatKnots, Poles, myHCurve2d);
748 AdvApprox_ApproxAFunction anApproximator(2,0,0,tol1d,tol2d,tol3d,fc3d,lc3d,
749 Continuity,11,40,ev);
751 if (anApproximator.IsDone() || anApproximator.HasResult()) {
752 GeomLib_MakeCurvefromApprox aCurveBuilder(anApproximator) ;
753 myCurve2d = aCurveBuilder.Curve2dFromTwo1d(1,2) ;
754 myHCurve2d = new Geom2dAdaptor_HCurve(myCurve2d);
755 CurveOnSurface.Load(myHCurve2d);
756 myTolReached = ComputeTolReached(myC3d,CurveOnSurface,NCONTROL);
757 myDone = Standard_True;
763 cout<<"SameParameter : Pas assez de points, on enrichit"<<endl;
766 Standard_Integer newcount = 0;
767 for(Standard_Integer n = 0; n < count; n++){
768 newpc3d[newcount] = pc3d[n];
769 newpcons[newcount] = pcons[n];
772 if(count - n + newcount == MAX_ARRAY_SIZE) continue;
774 Standard_Real ucons = 0.5*(pcons[n]+pcons[n+1]);
775 Standard_Real uc3d = 0.5*(pc3d[n]+pc3d[n+1]);
777 CurveOnSurface.D0(ucons,Pcons);
778 Projector.Perform(Pcons, uc3d);
779 if (Projector.IsDone()) {
780 curp = Projector.Point().Parameter();
781 Standard_Real dist_2 = Projector.SquareDistance();
782 if(dist_2 > besttol2) besttol2 = dist_2;
786 ProjectPointOnCurve(uc3d,Pcons,Tol,30,myC3d->Curve(),projok,curp);
789 if(curp > pc3d[n] + deltamin && curp < pc3d[n+1] - deltamin){
790 newpc3d[newcount] = curp;
791 newpcons[newcount] = ucons;
798 cout << "Projection not done" << endl;
802 newpc3d[newcount] = pc3d[count];
803 newpcons[newcount] = pcons[count];
804 Standard_Real * tempx;