7fd59977 |
1 | // File: BRepPrim_Torus.cxx |
2 | // Created: Fri Nov 6 14:27:00 1992 |
3 | // Author: Remi LEQUETTE |
4 | // <rle@phylox> |
5 | |
6 | |
7 | |
8 | #include <BRepPrim_Torus.ixx> |
9 | |
10 | #include <gp.hxx> |
11 | #include <gp_Vec.hxx> |
12 | #include <gp_Ax2d.hxx> |
13 | #include <Precision.hxx> |
14 | |
15 | #include <Geom_ToroidalSurface.hxx> |
16 | #include <Geom_Circle.hxx> |
17 | #include <Geom2d_Circle.hxx> |
18 | |
19 | //======================================================================= |
20 | //function : BRepPrim_Torus |
21 | //purpose : |
22 | //======================================================================= |
23 | |
24 | BRepPrim_Torus::BRepPrim_Torus(const gp_Ax2& Position, |
25 | const Standard_Real Major, |
26 | const Standard_Real Minor) : |
c6541a0c |
27 | BRepPrim_Revolution(Position,0,2*M_PI), |
7fd59977 |
28 | myMajor(Major), |
29 | myMinor(Minor) |
30 | { |
31 | SetMeridian(); |
32 | } |
33 | |
34 | //======================================================================= |
35 | //function : BRepPrim_Torus |
36 | //purpose : |
37 | //======================================================================= |
38 | |
39 | BRepPrim_Torus::BRepPrim_Torus(const Standard_Real Major, |
40 | const Standard_Real Minor) : |
c6541a0c |
41 | BRepPrim_Revolution(gp::XOY(),0,2*M_PI), |
7fd59977 |
42 | myMajor(Major), |
43 | myMinor(Minor) |
44 | { |
45 | SetMeridian(); |
46 | } |
47 | |
48 | //======================================================================= |
49 | //function : BRepPrim_Torus |
50 | //purpose : |
51 | //======================================================================= |
52 | |
53 | BRepPrim_Torus::BRepPrim_Torus(const gp_Pnt& Center, |
54 | const Standard_Real Major, |
55 | const Standard_Real Minor) : |
56 | BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)), |
c6541a0c |
57 | 0,2*M_PI), |
7fd59977 |
58 | myMajor(Major), |
59 | myMinor(Minor) |
60 | { |
61 | SetMeridian(); |
62 | } |
63 | |
64 | //======================================================================= |
65 | //function : MakeEmptyLateralFace |
66 | //purpose : |
67 | //======================================================================= |
68 | |
69 | TopoDS_Face BRepPrim_Torus::MakeEmptyLateralFace()const |
70 | { |
71 | Handle(Geom_ToroidalSurface) T = |
72 | new Geom_ToroidalSurface(Axes(),myMajor,myMinor); |
73 | TopoDS_Face F; |
74 | myBuilder.Builder().MakeFace(F,T,Precision::Confusion()); |
75 | return F; |
76 | } |
77 | |
78 | |
79 | //======================================================================= |
80 | //function : SetMeridian |
81 | //purpose : |
82 | //======================================================================= |
83 | |
84 | void BRepPrim_Torus::SetMeridian() |
85 | { |
86 | gp_Dir D = Axes().YDirection(); |
87 | D.Reverse(); |
88 | gp_Ax2 A(Axes().Location(),D,Axes().XDirection()); |
89 | gp_Vec V = Axes().XDirection(); |
90 | V.Multiply(myMajor); |
91 | A.Translate(V); |
92 | Handle(Geom_Circle) C = new Geom_Circle(A,myMinor); |
93 | Handle(Geom2d_Circle) C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(myMajor,0), |
94 | gp_Dir2d(1,0)), |
95 | myMinor); |
96 | Meridian(C,C2d); |
97 | } |