0023839: Projection algorithm produces wrong results for set of data
[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");
d3f26155 808 }
7fd59977 809 }
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