1 // File: Geom_CylindricalSurface.cxx
2 // Created: Wed Mar 10 09:38:21 1993
5 // Copyright: Matra Datavision 1993
7 //File Geom_CylindricalSurface.cxx, JCV 17/01/91
9 #include <Geom_CylindricalSurface.ixx>
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>
19 #include <gp_Circ.hxx>
21 #include <gp_Ax2d.hxx>
25 typedef Geom_CylindricalSurface CylindricalSurface;
26 typedef Handle(Geom_CylindricalSurface) Handle(CylindricalSurface);
41 //=======================================================================
44 //=======================================================================
46 Handle(Geom_Geometry) Geom_CylindricalSurface::Copy () const {
48 Handle(CylindricalSurface) Cs;
49 Cs = new CylindricalSurface (pos, radius);
54 //=======================================================================
55 //function : Geom_CylindricalSurface
57 //=======================================================================
59 Geom_CylindricalSurface::Geom_CylindricalSurface (const gp_Cylinder& C)
60 : radius (C.Radius()) {
66 //=======================================================================
67 //function : Geom_CylindricalSurface
69 //=======================================================================
71 Geom_CylindricalSurface::Geom_CylindricalSurface ( const Ax3& A3,
72 const Standard_Real R)
75 if (R < 0.0) Standard_ConstructionError::Raise();
80 //=======================================================================
81 //function : UReversedParameter
83 //=======================================================================
85 Standard_Real Geom_CylindricalSurface::UReversedParameter( const Standard_Real U) const
90 //=======================================================================
91 //function : VReversedParameter
93 //=======================================================================
95 Standard_Real Geom_CylindricalSurface::VReversedParameter( const Standard_Real V) const
100 //=======================================================================
103 //=======================================================================
105 Standard_Real Geom_CylindricalSurface::Radius () const { return radius; }
107 //=======================================================================
108 //function : IsUClosed
110 //=======================================================================
112 Standard_Boolean Geom_CylindricalSurface::IsUClosed () const { return Standard_True; }
114 //=======================================================================
115 //function : IsVClosed
117 //=======================================================================
119 Standard_Boolean Geom_CylindricalSurface::IsVClosed () const { return Standard_False; }
121 //=======================================================================
122 //function : IsUPeriodic
124 //=======================================================================
126 Standard_Boolean Geom_CylindricalSurface::IsUPeriodic () const { return Standard_True; }
128 //=======================================================================
129 //function : IsVPeriodic
131 //=======================================================================
133 Standard_Boolean Geom_CylindricalSurface::IsVPeriodic () const { return Standard_False; }
135 //=======================================================================
136 //function : SetCylinder
138 //=======================================================================
140 void Geom_CylindricalSurface::SetCylinder (const gp_Cylinder& C) {
147 //=======================================================================
148 //function : SetRadius
150 //=======================================================================
152 void Geom_CylindricalSurface::SetRadius (const Standard_Real R) {
154 if (R < 0.0) { Standard_ConstructionError::Raise(); }
159 //=======================================================================
162 //=======================================================================
164 void Geom_CylindricalSurface::Bounds (Standard_Real& U1, Standard_Real& U2,
165 Standard_Real& V1, Standard_Real& V2) const {
167 U1 = 0.0; U2 = 2.0 * M_PI;
168 V1 = - Precision::Infinite(); V2 = Precision::Infinite();
172 //=======================================================================
173 //function : Coefficients
175 //=======================================================================
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
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);
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);
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;
219 //=======================================================================
220 //function : Cylinder
222 //=======================================================================
224 gp_Cylinder Geom_CylindricalSurface::Cylinder () const {
226 return gp_Cylinder (pos, radius);
230 //=======================================================================
233 //=======================================================================
235 void Geom_CylindricalSurface::D0 (const Standard_Real U,
236 const Standard_Real V,
239 ElSLib::CylinderD0 (U, V, pos, radius, P);
243 //=======================================================================
246 //=======================================================================
248 void Geom_CylindricalSurface::D1 (const Standard_Real U, const Standard_Real V ,
250 Vec& D1U, Vec& D1V) const
252 ElSLib::CylinderD1 (U, V, pos, radius, P, D1U, D1V);
257 //=======================================================================
260 //=======================================================================
262 void Geom_CylindricalSurface::D2 (const Standard_Real U, const Standard_Real V,
265 Vec& D2U, Vec& D2V, Vec& D2UV) const
267 ElSLib::CylinderD2 (U, V, pos, radius, P, D1U, D1V, D2U, D2V, D2UV);
272 //=======================================================================
275 //=======================================================================
277 void Geom_CylindricalSurface::D3 (const Standard_Real U, const Standard_Real V,
280 Vec& D2U, Vec& D2V, Vec& D2UV,
281 Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV)
284 ElSLib::CylinderD3 (U, V, pos, radius, P, D1U, D1V, D2U, D2V,
285 D2UV, D3U, D3V, D3UUV, D3UVV);
289 //=======================================================================
292 //=======================================================================
294 Vec Geom_CylindricalSurface::DN (const Standard_Real U , const Standard_Real V ,
295 const Standard_Integer Nu, const Standard_Integer Nv ) const
297 Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " ");
299 if (Nv > 1) { return Vec (0.0, 0.0, 0.0); }
301 return ElSLib::CylinderDN (U, V, pos, radius, Nu, Nv);
308 //=======================================================================
311 //=======================================================================
313 Handle(Geom_Curve) Geom_CylindricalSurface::UIso (const Standard_Real U) const
315 Handle(Geom_Line) GL = new Geom_Line(ElSLib::CylinderUIso(pos,radius,U));
321 //=======================================================================
324 //=======================================================================
326 Handle(Geom_Curve) Geom_CylindricalSurface::VIso (const Standard_Real V) const
328 Handle(Geom_Circle) GC = new Geom_Circle(ElSLib::CylinderVIso(pos,radius,V));
334 //=======================================================================
335 //function : Transform
337 //=======================================================================
339 void Geom_CylindricalSurface::Transform (const Trsf& T) {
341 radius = radius * Abs(T.ScaleFactor());
345 //=======================================================================
346 //function : TransformParameters
348 //=======================================================================
350 void Geom_CylindricalSurface::TransformParameters(Standard_Real& ,
355 if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor());
358 //=======================================================================
359 //function : ParametricTransformation
361 //=======================================================================
363 gp_GTrsf2d Geom_CylindricalSurface::ParametricTransformation(const gp_Trsf& T)
367 gp_Ax2d Axis(gp::Origin2d(),gp::DX2d());
368 T2.SetAffinity(Axis, Abs(T.ScaleFactor()));