0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / AppDef / AppDef_BSplineCompute.hxx
CommitLineData
42cf5bc1 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
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 _AppDef_BSplineCompute_HeaderFile
18#define _AppDef_BSplineCompute_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <AppParCurves_MultiBSpCurve.hxx>
42cf5bc1 25#include <Approx_ParametrizationType.hxx>
26#include <TColStd_HArray1OfReal.hxx>
27#include <TColStd_HArray1OfInteger.hxx>
28#include <AppParCurves_HArray1OfConstraintCouple.hxx>
29#include <Standard_Integer.hxx>
30#include <Standard_Real.hxx>
31#include <AppParCurves_Constraint.hxx>
32#include <math_Vector.hxx>
33#include <TColStd_Array1OfReal.hxx>
34#include <TColStd_Array1OfInteger.hxx>
35class AppDef_MultiLine;
36class AppDef_MyLineTool;
37class AppDef_MyBSplGradientOfBSplineCompute;
38class AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute;
39class AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute;
40class AppDef_BSpGradient_BFGSOfMyBSplGradientOfBSplineCompute;
41class AppDef_MyGradientbisOfBSplineCompute;
42class AppDef_ParLeastSquareOfMyGradientbisOfBSplineCompute;
43class AppDef_ResConstraintOfMyGradientbisOfBSplineCompute;
44class AppDef_ParFunctionOfMyGradientbisOfBSplineCompute;
45class AppDef_Gradient_BFGSOfMyGradientbisOfBSplineCompute;
46class AppParCurves_MultiBSpCurve;
47class AppParCurves_MultiCurve;
48
49
50
51class AppDef_BSplineCompute
52{
53public:
54
55 DEFINE_STANDARD_ALLOC
56
57
36b9ff75 58 //! The MultiLine <Line> will be approximated until tolerances
59 //! will be reached.
60 //! The approximation will be done from degreemin to degreemax
61 //! with a cutting if the corresponding boolean is True.
62 //! If <Squares> is True, the computation will be done with
63 //! no iteration at all.
64 //!
65 //! The multiplicities of the internal knots is set by
66 //! default.
42cf5bc1 67 Standard_EXPORT AppDef_BSplineCompute(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);
68
36b9ff75 69 //! The MultiLine <Line> will be approximated until tolerances
70 //! will be reached.
71 //! The approximation will be done from degreemin to degreemax
72 //! with a cutting if the corresponding boolean is True.
73 //! If <Squares> is True, the computation will be done with
74 //! no iteration at all.
42cf5bc1 75 Standard_EXPORT AppDef_BSplineCompute(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);
76
36b9ff75 77 //! Initializes the fields of the algorithm.
42cf5bc1 78 Standard_EXPORT AppDef_BSplineCompute(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);
79
36b9ff75 80 //! Initializes the fields of the algorithm.
42cf5bc1 81 Standard_EXPORT AppDef_BSplineCompute(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
36b9ff75 83 //! Constructs an interpolation of the MultiLine <Line>
84 //! The result will be a C2 curve of degree 3.
42cf5bc1 85 Standard_EXPORT void Interpol (const AppDef_MultiLine& Line);
86
36b9ff75 87 //! Initializes the fields of the algorithm.
42cf5bc1 88 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);
89
36b9ff75 90 //! runs the algorithm after having initialized the fields.
42cf5bc1 91 Standard_EXPORT void Perform (const AppDef_MultiLine& Line);
92
36b9ff75 93 //! The approximation will begin with the
94 //! set of parameters <ThePar>.
42cf5bc1 95 Standard_EXPORT void SetParameters (const math_Vector& ThePar);
96
36b9ff75 97 //! The approximation will be done with the
98 //! set of knots <Knots>. The multiplicities will be set
99 //! with the degree and the desired continuity.
42cf5bc1 100 Standard_EXPORT void SetKnots (const TColStd_Array1OfReal& Knots);
101
36b9ff75 102 //! The approximation will be done with the
103 //! set of knots <Knots> and the multiplicities <Mults>.
42cf5bc1 104 Standard_EXPORT void SetKnotsAndMultiplicities (const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults);
105
36b9ff75 106 //! changes the degrees of the approximation.
42cf5bc1 107 Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax);
108
36b9ff75 109 //! Changes the tolerances of the approximation.
42cf5bc1 110 Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d);
111
36b9ff75 112 //! sets the continuity of the spline.
113 //! if C = 2, the spline will be C2.
42cf5bc1 114 Standard_EXPORT void SetContinuity (const Standard_Integer C);
115
36b9ff75 116 //! changes the first and the last constraint points.
42cf5bc1 117 Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
118
d1775ee9 119 //! Sets periodic flag.
21c7c457 120 //! If thePeriodic = Standard_True, algorithm tries to build periodic
d1775ee9 121 //! multicurve using corresponding C1 boundary condition for first and last multipoints.
122 //! Multiline must be closed.
123 Standard_EXPORT void SetPeriodic(const Standard_Boolean thePeriodic);
124
36b9ff75 125 //! returns False if at a moment of the approximation,
126 //! the status NoApproximation has been sent by the user
127 //! when more points were needed.
42cf5bc1 128 Standard_EXPORT Standard_Boolean IsAllApproximated() const;
129
36b9ff75 130 //! returns False if the status NoPointsAdded has been sent.
42cf5bc1 131 Standard_EXPORT Standard_Boolean IsToleranceReached() const;
132
36b9ff75 133 //! returns the tolerances 2d and 3d of the MultiBSpCurve.
42cf5bc1 134 Standard_EXPORT void Error (Standard_Real& tol3d, Standard_Real& tol2d) const;
135
36b9ff75 136 //! returns the result of the approximation.
42cf5bc1 137 Standard_EXPORT const AppParCurves_MultiBSpCurve& Value() const;
138
36b9ff75 139 //! returns the result of the approximation.
42cf5bc1 140 Standard_EXPORT AppParCurves_MultiBSpCurve& ChangeValue();
141
36b9ff75 142 //! returns the new parameters of the approximation
143 //! corresponding to the points of the MultiBSpCurve.
42cf5bc1 144 Standard_EXPORT const TColStd_Array1OfReal& Parameters() const;
145
146
147
148
149protected:
150
151
152
153
154
155private:
156
157
36b9ff75 158 //! is internally used in the algorithm.
42cf5bc1 159 Standard_EXPORT Standard_Boolean Compute (const AppDef_MultiLine& Line, const Standard_Integer fpt, const Standard_Integer lpt, math_Vector& Para, const TColStd_Array1OfReal& Knots, TColStd_Array1OfInteger& Mults);
160
36b9ff75 161 //! is internally used in the algorithm.
42cf5bc1 162 Standard_EXPORT Standard_Boolean ComputeCurve (const AppDef_MultiLine& Line, const Standard_Integer firspt, const Standard_Integer lastpt);
163
36b9ff75 164 //! computes new parameters between firstP and lastP.
42cf5bc1 165 Standard_EXPORT void Parameters (const AppDef_MultiLine& Line, const Standard_Integer firstP, const Standard_Integer LastP, math_Vector& TheParameters) const;
166
167 Standard_EXPORT Standard_Real SearchFirstLambda (const AppDef_MultiLine& Line, const math_Vector& Para, const TColStd_Array1OfReal& Knots, const math_Vector& V, const Standard_Integer index) const;
168
169 Standard_EXPORT Standard_Real SearchLastLambda (const AppDef_MultiLine& Line, const math_Vector& Para, const TColStd_Array1OfReal& Knots, const math_Vector& V, const Standard_Integer index) const;
170
171 Standard_EXPORT void TangencyVector (const AppDef_MultiLine& Line, const AppParCurves_MultiCurve& C, const Standard_Real U, math_Vector& V) const;
172
173 Standard_EXPORT void FirstTangencyVector (const AppDef_MultiLine& Line, const Standard_Integer index, math_Vector& V) const;
174
175 Standard_EXPORT void LastTangencyVector (const AppDef_MultiLine& Line, const Standard_Integer index, math_Vector& V) const;
176
177 Standard_EXPORT void FindRealConstraints (const AppDef_MultiLine& Line);
178
179
180 AppParCurves_MultiBSpCurve TheMultiBSpCurve;
181 Standard_Boolean alldone;
182 Standard_Boolean tolreached;
183 Approx_ParametrizationType Par;
184 Handle(TColStd_HArray1OfReal) myParameters;
185 Handle(TColStd_HArray1OfReal) myfirstParam;
186 Handle(TColStd_HArray1OfReal) myknots;
187 Handle(TColStd_HArray1OfInteger) mymults;
188 Standard_Boolean myhasknots;
189 Standard_Boolean myhasmults;
190 Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints;
191 Standard_Integer mydegremin;
192 Standard_Integer mydegremax;
193 Standard_Real mytol3d;
194 Standard_Real mytol2d;
195 Standard_Real currenttol3d;
196 Standard_Real currenttol2d;
197 Standard_Boolean mycut;
198 Standard_Boolean mysquares;
199 Standard_Integer myitermax;
200 AppParCurves_Constraint myfirstC;
201 AppParCurves_Constraint mylastC;
202 AppParCurves_Constraint realfirstC;
203 AppParCurves_Constraint reallastC;
204 Standard_Integer mycont;
205 Standard_Real mylambda1;
206 Standard_Real mylambda2;
d1775ee9 207 Standard_Boolean myPeriodic;
42cf5bc1 208
209
210};
211
212
213
214
215
216
217
218#endif // _AppDef_BSplineCompute_HeaderFile