1 // Created on: 1991-12-02
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute_HeaderFile
18 #define _AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <AppDef_MultiLine.hxx>
26 #include <AppParCurves_MultiBSpCurve.hxx>
27 #include <Standard_Integer.hxx>
28 #include <math_Vector.hxx>
29 #include <Standard_Real.hxx>
30 #include <math_Matrix.hxx>
31 #include <AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute.hxx>
32 #include <TColStd_HArray1OfInteger.hxx>
33 #include <AppParCurves_HArray1OfConstraintCouple.hxx>
34 #include <math_MultipleVarFunctionWithGradient.hxx>
35 #include <TColStd_Array1OfReal.hxx>
36 #include <TColStd_Array1OfInteger.hxx>
37 #include <math_IntegerVector.hxx>
38 #include <AppParCurves_Constraint.hxx>
39 class AppDef_MultiLine;
40 class AppDef_MyLineTool;
41 class AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute;
42 class AppParCurves_MultiBSpCurve;
47 class AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute : public math_MultipleVarFunctionWithGradient
54 //! initializes the fields of the function. The approximating
55 //! curve has <NbPol> control points.
56 Standard_EXPORT AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute(const AppDef_MultiLine& SSP, const Standard_Integer FirstPoint, const Standard_Integer LastPoint, const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const math_Vector& Parameters, const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults, const Standard_Integer NbPol);
58 //! returns the number of variables of the function. It
59 //! corresponds to the number of MultiPoints.
60 Standard_EXPORT Standard_Integer NbVariables() const;
62 //! this method computes the new approximation of the
64 //! SSP and calculates F = sum (||Pui - Bi*Pi||2) for each
65 //! point of the MultiLine.
66 Standard_EXPORT Standard_Boolean Value (const math_Vector& X, Standard_Real& F);
68 //! returns the gradient G of the sum above for the
70 Standard_EXPORT Standard_Boolean Gradient (const math_Vector& X, math_Vector& G);
72 //! returns the value F=sum(||Pui - Bi*Pi||)2.
73 //! returns the value G = grad(F) for the parameters Xi.
74 Standard_EXPORT Standard_Boolean Values (const math_Vector& X, Standard_Real& F, math_Vector& G);
76 //! returns the new parameters of the MultiLine.
77 Standard_EXPORT const math_Vector& NewParameters() const;
79 //! returns the MultiBSpCurve approximating the set after
80 //! computing the value F or Grad(F).
81 Standard_EXPORT AppParCurves_MultiBSpCurve CurveValue();
83 //! returns the distance between the MultiPoint of range
84 //! IPoint and the curve CurveIndex.
85 Standard_EXPORT Standard_Real Error (const Standard_Integer IPoint, const Standard_Integer CurveIndex);
87 //! returns the maximum distance between the points
88 //! and the MultiBSpCurve.
89 Standard_EXPORT Standard_Real MaxError3d() const;
91 //! returns the maximum distance between the points
92 //! and the MultiBSpCurve.
93 Standard_EXPORT Standard_Real MaxError2d() const;
95 //! returns the function matrix used to approximate the
97 Standard_EXPORT const math_Matrix& FunctionMatrix() const;
99 //! returns the derivative function matrix used to approximate the
101 Standard_EXPORT const math_Matrix& DerivativeFunctionMatrix() const;
103 //! Returns the indexes of the first non null values of
105 //! The values are non null from Index(ieme point) +1
106 //! to Index(ieme point) + degree +1.
107 Standard_EXPORT const math_IntegerVector& Index() const;
109 Standard_EXPORT AppParCurves_Constraint FirstConstraint (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer FirstPoint) const;
111 Standard_EXPORT AppParCurves_Constraint LastConstraint (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer LastPoint) const;
113 Standard_EXPORT void SetFirstLambda (const Standard_Real l1);
115 Standard_EXPORT void SetLastLambda (const Standard_Real l2);
123 //! this method is used each time Value or Gradient is
125 Standard_EXPORT void Perform (const math_Vector& X);
134 Standard_Boolean Done;
135 AppDef_MultiLine MyMultiLine;
136 AppParCurves_MultiBSpCurve MyMultiBSpCurve;
137 Standard_Integer nbpoles;
138 math_Vector myParameters;
140 math_Vector ValGrad_F;
147 AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute MyLeastSquare;
148 Standard_Boolean Contraintes;
149 Standard_Integer NbP;
150 Standard_Integer NbCu;
151 Standard_Integer Adeb;
152 Standard_Integer Afin;
153 Handle(TColStd_HArray1OfInteger) tabdim;
156 Standard_Integer FirstP;
157 Standard_Integer LastP;
158 Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints;
159 Standard_Real mylambda1;
160 Standard_Real mylambda2;
171 #endif // _AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute_HeaderFile