b311480e |
1 | // Created on: 1993-07-23 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1993-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 | // |
973c2be1 |
8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public version 2.1 as published |
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 | |
17 | #include <BRepPrimAPI_MakeSphere.ixx> |
18 | #include <BRepBuilderAPI.hxx> |
19 | |
20 | |
21 | #include <gp.hxx> |
22 | #include <gp_Dir.hxx> |
23 | #include <gp_Ax2.hxx> |
24 | |
25 | |
7fd59977 |
26 | static gp_Ax2 SphereComputeAxes() { |
27 | static Standard_Integer firsttime=1; |
28 | static Standard_Integer modif=0; |
29 | static Standard_Real cosa=cos(0.111); |
30 | static Standard_Real sina=sin(0.111); |
31 | static Standard_Real ux=1.0; |
32 | static Standard_Real uy=0.0; |
33 | |
34 | if(firsttime) { |
35 | modif = getenv("PRIM_SPHERE") != NULL; |
36 | firsttime = 0; |
37 | } |
38 | if(modif) { |
39 | Standard_Real nux = cosa*ux+sina*uy; |
40 | Standard_Real nuy =-sina*ux+cosa*uy; |
41 | ux=nux; uy=nuy; |
42 | return(gp_Ax2(gp::Origin(),gp::DZ(),gp_Dir(ux,uy,0.0))); |
43 | } |
44 | else { |
45 | return(gp::XOY()); |
46 | } |
47 | } |
48 | |
49 | |
50 | //======================================================================= |
51 | //function : BRepPrimAPI_MakeSphere |
52 | //purpose : |
53 | //======================================================================= |
54 | |
55 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R) : |
56 | mySphere(SphereComputeAxes(),R) |
57 | { |
58 | } |
59 | |
60 | |
61 | //======================================================================= |
62 | //function : BRepPrimAPI_MakeSphere |
63 | //purpose : |
64 | //======================================================================= |
65 | |
66 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R, |
67 | const Standard_Real angle) : |
68 | mySphere(gp_Ax2(gp::Origin(), (angle<0.?-1:1)*gp::DZ(), gp::DX()), |
69 | R) |
70 | { |
71 | mySphere.Angle(Abs(angle)); |
72 | } |
73 | |
74 | |
75 | //======================================================================= |
76 | //function : BRepPrimAPI_MakeSphere |
77 | //purpose : |
78 | //======================================================================= |
79 | |
80 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R, |
81 | const Standard_Real angle1, |
82 | const Standard_Real angle2) : |
83 | mySphere(R) |
84 | { |
85 | mySphere.VMin(angle1); |
86 | mySphere.VMax(angle2); |
87 | } |
88 | |
89 | |
90 | //======================================================================= |
91 | //function : BRepPrimAPI_MakeSphere |
92 | //purpose : |
93 | //======================================================================= |
94 | |
95 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const Standard_Real R, |
96 | const Standard_Real angle1, |
97 | const Standard_Real angle2, |
98 | const Standard_Real angle3) : |
99 | mySphere(R) |
100 | { |
101 | mySphere.VMin(angle1); |
102 | mySphere.VMax(angle2); |
103 | mySphere.Angle(angle3); |
104 | } |
105 | |
106 | //======================================================================= |
107 | //function : BRepPrimAPI_MakeSphere |
108 | //purpose : |
109 | //======================================================================= |
110 | |
111 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Pnt& Center, |
112 | const Standard_Real R) : |
113 | mySphere(gp_Ax2(Center, gp_Dir(0,0,1), gp_Dir(1,0,0)), |
114 | R) |
115 | { |
116 | } |
117 | |
118 | |
119 | //======================================================================= |
120 | //function : BRepPrimAPI_MakeSphere |
121 | //purpose : |
122 | //======================================================================= |
123 | |
124 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Pnt& Center, |
125 | const Standard_Real R, |
126 | const Standard_Real angle) : |
127 | mySphere(gp_Ax2(Center, gp_Dir(0,0,1), gp_Dir(1,0,0)), |
128 | R) |
129 | { |
130 | mySphere.Angle(angle); |
131 | } |
132 | |
133 | |
134 | //======================================================================= |
135 | //function : BRepPrimAPI_MakeSphere |
136 | //purpose : |
137 | //======================================================================= |
138 | |
139 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Pnt& Center, |
140 | const Standard_Real R, |
141 | const Standard_Real angle1, |
142 | const Standard_Real angle2) : |
143 | mySphere(gp_Ax2(Center, gp_Dir(0,0,1), gp_Dir(1,0,0)), |
144 | R) |
145 | { |
146 | mySphere.VMin(angle1); |
147 | mySphere.VMax(angle2); |
148 | } |
149 | |
150 | |
151 | //======================================================================= |
152 | //function : BRepPrimAPI_MakeSphere |
153 | //purpose : |
154 | //======================================================================= |
155 | |
156 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Pnt& Center, |
157 | const Standard_Real R, |
158 | const Standard_Real angle1, |
159 | const Standard_Real angle2, |
160 | const Standard_Real angle3) : |
161 | mySphere(gp_Ax2(Center, gp_Dir(0,0,1), gp_Dir(1,0,0)), |
162 | R) |
163 | { |
164 | mySphere.VMin(angle1); |
165 | mySphere.VMax(angle2); |
166 | mySphere.Angle(angle3); |
167 | } |
168 | |
169 | |
170 | //======================================================================= |
171 | //function : BRepPrimAPI_MakeSphere |
172 | //purpose : |
173 | //======================================================================= |
174 | |
175 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Ax2& Axis, |
176 | const Standard_Real R) : |
177 | mySphere(Axis, R) |
178 | { |
179 | } |
180 | |
181 | |
182 | //======================================================================= |
183 | //function : BRepPrimAPI_MakeSphere |
184 | //purpose : |
185 | //======================================================================= |
186 | |
187 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Ax2& Axis, |
188 | const Standard_Real R, |
189 | const Standard_Real angle) : |
190 | mySphere( Axis, R) |
191 | { |
192 | mySphere.Angle(angle); |
193 | } |
194 | |
195 | |
196 | //======================================================================= |
197 | //function : BRepPrimAPI_MakeSphere |
198 | //purpose : |
199 | //======================================================================= |
200 | |
201 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Ax2& Axis, |
202 | const Standard_Real R, |
203 | const Standard_Real angle1, |
204 | const Standard_Real angle2) : |
205 | mySphere(Axis, R) |
206 | { |
207 | mySphere.VMin(angle1); |
208 | mySphere.VMax(angle2); |
209 | } |
210 | |
211 | |
212 | //======================================================================= |
213 | //function : BRepPrimAPI_MakeSphere |
214 | //purpose : |
215 | //======================================================================= |
216 | |
217 | BRepPrimAPI_MakeSphere::BRepPrimAPI_MakeSphere(const gp_Ax2& Axis, |
218 | const Standard_Real R, |
219 | const Standard_Real angle1, |
220 | const Standard_Real angle2, |
221 | const Standard_Real angle3) : |
222 | mySphere( Axis, R) |
223 | { |
224 | mySphere.VMin(angle1); |
225 | mySphere.VMax(angle2); |
226 | mySphere.Angle(angle3); |
227 | } |
228 | |
229 | |
230 | |
231 | //======================================================================= |
232 | //function : OneAxis |
233 | //purpose : |
234 | //======================================================================= |
235 | |
236 | Standard_Address BRepPrimAPI_MakeSphere::OneAxis() |
237 | { |
238 | return &mySphere; |
239 | } |
240 | |
241 | |
242 | //======================================================================= |
243 | //function : Sphere |
244 | //purpose : |
245 | //======================================================================= |
246 | |
247 | BRepPrim_Sphere& BRepPrimAPI_MakeSphere::Sphere() |
248 | { |
249 | return mySphere; |
250 | } |
251 | |
252 | |