1 -- Created on: 1993-09-22
2 -- Created by: Modelistation
3 -- Copyright (c) 1993-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 generic class BSplComputeLine from Approx
23 uses ParametrizationType from Approx,
24 SequenceOfReal from TColStd,
25 HArray1OfReal from TColStd,
26 HArray1OfInteger from TColStd,
27 Array1OfReal from TColStd,
28 Array1OfInteger from TColStd,
29 HArray1OfConstraintCouple from AppParCurves,
30 Constraint from AppParCurves,
31 MultiBSpCurve from AppParCurves,
32 MultiCurve from AppParCurves,
37 private class MyBSplGradient instantiates BSpGradient from AppParCurves
42 private class MyGradientbis instantiates Gradient from AppParCurves
49 Create(Line: MultiLine;
50 degreemin: Integer = 4;
51 degreemax: Integer = 8;
52 Tolerance3d: Real = 1.0e-3;
53 Tolerance2d: Real = 1.0e-6;
54 NbIterations: Integer = 5;
55 cutting: Boolean = Standard_True;
56 parametrization: ParametrizationType from Approx =
58 Squares: Boolean = Standard_False)
60 ---Purpose: The MultiLine <Line> will be approximated until tolerances
62 -- The approximation will be done from degreemin to degreemax
63 -- with a cutting if the corresponding boolean is True.
64 -- If <Squares> is True, the computation will be done with
65 -- no iteration at all.
67 -- The multiplicities of the internal knots is set by
70 returns BSplComputeLine;
73 Create(Line: MultiLine;
74 Parameters: Vector from math;
75 degreemin: Integer = 4;
76 degreemax: Integer = 8;
77 Tolerance3d: Real = 1.0e-03;
78 Tolerance2d: Real = 1.0e-06;
79 NbIterations: Integer = 5;
80 cutting: Boolean = Standard_True;
81 Squares: Boolean = Standard_False)
83 ---Purpose: The MultiLine <Line> will be approximated until tolerances
85 -- The approximation will be done from degreemin to degreemax
86 -- with a cutting if the corresponding boolean is True.
87 -- If <Squares> is True, the computation will be done with
88 -- no iteration at all.
90 returns BSplComputeLine;
93 Create(Parameters: Vector from math;
94 degreemin: Integer = 4;
95 degreemax: Integer = 8;
96 Tolerance3d: Real = 1.0e-03;
97 Tolerance2d: Real = 1.0e-06;
98 NbIterations: Integer = 5;
99 cutting: Boolean = Standard_True;
100 Squares: Boolean = Standard_False)
102 ---Purpose: Initializes the fields of the algorithm.
104 returns BSplComputeLine;
107 Create(degreemin: Integer = 4;
108 degreemax: Integer = 8;
109 Tolerance3d: Real = 1.0e-03;
110 Tolerance2d: Real = 1.0e-06;
111 NbIterations: Integer = 5;
112 cutting: Boolean = Standard_True;
113 parametrization: ParametrizationType from Approx =
115 Squares: Boolean = Standard_False)
117 ---Purpose: Initializes the fields of the algorithm.
119 returns BSplComputeLine;
122 Interpol(me: in out; Line: MultiLine)
123 ---Purpose: Constructs an interpolation of the MultiLine <Line>
124 -- The result will be a C2 curve of degree 3.
129 Init(me: in out; degreemin: Integer = 4;
130 degreemax: Integer = 8;
131 Tolerance3d: Real = 1.0e-03;
132 Tolerance2d: Real = 1.0e-06;
133 NbIterations: Integer = 5;
134 cutting: Boolean = Standard_True;
135 parametrization: ParametrizationType from Approx =
137 Squares: Boolean = Standard_False)
139 ---Purpose: Initializes the fields of the algorithm.
144 Perform(me: in out; Line: MultiLine)
145 ---Purpose: runs the algorithm after having initialized the fields.
150 Compute(me: in out; Line: MultiLine; fpt, lpt: Integer;
151 Para: in out Vector from math; Knots: Array1OfReal;
152 Mults: in out Array1OfInteger)
153 ---Purpose: is internally used in the algorithm.
159 ComputeCurve(me: in out; Line: MultiLine; firspt, lastpt: Integer)
160 ---Purpose: is internally used in the algorithm.
166 Parameters(me; Line: MultiLine; firstP, LastP: Integer;
167 TheParameters: in out Vector)
168 ---Purpose: computes new parameters between firstP and lastP.
173 SetParameters(me: in out; ThePar: Vector from math)
174 ---Purpose: The approximation will begin with the
175 -- set of parameters <ThePar>.
179 SetKnots(me: in out; Knots: Array1OfReal from TColStd)
180 ---Purpose: The approximation will be done with the
181 -- set of knots <Knots>. The multiplicities will be set
182 -- with the degree and the desired continuity.
186 SetKnotsAndMultiplicities(me: in out;
187 Knots: Array1OfReal from TColStd;
188 Mults: Array1OfInteger from TColStd)
189 ---Purpose: The approximation will be done with the
190 -- set of knots <Knots> and the multiplicities <Mults>.
194 SetDegrees(me: in out; degreemin, degreemax: Integer)
195 ---Purpose: changes the degrees of the approximation.
200 SetTolerances(me: in out; Tolerance3d, Tolerance2d: Real)
201 ---Purpose: Changes the tolerances of the approximation.
206 SetContinuity(me: in out; C: Integer)
207 ---Purpose: sets the continuity of the spline.
208 -- if C = 2, the spline will be C2.
213 SetConstraints(me: in out; firstC, lastC: Constraint from AppParCurves)
214 ---Purpose: changes the first and the last constraint points.
218 IsAllApproximated(me)
219 ---Purpose: returns False if at a moment of the approximation,
220 -- the status NoApproximation has been sent by the user
221 -- when more points were needed.
227 IsToleranceReached(me)
228 ---Purpose: returns False if the status NoPointsAdded has been sent.
234 Error(me; tol3d: in out Real; tol2d: in out Real)
235 ---Purpose: returns the tolerances 2d and 3d of the MultiBSpCurve.
241 ---Purpose: returns the result of the approximation.
242 ---C++: return const&
243 returns MultiBSpCurve from AppParCurves;
246 ChangeValue(me: in out)
247 ---Purpose: returns the result of the approximation.
249 returns MultiBSpCurve from AppParCurves;
254 ---Purpose: returns the new parameters of the approximation
255 -- corresponding to the points of the MultiBSpCurve.
256 ---C++: return const&
257 returns Array1OfReal from TColStd
262 SearchFirstLambda(me; Line: MultiLine; Para: Vector;
263 Knots: Array1OfReal from TColStd;
264 V: Vector; index: Integer)
268 SearchLastLambda(me: ; Line: MultiLine; Para: Vector;
269 Knots: Array1OfReal from TColStd;
270 V: Vector; index: Integer)
274 TangencyVector(me; Line: MultiLine; C: MultiCurve from AppParCurves;
275 U: Real from Standard; V: in out Vector from math)
279 FirstTangencyVector(me; Line: MultiLine; index: Integer; V: out Vector)
282 LastTangencyVector(me; Line: MultiLine; index: Integer; V: out Vector)
285 FindRealConstraints(me: in out; Line: MultiLine)
290 TheMultiBSpCurve: MultiBSpCurve from AppParCurves;
291 alldone : Boolean from Standard;
292 tolreached : Boolean from Standard;
293 Par : ParametrizationType from Approx;
294 myParameters : HArray1OfReal from TColStd;
295 myfirstParam : HArray1OfReal from TColStd;
296 myknots : HArray1OfReal from TColStd;
297 mymults : HArray1OfInteger from TColStd;
298 myhasknots : Boolean from Standard;
299 myhasmults : Boolean from Standard;
300 myConstraints : HArray1OfConstraintCouple from AppParCurves;
301 mydegremin : Integer from Standard;
302 mydegremax : Integer from Standard;
303 mytol3d : Real from Standard;
304 mytol2d : Real from Standard;
305 currenttol3d : Real from Standard;
306 currenttol2d : Real from Standard;
307 mycut : Boolean from Standard;
308 mysquares : Boolean from Standard;
309 myitermax : Integer from Standard;
310 myfirstC : Constraint from AppParCurves;
311 mylastC : Constraint from AppParCurves;
312 realfirstC : Constraint from AppParCurves;
313 reallastC : Constraint from AppParCurves;
314 mycont : Integer from Standard;
315 mylambda1 : Real from Standard;
316 mylambda2 : Real from Standard;