0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / Geom / Geom_CylindricalSurface.cxx
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 {
87   return (2.*M_PI - U);
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
167    U1 = 0.0;  U2 = 2.0 * M_PI;
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);
194 #ifdef DEB
195   Standard_Real T31 = T.Value (3, 1);
196   Standard_Real T32 = T.Value (3, 2);
197   Standard_Real T33 = T.Value (3, 3);
198   Standard_Real T34 = T.Value (3, 4);
199 #else
200   T.Value (3, 1);
201   T.Value (3, 2);
202   T.Value (3, 3);
203   T.Value (3, 4);
204 #endif
205   A1 = T11 * T11 + T21 * T21;
206   A2 = T12 * T12 + T22 * T22;
207   A3 = T13 * T13 + T23 * T23;
208   B1 = T11 * T12 + T21 * T22;
209   B2 = T11 * T13 + T21 * T23;
210   B3 = T12 * T13 + T22 * T23;
211   C1 = T11 * T14 + T21 * T24;
212   C2 = T12 * T14 + T22 * T24;
213   C3 = T13 * T14 + T23 * T24;
214   D = T14 * T14 + T24 * T24 - radius * radius;  
215 }
216
217
218
219 //=======================================================================
220 //function : Cylinder
221 //purpose  : 
222 //=======================================================================
223
224 gp_Cylinder Geom_CylindricalSurface::Cylinder () const {
225   
226   return gp_Cylinder (pos, radius);
227 }
228
229
230 //=======================================================================
231 //function : D0
232 //purpose  : 
233 //=======================================================================
234
235 void Geom_CylindricalSurface::D0 (const Standard_Real U, 
236                                   const Standard_Real V,
237                                         Pnt& P ) const 
238 {
239   ElSLib::CylinderD0 (U, V, pos, radius, P);
240 }
241
242
243 //=======================================================================
244 //function : D1
245 //purpose  : 
246 //=======================================================================
247
248 void Geom_CylindricalSurface::D1 (const Standard_Real U, const Standard_Real V , 
249                                         Pnt& P, 
250                                         Vec& D1U,     Vec& D1V) const 
251 {
252   ElSLib::CylinderD1 (U, V, pos, radius, P, D1U, D1V);
253 }
254
255
256
257 //=======================================================================
258 //function : D2
259 //purpose  : 
260 //=======================================================================
261
262 void Geom_CylindricalSurface::D2 (const Standard_Real U, const Standard_Real V, 
263                                   Pnt& P,
264                                   Vec& D1U, Vec& D1V,
265                                   Vec& D2U, Vec& D2V, Vec& D2UV) const 
266 {
267   ElSLib::CylinderD2 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, D2UV);
268 }
269
270
271
272 //=======================================================================
273 //function : D3
274 //purpose  : 
275 //=======================================================================
276
277 void Geom_CylindricalSurface::D3 (const Standard_Real U, const Standard_Real V,
278                                   Pnt& P, 
279                                   Vec& D1U, Vec& D1V, 
280                                   Vec& D2U, Vec& D2V, Vec& D2UV,
281                                   Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV) 
282                                   const 
283 {
284   ElSLib::CylinderD3 (U, V, pos, radius, P, D1U, D1V, D2U, D2V,
285                       D2UV, D3U, D3V, D3UUV, D3UVV);
286 }
287
288
289 //=======================================================================
290 //function : DN
291 //purpose  : 
292 //=======================================================================
293
294 Vec Geom_CylindricalSurface::DN (const Standard_Real    U , const Standard_Real    V , 
295                                  const Standard_Integer Nu, const Standard_Integer Nv ) const 
296 {
297   Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
298
299   if (Nv > 1) { return Vec (0.0, 0.0, 0.0); }
300   else {
301     return ElSLib::CylinderDN (U, V, pos, radius, Nu, Nv);
302   }
303 }
304
305
306
307
308 //=======================================================================
309 //function : UIso
310 //purpose  : 
311 //=======================================================================
312
313 Handle(Geom_Curve) Geom_CylindricalSurface::UIso (const Standard_Real U) const 
314 {
315   Handle(Geom_Line) GL = new Geom_Line(ElSLib::CylinderUIso(pos,radius,U));
316   return GL;
317 }
318
319
320
321 //=======================================================================
322 //function : VIso
323 //purpose  : 
324 //=======================================================================
325
326 Handle(Geom_Curve) Geom_CylindricalSurface::VIso (const Standard_Real V) const 
327 {
328   Handle(Geom_Circle) GC = new Geom_Circle(ElSLib::CylinderVIso(pos,radius,V));
329   return GC;
330 }
331
332
333
334 //=======================================================================
335 //function : Transform
336 //purpose  : 
337 //=======================================================================
338
339 void Geom_CylindricalSurface::Transform (const Trsf& T) {
340
341    radius = radius * Abs(T.ScaleFactor());
342    pos.Transform (T);
343 }
344
345 //=======================================================================
346 //function : TransformParameters
347 //purpose  : 
348 //=======================================================================
349
350 void Geom_CylindricalSurface::TransformParameters(Standard_Real& ,
351                                                   Standard_Real& V,
352                                                   const gp_Trsf& T) 
353 const
354 {
355   if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
356 }
357
358 //=======================================================================
359 //function : ParametricTransformation
360 //purpose  : 
361 //=======================================================================
362
363 gp_GTrsf2d Geom_CylindricalSurface::ParametricTransformation(const gp_Trsf& T)
364 const
365 {
366   gp_GTrsf2d T2;
367   gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
368   T2.SetAffinity(Axis, Abs(T.ScaleFactor()));
369   return T2;
370 }