b311480e |
1 | // Created on: 1992-11-06 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1992-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <BRepPrim_Cylinder.hxx> |
19 | #include <Geom2d_Line.hxx> |
20 | #include <Geom_CylindricalSurface.hxx> |
21 | #include <Geom_Line.hxx> |
7fd59977 |
22 | #include <gp.hxx> |
42cf5bc1 |
23 | #include <gp_Ax2.hxx> |
24 | #include <gp_Pnt.hxx> |
7fd59977 |
25 | #include <gp_Vec.hxx> |
26 | #include <Precision.hxx> |
42cf5bc1 |
27 | #include <TopoDS_Face.hxx> |
7fd59977 |
28 | |
29 | //======================================================================= |
30 | //function : BRepPrim_Cylinder |
31 | //purpose : |
32 | //======================================================================= |
7fd59977 |
33 | BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Ax2& Position, |
34 | const Standard_Real Radius, |
35 | const Standard_Real Height) : |
36 | BRepPrim_Revolution(Position,0,Height), |
37 | myRadius(Radius) |
38 | { |
39 | SetMeridian(); |
40 | } |
41 | |
42 | //======================================================================= |
43 | //function : BRepPrim_Cylinder |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | BRepPrim_Cylinder::BRepPrim_Cylinder(const Standard_Real Radius) : |
48 | BRepPrim_Revolution(gp::XOY(),RealFirst(),RealLast()), |
49 | myRadius(Radius) |
50 | { |
51 | SetMeridian(); |
52 | } |
53 | |
54 | //======================================================================= |
55 | //function : BRepPrim_Cylinder |
56 | //purpose : |
57 | //======================================================================= |
58 | |
59 | BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Pnt& Center, |
60 | const Standard_Real Radius) : |
61 | BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)), |
62 | RealFirst(),RealLast()), |
63 | myRadius(Radius) |
64 | { |
65 | SetMeridian(); |
66 | } |
67 | |
68 | //======================================================================= |
69 | //function : BRepPrim_Cylinder |
70 | //purpose : |
71 | //======================================================================= |
72 | |
73 | BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Ax2& Axes, |
74 | const Standard_Real Radius) : |
75 | BRepPrim_Revolution(Axes, RealFirst(),RealLast()), |
76 | myRadius(Radius) |
77 | { |
78 | SetMeridian(); |
79 | } |
80 | |
81 | //======================================================================= |
82 | //function : BRepPrim_Cylinder |
83 | //purpose : |
84 | //======================================================================= |
85 | |
86 | BRepPrim_Cylinder::BRepPrim_Cylinder(const Standard_Real R, |
87 | const Standard_Real H) : |
88 | BRepPrim_Revolution(gp::XOY(), 0, H), |
89 | myRadius(R) |
90 | { |
91 | SetMeridian(); |
92 | } |
93 | |
94 | //======================================================================= |
95 | //function : BRepPrim_Cylinder |
96 | //purpose : |
97 | //======================================================================= |
98 | |
99 | BRepPrim_Cylinder::BRepPrim_Cylinder(const gp_Pnt& Center, |
100 | const Standard_Real R, |
101 | const Standard_Real H) : |
102 | BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)), |
103 | 0,H), |
104 | myRadius(R) |
105 | { |
106 | SetMeridian(); |
107 | } |
108 | |
109 | //======================================================================= |
110 | //function : MakeEmptyLateralFace |
111 | //purpose : |
112 | //======================================================================= |
113 | |
114 | TopoDS_Face BRepPrim_Cylinder::MakeEmptyLateralFace() const |
115 | { |
116 | Handle(Geom_CylindricalSurface) C = |
117 | new Geom_CylindricalSurface(Axes(),myRadius); |
118 | TopoDS_Face F; |
119 | myBuilder.Builder().MakeFace(F,C,Precision::Confusion()); |
120 | return F; |
121 | } |
122 | |
123 | //======================================================================= |
124 | //function : SetMeridian |
125 | //purpose : |
126 | //======================================================================= |
127 | |
128 | void BRepPrim_Cylinder::SetMeridian() |
129 | { |
130 | gp_Vec V = Axes().XDirection(); |
131 | V.Multiply(myRadius); |
132 | gp_Ax1 A = Axes().Axis(); |
133 | A.Translate(V); |
134 | Handle(Geom_Line) L = new Geom_Line(A); |
135 | Handle(Geom2d_Line) L2d = new Geom2d_Line(gp_Pnt2d(myRadius,0),gp_Dir2d(0,1)); |
136 | Meridian(L,L2d); |
137 | } |