1 // Created on: 1993-08-25
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272
25 #include <GeomAbs_SurfaceType.hxx>
26 #include <Standard_NoSuchObject.hxx>
27 #include <Standard_NotImplemented.hxx>
28 #include <ProjLib_ProjectedCurve.hxx>
29 #include <ProjLib_CompProjectedCurve.hxx>
30 #include <ProjLib_HCompProjectedCurve.hxx>
31 #include <ProjLib_ComputeApproxOnPolarSurface.hxx>
32 #include <ProjLib_ComputeApprox.hxx>
33 #include <ProjLib_Projector.hxx>
34 #include <Handle_Adaptor3d_HCurve.hxx>
35 #include <Handle_Adaptor3d_HSurface.hxx>
36 #include <Adaptor3d_HCurve.hxx>
37 #include <Adaptor3d_HSurface.hxx>
38 #include <Approx_CurveOnSurface.hxx>
39 #include <ProjLib_Plane.hxx>
40 #include <ProjLib_Cylinder.hxx>
41 #include <ProjLib_Cone.hxx>
42 #include <ProjLib_Sphere.hxx>
43 #include <ProjLib_Torus.hxx>
44 #include <Precision.hxx>
45 #include <Handle_Geom_BSplineCurve.hxx>
46 #include <Geom2d_BSplineCurve.hxx>
47 #include <Handle_Geom2d_BSplineCurve.hxx>
48 #include <Geom2d_BezierCurve.hxx>
49 #include <Handle_Geom2d_BezierCurve.hxx>
50 #include <Handle_Adaptor2d_HCurve2d.hxx>
51 #include <gp_Vec2d.hxx>
52 #include <StdFail_NotDone.hxx>
54 #include <TColgp_HArray1OfPnt2d.hxx>
55 #include <TColStd_HArray1OfReal.hxx>
56 #include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
57 #include <TColStd_Array1OfReal.hxx>
58 #include <TColStd_Array1OfInteger.hxx>
59 #include <TColgp_Array1OfPnt2d.hxx>
60 #include <TColgp_HArray1OfVec2d.hxx>
61 #include <TColStd_HArray1OfBoolean.hxx>
62 #include <BSplCLib.hxx>
63 #include <GeomAbs_IsoType.hxx>
65 //=======================================================================
68 //=======================================================================
70 static Standard_Boolean IsoIsDeg (const Adaptor3d_Surface& S,
71 const Standard_Real Param,
72 const GeomAbs_IsoType IT,
73 const Standard_Real TolMin,
74 const Standard_Real TolMax)
76 Standard_Real U1=0.,U2=0.,V1=0.,V2=0.,T;
77 Standard_Boolean Along = Standard_True;
78 U1 = S.FirstUParameter();
79 U2 = S.LastUParameter();
80 V1 = S.FirstVParameter();
81 V2 = S.LastVParameter();
84 Standard_Real Step,D1NormMax;
85 if (IT == GeomAbs_IsoV)
89 for (T=U1;T<=U2;T=T+Step)
91 S.D1(T,Param,P,D1U,D1V);
92 D1NormMax=Max(D1NormMax,D1U.Magnitude());
95 if (D1NormMax >TolMax || D1NormMax < TolMin )
96 Along = Standard_False;
102 for (T=V1;T<=V2;T=T+Step)
104 S.D1(Param,T,P,D1U,D1V);
105 D1NormMax=Max(D1NormMax,D1V.Magnitude());
108 if (D1NormMax >TolMax || D1NormMax < TolMin )
109 Along = Standard_False;
116 //=======================================================================
117 //function : Interpolate
119 //=======================================================================
121 static Handle(Geom2d_BSplineCurve) Interpolate(const Handle(TColgp_HArray1OfPnt2d)& myPoints,
122 const Handle(TColStd_HArray1OfReal)& myParameters,
123 const gp_Vec2d& InitialTangent,
124 const gp_Vec2d& FinalTangent)
126 Handle(Geom2d_BSplineCurve) myCurve = NULL;
128 // This code is extraction from Geom2dAPI_Interpolate with small correction
129 // This is done to avoid of cyclic dependency if Geom2dAPI is used in ProjLib
131 Standard_Integer degree,
146 Standard_Boolean myTangentRequest = Standard_True;
148 Handle(TColgp_HArray1OfVec2d) myTangents =
149 new TColgp_HArray1OfVec2d(myPoints->Lower(),
151 Handle(TColStd_HArray1OfBoolean) myTangentFlags =
152 new TColStd_HArray1OfBoolean(myPoints->Lower(),
154 myTangentFlags->Init(Standard_False);
156 myTangentFlags->SetValue(1,Standard_True) ;
157 myTangentFlags->SetValue(myPoints->Length(),Standard_True) ;
158 myTangents->SetValue(1,InitialTangent) ;
159 myTangents->SetValue(myPoints->Length(),FinalTangent);
163 num_poles = myPoints->Length() ;
164 if (num_poles == 2 && !myTangentRequest) {
167 else if (num_poles == 3 && !myTangentRequest) {
169 num_distinct_knots = 2 ;
174 //if (myTangentRequest)
175 //for (ii = myTangentFlags->Lower() + 1 ;
176 // ii < myTangentFlags->Upper() ; ii++) {
177 //if (myTangentFlags->Value(ii)) {
184 TColStd_Array1OfReal parameters(1,num_poles) ;
185 TColStd_Array1OfReal flatknots(1,num_poles + degree + 1) ;
186 TColStd_Array1OfInteger mults(1,num_distinct_knots) ;
187 TColStd_Array1OfReal knots(1,num_distinct_knots) ;
188 TColStd_Array1OfInteger contact_order_array(1, num_poles) ;
189 TColgp_Array1OfPnt2d poles(1,num_poles) ;
191 for (ii = 1 ; ii <= degree + 1 ; ii++) {
192 flatknots.SetValue(ii,myParameters->Value(1)) ;
193 flatknots.SetValue(ii + num_poles,
194 myParameters->Value(num_points)) ;
196 for (ii = 1 ; ii <= num_poles ; ii++) {
197 contact_order_array.SetValue(ii,0) ;
199 for (ii = 2 ; ii < num_distinct_knots ; ii++) {
200 mults.SetValue(ii,1) ;
202 mults.SetValue(1,degree + 1) ;
203 mults.SetValue(num_distinct_knots ,degree + 1) ;
207 for (ii = 1 ; ii <= num_poles ; ii++) {
208 poles.SetValue(ii ,myPoints->Value(ii)) ;
211 new Geom2d_BSplineCurve(poles,
212 myParameters->Array1(),
215 //myIsDone = Standard_True ;
218 knots.SetValue(1,myParameters->Value(1)) ;
219 knots.SetValue(2,myParameters->Value(3)) ;
220 for (ii = 1 ; ii <= num_poles ; ii++) {
221 poles.SetValue(ii,myPoints->Value(ii)) ;
224 BSplCLib::Interpolate(degree,
226 myParameters->Array1(),
230 if (!inversion_problem) {
232 new Geom2d_BSplineCurve(poles,
236 //myIsDone = Standard_True ;
241 // check if the boundary conditions are set
243 //if (num_points >= 3) {
245 // cannot build the tangents with degree 3 with only 2 points
246 // if those where not given in advance
248 //BuildTangents(myPoints->Array1(),
249 //myTangents->ChangeArray1(),
250 //myTangentFlags->ChangeArray1(),
251 //myParameters->Array1()) ;
253 contact_order_array.SetValue(2,1) ;
254 parameters.SetValue(1,myParameters->Value(1)) ;
255 parameters.SetValue(2,myParameters->Value(1)) ;
256 poles.SetValue(1,myPoints->Value(1)) ;
257 for (jj = 1 ; jj <= 2 ; jj++) {
258 a_point.SetCoord(jj,myTangents->Value(1).Coord(jj)) ;
261 poles.SetValue(2,a_point) ;
265 index2 = myPoints->Lower() + 1 ;
266 index3 = degree + 2 ;
267 if (myTangentRequest) {
268 for (ii = myParameters->Lower() + 1 ;
269 ii < myParameters->Upper() ; ii++) {
270 parameters.SetValue(index,myParameters->Value(ii)) ;
271 poles.SetValue(index,myPoints->Value(index2)) ;
272 flatknots.SetValue(index3,myParameters->Value(ii)) ;
275 if (myTangentFlags->Value(index1)) {
277 // set the multiplicities, the order of the contact, the
280 mults.SetValue(mult_index,mults.Value(mult_index) + 1) ;
281 contact_order_array(index) = 1 ;
282 flatknots.SetValue(index3, myParameters->Value(ii)) ;
283 parameters.SetValue(index,
284 myParameters->Value(ii)) ;
285 for (jj = 1 ; jj <= 2 ; jj++) {
286 a_point.SetCoord(jj,myTangents->Value(ii).Coord(jj)) ;
288 poles.SetValue(index,a_point) ;
300 for(ii = myParameters->Lower() ; ii <= myParameters->Upper() ; ii++) {
301 parameters.SetValue(index1,
302 myParameters->Value(ii)) ;
306 for (ii = myPoints->Lower() + 1 ; ii <= myPoints->Upper() - 1 ; ii++) {
307 poles.SetValue(index,
308 myPoints->Value(ii)) ;
314 for(ii = myParameters->Lower() ; ii <= myParameters->Upper() ; ii++) {
315 flatknots.SetValue(index,
316 myParameters->Value(ii)) ;
320 for (jj = 1 ; jj <= 2 ; jj++) {
322 myTangents->Value(num_points).Coord(jj)) ;
324 poles.SetValue(num_poles-1 ,a_point) ;
326 contact_order_array.SetValue(num_poles - 1,1) ;
327 parameters.SetValue(num_poles,
328 myParameters->Value(myParameters->Upper())) ;
329 parameters.SetValue(num_poles -1,
330 myParameters->Value(myParameters->Upper())) ;
332 poles.SetValue(num_poles,
333 myPoints->Value(num_points)) ;
335 BSplCLib::Interpolate(degree,
341 if (!inversion_problem) {
343 new Geom2d_BSplineCurve(poles,
344 myParameters->Array1(),
347 //myIsDone = Standard_True ;
357 //=======================================================================
360 //=======================================================================
362 static void TrimC3d(Handle(Adaptor3d_HCurve)& myCurve,
363 Standard_Boolean* IsTrimmed,
364 const Standard_Real dt,
367 Standard_Real f = myCurve->FirstParameter();
368 Standard_Real l = myCurve->LastParameter();
370 gp_Pnt P = myCurve->Value(f);
372 if(P.Distance(Pole) < Precision::Confusion()) {
373 IsTrimmed[0] = Standard_True;
375 myCurve = myCurve->Trim(f, l, Precision::Confusion());
378 P = myCurve->Value(l);
379 if(P.Distance(Pole) < Precision::Confusion()) {
380 IsTrimmed[1] = Standard_True;
382 myCurve = myCurve->Trim(f, l, Precision::Confusion());
386 //=======================================================================
387 //function : ExtendC2d
389 //=======================================================================
391 static void ExtendC2d(Handle(Geom2d_BSplineCurve)& aRes,
392 const Standard_Real t,
393 const Standard_Real dt,
394 const Standard_Real u1,
395 const Standard_Real u2,
396 const Standard_Real v1,
397 const Standard_Real v2)
401 aRes->D2(t, P0, V01, V02);
403 gp_XY XYP1 = P0.XY() + V01.XY()*dt + .5*V02.XY()*dt*dt;
405 gp_Vec2d V11 = V01 + V02*dt;
407 if(XYP1.X() < u1) XYP1.SetX(u1);
408 if(XYP1.X() > u2) XYP1.SetX(u2);
409 if(XYP1.Y() < v1) XYP1.SetY(v1);
410 if(XYP1.Y() > v2) XYP1.SetY(v2);
412 Handle(TColgp_HArray1OfPnt2d) aPnts = new TColgp_HArray1OfPnt2d(1, 2);
413 Handle(TColStd_HArray1OfReal) aPars = new TColStd_HArray1OfReal(1, 2);
416 aPnts->SetValue(1, gp_Pnt2d(XYP1));
417 aPnts->SetValue(2, P0);
418 aPars->SetValue(1, t + dt);
419 aPars->SetValue(2, t);
422 aPnts->SetValue(2, gp_Pnt2d(XYP1));
423 aPnts->SetValue(1, P0);
424 aPars->SetValue(2, t + dt);
425 aPars->SetValue(1, t);
428 Handle(Geom2d_BSplineCurve) aC;
431 aC = Interpolate(aPnts, aPars, V11, V01);
434 aC = Interpolate(aPnts, aPars, V01, V11);
438 Geom2dConvert_CompCurveToBSplineCurve aConcat(aRes);
439 aConcat.Add(aC, Precision::PConfusion());
441 aRes = aConcat.BSplineCurve();
445 //=======================================================================
448 //=======================================================================
450 static void Project(ProjLib_Projector& P, Handle(Adaptor3d_HCurve)& C)
452 GeomAbs_CurveType CType = C->GetType();
455 P.Project(C->Line());
458 P.Project(C->Circle());
460 case GeomAbs_Ellipse:
461 P.Project(C->Ellipse());
463 case GeomAbs_Hyperbola:
464 P.Project(C->Hyperbola());
466 case GeomAbs_Parabola:
467 P.Project(C->Parabola());
469 case GeomAbs_BSplineCurve:
470 case GeomAbs_BezierCurve:
471 case GeomAbs_OtherCurve: // try the approximation
474 Standard_NoSuchObject::Raise(" ");
478 //=======================================================================
479 //function : ProjLib_ProjectedCurve
481 //=======================================================================
483 ProjLib_ProjectedCurve::ProjLib_ProjectedCurve()
486 myTolerance = Precision::PApproximation();
490 //=======================================================================
491 //function : ProjLib_ProjectedCurve
493 //=======================================================================
495 ProjLib_ProjectedCurve::ProjLib_ProjectedCurve
496 (const Handle(Adaptor3d_HSurface)& S)
498 myTolerance = Precision::PApproximation();
503 //=======================================================================
504 //function : ProjLib_ProjectedCurve
506 //=======================================================================
508 ProjLib_ProjectedCurve::ProjLib_ProjectedCurve
509 (const Handle(Adaptor3d_HSurface)& S,
510 const Handle(Adaptor3d_HCurve)& C)
512 myTolerance = Precision::PApproximation();
518 //=======================================================================
519 //function : ProjLib_ProjectedCurve
521 //=======================================================================
523 ProjLib_ProjectedCurve::ProjLib_ProjectedCurve
524 (const Handle(Adaptor3d_HSurface)& S,
525 const Handle(Adaptor3d_HCurve)& C,
526 const Standard_Real Tol)
528 myTolerance = Max(Tol, Precision::PApproximation());
534 //=======================================================================
537 //=======================================================================
539 void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HSurface)& S)
545 //=======================================================================
548 //=======================================================================
550 void ProjLib_ProjectedCurve::Load(const Handle(Adaptor3d_HCurve)& C)
552 myTolerance = Max(myTolerance,Precision::PApproximation());
554 GeomAbs_SurfaceType SType = mySurface->GetType();
555 GeomAbs_CurveType CType = myCurve->GetType();
561 ProjLib_Plane P(mySurface->Plane());
567 case GeomAbs_Cylinder:
569 ProjLib_Cylinder P(mySurface->Cylinder());
577 ProjLib_Cone P(mySurface->Cone());
585 ProjLib_Sphere P(mySurface->Sphere());
588 // on met dans la pseudo-periode ( car Sphere n'est pas
589 // periodique en V !)
590 P.SetInBounds(myCurve->FirstParameter());
598 ProjLib_Torus P(mySurface->Torus());
604 case GeomAbs_BezierSurface:
605 case GeomAbs_BSplineSurface:
608 Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False};
609 Standard_Real f, l, dt;
610 const Standard_Real eps = 0.01;
611 f = myCurve->FirstParameter();
612 l = myCurve->LastParameter();
615 Standard_Real U1=0.,U2=0.,V1=0.,V2=0;
616 const Adaptor3d_Surface& S = mySurface->Surface();
617 U1 = S.FirstUParameter();
618 U2 = S.LastUParameter();
619 V1 = S.FirstVParameter();
620 V2 = S.LastVParameter();
622 if(IsoIsDeg(S, U1, GeomAbs_IsoU, 0., myTolerance) ) {
623 //Surface has pole at U = Umin
624 gp_Pnt Pole = mySurface->Value(U1, V1);
625 TrimC3d(myCurve, IsTrimmed, dt, Pole);
628 if(IsoIsDeg(S, U2, GeomAbs_IsoU, 0., myTolerance) ) {
629 //Surface has pole at U = Umax
630 gp_Pnt Pole = mySurface->Value(U2, V1);
631 TrimC3d(myCurve, IsTrimmed, dt, Pole);
634 if(IsoIsDeg(S, V1, GeomAbs_IsoV, 0., myTolerance) ) {
635 //Surface has pole at V = Vmin
636 gp_Pnt Pole = mySurface->Value(U1, V1);
637 TrimC3d(myCurve, IsTrimmed, dt, Pole);
640 if(IsoIsDeg(S, V2, GeomAbs_IsoV, 0., myTolerance) ) {
641 //Surface has pole at V = Vmax
642 gp_Pnt Pole = mySurface->Value(U1, V2);
643 TrimC3d(myCurve, IsTrimmed, dt, Pole);
646 ProjLib_ComputeApproxOnPolarSurface polar(myCurve,
650 Handle(Geom2d_BSplineCurve) aRes = polar.BSpline();
652 if(IsTrimmed[0] || IsTrimmed[1]) {
654 //Add segment before start of curve
655 f = myCurve->FirstParameter();
656 ExtendC2d(aRes, f, -dt, U1, U2, V1, V2);
659 //Add segment after end of curve
660 l = myCurve->LastParameter();
661 ExtendC2d(aRes, l, dt, U1, U2, V1, V2);
665 myResult.SetBSpline(aRes);
667 myResult.SetType(GeomAbs_BSplineCurve);
673 Standard_Boolean IsTrimmed[2] = {Standard_False, Standard_False};
674 Standard_Real f, l, dt;
675 const Standard_Real eps = 0.01;
677 if(mySurface->GetType() == GeomAbs_SurfaceOfRevolution) {
678 //Check possible singularity
680 gp_Pnt P = mySurface->AxeOfRevolution().Location();
681 gp_Dir N = mySurface->AxeOfRevolution().Direction();
685 f = myCurve->FirstParameter();
686 l = myCurve->LastParameter();
689 P = myCurve->Value(f);
690 if(L.Distance(P) < Precision::Confusion()) {
691 IsTrimmed[0] = Standard_True;
693 myCurve = myCurve->Trim(f, l, Precision::Confusion());
696 P = myCurve->Value(l);
697 if(L.Distance(P) < Precision::Confusion()) {
698 IsTrimmed[1] = Standard_True;
700 myCurve = myCurve->Trim(f, l, Precision::Confusion());
704 ProjLib_CompProjectedCurve Projector(mySurface,myCurve,
705 myTolerance,myTolerance);
706 Handle(ProjLib_HCompProjectedCurve) HProjector =
707 new ProjLib_HCompProjectedCurve();
708 HProjector->Set(Projector);
710 // Normalement, dans le cadre de ProjLib, le resultat
711 // doit etre une et une seule courbe !!!
712 // De plus, cette courbe ne doit pas etre Single point
713 Standard_Integer NbCurves = Projector.NbCurves();
714 Standard_Real Udeb,Ufin;
716 Projector.Bounds(1,Udeb,Ufin);
719 StdFail_NotDone::Raise("ProjLib CompProjectedCurve Not Done");
721 // Approximons cette courbe algorithmique.
722 Standard_Boolean Only3d = Standard_False;
723 Standard_Boolean Only2d = Standard_True;
724 GeomAbs_Shape Continuity = GeomAbs_C1;
725 Standard_Integer MaxDegree = 14;
726 Standard_Integer MaxSeg = 16;
728 Approx_CurveOnSurface appr(HProjector, mySurface, Udeb, Ufin,
730 Continuity, MaxDegree, MaxSeg,
733 Handle(Geom2d_BSplineCurve) aRes = appr.Curve2d();
735 if(IsTrimmed[0] || IsTrimmed[1]) {
736 // Treatment only for surface of revolution
737 Standard_Real u1, u2, v1, v2;
738 u1 = mySurface->FirstUParameter();
739 u2 = mySurface->LastUParameter();
740 v1 = mySurface->FirstVParameter();
741 v2 = mySurface->LastVParameter();
744 //Add segment before start of curve
745 ExtendC2d(aRes, f, -dt, u1, u2, v1, v2);
748 //Add segment after end of curve
749 ExtendC2d(aRes, l, dt, u1, u2, v1, v2);
753 myResult.SetBSpline(aRes);
755 myResult.SetType(GeomAbs_BSplineCurve);
758 if ( !myResult.IsDone()) {
759 ProjLib_ComputeApprox Comp( myCurve, mySurface, myTolerance);
763 if ( SType == GeomAbs_Plane && CType == GeomAbs_BezierCurve) {
764 myResult.SetType(GeomAbs_BezierCurve);
765 myResult.SetBezier(Comp.Bezier()) ;
768 myResult.SetType(GeomAbs_BSplineCurve);
769 myResult.SetBSpline(Comp.BSpline()) ;
771 // set the periodicity flag
772 if ( SType == GeomAbs_Plane &&
773 CType == GeomAbs_BSplineCurve &&
774 myCurve->IsPeriodic() ) {
775 myResult.SetPeriodic();
777 myTolerance = Comp.Tolerance();
781 // On remet arbitrairement la tol atteinte a une valeur
782 // petite en attendant mieux. dub lbo 11/03/97
783 myTolerance = Min(myTolerance,Precision::Confusion());
785 // Translate the projected curve to keep the first point
786 // In the canonical boundaries of periodic surfaces.
787 if (mySurface->IsUPeriodic()) {
789 Standard_Real aT1, aT2, aU1, aU2, aUPeriod, aUr, aUm, aUmid, dUm, dUr;
790 GeomAbs_CurveType aTypeR;
791 ProjLib_Projector aResult;
793 aT1=myCurve->FirstParameter();
794 aT2=myCurve->LastParameter();
795 aU1=mySurface->FirstUParameter();
796 aU2=mySurface->LastUParameter();
797 aUPeriod=mySurface->UPeriod();
799 aTypeR=myResult.GetType();
800 if ((aU2-aU1)<(aUPeriod-myTolerance) && aTypeR == GeomAbs_Line) {
802 aResult.UFrame(aT1, aT2, aU1, aUPeriod);
804 gp_Lin2d &aLr = (gp_Lin2d &) aResult.Line();
805 aUr=aLr.Location().X();
806 gp_Lin2d &aLm = (gp_Lin2d &) myResult.Line();
807 aUm=aLm.Location().X();
817 myResult.UFrame(aT1, aT2, aU1, aUPeriod);
821 myResult.UFrame(myCurve->FirstParameter(),
822 myCurve->LastParameter(),
823 mySurface->FirstUParameter(),
824 mySurface->UPeriod());
827 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
828 // Correct the U isoline in periodical surface
829 // to be inside restriction boundaries.
830 if (myResult.GetType() == GeomAbs_Line) {
831 gp_Lin2d &aLine = (gp_Lin2d &) myResult.Line();
833 Standard_Real aPeriod = mySurface->UPeriod();
834 Standard_Real aFUPar = mySurface->FirstUParameter();
835 Standard_Real aLUPar = mySurface->LastUParameter();
837 // Check if the parametric range is lower then the period.
838 if (aLUPar - aFUPar < aPeriod - myTolerance) {
839 Standard_Real aU = aLine.Location().X();
841 if (Abs(aU + aPeriod - aFUPar) < myTolerance ||
842 Abs(aU - aPeriod - aFUPar) < myTolerance) {
843 gp_Pnt2d aNewLoc(aFUPar, aLine.Location().Y());
845 aLine.SetLocation(aNewLoc);
846 } else if (Abs(aU + aPeriod - aLUPar) < myTolerance ||
847 Abs(aU - aPeriod - aLUPar) < myTolerance) {
848 gp_Pnt2d aNewLoc(aLUPar, aLine.Location().Y());
850 aLine.SetLocation(aNewLoc);
855 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
857 if (mySurface->IsVPeriodic()) {
858 myResult.VFrame(myCurve->FirstParameter(),
859 myCurve->LastParameter(),
860 mySurface->FirstVParameter(),
861 mySurface->VPeriod());
862 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 Begin
863 // Correct the V isoline in a periodical surface
864 // to be inside restriction boundaries.
865 if (myResult.GetType() == GeomAbs_Line) {
866 gp_Lin2d &aLine = (gp_Lin2d &) myResult.Line();
868 Standard_Real aPeriod = mySurface->VPeriod();
869 Standard_Real aFVPar = mySurface->FirstVParameter();
870 Standard_Real aLVPar = mySurface->LastVParameter();
872 // Check if the parametric range is lower then the period.
873 if (aLVPar - aFVPar < aPeriod - myTolerance) {
874 Standard_Real aV = aLine.Location().Y();
876 if (Abs(aV + aPeriod - aFVPar) < myTolerance ||
877 Abs(aV - aPeriod - aFVPar) < myTolerance) {
878 gp_Pnt2d aNewLoc(aLine.Location().X(), aFVPar);
880 aLine.SetLocation(aNewLoc);
881 } else if (Abs(aV + aPeriod - aLVPar) < myTolerance ||
882 Abs(aV - aPeriod - aLVPar) < myTolerance) {
883 gp_Pnt2d aNewLoc(aLine.Location().X(), aLVPar);
885 aLine.SetLocation(aNewLoc);
890 // Modified by skv - Wed Aug 11 15:45:58 2004 OCC6272 End
895 //=======================================================================
896 //function : GetSurface
898 //=======================================================================
900 const Handle(Adaptor3d_HSurface)& ProjLib_ProjectedCurve::GetSurface() const
906 //=======================================================================
907 //function : GetCurve
909 //=======================================================================
911 const Handle(Adaptor3d_HCurve)& ProjLib_ProjectedCurve::GetCurve() const
917 //=======================================================================
918 //function : GetTolerance
920 //=======================================================================
922 Standard_Real ProjLib_ProjectedCurve::GetTolerance() const
928 //=======================================================================
929 //function : FirstParameter
931 //=======================================================================
933 Standard_Real ProjLib_ProjectedCurve::FirstParameter() const
935 return myCurve->FirstParameter();
939 //=======================================================================
940 //function : LastParameter
942 //=======================================================================
944 Standard_Real ProjLib_ProjectedCurve::LastParameter() const
946 return myCurve->LastParameter();
950 //=======================================================================
951 //function : Continuity
953 //=======================================================================
955 GeomAbs_Shape ProjLib_ProjectedCurve::Continuity() const
957 Standard_NotImplemented::Raise("");
962 //=======================================================================
963 //function : NbIntervals
965 //=======================================================================
967 Standard_Integer ProjLib_ProjectedCurve::NbIntervals(const GeomAbs_Shape ) const
969 Standard_NotImplemented::Raise("");
974 //=======================================================================
975 //function : Intervals
977 //=======================================================================
979 //void ProjLib_ProjectedCurve::Intervals(TColStd_Array1OfReal& T,
980 void ProjLib_ProjectedCurve::Intervals(TColStd_Array1OfReal& ,
981 const GeomAbs_Shape ) const
983 Standard_NotImplemented::Raise("");
987 //=======================================================================
988 //function : IsClosed
990 //=======================================================================
992 Standard_Boolean ProjLib_ProjectedCurve::IsClosed() const
994 Standard_NotImplemented::Raise("");
995 return Standard_True;
999 //=======================================================================
1000 //function : IsPeriodic
1002 //=======================================================================
1004 Standard_Boolean ProjLib_ProjectedCurve::IsPeriodic() const
1006 return myResult.IsPeriodic();
1010 //=======================================================================
1013 //=======================================================================
1015 Standard_Real ProjLib_ProjectedCurve::Period() const
1017 Standard_NotImplemented::Raise("");
1022 //=======================================================================
1025 //=======================================================================
1027 gp_Pnt2d ProjLib_ProjectedCurve::Value(const Standard_Real ) const
1029 Standard_NotImplemented::Raise("");
1030 return gp_Pnt2d(0.,0.);
1034 //=======================================================================
1037 //=======================================================================
1039 void ProjLib_ProjectedCurve::D0(const Standard_Real , gp_Pnt2d& ) const
1041 Standard_NotImplemented::Raise("");
1045 //=======================================================================
1048 //=======================================================================
1050 void ProjLib_ProjectedCurve::D1(const Standard_Real ,
1054 Standard_NotImplemented::Raise("");
1058 //=======================================================================
1061 //=======================================================================
1063 void ProjLib_ProjectedCurve::D2(const Standard_Real ,
1068 Standard_NotImplemented::Raise("");
1072 //=======================================================================
1075 //=======================================================================
1077 void ProjLib_ProjectedCurve::D3(const Standard_Real,
1083 Standard_NotImplemented::Raise("");
1087 //=======================================================================
1090 //=======================================================================
1092 gp_Vec2d ProjLib_ProjectedCurve::DN(const Standard_Real,
1093 const Standard_Integer) const
1095 Standard_NotImplemented::Raise("");
1096 return gp_Vec2d(0.,0.);
1100 //=======================================================================
1101 //function : Resolution
1103 //=======================================================================
1105 Standard_Real ProjLib_ProjectedCurve::Resolution(const Standard_Real) const
1107 Standard_NotImplemented::Raise("");
1112 //=======================================================================
1113 //function : GetType
1115 //=======================================================================
1117 GeomAbs_CurveType ProjLib_ProjectedCurve::GetType() const
1119 return myResult.GetType();
1123 //=======================================================================
1126 //=======================================================================
1128 gp_Lin2d ProjLib_ProjectedCurve::Line() const
1130 return myResult.Line();
1134 //=======================================================================
1137 //=======================================================================
1139 gp_Circ2d ProjLib_ProjectedCurve::Circle() const
1141 return myResult.Circle();
1145 //=======================================================================
1146 //function : Ellipse
1148 //=======================================================================
1150 gp_Elips2d ProjLib_ProjectedCurve::Ellipse() const
1152 return myResult.Ellipse();
1156 //=======================================================================
1157 //function : Hyperbola
1159 //=======================================================================
1161 gp_Hypr2d ProjLib_ProjectedCurve::Hyperbola() const
1163 return myResult.Hyperbola();
1167 //=======================================================================
1168 //function : Parabola
1170 //=======================================================================
1172 gp_Parab2d ProjLib_ProjectedCurve::Parabola() const
1174 return myResult.Parabola();
1179 //=======================================================================
1182 //=======================================================================
1184 Standard_Integer ProjLib_ProjectedCurve::Degree() const
1186 Standard_NoSuchObject_Raise_if
1187 ( (GetType() != GeomAbs_BSplineCurve) &&
1188 (GetType() != GeomAbs_BezierCurve),
1189 "ProjLib_ProjectedCurve:Degree");
1190 if (GetType() == GeomAbs_BSplineCurve) {
1191 return myResult.BSpline()->Degree();
1193 else if (GetType() == GeomAbs_BezierCurve) {
1194 return myResult.Bezier()->Degree();
1201 //=======================================================================
1202 //function : IsRational
1204 //=======================================================================
1206 Standard_Boolean ProjLib_ProjectedCurve::IsRational() const
1208 Standard_NoSuchObject_Raise_if
1209 ( (GetType() != GeomAbs_BSplineCurve) &&
1210 (GetType() != GeomAbs_BezierCurve),
1211 "ProjLib_ProjectedCurve:IsRational");
1212 if (GetType() == GeomAbs_BSplineCurve) {
1213 return myResult.BSpline()->IsRational();
1215 else if (GetType() == GeomAbs_BezierCurve) {
1216 return myResult.Bezier()->IsRational();
1219 return Standard_False;
1222 //=======================================================================
1223 //function : NbPoles
1225 //=======================================================================
1227 Standard_Integer ProjLib_ProjectedCurve::NbPoles() const
1229 Standard_NoSuchObject_Raise_if
1230 ( (GetType() != GeomAbs_BSplineCurve) &&
1231 (GetType() != GeomAbs_BezierCurve)
1232 ,"ProjLib_ProjectedCurve:NbPoles" );
1233 if (GetType() == GeomAbs_BSplineCurve) {
1234 return myResult.BSpline()->NbPoles();
1236 else if (GetType() == GeomAbs_BezierCurve) {
1237 return myResult.Bezier()->NbPoles();
1244 //=======================================================================
1245 //function : NbKnots
1247 //=======================================================================
1249 Standard_Integer ProjLib_ProjectedCurve::NbKnots() const
1251 Standard_NoSuchObject_Raise_if ( GetType() != GeomAbs_BSplineCurve,
1252 "ProjLib_ProjectedCurve:NbKnots");
1253 return myResult.BSpline()->NbKnots();
1256 //=======================================================================
1259 //=======================================================================
1261 Handle(Geom2d_BezierCurve) ProjLib_ProjectedCurve::Bezier() const
1263 return myResult.Bezier() ;
1266 //=======================================================================
1267 //function : BSpline
1269 //=======================================================================
1271 Handle(Geom2d_BSplineCurve) ProjLib_ProjectedCurve::BSpline() const
1273 return myResult.BSpline() ;
1275 //=======================================================================
1278 //=======================================================================
1280 Handle(Adaptor2d_HCurve2d) ProjLib_ProjectedCurve::Trim
1281 //(const Standard_Real First,
1282 // const Standard_Real Last,
1283 // const Standard_Real Tolerance) const
1284 (const Standard_Real ,
1285 const Standard_Real ,
1286 const Standard_Real ) const
1288 Standard_NotImplemented::Raise("");