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
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 _BRepApprox_TheComputeLineBezierOfApprox_HeaderFile
18 #define _BRepApprox_TheComputeLineBezierOfApprox_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 <Standard_Boolean.hxx>
28 #include <Approx_ParametrizationType.hxx>
29 #include <TColStd_HArray1OfReal.hxx>
30 #include <Approx_SequenceOfHArray1OfReal.hxx>
31 #include <TColStd_SequenceOfReal.hxx>
32 #include <AppParCurves_HArray1OfConstraintCouple.hxx>
33 #include <Standard_Integer.hxx>
34 #include <Standard_Real.hxx>
35 #include <AppParCurves_Constraint.hxx>
36 #include <math_Vector.hxx>
37 #include <TColStd_Array1OfReal.hxx>
38 class BRepApprox_TheMultiLineOfApprox;
39 class BRepApprox_TheMultiLineToolOfApprox;
40 class BRepApprox_MyGradientOfTheComputeLineBezierOfApprox;
41 class BRepApprox_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfApprox;
42 class BRepApprox_ResConstraintOfMyGradientOfTheComputeLineBezierOfApprox;
43 class BRepApprox_ParFunctionOfMyGradientOfTheComputeLineBezierOfApprox;
44 class BRepApprox_Gradient_BFGSOfMyGradientOfTheComputeLineBezierOfApprox;
45 class AppParCurves_MultiCurve;
46 class AppParCurves_MultiBSpCurve;
50 class BRepApprox_TheComputeLineBezierOfApprox
57 //! The MultiLine <Line> will be approximated until tolerances
59 //! The approximation will be done from degreemin to degreemax
60 //! with a cutting if the corresponding boolean is True.
61 //! If <Squares> is True, the computation will be done with
62 //! no iteration at all.
63 Standard_EXPORT BRepApprox_TheComputeLineBezierOfApprox(const BRepApprox_TheMultiLineOfApprox& 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);
65 //! The MultiLine <Line> will be approximated until tolerances
67 //! The approximation will be done from degreemin to degreemax
68 //! with a cutting if the corresponding boolean is True.
69 //! If <Squares> is True, the computation will be done with
70 //! no iteration at all.
71 Standard_EXPORT BRepApprox_TheComputeLineBezierOfApprox(const BRepApprox_TheMultiLineOfApprox& 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);
73 //! Initializes the fields of the algorithm.
74 Standard_EXPORT BRepApprox_TheComputeLineBezierOfApprox(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);
76 //! Initializes the fields of the algorithm.
77 Standard_EXPORT BRepApprox_TheComputeLineBezierOfApprox(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);
79 //! Initializes the fields of the algorithm.
80 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);
82 //! runs the algorithm after having initialized the fields.
83 Standard_EXPORT void Perform (const BRepApprox_TheMultiLineOfApprox& Line);
85 //! changes the degrees of the approximation.
86 Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax);
88 //! Changes the tolerances of the approximation.
89 Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d);
91 //! changes the first and the last constraint points.
92 Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
94 //! returns False if at a moment of the approximation,
95 //! the status NoApproximation has been sent by the user
96 //! when more points were needed.
97 Standard_EXPORT Standard_Boolean IsAllApproximated() const;
99 //! returns False if the status NoPointsAdded has been sent.
100 Standard_EXPORT Standard_Boolean IsToleranceReached() const;
102 //! returns the tolerances 2d and 3d of the <Index> MultiCurve.
103 Standard_EXPORT void Error (const Standard_Integer Index, Standard_Real& tol3d, Standard_Real& tol2d) const;
105 //! Returns the number of MultiCurve doing the approximation
106 //! of the MultiLine.
107 Standard_EXPORT Standard_Integer NbMultiCurves() const;
109 //! returns the result of the approximation.
110 Standard_EXPORT const AppParCurves_MultiCurve& Value (const Standard_Integer Index = 1) const;
112 //! returns the result of the approximation.
113 Standard_EXPORT AppParCurves_MultiCurve& ChangeValue (const Standard_Integer Index = 1);
115 //! returns the result of the approximation.
116 Standard_EXPORT const AppParCurves_MultiBSpCurve& SplineValue();
118 //! returns the type of parametrization
119 Standard_EXPORT Approx_ParametrizationType Parametrization () const;
121 //! returns the new parameters of the approximation
122 //! corresponding to the points of the multicurve <Index>.
123 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 BRepApprox_TheMultiLineOfApprox& 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 BRepApprox_TheMultiLineOfApprox& Line, const Standard_Integer firspt, const Standard_Integer lastpt);
146 //! computes new parameters between firstP and lastP.
147 Standard_EXPORT void Parameters (const BRepApprox_TheMultiLineOfApprox& Line, const Standard_Integer firstP, const Standard_Integer LastP, math_Vector& TheParameters) const;
149 Standard_EXPORT Standard_Real SearchFirstLambda (const BRepApprox_TheMultiLineOfApprox& Line, const math_Vector& Para, const math_Vector& V, const Standard_Integer index) const;
151 Standard_EXPORT Standard_Real SearchLastLambda (const BRepApprox_TheMultiLineOfApprox& Line, const math_Vector& Para, const math_Vector& V, const Standard_Integer index) const;
153 Standard_EXPORT void FirstTangencyVector (const BRepApprox_TheMultiLineOfApprox& Line, const Standard_Integer index, math_Vector& V) const;
155 Standard_EXPORT void LastTangencyVector (const BRepApprox_TheMultiLineOfApprox& 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 // _BRepApprox_TheComputeLineBezierOfApprox_HeaderFile