0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / Geom / Geom_SurfaceOfRevolution.hxx
1 // Created on: 1993-03-10
2 // Created by: JCV
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Geom_SurfaceOfRevolution_HeaderFile
18 #define _Geom_SurfaceOfRevolution_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <gp_Pnt.hxx>
24 #include <Geom_SweptSurface.hxx>
25 #include <GeomEvaluator_SurfaceOfRevolution.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Standard_Integer.hxx>
29 class Standard_ConstructionError;
30 class Standard_RangeError;
31 class Geom_UndefinedDerivative;
32 class Geom_Curve;
33 class gp_Ax1;
34 class gp_Dir;
35 class gp_Pnt;
36 class gp_Ax2;
37 class gp_Trsf;
38 class gp_GTrsf2d;
39 class gp_Vec;
40 class Geom_Geometry;
41
42
43 class Geom_SurfaceOfRevolution;
44 DEFINE_STANDARD_HANDLE(Geom_SurfaceOfRevolution, Geom_SweptSurface)
45
46 //! Describes a surface of revolution (revolved surface).
47 //! Such a surface is obtained by rotating a curve (called
48 //! the "meridian") through a complete revolution about
49 //! an axis (referred to as the "axis of revolution"). The
50 //! curve and the axis must be in the same plane (the
51 //! "reference plane" of the surface).
52 //! Rotation around the axis of revolution in the
53 //! trigonometric sense defines the u parametric
54 //! direction. So the u parameter is an angle, and its
55 //! origin is given by the position of the meridian on the surface.
56 //! The parametric range for the u parameter is: [ 0, 2.*Pi ]
57 //! The v parameter is that of the meridian.
58 //! Note: A surface of revolution is built from a copy of the
59 //! original meridian. As a result the original meridian is
60 //! not modified when the surface is modified.
61 //! The form of a surface of revolution is typically a
62 //! general revolution surface
63 //! (GeomAbs_RevolutionForm). It can be:
64 //! - a conical surface, if the meridian is a line or a
65 //! trimmed line (GeomAbs_ConicalForm),
66 //! - a cylindrical surface, if the meridian is a line or a
67 //! trimmed line parallel to the axis of revolution
68 //! (GeomAbs_CylindricalForm),
69 //! - a planar surface if the meridian is a line or a
70 //! trimmed line perpendicular to the axis of revolution
71 //! of the surface (GeomAbs_PlanarForm),
72 //! - a toroidal surface, if the meridian is a circle or a
73 //! trimmed circle (GeomAbs_ToroidalForm), or
74 //! - a spherical surface, if the meridian is a circle, the
75 //! center of which is located on the axis of the
76 //! revolved surface (GeomAbs_SphericalForm).
77 //! Warning
78 //! Be careful not to construct a surface of revolution
79 //! where the curve and the axis or revolution are not
80 //! defined in the same plane. If you do not have a
81 //! correct configuration, you can correct your initial
82 //! curve, using a cylindrical projection in the reference plane.
83 class Geom_SurfaceOfRevolution : public Geom_SweptSurface
84 {
85
86 public:
87
88   
89
90   //! C : is the meridian  or the referenced curve.
91   //! A1 is the axis of revolution.
92   //! The form of a SurfaceOfRevolution can be :
93   //! . a general revolution surface (RevolutionForm),
94   //! . a conical surface if the meridian is a line or a trimmed line
95   //! (ConicalForm),
96   //! . a cylindrical surface if the meridian is a line or a trimmed
97   //! line parallel to the revolution axis (CylindricalForm),
98   //! . a planar surface if the meridian is a line perpendicular to
99   //! the revolution axis of the surface (PlanarForm).
100   //! . a spherical surface,
101   //! . a toroidal surface,
102   //! . a quadric surface.
103   //! Warnings :
104   //! It is not checked that the curve C is planar and that the
105   //! surface axis is in the plane of the curve.
106   //! It is not checked that the revolved curve C doesn't
107   //! self-intersects.
108   Standard_EXPORT Geom_SurfaceOfRevolution(const Handle(Geom_Curve)& C, const gp_Ax1& A1);
109   
110   //! Changes the axis of revolution.
111   //! Warnings :
112   //! It is not checked that the axis is in the plane of the
113   //! revolved curve.
114   Standard_EXPORT void SetAxis (const gp_Ax1& A1);
115   
116   //! Changes the direction of the revolution axis.
117   //! Warnings :
118   //! It is not checked that the axis is in the plane of the
119   //! revolved curve.
120   Standard_EXPORT void SetDirection (const gp_Dir& V);
121   
122   //! Changes the revolved curve of the surface.
123   //! Warnings :
124   //! It is not checked that the curve C is planar and that the
125   //! surface axis is in the plane of the curve.
126   //! It is not checked that the revolved curve C doesn't
127   //! self-intersects.
128   Standard_EXPORT void SetBasisCurve (const Handle(Geom_Curve)& C);
129   
130   //! Changes the location point of the revolution axis.
131   //! Warnings :
132   //! It is not checked that the axis is in the plane of the
133   //! revolved curve.
134   Standard_EXPORT void SetLocation (const gp_Pnt& P);
135   
136   //! Returns the revolution axis of the surface.
137   Standard_EXPORT gp_Ax1 Axis() const;
138   
139
140   //! Returns the location point of the axis of revolution.
141   Standard_EXPORT const gp_Pnt& Location() const;
142   
143
144   //! Computes the position of the reference plane of the surface
145   //! defined by the basis curve and the symmetry axis.
146   //! The location point is the location point of the revolution's
147   //! axis, the XDirection of the plane is given by the revolution's
148   //! axis and the orientation of the normal to the plane is given
149   //! by the sense of revolution.
150   //!
151   //! Raised if the revolved curve is not planar or if the revolved
152   //! curve and the symmetry axis are not in the same plane or if
153   //! the maximum of distance between the axis and the revolved
154   //! curve is lower or equal to Resolution from gp.
155   Standard_EXPORT gp_Ax2 ReferencePlane() const;
156   
157   //! Changes the orientation of this surface of revolution
158   //! in the u  parametric direction. The bounds of the
159   //! surface are not changed but the given parametric
160   //! direction is reversed. Hence the orientation of the
161   //! surface is reversed.
162   //! As a consequence:
163   //! - UReverse reverses the direction of the axis of
164   //! revolution of this surface,
165   Standard_EXPORT void UReverse() Standard_OVERRIDE;
166   
167   //! Computes the u  parameter on the modified
168   //! surface, when reversing its u  parametric
169   //! direction, for any point of u parameter U  on this surface of revolution.
170   //! In the case of a revolved surface:
171   //! - UReversedParameter returns 2.*Pi - U
172   Standard_EXPORT Standard_Real UReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
173   
174   //! Changes the orientation of this surface of revolution
175   //! in the v parametric direction. The bounds of the
176   //! surface are not changed but the given parametric
177   //! direction is reversed. Hence the orientation of the
178   //! surface is reversed.
179   //! As a consequence:
180   //! - VReverse reverses the meridian of this surface of revolution.
181   Standard_EXPORT void VReverse() Standard_OVERRIDE;
182   
183   //! Computes the  v parameter on the modified
184   //! surface, when reversing its  v parametric
185   //! direction, for any point of v parameter V on this surface of revolution.
186   //! In the case of a revolved surface:
187   //! - VReversedParameter returns the reversed
188   //! parameter given by the function
189   //! ReversedParameter called with V on the meridian.
190   Standard_EXPORT Standard_Real VReversedParameter (const Standard_Real V) const Standard_OVERRIDE;
191   
192   //! Computes the  parameters on the  transformed  surface for
193   //! the transform of the point of parameters U,V on <me>.
194   //!
195   //! me->Transformed(T)->Value(U',V')
196   //!
197   //! is the same point as
198   //!
199   //! me->Value(U,V).Transformed(T)
200   //!
201   //! Where U',V' are the new values of U,V after calling
202   //!
203   //! me->TranformParameters(U,V,T)
204   //!
205   //! This methods multiplies V by
206   //! BasisCurve()->ParametricTransformation(T)
207   Standard_EXPORT virtual void TransformParameters (Standard_Real& U, Standard_Real& V, const gp_Trsf& T) const Standard_OVERRIDE;
208   
209   //! Returns a 2d transformation  used to find the  new
210   //! parameters of a point on the transformed surface.
211   //!
212   //! me->Transformed(T)->Value(U',V')
213   //!
214   //! is the same point as
215   //!
216   //! me->Value(U,V).Transformed(T)
217   //!
218   //! Where U',V' are  obtained by transforming U,V with
219   //! th 2d transformation returned by
220   //!
221   //! me->ParametricTransformation(T)
222   //!
223   //! This  methods  returns  a scale  centered  on  the
224   //! U axis with BasisCurve()->ParametricTransformation(T)
225   Standard_EXPORT virtual gp_GTrsf2d ParametricTransformation (const gp_Trsf& T) const Standard_OVERRIDE;
226   
227   //! Returns the parametric bounds U1, U2 , V1 and V2 of this surface.
228   //! A surface of revolution is always complete, so U1 = 0, U2 = 2*PI.
229   Standard_EXPORT void Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const Standard_OVERRIDE;
230   
231   //! IsUClosed always returns true.
232   Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE;
233   
234   //! IsVClosed returns true if the meridian of this
235   //! surface of revolution is closed.
236   Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE;
237   
238   //! IsCNu always returns true.
239   Standard_EXPORT Standard_Boolean IsCNu (const Standard_Integer N) const Standard_OVERRIDE;
240   
241   //! IsCNv returns true if the degree of continuity of the
242   //! meridian of this surface of revolution is at least N.
243   //! Raised if N < 0.
244   Standard_EXPORT Standard_Boolean IsCNv (const Standard_Integer N) const Standard_OVERRIDE;
245   
246   //! Returns True.
247   Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE;
248   
249   //! IsVPeriodic returns true if the meridian of this
250   //! surface of revolution is periodic.
251   Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE;
252   
253   //! Computes the U isoparametric curve of this surface
254   //! of revolution. It is the curve obtained by rotating the
255   //! meridian through an angle U about the axis of revolution.
256   Standard_EXPORT Handle(Geom_Curve) UIso (const Standard_Real U) const Standard_OVERRIDE;
257   
258   //! Computes the U isoparametric curve of this surface
259   //! of revolution. It is the curve obtained by rotating the
260   //! meridian through an angle U about the axis of revolution.
261   Standard_EXPORT Handle(Geom_Curve) VIso (const Standard_Real V) const Standard_OVERRIDE;
262   
263   //! Computes the  point P (U, V) on the surface.
264   //! U is the angle of the rotation around the revolution axis.
265   //! The direction of this axis gives the sense of rotation.
266   //! V is the parameter of the revolved curve.
267   Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE;
268
269   //! Computes the current point and the first derivatives
270   //! in the directions U and V.
271   //! Raised if the continuity of the surface is not C1.
272   Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE;
273
274   //! Computes the current point, the first and the second derivatives
275   //! in the directions U and V.
276   //! Raised if the continuity of the surface is not C2.
277   Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const Standard_OVERRIDE;
278
279   //! Computes the current point, the first,the second and the third
280   //! derivatives in the directions U and V.
281   //! Raised if the continuity of the surface is not C3.
282   Standard_EXPORT void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const Standard_OVERRIDE;
283
284   //! Computes the derivative of order Nu in the direction u and
285   //! Nv in the direction v.
286   //!
287   //! Raised if the continuity of the surface is not CNu in the u
288   //! direction and CNv in the v direction.
289   //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
290   //! The following  functions  evaluates the  local
291   //! derivatives on surface. Useful to manage discontinuities
292   //! on the surface.
293   //! if    Side  =  1  ->  P  =  S( U+,V )
294   //! if    Side  = -1  ->  P  =  S( U-,V )
295   //! else  P  is betveen discontinuities
296   //! can be evaluated using methods  of
297   //! global evaluations    P  =  S( U ,V )
298   Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const Standard_OVERRIDE;
299
300   //! Applies the transformation T to this surface of revolution.
301   Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
302   
303   //! Creates a new object which is a copy of this surface of revolution.
304   Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
305
306   //! Dumps the content of me into the stream
307   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
308
309
310   DEFINE_STANDARD_RTTIEXT(Geom_SurfaceOfRevolution,Geom_SweptSurface)
311
312 private:
313   Handle(GeomEvaluator_SurfaceOfRevolution) myEvaluator;
314   gp_Pnt loc;
315 };
316
317 #endif // _Geom_SurfaceOfRevolution_HeaderFile