7fd59977 |
1 | // File: Geom_CylindricalSurface.cxx |
2 | // Created: Wed Mar 10 09:38:21 1993 |
3 | // Author: JCV |
4 | // <fid@phylox> |
5 | // Copyright: Matra Datavision 1993 |
6 | |
7 | //File Geom_CylindricalSurface.cxx, JCV 17/01/91 |
8 | |
9 | #include <Geom_CylindricalSurface.ixx> |
10 | |
11 | #include <Precision.hxx> |
12 | #include <GeomAbs_UVSense.hxx> |
13 | #include <Geom_Line.hxx> |
14 | #include <Geom_Circle.hxx> |
15 | #include <Standard_ConstructionError.hxx> |
16 | #include <Standard_RangeError.hxx> |
17 | |
18 | #include <gp_Lin.hxx> |
19 | #include <gp_Circ.hxx> |
20 | #include <gp_XYZ.hxx> |
21 | #include <gp_Ax2d.hxx> |
22 | #include <gp.hxx> |
23 | #include <ElSLib.hxx> |
24 | |
25 | typedef Geom_CylindricalSurface CylindricalSurface; |
26 | typedef Handle(Geom_CylindricalSurface) Handle(CylindricalSurface); |
27 | |
28 | typedef gp_Ax1 Ax1; |
29 | typedef gp_Ax2 Ax2; |
30 | typedef gp_Ax3 Ax3; |
31 | typedef gp_Circ Circ; |
32 | typedef gp_Dir Dir; |
33 | typedef gp_Lin Lin; |
34 | typedef gp_Pnt Pnt; |
35 | typedef gp_Trsf Trsf; |
36 | typedef gp_Vec Vec; |
37 | typedef gp_XYZ XYZ; |
38 | |
39 | |
40 | |
41 | //======================================================================= |
42 | //function : Copy |
43 | //purpose : |
44 | //======================================================================= |
45 | |
46 | Handle(Geom_Geometry) Geom_CylindricalSurface::Copy () const { |
47 | |
48 | Handle(CylindricalSurface) Cs; |
49 | Cs = new CylindricalSurface (pos, radius); |
50 | return Cs; |
51 | } |
52 | |
53 | |
54 | //======================================================================= |
55 | //function : Geom_CylindricalSurface |
56 | //purpose : |
57 | //======================================================================= |
58 | |
59 | Geom_CylindricalSurface::Geom_CylindricalSurface (const gp_Cylinder& C) |
60 | : radius (C.Radius()) { |
61 | |
62 | pos = C.Position (); |
63 | } |
64 | |
65 | |
66 | //======================================================================= |
67 | //function : Geom_CylindricalSurface |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | Geom_CylindricalSurface::Geom_CylindricalSurface ( const Ax3& A3, |
72 | const Standard_Real R) |
73 | : radius (R) { |
74 | |
75 | if (R < 0.0) Standard_ConstructionError::Raise(); |
76 | pos = A3; |
77 | } |
78 | |
79 | |
80 | //======================================================================= |
81 | //function : UReversedParameter |
82 | //purpose : |
83 | //======================================================================= |
84 | |
85 | Standard_Real Geom_CylindricalSurface::UReversedParameter( const Standard_Real U) const |
86 | { |
c6541a0c |
87 | return (2.*M_PI - U); |
7fd59977 |
88 | } |
89 | |
90 | //======================================================================= |
91 | //function : VReversedParameter |
92 | //purpose : |
93 | //======================================================================= |
94 | |
95 | Standard_Real Geom_CylindricalSurface::VReversedParameter( const Standard_Real V) const |
96 | { |
97 | return (-V); |
98 | } |
99 | |
100 | //======================================================================= |
101 | //function : Radius |
102 | //purpose : |
103 | //======================================================================= |
104 | |
105 | Standard_Real Geom_CylindricalSurface::Radius () const { return radius; } |
106 | |
107 | //======================================================================= |
108 | //function : IsUClosed |
109 | //purpose : |
110 | //======================================================================= |
111 | |
112 | Standard_Boolean Geom_CylindricalSurface::IsUClosed () const { return Standard_True; } |
113 | |
114 | //======================================================================= |
115 | //function : IsVClosed |
116 | //purpose : |
117 | //======================================================================= |
118 | |
119 | Standard_Boolean Geom_CylindricalSurface::IsVClosed () const { return Standard_False; } |
120 | |
121 | //======================================================================= |
122 | //function : IsUPeriodic |
123 | //purpose : |
124 | //======================================================================= |
125 | |
126 | Standard_Boolean Geom_CylindricalSurface::IsUPeriodic () const { return Standard_True; } |
127 | |
128 | //======================================================================= |
129 | //function : IsVPeriodic |
130 | //purpose : |
131 | //======================================================================= |
132 | |
133 | Standard_Boolean Geom_CylindricalSurface::IsVPeriodic () const { return Standard_False; } |
134 | |
135 | //======================================================================= |
136 | //function : SetCylinder |
137 | //purpose : |
138 | //======================================================================= |
139 | |
140 | void Geom_CylindricalSurface::SetCylinder (const gp_Cylinder& C) { |
141 | |
142 | radius = C.Radius(); |
143 | pos = C.Position(); |
144 | } |
145 | |
146 | |
147 | //======================================================================= |
148 | //function : SetRadius |
149 | //purpose : |
150 | //======================================================================= |
151 | |
152 | void Geom_CylindricalSurface::SetRadius (const Standard_Real R) { |
153 | |
154 | if (R < 0.0) { Standard_ConstructionError::Raise(); } |
155 | radius = R; |
156 | } |
157 | |
158 | |
159 | //======================================================================= |
160 | //function : Bounds |
161 | //purpose : |
162 | //======================================================================= |
163 | |
164 | void Geom_CylindricalSurface::Bounds (Standard_Real& U1, Standard_Real& U2, |
165 | Standard_Real& V1, Standard_Real& V2) const { |
166 | |
c6541a0c |
167 | U1 = 0.0; U2 = 2.0 * M_PI; |
7fd59977 |
168 | V1 = - Precision::Infinite(); V2 = Precision::Infinite(); |
169 | } |
170 | |
171 | |
172 | //======================================================================= |
173 | //function : Coefficients |
174 | //purpose : |
175 | //======================================================================= |
176 | |
177 | void Geom_CylindricalSurface::Coefficients (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3, |
178 | Standard_Real& B1, Standard_Real& B2, Standard_Real& B3, |
179 | Standard_Real& C1, Standard_Real& C2, Standard_Real& C3, |
180 | Standard_Real& D) const { |
181 | // Dans le repere local du cylindre : |
182 | // X**2 + Y**2 - radius = 0.0 |
183 | |
184 | Trsf T; |
185 | T.SetTransformation (pos); |
186 | Standard_Real T11 = T.Value (1, 1); |
187 | Standard_Real T12 = T.Value (1, 2); |
188 | Standard_Real T13 = T.Value (1, 3); |
189 | Standard_Real T14 = T.Value (1, 4); |
190 | Standard_Real T21 = T.Value (2, 1); |
191 | Standard_Real T22 = T.Value (2, 2); |
192 | Standard_Real T23 = T.Value (2, 3); |
193 | Standard_Real T24 = T.Value (2, 4); |
7fd59977 |
194 | A1 = T11 * T11 + T21 * T21; |
195 | A2 = T12 * T12 + T22 * T22; |
196 | A3 = T13 * T13 + T23 * T23; |
197 | B1 = T11 * T12 + T21 * T22; |
198 | B2 = T11 * T13 + T21 * T23; |
199 | B3 = T12 * T13 + T22 * T23; |
200 | C1 = T11 * T14 + T21 * T24; |
201 | C2 = T12 * T14 + T22 * T24; |
202 | C3 = T13 * T14 + T23 * T24; |
203 | D = T14 * T14 + T24 * T24 - radius * radius; |
204 | } |
205 | |
206 | |
207 | |
208 | //======================================================================= |
209 | //function : Cylinder |
210 | //purpose : |
211 | //======================================================================= |
212 | |
213 | gp_Cylinder Geom_CylindricalSurface::Cylinder () const { |
214 | |
215 | return gp_Cylinder (pos, radius); |
216 | } |
217 | |
218 | |
219 | //======================================================================= |
220 | //function : D0 |
221 | //purpose : |
222 | //======================================================================= |
223 | |
224 | void Geom_CylindricalSurface::D0 (const Standard_Real U, |
225 | const Standard_Real V, |
226 | Pnt& P ) const |
227 | { |
228 | ElSLib::CylinderD0 (U, V, pos, radius, P); |
229 | } |
230 | |
231 | |
232 | //======================================================================= |
233 | //function : D1 |
234 | //purpose : |
235 | //======================================================================= |
236 | |
237 | void Geom_CylindricalSurface::D1 (const Standard_Real U, const Standard_Real V , |
238 | Pnt& P, |
239 | Vec& D1U, Vec& D1V) const |
240 | { |
241 | ElSLib::CylinderD1 (U, V, pos, radius, P, D1U, D1V); |
242 | } |
243 | |
244 | |
245 | |
246 | //======================================================================= |
247 | //function : D2 |
248 | //purpose : |
249 | //======================================================================= |
250 | |
251 | void Geom_CylindricalSurface::D2 (const Standard_Real U, const Standard_Real V, |
252 | Pnt& P, |
253 | Vec& D1U, Vec& D1V, |
254 | Vec& D2U, Vec& D2V, Vec& D2UV) const |
255 | { |
256 | ElSLib::CylinderD2 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, D2UV); |
257 | } |
258 | |
259 | |
260 | |
261 | //======================================================================= |
262 | //function : D3 |
263 | //purpose : |
264 | //======================================================================= |
265 | |
266 | void Geom_CylindricalSurface::D3 (const Standard_Real U, const Standard_Real V, |
267 | Pnt& P, |
268 | Vec& D1U, Vec& D1V, |
269 | Vec& D2U, Vec& D2V, Vec& D2UV, |
270 | Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV) |
271 | const |
272 | { |
273 | ElSLib::CylinderD3 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, |
274 | D2UV, D3U, D3V, D3UUV, D3UVV); |
275 | } |
276 | |
277 | |
278 | //======================================================================= |
279 | //function : DN |
280 | //purpose : |
281 | //======================================================================= |
282 | |
283 | Vec Geom_CylindricalSurface::DN (const Standard_Real U , const Standard_Real V , |
284 | const Standard_Integer Nu, const Standard_Integer Nv ) const |
285 | { |
286 | Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " "); |
287 | |
288 | if (Nv > 1) { return Vec (0.0, 0.0, 0.0); } |
289 | else { |
290 | return ElSLib::CylinderDN (U, V, pos, radius, Nu, Nv); |
291 | } |
292 | } |
293 | |
294 | |
295 | |
296 | |
297 | //======================================================================= |
298 | //function : UIso |
299 | //purpose : |
300 | //======================================================================= |
301 | |
302 | Handle(Geom_Curve) Geom_CylindricalSurface::UIso (const Standard_Real U) const |
303 | { |
304 | Handle(Geom_Line) GL = new Geom_Line(ElSLib::CylinderUIso(pos,radius,U)); |
305 | return GL; |
306 | } |
307 | |
308 | |
309 | |
310 | //======================================================================= |
311 | //function : VIso |
312 | //purpose : |
313 | //======================================================================= |
314 | |
315 | Handle(Geom_Curve) Geom_CylindricalSurface::VIso (const Standard_Real V) const |
316 | { |
317 | Handle(Geom_Circle) GC = new Geom_Circle(ElSLib::CylinderVIso(pos,radius,V)); |
318 | return GC; |
319 | } |
320 | |
321 | |
322 | |
323 | //======================================================================= |
324 | //function : Transform |
325 | //purpose : |
326 | //======================================================================= |
327 | |
328 | void Geom_CylindricalSurface::Transform (const Trsf& T) { |
329 | |
330 | radius = radius * Abs(T.ScaleFactor()); |
331 | pos.Transform (T); |
332 | } |
333 | |
334 | //======================================================================= |
335 | //function : TransformParameters |
336 | //purpose : |
337 | //======================================================================= |
338 | |
339 | void Geom_CylindricalSurface::TransformParameters(Standard_Real& , |
340 | Standard_Real& V, |
341 | const gp_Trsf& T) |
342 | const |
343 | { |
344 | if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor()); |
345 | } |
346 | |
347 | //======================================================================= |
348 | //function : ParametricTransformation |
349 | //purpose : |
350 | //======================================================================= |
351 | |
352 | gp_GTrsf2d Geom_CylindricalSurface::ParametricTransformation(const gp_Trsf& T) |
353 | const |
354 | { |
355 | gp_GTrsf2d T2; |
356 | gp_Ax2d Axis(gp::Origin2d(),gp::DX2d()); |
357 | T2.SetAffinity(Axis, Abs(T.ScaleFactor())); |
358 | return T2; |
359 | } |