Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 09:16:11

0001 // Created on: 1993-03-10
0002 // Created by: JCV
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Geom_SurfaceOfRevolution_HeaderFile
0018 #define _Geom_SurfaceOfRevolution_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <gp_Pnt.hxx>
0024 #include <Geom_SweptSurface.hxx>
0025 #include <GeomEvaluator_SurfaceOfRevolution.hxx>
0026 #include <Standard_Integer.hxx>
0027 class Geom_Curve;
0028 class gp_Ax1;
0029 class gp_Dir;
0030 class gp_Ax2;
0031 class gp_Trsf;
0032 class gp_GTrsf2d;
0033 class gp_Vec;
0034 class Geom_Geometry;
0035 
0036 class Geom_SurfaceOfRevolution;
0037 DEFINE_STANDARD_HANDLE(Geom_SurfaceOfRevolution, Geom_SweptSurface)
0038 
0039 //! Describes a surface of revolution (revolved surface).
0040 //! Such a surface is obtained by rotating a curve (called
0041 //! the "meridian") through a complete revolution about
0042 //! an axis (referred to as the "axis of revolution"). The
0043 //! curve and the axis must be in the same plane (the
0044 //! "reference plane" of the surface).
0045 //! Rotation around the axis of revolution in the
0046 //! trigonometric sense defines the u parametric
0047 //! direction. So the u parameter is an angle, and its
0048 //! origin is given by the position of the meridian on the surface.
0049 //! The parametric range for the u parameter is: [ 0, 2.*Pi ]
0050 //! The v parameter is that of the meridian.
0051 //! Note: A surface of revolution is built from a copy of the
0052 //! original meridian. As a result the original meridian is
0053 //! not modified when the surface is modified.
0054 //! The form of a surface of revolution is typically a
0055 //! general revolution surface
0056 //! (GeomAbs_RevolutionForm). It can be:
0057 //! - a conical surface, if the meridian is a line or a
0058 //! trimmed line (GeomAbs_ConicalForm),
0059 //! - a cylindrical surface, if the meridian is a line or a
0060 //! trimmed line parallel to the axis of revolution
0061 //! (GeomAbs_CylindricalForm),
0062 //! - a planar surface if the meridian is a line or a
0063 //! trimmed line perpendicular to the axis of revolution
0064 //! of the surface (GeomAbs_PlanarForm),
0065 //! - a toroidal surface, if the meridian is a circle or a
0066 //! trimmed circle (GeomAbs_ToroidalForm), or
0067 //! - a spherical surface, if the meridian is a circle, the
0068 //! center of which is located on the axis of the
0069 //! revolved surface (GeomAbs_SphericalForm).
0070 //! Warning
0071 //! Be careful not to construct a surface of revolution
0072 //! where the curve and the axis or revolution are not
0073 //! defined in the same plane. If you do not have a
0074 //! correct configuration, you can correct your initial
0075 //! curve, using a cylindrical projection in the reference plane.
0076 class Geom_SurfaceOfRevolution : public Geom_SweptSurface
0077 {
0078 
0079 public:
0080   //! C : is the meridian  or the referenced curve.
0081   //! A1 is the axis of revolution.
0082   //! The form of a SurfaceOfRevolution can be :
0083   //! . a general revolution surface (RevolutionForm),
0084   //! . a conical surface if the meridian is a line or a trimmed line
0085   //! (ConicalForm),
0086   //! . a cylindrical surface if the meridian is a line or a trimmed
0087   //! line parallel to the revolution axis (CylindricalForm),
0088   //! . a planar surface if the meridian is a line perpendicular to
0089   //! the revolution axis of the surface (PlanarForm).
0090   //! . a spherical surface,
0091   //! . a toroidal surface,
0092   //! . a quadric surface.
0093   //! Warnings :
0094   //! It is not checked that the curve C is planar and that the
0095   //! surface axis is in the plane of the curve.
0096   //! It is not checked that the revolved curve C doesn't
0097   //! self-intersects.
0098   Standard_EXPORT Geom_SurfaceOfRevolution(const Handle(Geom_Curve)& C, const gp_Ax1& A1);
0099 
0100   //! Changes the axis of revolution.
0101   //! Warnings :
0102   //! It is not checked that the axis is in the plane of the
0103   //! revolved curve.
0104   Standard_EXPORT void SetAxis(const gp_Ax1& A1);
0105 
0106   //! Changes the direction of the revolution axis.
0107   //! Warnings :
0108   //! It is not checked that the axis is in the plane of the
0109   //! revolved curve.
0110   Standard_EXPORT void SetDirection(const gp_Dir& V);
0111 
0112   //! Changes the revolved curve of the surface.
0113   //! Warnings :
0114   //! It is not checked that the curve C is planar and that the
0115   //! surface axis is in the plane of the curve.
0116   //! It is not checked that the revolved curve C doesn't
0117   //! self-intersects.
0118   Standard_EXPORT void SetBasisCurve(const Handle(Geom_Curve)& C);
0119 
0120   //! Changes the location point of the revolution axis.
0121   //! Warnings :
0122   //! It is not checked that the axis is in the plane of the
0123   //! revolved curve.
0124   Standard_EXPORT void SetLocation(const gp_Pnt& P);
0125 
0126   //! Returns the revolution axis of the surface.
0127   Standard_EXPORT gp_Ax1 Axis() const;
0128 
0129   //! Returns the location point of the axis of revolution.
0130   Standard_EXPORT const gp_Pnt& Location() const;
0131 
0132   //! Computes the position of the reference plane of the surface
0133   //! defined by the basis curve and the symmetry axis.
0134   //! The location point is the location point of the revolution's
0135   //! axis, the XDirection of the plane is given by the revolution's
0136   //! axis and the orientation of the normal to the plane is given
0137   //! by the sense of revolution.
0138   //!
0139   //! Raised if the revolved curve is not planar or if the revolved
0140   //! curve and the symmetry axis are not in the same plane or if
0141   //! the maximum of distance between the axis and the revolved
0142   //! curve is lower or equal to Resolution from gp.
0143   Standard_EXPORT gp_Ax2 ReferencePlane() const;
0144 
0145   //! Changes the orientation of this surface of revolution
0146   //! in the u  parametric direction. The bounds of the
0147   //! surface are not changed but the given parametric
0148   //! direction is reversed. Hence the orientation of the
0149   //! surface is reversed.
0150   //! As a consequence:
0151   //! - UReverse reverses the direction of the axis of
0152   //! revolution of this surface,
0153   Standard_EXPORT void UReverse() Standard_OVERRIDE;
0154 
0155   //! Computes the u  parameter on the modified
0156   //! surface, when reversing its u  parametric
0157   //! direction, for any point of u parameter U  on this surface of revolution.
0158   //! In the case of a revolved surface:
0159   //! - UReversedParameter returns 2.*Pi - U
0160   Standard_EXPORT Standard_Real UReversedParameter(const Standard_Real U) const Standard_OVERRIDE;
0161 
0162   //! Changes the orientation of this surface of revolution
0163   //! in the v parametric direction. The bounds of the
0164   //! surface are not changed but the given parametric
0165   //! direction is reversed. Hence the orientation of the
0166   //! surface is reversed.
0167   //! As a consequence:
0168   //! - VReverse reverses the meridian of this surface of revolution.
0169   Standard_EXPORT void VReverse() Standard_OVERRIDE;
0170 
0171   //! Computes the  v parameter on the modified
0172   //! surface, when reversing its  v parametric
0173   //! direction, for any point of v parameter V on this surface of revolution.
0174   //! In the case of a revolved surface:
0175   //! - VReversedParameter returns the reversed
0176   //! parameter given by the function
0177   //! ReversedParameter called with V on the meridian.
0178   Standard_EXPORT Standard_Real VReversedParameter(const Standard_Real V) const Standard_OVERRIDE;
0179 
0180   //! Computes the  parameters on the  transformed  surface for
0181   //! the transform of the point of parameters U,V on <me>.
0182   //! @code
0183   //!   me->Transformed(T)->Value(U',V')
0184   //! @endcode
0185   //! is the same point as
0186   //! @code
0187   //!   me->Value(U,V).Transformed(T)
0188   //! @endcode
0189   //! Where U',V' are the new values of U,V after calling
0190   //! @code
0191   //!   me->TransformParameters(U,V,T)
0192   //! @endcode
0193   //! This method multiplies V by BasisCurve()->ParametricTransformation(T)
0194   Standard_EXPORT virtual void TransformParameters(Standard_Real& U,
0195                                                    Standard_Real& V,
0196                                                    const gp_Trsf& T) const Standard_OVERRIDE;
0197 
0198   //! Returns a 2d transformation  used to find the  new
0199   //! parameters of a point on the transformed surface.
0200   //! @code
0201   //!   me->Transformed(T)->Value(U',V')
0202   //! @endcode
0203   //! is the same point as
0204   //! @code
0205   //!   me->Value(U,V).Transformed(T)
0206   //! @endcode
0207   //! Where U',V' are  obtained by transforming U,V with
0208   //! the 2d transformation returned by
0209   //! @code
0210   //!   me->ParametricTransformation(T)
0211   //! @endcode
0212   //! This  method  returns  a scale  centered  on  the
0213   //! U axis with BasisCurve()->ParametricTransformation(T)
0214   Standard_EXPORT virtual gp_GTrsf2d ParametricTransformation(const gp_Trsf& T) const
0215     Standard_OVERRIDE;
0216 
0217   //! Returns the parametric bounds U1, U2 , V1 and V2 of this surface.
0218   //! A surface of revolution is always complete, so U1 = 0, U2 = 2*PI.
0219   Standard_EXPORT void Bounds(Standard_Real& U1,
0220                               Standard_Real& U2,
0221                               Standard_Real& V1,
0222                               Standard_Real& V2) const Standard_OVERRIDE;
0223 
0224   //! IsUClosed always returns true.
0225   Standard_EXPORT Standard_Boolean IsUClosed() const Standard_OVERRIDE;
0226 
0227   //! IsVClosed returns true if the meridian of this
0228   //! surface of revolution is closed.
0229   Standard_EXPORT Standard_Boolean IsVClosed() const Standard_OVERRIDE;
0230 
0231   //! IsCNu always returns true.
0232   Standard_EXPORT Standard_Boolean IsCNu(const Standard_Integer N) const Standard_OVERRIDE;
0233 
0234   //! IsCNv returns true if the degree of continuity of the
0235   //! meridian of this surface of revolution is at least N.
0236   //! Raised if N < 0.
0237   Standard_EXPORT Standard_Boolean IsCNv(const Standard_Integer N) const Standard_OVERRIDE;
0238 
0239   //! Returns True.
0240   Standard_EXPORT Standard_Boolean IsUPeriodic() const Standard_OVERRIDE;
0241 
0242   //! IsVPeriodic returns true if the meridian of this
0243   //! surface of revolution is periodic.
0244   Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE;
0245 
0246   //! Computes the U isoparametric curve of this surface
0247   //! of revolution. It is the curve obtained by rotating the
0248   //! meridian through an angle U about the axis of revolution.
0249   Standard_EXPORT Handle(Geom_Curve) UIso(const Standard_Real U) const Standard_OVERRIDE;
0250 
0251   //! Computes the U isoparametric curve of this surface
0252   //! of revolution. It is the curve obtained by rotating the
0253   //! meridian through an angle U about the axis of revolution.
0254   Standard_EXPORT Handle(Geom_Curve) VIso(const Standard_Real V) const Standard_OVERRIDE;
0255 
0256   //! Computes the  point P (U, V) on the surface.
0257   //! U is the angle of the rotation around the revolution axis.
0258   //! The direction of this axis gives the sense of rotation.
0259   //! V is the parameter of the revolved curve.
0260   Standard_EXPORT void D0(const Standard_Real U,
0261                           const Standard_Real V,
0262                           gp_Pnt&             P) const Standard_OVERRIDE;
0263 
0264   //! Computes the current point and the first derivatives
0265   //! in the directions U and V.
0266   //! Raised if the continuity of the surface is not C1.
0267   Standard_EXPORT void D1(const Standard_Real U,
0268                           const Standard_Real V,
0269                           gp_Pnt&             P,
0270                           gp_Vec&             D1U,
0271                           gp_Vec&             D1V) const Standard_OVERRIDE;
0272 
0273   //! Computes the current point, the first and the second derivatives
0274   //! in the directions U and V.
0275   //! Raised if the continuity of the surface is not C2.
0276   Standard_EXPORT void D2(const Standard_Real U,
0277                           const Standard_Real V,
0278                           gp_Pnt&             P,
0279                           gp_Vec&             D1U,
0280                           gp_Vec&             D1V,
0281                           gp_Vec&             D2U,
0282                           gp_Vec&             D2V,
0283                           gp_Vec&             D2UV) const Standard_OVERRIDE;
0284 
0285   //! Computes the current point, the first,the second and the third
0286   //! derivatives in the directions U and V.
0287   //! Raised if the continuity of the surface is not C3.
0288   Standard_EXPORT void D3(const Standard_Real U,
0289                           const Standard_Real V,
0290                           gp_Pnt&             P,
0291                           gp_Vec&             D1U,
0292                           gp_Vec&             D1V,
0293                           gp_Vec&             D2U,
0294                           gp_Vec&             D2V,
0295                           gp_Vec&             D2UV,
0296                           gp_Vec&             D3U,
0297                           gp_Vec&             D3V,
0298                           gp_Vec&             D3UUV,
0299                           gp_Vec&             D3UVV) const Standard_OVERRIDE;
0300 
0301   //! Computes the derivative of order Nu in the direction u and
0302   //! Nv in the direction v.
0303   //!
0304   //! Raised if the continuity of the surface is not CNu in the u
0305   //! direction and CNv in the v direction.
0306   //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
0307   //! The following  functions  evaluates the  local
0308   //! derivatives on surface. Useful to manage discontinuities
0309   //! on the surface.
0310   //! if    Side  =  1  ->  P  =  S( U+,V )
0311   //! if    Side  = -1  ->  P  =  S( U-,V )
0312   //! else  P  is betveen discontinuities
0313   //! can be evaluated using methods  of
0314   //! global evaluations    P  =  S( U ,V )
0315   Standard_EXPORT gp_Vec DN(const Standard_Real    U,
0316                             const Standard_Real    V,
0317                             const Standard_Integer Nu,
0318                             const Standard_Integer Nv) const Standard_OVERRIDE;
0319 
0320   //! Applies the transformation T to this surface of revolution.
0321   Standard_EXPORT void Transform(const gp_Trsf& T) Standard_OVERRIDE;
0322 
0323   //! Creates a new object which is a copy of this surface of revolution.
0324   Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
0325 
0326   //! Dumps the content of me into the stream
0327   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0328                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0329 
0330   DEFINE_STANDARD_RTTIEXT(Geom_SurfaceOfRevolution, Geom_SweptSurface)
0331 
0332 private:
0333   Handle(GeomEvaluator_SurfaceOfRevolution) myEvaluator;
0334   gp_Pnt                                    loc;
0335 };
0336 
0337 #endif // _Geom_SurfaceOfRevolution_HeaderFile