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_Compute_HeaderFile
18 #define _AppDef_Compute_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <AppParCurves_SequenceOfMultiCurve.hxx>
25 #include <AppParCurves_MultiCurve.hxx>
26 #include <AppParCurves_MultiBSpCurve.hxx>
27 #include <Approx_ParametrizationType.hxx>
28 #include <TColStd_HArray1OfReal.hxx>
29 #include <Approx_SequenceOfHArray1OfReal.hxx>
30 #include <TColStd_SequenceOfReal.hxx>
31 #include <AppParCurves_HArray1OfConstraintCouple.hxx>
32 #include <Standard_Integer.hxx>
33 #include <AppParCurves_Constraint.hxx>
34 #include <math_Vector.hxx>
35 #include <TColStd_Array1OfReal.hxx>
36 class AppDef_MultiLine;
37 class AppDef_MyLineTool;
38 class AppDef_MyGradientOfCompute;
39 class AppDef_ParLeastSquareOfMyGradientOfCompute;
40 class AppDef_ResConstraintOfMyGradientOfCompute;
41 class AppDef_ParFunctionOfMyGradientOfCompute;
42 class AppDef_Gradient_BFGSOfMyGradientOfCompute;
43 class AppParCurves_MultiCurve;
44 class AppParCurves_MultiBSpCurve;
55 //! The MultiLine <Line> will be approximated until tolerances
57 //! The approximation will be done from degreemin to degreemax
58 //! with a cutting if the corresponding boolean is True.
59 //! If <Squares> is True, the computation will be done with
60 //! no iteration at all.
61 Standard_EXPORT AppDef_Compute(const AppDef_MultiLine& Line, const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-3, const Standard_Real Tolerance2d = 1.0e-6, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Approx_ParametrizationType parametrization = Approx_ChordLength, const Standard_Boolean Squares = Standard_False);
63 //! The MultiLine <Line> will be approximated until tolerances
65 //! The approximation will be done from degreemin to degreemax
66 //! with a cutting if the corresponding boolean is True.
67 //! If <Squares> is True, the computation will be done with
68 //! no iteration at all.
69 Standard_EXPORT AppDef_Compute(const AppDef_MultiLine& Line, const math_Vector& Parameters, const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-03, const Standard_Real Tolerance2d = 1.0e-06, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Standard_Boolean Squares = Standard_False);
71 //! Initializes the fields of the algorithm.
72 Standard_EXPORT AppDef_Compute(const math_Vector& Parameters, const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-03, const Standard_Real Tolerance2d = 1.0e-06, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Standard_Boolean Squares = Standard_False);
74 //! Initializes the fields of the algorithm.
75 Standard_EXPORT AppDef_Compute(const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-03, const Standard_Real Tolerance2d = 1.0e-06, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Approx_ParametrizationType parametrization = Approx_ChordLength, const Standard_Boolean Squares = Standard_False);
77 //! Initializes the fields of the algorithm.
78 Standard_EXPORT void Init (const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-03, const Standard_Real Tolerance2d = 1.0e-06, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Approx_ParametrizationType parametrization = Approx_ChordLength, const Standard_Boolean Squares = Standard_False);
80 //! runs the algorithm after having initialized the fields.
81 Standard_EXPORT void Perform (const AppDef_MultiLine& Line);
83 //! changes the degrees of the approximation.
84 Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax);
86 //! Changes the tolerances of the approximation.
87 Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d);
89 //! changes the first and the last constraint points.
90 Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
92 //! returns False if at a moment of the approximation,
93 //! the status NoApproximation has been sent by the user
94 //! when more points were needed.
95 Standard_EXPORT Standard_Boolean IsAllApproximated() const;
97 //! returns False if the status NoPointsAdded has been sent.
98 Standard_EXPORT Standard_Boolean IsToleranceReached() const;
100 //! returns the tolerances 2d and 3d of the <Index> MultiCurve.
101 Standard_EXPORT void Error (const Standard_Integer Index, Standard_Real& tol3d, Standard_Real& tol2d) const;
103 //! Returns the number of MultiCurve doing the approximation
104 //! of the MultiLine.
105 Standard_EXPORT Standard_Integer NbMultiCurves() const;
107 //! returns the result of the approximation.
108 Standard_EXPORT const AppParCurves_MultiCurve& Value (const Standard_Integer Index = 1) const;
110 //! returns the result of the approximation.
111 Standard_EXPORT AppParCurves_MultiCurve& ChangeValue (const Standard_Integer Index = 1);
113 //! returns the result of the approximation.
114 Standard_EXPORT const AppParCurves_MultiBSpCurve& SplineValue();
116 //! returns the type of parametrization
117 Standard_EXPORT Approx_ParametrizationType Parametrization () const;
119 //! returns the new parameters of the approximation
120 //! corresponding to the points of the multicurve <Index>.
121 Standard_EXPORT const TColStd_Array1OfReal& Parameters (const Standard_Integer Index = 1) const;
134 //! is internally used in the algorithm.
135 Standard_EXPORT Standard_Boolean Compute (const AppDef_MultiLine& Line,
136 const Standard_Integer fpt,
137 const Standard_Integer lpt,
139 Standard_Real& TheTol3d,
140 Standard_Real& TheTol2d,
141 Standard_Integer& indbad);
143 //! is internally used in the algorithm.
144 Standard_EXPORT Standard_Boolean ComputeCurve (const AppDef_MultiLine& Line, const Standard_Integer firspt, const Standard_Integer lastpt);
146 //! computes new parameters between firstP and lastP.
147 Standard_EXPORT void Parameters (const AppDef_MultiLine& Line, const Standard_Integer firstP, const Standard_Integer LastP, math_Vector& TheParameters) const;
149 Standard_EXPORT Standard_Real SearchFirstLambda (const AppDef_MultiLine& Line, const math_Vector& Para, const math_Vector& V, const Standard_Integer index) const;
151 Standard_EXPORT Standard_Real SearchLastLambda (const AppDef_MultiLine& Line, const math_Vector& Para, const math_Vector& V, const Standard_Integer index) const;
153 Standard_EXPORT void FirstTangencyVector (const AppDef_MultiLine& Line, const Standard_Integer index, math_Vector& V) const;
155 Standard_EXPORT void LastTangencyVector (const AppDef_MultiLine& Line, const Standard_Integer index, math_Vector& V) const;
158 AppParCurves_SequenceOfMultiCurve myMultiCurves;
159 AppParCurves_MultiCurve TheMultiCurve;
160 AppParCurves_MultiBSpCurve myspline;
161 Standard_Boolean alldone;
162 Standard_Boolean tolreached;
163 Approx_ParametrizationType Par;
164 Handle(TColStd_HArray1OfReal) myParameters;
165 Handle(TColStd_HArray1OfReal) myfirstParam;
166 Approx_SequenceOfHArray1OfReal myPar;
167 TColStd_SequenceOfReal Tolers3d;
168 TColStd_SequenceOfReal Tolers2d;
169 Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints;
170 Standard_Integer mydegremin;
171 Standard_Integer mydegremax;
172 Standard_Real mytol3d;
173 Standard_Real mytol2d;
174 Standard_Real currenttol3d;
175 Standard_Real currenttol2d;
176 Standard_Boolean mycut;
177 Standard_Boolean mysquares;
178 Standard_Integer myitermax;
179 AppParCurves_Constraint myfirstC;
180 AppParCurves_Constraint mylastC;
181 Standard_Integer myMultiLineNb;
182 Standard_Boolean myIsClear;
193 #endif // _AppDef_Compute_HeaderFile