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