ad27bfc449ade198b67f2295e18ef9f7d6a72aac
[occt.git] / src / Adaptor3d / Adaptor3d_SurfaceOfRevolution.cxx
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
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 {
179   return 2*M_PI;
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.;
255   T(T.Lower()+1) = 2*M_PI;
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                          ) const 
287 {
288 #ifndef No_Exception
289   Standard_Real Eps = Precision::PConfusion();
290 #endif
291   Standard_OutOfRange_Raise_if
292     (  Abs(First) > Eps || Abs(Last - 2.*M_PI) > Eps,
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 {
357   return 2*M_PI;
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();
509       gp_Vec DNu = ( myAxeRev.XDirection()).Rotated( myAxis, U + NU*M_PI/2);
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 {
546   Standard_Real TolConf, TolAng;
547   GeomAbs_SurfaceType bRet;
548   //
549   bRet=GeomAbs_SurfaceOfRevolution;
550   TolConf = Precision::Confusion();
551   TolAng  = Precision::Angular();
552   //
553   switch ( myBasisCurve->GetType()) {
554   case GeomAbs_Line:    {
555     const gp_Ax1& Axe = (myBasisCurve->Line()).Position();
556     
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;
582         }
583         else if (projlen <= aTolConf) {
584           bRet=GeomAbs_Plane;
585           return bRet;
586         }
587       }
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;
594       }
595       else {
596         return bRet;
597       }
598     }
599     break;
600   }//case GeomAbs_Line: 
601   //  
602   case GeomAbs_Circle:   {
603     
604     Standard_Real MajorRadius, aR;
605     gp_Lin aLin(myAxis);
606     //
607     const gp_Circ& C=myBasisCurve->Circle();
608     const gp_Pnt& aLC=C.Location();
609     aR=C.Radius();
610     //
611    
612     if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) {
613       return bRet;
614     }
615     else if(aLin.Distance(aLC) <= TolConf) {
616       bRet=GeomAbs_Sphere;
617       return bRet;
618     }
619     else {
620       MajorRadius = aLin.Distance(aLC);
621       if(MajorRadius>aR) {
622         //modified by NIZNHY-PKV Thu Feb 24 09:46:29 2011f
623         Standard_Real aT, aDx, dX;
624         gp_Pnt aPx;
625         //
626         aT=0.;
627         aPx=ElCLib::Value(aT, C);
628         aDx=aLin.Distance(aPx);
629         dX=aDx-MajorRadius-aR;
630         if (dX<0.) {
631           dX=-dX;
632         }
633         if (dX<TolConf) {
634           bRet=GeomAbs_Torus;
635         }
636         //bRet=GeomAbs_Torus;
637         //return bRet;
638         //modified by NIZNHY-PKV Thu Feb 24 09:52:29 2011t
639       }
640       return bRet;
641     }
642     break;
643   }
644   //  
645   default:
646     break;
647   }
648   
649   return bRet;
650 }
651
652 //=======================================================================
653 //function : Plane
654 //purpose  : 
655 //=======================================================================
656
657 gp_Pln Adaptor3d_SurfaceOfRevolution::Plane() const 
658
659   Standard_NoSuchObject_Raise_if
660     (GetType() != GeomAbs_Plane, "Adaptor3d_SurfaceOfRevolution:Plane");
661
662   gp_Ax3 Axe = myAxeRev;
663   gp_Pnt P;
664   
665   // P = Projection du Point Debut de la generatrice sur l axe de rotation.
666   P.SetXYZ((myAxis.Location()).XYZ() +
667            (Value(0.,0.).XYZ()-(myAxis.Location()).XYZ()).
668            Dot((myAxis.Direction()).XYZ())
669            *(myAxis.Direction()).XYZ());
670   Axe.SetLocation( P);
671   //// modified by jgv, 8.01.03 for OCC1226 ////
672   if (Axe.XDirection().
673       Dot(myBasisCurve->Line().Direction()) >= -Precision::Confusion()) // > 0.
674     Axe.XReverse();
675   //////////////////////////////////////////////
676
677   return gp_Pln( Axe);
678 }
679
680 //=======================================================================
681 //function : Cylinder
682 //purpose  : 
683 //=======================================================================
684
685 gp_Cylinder Adaptor3d_SurfaceOfRevolution::Cylinder() const
686 {
687   Standard_NoSuchObject_Raise_if
688     (GetType() != GeomAbs_Cylinder, "Adaptor3d_SurfaceOfRevolution::Cylinder");
689
690   gp_Pnt P = Value( 0., 0.);
691   Standard_Real R   = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection();
692   return gp_Cylinder( myAxeRev, R);
693 }
694
695 //=======================================================================
696 //function : Cone
697 //purpose  : 
698 //=======================================================================
699
700 gp_Cone Adaptor3d_SurfaceOfRevolution::Cone() const
701 {
702   Standard_NoSuchObject_Raise_if
703     ( GetType() != GeomAbs_Cone, "Adaptor3d_SurfaceOfRevolution:Cone");
704
705   gp_Ax3 Axe = myAxeRev;
706   gp_Dir ldir = (myBasisCurve->Line()).Direction();
707   Standard_Real Angle = (Axe.Direction()).Angle(ldir);
708   gp_Pnt P0 = Value(0., 0.);
709   Standard_Real R = (Axe.Location()).Distance(P0);
710   if ( R >= Precision::Confusion()) {
711     gp_Pnt O = Axe.Location();
712     gp_Vec OP0(O,P0);
713     Standard_Real t = OP0.Dot(Axe.XDirection());
714     t /= ldir.Dot(Axe.XDirection());
715     OP0.Add(-t * gp_Vec(ldir));
716     if ( OP0.Dot(Axe.Direction()) > 0.) Angle = -Angle;
717   }
718   return gp_Cone( Axe, Angle, R);
719 }
720
721
722 //=======================================================================
723 //function : Sphere
724 //purpose  : 
725 //=======================================================================
726
727 gp_Sphere Adaptor3d_SurfaceOfRevolution::Sphere() const 
728 {
729   Standard_NoSuchObject_Raise_if
730     ( GetType() != GeomAbs_Sphere, "Adaptor3d_SurfaceOfRevolution:Sphere");
731
732   gp_Circ C = myBasisCurve->Circle();
733   gp_Ax3 Axe = myAxeRev;
734   Axe.SetLocation( C.Location());
735   return gp_Sphere( Axe, C.Radius());
736 }
737
738
739 //=======================================================================
740 //function : Torus
741 //purpose  : 
742 //=======================================================================
743
744 gp_Torus Adaptor3d_SurfaceOfRevolution::Torus() const 
745 {
746   Standard_NoSuchObject_Raise_if
747     (GetType() != GeomAbs_Torus, "Adaptor3d_SurfaceOfRevolution:Torus");
748
749   gp_Circ C = myBasisCurve->Circle();
750   Standard_Real MajorRadius = gp_Lin(myAxis).Distance(C.Location());
751   return gp_Torus( myAxeRev, MajorRadius, C.Radius());
752 }
753
754 //=======================================================================
755 //function : UDegree
756 //purpose  : 
757 //=======================================================================
758
759 Standard_Integer Adaptor3d_SurfaceOfRevolution::UDegree() const 
760 {
761   Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::UDegree");
762   return 0;
763 }
764
765 //=======================================================================
766 //function : NbUPoles
767 //purpose  : 
768 //=======================================================================
769
770 Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUPoles() const 
771 {
772   Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbUPoles");
773   return 0;
774 }
775
776 //=======================================================================
777 //function : VDegree
778 //purpose  : 
779 //=======================================================================
780
781 Standard_Integer Adaptor3d_SurfaceOfRevolution::VDegree() const 
782 {
783   return myBasisCurve->Degree();
784 }
785
786 //=======================================================================
787 //function : NbVPoles
788 //purpose  : 
789 //=======================================================================
790
791 Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVPoles() const
792 {
793   return myBasisCurve -> NbPoles();
794 }
795
796 //=======================================================================
797 //function : NbUKnots
798 //purpose  : 
799 //=======================================================================
800
801 Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUKnots() const 
802 {
803   Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbUKnots");
804   return 0;
805 }
806
807
808 //=======================================================================
809 //function : NbVKnots
810 //purpose  : 
811 //=======================================================================
812
813 Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVKnots() const 
814 {
815   Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbVKnots");
816   return 0;
817 }
818
819
820
821 //=======================================================================
822 //function : IsURational
823 //purpose  : 
824 //=======================================================================
825
826 Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsURational() const 
827 {
828   Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::IsURational");
829   return Standard_False;
830 }
831
832 //=======================================================================
833 //function : IsVRational
834 //purpose  : 
835 //=======================================================================
836
837 Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVRational() const 
838 {
839   Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::IsVRational");
840   return Standard_False;
841 }
842
843
844 //=======================================================================
845 //function : Bezier
846 //purpose  : 
847 //=======================================================================
848
849 Handle(Geom_BezierSurface) Adaptor3d_SurfaceOfRevolution::Bezier() const 
850 {
851   Standard_NoSuchObject::Raise("");
852   Handle(Geom_BezierSurface) Dummy;
853   return Dummy;
854 }
855
856
857 //=======================================================================
858 //function : BSpline
859 //purpose  : 
860 //=======================================================================
861
862 Handle(Geom_BSplineSurface) Adaptor3d_SurfaceOfRevolution::BSpline() const 
863 {
864   Standard_NoSuchObject::Raise("");
865   Handle(Geom_BSplineSurface) Dummy;
866   return Dummy;
867 }
868
869
870 //=======================================================================
871 //function : Axis
872 //purpose  : 
873 //=======================================================================
874
875 gp_Ax3 Adaptor3d_SurfaceOfRevolution::Axis() const 
876 {
877   return myAxeRev;
878 }
879
880 //=======================================================================
881 //function : Direction
882 //purpose  : 
883 //=======================================================================
884
885 gp_Dir Adaptor3d_SurfaceOfRevolution::Direction() const 
886 {
887   Standard_NoSuchObject::Raise("");
888   return gp_Dir();
889 }
890
891
892 //=======================================================================
893 //function : BasisCurve
894 //purpose  : 
895 //=======================================================================
896
897 Handle(Adaptor3d_HCurve) Adaptor3d_SurfaceOfRevolution::BasisCurve() const 
898 {
899   return myBasisCurve;
900 }