Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:15:45

0001 // Created on: 1995-06-06
0002 // Created by: Jean Yves LEBEY
0003 // Copyright (c) 1995-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 _BRepApprox_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfApprox_HeaderFile
0018 #define _BRepApprox_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfApprox_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <BRepApprox_TheMultiLineOfApprox.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_Real.hxx>
0027 #include <BRepApprox_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfApprox.hxx>
0028 #include <NCollection_Array1.hxx>
0029 #include <NCollection_HArray1.hxx>
0030 #include <AppParCurves_ConstraintCouple.hxx>
0031 #include <math_MultipleVarFunctionWithGradient.hxx>
0032 #include <math_IntegerVector.hxx>
0033 #include <AppParCurves_Constraint.hxx>
0034 class BRepApprox_TheMultiLineOfApprox;
0035 class BRepApprox_TheMultiLineToolOfApprox;
0036 class BRepApprox_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfApprox;
0037 class AppParCurves_MultiBSpCurve;
0038 class math_Matrix;
0039 
0040 class BRepApprox_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfApprox
0041     : public math_MultipleVarFunctionWithGradient
0042 {
0043 public:
0044   DEFINE_STANDARD_ALLOC
0045 
0046   //! initializes the fields of the function. The approximating
0047   //! curve has <NbPol> control points.
0048   Standard_EXPORT BRepApprox_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfApprox(
0049     const BRepApprox_TheMultiLineOfApprox&                                 SSP,
0050     const int                                                              FirstPoint,
0051     const int                                                              LastPoint,
0052     const occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>>& TheConstraints,
0053     const math_Vector&                                                     Parameters,
0054     const NCollection_Array1<double>&                                      Knots,
0055     const NCollection_Array1<int>&                                         Mults,
0056     const int                                                              NbPol);
0057 
0058   //! returns the number of variables of the function. It
0059   //! corresponds to the number of MultiPoints.
0060   Standard_EXPORT int NbVariables() const override;
0061 
0062   //! this method computes the new approximation of the
0063   //! MultiLine
0064   //! SSP and calculates F = sum (||Pui - Bi*Pi||2) for each
0065   //! point of the MultiLine.
0066   Standard_EXPORT bool Value(const math_Vector& X, double& F) override;
0067 
0068   //! returns the gradient G of the sum above for the
0069   //! parameters Xi.
0070   Standard_EXPORT bool Gradient(const math_Vector& X, math_Vector& G) override;
0071 
0072   //! returns the value F=sum(||Pui - Bi*Pi||)2.
0073   //! returns the value G = grad(F) for the parameters Xi.
0074   Standard_EXPORT bool Values(const math_Vector& X, double& F, math_Vector& G) override;
0075 
0076   //! returns the new parameters of the MultiLine.
0077   Standard_EXPORT const math_Vector& NewParameters() const;
0078 
0079   //! returns the MultiBSpCurve approximating the set after
0080   //! computing the value F or Grad(F).
0081   Standard_EXPORT AppParCurves_MultiBSpCurve CurveValue();
0082 
0083   //! returns the distance between the MultiPoint of range
0084   //! IPoint and the curve CurveIndex.
0085   Standard_EXPORT double Error(const int IPoint, const int CurveIndex);
0086 
0087   //! returns the maximum distance between the points
0088   //! and the MultiBSpCurve.
0089   Standard_EXPORT double MaxError3d() const;
0090 
0091   //! returns the maximum distance between the points
0092   //! and the MultiBSpCurve.
0093   Standard_EXPORT double MaxError2d() const;
0094 
0095   //! returns the function matrix used to approximate the
0096   //! multiline.
0097   Standard_EXPORT const math_Matrix& FunctionMatrix() const;
0098 
0099   //! returns the derivative function matrix used to approximate the
0100   //! multiline.
0101   Standard_EXPORT const math_Matrix& DerivativeFunctionMatrix() const;
0102 
0103   //! Returns the indexes of the first non null values of
0104   //! A and DA.
0105   //! The values are non null from Index(ieme point) +1
0106   //! to Index(ieme point) + degree +1.
0107   Standard_EXPORT const math_IntegerVector& Index() const;
0108 
0109   Standard_EXPORT AppParCurves_Constraint FirstConstraint(
0110     const occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>>& TheConstraints,
0111     const int                                                              FirstPoint) const;
0112 
0113   Standard_EXPORT AppParCurves_Constraint LastConstraint(
0114     const occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>>& TheConstraints,
0115     const int                                                              LastPoint) const;
0116 
0117   Standard_EXPORT void SetFirstLambda(const double l1);
0118 
0119   Standard_EXPORT void SetLastLambda(const double l2);
0120 
0121 protected:
0122   //! this method is used each time Value or Gradient is
0123   //! needed.
0124   Standard_EXPORT void Perform(const math_Vector& X);
0125 
0126 private:
0127   bool                                                                 Done;
0128   BRepApprox_TheMultiLineOfApprox                                      MyMultiLine;
0129   AppParCurves_MultiBSpCurve                                           MyMultiBSpCurve;
0130   int                                                                  nbpoles;
0131   math_Vector                                                          myParameters;
0132   double                                                               FVal;
0133   math_Vector                                                          ValGrad_F;
0134   math_Matrix                                                          MyF;
0135   math_Matrix                                                          PTLX;
0136   math_Matrix                                                          PTLY;
0137   math_Matrix                                                          PTLZ;
0138   math_Matrix                                                          A;
0139   math_Matrix                                                          DA;
0140   BRepApprox_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfApprox MyLeastSquare;
0141   bool                                                                 Contraintes;
0142   int                                                                  NbP;
0143   int                                                                  NbCu;
0144   int                                                                  Adeb;
0145   int                                                                  Afin;
0146   occ::handle<NCollection_HArray1<int>>                                tabdim;
0147   double                                                               ERR3d;
0148   double                                                               ERR2d;
0149   int                                                                  FirstP;
0150   int                                                                  LastP;
0151   occ::handle<NCollection_HArray1<AppParCurves_ConstraintCouple>>      myConstraints;
0152   double                                                               mylambda1;
0153   double                                                               mylambda2;
0154 };
0155 
0156 #endif // _BRepApprox_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfApprox_HeaderFile