1 // Created on: 1995-01-27 2 // Created by: Jacques GOUSSARD 3 // Copyright (c) 1995-1999 Matra Datavision 4 // Copyright (c) 1999-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 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. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 #ifndef _GeomInt_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfWLApprox_HeaderFile 18 #define _GeomInt_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfWLApprox_HeaderFile 19 20 #include <Standard.hxx> 21 #include <Standard_DefineAlloc.hxx> 22 #include <Standard_Handle.hxx> 23 24 #include <Standard_Boolean.hxx> 25 #include <GeomInt_TheMultiLineOfWLApprox.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 <GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox.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 GeomInt_TheMultiLineOfWLApprox; 40 class GeomInt_TheMultiLineToolOfWLApprox; 41 class GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox; 42 class AppParCurves_MultiBSpCurve; 43 class math_Matrix; 44 45 46 47 class GeomInt_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfWLApprox : public math_MultipleVarFunctionWithGradient 48 { 49 public: 50 51 DEFINE_STANDARD_ALLOC 52 53 54 //! initializes the fields of the function. The approximating 55 //! curve has <NbPol> control points. 56 Standard_EXPORT GeomInt_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& 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); 57 58 //! returns the number of variables of the function. It 59 //! corresponds to the number of MultiPoints. 60 Standard_EXPORT Standard_Integer NbVariables() const; 61 62 //! this method computes the new approximation of the 63 //! MultiLine 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); 67 68 //! returns the gradient G of the sum above for the 69 //! parameters Xi. 70 Standard_EXPORT Standard_Boolean Gradient (const math_Vector& X, math_Vector& G); 71 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); 75 76 //! returns the new parameters of the MultiLine. 77 Standard_EXPORT const math_Vector& NewParameters() const; 78 79 //! returns the MultiBSpCurve approximating the set after 80 //! computing the value F or Grad(F). 81 Standard_EXPORT AppParCurves_MultiBSpCurve CurveValue(); 82 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); 86 87 //! returns the maximum distance between the points 88 //! and the MultiBSpCurve. 89 Standard_EXPORT Standard_Real MaxError3d() const; 90 91 //! returns the maximum distance between the points 92 //! and the MultiBSpCurve. 93 Standard_EXPORT Standard_Real MaxError2d() const; 94 95 //! returns the function matrix used to approximate the 96 //! multiline. 97 Standard_EXPORT const math_Matrix& FunctionMatrix() const; 98 99 //! returns the derivative function matrix used to approximate the 100 //! multiline. 101 Standard_EXPORT const math_Matrix& DerivativeFunctionMatrix() const; 102 103 //! Returns the indexes of the first non null values of 104 //! A and DA. 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; 108 109 Standard_EXPORT AppParCurves_Constraint FirstConstraint (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer FirstPoint) const; 110 111 Standard_EXPORT AppParCurves_Constraint LastConstraint (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer LastPoint) const; 112 113 Standard_EXPORT void SetFirstLambda (const Standard_Real l1); 114 115 Standard_EXPORT void SetLastLambda (const Standard_Real l2); 116 117 118 119 120 protected: 121 122 123 //! this method is used each time Value or Gradient is 124 //! needed. 125 Standard_EXPORT void Perform (const math_Vector& X); 126 127 128 129 130 private: 131 132 133 134 Standard_Boolean Done; 135 GeomInt_TheMultiLineOfWLApprox MyMultiLine; 136 AppParCurves_MultiBSpCurve MyMultiBSpCurve; 137 Standard_Integer nbpoles; 138 math_Vector myParameters; 139 Standard_Real FVal; 140 math_Vector ValGrad_F; 141 math_Matrix MyF; 142 math_Matrix PTLX; 143 math_Matrix PTLY; 144 math_Matrix PTLZ; 145 math_Matrix A; 146 math_Matrix DA; 147 GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox 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; 154 Standard_Real ERR3d; 155 Standard_Real ERR2d; 156 Standard_Integer FirstP; 157 Standard_Integer LastP; 158 Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints; 159 Standard_Real mylambda1; 160 Standard_Real mylambda2; 161 162 163 }; 164 165 166 167 168 169 170 171 #endif // _GeomInt_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfWLApprox_HeaderFile 172