0023024: Update headers of OCCT files
[occt.git] / src / BRepPrim / BRepPrim_Torus.cxx
1 // Created on: 1992-11-06
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1992-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
23
24 #include <BRepPrim_Torus.ixx>
25
26 #include <gp.hxx>
27 #include <gp_Vec.hxx>
28 #include <gp_Ax2d.hxx>
29 #include <Precision.hxx>
30
31 #include <Geom_ToroidalSurface.hxx>
32 #include <Geom_Circle.hxx>
33 #include <Geom2d_Circle.hxx>
34
35 //=======================================================================
36 //function : BRepPrim_Torus
37 //purpose  : 
38 //=======================================================================
39
40 BRepPrim_Torus::BRepPrim_Torus(const gp_Ax2& Position, 
41                                const Standard_Real Major, 
42                                const Standard_Real Minor) :
43        BRepPrim_Revolution(Position,0,2*M_PI),
44        myMajor(Major),
45        myMinor(Minor)
46 {
47   SetMeridian();
48 }
49
50 //=======================================================================
51 //function : BRepPrim_Torus
52 //purpose  : 
53 //=======================================================================
54
55 BRepPrim_Torus::BRepPrim_Torus(const Standard_Real Major, 
56                                const Standard_Real Minor) :
57        BRepPrim_Revolution(gp::XOY(),0,2*M_PI),
58        myMajor(Major),
59        myMinor(Minor)
60 {
61   SetMeridian();
62 }
63
64 //=======================================================================
65 //function : BRepPrim_Torus
66 //purpose  : 
67 //=======================================================================
68
69 BRepPrim_Torus::BRepPrim_Torus(const gp_Pnt& Center, 
70                                const Standard_Real Major, 
71                                const Standard_Real Minor) :
72        BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)),
73                            0,2*M_PI),
74        myMajor(Major),
75        myMinor(Minor)
76 {
77   SetMeridian();
78 }
79
80 //=======================================================================
81 //function : MakeEmptyLateralFace
82 //purpose  : 
83 //=======================================================================
84
85 TopoDS_Face  BRepPrim_Torus::MakeEmptyLateralFace()const 
86 {
87   Handle(Geom_ToroidalSurface) T =
88     new Geom_ToroidalSurface(Axes(),myMajor,myMinor);
89   TopoDS_Face F;
90   myBuilder.Builder().MakeFace(F,T,Precision::Confusion());
91   return F;
92 }
93
94
95 //=======================================================================
96 //function : SetMeridian
97 //purpose  : 
98 //=======================================================================
99
100 void BRepPrim_Torus::SetMeridian()
101 {
102   gp_Dir D = Axes().YDirection();
103   D.Reverse();
104   gp_Ax2 A(Axes().Location(),D,Axes().XDirection());
105   gp_Vec V = Axes().XDirection();
106   V.Multiply(myMajor);
107   A.Translate(V);
108   Handle(Geom_Circle) C = new Geom_Circle(A,myMinor);
109   Handle(Geom2d_Circle) C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(myMajor,0),
110                                                         gp_Dir2d(1,0)),
111                                                 myMinor);
112   Meridian(C,C2d);
113 }