0024060: Wrong result done by general fuse algorithm.
[occt.git] / src / Adaptor3d / Adaptor3d_IsoCurve.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <Adaptor3d_IsoCurve.ixx>
19
20#include <Adaptor3d_HIsoCurve.hxx>
21#include <Adaptor3d_HSurfaceOfRevolution.hxx>
22#include <Geom_BezierSurface.hxx>
23#include <Geom_BSplineSurface.hxx>
24#include <GeomAbs_SurfaceType.hxx>
25#include <Standard_NoSuchObject.hxx>
26#include <Standard_NotImplemented.hxx>
27#include <gp_Ax2.hxx>
28#include <ElCLib.hxx>
29#include <ElSLib.hxx>
30#include <BSplCLib.hxx>
31#include <BSplSLib.hxx>
32#include <Precision.hxx>
33#include <TColgp_Array1OfPnt.hxx>
34#include <TColgp_Array2OfPnt.hxx>
35
36
37//=======================================================================
38//function : Adaptor3d_IsoCurve
39//purpose :
40//=======================================================================
41
42Adaptor3d_IsoCurve::Adaptor3d_IsoCurve() :
43 myIso(GeomAbs_NoneIso)
44{}
45
46//=======================================================================
47//function : Adaptor3d_IsoCurve
48//purpose :
49//=======================================================================
50
51Adaptor3d_IsoCurve::Adaptor3d_IsoCurve(const Handle(Adaptor3d_HSurface)& S)
52{
53 Load(S);
54}
55
56//=======================================================================
57//function : Adaptor3d_IsoCurve
58//purpose :
59//=======================================================================
60
61Adaptor3d_IsoCurve::Adaptor3d_IsoCurve(const Handle(Adaptor3d_HSurface)& S,
62 const GeomAbs_IsoType Iso,
63 const Standard_Real Param)
64{
65 Load(S);
66 Load(Iso,Param);
67}
68
69//=======================================================================
70//function : Adaptor3d_IsoCurve
71//purpose :
72//=======================================================================
73
74Adaptor3d_IsoCurve::Adaptor3d_IsoCurve(const Handle(Adaptor3d_HSurface)& S,
75 const GeomAbs_IsoType Iso,
76 const Standard_Real Param,
77 const Standard_Real WFirst,
78 const Standard_Real WLast)
79{
80 Load(S);
81 Load(Iso,Param,WFirst,WLast);
82}
83
84//=======================================================================
85//function : Load
86//purpose :
87//=======================================================================
88
89void Adaptor3d_IsoCurve::Load(const Handle(Adaptor3d_HSurface)& S )
90{
91 mySurface = S;
92 myIso = GeomAbs_NoneIso;
93}
94
95//=======================================================================
96//function : Load
97//purpose :
98//=======================================================================
99
100void Adaptor3d_IsoCurve::Load(const GeomAbs_IsoType Iso,
101 const Standard_Real Param)
102{
103 switch (Iso) {
104
105 case GeomAbs_IsoU:
106 Load(Iso,Param,
107 mySurface->FirstVParameter(),
108 mySurface->LastVParameter());
109 break;
110
111 case GeomAbs_IsoV:
112 Load(Iso,Param,
113 mySurface->FirstUParameter(),
114 mySurface->LastUParameter());
115 break;
116
117 case GeomAbs_NoneIso:
118 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
119 break;
120 }
121}
122
123//=======================================================================
124//function : Load
125//purpose :
126//=======================================================================
127
128void Adaptor3d_IsoCurve::Load(const GeomAbs_IsoType Iso,
129 const Standard_Real Param,
130 const Standard_Real WFirst,
131 const Standard_Real WLast)
132{
133 myIso =Iso;
134 myParameter = Param;
135 myFirst = WFirst;
136 myLast = WLast;
137
138
139 if (myIso == GeomAbs_IsoU) {
140 myFirst = Max(myFirst, mySurface->FirstVParameter());
141 myLast = Min(myLast, mySurface->LastVParameter());
142 }
143 else {
144 myFirst = Max(myFirst, mySurface->FirstUParameter());
145 myLast = Min(myLast, mySurface->LastUParameter());
146 }
147
148// Adjust the parameters on periodic surfaces
149
150 Standard_Real dummy = myParameter;
151
152 if (mySurface->IsUPeriodic()) {
153
154 if (myIso == GeomAbs_IsoU) {
155 ElCLib::AdjustPeriodic
156 (mySurface->FirstUParameter(),
157 mySurface->FirstUParameter()+
158 mySurface->UPeriod(),
159 mySurface->UResolution(Precision::Confusion()),
160 myParameter,dummy);
161 }
162 else {
163 ElCLib::AdjustPeriodic
164 (mySurface->FirstUParameter(),
165 mySurface->FirstUParameter()+
166 mySurface->UPeriod(),
167 mySurface->UResolution(Precision::Confusion()),
168 myFirst,myLast);
169 }
170 }
171
172 if (mySurface->IsVPeriodic()) {
173
174 if (myIso == GeomAbs_IsoV) {
175 ElCLib::AdjustPeriodic
176 (mySurface->FirstVParameter(),
177 mySurface->FirstVParameter() +
178 mySurface->VPeriod(),
179 mySurface->VResolution(Precision::Confusion()),
180 myParameter,dummy);
181 }
182 else {
183 ElCLib::AdjustPeriodic
184 (mySurface->FirstVParameter(),
185 mySurface->FirstVParameter() +
186 mySurface->VPeriod(),
187 mySurface->VResolution(Precision::Confusion()),
188 myFirst,myLast);
189 }
190 }
191
192}
193
194//=======================================================================
195//function : Continuity
196//purpose :
197//=======================================================================
198
199GeomAbs_Shape Adaptor3d_IsoCurve::Continuity() const
200{
201 switch (myIso) {
202 case GeomAbs_IsoU:
203 return mySurface->VContinuity();
204 case GeomAbs_IsoV:
205 return mySurface->UContinuity();
206 case GeomAbs_NoneIso:
207 default:
208 break;
209 }
210
211 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
212 return GeomAbs_C0;
213}
214
215//=======================================================================
216//function : NbIntervals
217//purpose :
218//=======================================================================
219
220Standard_Integer Adaptor3d_IsoCurve::NbIntervals(const GeomAbs_Shape S)
221{
222 if (myIso == GeomAbs_NoneIso) Standard_NoSuchObject::Raise();
223 Standard_Boolean UIso = (myIso == GeomAbs_IsoU);
224
225 Standard_Integer nbInter = UIso ?
226 mySurface->NbVIntervals(S) :
227 mySurface->NbUIntervals(S);
228
229 TColStd_Array1OfReal T(1,nbInter+1);
230
231 if (UIso)
232 mySurface->VIntervals(T,S);
233 else
234 mySurface->UIntervals(T,S);
235
236 if(nbInter == 1) return nbInter;
237
238 Standard_Integer first = 1;
239 while (T(first) <= myFirst) first++;
240 Standard_Integer last = nbInter+1;
241 while (T(last) >= myLast) last--;
242 return (last - first + 2);
243}
244
245//=======================================================================
246//function : Intervals
247//purpose :
248//=======================================================================
249
250void Adaptor3d_IsoCurve::Intervals(TColStd_Array1OfReal& TI,
251 const GeomAbs_Shape S)
252{
253 if (myIso == GeomAbs_NoneIso) Standard_NoSuchObject::Raise();
254 Standard_Boolean UIso = (myIso == GeomAbs_IsoU);
255
256 Standard_Integer nbInter = UIso ?
257 mySurface->NbVIntervals(S) :
258 mySurface->NbUIntervals(S);
259
260 TColStd_Array1OfReal T(1,nbInter+1);
261
262 if (UIso)
263 mySurface->VIntervals(T,S);
264 else
265 mySurface->UIntervals(T,S);
266
267 if(nbInter == 1) {
268 TI(TI.Lower()) = myFirst ;
269 TI(TI.Lower() + 1) = myLast ;
270 return;
271 }
272
273 Standard_Integer first = 1;
274 while (T(first) <= myFirst) first++;
275 Standard_Integer last = nbInter+1;
276 while (T(last) >= myLast) last--;
277
278 Standard_Integer i = TI.Lower(), j;
279 for (j = first-1; j <= last+1; j++) {
280 TI(i) = T(j);
281 i++;
282 }
283 TI(TI.Lower()) = myFirst ;
284 TI(TI.Lower() + last-first + 2) = myLast ;
285}
286
287//=======================================================================
288//function : Trim
289//purpose :
290//=======================================================================
291
292Handle(Adaptor3d_HCurve) Adaptor3d_IsoCurve::Trim
293 (const Standard_Real First,
294 const Standard_Real Last,
295 const Standard_Real) const
296{
297 Handle(Adaptor3d_HIsoCurve) HI = new Adaptor3d_HIsoCurve(*this);
298 ((Adaptor3d_IsoCurve *)&(HI->Curve()))->Load(myIso,myParameter,First,Last);
299 return HI;
300}
301
302//=======================================================================
303//function : IsClosed
304//purpose :
305//=======================================================================
306
307Standard_Boolean Adaptor3d_IsoCurve::IsClosed() const
308{
309 switch (myIso) {
310 case GeomAbs_IsoU:
311 return mySurface->IsVClosed();
312 case GeomAbs_IsoV:
313 return mySurface->IsUClosed();
314 case GeomAbs_NoneIso:
315 default:
316 break;
317 }
318
319 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
320 return Standard_False;
321}
322
323//=======================================================================
324//function : IsPeriodic
325//purpose :
326//=======================================================================
327
328Standard_Boolean Adaptor3d_IsoCurve::IsPeriodic() const
329{
330 switch (myIso) {
331 case GeomAbs_IsoU:
332 return mySurface->IsVPeriodic();
333 case GeomAbs_IsoV:
334 return mySurface->IsUPeriodic();
335 case GeomAbs_NoneIso:
336 default:
337 break;
338 }
339
340 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
341 return Standard_False;
342}
343
344//=======================================================================
345//function : Period
346//purpose :
347//=======================================================================
348
349Standard_Real Adaptor3d_IsoCurve::Period() const
350{
351 switch (myIso) {
352 case GeomAbs_IsoU:
353 return mySurface->VPeriod();
354 case GeomAbs_IsoV:
355 return mySurface->UPeriod();
356 case GeomAbs_NoneIso:
357 default:
358 break;
359 }
360
361 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
362 return 0.;
363}
364
365//=======================================================================
366//function : Value
367//purpose :
368//=======================================================================
369
370gp_Pnt Adaptor3d_IsoCurve::Value(const Standard_Real T) const
371{
372 switch (myIso) {
373
374 case GeomAbs_IsoU:
375 return mySurface->Value(myParameter,T);
376
377 case GeomAbs_IsoV:
378 return mySurface->Value(T,myParameter);
379
380 case GeomAbs_NoneIso:
381 {
382 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
383 break;
384 }
385 }
386 // portage WNT
387 return gp_Pnt();
388}
389
390
391//=======================================================================
392//function : D0
393//purpose :
394//=======================================================================
395
396void Adaptor3d_IsoCurve::D0(const Standard_Real T, gp_Pnt& P) const
397{
398 switch (myIso) {
399
400 case GeomAbs_IsoU:
401 mySurface->D0(myParameter,T,P);
402 break;
403
404 case GeomAbs_IsoV:
405 mySurface->D0(T,myParameter,P);
406 break;
407
408 case GeomAbs_NoneIso:
409 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
410 break;
411 }
412}
413
414//=======================================================================
415//function : D1
416//purpose :
417//=======================================================================
418
419void Adaptor3d_IsoCurve::D1(const Standard_Real T, gp_Pnt& P, gp_Vec& V) const
420{
421 gp_Vec dummy;
422 switch (myIso) {
423
424 case GeomAbs_IsoU:
425 mySurface->D1(myParameter,T,P,dummy,V);
426 break;
427
428 case GeomAbs_IsoV:
429 mySurface->D1(T,myParameter,P,V,dummy);
430 break;
431
432 case GeomAbs_NoneIso:
433 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
434 break;
435 }
436}
437
438//=======================================================================
439//function : D2
440//purpose :
441//=======================================================================
442
443void Adaptor3d_IsoCurve::D2(const Standard_Real T, gp_Pnt& P,
444 gp_Vec& V1, gp_Vec& V2) const
445{
446 gp_Vec dummy1,dummy2,dummy3;
447 switch (myIso) {
448
449 case GeomAbs_IsoU:
450 mySurface->D2(myParameter,T,P,
451 dummy1,V1,dummy2,V2,dummy3);
452 break;
453 case GeomAbs_IsoV:
454 mySurface->D2(T,myParameter,
455 P,V1,dummy1,V2,dummy2,dummy3);
456 break;
457 case GeomAbs_NoneIso:
458 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
459 break;
460 }
461}
462
463//=======================================================================
464//function : D3
465//purpose :
466//=======================================================================
467
468void Adaptor3d_IsoCurve::D3(const Standard_Real T, gp_Pnt& P,
469 gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const
470{
471 gp_Vec dummy[6];
472 switch (myIso) {
473
474 case GeomAbs_IsoU:
475 mySurface->D3(myParameter,T,P,dummy[0],V1,dummy[1],
476 V2,dummy[2],dummy[3],V3,dummy[4],dummy[5]);
477 break;
478
479 case GeomAbs_IsoV:
480 mySurface->D3(T,myParameter,P,V1,dummy[0],V2,dummy[1],
481 dummy[2],V3,dummy[3],dummy[4],dummy[5]);
482 break;
483
484 case GeomAbs_NoneIso:
485 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
486 break;
487 }
488}
489
490//=======================================================================
491//function : DN
492//purpose :
493//=======================================================================
494
495gp_Vec Adaptor3d_IsoCurve::DN(const Standard_Real T,
496 const Standard_Integer N) const
497{
498 switch (myIso) {
499
500 case GeomAbs_IsoU:
501 return mySurface->DN(myParameter,T,0,N);
502 case GeomAbs_IsoV:
503 return mySurface->DN(T,myParameter,N,0);
504 case GeomAbs_NoneIso:
505 {
506 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
507 break;
508 }
509 }
510
511 // portage WNT
512 return gp_Vec();
513}
514
515
516//=======================================================================
517//function : Resolution
518//purpose :
519//=======================================================================
520
521Standard_Real Adaptor3d_IsoCurve::Resolution(const Standard_Real R3D) const
522{
523 // Peut-on faire mieux ??
524 return Precision::Parametric(R3D);
525}
526
527
528
529//=======================================================================
530//function : GetType
531//purpose :
532//=======================================================================
533
534GeomAbs_CurveType Adaptor3d_IsoCurve::GetType() const {
535
536 switch (mySurface->GetType()) {
537
538 case GeomAbs_Plane:
539 return GeomAbs_Line;
540
541 case GeomAbs_Cylinder:
542 case GeomAbs_Cone:
543 {
544 switch (myIso) {
545 case GeomAbs_IsoU:
546 return GeomAbs_Line;
547
548 case GeomAbs_IsoV:
549 return GeomAbs_Circle;
550
551 case GeomAbs_NoneIso:
552 {
553 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
554 // portage WNT
555 return GeomAbs_OtherCurve;
556 break;
557 }
558 }
559 break;
560 }
561
562 case GeomAbs_Sphere:
563 case GeomAbs_Torus:
564 return GeomAbs_Circle;
565
566 case GeomAbs_BezierSurface:
567 return GeomAbs_BezierCurve;
568
569 case GeomAbs_BSplineSurface:
570 return GeomAbs_BSplineCurve;
571
572 case GeomAbs_SurfaceOfRevolution:
573 {
574 switch (myIso) {
575 case GeomAbs_IsoU:
576 return mySurface->BasisCurve()->GetType();
577
578 case GeomAbs_IsoV:
579 return GeomAbs_Circle;
580
581 case GeomAbs_NoneIso:
582 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
583 // portage WNT
584 return GeomAbs_OtherCurve;
585 break;
586 }
587 break;
588 }
589
590 case GeomAbs_SurfaceOfExtrusion:
591 {
592 switch (myIso) {
593 case GeomAbs_IsoU:
594 return GeomAbs_Line;
595
596 case GeomAbs_IsoV:
597 return mySurface->BasisCurve()->GetType();
598
599 case GeomAbs_NoneIso:
600 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
601 // portage WNT
602 return GeomAbs_OtherCurve;
603 break;
604 }
605 break;
606 }
607 default:
608 return GeomAbs_OtherCurve;
609 }
610
611 // portage WNT
612 return GeomAbs_OtherCurve;
613}
614
615//=======================================================================
616//function : Line
617//purpose :
618//=======================================================================
619
620gp_Lin Adaptor3d_IsoCurve::Line() const
621{
622 gp_Pnt P;
623 gp_Vec V;
624 D1(0,P,V);
625 return gp_Lin(P,V);
626}
627
628//=======================================================================
629//function : computeHR
630//purpose :
631//=======================================================================
632
633static void computeHR(const gp_Ax3& axes,
634 const gp_Pnt& P,
635 Standard_Real& h,
636 Standard_Real& radius)
637{
638 gp_Vec V(axes.Location(),P);
639 h = V * axes.Direction();
640 radius = V * axes.XDirection();
641}
642
643//=======================================================================
644//function : Circle
645//purpose :
646//=======================================================================
647
648gp_Circ Adaptor3d_IsoCurve::Circle() const
649{
650 gp_Ax3 axes;
651 Standard_Real radius,h = 0.;
652
653 switch (mySurface->GetType()) {
654
655 case GeomAbs_Cylinder:
656 {
657 gp_Cylinder cyl = mySurface->Cylinder();
658
659 switch (myIso) {
660
661 case GeomAbs_IsoU:
662 {
663 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:UIso");
664 return gp_Circ();
665 }
666 case GeomAbs_IsoV:
667 {
668 return ElSLib::CylinderVIso(cyl.Position(),cyl.Radius(),myParameter);
669 }
670 case GeomAbs_NoneIso:
671 {
672 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
673 return gp_Circ();
674 }
675 }
676 break;
677 }
678
679 case GeomAbs_Cone:
680 {
681 gp_Cone cone = mySurface->Cone();
682
683 switch (myIso) {
684
685 case GeomAbs_IsoU:
686 {
687 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:UIso");
688 return gp_Circ();
689 }
690 case GeomAbs_IsoV:
691 {
692 return ElSLib::ConeVIso(cone.Position(),cone.RefRadius(),
693 cone.SemiAngle(),myParameter);
694 }
695 case GeomAbs_NoneIso:
696 {
697 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
698 return gp_Circ();
699 }
700 }
701 break;
702 }
703
704 case GeomAbs_Sphere:
705 {
706 gp_Sphere sph = mySurface->Sphere();
707
708 switch (myIso) {
709
710 case GeomAbs_IsoU:
711 {
712 return ElSLib::SphereUIso(sph.Position(),sph.Radius(),myParameter);
713 }
714
715 case GeomAbs_IsoV:
716 {
717 return ElSLib::SphereVIso(sph.Position(),sph.Radius(),myParameter);
718 }
719
720 case GeomAbs_NoneIso:
721 {
722 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
723 return gp_Circ();
724 }
725 }
726 break;
727 }
728
729 case GeomAbs_Torus: {
730 gp_Torus tor = mySurface->Torus();
731
732 switch (myIso) {
733
734 case GeomAbs_IsoU:
735 {
736 return ElSLib::TorusUIso(tor.Position(),tor.MajorRadius(),
737 tor.MinorRadius(),myParameter);
738 }
739
740 case GeomAbs_IsoV:
741 {
742 return ElSLib::TorusVIso(tor.Position(),tor.MajorRadius(),
743 tor.MinorRadius(),myParameter);
744 }
745
746 case GeomAbs_NoneIso:
747 {
748 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
749 return gp_Circ();
750 }
751 }
752 break;
753 }
754
755 case GeomAbs_SurfaceOfRevolution:
756 {
757 if (myIso == GeomAbs_IsoV) {
758 gp_Ax1 Ax1 = mySurface->AxeOfRevolution();
759 gp_Vec DX(Ax1.Location(), Value(0));
760 if(DX.IsParallel(Ax1.Direction(),Precision::Angular())) {
761 return gp_Circ(gp_Ax2(Value(0), Ax1.Direction()),0);
762 }
763 else {
764 axes = gp_Ax3(Ax1.Location(), Ax1.Direction(), DX);
765 computeHR(axes,Value(0),h,radius);
766 gp_Vec VT = axes.Direction();
767 axes.Translate(VT * h);
768 return gp_Circ(axes.Ax2(),radius);
769 }
770 }
771 else {
772 return mySurface->BasisCurve()->Circle().Rotated
773 (mySurface->AxeOfRevolution(),myParameter);
774 }
775 }
776
777 case GeomAbs_SurfaceOfExtrusion: {
778 return mySurface->BasisCurve()->Circle().Translated
779 (myParameter * gp_Vec(mySurface->Direction()));
780 }
781 default:
782 {
783 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Circle");
784 return gp_Circ();
785 }
786
787 }
788 // portage WNT
789 return gp_Circ();
790}
791
792//=======================================================================
793//function : Ellipse
794//purpose :
795//=======================================================================
796
797gp_Elips Adaptor3d_IsoCurve::Ellipse() const
798{
799 switch (mySurface->GetType()) {
800
801 case GeomAbs_SurfaceOfExtrusion: {
802 return mySurface->BasisCurve()->Ellipse().Translated
803 (myParameter * gp_Vec(mySurface->Direction()));
804 }
805 default:
806 {
807 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Ellipse");
7fd59977 808 }
809
810 }
811 // portage WNT
812 return gp_Elips();
813}
814
815//=======================================================================
816//function : Hyperbola
817//purpose :
818//=======================================================================
819
820gp_Hypr Adaptor3d_IsoCurve::Hyperbola() const
821{
822 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Hyperbola");
823 return gp_Hypr();
824}
825
826//=======================================================================
827//function : Parabola
828//purpose :
829//=======================================================================
830
831gp_Parab Adaptor3d_IsoCurve::Parabola() const
832{
833 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Parabola");
834 return gp_Parab();
835}
836
837//=======================================================================
838//function : Degree
839//purpose :
840//=======================================================================
841
842Standard_Integer Adaptor3d_IsoCurve::Degree() const
843{
844 Standard_Integer degree = 0 ;
845 GeomAbs_SurfaceType type = mySurface->GetType() ;
846 switch(type) {
847 case GeomAbs_BezierSurface:
848 case GeomAbs_BSplineSurface:
849 {
850 switch (myIso) {
851 case GeomAbs_IsoU:
852 degree = mySurface->VDegree() ;
853 break ;
854 case GeomAbs_IsoV:
855 degree = mySurface->UDegree() ;
856 break ;
857
858 case GeomAbs_NoneIso:
859 default:
860 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
861 }
862 }
863 break ;
864 case GeomAbs_SurfaceOfRevolution:
865 {
866 switch (myIso) {
867 case GeomAbs_IsoU:
868 degree = mySurface->BasisCurve()->Degree();
869 break;
870 default:
871 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
872 }
873 }
874 break;
875 case GeomAbs_SurfaceOfExtrusion:
876 {
877 switch (myIso) {
878 case GeomAbs_IsoV:
879 degree = mySurface->BasisCurve()->Degree();
880 break;
881 default:
882 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
883 }
884 }
885 break;
886 default:
887 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
888 break ;
889 }
890 return degree ;
891}
892
893//=======================================================================
894//function : IsRational
895//purpose :
896//=======================================================================
897
898Standard_Boolean Adaptor3d_IsoCurve::IsRational() const
899{
900 Standard_Integer is_rational = Standard_False ;
901 GeomAbs_SurfaceType type = mySurface->GetType() ;
902 switch(type) {
903 case GeomAbs_BezierSurface:
904 case GeomAbs_BSplineSurface:
905 {
906 switch (myIso) {
907 case GeomAbs_IsoU:
908 is_rational = mySurface->IsVRational() ;
909 break ;
910 case GeomAbs_IsoV:
911 is_rational = mySurface->IsURational() ;
912 break ;
913
914 case GeomAbs_NoneIso:
915 default:
916 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
917 }
918 }
919 break ;
920 case GeomAbs_SurfaceOfRevolution:
921 {
922 switch (myIso) {
923 case GeomAbs_IsoU:
924 is_rational = mySurface->BasisCurve()->IsRational();
925 break;
926 default:
927 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
928 }
929 }
930 break;
931 case GeomAbs_SurfaceOfExtrusion:
932 {
933 switch (myIso) {
934 case GeomAbs_IsoV:
935 is_rational = mySurface->BasisCurve()->IsRational();
936 break;
937 default:
938 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
939 }
940 }
941 break;
942 default:
943 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
944 }
945 return is_rational;
946}
947
948
949//=======================================================================
950//function : NbPoles
951//purpose :
952//=======================================================================
953
954Standard_Integer Adaptor3d_IsoCurve::NbPoles() const
955{
956 Standard_Integer nb_poles = 0 ;
957 GeomAbs_SurfaceType type = mySurface->GetType() ;
958 switch(type) {
959 case GeomAbs_BezierSurface:
960 case GeomAbs_BSplineSurface:
961 switch (myIso) {
962 case GeomAbs_IsoU:
963 nb_poles = mySurface->NbVPoles() ;
964 break ;
965 case GeomAbs_IsoV:
966 nb_poles = mySurface->NbUPoles() ;
967 break ;
968
969 case GeomAbs_NoneIso:
970 default:
971 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
972 }
973 break ;
974 case GeomAbs_SurfaceOfRevolution:
975 {
976 switch( myIso) {
977 case GeomAbs_IsoU:
978 {
979 nb_poles = mySurface->BasisCurve()->NbPoles();
980 }
981 break;
982 default:
983 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
984 }
985 }
986 break;
987 case GeomAbs_SurfaceOfExtrusion:
988 {
989 switch( myIso) {
990 case GeomAbs_IsoV:
991 {
992 nb_poles = mySurface->BasisCurve()->NbPoles();
993 }
994 break;
995 default:
996 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
997 }
998 }
999 break;
1000
1001 default:
1002 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1003 break ;
1004 }
1005 return nb_poles ;
1006 }
1007
1008//=======================================================================
1009//function : NbKnots
1010//purpose :
1011//=======================================================================
1012
1013Standard_Integer Adaptor3d_IsoCurve::NbKnots() const
1014{
1015 Standard_Integer nb_knots = 0 ;
1016 GeomAbs_SurfaceType type = mySurface->GetType() ;
1017 switch(type) {
1018 case GeomAbs_BSplineSurface:
1019 {
1020 switch (myIso) {
1021 case GeomAbs_IsoU:
1022 nb_knots = mySurface->NbVKnots() ;
1023 break ;
1024 case GeomAbs_IsoV:
1025 nb_knots = mySurface->NbUKnots() ;
1026 break ;
1027
1028 case GeomAbs_NoneIso:
1029 default:
1030 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1031 }
1032 }
1033 break ;
1034 case GeomAbs_SurfaceOfRevolution:
1035 {
1036 switch (myIso) {
1037 case GeomAbs_IsoU:
1038 {
1039 nb_knots = mySurface->BasisCurve()->NbKnots() ;
1040 break ;
1041 }
1042 default:
1043 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1044 }
1045 }
1046 break ;
1047 case GeomAbs_SurfaceOfExtrusion:
1048 {
1049 switch (myIso) {
1050 case GeomAbs_IsoV:
1051 {
1052 nb_knots = mySurface->BasisCurve()->NbKnots() ;
1053 break ;
1054 }
1055 default:
1056 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1057 }
1058 }
1059 break ;
1060 default:
1061 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1062 break ;
1063 }
1064 return nb_knots ;
1065 }
1066
1067//=======================================================================
1068//function : Bezier
1069//purpose :
1070//=======================================================================
1071
1072Handle(Geom_BezierCurve) Adaptor3d_IsoCurve::Bezier() const
1073{
1074 Handle(Geom_BezierCurve) C;
1075 if (mySurface->GetType() == GeomAbs_SurfaceOfRevolution) {
1076 C = mySurface->BasisCurve()->Bezier();
1077 C = Handle(Geom_BezierCurve)::DownCast(C->Copy());
1078 C->Rotate(mySurface->AxeOfRevolution(),myParameter);
1079 }
1080 else if (mySurface->GetType() == GeomAbs_SurfaceOfExtrusion) {
1081 C = mySurface->BasisCurve()->Bezier();
1082 C = Handle(Geom_BezierCurve)::DownCast(C->Copy());
1083 C->Translate(myParameter * gp_Vec(mySurface->Direction()));
1084 }
1085 else if (myIso == GeomAbs_IsoU) {
1086 C = Handle(Geom_BezierCurve)::DownCast
1087 (mySurface->Bezier()->UIso(myParameter)) ;
1088 }
1089 else {
1090 C = Handle(Geom_BezierCurve)::DownCast
1091 (mySurface->Bezier()->VIso(myParameter));
1092 }
1093// C->Segment(myFirst,myLast);
1094 return C;
1095}
1096
1097//=======================================================================
1098//function : BSpline
1099//purpose :
1100//=======================================================================
1101
1102Handle(Geom_BSplineCurve) Adaptor3d_IsoCurve::BSpline() const
1103{
1104 Handle(Geom_BSplineCurve) C;
1105 if (mySurface->GetType() == GeomAbs_SurfaceOfRevolution) {
1106 C = mySurface->BasisCurve()->BSpline();
1107 C = Handle(Geom_BSplineCurve)::DownCast(C->Copy());
1108 C->Rotate(mySurface->AxeOfRevolution(),myParameter);
1109 }
1110 else if (mySurface->GetType() == GeomAbs_SurfaceOfExtrusion) {
1111 C = mySurface->BasisCurve()->BSpline();
1112 C = Handle(Geom_BSplineCurve)::DownCast(C->Copy());
1113 C->Translate(myParameter * gp_Vec(mySurface->Direction()));
1114 }
1115 else if (myIso == GeomAbs_IsoU) {
1116 C = Handle(Geom_BSplineCurve)::DownCast
1117 (mySurface->BSpline()->UIso(myParameter)) ;
1118 }
1119 else {
1120 C = Handle(Geom_BSplineCurve)::DownCast
1121 (mySurface->BSpline()->VIso(myParameter));
1122 }
1123// C->Segment(myFirst,myLast);
1124 return C;
1125}
1126