0024337: Draw Harness - relax vinit syntax
[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;
7fd59977 556 }
557 }
558 break;
559 }
560
561 case GeomAbs_Sphere:
562 case GeomAbs_Torus:
563 return GeomAbs_Circle;
564
565 case GeomAbs_BezierSurface:
566 return GeomAbs_BezierCurve;
567
568 case GeomAbs_BSplineSurface:
569 return GeomAbs_BSplineCurve;
570
571 case GeomAbs_SurfaceOfRevolution:
572 {
573 switch (myIso) {
574 case GeomAbs_IsoU:
575 return mySurface->BasisCurve()->GetType();
576
577 case GeomAbs_IsoV:
578 return GeomAbs_Circle;
579
580 case GeomAbs_NoneIso:
581 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
582 // portage WNT
583 return GeomAbs_OtherCurve;
584 break;
585 }
586 break;
587 }
588
589 case GeomAbs_SurfaceOfExtrusion:
590 {
591 switch (myIso) {
592 case GeomAbs_IsoU:
593 return GeomAbs_Line;
594
595 case GeomAbs_IsoV:
596 return mySurface->BasisCurve()->GetType();
597
598 case GeomAbs_NoneIso:
599 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
600 // portage WNT
601 return GeomAbs_OtherCurve;
602 break;
603 }
604 break;
605 }
606 default:
607 return GeomAbs_OtherCurve;
608 }
609
610 // portage WNT
611 return GeomAbs_OtherCurve;
612}
613
614//=======================================================================
615//function : Line
616//purpose :
617//=======================================================================
618
619gp_Lin Adaptor3d_IsoCurve::Line() const
620{
621 gp_Pnt P;
622 gp_Vec V;
623 D1(0,P,V);
624 return gp_Lin(P,V);
625}
626
627//=======================================================================
628//function : computeHR
629//purpose :
630//=======================================================================
631
632static void computeHR(const gp_Ax3& axes,
633 const gp_Pnt& P,
634 Standard_Real& h,
635 Standard_Real& radius)
636{
637 gp_Vec V(axes.Location(),P);
638 h = V * axes.Direction();
639 radius = V * axes.XDirection();
640}
641
642//=======================================================================
643//function : Circle
644//purpose :
645//=======================================================================
646
647gp_Circ Adaptor3d_IsoCurve::Circle() const
648{
649 gp_Ax3 axes;
650 Standard_Real radius,h = 0.;
651
652 switch (mySurface->GetType()) {
653
654 case GeomAbs_Cylinder:
655 {
656 gp_Cylinder cyl = mySurface->Cylinder();
657
658 switch (myIso) {
659
660 case GeomAbs_IsoU:
661 {
662 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:UIso");
663 return gp_Circ();
664 }
665 case GeomAbs_IsoV:
666 {
667 return ElSLib::CylinderVIso(cyl.Position(),cyl.Radius(),myParameter);
668 }
669 case GeomAbs_NoneIso:
670 {
671 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
672 return gp_Circ();
673 }
674 }
675 break;
676 }
677
678 case GeomAbs_Cone:
679 {
680 gp_Cone cone = mySurface->Cone();
681
682 switch (myIso) {
683
684 case GeomAbs_IsoU:
685 {
686 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:UIso");
687 return gp_Circ();
688 }
689 case GeomAbs_IsoV:
690 {
691 return ElSLib::ConeVIso(cone.Position(),cone.RefRadius(),
692 cone.SemiAngle(),myParameter);
693 }
694 case GeomAbs_NoneIso:
695 {
696 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
697 return gp_Circ();
698 }
699 }
700 break;
701 }
702
703 case GeomAbs_Sphere:
704 {
705 gp_Sphere sph = mySurface->Sphere();
706
707 switch (myIso) {
708
709 case GeomAbs_IsoU:
710 {
711 return ElSLib::SphereUIso(sph.Position(),sph.Radius(),myParameter);
712 }
713
714 case GeomAbs_IsoV:
715 {
716 return ElSLib::SphereVIso(sph.Position(),sph.Radius(),myParameter);
717 }
718
719 case GeomAbs_NoneIso:
720 {
721 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
722 return gp_Circ();
723 }
724 }
725 break;
726 }
727
728 case GeomAbs_Torus: {
729 gp_Torus tor = mySurface->Torus();
730
731 switch (myIso) {
732
733 case GeomAbs_IsoU:
734 {
735 return ElSLib::TorusUIso(tor.Position(),tor.MajorRadius(),
736 tor.MinorRadius(),myParameter);
737 }
738
739 case GeomAbs_IsoV:
740 {
741 return ElSLib::TorusVIso(tor.Position(),tor.MajorRadius(),
742 tor.MinorRadius(),myParameter);
743 }
744
745 case GeomAbs_NoneIso:
746 {
747 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
748 return gp_Circ();
749 }
750 }
751 break;
752 }
753
754 case GeomAbs_SurfaceOfRevolution:
755 {
756 if (myIso == GeomAbs_IsoV) {
757 gp_Ax1 Ax1 = mySurface->AxeOfRevolution();
758 gp_Vec DX(Ax1.Location(), Value(0));
759 if(DX.IsParallel(Ax1.Direction(),Precision::Angular())) {
760 return gp_Circ(gp_Ax2(Value(0), Ax1.Direction()),0);
761 }
762 else {
763 axes = gp_Ax3(Ax1.Location(), Ax1.Direction(), DX);
764 computeHR(axes,Value(0),h,radius);
765 gp_Vec VT = axes.Direction();
766 axes.Translate(VT * h);
767 return gp_Circ(axes.Ax2(),radius);
768 }
769 }
770 else {
771 return mySurface->BasisCurve()->Circle().Rotated
772 (mySurface->AxeOfRevolution(),myParameter);
773 }
774 }
775
776 case GeomAbs_SurfaceOfExtrusion: {
777 return mySurface->BasisCurve()->Circle().Translated
778 (myParameter * gp_Vec(mySurface->Direction()));
779 }
780 default:
781 {
782 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Circle");
783 return gp_Circ();
784 }
785
786 }
787 // portage WNT
788 return gp_Circ();
789}
790
791//=======================================================================
792//function : Ellipse
793//purpose :
794//=======================================================================
795
796gp_Elips Adaptor3d_IsoCurve::Ellipse() const
797{
798 switch (mySurface->GetType()) {
799
800 case GeomAbs_SurfaceOfExtrusion: {
801 return mySurface->BasisCurve()->Ellipse().Translated
802 (myParameter * gp_Vec(mySurface->Direction()));
803 }
804 default:
805 {
806 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Ellipse");
d3f26155 807 }
7fd59977 808 }
cf6625bd 809 return gp_Elips();
7fd59977 810}
811
812//=======================================================================
813//function : Hyperbola
814//purpose :
815//=======================================================================
816
817gp_Hypr Adaptor3d_IsoCurve::Hyperbola() const
818{
819 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Hyperbola");
820 return gp_Hypr();
821}
822
823//=======================================================================
824//function : Parabola
825//purpose :
826//=======================================================================
827
828gp_Parab Adaptor3d_IsoCurve::Parabola() const
829{
830 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Parabola");
831 return gp_Parab();
832}
833
834//=======================================================================
835//function : Degree
836//purpose :
837//=======================================================================
838
839Standard_Integer Adaptor3d_IsoCurve::Degree() const
840{
841 Standard_Integer degree = 0 ;
842 GeomAbs_SurfaceType type = mySurface->GetType() ;
843 switch(type) {
844 case GeomAbs_BezierSurface:
845 case GeomAbs_BSplineSurface:
846 {
847 switch (myIso) {
848 case GeomAbs_IsoU:
849 degree = mySurface->VDegree() ;
850 break ;
851 case GeomAbs_IsoV:
852 degree = mySurface->UDegree() ;
853 break ;
854
855 case GeomAbs_NoneIso:
856 default:
857 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
858 }
859 }
860 break ;
861 case GeomAbs_SurfaceOfRevolution:
862 {
863 switch (myIso) {
864 case GeomAbs_IsoU:
865 degree = mySurface->BasisCurve()->Degree();
866 break;
867 default:
868 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
869 }
870 }
871 break;
872 case GeomAbs_SurfaceOfExtrusion:
873 {
874 switch (myIso) {
875 case GeomAbs_IsoV:
876 degree = mySurface->BasisCurve()->Degree();
877 break;
878 default:
879 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
880 }
881 }
882 break;
883 default:
884 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
885 break ;
886 }
887 return degree ;
888}
889
890//=======================================================================
891//function : IsRational
892//purpose :
893//=======================================================================
894
895Standard_Boolean Adaptor3d_IsoCurve::IsRational() const
896{
897 Standard_Integer is_rational = Standard_False ;
898 GeomAbs_SurfaceType type = mySurface->GetType() ;
899 switch(type) {
900 case GeomAbs_BezierSurface:
901 case GeomAbs_BSplineSurface:
902 {
903 switch (myIso) {
904 case GeomAbs_IsoU:
905 is_rational = mySurface->IsVRational() ;
906 break ;
907 case GeomAbs_IsoV:
908 is_rational = mySurface->IsURational() ;
909 break ;
910
911 case GeomAbs_NoneIso:
912 default:
913 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
914 }
915 }
916 break ;
917 case GeomAbs_SurfaceOfRevolution:
918 {
919 switch (myIso) {
920 case GeomAbs_IsoU:
921 is_rational = mySurface->BasisCurve()->IsRational();
922 break;
923 default:
924 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
925 }
926 }
927 break;
928 case GeomAbs_SurfaceOfExtrusion:
929 {
930 switch (myIso) {
931 case GeomAbs_IsoV:
932 is_rational = mySurface->BasisCurve()->IsRational();
933 break;
934 default:
935 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
936 }
937 }
938 break;
939 default:
940 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
941 }
942 return is_rational;
943}
944
945
946//=======================================================================
947//function : NbPoles
948//purpose :
949//=======================================================================
950
951Standard_Integer Adaptor3d_IsoCurve::NbPoles() const
952{
953 Standard_Integer nb_poles = 0 ;
954 GeomAbs_SurfaceType type = mySurface->GetType() ;
955 switch(type) {
956 case GeomAbs_BezierSurface:
957 case GeomAbs_BSplineSurface:
958 switch (myIso) {
959 case GeomAbs_IsoU:
960 nb_poles = mySurface->NbVPoles() ;
961 break ;
962 case GeomAbs_IsoV:
963 nb_poles = mySurface->NbUPoles() ;
964 break ;
965
966 case GeomAbs_NoneIso:
967 default:
968 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
969 }
970 break ;
971 case GeomAbs_SurfaceOfRevolution:
972 {
973 switch( myIso) {
974 case GeomAbs_IsoU:
975 {
976 nb_poles = mySurface->BasisCurve()->NbPoles();
977 }
978 break;
979 default:
980 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
981 }
982 }
983 break;
984 case GeomAbs_SurfaceOfExtrusion:
985 {
986 switch( myIso) {
987 case GeomAbs_IsoV:
988 {
989 nb_poles = mySurface->BasisCurve()->NbPoles();
990 }
991 break;
992 default:
993 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
994 }
995 }
996 break;
997
998 default:
999 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1000 break ;
1001 }
1002 return nb_poles ;
1003 }
1004
1005//=======================================================================
1006//function : NbKnots
1007//purpose :
1008//=======================================================================
1009
1010Standard_Integer Adaptor3d_IsoCurve::NbKnots() const
1011{
1012 Standard_Integer nb_knots = 0 ;
1013 GeomAbs_SurfaceType type = mySurface->GetType() ;
1014 switch(type) {
1015 case GeomAbs_BSplineSurface:
1016 {
1017 switch (myIso) {
1018 case GeomAbs_IsoU:
1019 nb_knots = mySurface->NbVKnots() ;
1020 break ;
1021 case GeomAbs_IsoV:
1022 nb_knots = mySurface->NbUKnots() ;
1023 break ;
1024
1025 case GeomAbs_NoneIso:
1026 default:
1027 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1028 }
1029 }
1030 break ;
1031 case GeomAbs_SurfaceOfRevolution:
1032 {
1033 switch (myIso) {
1034 case GeomAbs_IsoU:
1035 {
1036 nb_knots = mySurface->BasisCurve()->NbKnots() ;
1037 break ;
1038 }
1039 default:
1040 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1041 }
1042 }
1043 break ;
1044 case GeomAbs_SurfaceOfExtrusion:
1045 {
1046 switch (myIso) {
1047 case GeomAbs_IsoV:
1048 {
1049 nb_knots = mySurface->BasisCurve()->NbKnots() ;
1050 break ;
1051 }
1052 default:
1053 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1054 }
1055 }
1056 break ;
1057 default:
1058 Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso");
1059 break ;
1060 }
1061 return nb_knots ;
1062 }
1063
1064//=======================================================================
1065//function : Bezier
1066//purpose :
1067//=======================================================================
1068
1069Handle(Geom_BezierCurve) Adaptor3d_IsoCurve::Bezier() const
1070{
1071 Handle(Geom_BezierCurve) C;
1072 if (mySurface->GetType() == GeomAbs_SurfaceOfRevolution) {
1073 C = mySurface->BasisCurve()->Bezier();
1074 C = Handle(Geom_BezierCurve)::DownCast(C->Copy());
1075 C->Rotate(mySurface->AxeOfRevolution(),myParameter);
1076 }
1077 else if (mySurface->GetType() == GeomAbs_SurfaceOfExtrusion) {
1078 C = mySurface->BasisCurve()->Bezier();
1079 C = Handle(Geom_BezierCurve)::DownCast(C->Copy());
1080 C->Translate(myParameter * gp_Vec(mySurface->Direction()));
1081 }
1082 else if (myIso == GeomAbs_IsoU) {
1083 C = Handle(Geom_BezierCurve)::DownCast
1084 (mySurface->Bezier()->UIso(myParameter)) ;
1085 }
1086 else {
1087 C = Handle(Geom_BezierCurve)::DownCast
1088 (mySurface->Bezier()->VIso(myParameter));
1089 }
1090// C->Segment(myFirst,myLast);
1091 return C;
1092}
1093
1094//=======================================================================
1095//function : BSpline
1096//purpose :
1097//=======================================================================
1098
1099Handle(Geom_BSplineCurve) Adaptor3d_IsoCurve::BSpline() const
1100{
1101 Handle(Geom_BSplineCurve) C;
1102 if (mySurface->GetType() == GeomAbs_SurfaceOfRevolution) {
1103 C = mySurface->BasisCurve()->BSpline();
1104 C = Handle(Geom_BSplineCurve)::DownCast(C->Copy());
1105 C->Rotate(mySurface->AxeOfRevolution(),myParameter);
1106 }
1107 else if (mySurface->GetType() == GeomAbs_SurfaceOfExtrusion) {
1108 C = mySurface->BasisCurve()->BSpline();
1109 C = Handle(Geom_BSplineCurve)::DownCast(C->Copy());
1110 C->Translate(myParameter * gp_Vec(mySurface->Direction()));
1111 }
1112 else if (myIso == GeomAbs_IsoU) {
1113 C = Handle(Geom_BSplineCurve)::DownCast
1114 (mySurface->BSpline()->UIso(myParameter)) ;
1115 }
1116 else {
1117 C = Handle(Geom_BSplineCurve)::DownCast
1118 (mySurface->BSpline()->VIso(myParameter));
1119 }
1120// C->Segment(myFirst,myLast);
1121 return C;
1122}
1123