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