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 | |
42 | Adaptor3d_IsoCurve::Adaptor3d_IsoCurve() : |
43 | myIso(GeomAbs_NoneIso) |
44 | {} |
45 | |
46 | //======================================================================= |
47 | //function : Adaptor3d_IsoCurve |
48 | //purpose : |
49 | //======================================================================= |
50 | |
51 | Adaptor3d_IsoCurve::Adaptor3d_IsoCurve(const Handle(Adaptor3d_HSurface)& S) |
52 | { |
53 | Load(S); |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : Adaptor3d_IsoCurve |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | Adaptor3d_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 | |
74 | Adaptor3d_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 | |
89 | void 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 | |
100 | void 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 | |
128 | void 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 | |
199 | GeomAbs_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 | |
220 | Standard_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 | |
250 | void 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 | |
292 | Handle(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 | |
307 | Standard_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 | |
328 | Standard_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 | |
349 | Standard_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 | |
370 | gp_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 | |
396 | void 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 | |
419 | void 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 | |
443 | void 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 | |
468 | void 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 | |
495 | gp_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 | |
521 | Standard_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 | |
534 | GeomAbs_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 | |
620 | gp_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 | |
633 | static 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 | |
648 | gp_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 | |
797 | gp_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 | } |
cf6625bd |
810 | return gp_Elips(); |
7fd59977 |
811 | } |
812 | |
813 | //======================================================================= |
814 | //function : Hyperbola |
815 | //purpose : |
816 | //======================================================================= |
817 | |
818 | gp_Hypr Adaptor3d_IsoCurve::Hyperbola() const |
819 | { |
820 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Hyperbola"); |
821 | return gp_Hypr(); |
822 | } |
823 | |
824 | //======================================================================= |
825 | //function : Parabola |
826 | //purpose : |
827 | //======================================================================= |
828 | |
829 | gp_Parab Adaptor3d_IsoCurve::Parabola() const |
830 | { |
831 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:Parabola"); |
832 | return gp_Parab(); |
833 | } |
834 | |
835 | //======================================================================= |
836 | //function : Degree |
837 | //purpose : |
838 | //======================================================================= |
839 | |
840 | Standard_Integer Adaptor3d_IsoCurve::Degree() const |
841 | { |
842 | Standard_Integer degree = 0 ; |
843 | GeomAbs_SurfaceType type = mySurface->GetType() ; |
844 | switch(type) { |
845 | case GeomAbs_BezierSurface: |
846 | case GeomAbs_BSplineSurface: |
847 | { |
848 | switch (myIso) { |
849 | case GeomAbs_IsoU: |
850 | degree = mySurface->VDegree() ; |
851 | break ; |
852 | case GeomAbs_IsoV: |
853 | degree = mySurface->UDegree() ; |
854 | break ; |
855 | |
856 | case GeomAbs_NoneIso: |
857 | default: |
858 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
859 | } |
860 | } |
861 | break ; |
862 | case GeomAbs_SurfaceOfRevolution: |
863 | { |
864 | switch (myIso) { |
865 | case GeomAbs_IsoU: |
866 | degree = mySurface->BasisCurve()->Degree(); |
867 | break; |
868 | default: |
869 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
870 | } |
871 | } |
872 | break; |
873 | case GeomAbs_SurfaceOfExtrusion: |
874 | { |
875 | switch (myIso) { |
876 | case GeomAbs_IsoV: |
877 | degree = mySurface->BasisCurve()->Degree(); |
878 | break; |
879 | default: |
880 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
881 | } |
882 | } |
883 | break; |
884 | default: |
885 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
886 | break ; |
887 | } |
888 | return degree ; |
889 | } |
890 | |
891 | //======================================================================= |
892 | //function : IsRational |
893 | //purpose : |
894 | //======================================================================= |
895 | |
896 | Standard_Boolean Adaptor3d_IsoCurve::IsRational() const |
897 | { |
898 | Standard_Integer is_rational = Standard_False ; |
899 | GeomAbs_SurfaceType type = mySurface->GetType() ; |
900 | switch(type) { |
901 | case GeomAbs_BezierSurface: |
902 | case GeomAbs_BSplineSurface: |
903 | { |
904 | switch (myIso) { |
905 | case GeomAbs_IsoU: |
906 | is_rational = mySurface->IsVRational() ; |
907 | break ; |
908 | case GeomAbs_IsoV: |
909 | is_rational = mySurface->IsURational() ; |
910 | break ; |
911 | |
912 | case GeomAbs_NoneIso: |
913 | default: |
914 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
915 | } |
916 | } |
917 | break ; |
918 | case GeomAbs_SurfaceOfRevolution: |
919 | { |
920 | switch (myIso) { |
921 | case GeomAbs_IsoU: |
922 | is_rational = mySurface->BasisCurve()->IsRational(); |
923 | break; |
924 | default: |
925 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
926 | } |
927 | } |
928 | break; |
929 | case GeomAbs_SurfaceOfExtrusion: |
930 | { |
931 | switch (myIso) { |
932 | case GeomAbs_IsoV: |
933 | is_rational = mySurface->BasisCurve()->IsRational(); |
934 | break; |
935 | default: |
936 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
937 | } |
938 | } |
939 | break; |
940 | default: |
941 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
942 | } |
943 | return is_rational; |
944 | } |
945 | |
946 | |
947 | //======================================================================= |
948 | //function : NbPoles |
949 | //purpose : |
950 | //======================================================================= |
951 | |
952 | Standard_Integer Adaptor3d_IsoCurve::NbPoles() const |
953 | { |
954 | Standard_Integer nb_poles = 0 ; |
955 | GeomAbs_SurfaceType type = mySurface->GetType() ; |
956 | switch(type) { |
957 | case GeomAbs_BezierSurface: |
958 | case GeomAbs_BSplineSurface: |
959 | switch (myIso) { |
960 | case GeomAbs_IsoU: |
961 | nb_poles = mySurface->NbVPoles() ; |
962 | break ; |
963 | case GeomAbs_IsoV: |
964 | nb_poles = mySurface->NbUPoles() ; |
965 | break ; |
966 | |
967 | case GeomAbs_NoneIso: |
968 | default: |
969 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
970 | } |
971 | break ; |
972 | case GeomAbs_SurfaceOfRevolution: |
973 | { |
974 | switch( myIso) { |
975 | case GeomAbs_IsoU: |
976 | { |
977 | nb_poles = mySurface->BasisCurve()->NbPoles(); |
978 | } |
979 | break; |
980 | default: |
981 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
982 | } |
983 | } |
984 | break; |
985 | case GeomAbs_SurfaceOfExtrusion: |
986 | { |
987 | switch( myIso) { |
988 | case GeomAbs_IsoV: |
989 | { |
990 | nb_poles = mySurface->BasisCurve()->NbPoles(); |
991 | } |
992 | break; |
993 | default: |
994 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
995 | } |
996 | } |
997 | break; |
998 | |
999 | default: |
1000 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
1001 | break ; |
1002 | } |
1003 | return nb_poles ; |
1004 | } |
1005 | |
1006 | //======================================================================= |
1007 | //function : NbKnots |
1008 | //purpose : |
1009 | //======================================================================= |
1010 | |
1011 | Standard_Integer Adaptor3d_IsoCurve::NbKnots() const |
1012 | { |
1013 | Standard_Integer nb_knots = 0 ; |
1014 | GeomAbs_SurfaceType type = mySurface->GetType() ; |
1015 | switch(type) { |
1016 | case GeomAbs_BSplineSurface: |
1017 | { |
1018 | switch (myIso) { |
1019 | case GeomAbs_IsoU: |
1020 | nb_knots = mySurface->NbVKnots() ; |
1021 | break ; |
1022 | case GeomAbs_IsoV: |
1023 | nb_knots = mySurface->NbUKnots() ; |
1024 | break ; |
1025 | |
1026 | case GeomAbs_NoneIso: |
1027 | default: |
1028 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
1029 | } |
1030 | } |
1031 | break ; |
1032 | case GeomAbs_SurfaceOfRevolution: |
1033 | { |
1034 | switch (myIso) { |
1035 | case GeomAbs_IsoU: |
1036 | { |
1037 | nb_knots = mySurface->BasisCurve()->NbKnots() ; |
1038 | break ; |
1039 | } |
1040 | default: |
1041 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
1042 | } |
1043 | } |
1044 | break ; |
1045 | case GeomAbs_SurfaceOfExtrusion: |
1046 | { |
1047 | switch (myIso) { |
1048 | case GeomAbs_IsoV: |
1049 | { |
1050 | nb_knots = mySurface->BasisCurve()->NbKnots() ; |
1051 | break ; |
1052 | } |
1053 | default: |
1054 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
1055 | } |
1056 | } |
1057 | break ; |
1058 | default: |
1059 | Standard_NoSuchObject::Raise("Adaptor3d_IsoCurve:NoneIso"); |
1060 | break ; |
1061 | } |
1062 | return nb_knots ; |
1063 | } |
1064 | |
1065 | //======================================================================= |
1066 | //function : Bezier |
1067 | //purpose : |
1068 | //======================================================================= |
1069 | |
1070 | Handle(Geom_BezierCurve) Adaptor3d_IsoCurve::Bezier() const |
1071 | { |
1072 | Handle(Geom_BezierCurve) C; |
1073 | if (mySurface->GetType() == GeomAbs_SurfaceOfRevolution) { |
1074 | C = mySurface->BasisCurve()->Bezier(); |
1075 | C = Handle(Geom_BezierCurve)::DownCast(C->Copy()); |
1076 | C->Rotate(mySurface->AxeOfRevolution(),myParameter); |
1077 | } |
1078 | else if (mySurface->GetType() == GeomAbs_SurfaceOfExtrusion) { |
1079 | C = mySurface->BasisCurve()->Bezier(); |
1080 | C = Handle(Geom_BezierCurve)::DownCast(C->Copy()); |
1081 | C->Translate(myParameter * gp_Vec(mySurface->Direction())); |
1082 | } |
1083 | else if (myIso == GeomAbs_IsoU) { |
1084 | C = Handle(Geom_BezierCurve)::DownCast |
1085 | (mySurface->Bezier()->UIso(myParameter)) ; |
1086 | } |
1087 | else { |
1088 | C = Handle(Geom_BezierCurve)::DownCast |
1089 | (mySurface->Bezier()->VIso(myParameter)); |
1090 | } |
1091 | // C->Segment(myFirst,myLast); |
1092 | return C; |
1093 | } |
1094 | |
1095 | //======================================================================= |
1096 | //function : BSpline |
1097 | //purpose : |
1098 | //======================================================================= |
1099 | |
1100 | Handle(Geom_BSplineCurve) Adaptor3d_IsoCurve::BSpline() const |
1101 | { |
1102 | Handle(Geom_BSplineCurve) C; |
1103 | if (mySurface->GetType() == GeomAbs_SurfaceOfRevolution) { |
1104 | C = mySurface->BasisCurve()->BSpline(); |
1105 | C = Handle(Geom_BSplineCurve)::DownCast(C->Copy()); |
1106 | C->Rotate(mySurface->AxeOfRevolution(),myParameter); |
1107 | } |
1108 | else if (mySurface->GetType() == GeomAbs_SurfaceOfExtrusion) { |
1109 | C = mySurface->BasisCurve()->BSpline(); |
1110 | C = Handle(Geom_BSplineCurve)::DownCast(C->Copy()); |
1111 | C->Translate(myParameter * gp_Vec(mySurface->Direction())); |
1112 | } |
1113 | else if (myIso == GeomAbs_IsoU) { |
1114 | C = Handle(Geom_BSplineCurve)::DownCast |
1115 | (mySurface->BSpline()->UIso(myParameter)) ; |
1116 | } |
1117 | else { |
1118 | C = Handle(Geom_BSplineCurve)::DownCast |
1119 | (mySurface->BSpline()->VIso(myParameter)); |
1120 | } |
1121 | // C->Segment(myFirst,myLast); |
1122 | return C; |
1123 | } |
1124 | |