Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-22 10:19:32

0001 // Created on: 1996-08-23
0002 // Created by: Benoit TANNIOU
0003 // Copyright (c) 1996-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 _CSLib_NormalPolyDef_HeaderFile
0018 #define _CSLib_NormalPolyDef_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <NCollection_Array1.hxx>
0024 #include <math_FunctionWithDerivative.hxx>
0025 
0026 //! Polynomial definition for surface normal computation at singular points.
0027 //!
0028 //! This class defines a polynomial function F(X) and its derivative for use
0029 //! with numerical root-finding algorithms. The function represents a trigonometric
0030 //! polynomial in terms of cos(X) and sin(X) with binomial coefficients.
0031 //!
0032 //! The polynomial has the form:
0033 //!   F(X) = Sum_{i=0}^{k0} C(k0,i) * cos^i(X) * sin^(k0-i)(X) * li(i)
0034 //!
0035 //! where C(k0,i) is the binomial coefficient and li(i) are user-provided coefficients.
0036 //!
0037 //! This is used internally by CSLib::Normal() to find the normal direction
0038 //! at singular surface points by solving for zeros of this polynomial.
0039 class CSLib_NormalPolyDef : public math_FunctionWithDerivative
0040 {
0041 public:
0042   DEFINE_STANDARD_ALLOC
0043 
0044   //! Constructs a polynomial definition for normal computation.
0045   //!
0046   //! @param[in] theK0 Polynomial degree (must be >= 0)
0047   //! @param[in] theLi Array of coefficients with indices 0 to theK0
0048   Standard_EXPORT CSLib_NormalPolyDef(int theK0, const NCollection_Array1<double>& theLi);
0049 
0050   //! Computes the value of the function for the given variable.
0051   //!
0052   //! Evaluates F(X) = Sum_{i=0}^{k0} C(k0,i) * cos^i(X) * sin^(k0-i)(X) * li(i)
0053   //!
0054   //! @param[in]  theX Input variable (angle in radians)
0055   //! @param[out] theF Computed function value
0056   //! @return true if calculation was successful, false otherwise
0057   Standard_EXPORT bool Value(const double theX, double& theF) override;
0058 
0059   //! Computes the derivative of the function for the given variable.
0060   //!
0061   //! Evaluates dF/dX using the chain rule on the trigonometric polynomial.
0062   //!
0063   //! @param[in]  theX Input variable (angle in radians)
0064   //! @param[out] theD Computed derivative value
0065   //! @return true if calculation was successful, false otherwise
0066   Standard_EXPORT bool Derivative(const double theX, double& theD) override;
0067 
0068   //! Computes both the value and derivative of the function.
0069   //!
0070   //! More efficient than calling Value() and Derivative() separately
0071   //! as common subexpressions are computed only once.
0072   //!
0073   //! @param[in]  theX Input variable (angle in radians)
0074   //! @param[out] theF Computed function value
0075   //! @param[out] theD Computed derivative value
0076   //! @return true if calculation was successful, false otherwise
0077   Standard_EXPORT bool Values(const double theX, double& theF, double& theD) override;
0078 
0079 private:
0080   int                        myK0;    //!< Polynomial degree
0081   NCollection_Array1<double> myTABli; //!< Array of coefficients li(i) for i = 0..myK0
0082 };
0083 
0084 #endif // _CSLib_NormalPolyDef_HeaderFile