Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File: Adaptor3d_SurfaceOfRevolution.gxx |
2 | // Created: Wed Apr 21 15:55:14 1993 | |
3 | // Author: Bruno DUMORTIER | |
4 | // <dub@phylox> | |
5 | ||
6 | #include <Adaptor3d_SurfaceOfRevolution.ixx> | |
7 | ||
8 | #include <Adaptor3d_HSurfaceOfRevolution.hxx> | |
9 | #include <ElCLib.hxx> | |
10 | #include <Precision.hxx> | |
11 | #include <Standard_ConstructionError.hxx> | |
12 | ||
13 | //======================================================================= | |
14 | //function : Adaptor3d_SurfaceOfRevolution | |
15 | //purpose : | |
16 | //======================================================================= | |
17 | ||
18 | Adaptor3d_SurfaceOfRevolution::Adaptor3d_SurfaceOfRevolution() | |
19 | :myHaveAxis(Standard_False) | |
20 | {} | |
21 | ||
22 | //======================================================================= | |
23 | //function : Adaptor3d_SurfaceOfRevolution | |
24 | //purpose : | |
25 | //======================================================================= | |
26 | ||
27 | Adaptor3d_SurfaceOfRevolution::Adaptor3d_SurfaceOfRevolution | |
28 | (const Handle(Adaptor3d_HCurve)& C) | |
29 | :myHaveAxis(Standard_False) | |
30 | { | |
31 | Load( C); | |
32 | } | |
33 | ||
34 | //======================================================================= | |
35 | //function : Adaptor3d_SurfaceOfRevolution | |
36 | //purpose : | |
37 | //======================================================================= | |
38 | ||
39 | Adaptor3d_SurfaceOfRevolution::Adaptor3d_SurfaceOfRevolution | |
40 | (const Handle(Adaptor3d_HCurve)& C, | |
41 | const gp_Ax1& V) | |
42 | :myHaveAxis(Standard_False) | |
43 | { | |
44 | Load( C); | |
45 | Load( V); | |
46 | } | |
47 | ||
48 | //======================================================================= | |
49 | //function : Load | |
50 | //purpose : | |
51 | //======================================================================= | |
52 | ||
53 | void Adaptor3d_SurfaceOfRevolution::Load( const Handle(Adaptor3d_HCurve)& C) | |
54 | { | |
55 | myBasisCurve = C; | |
56 | if ( myHaveAxis) Load(myAxis); // to evaluate the new myAxeRev. | |
57 | } | |
58 | ||
59 | //======================================================================= | |
60 | //function : Load | |
61 | //purpose : | |
62 | //======================================================================= | |
63 | ||
64 | void Adaptor3d_SurfaceOfRevolution::Load( const gp_Ax1& V) | |
65 | { | |
66 | myHaveAxis = Standard_True; | |
67 | myAxis = V; | |
68 | ||
69 | // Eval myAxeRev : axe of revolution ( Determination de Ox). | |
70 | gp_Pnt P,Q; | |
71 | gp_Pnt O = myAxis.Location(); | |
72 | gp_Dir Ox; | |
73 | gp_Dir Oz = myAxis.Direction(); | |
74 | Standard_Boolean yrev = Standard_False; | |
75 | if (myBasisCurve->GetType() == GeomAbs_Line) { | |
76 | if((myBasisCurve->Line().Direction()).Dot(Oz) < 0.){ | |
77 | yrev = Standard_True; | |
78 | Oz.Reverse(); | |
79 | } | |
80 | } | |
81 | ||
82 | if (myBasisCurve->GetType() == GeomAbs_Circle) { | |
83 | Q = P = (myBasisCurve->Circle()).Location(); | |
84 | } | |
85 | else { | |
86 | Standard_Real First = myBasisCurve->FirstParameter(); | |
87 | P = Value( 0., 0.);// ce qui ne veut pas dire grand chose | |
88 | if ( GetType() == GeomAbs_Cone) { | |
89 | if ( gp_Lin(myAxis).Distance(P) <= Precision::Confusion()) | |
90 | Q = ElCLib::Value(1.,myBasisCurve->Line()); | |
91 | else | |
92 | Q = P; | |
93 | } | |
94 | else if (Precision::IsInfinite(First)) | |
95 | Q = P; | |
96 | else | |
97 | Q = Value( 0., First); | |
98 | } | |
99 | ||
100 | gp_Dir DZ = myAxis.Direction(); | |
101 | O.SetXYZ( O.XYZ() + ( gp_Vec(O,P) * DZ) * DZ.XYZ()); | |
102 | if ( gp_Lin(myAxis).Distance(Q) > Precision::Confusion()) { | |
103 | Ox = gp_Dir(Q.XYZ() - O.XYZ()); | |
104 | } | |
105 | else { | |
106 | Standard_Real First = myBasisCurve->FirstParameter(); | |
107 | Standard_Real Last = myBasisCurve->LastParameter(); | |
108 | Standard_Integer Ratio = 1; | |
109 | Standard_Real Dist; | |
110 | gp_Pnt PP; | |
111 | do { | |
112 | PP = myBasisCurve->Value(First+(Last-First)/Ratio); | |
113 | Dist = gp_Lin(myAxis).Distance(PP); | |
114 | Ratio++; | |
115 | } | |
116 | while ( Dist < Precision::Confusion() && Ratio < 100); | |
117 | ||
118 | if ( Ratio >= 100 ) { | |
119 | Standard_ConstructionError::Raise | |
120 | ("Adaptor3d_SurfaceOfRevolution : Axe and meridian are confused"); | |
121 | } | |
122 | Ox = ( (Oz^gp_Vec(PP.XYZ()-O.XYZ()))^Oz); | |
123 | } | |
124 | ||
125 | myAxeRev = gp_Ax3(O,Oz,Ox); | |
126 | ||
127 | if (yrev) { | |
128 | myAxeRev.YReverse(); | |
129 | } | |
130 | else if (myBasisCurve->GetType() == GeomAbs_Circle) { | |
131 | gp_Dir DC = (myBasisCurve->Circle()).Axis().Direction(); | |
132 | if ((Ox.Crossed(Oz)).Dot(DC) < 0.) myAxeRev.ZReverse(); | |
133 | } | |
134 | } | |
135 | ||
136 | //======================================================================= | |
137 | //function : AxeOfRevolution | |
138 | //purpose : | |
139 | //======================================================================= | |
140 | ||
141 | gp_Ax1 Adaptor3d_SurfaceOfRevolution::AxeOfRevolution() const | |
142 | { | |
143 | return myAxis; | |
144 | } | |
145 | ||
146 | //======================================================================= | |
147 | //function : FirstUParameter | |
148 | //purpose : | |
149 | //======================================================================= | |
150 | ||
151 | Standard_Real Adaptor3d_SurfaceOfRevolution::FirstUParameter() const | |
152 | { | |
153 | return 0.; | |
154 | } | |
155 | ||
156 | //======================================================================= | |
157 | //function : LastUParameter | |
158 | //purpose : | |
159 | //======================================================================= | |
160 | ||
161 | Standard_Real Adaptor3d_SurfaceOfRevolution::LastUParameter() const | |
162 | { | |
163 | return 2*PI; | |
164 | } | |
165 | ||
166 | //======================================================================= | |
167 | //function : FirstVParameter | |
168 | //purpose : | |
169 | //======================================================================= | |
170 | ||
171 | Standard_Real Adaptor3d_SurfaceOfRevolution::FirstVParameter() const | |
172 | { | |
173 | return myBasisCurve->FirstParameter(); | |
174 | } | |
175 | ||
176 | //======================================================================= | |
177 | //function : LastVParameter | |
178 | //purpose : | |
179 | //======================================================================= | |
180 | ||
181 | Standard_Real Adaptor3d_SurfaceOfRevolution::LastVParameter() const | |
182 | { | |
183 | return myBasisCurve->LastParameter(); | |
184 | } | |
185 | ||
186 | //======================================================================= | |
187 | //function : UContinuity | |
188 | //purpose : | |
189 | //======================================================================= | |
190 | ||
191 | GeomAbs_Shape Adaptor3d_SurfaceOfRevolution::UContinuity() const | |
192 | { | |
193 | return GeomAbs_CN; | |
194 | } | |
195 | ||
196 | //======================================================================= | |
197 | //function : VContinuity | |
198 | //purpose : | |
199 | //======================================================================= | |
200 | ||
201 | GeomAbs_Shape Adaptor3d_SurfaceOfRevolution::VContinuity() const | |
202 | { | |
203 | return myBasisCurve->Continuity(); | |
204 | } | |
205 | ||
206 | //======================================================================= | |
207 | //function : NbUIntervals | |
208 | //purpose : | |
209 | //======================================================================= | |
210 | ||
211 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUIntervals | |
212 | //(const GeomAbs_Shape S) const | |
213 | (const GeomAbs_Shape ) const | |
214 | { | |
215 | return 1; | |
216 | } | |
217 | ||
218 | //======================================================================= | |
219 | //function : NbVIntervals | |
220 | //purpose : | |
221 | //======================================================================= | |
222 | ||
223 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVIntervals | |
224 | ( const GeomAbs_Shape S) const | |
225 | { | |
226 | return myBasisCurve->NbIntervals(S); | |
227 | } | |
228 | ||
229 | //======================================================================= | |
230 | //function : UIntervals | |
231 | //purpose : | |
232 | //======================================================================= | |
233 | ||
234 | void Adaptor3d_SurfaceOfRevolution::UIntervals (TColStd_Array1OfReal& T, | |
235 | // const GeomAbs_Shape S) const | |
236 | const GeomAbs_Shape ) const | |
237 | { | |
238 | T(T.Lower() ) = 0.; | |
239 | T(T.Lower()+1) = 2*PI; | |
240 | } | |
241 | ||
242 | ||
243 | //======================================================================= | |
244 | //function : VIntervals | |
245 | //purpose : | |
246 | //======================================================================= | |
247 | ||
248 | void Adaptor3d_SurfaceOfRevolution::VIntervals(TColStd_Array1OfReal& T, | |
249 | const GeomAbs_Shape S) const | |
250 | { | |
251 | myBasisCurve->Intervals(T,S); | |
252 | } | |
253 | ||
254 | ||
255 | //======================================================================= | |
256 | //function : UTrim | |
257 | //purpose : | |
258 | //======================================================================= | |
259 | ||
260 | Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfRevolution::UTrim | |
261 | (const Standard_Real | |
262 | #ifndef No_Exception | |
263 | First | |
264 | #endif | |
265 | ,const Standard_Real | |
266 | #ifndef No_Exception | |
267 | Last | |
268 | #endif | |
269 | ,const Standard_Real | |
270 | #ifndef No_Exception | |
271 | Tol | |
272 | #endif | |
273 | ) const | |
274 | { | |
275 | #ifndef No_Exception | |
276 | Standard_Real Eps = Precision::PConfusion(); | |
277 | #endif | |
278 | Standard_OutOfRange_Raise_if | |
279 | ( Abs(First) > Eps || Abs(Last - 2.*PI) > Eps, | |
280 | "Adaptor3d_SurfaceOfRevolution : UTrim : Parameters out of range"); | |
281 | ||
282 | Handle(Adaptor3d_HSurfaceOfRevolution) HR = | |
283 | new Adaptor3d_HSurfaceOfRevolution(*this); | |
284 | return HR; | |
285 | } | |
286 | ||
287 | ||
288 | //======================================================================= | |
289 | //function : VTrim | |
290 | //purpose : | |
291 | //======================================================================= | |
292 | ||
293 | Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfRevolution::VTrim | |
294 | (const Standard_Real First, | |
295 | const Standard_Real Last, | |
296 | const Standard_Real Tol) const | |
297 | { | |
298 | Handle(Adaptor3d_HSurfaceOfRevolution) HR = | |
299 | new Adaptor3d_HSurfaceOfRevolution(*this); | |
300 | Handle(Adaptor3d_HCurve) HC = BasisCurve()->Trim(First,Last,Tol); | |
301 | HR->ChangeSurface(). | |
302 | Load(HC); | |
303 | return HR; | |
304 | } | |
305 | ||
306 | ||
307 | //======================================================================= | |
308 | //function : IsUClosed | |
309 | //purpose : | |
310 | //======================================================================= | |
311 | ||
312 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsUClosed() const | |
313 | { | |
314 | return Standard_True; | |
315 | } | |
316 | ||
317 | //======================================================================= | |
318 | //function : IsVClosed | |
319 | //purpose : | |
320 | //======================================================================= | |
321 | ||
322 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVClosed() const | |
323 | { | |
324 | return myBasisCurve->IsClosed(); | |
325 | } | |
326 | ||
327 | //======================================================================= | |
328 | //function : IsUPeriodic | |
329 | //purpose : | |
330 | //======================================================================= | |
331 | ||
332 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsUPeriodic() const | |
333 | { | |
334 | return Standard_True; | |
335 | } | |
336 | ||
337 | //======================================================================= | |
338 | //function : UPeriod | |
339 | //purpose : | |
340 | //======================================================================= | |
341 | ||
342 | Standard_Real Adaptor3d_SurfaceOfRevolution::UPeriod() const | |
343 | { | |
344 | return 2*PI; | |
345 | } | |
346 | ||
347 | //======================================================================= | |
348 | //function : IsVPeriodic | |
349 | //purpose : | |
350 | //======================================================================= | |
351 | ||
352 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVPeriodic() const | |
353 | { | |
354 | return myBasisCurve->IsPeriodic(); | |
355 | } | |
356 | ||
357 | //======================================================================= | |
358 | //function : VPeriod | |
359 | //purpose : | |
360 | //======================================================================= | |
361 | ||
362 | Standard_Real Adaptor3d_SurfaceOfRevolution::VPeriod() const | |
363 | { | |
364 | return myBasisCurve->Period(); | |
365 | } | |
366 | ||
367 | //======================================================================= | |
368 | //function : Value | |
369 | //purpose : | |
370 | //======================================================================= | |
371 | ||
372 | gp_Pnt Adaptor3d_SurfaceOfRevolution::Value(const Standard_Real U, | |
373 | const Standard_Real V) const | |
374 | { | |
375 | gp_Pnt P; | |
376 | myBasisCurve->D0(V,P); | |
377 | P.Rotate( myAxis, U); | |
378 | return P; | |
379 | } | |
380 | ||
381 | //======================================================================= | |
382 | //function : D0 | |
383 | //purpose : | |
384 | //======================================================================= | |
385 | ||
386 | void Adaptor3d_SurfaceOfRevolution::D0(const Standard_Real U, | |
387 | const Standard_Real V, | |
388 | gp_Pnt& P) const | |
389 | { | |
390 | myBasisCurve->D0(V,P); | |
391 | P.Rotate( myAxis, U); | |
392 | } | |
393 | ||
394 | //======================================================================= | |
395 | //function : D1 | |
396 | //purpose : | |
397 | //======================================================================= | |
398 | ||
399 | void Adaptor3d_SurfaceOfRevolution::D1(const Standard_Real U, | |
400 | const Standard_Real V, | |
401 | gp_Pnt& P, gp_Vec& D1U, | |
402 | gp_Vec& D1V) const | |
403 | { | |
404 | myBasisCurve->D1(V,P,D1V); | |
405 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
406 | ||
407 | D0( U,V,P); | |
408 | D1V.Rotate( myAxis, U); | |
409 | D1U = R*(myAxeRev.YDirection()); | |
410 | D1U.Rotate( myAxis, U); | |
411 | } | |
412 | ||
413 | //======================================================================= | |
414 | //function : D2 | |
415 | //purpose : | |
416 | //======================================================================= | |
417 | ||
418 | void Adaptor3d_SurfaceOfRevolution::D2(const Standard_Real U, | |
419 | const Standard_Real V, | |
420 | gp_Pnt& P, gp_Vec& D1U, | |
421 | gp_Vec& D1V, | |
422 | gp_Vec& D2U, gp_Vec& D2V, | |
423 | gp_Vec& D2UV) const | |
424 | { | |
425 | myBasisCurve->D2(V,P,D1V,D2V); | |
426 | ||
427 | gp_Vec D1 = (myAxeRev.YDirection()).Rotated( myAxis, U); | |
428 | gp_Vec D2 = (myAxeRev.XDirection()).Rotated( myAxis, U); | |
429 | ||
430 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
431 | Standard_Real D1R = D1V * myAxeRev.XDirection(); // D1R = dR/dV | |
432 | // et R=AP*XDirection | |
433 | ||
434 | D0( U,V,P); | |
435 | D1V.Rotate( myAxis, U); | |
436 | D2V.Rotate( myAxis, U); | |
437 | D1U = R * D1; | |
438 | D2U = -R * D2; | |
439 | D2UV = D1R * D1; | |
440 | } | |
441 | ||
442 | //======================================================================= | |
443 | //function : D3 | |
444 | //purpose : | |
445 | //======================================================================= | |
446 | ||
447 | void Adaptor3d_SurfaceOfRevolution::D3(const Standard_Real U, | |
448 | const Standard_Real V, | |
449 | gp_Pnt& P,gp_Vec& D1U, gp_Vec& D1V, | |
450 | gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, | |
451 | gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, | |
452 | gp_Vec& D3UVV) const | |
453 | { | |
454 | myBasisCurve->D3(V,P,D1V,D2V,D3V); | |
455 | ||
456 | gp_Vec D1 = (myAxeRev.YDirection()).Rotated( myAxis, U); | |
457 | gp_Vec D2 = (myAxeRev.XDirection()).Rotated( myAxis, U); | |
458 | ||
459 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
460 | Standard_Real D1R = D1V * myAxeRev.XDirection(); // D1R = dR/dV et | |
461 | // R=AP*XDirection | |
462 | Standard_Real D2R = D2V * myAxeRev.XDirection(); | |
463 | ||
464 | D0( U,V,P); | |
465 | D1V.Rotate( myAxis, U); | |
466 | D2V.Rotate( myAxis, U); | |
467 | D3V.Rotate( myAxis, U); | |
468 | D1U = R * D1; | |
469 | D2U = -R * D2; | |
470 | D3U = -R * D1; | |
471 | D2UV = D1R * D1; | |
472 | D3UUV = -D1R * D2; | |
473 | D3UVV = D2R * D1; | |
474 | } | |
475 | ||
476 | //======================================================================= | |
477 | //function : DN | |
478 | //purpose : | |
479 | //======================================================================= | |
480 | ||
481 | gp_Vec Adaptor3d_SurfaceOfRevolution::DN(const Standard_Real U, | |
482 | const Standard_Real V, | |
483 | const Standard_Integer NU, | |
484 | const Standard_Integer NV) const | |
485 | { | |
486 | if ( (NU+NV)<1 || NU<0 || NV<0) { | |
487 | Standard_DomainError::Raise("Adaptor3d_SurfaceOfRevolution::DN"); | |
488 | } | |
489 | else { | |
490 | gp_Vec DNv = myBasisCurve->DN( V, NV); | |
491 | if ( NU == 0) { | |
492 | return DNv.Rotated( myAxis, U); | |
493 | } | |
494 | else { | |
495 | Standard_Real DNR = DNv * myAxeRev.XDirection(); | |
496 | gp_Vec DNu = ( myAxeRev.XDirection()).Rotated( myAxis, U + NU*PI/2); | |
497 | return ( DNR * DNu); | |
498 | } | |
499 | } | |
500 | // portage WNT | |
501 | return gp_Vec(); | |
502 | } | |
503 | ||
504 | //======================================================================= | |
505 | //function : UResolution | |
506 | //purpose : | |
507 | //======================================================================= | |
508 | ||
509 | Standard_Real Adaptor3d_SurfaceOfRevolution::UResolution | |
510 | (const Standard_Real R3d) const | |
511 | { | |
512 | return Precision::Parametric(R3d); | |
513 | } | |
514 | ||
515 | //======================================================================= | |
516 | //function : VResolution | |
517 | //purpose : | |
518 | //======================================================================= | |
519 | ||
520 | Standard_Real Adaptor3d_SurfaceOfRevolution::VResolution | |
521 | (const Standard_Real R3d) const | |
522 | { | |
523 | return myBasisCurve->Resolution(R3d); | |
524 | } | |
525 | ||
526 | //======================================================================= | |
527 | //function : GetType | |
528 | //purpose : | |
529 | //======================================================================= | |
530 | ||
531 | GeomAbs_SurfaceType Adaptor3d_SurfaceOfRevolution::GetType() const | |
532 | { | |
bd05fabf S |
533 | Standard_Real TolConf, TolAng; |
534 | GeomAbs_SurfaceType bRet; | |
535 | // | |
536 | bRet=GeomAbs_SurfaceOfRevolution; | |
537 | TolConf = Precision::Confusion(); | |
538 | TolAng = Precision::Angular(); | |
539 | // | |
7fd59977 | 540 | switch ( myBasisCurve->GetType()) { |
bd05fabf S |
541 | case GeomAbs_Line: { |
542 | const gp_Ax1& Axe = (myBasisCurve->Line()).Position(); | |
7fd59977 | 543 | |
bd05fabf S |
544 | if (myAxis.IsParallel(Axe, TolAng)) { |
545 | bRet=GeomAbs_Cylinder; | |
546 | return bRet; | |
547 | } | |
548 | else if (myAxis.IsNormal( Axe, TolAng)) { | |
549 | bRet=GeomAbs_Plane; | |
550 | return bRet; | |
551 | } | |
552 | else { | |
553 | Standard_Real uf = myBasisCurve->FirstParameter(); | |
554 | Standard_Real ul = myBasisCurve->LastParameter(); | |
555 | Standard_Boolean istrim = (!Precision::IsInfinite(uf) && | |
556 | !Precision::IsInfinite(ul)); | |
557 | if(istrim){ | |
558 | gp_Pnt pf = myBasisCurve->Value(uf); | |
559 | gp_Pnt pl = myBasisCurve->Value(ul); | |
560 | Standard_Real len = pf.Distance(pl); | |
561 | //on calcule la distance projetee sur l axe. | |
562 | gp_Vec vlin(pf,pl); | |
563 | gp_Vec vaxe(myAxis.Direction()); | |
564 | Standard_Real projlen = Abs(vaxe.Dot(vlin)); | |
565 | Standard_Real aTolConf = len*TolAng; | |
566 | if ((len - projlen) <= aTolConf) { | |
567 | bRet=GeomAbs_Cylinder; | |
568 | return bRet; | |
7fd59977 | 569 | } |
bd05fabf S |
570 | else if (projlen <= aTolConf) { |
571 | bRet=GeomAbs_Plane; | |
572 | return bRet; | |
7fd59977 | 573 | } |
574 | } | |
bd05fabf S |
575 | gp_Vec V(myAxis.Location(), |
576 | myBasisCurve->Line().Location()); | |
577 | gp_Vec W(Axe.Direction()); | |
578 | if (Abs(V.DotCross(myAxis.Direction(),W)) <= TolConf){ | |
579 | bRet=GeomAbs_Cone; | |
580 | return bRet; | |
7fd59977 | 581 | } |
582 | else { | |
bd05fabf | 583 | return bRet; |
7fd59977 | 584 | } |
7fd59977 | 585 | } |
bd05fabf S |
586 | break; |
587 | }//case GeomAbs_Line: | |
588 | // | |
589 | case GeomAbs_Circle: { | |
7fd59977 | 590 | |
bd05fabf S |
591 | Standard_Real MajorRadius, aR; |
592 | gp_Lin aLin(myAxis); | |
593 | // | |
594 | const gp_Circ& C=myBasisCurve->Circle(); | |
595 | const gp_Pnt& aLC=C.Location(); | |
596 | aR=C.Radius(); | |
597 | // | |
598 | ||
599 | if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) { | |
600 | return bRet; | |
601 | } | |
602 | else if(aLin.Distance(aLC) <= TolConf) { | |
603 | bRet=GeomAbs_Sphere; | |
604 | return bRet; | |
605 | } | |
606 | else { | |
607 | MajorRadius = aLin.Distance(aLC); | |
608 | if(MajorRadius>aR) { | |
609 | //modified by NIZNHY-PKV Thu Feb 24 09:46:29 2011f | |
610 | Standard_Real aT, aDx, dX; | |
611 | gp_Pnt aPx; | |
612 | // | |
613 | aT=0.; | |
614 | aPx=ElCLib::Value(aT, C); | |
615 | aDx=aLin.Distance(aPx); | |
616 | dX=aDx-MajorRadius-aR; | |
617 | if (dX<0.) { | |
618 | dX=-dX; | |
619 | } | |
620 | if (dX<TolConf) { | |
621 | bRet=GeomAbs_Torus; | |
622 | } | |
623 | //bRet=GeomAbs_Torus; | |
624 | //return bRet; | |
625 | //modified by NIZNHY-PKV Thu Feb 24 09:52:29 2011t | |
626 | } | |
627 | return bRet; | |
628 | } | |
629 | break; | |
630 | } | |
631 | // | |
7fd59977 | 632 | default: |
bd05fabf | 633 | break; |
7fd59977 | 634 | } |
635 | ||
bd05fabf | 636 | return bRet; |
7fd59977 | 637 | } |
638 | ||
639 | //======================================================================= | |
640 | //function : Plane | |
641 | //purpose : | |
642 | //======================================================================= | |
643 | ||
644 | gp_Pln Adaptor3d_SurfaceOfRevolution::Plane() const | |
645 | { | |
646 | Standard_NoSuchObject_Raise_if | |
647 | (GetType() != GeomAbs_Plane, "Adaptor3d_SurfaceOfRevolution:Plane"); | |
648 | ||
649 | gp_Ax3 Axe = myAxeRev; | |
650 | gp_Pnt P; | |
651 | ||
652 | // P = Projection du Point Debut de la generatrice sur l axe de rotation. | |
653 | P.SetXYZ((myAxis.Location()).XYZ() + | |
654 | (Value(0.,0.).XYZ()-(myAxis.Location()).XYZ()). | |
655 | Dot((myAxis.Direction()).XYZ()) | |
656 | *(myAxis.Direction()).XYZ()); | |
657 | Axe.SetLocation( P); | |
658 | //// modified by jgv, 8.01.03 for OCC1226 //// | |
659 | if (Axe.XDirection(). | |
660 | Dot(myBasisCurve->Line().Direction()) >= -Precision::Confusion()) // > 0. | |
661 | Axe.XReverse(); | |
662 | ////////////////////////////////////////////// | |
663 | ||
664 | return gp_Pln( Axe); | |
665 | } | |
666 | ||
667 | //======================================================================= | |
668 | //function : Cylinder | |
669 | //purpose : | |
670 | //======================================================================= | |
671 | ||
672 | gp_Cylinder Adaptor3d_SurfaceOfRevolution::Cylinder() const | |
673 | { | |
674 | Standard_NoSuchObject_Raise_if | |
675 | (GetType() != GeomAbs_Cylinder, "Adaptor3d_SurfaceOfRevolution::Cylinder"); | |
676 | ||
677 | gp_Pnt P = Value( 0., 0.); | |
678 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
679 | return gp_Cylinder( myAxeRev, R); | |
680 | } | |
681 | ||
682 | //======================================================================= | |
683 | //function : Cone | |
684 | //purpose : | |
685 | //======================================================================= | |
686 | ||
687 | gp_Cone Adaptor3d_SurfaceOfRevolution::Cone() const | |
688 | { | |
689 | Standard_NoSuchObject_Raise_if | |
690 | ( GetType() != GeomAbs_Cone, "Adaptor3d_SurfaceOfRevolution:Cone"); | |
691 | ||
692 | gp_Ax3 Axe = myAxeRev; | |
693 | gp_Dir ldir = (myBasisCurve->Line()).Direction(); | |
694 | Standard_Real Angle = (Axe.Direction()).Angle(ldir); | |
695 | gp_Pnt P0 = Value(0., 0.); | |
696 | Standard_Real R = (Axe.Location()).Distance(P0); | |
697 | if ( R >= Precision::Confusion()) { | |
698 | gp_Pnt O = Axe.Location(); | |
699 | gp_Vec OP0(O,P0); | |
700 | Standard_Real t = OP0.Dot(Axe.XDirection()); | |
701 | t /= ldir.Dot(Axe.XDirection()); | |
702 | OP0.Add(-t * gp_Vec(ldir)); | |
703 | if ( OP0.Dot(Axe.Direction()) > 0.) Angle = -Angle; | |
704 | } | |
705 | return gp_Cone( Axe, Angle, R); | |
706 | } | |
707 | ||
708 | ||
709 | //======================================================================= | |
710 | //function : Sphere | |
711 | //purpose : | |
712 | //======================================================================= | |
713 | ||
714 | gp_Sphere Adaptor3d_SurfaceOfRevolution::Sphere() const | |
715 | { | |
716 | Standard_NoSuchObject_Raise_if | |
717 | ( GetType() != GeomAbs_Sphere, "Adaptor3d_SurfaceOfRevolution:Sphere"); | |
718 | ||
719 | gp_Circ C = myBasisCurve->Circle(); | |
720 | gp_Ax3 Axe = myAxeRev; | |
721 | Axe.SetLocation( C.Location()); | |
722 | return gp_Sphere( Axe, C.Radius()); | |
723 | } | |
724 | ||
725 | ||
726 | //======================================================================= | |
727 | //function : Torus | |
728 | //purpose : | |
729 | //======================================================================= | |
730 | ||
731 | gp_Torus Adaptor3d_SurfaceOfRevolution::Torus() const | |
732 | { | |
733 | Standard_NoSuchObject_Raise_if | |
734 | (GetType() != GeomAbs_Torus, "Adaptor3d_SurfaceOfRevolution:Torus"); | |
735 | ||
736 | gp_Circ C = myBasisCurve->Circle(); | |
737 | Standard_Real MajorRadius = gp_Lin(myAxis).Distance(C.Location()); | |
738 | return gp_Torus( myAxeRev, MajorRadius, C.Radius()); | |
739 | } | |
740 | ||
741 | //======================================================================= | |
742 | //function : UDegree | |
743 | //purpose : | |
744 | //======================================================================= | |
745 | ||
746 | Standard_Integer Adaptor3d_SurfaceOfRevolution::UDegree() const | |
747 | { | |
748 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::UDegree"); | |
749 | return 0; | |
750 | } | |
751 | ||
752 | //======================================================================= | |
753 | //function : NbUPoles | |
754 | //purpose : | |
755 | //======================================================================= | |
756 | ||
757 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUPoles() const | |
758 | { | |
759 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbUPoles"); | |
760 | return 0; | |
761 | } | |
762 | ||
763 | //======================================================================= | |
764 | //function : VDegree | |
765 | //purpose : | |
766 | //======================================================================= | |
767 | ||
768 | Standard_Integer Adaptor3d_SurfaceOfRevolution::VDegree() const | |
769 | { | |
770 | return myBasisCurve->Degree(); | |
771 | } | |
772 | ||
773 | //======================================================================= | |
774 | //function : NbVPoles | |
775 | //purpose : | |
776 | //======================================================================= | |
777 | ||
778 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVPoles() const | |
779 | { | |
780 | return myBasisCurve -> NbPoles(); | |
781 | } | |
782 | ||
783 | //======================================================================= | |
784 | //function : NbUKnots | |
785 | //purpose : | |
786 | //======================================================================= | |
787 | ||
788 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUKnots() const | |
789 | { | |
790 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbUKnots"); | |
791 | return 0; | |
792 | } | |
793 | ||
794 | ||
795 | //======================================================================= | |
796 | //function : NbVKnots | |
797 | //purpose : | |
798 | //======================================================================= | |
799 | ||
800 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVKnots() const | |
801 | { | |
802 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbVKnots"); | |
803 | return 0; | |
804 | } | |
805 | ||
806 | ||
807 | ||
808 | //======================================================================= | |
809 | //function : IsURational | |
810 | //purpose : | |
811 | //======================================================================= | |
812 | ||
813 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsURational() const | |
814 | { | |
815 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::IsURational"); | |
816 | return Standard_False; | |
817 | } | |
818 | ||
819 | //======================================================================= | |
820 | //function : IsVRational | |
821 | //purpose : | |
822 | //======================================================================= | |
823 | ||
824 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVRational() const | |
825 | { | |
826 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::IsVRational"); | |
827 | return Standard_False; | |
828 | } | |
829 | ||
830 | ||
831 | //======================================================================= | |
832 | //function : Bezier | |
833 | //purpose : | |
834 | //======================================================================= | |
835 | ||
836 | Handle(Geom_BezierSurface) Adaptor3d_SurfaceOfRevolution::Bezier() const | |
837 | { | |
838 | Standard_NoSuchObject::Raise(""); | |
839 | Handle(Geom_BezierSurface) Dummy; | |
840 | return Dummy; | |
841 | } | |
842 | ||
843 | ||
844 | //======================================================================= | |
845 | //function : BSpline | |
846 | //purpose : | |
847 | //======================================================================= | |
848 | ||
849 | Handle(Geom_BSplineSurface) Adaptor3d_SurfaceOfRevolution::BSpline() const | |
850 | { | |
851 | Standard_NoSuchObject::Raise(""); | |
852 | Handle(Geom_BSplineSurface) Dummy; | |
853 | return Dummy; | |
854 | } | |
855 | ||
856 | ||
857 | //======================================================================= | |
858 | //function : Axis | |
859 | //purpose : | |
860 | //======================================================================= | |
861 | ||
862 | gp_Ax3 Adaptor3d_SurfaceOfRevolution::Axis() const | |
863 | { | |
864 | return myAxeRev; | |
865 | } | |
866 | ||
867 | //======================================================================= | |
868 | //function : Direction | |
869 | //purpose : | |
870 | //======================================================================= | |
871 | ||
872 | gp_Dir Adaptor3d_SurfaceOfRevolution::Direction() const | |
873 | { | |
874 | Standard_NoSuchObject::Raise(""); | |
875 | return gp_Dir(); | |
876 | } | |
877 | ||
878 | ||
879 | //======================================================================= | |
880 | //function : BasisCurve | |
881 | //purpose : | |
882 | //======================================================================= | |
883 | ||
884 | Handle(Adaptor3d_HCurve) Adaptor3d_SurfaceOfRevolution::BasisCurve() const | |
885 | { | |
886 | return myBasisCurve; | |
887 | } |