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