1 // Created by: Bruno DUMORTIER
2 // Copyright (c) 1995-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <ProjLib_ComputeApproxOnPolarSurface.hxx>
17 #include <AppCont_Function.hxx>
20 #include <BSplCLib.hxx>
22 #include <Standard_NoSuchObject.hxx>
23 #include <Geom_UndefinedDerivative.hxx>
24 #include <gp_Trsf.hxx>
25 #include <Precision.hxx>
26 #include <Approx_FitAndDivide2d.hxx>
28 #include <AppParCurves_MultiCurve.hxx>
29 #include <Geom_Surface.hxx>
30 #include <Geom2d_BSplineCurve.hxx>
31 #include <Geom2d_BezierCurve.hxx>
32 #include <Geom2d_Line.hxx>
33 #include <Geom2d_Circle.hxx>
34 #include <Geom2d_Ellipse.hxx>
35 #include <Geom2d_Hyperbola.hxx>
36 #include <Geom2d_Parabola.hxx>
37 #include <Geom2d_TrimmedCurve.hxx>
38 #include <Geom_BSplineSurface.hxx>
39 #include <Geom_BezierSurface.hxx>
40 #include <Geom_BSplineCurve.hxx>
41 #include <Geom_BezierCurve.hxx>
42 #include <Geom_TrimmedCurve.hxx>
44 #include <TColgp_Array1OfPnt2d.hxx>
45 #include <TColgp_Array2OfPnt2d.hxx>
46 #include <TColgp_Array1OfPnt.hxx>
47 #include <TColgp_SequenceOfPnt2d.hxx>
48 #include <TColStd_Array1OfReal.hxx>
49 #include <TColStd_Array1OfInteger.hxx>
50 #include <TColStd_SequenceOfReal.hxx>
51 #include <TColStd_ListOfTransient.hxx>
53 #include <GeomAbs_SurfaceType.hxx>
54 #include <GeomAbs_CurveType.hxx>
55 #include <Adaptor3d_Surface.hxx>
56 #include <Adaptor3d_Curve.hxx>
57 #include <Adaptor3d_HSurface.hxx>
58 #include <Adaptor3d_HCurve.hxx>
59 #include <Adaptor2d_HCurve2d.hxx>
60 #include <Geom2dAdaptor_Curve.hxx>
61 #include <Geom2dAdaptor_HCurve.hxx>
62 #include <GeomAdaptor_HCurve.hxx>
63 #include <GeomAdaptor.hxx>
64 #include <GeomAdaptor_Surface.hxx>
65 #include <TColgp_SequenceOfPnt.hxx>
68 #include <gp_Pnt2d.hxx>
69 #include <gp_Vec2d.hxx>
70 #include <Extrema_GenLocateExtPS.hxx>
71 #include <Extrema_ExtPS.hxx>
72 #include <GCPnts_QuasiUniformAbscissa.hxx>
73 #include <Standard_DomainError.hxx>
74 //#include <GeomLib_IsIso.hxx>
75 //#include <GeomLib_CheckSameParameter.hxx>
79 #include <DrawTrSurf.hxx>
80 #include <Geom2d_Curve.hxx>
82 //static Standard_Integer compteur = 0;
87 Handle(Adaptor3d_HSurface) mySurf; // Surface where to project.
88 Handle(Adaptor3d_HCurve) myCurve; // Curve to project.
89 Handle(Adaptor2d_HCurve2d) myInitCurve2d; // Initial 2dcurve projection.
90 Standard_Real mySqProjOrtTol; // Used to filter non-orthogonal projected point.
93 Standard_Real myPeriod[2]; // U and V period correspondingly.
96 //=======================================================================
97 //function : computePeriodicity
98 //purpose : Compute period information on adaptor.
99 //=======================================================================
100 static void computePeriodicity(const Handle(Adaptor3d_HSurface)& theSurf,
101 Standard_Real &theUPeriod,
102 Standard_Real &theVPeriod)
107 // Compute once information about periodicity.
108 // Param space may be reduced in case of rectangular trimmed surface,
109 // in this case really trimmed bounds should be set as unperiodic.
110 Standard_Real aTrimF, aTrimL, aBaseF, aBaseL, aDummyF, aDummyL;
111 Handle(Geom_Surface) aS = GeomAdaptor::MakeSurface(theSurf->Surface(), Standard_False); // Not trim.
113 if (theSurf->IsUPeriodic())
115 theUPeriod = theSurf->UPeriod();
117 else if(theSurf->IsUClosed())
119 theUPeriod = theSurf->LastUParameter() - theSurf->FirstUParameter();
121 if (theUPeriod != 0.0)
123 aTrimF = theSurf->FirstUParameter(); // Trimmed first
124 aTrimL = theSurf->LastUParameter(); // Trimmed last
125 aS->Bounds(aBaseF, aBaseL, aDummyF, aDummyL); // Non-trimmed values.
126 if (Abs (aBaseF - aTrimF) + Abs (aBaseL - aTrimL) > Precision::PConfusion())
128 // Param space reduced.
134 if (theSurf->IsVPeriodic())
136 theVPeriod = theSurf->VPeriod();
138 else if(theSurf->IsVClosed())
140 theVPeriod = theSurf->LastVParameter() - theSurf->FirstVParameter();
142 if (theVPeriod != 0.0)
144 aTrimF = theSurf->FirstVParameter(); // Trimmed first
145 aTrimL = theSurf->LastVParameter(); // Trimmed last
146 aS->Bounds(aDummyF, aDummyL, aBaseF, aBaseL); // Non-trimmed values.
147 if (Abs (aBaseF - aTrimF) + Abs (aBaseL - aTrimL) > Precision::PConfusion())
149 // Param space reduced.
155 //=======================================================================
156 //function : aFuncValue
157 //purpose : compute functional value in (theU,theV) point
158 //=======================================================================
159 static Standard_Real anOrthogSqValue(const gp_Pnt& aBasePnt,
160 const Handle(Adaptor3d_HSurface)& Surf,
161 const Standard_Real theU,
162 const Standard_Real theV)
164 // Since find projection, formula is:
165 // F1 = Dot(S_U, Vec(aBasePnt, aProjPnt))
166 // F2 = Dot(S_V, Vec(aBasePnt, aProjPnt))
171 Surf->D1(theU, theV, aProjPnt, aSu, aSv);
172 gp_Vec aBaseVec(aBasePnt, aProjPnt);
174 if (aSu.SquareMagnitude() > Precision::SquareConfusion())
177 if (aSv.SquareMagnitude() > Precision::SquareConfusion())
180 Standard_Real aFirstPart = aSu.Dot(aBaseVec);
181 Standard_Real aSecondPart = aSv.Dot(aBaseVec);
182 return (aFirstPart * aFirstPart + aSecondPart * aSecondPart);
185 //=======================================================================
187 //purpose : (OCC217 - apo)- Compute Point2d that project on polar surface(<Surf>) 3D<Curve>
188 // <InitCurve2d> use for calculate start 2D point.
189 //=======================================================================
190 static gp_Pnt2d Function_Value(const Standard_Real theU,
191 const aFuncStruct& theData)
193 gp_Pnt2d p2d = theData.myInitCurve2d->Value(theU) ;
194 gp_Pnt p = theData.myCurve->Value(theU);
195 gp_Pnt aSurfPnt = theData.mySurf->Value(p2d.X(), p2d.Y());
196 Standard_Real aSurfPntDist = aSurfPnt.SquareDistance(p);
198 Standard_Real Uinf, Usup, Vinf, Vsup;
199 Uinf = theData.mySurf->Surface().FirstUParameter();
200 Usup = theData.mySurf->Surface().LastUParameter();
201 Vinf = theData.mySurf->Surface().FirstVParameter();
202 Vsup = theData.mySurf->Surface().LastVParameter();
204 // Check case when curve is close to co-parametrized isoline on surf.
205 if (Abs (p2d.X() - Uinf) < Precision::PConfusion() ||
206 Abs (p2d.X() - Usup) < Precision::PConfusion() )
210 theData.mySurf->D0(p2d.X(), theU, aPnt);
211 if (aPnt.SquareDistance(p) < aSurfPntDist)
215 if (Abs (p2d.Y() - Vinf) < Precision::PConfusion() ||
216 Abs (p2d.Y() - Vsup) < Precision::PConfusion() )
220 theData.mySurf->D0(theU, p2d.Y(), aPnt);
221 if (aPnt.SquareDistance(p) < aSurfPntDist)
225 Standard_Integer decalU = 0, decalV = 0;
226 Standard_Real U0 = p2d.X(), V0 = p2d.Y();
228 GeomAbs_SurfaceType Type = theData.mySurf->GetType();
229 if((Type != GeomAbs_BSplineSurface) &&
230 (Type != GeomAbs_BezierSurface) &&
231 (Type != GeomAbs_OffsetSurface) )
234 Standard_Real S = 0., T = 0.;
237 case GeomAbs_Cylinder:
239 gp_Cylinder Cylinder = theData.mySurf->Cylinder();
240 ElSLib::Parameters( Cylinder, p, S, T);
241 if(U0 < Uinf) decalU = -int((Uinf - U0)/(2*M_PI))-1;
242 if(U0 > Usup) decalU = int((U0 - Usup)/(2*M_PI))+1;
248 gp_Cone Cone = theData.mySurf->Cone();
249 ElSLib::Parameters( Cone, p, S, T);
250 if(U0 < Uinf) decalU = -int((Uinf - U0)/(2*M_PI))-1;
251 if(U0 > Usup) decalU = int((U0 - Usup)/(2*M_PI))+1;
257 gp_Sphere Sphere = theData.mySurf->Sphere();
258 ElSLib::Parameters( Sphere, p, S, T);
259 if(U0 < Uinf) decalU = -int((Uinf - U0)/(2*M_PI))-1;
260 if(U0 > Usup) decalU = int((U0 - Usup)/(2*M_PI))+1;
262 if(V0 < Vinf) decalV = -int((Vinf - V0)/(2*M_PI))-1;
263 if(V0 > (Vsup+(Vsup-Vinf))) decalV = int((V0 - Vsup+(Vsup-Vinf))/(2*M_PI))+1;
265 if(0.4*M_PI < Abs(U0 - S) && Abs(U0 - S) < 1.6*M_PI)
277 gp_Torus Torus = theData.mySurf->Torus();
278 ElSLib::Parameters( Torus, p, S, T);
279 if(U0 < Uinf) decalU = -int((Uinf - U0)/(2*M_PI))-1;
280 if(U0 > Usup) decalU = int((U0 - Usup)/(2*M_PI))+1;
281 if(V0 < Vinf) decalV = -int((Vinf - V0)/(2*M_PI))-1;
282 if(V0 > Vsup) decalV = int((V0 - Vsup)/(2*M_PI))+1;
283 S += decalU*2*M_PI; T += decalV*2*M_PI;
287 throw Standard_NoSuchObject("ProjLib_ComputeApproxOnPolarSurface::Value");
289 return gp_Pnt2d(S, T);
292 // Non-analytical case.
293 Standard_Real Dist2Min = RealLast();
294 Standard_Real uperiod = theData.myPeriod[0],
295 vperiod = theData.myPeriod[1],
298 // U0 and V0 are the points within the initialized period.
305 decalU = int((Uinf - U0)/uperiod)+1;
306 U0 += decalU*uperiod;
315 decalU = -(int((U0 - Usup)/uperiod)+1);
316 U0 += decalU*uperiod;
325 decalV = int((Vinf - V0)/vperiod)+1;
326 V0 += decalV*vperiod;
335 decalV = -int((V0 - Vsup)/vperiod)-1;
336 V0 += decalV*vperiod;
340 // The surface around (U0,V0) is reduced.
341 Standard_Real uLittle = (Usup - Uinf)/10, vLittle = (Vsup - Vinf)/10;
342 Standard_Real uInfLi = 0, vInfLi = 0,uSupLi = 0, vSupLi = 0;
343 if((U0 - Uinf) > uLittle) uInfLi = U0 - uLittle; else uInfLi = Uinf;
344 if((V0 - Vinf) > vLittle) vInfLi = V0 - vLittle; else vInfLi = Vinf;
345 if((Usup - U0) > uLittle) uSupLi = U0 + uLittle; else uSupLi = Usup;
346 if((Vsup - V0) > vLittle) vSupLi = V0 + vLittle; else vSupLi = Vsup;
348 GeomAdaptor_Surface SurfLittle;
349 if (Type == GeomAbs_BSplineSurface)
351 Handle(Geom_Surface) GBSS(theData.mySurf->Surface().BSpline());
352 SurfLittle.Load(GBSS, uInfLi, uSupLi, vInfLi, vSupLi);
354 else if (Type == GeomAbs_BezierSurface)
356 Handle(Geom_Surface) GS(theData.mySurf->Surface().Bezier());
357 SurfLittle.Load(GS, uInfLi, uSupLi, vInfLi, vSupLi);
359 else if (Type == GeomAbs_OffsetSurface)
361 Handle(Geom_Surface) GS = GeomAdaptor::MakeSurface(theData.mySurf->Surface());
362 SurfLittle.Load(GS, uInfLi, uSupLi, vInfLi, vSupLi);
366 throw Standard_NoSuchObject ("ProjLib_ComputeApproxOnPolarSurface::ProjectUsingInitialCurve2d() - unknown surface type");
369 // Try to run simple search with initial point (U0, V0).
370 Extrema_GenLocateExtPS locext(SurfLittle, theData.myTolU, theData.myTolV);
371 locext.Perform(p, U0, V0);
374 locext.Point().Parameter(u, v);
375 Dist2Min = anOrthogSqValue(p, theData.mySurf, u, v);
376 if (Dist2Min < theData.mySqProjOrtTol && // Point is projection.
377 locext.SquareDistance() < aSurfPntDist + Precision::SquareConfusion()) // Point better than initial.
379 gp_Pnt2d pnt(u - decalU*uperiod,v - decalV*vperiod);
384 // Perform whole param space search.
385 Extrema_ExtPS ext(p, SurfLittle, theData.myTolU, theData.myTolV);
386 if (ext.IsDone() && ext.NbExt() >= 1)
388 Dist2Min = ext.SquareDistance(1);
389 Standard_Integer GoodValue = 1;
390 for (Standard_Integer i = 2 ; i <= ext.NbExt() ; i++ )
392 if( Dist2Min > ext.SquareDistance(i))
394 Dist2Min = ext.SquareDistance(i);
398 ext.Point(GoodValue).Parameter(u, v);
399 Dist2Min = anOrthogSqValue(p, theData.mySurf, u, v);
400 if (Dist2Min < theData.mySqProjOrtTol && // Point is projection.
401 ext.SquareDistance(GoodValue) < aSurfPntDist + Precision::SquareConfusion()) // Point better than initial.
403 gp_Pnt2d pnt(u - decalU*uperiod,v - decalV*vperiod);
408 // Both searches return bad values, use point from initial 2dcurve.
413 //=======================================================================
414 //function : ProjLib_PolarFunction
415 //purpose : (OCC217 - apo)- This class produce interface to call "gp_Pnt2d Function_Value(...)"
416 //=======================================================================
418 class ProjLib_PolarFunction : public AppCont_Function
420 aFuncStruct myStruct;
424 ProjLib_PolarFunction(const Handle(Adaptor3d_HCurve) & C,
425 const Handle(Adaptor3d_HSurface)& Surf,
426 const Handle(Adaptor2d_HCurve2d)& InitialCurve2d,
427 const Standard_Real Tol3d)
432 computePeriodicity(Surf, myStruct.myPeriod[0], myStruct.myPeriod[1]);
434 myStruct.myCurve = C;
435 myStruct.myInitCurve2d = InitialCurve2d;
436 myStruct.mySurf = Surf;
437 myStruct.mySqProjOrtTol = 10000.0 * Tol3d * Tol3d;
438 myStruct.myTolU = Surf->UResolution(Tol3d);
439 myStruct.myTolV = Surf->VResolution(Tol3d);
442 ~ProjLib_PolarFunction() {}
444 Standard_Real FirstParameter() const
446 return myStruct.myCurve->FirstParameter();
449 Standard_Real LastParameter() const
451 return myStruct.myCurve->LastParameter();
454 gp_Pnt2d Value(const Standard_Real t) const
456 return Function_Value(t, myStruct);
459 Standard_Boolean Value(const Standard_Real theT,
460 NCollection_Array1<gp_Pnt2d>& thePnt2d,
461 NCollection_Array1<gp_Pnt>& /*thePnt*/) const
463 thePnt2d(1) = Function_Value(theT, myStruct);
464 return Standard_True;
467 Standard_Boolean D1(const Standard_Real /*theT*/,
468 NCollection_Array1<gp_Vec2d>& /*theVec2d*/,
469 NCollection_Array1<gp_Vec>& /*theVec*/) const
470 {return Standard_False;}
473 //=======================================================================
474 //function : ProjLib_ComputeApproxOnPolarSurface
476 //=======================================================================
478 ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface()
479 : myProjIsDone(Standard_False),
480 myTolerance(Precision::Approximation()),
482 myDegMin(-1), myDegMax(-1),
485 myBndPnt(AppParCurves_TangencyPoint),
490 //=======================================================================
491 //function : ProjLib_ComputeApproxOnPolarSurface
493 //=======================================================================
495 ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface
496 (const Handle(Adaptor2d_HCurve2d)& theInitialCurve2d,
497 const Handle(Adaptor3d_HCurve)& theCurve,
498 const Handle(Adaptor3d_HSurface)& theSurface,
499 const Standard_Real theTolerance3D)
500 : myProjIsDone(Standard_False),
501 myTolerance(theTolerance3D),
503 myDegMin(-1), myDegMax(-1),
506 myBndPnt(AppParCurves_TangencyPoint),
509 myBSpline = Perform(theInitialCurve2d, theCurve, theSurface);
512 //=======================================================================
513 //function : ProjLib_ComputeApproxOnPolarSurface
514 //purpose : case without curve of initialization
515 //=======================================================================
517 ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface
518 (const Handle(Adaptor3d_HCurve)& theCurve,
519 const Handle(Adaptor3d_HSurface)& theSurface,
520 const Standard_Real theTolerance3D)
521 : myProjIsDone(Standard_False),
522 myTolerance(theTolerance3D),
524 myDegMin(-1), myDegMax(-1),
527 myBndPnt(AppParCurves_TangencyPoint),
530 const Handle(Adaptor2d_HCurve2d) anInitCurve2d;
531 myBSpline = Perform(anInitCurve2d, theCurve, theSurface);
534 //=======================================================================
535 //function : ProjLib_ComputeApproxOnPolarSurface
536 //purpose : Process the case of sewing
537 //=======================================================================
539 ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface
540 (const Handle(Adaptor2d_HCurve2d)& theInitialCurve2d,
541 const Handle(Adaptor2d_HCurve2d)& theInitialCurve2dBis,
542 const Handle(Adaptor3d_HCurve)& theCurve,
543 const Handle(Adaptor3d_HSurface)& theSurface,
544 const Standard_Real theTolerance3D)
545 : myProjIsDone(Standard_False),
546 myTolerance(theTolerance3D),
548 myDegMin(-1), myDegMax(-1),
551 myBndPnt(AppParCurves_TangencyPoint),
554 // InitialCurve2d and InitialCurve2dBis are two pcurves of the sewing
555 Handle(Geom2d_BSplineCurve) bsc =
556 Perform(theInitialCurve2d, theCurve, theSurface);
559 gp_Pnt2d P2dproj, P2d, P2dBis;
560 P2dproj = bsc->StartPoint();
561 P2d = theInitialCurve2d->Value(theInitialCurve2d->FirstParameter());
562 P2dBis = theInitialCurve2dBis->Value(theInitialCurve2dBis->FirstParameter());
564 Standard_Real Dist, DistBis;
565 Dist = P2dproj.Distance(P2d);
566 DistBis = P2dproj.Distance(P2dBis);
567 if( Dist < DistBis) {
568 // myBSpline2d is the pcurve that is found. It is translated to obtain myCurve2d
570 Handle(Geom2d_Geometry) GG = myBSpline->Translated(P2d, P2dBis);
571 my2ndCurve = Handle(Geom2d_Curve)::DownCast(GG);
575 Handle(Geom2d_Geometry) GG = my2ndCurve->Translated(P2dBis, P2d);
576 myBSpline = Handle(Geom2d_BSplineCurve)::DownCast(GG);
582 //=======================================================================
585 //=======================================================================
587 static Handle(Geom2d_BSplineCurve) Concat(Handle(Geom2d_BSplineCurve) C1,
588 Handle(Geom2d_BSplineCurve) C2,
589 Standard_Real theUJump,
590 Standard_Real theVJump)
592 Standard_Integer deg, deg1, deg2;
597 C1->IncreaseDegree(deg2);
600 else if ( deg2 < deg1) {
601 C2->IncreaseDegree(deg1);
606 Standard_Integer np1,np2,nk1,nk2,np,nk;
614 TColStd_Array1OfReal K1(1,nk1); C1->Knots(K1);
615 TColStd_Array1OfInteger M1(1,nk1); C1->Multiplicities(M1);
616 TColgp_Array1OfPnt2d P1(1,np1); C1->Poles(P1);
617 TColStd_Array1OfReal K2(1,nk2); C2->Knots(K2);
618 TColStd_Array1OfInteger M2(1,nk2); C2->Multiplicities(M2);
619 TColgp_Array1OfPnt2d P2(1,np2); C2->Poles(P2);
621 // Compute the new BSplineCurve
622 TColStd_Array1OfReal K(1,nk);
623 TColStd_Array1OfInteger M(1,nk);
624 TColgp_Array1OfPnt2d P(1,np);
626 Standard_Integer i, count = 0;
627 // Set Knots and Mults
628 for ( i = 1; i <= nk1; i++) {
634 for ( i = 2; i <= nk2; i++) {
641 for (i = 1; i <= np1; i++) {
645 for (i = 2; i <= np2; i++) {
647 P(count).SetX(P2(i).X() + theUJump);
648 P(count).SetY(P2(i).Y() + theVJump);
651 Handle(Geom2d_BSplineCurve) BS =
652 new Geom2d_BSplineCurve(P,K,M,deg);
656 //=======================================================================
659 //=======================================================================
661 void ProjLib_ComputeApproxOnPolarSurface::Perform
662 (const Handle(Adaptor3d_HCurve)& Curve, const Handle(Adaptor3d_HSurface)& S)
664 const Handle(Adaptor2d_HCurve2d) anInitCurve2d;
665 myBSpline = Perform(anInitCurve2d, Curve, S);
668 //=======================================================================
671 //=======================================================================
673 Handle(Geom2d_BSplineCurve) ProjLib_ComputeApproxOnPolarSurface::Perform
674 (const Handle(Adaptor2d_HCurve2d)& InitialCurve2d,
675 const Handle(Adaptor3d_HCurve)& Curve,
676 const Handle(Adaptor3d_HSurface)& S)
679 Standard_Real Tol3d = myTolerance;
680 Standard_Real ParamTol = Precision::PApproximation();
682 Handle(Adaptor2d_HCurve2d) AHC2d = InitialCurve2d;
683 Handle(Adaptor3d_HCurve) AHC = Curve;
685 // if the curve 3d is a BSpline with degree C0, it is cut into sections with degree C1
687 GeomAbs_CurveType typeCurve = Curve->GetType();
688 if(typeCurve == GeomAbs_BSplineCurve) {
689 TColStd_ListOfTransient LOfBSpline2d;
690 Handle(Geom_BSplineCurve) BSC = Curve->BSpline();
691 Standard_Integer nbInter = Curve->NbIntervals(GeomAbs_C1);
693 Standard_Integer i, j;
694 Handle(Geom_TrimmedCurve) GTC;
695 Handle(Geom2d_TrimmedCurve) G2dTC;
696 TColStd_Array1OfReal Inter(1,nbInter+1);
697 Curve->Intervals(Inter,GeomAbs_C1);
698 Standard_Real firstinter = Inter.Value(1), secondinter = Inter.Value(2);
700 GTC = new Geom_TrimmedCurve(BSC, firstinter, secondinter);
701 AHC = new GeomAdaptor_HCurve(GTC);
703 // if there is an initialization curve:
704 // - either this is a BSpline C0, with discontinuity at the same parameters of nodes
705 // and the sections C1 are taken
706 // - or this is a curve C1 and the sections of intrest are taken otherwise the curve is created.
709 Standard_Integer nbInter2d;
710 Standard_Boolean C2dIsToCompute;
711 C2dIsToCompute = InitialCurve2d.IsNull();
712 Handle(Geom2d_BSplineCurve) BSC2d;
713 Handle(Geom2d_Curve) G2dC;
715 if(!C2dIsToCompute) {
716 nbInter2d = InitialCurve2d->NbIntervals(GeomAbs_C1);
717 TColStd_Array1OfReal Inter2d(1,nbInter2d+1);
718 InitialCurve2d->Intervals(Inter2d,GeomAbs_C1);
720 for(i = 1,j = 1;i <= nbInter;i++)
721 if(Abs(Inter.Value(i) - Inter2d.Value(j)) < ParamTol) { //OCC217
722 //if(Abs(Inter.Value(i) - Inter2d.Value(j)) < myTolerance) {
723 if (j > nbInter2d) break;
726 if(j != (nbInter2d+1)) {
727 C2dIsToCompute = Standard_True;
732 AHC2d = BuildInitialCurve2d(AHC, S);
735 typeCurve = InitialCurve2d->GetType();
738 G2dC = new Geom2d_Line(InitialCurve2d->Line());
741 case GeomAbs_Circle: {
742 G2dC = new Geom2d_Circle(InitialCurve2d->Circle());
745 case GeomAbs_Ellipse: {
746 G2dC = new Geom2d_Ellipse(InitialCurve2d->Ellipse());
749 case GeomAbs_Hyperbola: {
750 G2dC = new Geom2d_Hyperbola(InitialCurve2d->Hyperbola());
753 case GeomAbs_Parabola: {
754 G2dC = new Geom2d_Parabola(InitialCurve2d->Parabola());
757 case GeomAbs_BezierCurve: {
758 G2dC = InitialCurve2d->Bezier();
761 case GeomAbs_BSplineCurve: {
762 G2dC = InitialCurve2d->BSpline();
765 case GeomAbs_OtherCurve:
769 gp_Pnt2d fp2d = G2dC->Value(firstinter), lp2d = G2dC->Value(secondinter);
770 gp_Pnt fps, lps, fpc, lpc;
771 S->D0(fp2d.X(), fp2d.Y(), fps);
772 S->D0(lp2d.X(), lp2d.Y(), lps);
773 Curve->D0(firstinter, fpc);
774 Curve->D0(secondinter, lpc);
776 if((fps.IsEqual(fpc, Tol3d)) &&
777 (lps.IsEqual(lpc, Tol3d))) {
778 //if((fps.IsEqual(fpc, myTolerance)) &&
779 // (lps.IsEqual(lpc, myTolerance))) {
780 G2dTC = new Geom2d_TrimmedCurve(G2dC, firstinter, secondinter);
781 Geom2dAdaptor_Curve G2dAC(G2dTC);
782 AHC2d = new Geom2dAdaptor_HCurve(G2dAC);
783 myProjIsDone = Standard_True;
786 AHC2d = BuildInitialCurve2d(AHC, S);
787 C2dIsToCompute = Standard_True;
792 BSC2d = ProjectUsingInitialCurve2d(AHC, S, AHC2d);
795 return Handle(Geom2d_BSplineCurve)();
797 LOfBSpline2d.Append(BSC2d);
800 return Handle(Geom2d_BSplineCurve)();
805 Standard_Real iinter, ip1inter;
806 Standard_Integer nbK2d, deg;
807 nbK2d = BSC2d->NbKnots(); deg = BSC2d->Degree();
809 for(i = 2;i <= nbInter;i++) {
810 iinter = Inter.Value(i);
811 ip1inter = Inter.Value(i+1);
813 GTC->SetTrim(iinter, ip1inter);
814 AHC = new GeomAdaptor_HCurve(GTC);
818 AHC2d = BuildInitialCurve2d(AHC, S);
821 gp_Pnt2d fp2d = G2dC->Value(iinter), lp2d = G2dC->Value(ip1inter);
822 gp_Pnt fps, lps, fpc, lpc;
823 S->D0(fp2d.X(), fp2d.Y(), fps);
824 S->D0(lp2d.X(), lp2d.Y(), lps);
825 Curve->D0(iinter, fpc);
826 Curve->D0(ip1inter, lpc);
828 if((fps.IsEqual(fpc, Tol3d)) &&
829 (lps.IsEqual(lpc, Tol3d))) {
830 //if((fps.IsEqual(fpc, myTolerance)) &&
831 // (lps.IsEqual(lpc, myTolerance))) {
832 G2dTC->SetTrim(iinter, ip1inter);
833 Geom2dAdaptor_Curve G2dAC(G2dTC);
834 AHC2d = new Geom2dAdaptor_HCurve(G2dAC);
835 myProjIsDone = Standard_True;
838 AHC2d = BuildInitialCurve2d(AHC, S);
842 BSC2d = ProjectUsingInitialCurve2d(AHC, S, AHC2d);
844 return Handle(Geom2d_BSplineCurve)();
846 LOfBSpline2d.Append(BSC2d);
847 nbK2d += BSC2d->NbKnots() - 1;
848 deg = Max(deg, BSC2d->Degree());
851 return Handle(Geom2d_BSplineCurve)();
855 Standard_Real anUPeriod, anVPeriod;
856 computePeriodicity(S, anUPeriod, anVPeriod);
857 Standard_Integer NbC = LOfBSpline2d.Extent();
858 Handle(Geom2d_BSplineCurve) CurBS;
859 CurBS = Handle(Geom2d_BSplineCurve)::DownCast(LOfBSpline2d.First());
860 LOfBSpline2d.RemoveFirst();
861 for (Standard_Integer ii = 2; ii <= NbC; ii++)
863 Handle(Geom2d_BSplineCurve) BS =
864 Handle(Geom2d_BSplineCurve)::DownCast(LOfBSpline2d.First());
866 //Check for period jump in point of contact.
867 gp_Pnt2d aC1End = CurBS->Pole(CurBS->NbPoles()); // End of C1.
868 gp_Pnt2d aC2Beg = BS->Pole(1); // Beginning of C2.
869 Standard_Real anUJump = 0.0, anVJump = 0.0;
871 if (anUPeriod > 0.0 &&
872 Abs (aC1End.X() - aC2Beg.X()) > (anUPeriod ) / 2.01)
874 Standard_Real aMultCoeff = aC2Beg.X() < aC1End.X() ? 1.0 : -1.0;
875 anUJump = (anUPeriod) * aMultCoeff;
879 Abs (aC1End.Y() - aC2Beg.Y()) > (anVPeriod) / 2.01)
881 Standard_Real aMultCoeff = aC2Beg.Y() < aC1End.Y() ? 1.0 : -1.0;
882 anVJump = (anVPeriod) * aMultCoeff;
885 CurBS = Concat(CurBS,BS, anUJump, anVJump);
886 LOfBSpline2d.RemoveFirst();
892 if(InitialCurve2d.IsNull()) {
893 AHC2d = BuildInitialCurve2d(Curve, S);
895 return Handle(Geom2d_BSplineCurve)();
897 return ProjectUsingInitialCurve2d(AHC, S, AHC2d);
901 //=======================================================================
902 //function : ProjLib_BuildInitialCurve2d
904 //=======================================================================
906 Handle(Adaptor2d_HCurve2d)
907 ProjLib_ComputeApproxOnPolarSurface::
908 BuildInitialCurve2d(const Handle(Adaptor3d_HCurve)& Curve,
909 const Handle(Adaptor3d_HSurface)& Surf)
911 // discretize the Curve with quasiuniform deflection
912 // density at least NbOfPnts points
913 myProjIsDone = Standard_False;
916 Standard_Real Tol3d = myTolerance;
917 Standard_Real TolU = Surf->UResolution(Tol3d), TolV = Surf->VResolution(Tol3d);
918 Standard_Real DistTol3d = 100.0*Tol3d;
921 DistTol3d = myMaxDist;
923 Standard_Real DistTol3d2 = DistTol3d * DistTol3d;
924 Standard_Real uperiod = 0.0, vperiod = 0.0;
925 computePeriodicity(Surf, uperiod, vperiod);
927 // NO myTol is Tol2d !!!!
928 //Standard_Real TolU = myTolerance, TolV = myTolerance;
929 //Standard_Real Tol3d = 100*myTolerance; // At random Balthazar.
931 Standard_Integer NbOfPnts = 61;
932 GCPnts_QuasiUniformAbscissa QUA(Curve->GetCurve(),NbOfPnts);
933 NbOfPnts = QUA.NbPoints();
934 TColgp_Array1OfPnt Pts(1,NbOfPnts);
935 TColStd_Array1OfReal Param(1,NbOfPnts);
936 Standard_Integer i, j;
937 for( i = 1; i <= NbOfPnts ; i++ ) {
938 Param(i) = QUA.Parameter(i);
939 Pts(i) = Curve->Value(Param(i));
942 TColgp_Array1OfPnt2d Pts2d(1,NbOfPnts);
943 TColStd_Array1OfInteger Mult(1,NbOfPnts);
945 Mult(1) = Mult(NbOfPnts) = 2;
947 Standard_Real Uinf, Usup, Vinf, Vsup;
948 Uinf = Surf->Surface().FirstUParameter();
949 Usup = Surf->Surface().LastUParameter();
950 Vinf = Surf->Surface().FirstVParameter();
951 Vsup = Surf->Surface().LastVParameter();
952 GeomAbs_SurfaceType Type = Surf->GetType();
953 if((Type != GeomAbs_BSplineSurface) && (Type != GeomAbs_BezierSurface) &&
954 (Type != GeomAbs_OffsetSurface)) {
956 // Standard_Integer usens = 0, vsens = 0;
957 // to know the position relatively to the period
959 // case GeomAbs_Plane:
961 // gp_Pln Plane = Surf->Plane();
962 // for ( i = 1 ; i <= NbOfPnts ; i++) {
963 // ElSLib::Parameters( Plane, Pts(i), S, T);
964 // Pts2d(i).SetCoord(S,T);
966 // myProjIsDone = Standard_True;
969 case GeomAbs_Cylinder:
971 // Standard_Real Sloc, Tloc;
973 Standard_Integer usens = 0;
974 gp_Cylinder Cylinder = Surf->Cylinder();
975 ElSLib::Parameters( Cylinder, Pts(1), S, T);
976 Pts2d(1).SetCoord(S,T);
977 for ( i = 2 ; i <= NbOfPnts ; i++) {
979 ElSLib::Parameters( Cylinder, Pts(i), S, T);
980 if(Abs(Sloc - S) > M_PI) {
986 Pts2d(i).SetCoord(S+usens*2*M_PI,T);
988 myProjIsDone = Standard_True;
993 // Standard_Real Sloc, Tloc;
995 Standard_Integer usens = 0;
996 gp_Cone Cone = Surf->Cone();
997 ElSLib::Parameters( Cone, Pts(1), S, T);
998 Pts2d(1).SetCoord(S,T);
999 for ( i = 2 ; i <= NbOfPnts ; i++) {
1001 ElSLib::Parameters( Cone, Pts(i), S, T);
1002 if(Abs(Sloc - S) > M_PI) {
1008 Pts2d(i).SetCoord(S+usens*2*M_PI,T);
1010 myProjIsDone = Standard_True;
1013 case GeomAbs_Sphere:
1015 Standard_Real Sloc, Tloc;
1016 Standard_Integer usens = 0, vsens = 0; //usens steps by half-period
1017 Standard_Boolean vparit = Standard_False;
1018 gp_Sphere Sphere = Surf->Sphere();
1019 ElSLib::Parameters( Sphere, Pts(1), S, T);
1020 Pts2d(1).SetCoord(S,T);
1021 for ( i = 2 ; i <= NbOfPnts ; i++) {
1023 ElSLib::Parameters( Sphere, Pts(i), S, T);
1024 if(1.6*M_PI < Abs(Sloc - S)) {
1030 if(1.6*M_PI > Abs(Sloc - S) && Abs(Sloc - S) > 0.4*M_PI) {
1036 if(Abs(Tloc - Vsup) < (Vsup - Vinf)/5)
1042 Pts2d(i).SetCoord(S+usens*M_PI,(M_PI - T)*(vsens-1));
1045 Pts2d(i).SetCoord(S+usens*M_PI,T+vsens*M_PI);
1049 myProjIsDone = Standard_True;
1054 Standard_Real Sloc, Tloc;
1055 Standard_Integer usens = 0, vsens = 0;
1056 gp_Torus Torus = Surf->Torus();
1057 ElSLib::Parameters( Torus, Pts(1), S, T);
1058 Pts2d(1).SetCoord(S,T);
1059 for ( i = 2 ; i <= NbOfPnts ; i++) {
1061 ElSLib::Parameters( Torus, Pts(i), S, T);
1062 if(Abs(Sloc - S) > M_PI) {
1068 if(Abs(Tloc - T) > M_PI) {
1074 Pts2d(i).SetCoord(S+usens*2*M_PI,T+vsens*2*M_PI);
1076 myProjIsDone = Standard_True;
1080 throw Standard_NoSuchObject("ProjLib_ComputeApproxOnPolarSurface::BuildInitialCurve2d");
1084 myProjIsDone = Standard_False;
1085 Standard_Real Dist2Min = 1.e+200, u = 0., v = 0.;
1089 TColgp_SequenceOfPnt2d Sols;
1090 Standard_Boolean areManyZeros = Standard_False;
1092 Curve->D0(Param.Value(1), pntproj) ;
1093 Extrema_ExtPS aExtPS(pntproj, Surf->Surface(), TolU, TolV) ;
1094 Standard_Real aMinSqDist = RealLast();
1095 if (aExtPS.IsDone())
1097 for (i = 1; i <= aExtPS.NbExt(); i++)
1099 Standard_Real aSqDist = aExtPS.SquareDistance(i);
1100 if (aSqDist < aMinSqDist)
1101 aMinSqDist = aSqDist;
1104 if (aMinSqDist > DistTol3d2) //try to project with less tolerance
1106 TolU = Min(TolU, Precision::PConfusion());
1107 TolV = Min(TolV, Precision::PConfusion());
1108 aExtPS.Initialize(Surf->Surface(),
1109 Surf->Surface().FirstUParameter(), Surf->Surface().LastUParameter(),
1110 Surf->Surface().FirstVParameter(), Surf->Surface().LastVParameter(),
1112 aExtPS.Perform(pntproj);
1115 if( aExtPS.IsDone() && aExtPS.NbExt() >= 1 ) {
1117 Standard_Integer GoodValue = 1;
1119 for ( i = 1 ; i <= aExtPS.NbExt() ; i++ ) {
1120 if( aExtPS.SquareDistance(i) < DistTol3d2 ) {
1121 if( aExtPS.SquareDistance(i) <= 1.e-18 ) {
1122 aExtPS.Point(i).Parameter(u,v);
1124 Standard_Boolean isSame = Standard_False;
1125 for( j = 1; j <= Sols.Length(); j++ ) {
1126 if( p2d.SquareDistance( Sols.Value(j) ) <= 1.e-18 ) {
1127 isSame = Standard_True;
1131 if( !isSame ) Sols.Append( p2d );
1133 if( Dist2Min > aExtPS.SquareDistance(i) ) {
1134 Dist2Min = aExtPS.SquareDistance(i);
1140 if( Sols.Length() > 1 ) areManyZeros = Standard_True;
1142 if( Dist2Min <= DistTol3d2) {
1143 if( !areManyZeros ) {
1144 aExtPS.Point(GoodValue).Parameter(u,v);
1145 Pts2d(1).SetCoord(u,v);
1146 myProjIsDone = Standard_True;
1149 Standard_Integer nbSols = Sols.Length();
1150 Standard_Real Dist2Max = -1.e+200;
1151 for( i = 1; i <= nbSols; i++ ) {
1152 const gp_Pnt2d& aP1 = Sols.Value(i);
1153 for( j = i+1; j <= nbSols; j++ ) {
1154 const gp_Pnt2d& aP2 = Sols.Value(j);
1155 Standard_Real aDist2 = aP1.SquareDistance(aP2);
1156 if( aDist2 > Dist2Max ) Dist2Max = aDist2;
1159 Standard_Real aMaxT2 = Max(TolU,TolV);
1161 if( Dist2Max > aMaxT2 ) {
1162 Standard_Integer tPp = 0;
1163 for( i = 1; i <= 5; i++ ) {
1164 Standard_Integer nbExtOk = 0;
1165 Standard_Integer indExt = 0;
1166 Standard_Integer iT = 1 + (NbOfPnts - 1)/5*i;
1167 Curve->D0( Param.Value(iT), pntproj );
1168 Extrema_ExtPS aTPS( pntproj, Surf->Surface(), TolU, TolV );
1170 if( aTPS.IsDone() && aTPS.NbExt() >= 1 ) {
1171 for( j = 1 ; j <= aTPS.NbExt() ; j++ ) {
1172 if( aTPS.SquareDistance(j) < DistTol3d2 ) {
1174 if( aTPS.SquareDistance(j) < Dist2Min ) {
1175 Dist2Min = aTPS.SquareDistance(j);
1181 if( nbExtOk == 1 ) {
1183 aTPS.Point(indExt).Parameter(u,v);
1188 if (tPp != 0 && tPp != NbOfPnts) {
1189 gp_Pnt2d aPp = gp_Pnt2d(u,v);
1191 Standard_Boolean isFound = Standard_False;
1192 for (j = tPp + 1; j <= NbOfPnts; ++j)
1194 Curve->D0( Param.Value(j), pntproj );
1195 Extrema_ExtPS aTPS( pntproj, Surf->Surface(), TolU, TolV );
1196 Dist2Min = RealLast();
1197 if( aTPS.IsDone() && aTPS.NbExt() >= 1 ) {
1198 Standard_Integer indExt = 0;
1199 for (i = 1; i <= aTPS.NbExt(); i++) {
1200 if (aTPS.SquareDistance(i) < DistTol3d2 && aTPS.SquareDistance(i) < Dist2Min) {
1201 Dist2Min = aTPS.SquareDistance(i);
1206 aTPS.Point(indExt).Parameter(u,v);
1207 aPn = gp_Pnt2d(u,v);
1208 isFound = Standard_True;
1215 gp_Vec2d atV(aPp,aPn);
1216 Standard_Boolean isChosen = Standard_False;
1217 for( i = 1; i <= nbSols; i++ ) {
1218 const gp_Pnt2d& aP1 = Sols.Value(i);
1219 gp_Vec2d asV(aP1,aPp);
1220 if( asV.Dot(atV) > 0. ) {
1221 isChosen = Standard_True;
1222 Pts2d(1).SetCoord(aP1.X(),aP1.Y());
1223 myProjIsDone = Standard_True;
1228 aExtPS.Point(GoodValue).Parameter(u,v);
1229 Pts2d(1).SetCoord(u,v);
1230 myProjIsDone = Standard_True;
1234 aExtPS.Point(GoodValue).Parameter(u,v);
1235 Pts2d(1).SetCoord(u,v);
1236 myProjIsDone = Standard_True;
1240 aExtPS.Point(GoodValue).Parameter(u,v);
1241 Pts2d(1).SetCoord(u,v);
1242 myProjIsDone = Standard_True;
1246 aExtPS.Point(GoodValue).Parameter(u,v);
1247 Pts2d(1).SetCoord(u,v);
1248 myProjIsDone = Standard_True;
1253 // calculate the following points with GenLocate_ExtPS
1254 // (and store the result and each parameter in a sequence)
1255 Standard_Integer usens = 0, vsens = 0;
1256 // to know the position relatively to the period
1257 Standard_Real U0 = u, V0 = v, U1 = u, V1 = v;
1258 // U0 and V0 are the points in the initialized period
1259 // (period with u and v),
1260 // U1 and V1 are the points for construction of poles
1262 for ( i = 2 ; i <= NbOfPnts ; i++)
1264 myProjIsDone = Standard_False;
1265 Dist2Min = RealLast();
1266 Curve->D0(Param.Value(i), pntproj);
1267 Extrema_GenLocateExtPS aLocateExtPS(Surf->Surface(), TolU, TolV);
1268 aLocateExtPS.Perform(pntproj, U0, V0);
1270 if (aLocateExtPS.IsDone())
1272 if (aLocateExtPS.SquareDistance() < DistTol3d2)
1274 //if (aLocateExtPS.SquareDistance() < Tol3d * Tol3d) {
1275 if (aLocateExtPS.SquareDistance() > myDist)
1277 myDist = aLocateExtPS.SquareDistance();
1279 (aLocateExtPS.Point()).Parameter(U0,V0);
1280 U1 = U0 + usens*uperiod;
1281 V1 = V0 + vsens*vperiod;
1282 Pts2d(i).SetCoord(U1,V1);
1283 myProjIsDone = Standard_True;
1287 Extrema_ExtPS aGlobalExtr(pntproj, Surf->Surface(), TolU, TolV);
1288 if (aGlobalExtr.IsDone())
1290 Standard_Real LocalMinSqDist = RealLast();
1291 Standard_Integer imin = 0;
1292 for (Standard_Integer isol = 1; isol <= aGlobalExtr.NbExt(); isol++)
1294 Standard_Real aSqDist = aGlobalExtr.SquareDistance(isol);
1295 if (aSqDist < LocalMinSqDist)
1297 LocalMinSqDist = aSqDist;
1301 if (LocalMinSqDist < DistTol3d2)
1303 if (LocalMinSqDist > myDist)
1305 myDist = LocalMinSqDist;
1307 Standard_Real LocalU, LocalV;
1308 aGlobalExtr.Point(imin).Parameter(LocalU, LocalV);
1309 if (uperiod > 0. && Abs(U0 - LocalU) >= uperiod/2.)
1316 if (vperiod > 0. && Abs(V0 - LocalV) >= vperiod/2.)
1323 U0 = LocalU; V0 = LocalV;
1324 U1 = U0 + usens*uperiod;
1325 V1 = V0 + vsens*vperiod;
1326 Pts2d(i).SetCoord(U1,V1);
1327 myProjIsDone = Standard_True;
1329 if((i == 2) && (!IsEqual(uperiod, 0.0) || !IsEqual(vperiod, 0.0)))
1330 {//Make 1st point more precise for periodic surfaces
1331 const Standard_Integer aSize = 3;
1332 const gp_Pnt2d aP(Pts2d(2));
1333 Standard_Real aUpar[aSize], aVpar[aSize];
1334 Pts2d(1).Coord(aUpar[1], aVpar[1]);
1335 aUpar[0] = aUpar[1] - uperiod;
1336 aUpar[2] = aUpar[1] + uperiod;
1337 aVpar[0] = aVpar[1] - vperiod;
1338 aVpar[2] = aVpar[1] + vperiod;
1340 Standard_Real aSQdistMin = RealLast();
1341 Standard_Integer aBestUInd = 1, aBestVInd = 1;
1342 const Standard_Integer aSizeU = IsEqual(uperiod, 0.0) ? 1 : aSize,
1343 aSizeV = IsEqual(vperiod, 0.0) ? 1 : aSize;
1344 for(Standard_Integer uInd = 0; uInd < aSizeU; uInd++)
1346 for(Standard_Integer vInd = 0; vInd < aSizeV; vInd++)
1348 Standard_Real aSQdist = aP.SquareDistance(gp_Pnt2d(aUpar[uInd], aVpar[vInd]));
1349 if(aSQdist < aSQdistMin)
1351 aSQdistMin = aSQdist;
1358 Pts2d(1).SetCoord(aUpar[aBestUInd], aVpar[aBestVInd]);
1359 }//if(i == 2) condition
1364 if(!myProjIsDone && uperiod) {
1365 Standard_Real aUinf, aUsup, Uaux;
1366 aUinf = Surf->Surface().FirstUParameter();
1367 aUsup = Surf->Surface().LastUParameter();
1368 if((aUsup - U0) > (U0 - aUinf))
1369 Uaux = 2*aUinf - U0 + uperiod;
1371 Uaux = 2*aUsup - U0 - uperiod;
1373 Extrema_GenLocateExtPS locext(Surf->Surface(), TolU, TolV);
1374 locext.Perform(pntproj, Uaux, V0);
1376 if (locext.IsDone())
1377 if (locext.SquareDistance() < DistTol3d2) { //OCC217
1378 //if (locext.SquareDistance() < Tol3d * Tol3d) {
1379 if (locext.SquareDistance() > myDist)
1381 myDist = locext.SquareDistance();
1383 (locext.Point()).Parameter(u,v);
1384 if((aUsup - U0) > (U0 - aUinf))
1389 U1 = U0 + usens*uperiod;
1390 V1 = V0 + vsens*vperiod;
1391 Pts2d(i).SetCoord(U1,V1);
1392 myProjIsDone = Standard_True;
1395 if(!myProjIsDone && vperiod) {
1396 Standard_Real aVinf, aVsup, Vaux;
1397 aVinf = Surf->Surface().FirstVParameter();
1398 aVsup = Surf->Surface().LastVParameter();
1399 if((aVsup - V0) > (V0 - aVinf))
1400 Vaux = 2*aVinf - V0 + vperiod;
1402 Vaux = 2*aVsup - V0 - vperiod;
1404 Extrema_GenLocateExtPS locext(Surf->Surface(), TolU, TolV);
1405 locext.Perform(pntproj, U0, Vaux);
1407 if (locext.IsDone())
1408 if (locext.SquareDistance() < DistTol3d2) { //OCC217
1409 //if (locext.SquareDistance() < Tol3d * Tol3d) {
1410 if (locext.SquareDistance() > myDist)
1412 myDist = locext.SquareDistance();
1414 (locext.Point()).Parameter(u, v);
1415 if((aVsup - V0) > (V0 - aVinf))
1420 U1 = U0 + usens*uperiod;
1421 V1 = V0 + vsens*vperiod;
1422 Pts2d(i).SetCoord(U1,V1);
1423 myProjIsDone = Standard_True;
1426 if(!myProjIsDone && uperiod && vperiod) {
1427 Standard_Real Uaux, Vaux;
1428 if((Usup - U0) > (U0 - Uinf))
1429 Uaux = 2*Uinf - U0 + uperiod;
1431 Uaux = 2*Usup - U0 - uperiod;
1432 if((Vsup - V0) > (V0 - Vinf))
1433 Vaux = 2*Vinf - V0 + vperiod;
1435 Vaux = 2*Vsup - V0 - vperiod;
1437 Extrema_GenLocateExtPS locext(Surf->Surface(), TolU, TolV);
1438 locext.Perform(pntproj, Uaux, Vaux);
1440 if (locext.IsDone())
1441 if (locext.SquareDistance() < DistTol3d2) {
1442 //if (locext.SquareDistance() < Tol3d * Tol3d) {
1443 if (locext.SquareDistance() > myDist)
1445 myDist = locext.SquareDistance();
1447 (locext.Point()).Parameter(u, v);
1448 if((Usup - U0) > (U0 - Uinf))
1452 if((Vsup - V0) > (V0 - Vinf))
1457 U1 = U0 + usens*uperiod;
1458 V1 = V0 + vsens*vperiod;
1459 Pts2d(i).SetCoord(U1,V1);
1460 myProjIsDone = Standard_True;
1464 Extrema_ExtPS ext(pntproj, Surf->Surface(), TolU, TolV) ;
1466 Dist2Min = ext.SquareDistance(1);
1467 Standard_Integer aGoodValue = 1;
1468 for ( j = 2 ; j <= ext.NbExt() ; j++ )
1469 if( Dist2Min > ext.SquareDistance(j)) {
1470 Dist2Min = ext.SquareDistance(j);
1473 if (Dist2Min < DistTol3d2) {
1474 //if (Dist2Min < Tol3d * Tol3d) {
1475 if (Dist2Min > myDist)
1479 (ext.Point(aGoodValue)).Parameter(u, v);
1481 if((U0 - u) > (2*uperiod/3)) {
1485 if((u - U0) > (2*uperiod/3)) {
1490 if((V0 - v) > (vperiod/2)) {
1494 if((v - V0) > (vperiod/2)) {
1499 U1 = U0 + usens*uperiod;
1500 V1 = V0 + vsens*vperiod;
1501 Pts2d(i).SetCoord(U1,V1);
1502 myProjIsDone = Standard_True;
1510 // -- Pnts2d is transformed into Geom2d_BSplineCurve, with the help of Param and Mult
1512 myBSpline = new Geom2d_BSplineCurve(Pts2d,Param,Mult,1);
1513 //jgv: put the curve into parametric range
1514 gp_Pnt2d MidPoint = myBSpline->Value(0.5*(myBSpline->FirstParameter() + myBSpline->LastParameter()));
1515 Standard_Real TestU = MidPoint.X(), TestV = MidPoint.Y();
1516 Standard_Real sense = 0.;
1519 if (TestU < Uinf - TolU)
1521 else if (TestU > Usup + TolU)
1523 while (TestU < Uinf - TolU || TestU > Usup + TolU)
1524 TestU += sense * uperiod;
1529 if (TestV < Vinf - TolV)
1531 else if (TestV > Vsup + TolV)
1533 while (TestV < Vinf - TolV || TestV > Vsup + TolV)
1534 TestV += sense * vperiod;
1536 gp_Vec2d Offset(TestU - MidPoint.X(), TestV - MidPoint.Y());
1537 if (Abs(Offset.X()) > gp::Resolution() ||
1538 Abs(Offset.Y()) > gp::Resolution())
1539 myBSpline->Translate(Offset);
1540 //////////////////////////////////////////
1541 Geom2dAdaptor_Curve GAC(myBSpline);
1542 Handle(Adaptor2d_HCurve2d) IC2d = new Geom2dAdaptor_HCurve(GAC);
1545 // sprintf(name,"%s_%d","build",compteur++);
1546 // DrawTrSurf::Set(name,myBSpline);
1551 // Modified by Sergey KHROMOV - Thu Apr 18 10:57:50 2002 Begin
1552 // Standard_NoSuchObject_Raise_if(1,"ProjLib_Compu: build echec");
1553 // Modified by Sergey KHROMOV - Thu Apr 18 10:57:51 2002 End
1554 return Handle(Adaptor2d_HCurve2d)();
1556 // myProjIsDone = Standard_False;
1557 // Modified by Sergey KHROMOV - Thu Apr 18 10:58:01 2002 Begin
1558 // Standard_NoSuchObject_Raise_if(1,"ProjLib_ComputeOnPS: build echec");
1559 // Modified by Sergey KHROMOV - Thu Apr 18 10:58:02 2002 End
1562 //=======================================================================
1563 //function : ProjLib_ProjectUsingInitialCurve2d
1565 //=======================================================================
1566 Handle(Geom2d_BSplineCurve)
1567 ProjLib_ComputeApproxOnPolarSurface::
1568 ProjectUsingInitialCurve2d(const Handle(Adaptor3d_HCurve)& Curve,
1569 const Handle(Adaptor3d_HSurface)& Surf,
1570 const Handle(Adaptor2d_HCurve2d)& InitCurve2d)
1573 Standard_Real Tol3d = myTolerance;
1574 Standard_Real DistTol3d = 100.0*Tol3d;
1577 DistTol3d = myMaxDist;
1579 Standard_Real DistTol3d2 = DistTol3d * DistTol3d;
1580 Standard_Real TolU = Surf->UResolution(Tol3d), TolV = Surf->VResolution(Tol3d);
1581 Standard_Real Tol2d = Max(Sqrt(TolU*TolU + TolV*TolV), Precision::PConfusion());
1584 GeomAbs_SurfaceType TheTypeS = Surf->GetType();
1585 GeomAbs_CurveType TheTypeC = Curve->GetType();
1586 if(TheTypeS == GeomAbs_Plane) {
1588 gp_Pln Plane = Surf->Plane();
1589 if(TheTypeC == GeomAbs_BSplineCurve) {
1590 myTolReached = Precision::Confusion();
1591 Handle(Geom_BSplineCurve) BSC = Curve->BSpline();
1592 TColgp_Array1OfPnt2d Poles2d(1,Curve->NbPoles());
1593 for(i = 1;i <= Curve->NbPoles();i++) {
1594 ElSLib::Parameters( Plane, BSC->Pole(i), S, T);
1595 Poles2d(i).SetCoord(S,T);
1597 TColStd_Array1OfReal Knots(1, BSC->NbKnots());
1599 TColStd_Array1OfInteger Mults(1, BSC->NbKnots());
1600 BSC->Multiplicities(Mults);
1601 if(BSC->IsRational()) {
1602 TColStd_Array1OfReal Weights(1, BSC->NbPoles());
1603 BSC->Weights(Weights);
1604 return new Geom2d_BSplineCurve(Poles2d, Weights, Knots, Mults,
1605 BSC->Degree(), BSC->IsPeriodic()) ;
1607 return new Geom2d_BSplineCurve(Poles2d, Knots, Mults,
1608 BSC->Degree(), BSC->IsPeriodic()) ;
1611 if(TheTypeC == GeomAbs_BezierCurve) {
1612 myTolReached = Precision::Confusion();
1613 Handle(Geom_BezierCurve) BC = Curve->Bezier();
1614 TColgp_Array1OfPnt2d Poles2d(1,Curve->NbPoles());
1615 for(i = 1;i <= Curve->NbPoles();i++) {
1616 ElSLib::Parameters( Plane, BC->Pole(i), S, T);
1617 Poles2d(i).SetCoord(S,T);
1619 TColStd_Array1OfReal Knots(1, 2);
1620 Knots.SetValue(1,0.0);
1621 Knots.SetValue(2,1.0);
1622 TColStd_Array1OfInteger Mults(1, 2);
1623 Mults.Init(BC->NbPoles());
1624 if(BC->IsRational()) {
1625 TColStd_Array1OfReal Weights(1, BC->NbPoles());
1626 BC->Weights(Weights);
1627 return new Geom2d_BSplineCurve(Poles2d, Weights, Knots, Mults,
1628 BC->Degree(), BC->IsPeriodic()) ;
1630 return new Geom2d_BSplineCurve(Poles2d, Knots, Mults,
1631 BC->Degree(), BC->IsPeriodic()) ;
1634 if(TheTypeS == GeomAbs_BSplineSurface) {
1635 Handle(Geom_BSplineSurface) BSS = Surf->BSpline();
1636 if((BSS->MaxDegree() == 1) &&
1637 (BSS->NbUPoles() == 2) &&
1638 (BSS->NbVPoles() == 2)) {
1639 gp_Pnt p11 = BSS->Pole(1,1);
1640 gp_Pnt p12 = BSS->Pole(1,2);
1641 gp_Pnt p21 = BSS->Pole(2,1);
1642 gp_Pnt p22 = BSS->Pole(2,2);
1645 if(V1.IsEqual(V2,Tol3d,Tol3d/(p11.Distance(p12)*180/M_PI))){
1646 Standard_Integer Dist2Min = IntegerLast();
1648 if(TheTypeC == GeomAbs_BSplineCurve) {
1649 myTolReached = Tol3d;
1650 Handle(Geom_BSplineCurve) BSC = Curve->BSpline();
1651 TColgp_Array1OfPnt2d Poles2d(1,Curve->NbPoles());
1652 for(i = 1;i <= Curve->NbPoles();i++) {
1653 myProjIsDone = Standard_False;
1654 Dist2Min = IntegerLast();
1656 Extrema_GenLocateExtPS extrloc(Surf->Surface(), TolU, TolV);
1657 extrloc.Perform(BSC->Pole(i), (p11.X()+p22.X())/2, (p11.Y()+p22.Y())/2);
1659 if (extrloc.IsDone()) {
1660 Dist2Min = (Standard_Integer ) extrloc.SquareDistance();
1661 if (Dist2Min < DistTol3d2) {
1662 (extrloc.Point()).Parameter(u,v);
1663 Poles2d(i).SetCoord(u,v);
1664 myProjIsDone = Standard_True;
1673 TColStd_Array1OfReal Knots(1, BSC->NbKnots());
1675 TColStd_Array1OfInteger Mults(1, BSC->NbKnots());
1676 BSC->Multiplicities(Mults);
1677 if(BSC->IsRational()) {
1678 TColStd_Array1OfReal Weights(1, BSC->NbPoles());
1679 BSC->Weights(Weights);
1680 return new Geom2d_BSplineCurve(Poles2d, Weights, Knots, Mults,
1681 BSC->Degree(), BSC->IsPeriodic()) ;
1683 return new Geom2d_BSplineCurve(Poles2d, Knots, Mults,
1684 BSC->Degree(), BSC->IsPeriodic()) ;
1689 if(TheTypeC == GeomAbs_BezierCurve) {
1690 myTolReached = Tol3d;
1691 Handle(Geom_BezierCurve) BC = Curve->Bezier();
1692 TColgp_Array1OfPnt2d Poles2d(1,Curve->NbPoles());
1693 for(i = 1;i <= Curve->NbPoles();i++) {
1694 Dist2Min = IntegerLast();
1696 Extrema_GenLocateExtPS extrloc(Surf->Surface(), TolU, TolV);
1697 extrloc.Perform(BC->Pole(i), 0.5, 0.5);
1699 if (extrloc.IsDone()) {
1700 Dist2Min = (Standard_Integer ) extrloc.SquareDistance();
1701 if (Dist2Min < DistTol3d2) {
1702 (extrloc.Point()).Parameter(u,v);
1703 Poles2d(i).SetCoord(u,v);
1704 myProjIsDone = Standard_True;
1710 myProjIsDone = Standard_False;
1714 TColStd_Array1OfReal Knots(1, 2);
1715 Knots.SetValue(1,0.0);
1716 Knots.SetValue(2,1.0);
1717 TColStd_Array1OfInteger Mults(1, 2);
1718 Mults.Init(BC->NbPoles());
1719 if(BC->IsRational()) {
1720 TColStd_Array1OfReal Weights(1, BC->NbPoles());
1721 BC->Weights(Weights);
1722 return new Geom2d_BSplineCurve(Poles2d, Weights, Knots, Mults,
1723 BC->Degree(), BC->IsPeriodic()) ;
1725 return new Geom2d_BSplineCurve(Poles2d, Knots, Mults,
1726 BC->Degree(), BC->IsPeriodic()) ;
1732 else if(TheTypeS == GeomAbs_BezierSurface) {
1733 Handle(Geom_BezierSurface) BS = Surf->Bezier();
1734 if((BS->MaxDegree() == 1) &&
1735 (BS->NbUPoles() == 2) &&
1736 (BS->NbVPoles() == 2)) {
1737 gp_Pnt p11 = BS->Pole(1,1);
1738 gp_Pnt p12 = BS->Pole(1,2);
1739 gp_Pnt p21 = BS->Pole(2,1);
1740 gp_Pnt p22 = BS->Pole(2,2);
1743 if(V1.IsEqual(V2,Tol3d,Tol3d/(p11.Distance(p12)*180/M_PI))){
1744 Standard_Integer Dist2Min = IntegerLast();
1748 if(TheTypeC == GeomAbs_BSplineCurve) {
1749 myTolReached = Tol3d;
1750 Handle(Geom_BSplineCurve) BSC = Curve->BSpline();
1751 TColgp_Array1OfPnt2d Poles2d(1,Curve->NbPoles());
1752 for(i = 1;i <= Curve->NbPoles();i++) {
1753 myProjIsDone = Standard_False;
1754 Dist2Min = IntegerLast();
1756 Extrema_GenLocateExtPS extrloc(Surf->Surface(), TolU, TolV);
1757 extrloc.Perform(BSC->Pole(i), (p11.X()+p22.X())/2, (p11.Y()+p22.Y())/2);
1759 if (extrloc.IsDone()) {
1760 Dist2Min = (Standard_Integer ) extrloc.SquareDistance();
1761 if (Dist2Min < DistTol3d2) {
1762 (extrloc.Point()).Parameter(u,v);
1763 Poles2d(i).SetCoord(u,v);
1764 myProjIsDone = Standard_True;
1773 TColStd_Array1OfReal Knots(1, BSC->NbKnots());
1775 TColStd_Array1OfInteger Mults(1, BSC->NbKnots());
1776 BSC->Multiplicities(Mults);
1777 if(BSC->IsRational()) {
1778 TColStd_Array1OfReal Weights(1, BSC->NbPoles());
1779 BSC->Weights(Weights);
1780 return new Geom2d_BSplineCurve(Poles2d, Weights, Knots, Mults,
1781 BSC->Degree(), BSC->IsPeriodic()) ;
1783 return new Geom2d_BSplineCurve(Poles2d, Knots, Mults,
1784 BSC->Degree(), BSC->IsPeriodic()) ;
1789 if(TheTypeC == GeomAbs_BezierCurve) {
1790 myTolReached = Tol3d;
1791 Handle(Geom_BezierCurve) BC = Curve->Bezier();
1792 TColgp_Array1OfPnt2d Poles2d(1,Curve->NbPoles());
1793 for(i = 1;i <= Curve->NbPoles();i++) {
1794 Dist2Min = IntegerLast();
1796 Extrema_GenLocateExtPS extrloc(Surf->Surface(), TolU, TolV);
1797 extrloc.Perform(BC->Pole(i), 0.5, 0.5);
1799 if (extrloc.IsDone()) {
1800 Dist2Min = (Standard_Integer ) extrloc.SquareDistance();
1801 if (Dist2Min < DistTol3d2) {
1802 (extrloc.Point()).Parameter(u,v);
1803 Poles2d(i).SetCoord(u,v);
1804 myProjIsDone = Standard_True;
1810 myProjIsDone = Standard_False;
1814 TColStd_Array1OfReal Knots(1, 2);
1815 Knots.SetValue(1,0.0);
1816 Knots.SetValue(2,1.0);
1817 TColStd_Array1OfInteger Mults(1, 2);
1818 Mults.Init(BC->NbPoles());
1819 if(BC->IsRational()) {
1820 TColStd_Array1OfReal Weights(1, BC->NbPoles());
1821 BC->Weights(Weights);
1822 return new Geom2d_BSplineCurve(Poles2d, Weights, Knots, Mults,
1823 BC->Degree(), BC->IsPeriodic()) ;
1825 return new Geom2d_BSplineCurve(Poles2d, Knots, Mults,
1826 BC->Degree(), BC->IsPeriodic()) ;
1833 ProjLib_PolarFunction F(Curve, Surf, InitCurve2d, Tol3d) ;
1836 Standard_Integer Nb = 50;
1838 Standard_Real U, U1, U2;
1839 U1 = F.FirstParameter();
1840 U2 = F.LastParameter();
1842 TColgp_Array1OfPnt2d DummyPoles(1,Nb+1);
1843 TColStd_Array1OfReal DummyKnots(1,Nb+1);
1844 TColStd_Array1OfInteger DummyMults(1,Nb+1);
1847 DummyMults(Nb+1) = 2;
1848 for (Standard_Integer ij = 0; ij <= Nb; ij++) {
1849 U = (Nb-ij)*U1 + ij*U2;
1851 DummyPoles(ij+1) = F.Value(U);
1852 DummyKnots(ij+1) = ij;
1854 Handle(Geom2d_BSplineCurve) DummyC2d =
1855 new Geom2d_BSplineCurve(DummyPoles, DummyKnots, DummyMults, 1);
1857 Standard_CString Temp = "bs2d";
1858 DrawTrSurf::Set(Temp,DummyC2d);
1860 // DrawTrSurf::Set((Standard_CString ) "bs2d",DummyC2d);
1861 Handle(Geom2dAdaptor_HCurve) DDD =
1862 Handle(Geom2dAdaptor_HCurve)::DownCast(InitCurve2d);
1866 DrawTrSurf::Set(Temp,DDD->ChangeCurve2d().Curve());
1868 // DrawTrSurf::Set((Standard_CString ) "initc2d",DDD->ChangeCurve2d().Curve());
1871 Standard_Integer Deg1,Deg2;
1882 Standard_Integer aMaxSegments = 1000;
1883 if(myMaxSegments > 0)
1885 aMaxSegments = myMaxSegments;
1887 AppParCurves_Constraint aFistC = AppParCurves_TangencyPoint, aLastC = AppParCurves_TangencyPoint;
1888 if(myBndPnt != AppParCurves_TangencyPoint)
1894 if (myDist > 10.*Tol3d)
1896 aFistC = AppParCurves_PassPoint;
1897 aLastC = AppParCurves_PassPoint;
1900 Approx_FitAndDivide2d Fit(Deg1, Deg2, Tol3d, Tol2d, Standard_True, aFistC, aLastC);
1901 Fit.SetMaxSegments(aMaxSegments);
1902 if (InitCurve2d->GetType() == GeomAbs_Line)
1904 Fit.SetInvOrder(Standard_False);
1908 Standard_Real anOldTol2d = Tol2d;
1909 Standard_Real aNewTol2d = 0;
1910 if(Fit.IsAllApproximated()) {
1912 Standard_Integer NbCurves = Fit.NbMultiCurves();
1913 Standard_Integer MaxDeg = 0;
1914 // To transform the MultiCurve into BSpline, it is required that all
1915 // Bezier constituing it have the same degree -> Calculation of MaxDeg
1916 Standard_Integer NbPoles = 1;
1917 for (j = 1; j <= NbCurves; j++) {
1918 Standard_Integer Deg = Fit.Value(j).Degree();
1919 MaxDeg = Max ( MaxDeg, Deg);
1920 Fit.Error(j,Tol3d, Tol2d);
1921 aNewTol2d = Max(aNewTol2d, Tol2d);
1924 myTolReached = Max(myTolReached, myTolerance * (aNewTol2d / anOldTol2d));
1926 NbPoles = MaxDeg * NbCurves + 1; //Tops on the BSpline
1927 TColgp_Array1OfPnt2d Poles( 1, NbPoles);
1929 TColgp_Array1OfPnt2d TempPoles( 1, MaxDeg + 1);//to augment the degree
1931 TColStd_Array1OfReal Knots( 1, NbCurves + 1); //Nodes of the BSpline
1933 Standard_Integer Compt = 1;
1934 for (i = 1; i <= NbCurves; i++) {
1935 Fit.Parameters(i, Knots(i), Knots(i+1));
1936 AppParCurves_MultiCurve MC = Fit.Value( i); //Load the Ith Curve
1937 TColgp_Array1OfPnt2d Poles2d( 1, MC.Degree() + 1);//Retrieve the tops
1938 MC.Curve(1, Poles2d);
1940 //Eventual augmentation of the degree
1941 Standard_Integer Inc = MaxDeg - MC.Degree();
1943 // BSplCLib::IncreaseDegree( Inc, Poles2d, PLib::NoWeights(),
1944 BSplCLib::IncreaseDegree( MaxDeg, Poles2d, BSplCLib::NoWeights(),
1945 TempPoles, BSplCLib::NoWeights());
1946 //update of tops of the PCurve
1947 for (Standard_Integer k = 1 ; k <= MaxDeg + 1; k++) {
1948 Poles.SetValue( Compt, TempPoles( k));
1953 //update of tops of the PCurve
1954 for (Standard_Integer k = 1 ; k <= MaxDeg + 1; k++) {
1955 Poles.SetValue( Compt, Poles2d( k));
1963 //update of fields of ProjLib_Approx
1964 Standard_Integer NbKnots = NbCurves + 1;
1966 TColStd_Array1OfInteger Mults( 1, NbKnots);
1968 Mults.SetValue( 1, MaxDeg + 1);
1969 Mults.SetValue(NbKnots, MaxDeg + 1);
1970 myProjIsDone = Standard_True;
1971 Handle(Geom2d_BSplineCurve) Dummy =
1972 new Geom2d_BSplineCurve(Poles,Knots,Mults,MaxDeg);
1974 // try to smoother the Curve GeomAbs_C1.
1976 Standard_Boolean OK = Standard_True;
1977 Standard_Real aSmoothTol = Max(Precision::Confusion(), aNewTol2d);
1978 if (myBndPnt == AppParCurves_PassPoint)
1982 for (Standard_Integer ij = 2; ij < NbKnots; ij++) {
1983 OK = OK && Dummy->RemoveKnot(ij,MaxDeg-1, aSmoothTol);
1987 std::cout << "ProjLib_ComputeApproxOnPolarSurface : Smoothing echoue"<<std::endl;
1992 return Handle(Geom2d_BSplineCurve)();
1995 //=======================================================================
1996 //function : BSpline
1998 //=======================================================================
2000 Handle(Geom2d_BSplineCurve)
2001 ProjLib_ComputeApproxOnPolarSurface::BSpline() const
2007 //=======================================================================
2008 //function : Curve2d
2010 //=======================================================================
2012 Handle(Geom2d_Curve)
2013 ProjLib_ComputeApproxOnPolarSurface::Curve2d() const
2016 Standard_NoSuchObject_Raise_if
2018 "ProjLib_ComputeApproxOnPolarSurface:2ndCurve2d");
2023 //=======================================================================
2026 //=======================================================================
2028 Standard_Boolean ProjLib_ComputeApproxOnPolarSurface::IsDone() const
2031 return myProjIsDone;
2033 //=======================================================================
2034 //function : SetTolerance
2036 //=======================================================================
2038 void ProjLib_ComputeApproxOnPolarSurface::SetTolerance(const Standard_Real theTol)
2041 myTolerance = theTol;
2043 //=======================================================================
2044 //function : SetDegree
2046 //=======================================================================
2047 void ProjLib_ComputeApproxOnPolarSurface::SetDegree(
2048 const Standard_Integer theDegMin,
2049 const Standard_Integer theDegMax)
2051 myDegMin = theDegMin;
2052 myDegMax = theDegMax;
2054 //=======================================================================
2055 //function : SetMaxSegments
2057 //=======================================================================
2058 void ProjLib_ComputeApproxOnPolarSurface::SetMaxSegments(
2059 const Standard_Integer theMaxSegments)
2061 myMaxSegments = theMaxSegments;
2064 //=======================================================================
2065 //function : SetBndPnt
2067 //=======================================================================
2068 void ProjLib_ComputeApproxOnPolarSurface::SetBndPnt(
2069 const AppParCurves_Constraint theBndPnt)
2071 myBndPnt = theBndPnt;
2074 //=======================================================================
2075 //function : SetMaxDist
2077 //=======================================================================
2078 void ProjLib_ComputeApproxOnPolarSurface::SetMaxDist(
2079 const Standard_Real theMaxDist)
2081 myMaxDist = theMaxDist;
2084 //=======================================================================
2085 //function : Tolerance
2087 //=======================================================================
2089 Standard_Real ProjLib_ComputeApproxOnPolarSurface::Tolerance() const
2092 return myTolReached;