Back to home page

EIC code displayed by LXR

 
 

    


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

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 _Geom2dEval_AHTBezierCurve_HeaderFile
0015 #define _Geom2dEval_AHTBezierCurve_HeaderFile
0016 
0017 #include <Geom2d_BoundedCurve.hxx>
0018 #include <NCollection_Array1.hxx>
0019 #include <gp_Pnt2d.hxx>
0020 
0021 class gp_Trsf2d;
0022 class Geom2d_Geometry;
0023 
0024 //! 2D Algebraic-Hyperbolic-Trigonometric Bezier curve.
0025 //! Uses a mixed basis: {1, t, ..., t^k, sinh(alpha*t), cosh(alpha*t), sin(beta*t), cos(beta*t)}.
0026 //! The number of basis functions = algDegree + 1 + 2*(alpha>0) + 2*(beta>0) must equal NbPoles.
0027 //! Parameter range: [0, 1].
0028 class Geom2dEval_AHTBezierCurve : public Geom2d_BoundedCurve
0029 {
0030 public:
0031   //! Non-rational constructor.
0032   //! @param[in] thePoles control points
0033   //! @param[in] theAlgDegree algebraic polynomial degree (>= 0)
0034   //! @param[in] theAlpha hyperbolic frequency (>= 0, 0 = no hyperbolic terms)
0035   //! @param[in] theBeta trigonometric frequency (>= 0, 0 = no trig terms)
0036   Standard_EXPORT Geom2dEval_AHTBezierCurve(const NCollection_Array1<gp_Pnt2d>& thePoles,
0037                                             int                                 theAlgDegree,
0038                                             double                              theAlpha,
0039                                             double                              theBeta);
0040 
0041   //! Rational constructor.
0042   //! @param[in] thePoles control points
0043   //! @param[in] theWeights weights for each pole (must be > 0)
0044   //! @param[in] theAlgDegree algebraic polynomial degree (>= 0)
0045   //! @param[in] theAlpha hyperbolic frequency (>= 0, 0 = no hyperbolic terms)
0046   //! @param[in] theBeta trigonometric frequency (>= 0, 0 = no trig terms)
0047   Standard_EXPORT Geom2dEval_AHTBezierCurve(const NCollection_Array1<gp_Pnt2d>& thePoles,
0048                                             const NCollection_Array1<double>&   theWeights,
0049                                             int                                 theAlgDegree,
0050                                             double                              theAlpha,
0051                                             double                              theBeta);
0052 
0053   //! Returns the array of poles.
0054   Standard_EXPORT const NCollection_Array1<gp_Pnt2d>& Poles() const;
0055 
0056   //! Returns the array of weights.
0057   Standard_EXPORT const NCollection_Array1<double>& Weights() const;
0058 
0059   //! Returns the algebraic polynomial degree.
0060   Standard_EXPORT int AlgDegree() const;
0061 
0062   //! Returns the hyperbolic frequency parameter.
0063   Standard_EXPORT double Alpha() const;
0064 
0065   //! Returns the trigonometric frequency parameter.
0066   Standard_EXPORT double Beta() const;
0067 
0068   //! Returns the number of poles.
0069   Standard_EXPORT int NbPoles() const;
0070 
0071   //! Returns true if the curve is rational (has explicit weights).
0072   Standard_EXPORT bool IsRational() const;
0073 
0074   //! Returns the start point of the curve (at parameter 0).
0075   Standard_EXPORT gp_Pnt2d StartPoint() const final;
0076 
0077   //! Returns the end point of the curve (at parameter 1).
0078   Standard_EXPORT gp_Pnt2d EndPoint() const final;
0079 
0080   //! Reversal is not supported for this eval curve.
0081   //! @throw Standard_NotImplemented
0082   Standard_EXPORT void Reverse() final;
0083 
0084   //! Reversal is not supported for this eval curve.
0085   //! @throw Standard_NotImplemented
0086   Standard_EXPORT double ReversedParameter(const double U) const final;
0087 
0088   //! Returns the value of the first parameter: 0.0.
0089   Standard_EXPORT double FirstParameter() const final;
0090 
0091   //! Returns the value of the last parameter: 1.0.
0092   Standard_EXPORT double LastParameter() const final;
0093 
0094   //! Returns true if the curve is closed.
0095   Standard_EXPORT bool IsClosed() const final;
0096 
0097   //! Returns false. The AHT-Bezier curve is not periodic.
0098   Standard_EXPORT bool IsPeriodic() const final;
0099 
0100   //! Returns GeomAbs_CN.
0101   Standard_EXPORT GeomAbs_Shape Continuity() const final;
0102 
0103   //! Returns true for any N. The AHT-Bezier curve is infinitely differentiable.
0104   Standard_EXPORT bool IsCN(const int N) const final;
0105 
0106   //! Computes the point at parameter U.
0107   Standard_EXPORT gp_Pnt2d EvalD0(const double U) const final;
0108 
0109   //! Computes the point and first derivative at parameter U.
0110   Standard_EXPORT Geom2d_Curve::ResD1 EvalD1(const double U) const final;
0111 
0112   //! Computes the point and first two derivatives at parameter U.
0113   Standard_EXPORT Geom2d_Curve::ResD2 EvalD2(const double U) const final;
0114 
0115   //! Computes the point and first three derivatives at parameter U.
0116   Standard_EXPORT Geom2d_Curve::ResD3 EvalD3(const double U) const final;
0117 
0118   //! Computes the N-th derivative at parameter U.
0119   //! @param[in] U the parameter value
0120   //! @param[in] N the derivative order (must be >= 1)
0121   //! @return the N-th derivative vector
0122   Standard_EXPORT gp_Vec2d EvalDN(const double U, const int N) const final;
0123 
0124   //! Transformation is not supported for this eval geometry.
0125   //! @throw Standard_NotImplemented
0126   Standard_EXPORT void Transform(const gp_Trsf2d& T) final;
0127 
0128   //! Creates a new object which is a copy of this curve.
0129   Standard_EXPORT occ::handle<Geom2d_Geometry> Copy() const final;
0130 
0131   //! Dumps the content of me into the stream.
0132   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const final;
0133 
0134   DEFINE_STANDARD_RTTIEXT(Geom2dEval_AHTBezierCurve, Geom2d_BoundedCurve)
0135 
0136 private:
0137   //! Compute the number of basis functions for the given parameters.
0138   static int basisDimension(int theAlgDegree, double theAlpha, double theBeta);
0139 
0140   //! Evaluate basis at t: fills theBasis with values of all basis functions.
0141   void evalBasis(double theT, NCollection_Array1<double>& theBasis) const;
0142 
0143   //! Evaluate d-th derivative of basis at t.
0144   void evalBasisDeriv(double                      theT,
0145                       int                         theDerivOrder,
0146                       NCollection_Array1<double>& theBasisDeriv) const;
0147 
0148   NCollection_Array1<gp_Pnt2d> myPoles;
0149   NCollection_Array1<double>   myWeights;
0150   int                          myAlgDegree;
0151   double                       myAlpha;
0152   double                       myBeta;
0153   bool                         myRational;
0154 };
0155 
0156 #endif // _Geom2dEval_AHTBezierCurve_HeaderFile