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