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 | |
286 | #ifndef No_Exception | |
287 | Tol | |
288 | #endif | |
289 | ) const | |
290 | { | |
291 | #ifndef No_Exception | |
292 | Standard_Real Eps = Precision::PConfusion(); | |
293 | #endif | |
294 | Standard_OutOfRange_Raise_if | |
c6541a0c | 295 | ( Abs(First) > Eps || Abs(Last - 2.*M_PI) > Eps, |
7fd59977 | 296 | "Adaptor3d_SurfaceOfRevolution : UTrim : Parameters out of range"); |
297 | ||
298 | Handle(Adaptor3d_HSurfaceOfRevolution) HR = | |
299 | new Adaptor3d_HSurfaceOfRevolution(*this); | |
300 | return HR; | |
301 | } | |
302 | ||
303 | ||
304 | //======================================================================= | |
305 | //function : VTrim | |
306 | //purpose : | |
307 | //======================================================================= | |
308 | ||
309 | Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfRevolution::VTrim | |
310 | (const Standard_Real First, | |
311 | const Standard_Real Last, | |
312 | const Standard_Real Tol) const | |
313 | { | |
314 | Handle(Adaptor3d_HSurfaceOfRevolution) HR = | |
315 | new Adaptor3d_HSurfaceOfRevolution(*this); | |
316 | Handle(Adaptor3d_HCurve) HC = BasisCurve()->Trim(First,Last,Tol); | |
317 | HR->ChangeSurface(). | |
318 | Load(HC); | |
319 | return HR; | |
320 | } | |
321 | ||
322 | ||
323 | //======================================================================= | |
324 | //function : IsUClosed | |
325 | //purpose : | |
326 | //======================================================================= | |
327 | ||
328 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsUClosed() const | |
329 | { | |
330 | return Standard_True; | |
331 | } | |
332 | ||
333 | //======================================================================= | |
334 | //function : IsVClosed | |
335 | //purpose : | |
336 | //======================================================================= | |
337 | ||
338 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVClosed() const | |
339 | { | |
340 | return myBasisCurve->IsClosed(); | |
341 | } | |
342 | ||
343 | //======================================================================= | |
344 | //function : IsUPeriodic | |
345 | //purpose : | |
346 | //======================================================================= | |
347 | ||
348 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsUPeriodic() const | |
349 | { | |
350 | return Standard_True; | |
351 | } | |
352 | ||
353 | //======================================================================= | |
354 | //function : UPeriod | |
355 | //purpose : | |
356 | //======================================================================= | |
357 | ||
358 | Standard_Real Adaptor3d_SurfaceOfRevolution::UPeriod() const | |
359 | { | |
c6541a0c | 360 | return 2*M_PI; |
7fd59977 | 361 | } |
362 | ||
363 | //======================================================================= | |
364 | //function : IsVPeriodic | |
365 | //purpose : | |
366 | //======================================================================= | |
367 | ||
368 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVPeriodic() const | |
369 | { | |
370 | return myBasisCurve->IsPeriodic(); | |
371 | } | |
372 | ||
373 | //======================================================================= | |
374 | //function : VPeriod | |
375 | //purpose : | |
376 | //======================================================================= | |
377 | ||
378 | Standard_Real Adaptor3d_SurfaceOfRevolution::VPeriod() const | |
379 | { | |
380 | return myBasisCurve->Period(); | |
381 | } | |
382 | ||
383 | //======================================================================= | |
384 | //function : Value | |
385 | //purpose : | |
386 | //======================================================================= | |
387 | ||
388 | gp_Pnt Adaptor3d_SurfaceOfRevolution::Value(const Standard_Real U, | |
389 | const Standard_Real V) const | |
390 | { | |
391 | gp_Pnt P; | |
392 | myBasisCurve->D0(V,P); | |
393 | P.Rotate( myAxis, U); | |
394 | return P; | |
395 | } | |
396 | ||
397 | //======================================================================= | |
398 | //function : D0 | |
399 | //purpose : | |
400 | //======================================================================= | |
401 | ||
402 | void Adaptor3d_SurfaceOfRevolution::D0(const Standard_Real U, | |
403 | const Standard_Real V, | |
404 | gp_Pnt& P) const | |
405 | { | |
406 | myBasisCurve->D0(V,P); | |
407 | P.Rotate( myAxis, U); | |
408 | } | |
409 | ||
410 | //======================================================================= | |
411 | //function : D1 | |
412 | //purpose : | |
413 | //======================================================================= | |
414 | ||
415 | void Adaptor3d_SurfaceOfRevolution::D1(const Standard_Real U, | |
416 | const Standard_Real V, | |
417 | gp_Pnt& P, gp_Vec& D1U, | |
418 | gp_Vec& D1V) const | |
419 | { | |
420 | myBasisCurve->D1(V,P,D1V); | |
421 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
422 | ||
423 | D0( U,V,P); | |
424 | D1V.Rotate( myAxis, U); | |
425 | D1U = R*(myAxeRev.YDirection()); | |
426 | D1U.Rotate( myAxis, U); | |
427 | } | |
428 | ||
429 | //======================================================================= | |
430 | //function : D2 | |
431 | //purpose : | |
432 | //======================================================================= | |
433 | ||
434 | void Adaptor3d_SurfaceOfRevolution::D2(const Standard_Real U, | |
435 | const Standard_Real V, | |
436 | gp_Pnt& P, gp_Vec& D1U, | |
437 | gp_Vec& D1V, | |
438 | gp_Vec& D2U, gp_Vec& D2V, | |
439 | gp_Vec& D2UV) const | |
440 | { | |
441 | myBasisCurve->D2(V,P,D1V,D2V); | |
442 | ||
443 | gp_Vec D1 = (myAxeRev.YDirection()).Rotated( myAxis, U); | |
444 | gp_Vec D2 = (myAxeRev.XDirection()).Rotated( myAxis, U); | |
445 | ||
446 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
447 | Standard_Real D1R = D1V * myAxeRev.XDirection(); // D1R = dR/dV | |
448 | // et R=AP*XDirection | |
449 | ||
450 | D0( U,V,P); | |
451 | D1V.Rotate( myAxis, U); | |
452 | D2V.Rotate( myAxis, U); | |
453 | D1U = R * D1; | |
454 | D2U = -R * D2; | |
455 | D2UV = D1R * D1; | |
456 | } | |
457 | ||
458 | //======================================================================= | |
459 | //function : D3 | |
460 | //purpose : | |
461 | //======================================================================= | |
462 | ||
463 | void Adaptor3d_SurfaceOfRevolution::D3(const Standard_Real U, | |
464 | const Standard_Real V, | |
465 | gp_Pnt& P,gp_Vec& D1U, gp_Vec& D1V, | |
466 | gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, | |
467 | gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, | |
468 | gp_Vec& D3UVV) const | |
469 | { | |
470 | myBasisCurve->D3(V,P,D1V,D2V,D3V); | |
471 | ||
472 | gp_Vec D1 = (myAxeRev.YDirection()).Rotated( myAxis, U); | |
473 | gp_Vec D2 = (myAxeRev.XDirection()).Rotated( myAxis, U); | |
474 | ||
475 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
476 | Standard_Real D1R = D1V * myAxeRev.XDirection(); // D1R = dR/dV et | |
477 | // R=AP*XDirection | |
478 | Standard_Real D2R = D2V * myAxeRev.XDirection(); | |
479 | ||
480 | D0( U,V,P); | |
481 | D1V.Rotate( myAxis, U); | |
482 | D2V.Rotate( myAxis, U); | |
483 | D3V.Rotate( myAxis, U); | |
484 | D1U = R * D1; | |
485 | D2U = -R * D2; | |
486 | D3U = -R * D1; | |
487 | D2UV = D1R * D1; | |
488 | D3UUV = -D1R * D2; | |
489 | D3UVV = D2R * D1; | |
490 | } | |
491 | ||
492 | //======================================================================= | |
493 | //function : DN | |
494 | //purpose : | |
495 | //======================================================================= | |
496 | ||
497 | gp_Vec Adaptor3d_SurfaceOfRevolution::DN(const Standard_Real U, | |
498 | const Standard_Real V, | |
499 | const Standard_Integer NU, | |
500 | const Standard_Integer NV) const | |
501 | { | |
502 | if ( (NU+NV)<1 || NU<0 || NV<0) { | |
503 | Standard_DomainError::Raise("Adaptor3d_SurfaceOfRevolution::DN"); | |
504 | } | |
505 | else { | |
506 | gp_Vec DNv = myBasisCurve->DN( V, NV); | |
507 | if ( NU == 0) { | |
508 | return DNv.Rotated( myAxis, U); | |
509 | } | |
510 | else { | |
511 | Standard_Real DNR = DNv * myAxeRev.XDirection(); | |
c6541a0c | 512 | gp_Vec DNu = ( myAxeRev.XDirection()).Rotated( myAxis, U + NU*M_PI/2); |
7fd59977 | 513 | return ( DNR * DNu); |
514 | } | |
515 | } | |
516 | // portage WNT | |
517 | return gp_Vec(); | |
518 | } | |
519 | ||
520 | //======================================================================= | |
521 | //function : UResolution | |
522 | //purpose : | |
523 | //======================================================================= | |
524 | ||
525 | Standard_Real Adaptor3d_SurfaceOfRevolution::UResolution | |
526 | (const Standard_Real R3d) const | |
527 | { | |
528 | return Precision::Parametric(R3d); | |
529 | } | |
530 | ||
531 | //======================================================================= | |
532 | //function : VResolution | |
533 | //purpose : | |
534 | //======================================================================= | |
535 | ||
536 | Standard_Real Adaptor3d_SurfaceOfRevolution::VResolution | |
537 | (const Standard_Real R3d) const | |
538 | { | |
539 | return myBasisCurve->Resolution(R3d); | |
540 | } | |
541 | ||
542 | //======================================================================= | |
543 | //function : GetType | |
544 | //purpose : | |
545 | //======================================================================= | |
546 | ||
547 | GeomAbs_SurfaceType Adaptor3d_SurfaceOfRevolution::GetType() const | |
548 | { | |
bd05fabf S |
549 | Standard_Real TolConf, TolAng; |
550 | GeomAbs_SurfaceType bRet; | |
551 | // | |
552 | bRet=GeomAbs_SurfaceOfRevolution; | |
553 | TolConf = Precision::Confusion(); | |
554 | TolAng = Precision::Angular(); | |
555 | // | |
7fd59977 | 556 | switch ( myBasisCurve->GetType()) { |
bd05fabf S |
557 | case GeomAbs_Line: { |
558 | const gp_Ax1& Axe = (myBasisCurve->Line()).Position(); | |
7fd59977 | 559 | |
bd05fabf S |
560 | if (myAxis.IsParallel(Axe, TolAng)) { |
561 | bRet=GeomAbs_Cylinder; | |
562 | return bRet; | |
563 | } | |
564 | else if (myAxis.IsNormal( Axe, TolAng)) { | |
565 | bRet=GeomAbs_Plane; | |
566 | return bRet; | |
567 | } | |
568 | else { | |
569 | Standard_Real uf = myBasisCurve->FirstParameter(); | |
570 | Standard_Real ul = myBasisCurve->LastParameter(); | |
571 | Standard_Boolean istrim = (!Precision::IsInfinite(uf) && | |
572 | !Precision::IsInfinite(ul)); | |
573 | if(istrim){ | |
574 | gp_Pnt pf = myBasisCurve->Value(uf); | |
575 | gp_Pnt pl = myBasisCurve->Value(ul); | |
576 | Standard_Real len = pf.Distance(pl); | |
577 | //on calcule la distance projetee sur l axe. | |
578 | gp_Vec vlin(pf,pl); | |
579 | gp_Vec vaxe(myAxis.Direction()); | |
580 | Standard_Real projlen = Abs(vaxe.Dot(vlin)); | |
581 | Standard_Real aTolConf = len*TolAng; | |
582 | if ((len - projlen) <= aTolConf) { | |
583 | bRet=GeomAbs_Cylinder; | |
584 | return bRet; | |
7fd59977 | 585 | } |
bd05fabf S |
586 | else if (projlen <= aTolConf) { |
587 | bRet=GeomAbs_Plane; | |
588 | return bRet; | |
7fd59977 | 589 | } |
590 | } | |
bd05fabf S |
591 | gp_Vec V(myAxis.Location(), |
592 | myBasisCurve->Line().Location()); | |
593 | gp_Vec W(Axe.Direction()); | |
594 | if (Abs(V.DotCross(myAxis.Direction(),W)) <= TolConf){ | |
595 | bRet=GeomAbs_Cone; | |
596 | return bRet; | |
7fd59977 | 597 | } |
598 | else { | |
bd05fabf | 599 | return bRet; |
7fd59977 | 600 | } |
7fd59977 | 601 | } |
bd05fabf S |
602 | break; |
603 | }//case GeomAbs_Line: | |
604 | // | |
605 | case GeomAbs_Circle: { | |
7fd59977 | 606 | |
bd05fabf S |
607 | Standard_Real MajorRadius, aR; |
608 | gp_Lin aLin(myAxis); | |
609 | // | |
610 | const gp_Circ& C=myBasisCurve->Circle(); | |
611 | const gp_Pnt& aLC=C.Location(); | |
612 | aR=C.Radius(); | |
613 | // | |
614 | ||
615 | if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) { | |
616 | return bRet; | |
617 | } | |
618 | else if(aLin.Distance(aLC) <= TolConf) { | |
619 | bRet=GeomAbs_Sphere; | |
620 | return bRet; | |
621 | } | |
622 | else { | |
623 | MajorRadius = aLin.Distance(aLC); | |
624 | if(MajorRadius>aR) { | |
625 | //modified by NIZNHY-PKV Thu Feb 24 09:46:29 2011f | |
626 | Standard_Real aT, aDx, dX; | |
627 | gp_Pnt aPx; | |
628 | // | |
629 | aT=0.; | |
630 | aPx=ElCLib::Value(aT, C); | |
631 | aDx=aLin.Distance(aPx); | |
632 | dX=aDx-MajorRadius-aR; | |
633 | if (dX<0.) { | |
634 | dX=-dX; | |
635 | } | |
636 | if (dX<TolConf) { | |
637 | bRet=GeomAbs_Torus; | |
638 | } | |
639 | //bRet=GeomAbs_Torus; | |
640 | //return bRet; | |
641 | //modified by NIZNHY-PKV Thu Feb 24 09:52:29 2011t | |
642 | } | |
643 | return bRet; | |
644 | } | |
645 | break; | |
646 | } | |
647 | // | |
7fd59977 | 648 | default: |
bd05fabf | 649 | break; |
7fd59977 | 650 | } |
651 | ||
bd05fabf | 652 | return bRet; |
7fd59977 | 653 | } |
654 | ||
655 | //======================================================================= | |
656 | //function : Plane | |
657 | //purpose : | |
658 | //======================================================================= | |
659 | ||
660 | gp_Pln Adaptor3d_SurfaceOfRevolution::Plane() const | |
661 | { | |
662 | Standard_NoSuchObject_Raise_if | |
663 | (GetType() != GeomAbs_Plane, "Adaptor3d_SurfaceOfRevolution:Plane"); | |
664 | ||
665 | gp_Ax3 Axe = myAxeRev; | |
666 | gp_Pnt P; | |
667 | ||
668 | // P = Projection du Point Debut de la generatrice sur l axe de rotation. | |
669 | P.SetXYZ((myAxis.Location()).XYZ() + | |
670 | (Value(0.,0.).XYZ()-(myAxis.Location()).XYZ()). | |
671 | Dot((myAxis.Direction()).XYZ()) | |
672 | *(myAxis.Direction()).XYZ()); | |
673 | Axe.SetLocation( P); | |
674 | //// modified by jgv, 8.01.03 for OCC1226 //// | |
675 | if (Axe.XDirection(). | |
676 | Dot(myBasisCurve->Line().Direction()) >= -Precision::Confusion()) // > 0. | |
677 | Axe.XReverse(); | |
678 | ////////////////////////////////////////////// | |
679 | ||
680 | return gp_Pln( Axe); | |
681 | } | |
682 | ||
683 | //======================================================================= | |
684 | //function : Cylinder | |
685 | //purpose : | |
686 | //======================================================================= | |
687 | ||
688 | gp_Cylinder Adaptor3d_SurfaceOfRevolution::Cylinder() const | |
689 | { | |
690 | Standard_NoSuchObject_Raise_if | |
691 | (GetType() != GeomAbs_Cylinder, "Adaptor3d_SurfaceOfRevolution::Cylinder"); | |
692 | ||
693 | gp_Pnt P = Value( 0., 0.); | |
694 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
695 | return gp_Cylinder( myAxeRev, R); | |
696 | } | |
697 | ||
698 | //======================================================================= | |
699 | //function : Cone | |
700 | //purpose : | |
701 | //======================================================================= | |
702 | ||
703 | gp_Cone Adaptor3d_SurfaceOfRevolution::Cone() const | |
704 | { | |
705 | Standard_NoSuchObject_Raise_if | |
706 | ( GetType() != GeomAbs_Cone, "Adaptor3d_SurfaceOfRevolution:Cone"); | |
707 | ||
708 | gp_Ax3 Axe = myAxeRev; | |
709 | gp_Dir ldir = (myBasisCurve->Line()).Direction(); | |
710 | Standard_Real Angle = (Axe.Direction()).Angle(ldir); | |
711 | gp_Pnt P0 = Value(0., 0.); | |
712 | Standard_Real R = (Axe.Location()).Distance(P0); | |
713 | if ( R >= Precision::Confusion()) { | |
714 | gp_Pnt O = Axe.Location(); | |
715 | gp_Vec OP0(O,P0); | |
716 | Standard_Real t = OP0.Dot(Axe.XDirection()); | |
717 | t /= ldir.Dot(Axe.XDirection()); | |
718 | OP0.Add(-t * gp_Vec(ldir)); | |
719 | if ( OP0.Dot(Axe.Direction()) > 0.) Angle = -Angle; | |
720 | } | |
721 | return gp_Cone( Axe, Angle, R); | |
722 | } | |
723 | ||
724 | ||
725 | //======================================================================= | |
726 | //function : Sphere | |
727 | //purpose : | |
728 | //======================================================================= | |
729 | ||
730 | gp_Sphere Adaptor3d_SurfaceOfRevolution::Sphere() const | |
731 | { | |
732 | Standard_NoSuchObject_Raise_if | |
733 | ( GetType() != GeomAbs_Sphere, "Adaptor3d_SurfaceOfRevolution:Sphere"); | |
734 | ||
735 | gp_Circ C = myBasisCurve->Circle(); | |
736 | gp_Ax3 Axe = myAxeRev; | |
737 | Axe.SetLocation( C.Location()); | |
738 | return gp_Sphere( Axe, C.Radius()); | |
739 | } | |
740 | ||
741 | ||
742 | //======================================================================= | |
743 | //function : Torus | |
744 | //purpose : | |
745 | //======================================================================= | |
746 | ||
747 | gp_Torus Adaptor3d_SurfaceOfRevolution::Torus() const | |
748 | { | |
749 | Standard_NoSuchObject_Raise_if | |
750 | (GetType() != GeomAbs_Torus, "Adaptor3d_SurfaceOfRevolution:Torus"); | |
751 | ||
752 | gp_Circ C = myBasisCurve->Circle(); | |
753 | Standard_Real MajorRadius = gp_Lin(myAxis).Distance(C.Location()); | |
754 | return gp_Torus( myAxeRev, MajorRadius, C.Radius()); | |
755 | } | |
756 | ||
757 | //======================================================================= | |
758 | //function : UDegree | |
759 | //purpose : | |
760 | //======================================================================= | |
761 | ||
762 | Standard_Integer Adaptor3d_SurfaceOfRevolution::UDegree() const | |
763 | { | |
764 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::UDegree"); | |
765 | return 0; | |
766 | } | |
767 | ||
768 | //======================================================================= | |
769 | //function : NbUPoles | |
770 | //purpose : | |
771 | //======================================================================= | |
772 | ||
773 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUPoles() const | |
774 | { | |
775 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbUPoles"); | |
776 | return 0; | |
777 | } | |
778 | ||
779 | //======================================================================= | |
780 | //function : VDegree | |
781 | //purpose : | |
782 | //======================================================================= | |
783 | ||
784 | Standard_Integer Adaptor3d_SurfaceOfRevolution::VDegree() const | |
785 | { | |
786 | return myBasisCurve->Degree(); | |
787 | } | |
788 | ||
789 | //======================================================================= | |
790 | //function : NbVPoles | |
791 | //purpose : | |
792 | //======================================================================= | |
793 | ||
794 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVPoles() const | |
795 | { | |
796 | return myBasisCurve -> NbPoles(); | |
797 | } | |
798 | ||
799 | //======================================================================= | |
800 | //function : NbUKnots | |
801 | //purpose : | |
802 | //======================================================================= | |
803 | ||
804 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUKnots() const | |
805 | { | |
806 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbUKnots"); | |
807 | return 0; | |
808 | } | |
809 | ||
810 | ||
811 | //======================================================================= | |
812 | //function : NbVKnots | |
813 | //purpose : | |
814 | //======================================================================= | |
815 | ||
816 | Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVKnots() const | |
817 | { | |
818 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbVKnots"); | |
819 | return 0; | |
820 | } | |
821 | ||
822 | ||
823 | ||
824 | //======================================================================= | |
825 | //function : IsURational | |
826 | //purpose : | |
827 | //======================================================================= | |
828 | ||
829 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsURational() const | |
830 | { | |
831 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::IsURational"); | |
832 | return Standard_False; | |
833 | } | |
834 | ||
835 | //======================================================================= | |
836 | //function : IsVRational | |
837 | //purpose : | |
838 | //======================================================================= | |
839 | ||
840 | Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVRational() const | |
841 | { | |
842 | Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::IsVRational"); | |
843 | return Standard_False; | |
844 | } | |
845 | ||
846 | ||
847 | //======================================================================= | |
848 | //function : Bezier | |
849 | //purpose : | |
850 | //======================================================================= | |
851 | ||
852 | Handle(Geom_BezierSurface) Adaptor3d_SurfaceOfRevolution::Bezier() const | |
853 | { | |
854 | Standard_NoSuchObject::Raise(""); | |
855 | Handle(Geom_BezierSurface) Dummy; | |
856 | return Dummy; | |
857 | } | |
858 | ||
859 | ||
860 | //======================================================================= | |
861 | //function : BSpline | |
862 | //purpose : | |
863 | //======================================================================= | |
864 | ||
865 | Handle(Geom_BSplineSurface) Adaptor3d_SurfaceOfRevolution::BSpline() const | |
866 | { | |
867 | Standard_NoSuchObject::Raise(""); | |
868 | Handle(Geom_BSplineSurface) Dummy; | |
869 | return Dummy; | |
870 | } | |
871 | ||
872 | ||
873 | //======================================================================= | |
874 | //function : Axis | |
875 | //purpose : | |
876 | //======================================================================= | |
877 | ||
878 | gp_Ax3 Adaptor3d_SurfaceOfRevolution::Axis() const | |
879 | { | |
880 | return myAxeRev; | |
881 | } | |
882 | ||
883 | //======================================================================= | |
884 | //function : Direction | |
885 | //purpose : | |
886 | //======================================================================= | |
887 | ||
888 | gp_Dir Adaptor3d_SurfaceOfRevolution::Direction() const | |
889 | { | |
890 | Standard_NoSuchObject::Raise(""); | |
891 | return gp_Dir(); | |
892 | } | |
893 | ||
894 | ||
895 | //======================================================================= | |
896 | //function : BasisCurve | |
897 | //purpose : | |
898 | //======================================================================= | |
899 | ||
900 | Handle(Adaptor3d_HCurve) Adaptor3d_SurfaceOfRevolution::BasisCurve() const | |
901 | { | |
902 | return myBasisCurve; | |
903 | } |