Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-12-03 10:54:51

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_SphericalSurface_HeaderFile
0018 #define _Geom_SphericalSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom_ElementarySurface.hxx>
0024 
0025 class gp_Ax3;
0026 class gp_Sphere;
0027 class gp_Trsf;
0028 class Geom_Geometry;
0029 
0030 //! Describes a sphere.
0031 //! A sphere is defined by its radius, and is positioned in
0032 //! space by a coordinate system (a gp_Ax3 object), the
0033 //! origin of which is the center of the sphere.
0034 //! This coordinate system is the "local coordinate
0035 //! system" of the sphere. The following apply:
0036 //! - Rotation around its "main Axis", in the trigonometric
0037 //! sense given by the "X Direction" and the "Y
0038 //! Direction", defines the u parametric direction.
0039 //! - Its "X Axis" gives the origin for the u parameter.
0040 //! - The "reference meridian" of the sphere is a
0041 //! half-circle, of radius equal to the radius of the
0042 //! sphere. It is located in the plane defined by the
0043 //! origin, "X Direction" and "main Direction", centered
0044 //! on the origin, and positioned on the positive side of the "X Axis".
0045 //! - Rotation around the "Y Axis" gives the v parameter
0046 //! on the reference meridian.
0047 //! - The "X Axis" gives the origin of the v parameter on
0048 //! the reference meridian.
0049 //! - The v parametric direction is oriented by the "main
0050 //! Direction", i.e. when v increases, the Z coordinate
0051 //! increases. (This implies that the "Y Direction"
0052 //! orients the reference meridian only when the local
0053 //! coordinate system is indirect.)
0054 //! - The u isoparametric curve is a half-circle obtained
0055 //! by rotating the reference meridian of the sphere
0056 //! through an angle u around the "main Axis", in the
0057 //! trigonometric sense defined by the "X Direction"
0058 //! and the "Y Direction".
0059 //! The parametric equation of the sphere is:
0060 //! P(u,v) = O + R*cos(v)*(cos(u)*XDir + sin(u)*YDir)+R*sin(v)*ZDir
0061 //! where:
0062 //! - O, XDir, YDir and ZDir are respectively the
0063 //! origin, the "X Direction", the "Y Direction" and the "Z
0064 //! Direction" of its local coordinate system, and
0065 //! - R is the radius of the sphere.
0066 //! The parametric range of the two parameters is:
0067 //! - [ 0, 2.*Pi ] for u, and
0068 //! - [ - Pi/2., + Pi/2. ] for v.
0069 class Geom_SphericalSurface : public Geom_ElementarySurface
0070 {
0071 
0072 public:
0073   //! A3 is the local coordinate system of the surface.
0074   //! At the creation the parametrization of the surface is defined
0075   //! such as the normal Vector (N = D1U ^ D1V) is directed away from
0076   //! the center of the sphere.
0077   //! The direction of increasing parametric value V is defined by the
0078   //! rotation around the "YDirection" of A2 in the trigonometric sense
0079   //! and the orientation of increasing parametric value U is defined
0080   //! by the rotation around the main direction of A2 in the
0081   //! trigonometric sense.
0082   //! Warnings :
0083   //! It is not forbidden to create a spherical surface with
0084   //! Radius = 0.0
0085   //! Raised if Radius < 0.0.
0086   Standard_EXPORT Geom_SphericalSurface(const gp_Ax3& A3, const double Radius);
0087 
0088   //! Creates a SphericalSurface from a non persistent Sphere from
0089   //! package gp.
0090   Standard_EXPORT Geom_SphericalSurface(const gp_Sphere& S);
0091 
0092   //! Assigns the value R to the radius of this sphere.
0093   //! Exceptions Standard_ConstructionError if R is less than 0.0.
0094   Standard_EXPORT void SetRadius(const double R);
0095 
0096   //! Converts the gp_Sphere S into this sphere.
0097   Standard_EXPORT void SetSphere(const gp_Sphere& S);
0098 
0099   //! Returns a non persistent sphere with the same geometric
0100   //! properties as <me>.
0101   Standard_EXPORT gp_Sphere Sphere() const;
0102 
0103   //! Computes the u parameter on the modified
0104   //! surface, when reversing its u parametric
0105   //! direction, for any point of u parameter U on this sphere.
0106   //! In the case of a sphere, these functions returns 2.PI - U.
0107   Standard_EXPORT double UReversedParameter(const double U) const final;
0108 
0109   //! Computes the v parameter on the modified
0110   //! surface, when reversing its v parametric
0111   //! direction, for any point of v parameter V on this sphere.
0112   //! In the case of a sphere, these functions returns -U.
0113   Standard_EXPORT double VReversedParameter(const double V) const final;
0114 
0115   //! Computes the area of the spherical surface.
0116   Standard_EXPORT double Area() const;
0117 
0118   //! Returns the parametric bounds U1, U2, V1 and V2 of this sphere.
0119   //! For a sphere: U1 = 0, U2 = 2*PI, V1 = -PI/2, V2 = PI/2.
0120   Standard_EXPORT void Bounds(double& U1, double& U2, double& V1, double& V2) const final;
0121 
0122   //! Returns the coefficients of the implicit equation of the
0123   //! quadric in the absolute cartesian coordinates system :
0124   //! These coefficients are normalized.
0125   //! A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) +
0126   //! 2.(C1.X + C2.Y + C3.Z) + D = 0.0
0127   Standard_EXPORT void Coefficients(double& A1,
0128                                     double& A2,
0129                                     double& A3,
0130                                     double& B1,
0131                                     double& B2,
0132                                     double& B3,
0133                                     double& C1,
0134                                     double& C2,
0135                                     double& C3,
0136                                     double& D) const;
0137 
0138   //! Computes the coefficients of the implicit equation of
0139   //! this quadric in the absolute Cartesian coordinate system:
0140   //! A1.X**2 + A2.Y**2 + A3.Z**2 + 2.(B1.X.Y + B2.X.Z + B3.Y.Z) +
0141   //! 2.(C1.X + C2.Y + C3.Z) + D = 0.0
0142   //! An implicit normalization is applied (i.e. A1 = A2 = 1.
0143   //! in the local coordinate system of this sphere).
0144   Standard_EXPORT double Radius() const;
0145 
0146   //! Computes the volume of the spherical surface.
0147   Standard_EXPORT double Volume() const;
0148 
0149   //! Returns True.
0150   Standard_EXPORT bool IsUClosed() const final;
0151 
0152   //! Returns False.
0153   Standard_EXPORT bool IsVClosed() const final;
0154 
0155   //! Returns True.
0156   Standard_EXPORT bool IsUPeriodic() const final;
0157 
0158   //! Returns False.
0159   Standard_EXPORT bool IsVPeriodic() const final;
0160 
0161   //! Computes the U isoparametric curve.
0162   //! The U isoparametric curves of the surface are defined by the
0163   //! section of the spherical surface with plane obtained by rotation
0164   //! of the plane (Location, XAxis, ZAxis) around ZAxis. This plane
0165   //! defines the origin of parametrization u.
0166   //! For a SphericalSurface the UIso curve is a Circle.
0167   //! Warnings : The radius of this circle can be zero.
0168   Standard_EXPORT occ::handle<Geom_Curve> UIso(const double U) const final;
0169 
0170   //! Computes the V isoparametric curve.
0171   //! The V isoparametric curves of the surface are defined by
0172   //! the section of the spherical surface with plane parallel to the
0173   //! plane (Location, XAxis, YAxis). This plane defines the origin of
0174   //! parametrization V.
0175   //! Be careful if V is close to PI/2 or 3*PI/2 the radius of the
0176   //! circle becomes tiny. It is not forbidden in this toolkit to
0177   //! create circle with radius = 0.0
0178   //! For a SphericalSurface the VIso curve is a Circle.
0179   //! Warnings : The radius of this circle can be zero.
0180   Standard_EXPORT occ::handle<Geom_Curve> VIso(const double V) const final;
0181 
0182   //! Computes the point P (U, V) on the surface.
0183   //! P (U, V) = Loc + Radius * Sin (V) * Zdir +
0184   //! Radius * Cos (V) * (cos (U) * XDir + sin (U) * YDir)
0185   //! where Loc is the origin of the placement plane (XAxis, YAxis)
0186   //! XDir is the direction of the XAxis and YDir the direction of
0187   //! the YAxis and ZDir the direction of the ZAxis.
0188   Standard_EXPORT gp_Pnt EvalD0(const double U, const double V) const final;
0189 
0190   //! Computes the current point and the first derivatives in the
0191   //! directions U and V.
0192   Standard_EXPORT Geom_Surface::ResD1 EvalD1(const double U, const double V) const final;
0193 
0194   //! Computes the current point, the first and the second derivatives
0195   //! in the directions U and V.
0196   Standard_EXPORT Geom_Surface::ResD2 EvalD2(const double U, const double V) const final;
0197 
0198   //! Computes the current point, the first,the second and the third
0199   //! derivatives in the directions U and V.
0200   Standard_EXPORT Geom_Surface::ResD3 EvalD3(const double U, const double V) const final;
0201 
0202   //! Computes the derivative of order Nu in the direction u
0203   //! and Nv in the direction v.
0204   //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
0205   Standard_EXPORT gp_Vec EvalDN(const double U,
0206                                 const double V,
0207                                 const int    Nu,
0208                                 const int    Nv) const final;
0209 
0210   //! Applies the transformation T to this sphere.
0211   Standard_EXPORT void Transform(const gp_Trsf& T) final;
0212 
0213   //! Creates a new object which is a copy of this sphere.
0214   Standard_EXPORT occ::handle<Geom_Geometry> Copy() const final;
0215 
0216   //! Dumps the content of me into the stream
0217   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const final;
0218 
0219   DEFINE_STANDARD_RTTIEXT(Geom_SphericalSurface, Geom_ElementarySurface)
0220 
0221 private:
0222   double radius;
0223 };
0224 
0225 #endif // _Geom_SphericalSurface_HeaderFile