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