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_HyperboloidSurface_HeaderFile
0015 #define _GeomEval_HyperboloidSurface_HeaderFile
0016 
0017 #include <Geom_ElementarySurface.hxx>
0018 
0019 //! Describes a hyperboloid of revolution surface (one-sheet or two-sheet).
0020 //!
0021 //! A hyperboloid is defined by two semi-axis radii R1 and R2, a sheet mode,
0022 //! and is positioned in space by a coordinate system (a gp_Ax3 object),
0023 //! the origin of which is the center of the hyperboloid.
0024 //!
0025 //! **One-sheet parametrization:**
0026 //! @code
0027 //!   P(u,v) = O + R1*cosh(v)*cos(u)*XDir + R1*cosh(v)*sin(u)*YDir + R2*sinh(v)*ZDir
0028 //! @endcode
0029 //! Implicit equation in local coordinates:
0030 //! @code
0031 //!   X^2/R1^2 + Y^2/R1^2 - Z^2/R2^2 = 1
0032 //! @endcode
0033 //!
0034 //! **Two-sheet parametrization** (covers one sheet only):
0035 //! @code
0036 //!   P(u,v) = O + R2*sinh(v)*cos(u)*XDir + R2*sinh(v)*sin(u)*YDir + R1*cosh(v)*ZDir
0037 //! @endcode
0038 //! Implicit equation in local coordinates:
0039 //! @code
0040 //!   X^2/R2^2 + Y^2/R2^2 - Z^2/R1^2 = -1
0041 //! @endcode
0042 //! The second sheet is not represented by this class.
0043 //!
0044 //! The parametric range is:
0045 //! - [0, 2*Pi] for u (periodic, closed), and
0046 //! - (-inf, +inf) for v (not periodic, not closed).
0047 class GeomEval_HyperboloidSurface : public Geom_ElementarySurface
0048 {
0049 public:
0050   //! Sheet mode selector.
0051   enum class SheetMode
0052   {
0053     OneSheet, //!< hyperboloid of one sheet
0054     TwoSheets //!< hyperboloid of two sheets (one sheet only)
0055   };
0056 
0057   //! Creates a hyperboloid surface with the given local coordinate system,
0058   //! semi-axis radii, and sheet mode.
0059   //! @param[in] thePosition local coordinate system
0060   //! @param[in] theR1 first semi-axis radius (must be > 0)
0061   //! @param[in] theR2 second semi-axis radius (must be > 0)
0062   //! @param[in] theMode one-sheet or two-sheet mode
0063   //! @throw Standard_ConstructionError if theR1 <= 0 or theR2 <= 0
0064   Standard_EXPORT GeomEval_HyperboloidSurface(const gp_Ax3& thePosition,
0065                                               double        theR1,
0066                                               double        theR2,
0067                                               SheetMode     theMode = SheetMode::OneSheet);
0068 
0069   //! Returns the first semi-axis radius.
0070   Standard_EXPORT double R1() const;
0071 
0072   //! Returns the second semi-axis radius.
0073   Standard_EXPORT double R2() const;
0074 
0075   //! Returns the sheet mode.
0076   Standard_EXPORT SheetMode Mode() const;
0077 
0078   //! Assigns the value theR1 to the first semi-axis radius.
0079   //! @param[in] theR1 the new first semi-axis radius (must be > 0)
0080   //! @throw Standard_ConstructionError if theR1 <= 0
0081   Standard_EXPORT void SetR1(double theR1);
0082 
0083   //! Assigns the value theR2 to the second semi-axis radius.
0084   //! @param[in] theR2 the new second semi-axis radius (must be > 0)
0085   //! @throw Standard_ConstructionError if theR2 <= 0
0086   Standard_EXPORT void SetR2(double theR2);
0087 
0088   //! Sets the sheet mode.
0089   //! @param[in] theMode one-sheet or two-sheet mode
0090   Standard_EXPORT void SetMode(SheetMode theMode);
0091 
0092   //! Reversal is not supported for this eval surface.
0093   //! @throw Standard_NotImplemented
0094   Standard_EXPORT void UReverse() final;
0095 
0096   //! Reversal is not supported for this eval surface.
0097   //! @throw Standard_NotImplemented
0098   Standard_EXPORT void VReverse() final;
0099 
0100   //! Reversal is not supported for this eval surface.
0101   //! @throw Standard_NotImplemented
0102   Standard_EXPORT double UReversedParameter(const double U) const final;
0103 
0104   //! Reversal is not supported for this eval surface.
0105   //! @throw Standard_NotImplemented
0106   Standard_EXPORT double VReversedParameter(const double V) const final;
0107 
0108   //! Returns the parametric bounds U1, U2, V1 and V2 of this hyperboloid.
0109   //! @param[out] U1 lower U bound (0)
0110   //! @param[out] U2 upper U bound (2*Pi)
0111   //! @param[out] V1 lower V bound (-Precision::Infinite())
0112   //! @param[out] V2 upper V bound (Precision::Infinite())
0113   Standard_EXPORT void Bounds(double& U1, double& U2, double& V1, double& V2) const final;
0114 
0115   //! Returns True. The hyperboloid is closed in U (period 2*Pi).
0116   Standard_EXPORT bool IsUClosed() const final;
0117 
0118   //! Returns False.
0119   Standard_EXPORT bool IsVClosed() const final;
0120 
0121   //! Returns True. The hyperboloid is periodic in U (period 2*Pi).
0122   Standard_EXPORT bool IsUPeriodic() const final;
0123 
0124   //! Returns False.
0125   Standard_EXPORT bool IsVPeriodic() const final;
0126 
0127   //! Computes the U isoparametric curve.
0128   //! For a hyperboloid, no standard Geom_Curve representation is available.
0129   //! @throw Standard_NotImplemented
0130   Standard_EXPORT occ::handle<Geom_Curve> UIso(const double U) const final;
0131 
0132   //! Computes the V isoparametric curve.
0133   //! For a hyperboloid, no standard Geom_Curve representation is available.
0134   //! @throw Standard_NotImplemented
0135   Standard_EXPORT occ::handle<Geom_Curve> VIso(const double V) const final;
0136 
0137   //! Computes the point P(U, V) on the surface.
0138   Standard_EXPORT gp_Pnt EvalD0(const double U, const double V) const final;
0139 
0140   //! Computes the point and the first partial derivatives at (U, V).
0141   Standard_EXPORT Geom_Surface::ResD1 EvalD1(const double U, const double V) const final;
0142 
0143   //! Computes the point and partial derivatives up to 2nd order at (U, V).
0144   Standard_EXPORT Geom_Surface::ResD2 EvalD2(const double U, const double V) const final;
0145 
0146   //! Computes the point and partial derivatives up to 3rd order at (U, V).
0147   Standard_EXPORT Geom_Surface::ResD3 EvalD3(const double U, const double V) const final;
0148 
0149   //! Computes the derivative of order Nu in the direction u
0150   //! and Nv in the direction v.
0151   //! @param[in] U the u parameter
0152   //! @param[in] V the v parameter
0153   //! @param[in] Nu derivative order in u (must be >= 0)
0154   //! @param[in] Nv derivative order in v (must be >= 0)
0155   //! @return the derivative vector
0156   //! @throw Geom_UndefinedDerivative if Nu + Nv < 1 or Nu < 0 or Nv < 0
0157   Standard_EXPORT gp_Vec EvalDN(const double U,
0158                                 const double V,
0159                                 const int    Nu,
0160                                 const int    Nv) const final;
0161 
0162   //! Transformation is not supported for this eval geometry.
0163   //! @throw Standard_NotImplemented
0164   Standard_EXPORT void Transform(const gp_Trsf& T) final;
0165 
0166   //! Creates a new object which is a copy of this hyperboloid.
0167   Standard_EXPORT occ::handle<Geom_Geometry> Copy() const final;
0168 
0169   //! Dumps the content of me into the stream.
0170   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const final;
0171 
0172   //! Returns the coefficients of the implicit equation of the
0173   //! quadric in the absolute Cartesian coordinate system:
0174   //! @code
0175   //!   A1*X^2 + A2*Y^2 + A3*Z^2 + 2*(B1*X*Y + B2*X*Z + B3*Y*Z) +
0176   //!   2*(C1*X + C2*Y + C3*Z) + D = 0
0177   //! @endcode
0178   //! For one-sheet (local): X^2/R1^2 + Y^2/R1^2 - Z^2/R2^2 - 1 = 0.
0179   //! For two-sheet (local): X^2/R2^2 + Y^2/R2^2 - Z^2/R1^2 + 1 = 0.
0180   Standard_EXPORT void Coefficients(double& A1,
0181                                     double& A2,
0182                                     double& A3,
0183                                     double& B1,
0184                                     double& B2,
0185                                     double& B3,
0186                                     double& C1,
0187                                     double& C2,
0188                                     double& C3,
0189                                     double& D) const;
0190 
0191   DEFINE_STANDARD_RTTIEXT(GeomEval_HyperboloidSurface, Geom_ElementarySurface)
0192 
0193 private:
0194   double    myR1;
0195   double    myR2;
0196   SheetMode myMode;
0197 };
0198 
0199 #endif // _GeomEval_HyperboloidSurface_HeaderFile