1 // File: Geom2dAdaptor_Curve.cxx
2 // Created: Fri Jun 4 10:39:27 1993
3 // Author: Bruno DUMORTIER
5 // 20/02/97 : PMN -> Positionement local sur BSpline (PRO6902)
6 // 10/07/97 : PMN -> Pas de calcul de resolution dans Nb(Intervals) (PRO9248)
7 // 20/10/97 : JPI -> traitement des offset curves
9 #define No_Standard_RangeError
10 #define No_Standard_OutOfRange
12 #include <Geom2dAdaptor_Curve.ixx>
13 #include <Geom2d_OffsetCurve.hxx>
14 #include <Geom2dAdaptor_HCurve.hxx>
15 #include <Adaptor2d_HCurve2d.hxx>
16 #include <BSplCLib.hxx>
17 #include <GeomAbs_Shape.hxx>
18 #include <TColgp_Array1OfPnt2d.hxx>
19 #include <TColStd_Array1OfReal.hxx>
20 #include <TColStd_Array1OfInteger.hxx>
21 #include <TColStd_HArray1OfInteger.hxx>
22 #include <Precision.hxx>
24 #include <Geom2d_TrimmedCurve.hxx>
25 #include <Geom2d_Circle.hxx>
26 #include <Geom2d_Line.hxx>
27 #include <Geom2d_TrimmedCurve.hxx>
28 #include <Geom2d_BezierCurve.hxx>
29 #include <Geom2d_BSplineCurve.hxx>
30 #include <Geom2d_Ellipse.hxx>
31 #include <Geom2d_Parabola.hxx>
32 #include <Geom2d_Hyperbola.hxx>
33 //#include <Geom2dConvert_BSplineCurveKnotSplitting.hxx>
35 #include <Standard_OutOfRange.hxx>
36 #include <Standard_NoSuchObject.hxx>
37 #include <Standard_NullObject.hxx>
38 #include <Standard_NotImplemented.hxx>
40 #define myBspl (*((Handle(Geom2d_BSplineCurve)*)&myCurve))
41 #define PosTol Precision::PConfusion()/2
43 //=======================================================================
44 //function : LocalContinuity
45 //purpose : Computes the Continuity of a BSplineCurve
46 // between the parameters U1 and U2
47 // The continuity is C(d-m)
49 // m = max multiplicity of the Knots between U1 and U2
50 //=======================================================================
52 GeomAbs_Shape Geom2dAdaptor_Curve::LocalContinuity(const Standard_Real U1,
53 const Standard_Real U2)
56 Standard_NoSuchObject_Raise_if(myTypeCurve!=GeomAbs_BSplineCurve," ");
57 Standard_Integer Nb = myBspl->NbKnots();
58 Standard_Integer Index1 = 0;
59 Standard_Integer Index2 = 0;
60 Standard_Real newFirst, newLast;
61 TColStd_Array1OfReal TK(1,Nb);
62 TColStd_Array1OfInteger TM(1,Nb);
64 myBspl->Multiplicities(TM);
65 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,U1,myBspl->IsPeriodic(),
66 1,Nb,Index1,newFirst);
67 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,U2,myBspl->IsPeriodic(),
69 if ( Abs(newFirst-TK(Index1+1))<Precision::PConfusion()) {
70 if (Index1 < Nb)Index1++;
72 if ( Abs(newLast-TK(Index2))<Precision::PConfusion())
74 Standard_Integer MultMax;
75 // attention aux courbes peridiques.
76 if ( (myBspl->IsPeriodic()) && (Index1 == Nb) )
79 if ( Index2 - Index1 <= 0) {
80 MultMax = 100; // CN entre 2 Noeuds consecutifs
83 MultMax = TM(Index1+1);
84 for(Standard_Integer i = Index1+1;i<=Index2;i++) {
85 if ( TM(i)>MultMax) MultMax=TM(i);
87 MultMax = myBspl->Degree() - MultMax;
92 else if ( MultMax == 1) {
95 else if ( MultMax == 2) {
98 else if ( MultMax == 3) {
107 //=======================================================================
108 //function : Geom2dAdaptor_Curve
110 //=======================================================================
112 Geom2dAdaptor_Curve::Geom2dAdaptor_Curve()
113 : myTypeCurve(GeomAbs_OtherCurve),
119 //=======================================================================
120 //function : Geom2dAdaptor_Curve
122 //=======================================================================
124 Geom2dAdaptor_Curve::Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C)
129 //=======================================================================
130 //function : Geom2dAdaptor_Curve
132 //=======================================================================
134 Geom2dAdaptor_Curve::Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C,
135 const Standard_Real UFirst,
136 const Standard_Real ULast)
138 Load(C,UFirst,ULast);
142 //=======================================================================
145 //=======================================================================
147 void Geom2dAdaptor_Curve::load(const Handle(Geom2d_Curve)& C,
148 const Standard_Real UFirst,
149 const Standard_Real ULast)
157 Handle(Standard_Type) TheType = C->DynamicType();
158 if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
159 Load((*((Handle(Geom2d_TrimmedCurve)*)&C))->BasisCurve(),
162 else if ( TheType == STANDARD_TYPE(Geom2d_Circle)) {
163 myTypeCurve = GeomAbs_Circle;
165 else if ( TheType ==STANDARD_TYPE(Geom2d_Line)) {
166 myTypeCurve = GeomAbs_Line;
168 else if ( TheType == STANDARD_TYPE(Geom2d_Ellipse)) {
169 myTypeCurve = GeomAbs_Ellipse;
171 else if ( TheType == STANDARD_TYPE(Geom2d_Parabola)) {
172 myTypeCurve = GeomAbs_Parabola;
174 else if ( TheType == STANDARD_TYPE(Geom2d_Hyperbola)) {
175 myTypeCurve = GeomAbs_Hyperbola;
177 else if ( TheType == STANDARD_TYPE(Geom2d_BezierCurve)) {
178 myTypeCurve = GeomAbs_BezierCurve;
180 else if ( TheType == STANDARD_TYPE(Geom2d_BSplineCurve)) {
181 myTypeCurve = GeomAbs_BSplineCurve;
184 myTypeCurve = GeomAbs_OtherCurve;
190 // -- Global methods - Apply to the whole curve.
193 //=======================================================================
194 //function : Continuity
196 //=======================================================================
198 GeomAbs_Shape Geom2dAdaptor_Curve::Continuity() const
200 if (myTypeCurve == GeomAbs_BSplineCurve) {
201 return LocalContinuity(myFirst, myLast);
203 else if (myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))){
205 (*((Handle(Geom2d_OffsetCurve)*)&myCurve))->BasisCurve()->Continuity();
207 case GeomAbs_CN: return GeomAbs_CN;
208 case GeomAbs_C3: return GeomAbs_C2;
209 case GeomAbs_C2: return GeomAbs_C1;
210 case GeomAbs_C1: return GeomAbs_C0;
212 Standard_NoSuchObject::Raise("Geom2dAdaptor_Curve::Continuity");
216 else if (myTypeCurve == GeomAbs_OtherCurve) {
217 Standard_NoSuchObject::Raise("Geom2dAdaptor_Curve::Continuity");
227 //=======================================================================
228 //function : NbIntervals
230 //=======================================================================
232 Standard_Integer Geom2dAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const
234 Standard_Integer myNbIntervals = 1;
235 Standard_Integer NbSplit;
236 if (myTypeCurve == GeomAbs_BSplineCurve) {
237 Standard_Integer FirstIndex = myBspl->FirstUKnotIndex();
238 Standard_Integer LastIndex = myBspl->LastUKnotIndex();
239 TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
240 if ( S > Continuity()) {
241 Standard_Integer Cont;
245 Standard_DomainError::Raise("Geom2dAdaptor_Curve::NbIntervals");
255 if ( S == GeomAbs_C1) Cont = 1;
256 else if ( S == GeomAbs_C2) Cont = 2;
257 else if ( S == GeomAbs_C3) Cont = 3;
258 else Cont = myBspl->Degree();
259 Standard_Integer Degree = myBspl->Degree();
260 Standard_Integer NbKnots = myBspl->NbKnots();
261 TColStd_Array1OfInteger Mults (1, NbKnots);
262 myBspl->Multiplicities (Mults);
264 Standard_Integer Index = FirstIndex;
265 Inter (NbSplit) = Index;
268 while (Index < LastIndex)
270 if (Degree - Mults (Index) < Cont)
272 Inter (NbSplit) = Index;
277 Inter (NbSplit) = Index;
279 Standard_Integer NbInt = NbSplit-1;
281 Standard_Integer Nb = myBspl->NbKnots();
282 Standard_Integer Index1 = 0;
283 Standard_Integer Index2 = 0;
284 Standard_Real newFirst, newLast;
285 TColStd_Array1OfReal TK(1,Nb);
286 TColStd_Array1OfInteger TM(1,Nb);
288 myBspl->Multiplicities(TM);
289 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myFirst,
290 myBspl->IsPeriodic(),
291 1,Nb,Index1,newFirst);
292 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myLast,
293 myBspl->IsPeriodic(),
294 1,Nb,Index2,newLast);
296 // On decale eventuellement les indices
297 // On utilise une "petite" tolerance, la resolution ne doit
298 // servir que pour les tres longue courbes....(PRO9248)
299 Standard_Real Eps = Min(Resolution(Precision::Confusion()),
300 Precision::PConfusion());
301 if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
302 if ( newLast-TK(Index2)> Eps) Index2++;
305 for ( Standard_Integer i=1; i<=NbInt; i++)
306 if (Inter(i)>Index1 && Inter(i)<Index2) myNbIntervals++;
312 else if (myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))){
313 GeomAbs_Shape BaseS=GeomAbs_C0;
317 Standard_DomainError::Raise("GeomAdaptor_Curve::NbIntervals");
319 case GeomAbs_C0: BaseS = GeomAbs_C1; break;
320 case GeomAbs_C1: BaseS = GeomAbs_C2; break;
321 case GeomAbs_C2: BaseS = GeomAbs_C3; break;
322 default: BaseS = GeomAbs_CN;
324 Geom2dAdaptor_Curve C
325 ((*((Handle(Geom2d_OffsetCurve)*)&myCurve))->BasisCurve());
326 myNbIntervals = C.NbIntervals(BaseS);
329 return myNbIntervals;
332 //=======================================================================
333 //function : Intervals
335 //=======================================================================
337 void Geom2dAdaptor_Curve::Intervals(TColStd_Array1OfReal& T,
338 const GeomAbs_Shape S ) const
340 Standard_Integer myNbIntervals = 1;
341 Standard_Integer NbSplit;
342 if (myTypeCurve == GeomAbs_BSplineCurve) {
343 Standard_Integer FirstIndex = myBspl->FirstUKnotIndex();
344 Standard_Integer LastIndex = myBspl->LastUKnotIndex();
345 TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1);
346 if ( S > Continuity()) {
347 Standard_Integer Cont;
351 Standard_DomainError::Raise("Geom2dAdaptor_Curve::NbIntervals");
361 if ( S == GeomAbs_C1) Cont = 1;
362 else if ( S == GeomAbs_C2) Cont = 2;
363 else if ( S == GeomAbs_C3) Cont = 3;
364 else Cont = myBspl->Degree();
365 Standard_Integer Degree = myBspl->Degree();
366 Standard_Integer NbKnots = myBspl->NbKnots();
367 TColStd_Array1OfInteger Mults (1, NbKnots);
368 myBspl->Multiplicities (Mults);
370 Standard_Integer Index = FirstIndex;
371 Inter (NbSplit) = Index;
374 while (Index < LastIndex)
376 if (Degree - Mults (Index) < Cont)
378 Inter (NbSplit) = Index;
383 Inter (NbSplit) = Index;
384 Standard_Integer NbInt = NbSplit-1;
386 Standard_Integer Nb = myBspl->NbKnots();
387 Standard_Integer Index1 = 0;
388 Standard_Integer Index2 = 0;
389 Standard_Real newFirst, newLast;
390 TColStd_Array1OfReal TK(1,Nb);
391 TColStd_Array1OfInteger TM(1,Nb);
393 myBspl->Multiplicities(TM);
394 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myFirst,
395 myBspl->IsPeriodic(),
396 1,Nb,Index1,newFirst);
397 BSplCLib::LocateParameter(myBspl->Degree(),TK,TM,myLast,
398 myBspl->IsPeriodic(),
399 1,Nb,Index2,newLast);
402 // On decale eventuellement les indices
403 // On utilise une "petite" tolerance, la resolution ne doit
404 // servir que pour les tres longue courbes....(PRO9248)
405 Standard_Real Eps = Min(Resolution(Precision::Confusion()),
406 Precision::PConfusion());
407 if ( Abs(newFirst-TK(Index1+1))< Eps) Index1++;
408 if ( newLast-TK(Index2)> Eps) Index2++;
412 for ( Standard_Integer i=1; i<=NbInt; i++) {
413 if (Inter(i) > Index1 && Inter(i)<Index2 ) {
415 Inter(myNbIntervals) = Inter(i);
418 Inter(myNbIntervals+1) = Index2;
420 Standard_Integer ii = T.Lower() - 1;
421 for (Standard_Integer I=1;I<=myNbIntervals+1;I++) {
422 T(ii + I) = TK(Inter(I));
429 else if (myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))){
430 GeomAbs_Shape BaseS=GeomAbs_C0;
434 Standard_DomainError::Raise("GeomAdaptor_Curve::NbIntervals");
436 case GeomAbs_C0: BaseS = GeomAbs_C1; break;
437 case GeomAbs_C1: BaseS = GeomAbs_C2; break;
438 case GeomAbs_C2: BaseS = GeomAbs_C3; break;
439 default: BaseS = GeomAbs_CN;
441 Geom2dAdaptor_Curve C
442 ((*((Handle(Geom2d_OffsetCurve)*)&myCurve))->BasisCurve());
443 myNbIntervals = C.NbIntervals(BaseS);
444 C.Intervals(T, BaseS);
447 T( T.Lower() ) = myFirst;
448 T( T.Lower() + myNbIntervals ) = myLast;
451 //=======================================================================
454 //=======================================================================
456 Handle(Adaptor2d_HCurve2d) Geom2dAdaptor_Curve::Trim
457 (const Standard_Real First,
458 const Standard_Real Last,
459 // const Standard_Real Tol) const
460 const Standard_Real ) const
462 Handle(Geom2dAdaptor_HCurve) HE = new Geom2dAdaptor_HCurve(myCurve,First,Last);
467 //=======================================================================
468 //function : IsClosed
470 //=======================================================================
472 Standard_Boolean Geom2dAdaptor_Curve::IsClosed() const
474 if (!Precision::IsPositiveInfinite(myLast) &&
475 !Precision::IsNegativeInfinite(myFirst)) {
476 gp_Pnt2d Pd = Value(myFirst);
477 gp_Pnt2d Pf = Value(myLast);
478 return ( Pd.Distance(Pf) <= Precision::Confusion());
481 return Standard_False;
484 //=======================================================================
485 //function : IsPeriodic
487 //=======================================================================
489 Standard_Boolean Geom2dAdaptor_Curve::IsPeriodic() const
491 if (myCurve->IsPeriodic())
494 return Standard_False;
497 //=======================================================================
500 //=======================================================================
502 Standard_Real Geom2dAdaptor_Curve::Period() const
504 return myCurve->LastParameter() - myCurve->FirstParameter();
507 //=======================================================================
510 //=======================================================================
512 gp_Pnt2d Geom2dAdaptor_Curve::Value(const Standard_Real U) const
514 if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
515 (U==myFirst || U==myLast) ) {
516 Standard_Integer Ideb, Ifin;
518 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
520 if (Ideb>=Ifin) Ifin = Ideb+1;
523 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
524 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
525 if (Ideb>=Ifin) Ideb = Ifin-1;
527 return myBspl->LocalValue(U, Ideb, Ifin);
530 return myCurve->Value( U);
534 //=======================================================================
537 //=======================================================================
539 void Geom2dAdaptor_Curve::D0(const Standard_Real U, gp_Pnt2d& P) const
541 if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
542 (U==myFirst || U==myLast) ) {
543 Standard_Integer Ideb, Ifin;
545 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
547 if (Ideb>=Ifin) Ifin = Ideb+1;
550 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
551 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
552 if (Ideb>=Ifin) Ideb = Ifin-1;
554 myBspl->LocalD0( U, Ideb, Ifin, P);
561 //=======================================================================
564 //=======================================================================
566 void Geom2dAdaptor_Curve::D1(const Standard_Real U,
567 gp_Pnt2d& P, gp_Vec2d& V) const
569 if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
570 (U==myFirst || U==myLast) ) {
571 Standard_Integer Ideb, Ifin;
573 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
575 if (Ideb>=Ifin) Ifin = Ideb+1;
578 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
579 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
580 if (Ideb>=Ifin) Ideb = Ifin-1;
582 myBspl->LocalD1( U, Ideb, Ifin, P, V);
585 myCurve->D1( U, P, V);
589 //=======================================================================
592 //=======================================================================
594 void Geom2dAdaptor_Curve::D2(const Standard_Real U,
595 gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const
597 if ( (myTypeCurve == GeomAbs_BSplineCurve)&&
598 (U==myFirst || U==myLast) ) {
599 Standard_Integer Ideb, Ifin;
601 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
603 if (Ideb>=Ifin) Ifin = Ideb+1;
606 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
607 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
608 if (Ideb>=Ifin) Ideb = Ifin-1;
610 myBspl->LocalD2( U, Ideb, Ifin, P, V1, V2);
613 myCurve->D2( U, P, V1, V2);
617 //=======================================================================
620 //=======================================================================
622 void Geom2dAdaptor_Curve::D3(const Standard_Real U,
623 gp_Pnt2d& P, gp_Vec2d& V1,
624 gp_Vec2d& V2, gp_Vec2d& V3) const
626 if ( (myTypeCurve == GeomAbs_BSplineCurve) &&
627 (U==myFirst || U==myLast) ) {
628 Standard_Integer Ideb, Ifin;
630 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
632 if (Ideb>=Ifin) Ifin = Ideb+1;
635 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
636 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
637 if (Ideb>=Ifin) Ideb = Ifin-1;
639 myBspl->LocalD3( U, Ideb, Ifin, P, V1, V2, V3);
642 myCurve->D3( U, P, V1, V2, V3);
646 //=======================================================================
649 //=======================================================================
651 gp_Vec2d Geom2dAdaptor_Curve::DN(const Standard_Real U,
652 const Standard_Integer N) const
654 if ( (myTypeCurve == GeomAbs_BSplineCurve) &&
655 (U==myFirst || U==myLast) ) {
656 Standard_Integer Ideb, Ifin;
658 myBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
660 if (Ideb>=Ifin) Ifin = Ideb+1;
663 myBspl->LocateU(myLast, PosTol, Ideb, Ifin);
664 if (Ifin>myBspl->NbKnots()) Ifin = myBspl->NbKnots();
665 if (Ideb>=Ifin) Ideb = Ifin-1;
667 return myBspl->LocalDN( U, Ideb, Ifin, N);
670 return myCurve->DN( U, N);
674 //=======================================================================
675 //function : Resolution
677 //=======================================================================
679 Standard_Real Geom2dAdaptor_Curve::Resolution(const Standard_Real Ruv) const {
680 switch ( myTypeCurve) {
683 case GeomAbs_Circle: {
684 Standard_Real R = (*((Handle(Geom2d_Circle)*)&myCurve))->Circ2d().Radius();
686 return 2*ASin(Ruv/(2*R));
690 case GeomAbs_Ellipse: {
691 return Ruv / (*((Handle(Geom2d_Ellipse)*)&myCurve))->MajorRadius();
693 case GeomAbs_BezierCurve: {
695 (*((Handle(Geom2d_BezierCurve)*)&myCurve))->Resolution(Ruv,res);
698 case GeomAbs_BSplineCurve: {
700 (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->Resolution(Ruv,res);
704 return Precision::Parametric(Ruv);
710 // -- The following methods must be called when GetType returned
711 // -- the corresponding type.
714 //=======================================================================
717 //=======================================================================
719 gp_Lin2d Geom2dAdaptor_Curve::Line() const
721 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Line, "");
722 return (*((Handle(Geom2d_Line)*)&myCurve))->Lin2d();
725 //=======================================================================
728 //=======================================================================
730 gp_Circ2d Geom2dAdaptor_Curve::Circle() const
732 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Circle, "");
733 return (*((Handle(Geom2d_Circle)*)&myCurve))->Circ2d();
736 //=======================================================================
739 //=======================================================================
741 gp_Elips2d Geom2dAdaptor_Curve::Ellipse() const
743 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Ellipse, "");
744 return (*((Handle(Geom2d_Ellipse)*)&myCurve))->Elips2d();
747 //=======================================================================
748 //function : Hyperbola
750 //=======================================================================
752 gp_Hypr2d Geom2dAdaptor_Curve::Hyperbola() const
754 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Hyperbola, "");
755 return (*((Handle(Geom2d_Hyperbola)*)&myCurve))->Hypr2d();
758 //=======================================================================
759 //function : Parabola
761 //=======================================================================
763 gp_Parab2d Geom2dAdaptor_Curve::Parabola() const
765 Standard_NoSuchObject_Raise_if(myTypeCurve != GeomAbs_Parabola, "");
766 return (*((Handle(Geom2d_Parabola)*)&myCurve))->Parab2d();
769 //=======================================================================
772 //=======================================================================
774 Standard_Integer Geom2dAdaptor_Curve::Degree() const
776 if (myTypeCurve == GeomAbs_BezierCurve)
777 return (*((Handle(Geom2d_BezierCurve)*)&myCurve))->Degree();
778 else if (myTypeCurve == GeomAbs_BSplineCurve)
779 return (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->Degree();
781 Standard_NoSuchObject::Raise();
786 //=======================================================================
787 //function : IsRational
789 //=======================================================================
791 Standard_Boolean Geom2dAdaptor_Curve::IsRational() const {
792 switch( myTypeCurve) {
793 case GeomAbs_BSplineCurve:
794 return (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->IsRational();
795 case GeomAbs_BezierCurve:
796 return (*((Handle(Geom2d_BezierCurve)*)&myCurve))->IsRational();
798 return Standard_False;
802 //=======================================================================
805 //=======================================================================
807 Standard_Integer Geom2dAdaptor_Curve::NbPoles() const
809 if (myTypeCurve == GeomAbs_BezierCurve)
810 return (*((Handle(Geom2d_BezierCurve)*)&myCurve))->NbPoles();
811 else if (myTypeCurve == GeomAbs_BSplineCurve)
812 return (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->NbPoles();
814 Standard_NoSuchObject::Raise();
819 //=======================================================================
822 //=======================================================================
824 Standard_Integer Geom2dAdaptor_Curve::NbKnots() const {
825 if ( myTypeCurve != GeomAbs_BSplineCurve)
826 Standard_NoSuchObject::Raise("Geom2dAdaptor_Curve::NbKnots");
827 return (*((Handle(Geom2d_BSplineCurve)*)&myCurve))->NbKnots();
831 //=======================================================================
834 //=======================================================================
836 Handle(Geom2d_BezierCurve) Geom2dAdaptor_Curve::Bezier() const
838 return *((Handle(Geom2d_BezierCurve)*)&myCurve);
841 //=======================================================================
844 //=======================================================================
846 Handle(Geom2d_BSplineCurve) Geom2dAdaptor_Curve::BSpline() const
848 return *((Handle(Geom2d_BSplineCurve)*)&myCurve);