0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / BRepApprox / BRepApprox_ParFunctionOfMyGradientbisOfTheComputeLineOfApprox.hxx
1 // Created on: 1995-06-06
2 // Created by: Jean Yves LEBEY
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 _BRepApprox_ParFunctionOfMyGradientbisOfTheComputeLineOfApprox_HeaderFile
18 #define _BRepApprox_ParFunctionOfMyGradientbisOfTheComputeLineOfApprox_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Boolean.hxx>
25 #include <BRepApprox_TheMultiLineOfApprox.hxx>
26 #include <AppParCurves_MultiCurve.hxx>
27 #include <Standard_Integer.hxx>
28 #include <math_Vector.hxx>
29 #include <Standard_Real.hxx>
30 #include <math_Matrix.hxx>
31 #include <BRepApprox_ParLeastSquareOfMyGradientbisOfTheComputeLineOfApprox.hxx>
32 #include <TColStd_HArray1OfInteger.hxx>
33 #include <AppParCurves_HArray1OfConstraintCouple.hxx>
34 #include <math_MultipleVarFunctionWithGradient.hxx>
35 #include <AppParCurves_Constraint.hxx>
36 class BRepApprox_TheMultiLineOfApprox;
37 class BRepApprox_TheMultiLineToolOfApprox;
38 class BRepApprox_ParLeastSquareOfMyGradientbisOfTheComputeLineOfApprox;
39 class BRepApprox_ResConstraintOfMyGradientbisOfTheComputeLineOfApprox;
40 class AppParCurves_MultiCurve;
41
42
43
44 class BRepApprox_ParFunctionOfMyGradientbisOfTheComputeLineOfApprox  : public math_MultipleVarFunctionWithGradient
45 {
46 public:
47
48   DEFINE_STANDARD_ALLOC
49
50   
51   //! initializes the fields of the function. The approximating
52   //! curve has the desired degree Deg.
53   Standard_EXPORT BRepApprox_ParFunctionOfMyGradientbisOfTheComputeLineOfApprox(const BRepApprox_TheMultiLineOfApprox& SSP, const Standard_Integer FirstPoint, const Standard_Integer LastPoint, const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const math_Vector& Parameters, const Standard_Integer Deg);
54   
55   //! returns the number of variables of the function. It
56   //! corresponds to the number of MultiPoints.
57   Standard_EXPORT Standard_Integer NbVariables() const;
58   
59   //! this method computes the new approximation of the
60   //! MultiLine
61   //! SSP and calculates F = sum (||Pui - Bi*Pi||2) for each
62   //! point of the MultiLine.
63   Standard_EXPORT Standard_Boolean Value (const math_Vector& X, Standard_Real& F);
64   
65   //! returns the gradient G of the sum above for the
66   //! parameters Xi.
67   Standard_EXPORT Standard_Boolean Gradient (const math_Vector& X, math_Vector& G);
68   
69   //! returns the value F=sum(||Pui - Bi*Pi||)2.
70   //! returns the value G = grad(F) for the parameters Xi.
71   Standard_EXPORT Standard_Boolean Values (const math_Vector& X, Standard_Real& F, math_Vector& G);
72   
73   //! returns the new parameters of the MultiLine.
74   Standard_EXPORT const math_Vector& NewParameters() const;
75   
76   //! returns the MultiCurve approximating the set after
77   //! computing the value F or Grad(F).
78   Standard_EXPORT const AppParCurves_MultiCurve& CurveValue();
79   
80   //! returns the distance between the MultiPoint of range
81   //! IPoint and the curve CurveIndex.
82   Standard_EXPORT Standard_Real Error (const Standard_Integer IPoint, const Standard_Integer CurveIndex) const;
83   
84   //! returns the maximum distance between the points
85   //! and the MultiCurve.
86   Standard_EXPORT Standard_Real MaxError3d() const;
87   
88   //! returns the maximum distance between the points
89   //! and the MultiCurve.
90   Standard_EXPORT Standard_Real MaxError2d() const;
91   
92   Standard_EXPORT AppParCurves_Constraint FirstConstraint (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer FirstPoint) const;
93   
94   Standard_EXPORT AppParCurves_Constraint LastConstraint (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer LastPoint) const;
95
96
97
98
99 protected:
100
101   
102   //! this method is used each time Value or Gradient is
103   //! needed.
104   Standard_EXPORT void Perform (const math_Vector& X);
105
106
107
108
109 private:
110
111
112
113   Standard_Boolean Done;
114   BRepApprox_TheMultiLineOfApprox MyMultiLine;
115   AppParCurves_MultiCurve MyMultiCurve;
116   Standard_Integer Degre;
117   math_Vector myParameters;
118   Standard_Real FVal;
119   math_Vector ValGrad_F;
120   math_Matrix MyF;
121   math_Matrix PTLX;
122   math_Matrix PTLY;
123   math_Matrix PTLZ;
124   math_Matrix A;
125   math_Matrix DA;
126   BRepApprox_ParLeastSquareOfMyGradientbisOfTheComputeLineOfApprox MyLeastSquare;
127   Standard_Boolean Contraintes;
128   Standard_Integer NbP;
129   Standard_Integer NbCu;
130   Standard_Integer Adeb;
131   Standard_Integer Afin;
132   Handle(TColStd_HArray1OfInteger) tabdim;
133   Standard_Real ERR3d;
134   Standard_Real ERR2d;
135   Standard_Integer FirstP;
136   Standard_Integer LastP;
137   Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints;
138
139
140 };
141
142
143
144
145
146
147
148 #endif // _BRepApprox_ParFunctionOfMyGradientbisOfTheComputeLineOfApprox_HeaderFile