1 // Created on: 1993-03-10
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Geom_Circle.hxx>
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>
26 #include <gp_Ax2d.hxx>
28 #include <gp_Circ.hxx>
29 #include <gp_Cylinder.hxx>
30 #include <gp_GTrsf2d.hxx>
33 #include <gp_Trsf.hxx>
36 #include <Precision.hxx>
37 #include <Standard_ConstructionError.hxx>
38 #include <Standard_RangeError.hxx>
39 #include <Standard_Type.hxx>
41 IMPLEMENT_STANDARD_RTTIEXT(Geom_CylindricalSurface,Geom_ElementarySurface)
43 typedef Geom_CylindricalSurface CylindricalSurface;
58 //=======================================================================
61 //=======================================================================
63 Handle(Geom_Geometry) Geom_CylindricalSurface::Copy () const {
65 Handle(Geom_CylindricalSurface) Cs;
66 Cs = new CylindricalSurface (pos, radius);
71 //=======================================================================
72 //function : Geom_CylindricalSurface
74 //=======================================================================
76 Geom_CylindricalSurface::Geom_CylindricalSurface (const gp_Cylinder& C)
77 : radius (C.Radius()) {
83 //=======================================================================
84 //function : Geom_CylindricalSurface
86 //=======================================================================
88 Geom_CylindricalSurface::Geom_CylindricalSurface ( const Ax3& A3,
89 const Standard_Real R)
92 if (R < 0.0) throw Standard_ConstructionError();
97 //=======================================================================
98 //function : UReversedParameter
100 //=======================================================================
102 Standard_Real Geom_CylindricalSurface::UReversedParameter( const Standard_Real U) const
104 return (2.*M_PI - U);
107 //=======================================================================
108 //function : VReversedParameter
110 //=======================================================================
112 Standard_Real Geom_CylindricalSurface::VReversedParameter( const Standard_Real V) const
117 //=======================================================================
120 //=======================================================================
122 Standard_Real Geom_CylindricalSurface::Radius () const { return radius; }
124 //=======================================================================
125 //function : IsUClosed
127 //=======================================================================
129 Standard_Boolean Geom_CylindricalSurface::IsUClosed () const { return Standard_True; }
131 //=======================================================================
132 //function : IsVClosed
134 //=======================================================================
136 Standard_Boolean Geom_CylindricalSurface::IsVClosed () const { return Standard_False; }
138 //=======================================================================
139 //function : IsUPeriodic
141 //=======================================================================
143 Standard_Boolean Geom_CylindricalSurface::IsUPeriodic () const { return Standard_True; }
145 //=======================================================================
146 //function : IsVPeriodic
148 //=======================================================================
150 Standard_Boolean Geom_CylindricalSurface::IsVPeriodic () const { return Standard_False; }
152 //=======================================================================
153 //function : SetCylinder
155 //=======================================================================
157 void Geom_CylindricalSurface::SetCylinder (const gp_Cylinder& C) {
164 //=======================================================================
165 //function : SetRadius
167 //=======================================================================
169 void Geom_CylindricalSurface::SetRadius (const Standard_Real R) {
171 if (R < 0.0) { throw Standard_ConstructionError(); }
176 //=======================================================================
179 //=======================================================================
181 void Geom_CylindricalSurface::Bounds (Standard_Real& U1, Standard_Real& U2,
182 Standard_Real& V1, Standard_Real& V2) const {
184 U1 = 0.0; U2 = 2.0 * M_PI;
185 V1 = - Precision::Infinite(); V2 = Precision::Infinite();
189 //=======================================================================
190 //function : Coefficients
192 //=======================================================================
194 void 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
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);
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;
225 //=======================================================================
226 //function : Cylinder
228 //=======================================================================
230 gp_Cylinder Geom_CylindricalSurface::Cylinder () const {
232 return gp_Cylinder (pos, radius);
236 //=======================================================================
239 //=======================================================================
241 void Geom_CylindricalSurface::D0 (const Standard_Real U,
242 const Standard_Real V,
245 ElSLib::CylinderD0 (U, V, pos, radius, P);
249 //=======================================================================
252 //=======================================================================
254 void Geom_CylindricalSurface::D1 (const Standard_Real U, const Standard_Real V ,
256 Vec& D1U, Vec& D1V) const
258 ElSLib::CylinderD1 (U, V, pos, radius, P, D1U, D1V);
263 //=======================================================================
266 //=======================================================================
268 void Geom_CylindricalSurface::D2 (const Standard_Real U, const Standard_Real V,
271 Vec& D2U, Vec& D2V, Vec& D2UV) const
273 ElSLib::CylinderD2 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, D2UV);
278 //=======================================================================
281 //=======================================================================
283 void Geom_CylindricalSurface::D3 (const Standard_Real U, const Standard_Real V,
286 Vec& D2U, Vec& D2V, Vec& D2UV,
287 Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV)
290 ElSLib::CylinderD3 (U, V, pos, radius, P, D1U, D1V, D2U, D2V,
291 D2UV, D3U, D3V, D3UUV, D3UVV);
295 //=======================================================================
298 //=======================================================================
300 Vec Geom_CylindricalSurface::DN (const Standard_Real U , const Standard_Real V ,
301 const Standard_Integer Nu, const Standard_Integer Nv ) const
303 Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
305 if (Nv > 1) { return Vec (0.0, 0.0, 0.0); }
307 return ElSLib::CylinderDN (U, V, pos, radius, Nu, Nv);
314 //=======================================================================
317 //=======================================================================
319 Handle(Geom_Curve) Geom_CylindricalSurface::UIso (const Standard_Real U) const
321 Handle(Geom_Line) GL = new Geom_Line(ElSLib::CylinderUIso(pos,radius,U));
327 //=======================================================================
330 //=======================================================================
332 Handle(Geom_Curve) Geom_CylindricalSurface::VIso (const Standard_Real V) const
334 Handle(Geom_Circle) GC = new Geom_Circle(ElSLib::CylinderVIso(pos,radius,V));
340 //=======================================================================
341 //function : Transform
343 //=======================================================================
345 void Geom_CylindricalSurface::Transform (const Trsf& T) {
347 radius = radius * Abs(T.ScaleFactor());
351 //=======================================================================
352 //function : TransformParameters
354 //=======================================================================
356 void Geom_CylindricalSurface::TransformParameters(Standard_Real& ,
361 if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
364 //=======================================================================
365 //function : ParametricTransformation
367 //=======================================================================
369 gp_GTrsf2d Geom_CylindricalSurface::ParametricTransformation(const gp_Trsf& T)
373 gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
374 T2.SetAffinity(Axis, Abs(T.ScaleFactor()));