0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / GeomInt / GeomInt_TheComputeLineBezierOfWLApprox.hxx
CommitLineData
42cf5bc1 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_TheComputeLineBezierOfWLApprox_HeaderFile
18#define _GeomInt_TheComputeLineBezierOfWLApprox_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
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>
38class GeomInt_TheMultiLineOfWLApprox;
39class GeomInt_TheMultiLineToolOfWLApprox;
40class GeomInt_MyGradientOfTheComputeLineBezierOfWLApprox;
41class GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox;
42class GeomInt_ResConstraintOfMyGradientOfTheComputeLineBezierOfWLApprox;
43class GeomInt_ParFunctionOfMyGradientOfTheComputeLineBezierOfWLApprox;
44class GeomInt_Gradient_BFGSOfMyGradientOfTheComputeLineBezierOfWLApprox;
45class AppParCurves_MultiCurve;
46class AppParCurves_MultiBSpCurve;
47
48
49
50class GeomInt_TheComputeLineBezierOfWLApprox
51{
52public:
53
54 DEFINE_STANDARD_ALLOC
55
56
36b9ff75 57 //! The MultiLine <Line> will be approximated until tolerances
58 //! will be reached.
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.
42cf5bc1 63 Standard_EXPORT GeomInt_TheComputeLineBezierOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& 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);
64
36b9ff75 65 //! The MultiLine <Line> will be approximated until tolerances
66 //! will be reached.
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.
42cf5bc1 71 Standard_EXPORT GeomInt_TheComputeLineBezierOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& 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);
72
36b9ff75 73 //! Initializes the fields of the algorithm.
42cf5bc1 74 Standard_EXPORT GeomInt_TheComputeLineBezierOfWLApprox(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);
75
36b9ff75 76 //! Initializes the fields of the algorithm.
42cf5bc1 77 Standard_EXPORT GeomInt_TheComputeLineBezierOfWLApprox(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);
78
36b9ff75 79 //! Initializes the fields of the algorithm.
42cf5bc1 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);
81
36b9ff75 82 //! runs the algorithm after having initialized the fields.
42cf5bc1 83 Standard_EXPORT void Perform (const GeomInt_TheMultiLineOfWLApprox& Line);
84
36b9ff75 85 //! changes the degrees of the approximation.
42cf5bc1 86 Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax);
87
36b9ff75 88 //! Changes the tolerances of the approximation.
42cf5bc1 89 Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d);
90
36b9ff75 91 //! changes the first and the last constraint points.
42cf5bc1 92 Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
93
36b9ff75 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.
42cf5bc1 97 Standard_EXPORT Standard_Boolean IsAllApproximated() const;
98
36b9ff75 99 //! returns False if the status NoPointsAdded has been sent.
42cf5bc1 100 Standard_EXPORT Standard_Boolean IsToleranceReached() const;
101
36b9ff75 102 //! returns the tolerances 2d and 3d of the <Index> MultiCurve.
42cf5bc1 103 Standard_EXPORT void Error (const Standard_Integer Index, Standard_Real& tol3d, Standard_Real& tol2d) const;
104
36b9ff75 105 //! Returns the number of MultiCurve doing the approximation
106 //! of the MultiLine.
42cf5bc1 107 Standard_EXPORT Standard_Integer NbMultiCurves() const;
108
36b9ff75 109 //! returns the result of the approximation.
42cf5bc1 110 Standard_EXPORT const AppParCurves_MultiCurve& Value (const Standard_Integer Index = 1) const;
111
36b9ff75 112 //! returns the result of the approximation.
42cf5bc1 113 Standard_EXPORT AppParCurves_MultiCurve& ChangeValue (const Standard_Integer Index = 1);
114
36b9ff75 115 //! returns the result of the approximation.
42cf5bc1 116 Standard_EXPORT const AppParCurves_MultiBSpCurve& SplineValue();
117
36b9ff75 118 //! returns the type of parametrization
4e14c88f 119 Standard_EXPORT Approx_ParametrizationType Parametrization () const;
120
36b9ff75 121 //! returns the new parameters of the approximation
122 //! corresponding to the points of the multicurve <Index>.
42cf5bc1 123 Standard_EXPORT const TColStd_Array1OfReal& Parameters (const Standard_Integer Index = 1) const;
124
125
126
127
128protected:
129
130
131
132
133
134private:
135
136
36b9ff75 137 //! is internally used in the algorithm.
2c26a53d 138 Standard_EXPORT Standard_Boolean Compute (const GeomInt_TheMultiLineOfWLApprox& Line,
139 const Standard_Integer fpt,
140 const Standard_Integer lpt,
141 math_Vector& Para,
142 Standard_Real& TheTol3d,
143 Standard_Real& TheTol2d,
144 Standard_Integer& indbad);
42cf5bc1 145
36b9ff75 146 //! is internally used in the algorithm.
42cf5bc1 147 Standard_EXPORT Standard_Boolean ComputeCurve (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer firspt, const Standard_Integer lastpt);
148
36b9ff75 149 //! computes new parameters between firstP and lastP.
42cf5bc1 150 Standard_EXPORT void Parameters (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer firstP, const Standard_Integer LastP, math_Vector& TheParameters) const;
151
152 Standard_EXPORT Standard_Real SearchFirstLambda (const GeomInt_TheMultiLineOfWLApprox& Line, const math_Vector& Para, const math_Vector& V, const Standard_Integer index) const;
153
154 Standard_EXPORT Standard_Real SearchLastLambda (const GeomInt_TheMultiLineOfWLApprox& Line, const math_Vector& Para, const math_Vector& V, const Standard_Integer index) const;
155
156 Standard_EXPORT void FirstTangencyVector (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer index, math_Vector& V) const;
157
158 Standard_EXPORT void LastTangencyVector (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer index, math_Vector& V) const;
159
160
161 AppParCurves_SequenceOfMultiCurve myMultiCurves;
162 AppParCurves_MultiCurve TheMultiCurve;
163 AppParCurves_MultiBSpCurve myspline;
164 Standard_Boolean alldone;
165 Standard_Boolean tolreached;
166 Approx_ParametrizationType Par;
167 Handle(TColStd_HArray1OfReal) myParameters;
168 Handle(TColStd_HArray1OfReal) myfirstParam;
169 Approx_SequenceOfHArray1OfReal myPar;
170 TColStd_SequenceOfReal Tolers3d;
171 TColStd_SequenceOfReal Tolers2d;
172 Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints;
173 Standard_Integer mydegremin;
174 Standard_Integer mydegremax;
175 Standard_Real mytol3d;
176 Standard_Real mytol2d;
177 Standard_Real currenttol3d;
178 Standard_Real currenttol2d;
179 Standard_Boolean mycut;
180 Standard_Boolean mysquares;
181 Standard_Integer myitermax;
182 AppParCurves_Constraint myfirstC;
183 AppParCurves_Constraint mylastC;
184 Standard_Integer myMultiLineNb;
2c26a53d 185 Standard_Integer myNbPlusOnePoint;
42cf5bc1 186 Standard_Boolean myIsClear;
187
188
189};
190
191
192
193
194
195
196
197#endif // _GeomInt_TheComputeLineBezierOfWLApprox_HeaderFile