1 -- Created on: 1993-01-26
2 -- Created by: Laurent PAINNOT
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 ComputeLine from Approx
22 uses ParametrizationType from Approx,
23 SequenceOfReal from TColStd,
24 HArray1OfReal from TColStd,
25 Array1OfReal from TColStd,
26 SequenceOfMultiCurve from AppParCurves,
27 HArray1OfMultiCurve from AppParCurves,
28 HArray1OfConstraintCouple from AppParCurves,
29 Constraint from AppParCurves,
30 SequenceOfHArray1OfReal from Approx,
31 MultiCurve from AppParCurves,
32 MultiBSpCurve from AppParCurves,
37 private class MyGradient instantiates Gradient from AppParCurves
44 Create(Line: MultiLine;
45 degreemin: Integer = 4;
46 degreemax: Integer = 8;
47 Tolerance3d: Real = 1.0e-3;
48 Tolerance2d: Real = 1.0e-6;
49 NbIterations: Integer = 5;
50 cutting: Boolean = Standard_True;
51 parametrization: ParametrizationType from Approx =
53 Squares: Boolean = Standard_False)
55 ---Purpose: 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.
65 Create(Line: MultiLine;
66 Parameters: Vector from math;
67 degreemin: Integer = 4;
68 degreemax: Integer = 8;
69 Tolerance3d: Real = 1.0e-03;
70 Tolerance2d: Real = 1.0e-06;
71 NbIterations: Integer = 5;
72 cutting: Boolean = Standard_True;
73 Squares: Boolean = Standard_False)
75 ---Purpose: The MultiLine <Line> will be approximated until tolerances
77 -- The approximation will be done from degreemin to degreemax
78 -- with a cutting if the corresponding boolean is True.
79 -- If <Squares> is True, the computation will be done with
80 -- no iteration at all.
85 Create(Parameters: Vector from math;
86 degreemin: Integer = 4;
87 degreemax: Integer = 8;
88 Tolerance3d: Real = 1.0e-03;
89 Tolerance2d: Real = 1.0e-06;
90 NbIterations: Integer = 5;
91 cutting: Boolean = Standard_True;
92 Squares: Boolean = Standard_False)
94 ---Purpose: Initializes the fields of the algorithm.
99 Create(degreemin: Integer = 4;
100 degreemax: Integer = 8;
101 Tolerance3d: Real = 1.0e-03;
102 Tolerance2d: Real = 1.0e-06;
103 NbIterations: Integer = 5;
104 cutting: Boolean = Standard_True;
105 parametrization: ParametrizationType from Approx =
107 Squares: Boolean = Standard_False)
109 ---Purpose: Initializes the fields of the algorithm.
114 Init(me: in out; degreemin: Integer = 4;
115 degreemax: Integer = 8;
116 Tolerance3d: Real = 1.0e-03;
117 Tolerance2d: Real = 1.0e-06;
118 NbIterations: Integer = 5;
119 cutting: Boolean = Standard_True;
120 parametrization: ParametrizationType from Approx =
122 Squares: Boolean = Standard_False)
124 ---Purpose: Initializes the fields of the algorithm.
131 Perform(me: in out; Line: MultiLine)
132 ---Purpose: runs the algorithm after having initialized the fields.
137 Compute(me: in out; Line: MultiLine; fpt, lpt: Integer;
138 Para: in out Vector from math; TheTol3d, TheTol2d: in out Real)
139 ---Purpose: is internally used in the algorithm.
145 ComputeCurve(me: in out; Line: MultiLine; firspt, lastpt: Integer)
146 ---Purpose: is internally used in the algorithm.
152 Parameters(me; Line: MultiLine; firstP, LastP: Integer;
153 TheParameters: in out Vector)
154 ---Purpose: computes new parameters between firstP and lastP.
159 SetDegrees(me: in out; degreemin, degreemax: Integer)
160 ---Purpose: changes the degrees of the approximation.
165 SetTolerances(me: in out; Tolerance3d, Tolerance2d: Real)
166 ---Purpose: Changes the tolerances of the approximation.
171 SetConstraints(me: in out; firstC, lastC: Constraint from AppParCurves)
172 ---Purpose: changes the first and the last constraint points.
176 IsAllApproximated(me)
177 ---Purpose: returns False if at a moment of the approximation,
178 -- the status NoApproximation has been sent by the user
179 -- when more points were needed.
185 IsToleranceReached(me)
186 ---Purpose: returns False if the status NoPointsAdded has been sent.
192 Error(me; Index: Integer; tol3d: in out Real; tol2d: in out Real)
193 ---Purpose: returns the tolerances 2d and 3d of the <Index> MultiCurve.
199 ---Purpose: Returns the number of MultiCurve doing the approximation
205 Value(me; Index: Integer = 1)
206 ---Purpose: returns the result of the approximation.
207 ---C++: return const&
208 returns MultiCurve from AppParCurves
211 ChangeValue(me: in out; Index: Integer = 1)
212 ---Purpose: returns the result of the approximation.
214 returns MultiCurve from AppParCurves
218 SplineValue(me: in out)
219 ---Purpose: returns the result of the approximation.
220 ---C++: return const&
221 returns MultiBSpCurve from AppParCurves
224 Parametrization(me; partype : in out ParametrizationType from Approx)
225 ---Purpose: returns the type of parametrization
229 Parameters(me; Index: Integer = 1)
230 ---Purpose: returns the new parameters of the approximation
231 -- corresponding to the points of the multicurve <Index>.
232 ---C++: return const&
233 returns Array1OfReal from TColStd
238 SearchFirstLambda(me; Line: MultiLine; Para: Vector;
239 V: Vector; index: Integer)
243 SearchLastLambda(me: ; Line: MultiLine; Para: Vector;
244 V: Vector; index: Integer)
248 FirstTangencyVector(me; Line: MultiLine; index: Integer; V: in out Vector)
251 LastTangencyVector(me; Line: MultiLine; index: Integer; V: in out Vector)
258 myMultiCurves: SequenceOfMultiCurve from AppParCurves;
259 TheMultiCurve: MultiCurve from AppParCurves;
260 myspline : MultiBSpCurve from AppParCurves;
261 alldone: Boolean from Standard;
262 tolreached: Boolean from Standard;
263 Par: ParametrizationType from Approx;
264 myParameters: HArray1OfReal from TColStd;
265 myfirstParam: HArray1OfReal from TColStd;
266 myPar: SequenceOfHArray1OfReal from Approx;
267 Tolers3d: SequenceOfReal from TColStd;
268 Tolers2d: SequenceOfReal from TColStd;
269 myConstraints: HArray1OfConstraintCouple from AppParCurves;
270 mydegremin: Integer from Standard;
271 mydegremax: Integer from Standard;
272 mytol3d: Real from Standard;
273 mytol2d: Real from Standard;
274 currenttol3d: Real from Standard;
275 currenttol2d: Real from Standard;
276 mycut: Boolean from Standard;
277 mysquares: Boolean from Standard;
278 myitermax: Integer from Standard;
279 myfirstC: Constraint from AppParCurves;
280 mylastC: Constraint from AppParCurves;
281 myMultiLineNb: Integer from Standard;
282 myIsClear : Boolean from Standard;