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