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