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