0024428: Implementation of LGPL license
[occt.git] / src / Approx / Approx_ComputeLine.cdl
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
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
9 -- under the terms of the GNU Lesser General Public 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 generic class ComputeLine from Approx 
18                     (MultiLine as any;
19                      LineTool  as any) --as TheLineTool(MultiLine)
20
21
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,
33      Vector                    from math
34      
35      
36
37 private class MyGradient instantiates Gradient from AppParCurves
38                                        (MultiLine,
39                                         LineTool);
40                                                           
41 is
42
43
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 =
52            Approx_ChordLength;
53            Squares:         Boolean = Standard_False)
54            
55         ---Purpose: The MultiLine <Line> will be approximated until tolerances
56         --          will be reached.
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.
61
62     returns ComputeLine;
63
64
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)
74            
75         ---Purpose: The MultiLine <Line> will be approximated until tolerances
76         --          will be reached.
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.
81
82     returns ComputeLine;
83
84
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)
93            
94         ---Purpose: Initializes the fields of the algorithm.
95
96     returns ComputeLine;
97
98
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 =
106            Approx_ChordLength;
107            Squares:      Boolean = Standard_False)
108            
109         ---Purpose: Initializes the fields of the algorithm.
110
111     returns ComputeLine;
112
113
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 =
121                      Approx_ChordLength;
122                      Squares:      Boolean = Standard_False)
123            
124         ---Purpose: Initializes the fields of the algorithm.
125
126     is static;
127
128
129
130
131     Perform(me: in out; Line: MultiLine)
132         ---Purpose: runs the algorithm after having initialized the fields.
133     
134     is static;
135
136
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.
140
141     returns Boolean
142     is static private;
143     
144     
145     ComputeCurve(me: in out; Line: MultiLine; firspt, lastpt: Integer) 
146         ---Purpose: is internally used in the algorithm.
147     
148     returns Boolean
149     is static private;
150     
151     
152     Parameters(me; Line: MultiLine; firstP, LastP: Integer;
153                TheParameters: in out Vector)
154         ---Purpose: computes new parameters between firstP and lastP.
155
156     is static private;
157     
158     
159     SetDegrees(me: in out; degreemin, degreemax: Integer)
160         ---Purpose: changes the degrees of the approximation.
161     
162     is static;
163     
164     
165     SetTolerances(me: in out; Tolerance3d, Tolerance2d: Real)
166         ---Purpose: Changes the tolerances of the approximation.
167     
168     is static;
169     
170
171     SetConstraints(me: in out; firstC, lastC: Constraint from AppParCurves)
172             ---Purpose: changes the first and the last constraint points.
173     is static;
174
175
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.
180     
181     returns Boolean
182     is static;
183     
184
185     IsToleranceReached(me)
186         ---Purpose: returns False if the status NoPointsAdded has been sent.
187     
188     returns Boolean
189     is static;
190     
191
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.
194
195     is static;
196     
197
198     NbMultiCurves(me)
199         ---Purpose: Returns the number of MultiCurve doing the approximation
200         --          of the MultiLine.
201     returns Integer
202     is static;
203
204
205     Value(me; Index: Integer = 1)
206         ---Purpose: returns the result of the approximation.
207         ---C++: return const&
208     returns MultiCurve from AppParCurves
209     is static;
210
211     ChangeValue(me: in out; Index: Integer = 1)
212         ---Purpose: returns the result of the approximation.
213         ---C++: return &
214     returns MultiCurve from AppParCurves
215     is static;
216
217
218     SplineValue(me: in out)
219         ---Purpose: returns the result of the approximation.
220         ---C++: return const&
221     returns MultiBSpCurve from AppParCurves
222     is static;
223
224     Parametrization(me; partype :  in  out ParametrizationType from Approx) 
225         ---Purpose: returns the type  of  parametrization
226     is static;
227
228
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
234     is static;
235  
236      
237     
238     SearchFirstLambda(me; Line: MultiLine; Para: Vector; 
239                       V: Vector; index: Integer)
240     returns Real
241     is static private;
242     
243     SearchLastLambda(me: ; Line: MultiLine; Para: Vector;
244                      V: Vector; index: Integer)
245     returns Real
246     is static private;
247     
248     FirstTangencyVector(me; Line: MultiLine; index: Integer; V: in out Vector)
249     is static private;
250     
251     LastTangencyVector(me; Line: MultiLine; index: Integer; V: in out Vector)
252     is static private;
253
254
255 fields
256
257
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;
283
284 end ComputeLine;