Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:08

0001 // Copyright (c) 2025 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _GeomEval_EllipsoidSurface_HeaderFile
0015 #define _GeomEval_EllipsoidSurface_HeaderFile
0016 
0017 #include <Geom_ElementarySurface.hxx>
0018 
0019 //! Describes a triaxial ellipsoid surface.
0020 //! An ellipsoid is defined by three semi-axes A, B, C (all > 0)
0021 //! and is positioned in space by a coordinate system (a gp_Ax3 object),
0022 //! the origin of which is the center of the ellipsoid.
0023 //!
0024 //! The parametric equation of the ellipsoid is:
0025 //! @code
0026 //!   P(u,v) = O + A*cos(v)*cos(u)*XDir + B*cos(v)*sin(u)*YDir + C*sin(v)*ZDir
0027 //! @endcode
0028 //! where:
0029 //! - O, XDir, YDir and ZDir are respectively the origin,
0030 //!   the "X Direction", the "Y Direction" and the "Z Direction"
0031 //!   of its local coordinate system, and
0032 //! - A, B, C are the three semi-axes.
0033 //!
0034 //! The parametric range is:
0035 //! - [0, 2*Pi] for u, and
0036 //! - [-Pi/2, Pi/2] for v.
0037 //!
0038 //! When A == B the surface degenerates to a spheroid (ellipsoid of revolution).
0039 //!
0040 //! The implicit equation in local coordinates is:
0041 //! @code
0042 //!   X^2/A^2 + Y^2/B^2 + Z^2/C^2 - 1 = 0
0043 //! @endcode
0044 class GeomEval_EllipsoidSurface : public Geom_ElementarySurface
0045 {
0046 public:
0047   //! Creates a triaxial ellipsoid surface with the given local coordinate system
0048   //! and three semi-axes.
0049   //! @param[in] thePosition the local coordinate system
0050   //! @param[in] theA the semi-axis along XDir (must be > 0)
0051   //! @param[in] theB the semi-axis along YDir (must be > 0)
0052   //! @param[in] theC the semi-axis along ZDir (must be > 0)
0053   //! @throw Standard_ConstructionError if any semi-axis <= 0
0054   Standard_EXPORT GeomEval_EllipsoidSurface(const gp_Ax3& thePosition,
0055                                             double        theA,
0056                                             double        theB,
0057                                             double        theC);
0058 
0059   //! Returns the semi-axis A (along XDir).
0060   Standard_EXPORT double SemiAxisA() const;
0061 
0062   //! Returns the semi-axis B (along YDir).
0063   Standard_EXPORT double SemiAxisB() const;
0064 
0065   //! Returns the semi-axis C (along ZDir).
0066   Standard_EXPORT double SemiAxisC() const;
0067 
0068   //! Assigns the value theA to the semi-axis A.
0069   //! @param[in] theA the new semi-axis value (must be > 0)
0070   //! @throw Standard_ConstructionError if theA <= 0
0071   Standard_EXPORT void SetSemiAxisA(double theA);
0072 
0073   //! Assigns the value theB to the semi-axis B.
0074   //! @param[in] theB the new semi-axis value (must be > 0)
0075   //! @throw Standard_ConstructionError if theB <= 0
0076   Standard_EXPORT void SetSemiAxisB(double theB);
0077 
0078   //! Assigns the value theC to the semi-axis C.
0079   //! @param[in] theC the new semi-axis value (must be > 0)
0080   //! @throw Standard_ConstructionError if theC <= 0
0081   Standard_EXPORT void SetSemiAxisC(double theC);
0082 
0083   //! Reversal is not supported for this eval surface.
0084   //! @throw Standard_NotImplemented
0085   Standard_EXPORT void UReverse() final;
0086 
0087   //! Reversal is not supported for this eval surface.
0088   //! @throw Standard_NotImplemented
0089   Standard_EXPORT void VReverse() final;
0090 
0091   //! Reversal is not supported for this eval surface.
0092   //! @throw Standard_NotImplemented
0093   Standard_EXPORT double UReversedParameter(const double U) const final;
0094 
0095   //! Reversal is not supported for this eval surface.
0096   //! @throw Standard_NotImplemented
0097   Standard_EXPORT double VReversedParameter(const double V) const final;
0098 
0099   //! Returns the parametric bounds U1, U2, V1 and V2 of this ellipsoid.
0100   //! @param[out] U1 lower U bound (0)
0101   //! @param[out] U2 upper U bound (2*Pi)
0102   //! @param[out] V1 lower V bound (-Pi/2)
0103   //! @param[out] V2 upper V bound (Pi/2)
0104   Standard_EXPORT void Bounds(double& U1, double& U2, double& V1, double& V2) const final;
0105 
0106   //! Returns True. The ellipsoid is closed in U (period 2*Pi).
0107   Standard_EXPORT bool IsUClosed() const final;
0108 
0109   //! Returns False.
0110   Standard_EXPORT bool IsVClosed() const final;
0111 
0112   //! Returns True. The ellipsoid is periodic in U (period 2*Pi).
0113   Standard_EXPORT bool IsUPeriodic() const final;
0114 
0115   //! Returns False.
0116   Standard_EXPORT bool IsVPeriodic() const final;
0117 
0118   //! Computes the U isoparametric curve.
0119   //! For a triaxial ellipsoid, the U isoparametric curve is not
0120   //! a standard Geom_Curve type.
0121   //! @throw Standard_NotImplemented
0122   Standard_EXPORT occ::handle<Geom_Curve> UIso(const double U) const final;
0123 
0124   //! Computes the V isoparametric curve.
0125   //! For a triaxial ellipsoid, the V isoparametric curve is not
0126   //! a standard Geom_Curve type (it is an ellipse only when A == B).
0127   //! @throw Standard_NotImplemented
0128   Standard_EXPORT occ::handle<Geom_Curve> VIso(const double V) const final;
0129 
0130   //! Computes the point P(U, V) on the surface.
0131   //! @code
0132   //!   P(U, V) = O + A*cos(V)*cos(U)*XDir + B*cos(V)*sin(U)*YDir + C*sin(V)*ZDir
0133   //! @endcode
0134   Standard_EXPORT gp_Pnt EvalD0(const double U, const double V) const final;
0135 
0136   //! Computes the point and the first partial derivatives at (U, V).
0137   Standard_EXPORT Geom_Surface::ResD1 EvalD1(const double U, const double V) const final;
0138 
0139   //! Computes the point and partial derivatives up to 2nd order at (U, V).
0140   Standard_EXPORT Geom_Surface::ResD2 EvalD2(const double U, const double V) const final;
0141 
0142   //! Computes the point and partial derivatives up to 3rd order at (U, V).
0143   Standard_EXPORT Geom_Surface::ResD3 EvalD3(const double U, const double V) const final;
0144 
0145   //! Computes the derivative of order Nu in the direction u
0146   //! and Nv in the direction v.
0147   //! @param[in] U the u parameter
0148   //! @param[in] V the v parameter
0149   //! @param[in] Nu derivative order in u (must be >= 0)
0150   //! @param[in] Nv derivative order in v (must be >= 0)
0151   //! @return the derivative vector
0152   //! @throw Geom_UndefinedDerivative if Nu + Nv < 1 or Nu < 0 or Nv < 0
0153   Standard_EXPORT gp_Vec EvalDN(const double U,
0154                                 const double V,
0155                                 const int    Nu,
0156                                 const int    Nv) const final;
0157 
0158   //! Transformation is not supported for this eval geometry.
0159   //! @throw Standard_NotImplemented
0160   Standard_EXPORT void Transform(const gp_Trsf& T) final;
0161 
0162   //! Creates a new object which is a copy of this ellipsoid.
0163   Standard_EXPORT occ::handle<Geom_Geometry> Copy() const final;
0164 
0165   //! Dumps the content of me into the stream.
0166   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const final;
0167 
0168   //! Returns the coefficients of the implicit equation of the
0169   //! quadric in the absolute Cartesian coordinate system:
0170   //! @code
0171   //!   A1*X^2 + A2*Y^2 + A3*Z^2 + 2*(B1*X*Y + B2*X*Z + B3*Y*Z) +
0172   //!   2*(C1*X + C2*Y + C3*Z) + D = 0
0173   //! @endcode
0174   //! In local coordinates the equation is: X^2/A^2 + Y^2/B^2 + Z^2/C^2 - 1 = 0.
0175   Standard_EXPORT void Coefficients(double& A1,
0176                                     double& A2,
0177                                     double& A3,
0178                                     double& B1,
0179                                     double& B2,
0180                                     double& B3,
0181                                     double& C1,
0182                                     double& C2,
0183                                     double& C3,
0184                                     double& D) const;
0185 
0186   DEFINE_STANDARD_RTTIEXT(GeomEval_EllipsoidSurface, Geom_ElementarySurface)
0187 
0188 private:
0189   double myA; //!< Semi-axis along XDir
0190   double myB; //!< Semi-axis along YDir
0191   double myC; //!< Semi-axis along ZDir
0192 };
0193 
0194 #endif // _GeomEval_EllipsoidSurface_HeaderFile