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