Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:18:57

0001 // Created on: 1991-12-02
0002 // Created by: Laurent PAINNOT
0003 // Copyright (c) 1991-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 _AppDef_TheFunction_HeaderFile
0018 #define _AppDef_TheFunction_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <AppDef_MultiLine.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_Real.hxx>
0027 #include <AppDef_TheLeastSquares.hxx>
0028 #include <NCollection_Array1.hxx>
0029 #include <NCollection_HArray1.hxx>
0030 #include <AppParCurves_ConstraintCouple.hxx>
0031 #include <math_MultipleVarFunctionWithGradient.hxx>
0032 #include <AppParCurves_Constraint.hxx>
0033 class AppDef_MultiLine;
0034 class AppDef_MyLineTool;
0035 class AppDef_TheLeastSquares;
0036 class AppDef_TheResol;
0037 class AppParCurves_MultiCurve;
0038 
0039 class AppDef_TheFunction : public math_MultipleVarFunctionWithGradient
0040 {
0041 public:
0042   DEFINE_STANDARD_ALLOC
0043 
0044   //! initializes the fields of the function. The approximating
0045   //! curve has the desired degree Deg.
0046   Standard_EXPORT AppDef_TheFunction(
0047     const AppDef_MultiLine&                                                SSP,
0048     const int                                                              FirstPoint,
0049     const int                                                              LastPoint,
0050     const occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>>& TheConstraints,
0051     const math_Vector&                                                     Parameters,
0052     const int                                                              Deg);
0053 
0054   //! returns the number of variables of the function. It
0055   //! corresponds to the number of MultiPoints.
0056   Standard_EXPORT int NbVariables() const override;
0057 
0058   //! this method computes the new approximation of the
0059   //! MultiLine
0060   //! SSP and calculates F = sum (||Pui - Bi*Pi||2) for each
0061   //! point of the MultiLine.
0062   Standard_EXPORT bool Value(const math_Vector& X, double& F) override;
0063 
0064   //! returns the gradient G of the sum above for the
0065   //! parameters Xi.
0066   Standard_EXPORT bool Gradient(const math_Vector& X, math_Vector& G) override;
0067 
0068   //! returns the value F=sum(||Pui - Bi*Pi||)2.
0069   //! returns the value G = grad(F) for the parameters Xi.
0070   Standard_EXPORT bool Values(const math_Vector& X, double& F, math_Vector& G) override;
0071 
0072   //! returns the new parameters of the MultiLine.
0073   Standard_EXPORT const math_Vector& NewParameters() const;
0074 
0075   //! returns the MultiCurve approximating the set after
0076   //! computing the value F or Grad(F).
0077   Standard_EXPORT const AppParCurves_MultiCurve& CurveValue();
0078 
0079   //! returns the distance between the MultiPoint of range
0080   //! IPoint and the curve CurveIndex.
0081   Standard_EXPORT double Error(const int IPoint, const int CurveIndex) const;
0082 
0083   //! returns the maximum distance between the points
0084   //! and the MultiCurve.
0085   Standard_EXPORT double MaxError3d() const;
0086 
0087   //! returns the maximum distance between the points
0088   //! and the MultiCurve.
0089   Standard_EXPORT double MaxError2d() const;
0090 
0091   Standard_EXPORT AppParCurves_Constraint FirstConstraint(
0092     const occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>>& TheConstraints,
0093     const int                                                              FirstPoint) const;
0094 
0095   Standard_EXPORT AppParCurves_Constraint LastConstraint(
0096     const occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>>& TheConstraints,
0097     const int                                                              LastPoint) const;
0098 
0099 protected:
0100   //! this method is used each time Value or Gradient is
0101   //! needed.
0102   Standard_EXPORT void Perform(const math_Vector& X);
0103 
0104 private:
0105   bool                                                            Done;
0106   AppDef_MultiLine                                                MyMultiLine;
0107   AppParCurves_MultiCurve                                         MyMultiCurve;
0108   int                                                             Degre;
0109   math_Vector                                                     myParameters;
0110   double                                                          FVal;
0111   math_Vector                                                     ValGrad_F;
0112   math_Matrix                                                     MyF;
0113   math_Matrix                                                     PTLX;
0114   math_Matrix                                                     PTLY;
0115   math_Matrix                                                     PTLZ;
0116   math_Matrix                                                     A;
0117   math_Matrix                                                     DA;
0118   AppDef_TheLeastSquares                                          MyLeastSquare;
0119   bool                                                            Contraintes;
0120   int                                                             NbP;
0121   int                                                             NbCu;
0122   int                                                             Adeb;
0123   int                                                             Afin;
0124   occ::handle<NCollection_HArray1<int>>                           tabdim;
0125   double                                                          ERR3d;
0126   double                                                          ERR2d;
0127   int                                                             FirstP;
0128   int                                                             LastP;
0129   occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>> myConstraints;
0130 };
0131 
0132 #endif // _AppDef_TheFunction_HeaderFile