1 // File: GeomAdaptor_Curve.cxx
2 // Created: Thu Apr 29 11:54:32 1993
3 // Author: Bruno DUMORTIER
4 // Copyright: OPEN CASCADE 1993
6 // 20/02/97 : PMN -> Positionement local sur BSpline (PRO6902)
7 // 10/07/97 : PMN -> Pas de calcul de resolution dans Nb(Intervals)(PRO9248)
8 // 20/10/97 : RBV -> traitement des offset curves
10 #define No_Standard_RangeError
11 #define No_Standard_OutOfRange
13 #include <GeomAdaptor_Curve.ixx>
15 #include <GeomAdaptor_HCurve.hxx>
16 #include <Adaptor3d_HCurve.hxx>
17 #include <BSplCLib.hxx>
18 #include <GeomAbs_Shape.hxx>
19 #include <TColgp_Array1OfPnt.hxx>
20 #include <TColStd_Array1OfReal.hxx>
21 #include <TColStd_Array1OfInteger.hxx>
22 #include <TColStd_HArray1OfInteger.hxx>
23 #include <Precision.hxx>
24 #include <Geom_TrimmedCurve.hxx>
25 #include <Geom_Circle.hxx>
26 #include <Geom_Line.hxx>
27 #include <Geom_TrimmedCurve.hxx>
28 #include <Geom_BezierCurve.hxx>
29 #include <Geom_BSplineCurve.hxx>
30 #include <Geom_Ellipse.hxx>
31 #include <Geom_Parabola.hxx>
32 #include <Geom_Hyperbola.hxx>
33 //#include <GeomConvert_BSplineCurveKnotSplitting.hxx>
35 #include <Standard_OutOfRange.hxx>
36 #include <Standard_NoSuchObject.hxx>
37 #include <Standard_NullObject.hxx>
38 #include <Standard_NotImplemented.hxx>
39 #include <Geom_OffsetCurve.hxx>
41 #define myBspl (*((Handle(Geom_BSplineCurve)*)&myCurve))
42 #define PosTol Precision::PConfusion()/2
44 //=======================================================================
45 //function : LocalContinuity
46 //purpose : Computes the Continuity of a BSplineCurve
47 // between the parameters U1 and U2
48 // The continuity is C(d-m)
50 // m = max multiplicity of the Knots between U1 and U2
51 //=======================================================================
53 GeomAbs_Shape GeomAdaptor_Curve::LocalContinuity(const Standard_Real U1,
54 const Standard_Real U2)
57 Standard_NoSuchObject_Raise_if(myTypeCurve!=GeomAbs_BSplineCurve," ");
58 Standard_Integer Nb = myBspl->NbKnots();
59 Standard_Integer Index1 = 0;
60 Standard_Integer Index2 = 0;
61 Standard_Real newFirst, newLast;
62 TColStd_Array1OfReal TK(1,Nb);
63 TColStd_Array1OfInteger TM(1,Nb);
65 myBspl->Multiplicities(TM);
66 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,U1,myBspl->IsPeriodic(),
67 1,Nb,Index1,newFirst);
68 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,U2,myBspl->IsPeriodic(),
70 if ( Abs(newFirst-TK(Index1+1))<Precision::PConfusion()) {
71 if (Index1 < Nb) Index1++;
73 if ( Abs(newLast-TK(Index2))<Precision::PConfusion())
75 Standard_Integer MultMax;
76 // attention aux courbes peridiques.
77 if ( (myBspl->IsPeriodic()) && (Index1 == Nb) )
80 if ( Index2 - Index1 <= 0) {
81 MultMax = 100; // CN entre 2 Noeuds consecutifs
84 MultMax = TM(Index1+1);
85 for(Standard_Integer i = Index1+1;i<=Index2;i++) {
86 if ( TM(i)>MultMax) MultMax=TM(i);
88 MultMax = myBspl->Degree() - MultMax;
93 else if ( MultMax == 1) {
96 else if ( MultMax == 2) {
99 else if ( MultMax == 3) {
108 //=======================================================================
111 //=======================================================================
113 void GeomAdaptor_Curve::load(const Handle(Geom_Curve)& C,
114 const Standard_Real UFirst,
115 const Standard_Real ULast)
123 const Handle(Standard_Type)& TheType = C->DynamicType();
124 if ( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) {
125 Load((*((Handle(Geom_TrimmedCurve)*)&C))->BasisCurve(),UFirst,ULast);
127 else if ( TheType == STANDARD_TYPE(Geom_Circle)) {
128 myTypeCurve = GeomAbs_Circle;
130 else if ( TheType ==STANDARD_TYPE(Geom_Line)) {
131 myTypeCurve = GeomAbs_Line;
133 else if ( TheType == STANDARD_TYPE(Geom_Ellipse)) {
134 myTypeCurve = GeomAbs_Ellipse;
136 else if ( TheType == STANDARD_TYPE(Geom_Parabola)) {
137 myTypeCurve = GeomAbs_Parabola;
139 else if ( TheType == STANDARD_TYPE(Geom_Hyperbola)) {
140 myTypeCurve = GeomAbs_Hyperbola;
142 else if ( TheType == STANDARD_TYPE(Geom_BezierCurve)) {
143 myTypeCurve = GeomAbs_BezierCurve;
145 else if ( TheType == STANDARD_TYPE(Geom_BSplineCurve)) {
146 myTypeCurve = GeomAbs_BSplineCurve;
149 myTypeCurve = GeomAbs_OtherCurve;
155 // -- Global methods - Apply to the whole curve.
158 //=======================================================================
159 //function : Continuity
161 //=======================================================================
163 GeomAbs_Shape GeomAdaptor_Curve::Continuity() const
165 if (myTypeCurve == GeomAbs_BSplineCurve)
166 return LocalContinuity(myFirst, myLast);
168 if (myCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve)))
170 const GeomAbs_Shape S =
171 (*((Handle(Geom_OffsetCurve)*)&myCurve))->BasisCurve()->Continuity();
174 case GeomAbs_CN: return GeomAbs_CN;
175 case GeomAbs_C3: return GeomAbs_C2;
176 case GeomAbs_C2: return GeomAbs_C1;
177 case GeomAbs_C1: return GeomAbs_C0;
179 Standard_NoSuchObject::Raise("GeomAdaptor_Curve::Continuity");
182 else if (myTypeCurve == GeomAbs_OtherCurve) {
183 Standard_NoSuchObject::Raise("GeomAdaptor_Curve::Contunuity");
189 //=======================================================================
190 //function : NbIntervals
192 //=======================================================================
194 Standard_Integer GeomAdaptor_Curve::NbIntervals(const GeomAbs_Shape S)
196 Standard_Integer myNbIntervals = 1;
197 Standard_Integer NbSplit;
198 if (myTypeCurve == GeomAbs_BSplineCurve) {
199 Standard_Integer FirstIndex = myBspl->FirstUKnotIndex();
200 Standard_Integer LastIndex = myBspl->LastUKnotIndex();
201 TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
202 if ( S > Continuity()) {
203 Standard_Integer Cont;
207 Standard_DomainError::Raise("GeomAdaptor_Curve::NbIntervals");
217 if ( S == GeomAbs_C1) Cont = 1;
218 else if ( S == GeomAbs_C2) Cont = 2;
219 else if ( S == GeomAbs_C3) Cont = 3;
220 else Cont = myBspl->Degree();
221 Standard_Integer FirstIndex = myBspl->FirstUKnotIndex();
222 Standard_Integer LastIndex = myBspl->LastUKnotIndex();
223 Standard_Integer Degree = myBspl->Degree();
224 Standard_Integer NbKnots = myBspl->NbKnots();
225 TColStd_Array1OfInteger Mults (1, NbKnots);
226 myBspl->Multiplicities (Mults);
228 Standard_Integer Index = FirstIndex;
229 Inter (NbSplit) = Index;
232 while (Index < LastIndex)
234 if (Degree - Mults (Index) < Cont)
236 Inter (NbSplit) = Index;
241 Inter (NbSplit) = Index;
243 Standard_Integer NbInt = NbSplit-1;
245 Standard_Integer Nb = myBspl->NbKnots();
246 Standard_Integer Index1 = 0;
247 Standard_Integer Index2 = 0;
248 Standard_Real newFirst, newLast;
249 TColStd_Array1OfReal TK(1,Nb);
250 TColStd_Array1OfInteger TM(1,Nb);
252 myBspl->Multiplicities(TM);
253 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myFirst,
254 myBspl->IsPeriodic(),
255 1,Nb,Index1,newFirst);
256 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myLast,
257 myBspl->IsPeriodic(),
258 1,Nb,Index2,newLast);
260 // On decale eventuellement les indices
261 // On utilise une "petite" tolerance, la resolution ne doit
262 // servir que pour les tres longue courbes....(PRO9248)
263 Standard_Real Eps = Min(Resolution(Precision::Confusion()),
264 Precision::PConfusion());
265 if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
266 if ( newLast-TK(Index2)> Eps) Index2++;
269 for ( Standard_Integer i=1; i<=NbInt; i++)
270 if (Inter(i)>Index1 && Inter(i)<Index2) myNbIntervals++;
277 else if (myCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))){
278 GeomAbs_Shape BaseS=GeomAbs_C0;
282 Standard_DomainError::Raise("GeomAdaptor_Curve::NbIntervals");
284 case GeomAbs_C0: BaseS = GeomAbs_C1; break;
285 case GeomAbs_C1: BaseS = GeomAbs_C2; break;
286 case GeomAbs_C2: BaseS = GeomAbs_C3; break;
287 default: BaseS = GeomAbs_CN;
290 ((*((Handle(Geom_OffsetCurve)*)&myCurve))->BasisCurve());
291 // akm 05/04/02 (OCC278) If our curve is trimmed we must recalculate
292 // the number of intervals obtained from the basis to
293 // vvv reflect parameter bounds
294 Standard_Integer iNbBasisInt = C.NbIntervals(BaseS), iInt;
297 TColStd_Array1OfReal rdfInter(1,1+iNbBasisInt);
298 C.Intervals(rdfInter,BaseS);
299 for (iInt=1; iInt<=iNbBasisInt; iInt++)
300 if (rdfInter(iInt)>myFirst && rdfInter(iInt)<myLast)
305 return myNbIntervals;
308 //=======================================================================
309 //function : Intervals
311 //=======================================================================
313 void GeomAdaptor_Curve::Intervals(TColStd_Array1OfReal& T,
314 const GeomAbs_Shape S )
316 Standard_Integer myNbIntervals = 1;
317 Standard_Integer NbSplit;
319 if (myTypeCurve == GeomAbs_BSplineCurve)
321 Standard_Integer FirstIndex = myBspl->FirstUKnotIndex();
322 Standard_Integer LastIndex = myBspl->LastUKnotIndex();
323 TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
325 if ( S > Continuity()) {
326 Standard_Integer Cont;
330 Standard_DomainError::Raise("Geom2dAdaptor_Curve::NbIntervals");
340 if ( S == GeomAbs_C1) Cont = 1;
341 else if ( S == GeomAbs_C2) Cont = 2;
342 else if ( S == GeomAbs_C3) Cont = 3;
343 else Cont = myBspl->Degree();
344 Standard_Integer FirstIndex = myBspl->FirstUKnotIndex();
345 Standard_Integer LastIndex = myBspl->LastUKnotIndex();
346 Standard_Integer Degree = myBspl->Degree();
347 Standard_Integer NbKnots = myBspl->NbKnots();
348 TColStd_Array1OfInteger Mults (1, NbKnots);
349 myBspl->Multiplicities (Mults);
351 Standard_Integer Index = FirstIndex;
352 Inter (NbSplit) = Index;
355 while (Index < LastIndex)
357 if (Degree - Mults (Index) < Cont)
359 Inter (NbSplit) = Index;
364 Inter (NbSplit) = Index;
365 Standard_Integer NbInt = NbSplit-1;
366 // GeomConvert_BSplineCurveKnotSplitting Convector(myBspl, Cont);
367 // Standard_Integer NbInt = Convector.NbSplits()-1;
368 // TColStd_Array1OfInteger Inter(1,NbInt+1);
369 // Convector.Splitting( Inter);
371 Standard_Integer Nb = myBspl->NbKnots();
372 Standard_Integer Index1 = 0;
373 Standard_Integer Index2 = 0;
374 Standard_Real newFirst, newLast;
375 TColStd_Array1OfReal TK(1,Nb);
376 TColStd_Array1OfInteger TM(1,Nb);
378 myBspl->Multiplicities(TM);
379 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myFirst,
380 myBspl->IsPeriodic(),
381 1,Nb,Index1,newFirst);
382 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myLast,
383 myBspl->IsPeriodic(),
384 1,Nb,Index2,newLast);
385 // On decale eventuellement les indices
386 // On utilise une "petite" tolerance, la resolution ne doit
387 // servir que pour les tres longue courbes....(PRO9248)
388 Standard_Real Eps = Min(Resolution(Precision::Confusion()),
389 Precision::PConfusion());
390 if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
391 if ( newLast-TK(Index2)> Eps) Index2++;
395 for ( Standard_Integer i=1; i<=NbInt; i++) {
396 if (Inter(i) > Index1 && Inter(i)<Index2 ) {
398 Inter(myNbIntervals) = Inter(i);
401 Inter(myNbIntervals+1) = Index2;
403 for (Standard_Integer I=1;I<=myNbIntervals+1;I++) {
412 else if (myCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))){
413 GeomAbs_Shape BaseS=GeomAbs_C0;
417 Standard_DomainError::Raise("GeomAdaptor_Curve::NbIntervals");
419 case GeomAbs_C0: BaseS = GeomAbs_C1; break;
420 case GeomAbs_C1: BaseS = GeomAbs_C2; break;
421 case GeomAbs_C2: BaseS = GeomAbs_C3; break;
422 default: BaseS = GeomAbs_CN;
425 ((*((Handle(Geom_OffsetCurve)*)&myCurve))->BasisCurve());
426 // akm 05/04/02 (OCC278) If our curve is trimmed we must recalculate
427 // the array of intervals obtained from the basis to
428 // vvv reflect parameter bounds
429 Standard_Integer iNbBasisInt = C.NbIntervals(BaseS), iInt;
432 TColStd_Array1OfReal rdfInter(1,1+iNbBasisInt);
433 C.Intervals(rdfInter,BaseS);
434 for (iInt=1; iInt<=iNbBasisInt; iInt++)
435 if (rdfInter(iInt)>myFirst && rdfInter(iInt)<myLast)
436 T(++myNbIntervals)=rdfInter(iInt);
438 // old - myNbIntervals = C.NbIntervals(BaseS);
439 // old - C.Intervals(T, BaseS);
443 T( T.Lower() ) = myFirst;
444 T( T.Lower() + myNbIntervals ) = myLast;
447 //=======================================================================
450 //=======================================================================
452 Handle(Adaptor3d_HCurve) GeomAdaptor_Curve::Trim(const Standard_Real First,
453 const Standard_Real Last,
454 const Standard_Real /*Tol*/) const
456 return Handle(GeomAdaptor_HCurve)(new GeomAdaptor_HCurve(myCurve,First,Last));
460 //=======================================================================
461 //function : IsClosed
463 //=======================================================================
465 Standard_Boolean GeomAdaptor_Curve::IsClosed() const
467 if (!Precision::IsPositiveInfinite(myLast) &&
468 !Precision::IsNegativeInfinite(myFirst))
470 const gp_Pnt Pd = Value(myFirst);
471 const gp_Pnt Pf = Value(myLast);
472 return (Pd.Distance(Pf) <= Precision::Confusion());
474 return Standard_False;
477 //=======================================================================
478 //function : IsPeriodic
480 //=======================================================================
482 Standard_Boolean GeomAdaptor_Curve::IsPeriodic() const
484 return (myCurve->IsPeriodic()? IsClosed() : Standard_False);
487 //=======================================================================
490 //=======================================================================
492 Standard_Real GeomAdaptor_Curve::Period() const
494 return myCurve->LastParameter() - myCurve->FirstParameter();
497 //=======================================================================
500 //=======================================================================
502 gp_Pnt GeomAdaptor_Curve::Value(const Standard_Real U) const
504 if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
505 (U==myFirst || U==myLast) ) {
506 Standard_Integer Ideb, Ifin;
508 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
510 if (Ideb>=Ifin) Ifin = Ideb+1;
513 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
514 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
515 if (Ideb>=Ifin) Ideb = Ifin-1;
517 return myBspl->LocalValue(U, Ideb, Ifin);
519 return myCurve->Value(U);
522 //=======================================================================
525 //=======================================================================
527 void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const
529 if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
530 (U==myFirst || U==myLast) ) {
531 Standard_Integer Ideb, Ifin;
533 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
535 if (Ideb>=Ifin) Ifin = Ideb+1;
538 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
539 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
540 if (Ideb>=Ifin) Ideb = Ifin-1;
542 myBspl->LocalD0( U, Ideb, Ifin, P);
549 //=======================================================================
552 //=======================================================================
554 void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const
556 if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
557 (U==myFirst || U==myLast) ) {
558 Standard_Integer Ideb, Ifin;
560 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
562 if (Ideb>=Ifin) Ifin = Ideb+1;
565 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
566 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
567 if (Ideb>=Ifin) Ideb = Ifin-1;
569 myBspl->LocalD1( U, Ideb, Ifin, P, V);
572 myCurve->D1( U, P, V);
576 //=======================================================================
579 //=======================================================================
581 void GeomAdaptor_Curve::D2(const Standard_Real U,
582 gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
584 if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
585 (U==myFirst || U==myLast) ) {
586 Standard_Integer Ideb, Ifin;
588 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
590 if (Ideb>=Ifin) Ifin = Ideb+1;
593 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
594 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
595 if (Ideb>=Ifin) Ideb = Ifin-1;
597 myBspl->LocalD2( U, Ideb, Ifin, P, V1, V2);
600 myCurve->D2( U, P, V1, V2);
604 //=======================================================================
607 //=======================================================================
609 void GeomAdaptor_Curve::D3(const Standard_Real U,
610 gp_Pnt& P, gp_Vec& V1,
611 gp_Vec& V2, gp_Vec& V3) const
613 if ( (myTypeCurve == GeomAbs_BSplineCurve) &&
614 (U==myFirst || U==myLast) ) {
615 Standard_Integer Ideb, Ifin;
617 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
619 if (Ideb>=Ifin) Ifin = Ideb+1;
622 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
623 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
624 if (Ideb>=Ifin) Ideb = Ifin-1;
626 myBspl->LocalD3( U, Ideb, Ifin, P, V1, V2, V3);
629 myCurve->D3( U, P, V1, V2, V3);
633 //=======================================================================
636 //=======================================================================
638 gp_Vec GeomAdaptor_Curve::DN(const Standard_Real U,
639 const Standard_Integer N) const
641 if ( (myTypeCurve == GeomAbs_BSplineCurve) &&
642 (U==myFirst || U==myLast) ) {
643 Standard_Integer Ideb, Ifin;
645 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
647 if (Ideb>=Ifin) Ifin = Ideb+1;
650 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
651 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
652 if (Ideb>=Ifin) Ideb = Ifin-1;
654 return myBspl->LocalDN( U, Ideb, Ifin, N);
657 return myCurve->DN( U, N);
661 //=======================================================================
662 //function : Resolution
664 //=======================================================================
666 Standard_Real GeomAdaptor_Curve::Resolution(const Standard_Real R3D) const
668 switch ( myTypeCurve) {
671 case GeomAbs_Circle: {
672 Standard_Real R = (*((Handle(Geom_Circle)*)&myCurve))->Circ().Radius();
674 return 2*ASin(R3D/(2*R));
678 case GeomAbs_Ellipse: {
679 return R3D / (*((Handle(Geom_Ellipse)*)&myCurve))->MajorRadius();
681 case GeomAbs_BezierCurve: {
683 (*((Handle(Geom_BezierCurve)*)&myCurve))->Resolution(R3D,res);
686 case GeomAbs_BSplineCurve: {
688 (*((Handle(Geom_BSplineCurve)*)&myCurve))->Resolution(R3D,res);
692 return Precision::Parametric(R3D);
698 // -- The following methods must be called when GetType returned
699 // -- the corresponding type.
702 //=======================================================================
705 //=======================================================================
707 gp_Lin GeomAdaptor_Curve::Line() const
709 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Line, "");
710 return (*((Handle(Geom_Line)*)&myCurve))->Lin();
713 //=======================================================================
716 //=======================================================================
718 gp_Circ GeomAdaptor_Curve::Circle() const
720 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Circle, "");
721 return (*((Handle(Geom_Circle)*)&myCurve))->Circ();
724 //=======================================================================
727 //=======================================================================
729 gp_Elips GeomAdaptor_Curve::Ellipse() const
731 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Ellipse, "");
732 return (*((Handle(Geom_Ellipse)*)&myCurve))->Elips();
735 //=======================================================================
736 //function : Hyperbola
738 //=======================================================================
740 gp_Hypr GeomAdaptor_Curve::Hyperbola() const
742 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Hyperbola, "");
743 return (*((Handle(Geom_Hyperbola)*)&myCurve))->Hypr();
746 //=======================================================================
747 //function : Parabola
749 //=======================================================================
751 gp_Parab GeomAdaptor_Curve::Parabola() const
753 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Parabola, "");
754 return (*((Handle(Geom_Parabola)*)&myCurve))->Parab();
757 //=======================================================================
760 //=======================================================================
762 Standard_Integer GeomAdaptor_Curve::Degree() const
764 if (myTypeCurve == GeomAbs_BezierCurve)
765 return (*((Handle(Geom_BezierCurve)*)&myCurve))->Degree();
766 else if (myTypeCurve == GeomAbs_BSplineCurve)
767 return (*((Handle(Geom_BSplineCurve)*)&myCurve))->Degree();
769 Standard_NoSuchObject::Raise();
774 //=======================================================================
775 //function : IsRational
777 //=======================================================================
779 Standard_Boolean GeomAdaptor_Curve::IsRational() const {
780 switch( myTypeCurve) {
781 case GeomAbs_BSplineCurve:
782 return (*((Handle(Geom_BSplineCurve)*)&myCurve))->IsRational();
783 case GeomAbs_BezierCurve:
784 return (*((Handle(Geom_BezierCurve)*)&myCurve))->IsRational();
786 return Standard_False;
790 //=======================================================================
793 //=======================================================================
795 Standard_Integer GeomAdaptor_Curve::NbPoles() const
797 if (myTypeCurve == GeomAbs_BezierCurve)
798 return (*((Handle(Geom_BezierCurve)*)&myCurve))->NbPoles();
799 else if (myTypeCurve == GeomAbs_BSplineCurve)
800 return (*((Handle(Geom_BSplineCurve)*)&myCurve))->NbPoles();
802 Standard_NoSuchObject::Raise();
807 //=======================================================================
810 //=======================================================================
812 Standard_Integer GeomAdaptor_Curve::NbKnots() const
814 if ( myTypeCurve != GeomAbs_BSplineCurve)
815 Standard_NoSuchObject::Raise("GeomAdaptor_Curve::NbKnots");
816 return (*((Handle(Geom_BSplineCurve)*)&myCurve))->NbKnots();
819 //=======================================================================
822 //=======================================================================
824 Handle(Geom_BezierCurve) GeomAdaptor_Curve::Bezier() const
826 if ( myTypeCurve != GeomAbs_BezierCurve)
827 Standard_NoSuchObject::Raise("GeomAdaptor_Curve::Bezier");
828 return *((Handle(Geom_BezierCurve)*)&myCurve);
831 //=======================================================================
834 //=======================================================================
836 Handle(Geom_BSplineCurve) GeomAdaptor_Curve::BSpline() const
838 if ( myTypeCurve != GeomAbs_BSplineCurve)
839 Standard_NoSuchObject::Raise("GeomAdaptor_Curve::BSpline");
841 return *((Handle(Geom_BSplineCurve)*)&myCurve);