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>
25 #include <gp_Ax2d.hxx>
27 #include <gp_Circ.hxx>
28 #include <gp_Cylinder.hxx>
29 #include <gp_GTrsf2d.hxx>
32 #include <gp_Trsf.hxx>
35 #include <Precision.hxx>
36 #include <Standard_ConstructionError.hxx>
37 #include <Standard_RangeError.hxx>
38 #include <Standard_Type.hxx>
40 IMPLEMENT_STANDARD_RTTIEXT(Geom_CylindricalSurface,Geom_ElementarySurface)
42 typedef Geom_CylindricalSurface CylindricalSurface;
57 //=======================================================================
60 //=======================================================================
62 Handle(Geom_Geometry) Geom_CylindricalSurface::Copy () const {
64 Handle(Geom_CylindricalSurface) Cs;
65 Cs = new CylindricalSurface (pos, radius);
70 //=======================================================================
71 //function : Geom_CylindricalSurface
73 //=======================================================================
75 Geom_CylindricalSurface::Geom_CylindricalSurface (const gp_Cylinder& C)
76 : radius (C.Radius()) {
82 //=======================================================================
83 //function : Geom_CylindricalSurface
85 //=======================================================================
87 Geom_CylindricalSurface::Geom_CylindricalSurface ( const Ax3& A3,
88 const Standard_Real R)
91 if (R < 0.0) throw Standard_ConstructionError();
96 //=======================================================================
97 //function : UReversedParameter
99 //=======================================================================
101 Standard_Real Geom_CylindricalSurface::UReversedParameter( const Standard_Real U) const
103 return (2.*M_PI - U);
106 //=======================================================================
107 //function : VReversedParameter
109 //=======================================================================
111 Standard_Real Geom_CylindricalSurface::VReversedParameter( const Standard_Real V) const
116 //=======================================================================
119 //=======================================================================
121 Standard_Real Geom_CylindricalSurface::Radius () const { return radius; }
123 //=======================================================================
124 //function : IsUClosed
126 //=======================================================================
128 Standard_Boolean Geom_CylindricalSurface::IsUClosed () const { return Standard_True; }
130 //=======================================================================
131 //function : IsVClosed
133 //=======================================================================
135 Standard_Boolean Geom_CylindricalSurface::IsVClosed () const { return Standard_False; }
137 //=======================================================================
138 //function : IsUPeriodic
140 //=======================================================================
142 Standard_Boolean Geom_CylindricalSurface::IsUPeriodic () const { return Standard_True; }
144 //=======================================================================
145 //function : IsVPeriodic
147 //=======================================================================
149 Standard_Boolean Geom_CylindricalSurface::IsVPeriodic () const { return Standard_False; }
151 //=======================================================================
152 //function : SetCylinder
154 //=======================================================================
156 void Geom_CylindricalSurface::SetCylinder (const gp_Cylinder& C) {
163 //=======================================================================
164 //function : SetRadius
166 //=======================================================================
168 void Geom_CylindricalSurface::SetRadius (const Standard_Real R) {
170 if (R < 0.0) { throw Standard_ConstructionError(); }
175 //=======================================================================
178 //=======================================================================
180 void Geom_CylindricalSurface::Bounds (Standard_Real& U1, Standard_Real& U2,
181 Standard_Real& V1, Standard_Real& V2) const {
183 U1 = 0.0; U2 = 2.0 * M_PI;
184 V1 = - Precision::Infinite(); V2 = Precision::Infinite();
188 //=======================================================================
189 //function : Coefficients
191 //=======================================================================
193 void Geom_CylindricalSurface::Coefficients (Standard_Real& A1, Standard_Real& A2, Standard_Real& A3,
194 Standard_Real& B1, Standard_Real& B2, Standard_Real& B3,
195 Standard_Real& C1, Standard_Real& C2, Standard_Real& C3,
196 Standard_Real& D) const {
197 // Dans le repere local du cylindre :
198 // X**2 + Y**2 - radius = 0.0
201 T.SetTransformation (pos);
202 Standard_Real T11 = T.Value (1, 1);
203 Standard_Real T12 = T.Value (1, 2);
204 Standard_Real T13 = T.Value (1, 3);
205 Standard_Real T14 = T.Value (1, 4);
206 Standard_Real T21 = T.Value (2, 1);
207 Standard_Real T22 = T.Value (2, 2);
208 Standard_Real T23 = T.Value (2, 3);
209 Standard_Real T24 = T.Value (2, 4);
210 A1 = T11 * T11 + T21 * T21;
211 A2 = T12 * T12 + T22 * T22;
212 A3 = T13 * T13 + T23 * T23;
213 B1 = T11 * T12 + T21 * T22;
214 B2 = T11 * T13 + T21 * T23;
215 B3 = T12 * T13 + T22 * T23;
216 C1 = T11 * T14 + T21 * T24;
217 C2 = T12 * T14 + T22 * T24;
218 C3 = T13 * T14 + T23 * T24;
219 D = T14 * T14 + T24 * T24 - radius * radius;
224 //=======================================================================
225 //function : Cylinder
227 //=======================================================================
229 gp_Cylinder Geom_CylindricalSurface::Cylinder () const {
231 return gp_Cylinder (pos, radius);
235 //=======================================================================
238 //=======================================================================
240 void Geom_CylindricalSurface::D0 (const Standard_Real U,
241 const Standard_Real V,
244 ElSLib::CylinderD0 (U, V, pos, radius, P);
248 //=======================================================================
251 //=======================================================================
253 void Geom_CylindricalSurface::D1 (const Standard_Real U, const Standard_Real V ,
255 Vec& D1U, Vec& D1V) const
257 ElSLib::CylinderD1 (U, V, pos, radius, P, D1U, D1V);
262 //=======================================================================
265 //=======================================================================
267 void Geom_CylindricalSurface::D2 (const Standard_Real U, const Standard_Real V,
270 Vec& D2U, Vec& D2V, Vec& D2UV) const
272 ElSLib::CylinderD2 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, D2UV);
277 //=======================================================================
280 //=======================================================================
282 void Geom_CylindricalSurface::D3 (const Standard_Real U, const Standard_Real V,
285 Vec& D2U, Vec& D2V, Vec& D2UV,
286 Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV)
289 ElSLib::CylinderD3 (U, V, pos, radius, P, D1U, D1V, D2U, D2V,
290 D2UV, D3U, D3V, D3UUV, D3UVV);
294 //=======================================================================
297 //=======================================================================
299 Vec Geom_CylindricalSurface::DN (const Standard_Real U , const Standard_Real V ,
300 const Standard_Integer Nu, const Standard_Integer Nv ) const
302 Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
304 if (Nv > 1) { return Vec (0.0, 0.0, 0.0); }
306 return ElSLib::CylinderDN (U, V, pos, radius, Nu, Nv);
313 //=======================================================================
316 //=======================================================================
318 Handle(Geom_Curve) Geom_CylindricalSurface::UIso (const Standard_Real U) const
320 Handle(Geom_Line) GL = new Geom_Line(ElSLib::CylinderUIso(pos,radius,U));
326 //=======================================================================
329 //=======================================================================
331 Handle(Geom_Curve) Geom_CylindricalSurface::VIso (const Standard_Real V) const
333 Handle(Geom_Circle) GC = new Geom_Circle(ElSLib::CylinderVIso(pos,radius,V));
339 //=======================================================================
340 //function : Transform
342 //=======================================================================
344 void Geom_CylindricalSurface::Transform (const Trsf& T) {
346 radius = radius * Abs(T.ScaleFactor());
350 //=======================================================================
351 //function : TransformParameters
353 //=======================================================================
355 void Geom_CylindricalSurface::TransformParameters(Standard_Real& ,
360 if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
363 //=======================================================================
364 //function : ParametricTransformation
366 //=======================================================================
368 gp_GTrsf2d Geom_CylindricalSurface::ParametricTransformation(const gp_Trsf& T)
372 gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
373 T2.SetAffinity(Axis, Abs(T.ScaleFactor()));
377 //=======================================================================
378 //function : DumpJson
380 //=======================================================================
381 void Geom_CylindricalSurface::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
383 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
385 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Geom_ElementarySurface)
387 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, radius)