0024708: Convertation of the generic classes to the non-generic. Part 2
[occt.git] / src / AppDef / AppDef_Variational.cdl
CommitLineData
b311480e 1-- Created on: 1996-05-14
2-- Created by: Philippe MANGIN / Jeannine PANCIATICI
3-- Copyright (c) 1996-1999 Matra Datavision
973c2be1 4-- Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5--
973c2be1 6-- This file is part of Open CASCADE Technology software library.
b311480e 7--
d5f74e42 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
973c2be1 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.
b311480e 13--
973c2be1 14-- Alternatively, this file may be used under the terms of Open CASCADE
15-- commercial license or contractual agreement.
b311480e 16
7fd59977 17-- Igor FEOKTISTOV - correction 14/12/98
7fd59977 18
19
f62de372 20class Variational from AppDef
7fd59977 21
22
23 ---Purpose: This class is used to smooth N points with constraints
24 -- by minimization of quadratic criterium but also
25 -- variational criterium in order to obtain " fair Curve "
26 --
27
28uses Matrix from math,
29 Vector from math,
30 HArray1OfReal from TColStd,
31 Array1OfReal from TColStd,
32 HArray1OfInteger from TColStd,
33 Shape from GeomAbs,
34 HArray1OfConstraintCouple from AppParCurves,
35 MultiBSpCurve from AppParCurves,
f62de372 36 SmoothCriterion from AppDef,
7fd59977 37 Curve from FEmTool,
38 Assembly from FEmTool,
39 Base from PLib,
f62de372 40 Constraint from AppParCurves,
41 MultiLine from AppDef,
42 MyLineTool from AppDef
7fd59977 43
44raises OutOfRange from Standard,
45 DimensionError from Standard,
46 DomainError from Standard,
47 ConstructionError from Standard,
48 NotDone from StdFail,
49 VectorWithNullMagnitude from gp
50
7fd59977 51
52is
f62de372 53 Create(SSP: MultiLine from AppDef;
7fd59977 54 FirstPoint, LastPoint: Integer;
55 TheConstraints: HArray1OfConstraintCouple;
56 MaxDegree: Integer = 14;
57 MaxSegment: Integer = 100;
58 Continuity : Shape from GeomAbs = GeomAbs_C2;
59 WithMinMax : Boolean = Standard_False;
60 WithCutting: Boolean = Standard_True;
61 Tolerance : Real = 1.0;
62 NbIterations: Integer = 2)
63 ---Purpose: Constructor.
64 -- Initialization of the fields.
65 -- warning : Nc0 : number of PassagePoint consraints
66 -- Nc2 : number of TangencyPoint constraints
67 -- Nc3 : number of CurvaturePoint constraints
68 -- if
69 -- ((MaxDegree-Continuity)*MaxSegment -Nc0 - 2*Nc1
70 -- -3*Nc2)
71 -- is negative
72 -- The problem is over-constrained.
73 --
f62de372 74 -- Limitation : The MultiLine from AppDef has to be composed by
7fd59977 75 -- only one Line ( Dimension 2 or 3).
76
f62de372 77 returns Variational from AppDef;
7fd59977 78
79
80 Approximate(me : in out)
81 ---Purpose: Makes the approximation with the current fields.
82 raises NotDone from StdFail
83 is static;
84
85
86
87-- ==================== The Selectors ===========================
88
89 IsCreated(me)
90 ---Purpose: returns True if the creation is done
91 -- and correspond to the current fields.
92 returns Boolean
93 is static;
94
95
96 IsDone(me)
97 ---Purpose: returns True if the approximation is ok
98 -- and correspond to the current fields.
99 returns Boolean
100 is static;
101
102 IsOverConstrained(me)
103 ---Purpose: returns True if the problem is overconstrained
104 -- in this case, approximation cannot be done.
105 returns Boolean
106 is static;
107
108 Value(me)
109 ---Purpose: returns all the BSpline curves approximating the
f62de372 110 -- MultiLine from AppDef SSP after minimization of the parameter.
7fd59977 111
112 returns MultiBSpCurve from AppParCurves
113 raises NotDone from StdFail
114 is static;
115
116
117 MaxError(me)
118 ---Purpose: returns the maximum of the distances between
119 -- the points of the multiline and the approximation
120 -- curves.
121 returns Real
122 raises NotDone from StdFail
123 is static;
124
125 MaxErrorIndex(me)
126 ---Purpose: returns the index of the MultiPoint of ErrorMax
127 returns Integer
128
129 raises NotDone from StdFail
130 is static;
131
132
133 QuadraticError(me)
134 ---Purpose: returns the quadratic average of the distances between
135 -- the points of the multiline and the approximation
136 -- curves.
137 returns Real
138 raises NotDone from StdFail
139 is static;
140
141 Distance(me : in out ; mat : out Matrix from math)
142 ---Purpose: returns the distances between the points of the
143 -- multiline and the approximation curves.
144 raises NotDone from StdFail
145 is static;
146
147 AverageError(me)
148 ---Purpose: returns the average error between
f62de372 149 -- the MultiLine from AppDef and the approximation.
7fd59977 150
151 returns Real
152 raises NotDone from StdFail
153 is static;
154
155 Parameters(me)
156 ---Purpose: returns the parameters uses to the approximations
157 ---C++: return const&
158
159 returns HArray1OfReal
160 raises NotDone from StdFail
161 is static;
162
163 Knots(me)
164 ---Purpose: returns the knots uses to the approximations
165 ---C++: return const&
166 returns HArray1OfReal
167 raises NotDone from StdFail
168 is static;
169
170 Criterium(me; VFirstOrder,
171 VSecondOrder,
172 VThirdOrder : out Real)
173 ---Purpose: returns the values of the quality criterium.
174 raises NotDone from StdFail
175 is static;
176
177 CriteriumWeight(me ;
178 Percent1, Percent2, Percent3 : out Real)
179 ---Purpose: returns the Weights (as percent) associed to the criterium used in
180 -- the optimization.
181 is static;
182
183 MaxDegree(me)
184 ---Purpose: returns the Maximum Degree used in the approximation
185 returns Integer
186 is static;
187
188 MaxSegment(me)
189 ---Purpose: returns the Maximum of segment used in the approximation
190 returns Integer
191 is static;
192
193 Continuity(me)
194 ---Purpose: returns the Continuity used in the approximation
195 returns Shape from GeomAbs
196 is static;
197
198
199 WithMinMax(me)
200 ---Purpose: returns if the approximation search to minimize the
201 -- maximum Error or not.
202 returns Boolean
203 is static;
204
205 WithCutting(me)
206 ---Purpose: returns if the approximation can insert new Knots or not.
207 returns Boolean
208 is static;
209
210 Tolerance(me)
211 ---Purpose: returns the tolerance used in the approximation.
212 returns Real
213 is static;
214
215 NbIterations(me)
216 ---Purpose: returns the number of iterations used in the approximation.
217 returns Integer
218 is static;
219
220 Dump(me ; o : in out OStream)
221 ---Purpose: Prints on the stream o information on the current state
222 -- of the object.
223 -- MaxError,MaxErrorIndex,AverageError,QuadraticError,Criterium
224 -- Distances,Degre,Nombre de poles, parametres, noeuds
225 is static;
226
227 SetConstraints(me:in out; aConstrainst:HArray1OfConstraintCouple)
228 ---Purpose: Define the constraints to approximate
229 -- If this value is incompatible with the others fields
230 -- this method modify nothing and returns false
231 returns Boolean
232 is static;
233
234 SetParameters(me:in out; param : HArray1OfReal)
235 ---Purpose: Defines the parameters used by the approximations.
236 raises DimensionError
237 is static;
238
239 SetKnots(me:in out; knots : HArray1OfReal)
240 ---Purpose: Defines the knots used by the approximations
241 -- If this value is incompatible with the others fields
242 -- this method modify nothing and returns false
243 returns Boolean
244 raises DimensionError,
245 DomainError
246 is static;
247
248 SetMaxDegree(me: in out; Degree : Integer)
249 ---Purpose: Define the Maximum Degree used in the approximation
250 -- If this value is incompatible with the others fields
251 -- this method modify nothing and returns false
252 returns Boolean
253 is static;
254
255 SetMaxSegment(me: in out; NbSegment : Integer)
256 ---Purpose: Define the maximum number of segments used in the approximation
257 -- If this value is incompatible with the others fields
258 -- this method modify nothing and returns false
259 returns Boolean
260 is static;
261
262 SetContinuity(me: in out; C : Shape from GeomAbs)
263 ---Purpose: Define the Continuity used in the approximation
264 -- If this value is incompatible with the others fields
265 -- this method modify nothing and returns false
266 returns Boolean
267 raises ConstructionError from Standard
268 is static;
269
270
271 SetWithMinMax(me: in out; MinMax : Boolean)
272 ---Purpose: Define if the approximation search to minimize the
273 -- maximum Error or not.
274 is static;
275
276 SetWithCutting(me : in out; Cutting : Boolean )
277 ---Purpose: Define if the approximation can insert new Knots or not.
278 -- If this value is incompatible with the others fields
279 -- this method modify nothing and returns false
280 returns Boolean
281 is static;
282
283 SetCriteriumWeight(me : in out;
284 Percent1, Percent2, Percent3 : Real)
285 ---Purpose: define the Weights (as percent) associed to the criterium used in
286 -- the optimization.
287 --
288 raises DomainError -- if Percent <= 0
289 is static;
290
291 SetCriteriumWeight(me : in out;
292 Order : Integer;
293 Percent : Real)
294 ---Purpose: define the Weight (as percent) associed to the
295 -- criterium Order used in the optimization : Others
296 -- weights are updated.
297 raises DomainError, -- if Percent < 0
298 OutOfRange -- if Order < 1 or Order > 3
299 is static;
300
301 SetTolerance(me:in out; Tol : Real)
302 ---Purpose: define the tolerance used in the approximation.
303 is static;
304
305 SetNbIterations(me:in out; Iter : Integer)
306 ---Purpose: define the number of iterations used in the approximation.
307 raises DomainError -- if Iter < 1
308 is static;
309
310
311-- ====================== The Private methods ======================
312
313 TheMotor(me : in out;
f62de372 314 J : in out SmoothCriterion from AppDef;
7fd59977 315 WQuadratic, WQuality : Real;
316 TheCurve : in out Curve from FEmTool;
317 Ecarts : out Array1OfReal from TColStd) is private;
318
319 Adjusting(me : in out;
f62de372 320 J : in out SmoothCriterion from AppDef;
7fd59977 321 WQuadratic, WQuality : in out Real;
322 TheCurve : in out Curve from FEmTool;
323 Ecarts : out Array1OfReal from TColStd) is private;
324
325 Optimization(me;
f62de372 326 J : in out SmoothCriterion from AppDef;
7fd59977 327 A : in out Assembly from FEmTool;
328 ToAssemble : in Boolean;
329 EpsDeg : Real;
330 Curve : out Curve from FEmTool;
331 Parameters : Array1OfReal from TColStd) is private;
332
333 Project(me; C : Curve from FEmTool;
334 Ti : Array1OfReal from TColStd;
335 ProjTi : out Array1OfReal from TColStd;
336 Distance : out Array1OfReal from TColStd;
337 NumPoints : out Integer;
338 MaxErr, QuaErr, AveErr : out Real;
339 NbIterations: Integer=2) is private;
340
341 ACR(me; Curve : in out Curve from FEmTool;
342 Ti : in out Array1OfReal from TColStd;
343 Decima: Integer) is private;
344
345 SplitCurve(me; InCurve : Curve from FEmTool;
346 Ti : Array1OfReal from TColStd;
347 CurveTol: Real;
348 OutCurve: out Curve from FEmTool;
349 iscut : out Boolean) is private;
350
351 Init(me : in out)
352 raises NotDone from StdFail,
353 ConstructionError from Standard,
354 DimensionError from Standard
355 is private;
356
357 InitSmoothCriterion(me : in out)
358 is private;
359
360 InitParameters(me : in out; Length : out Real)
361 raises ConstructionError from Standard
362 is private;
363
364 InitCriterionEstimations(me; Length : Real; J1, J2, J3 : out Real)
365 is private;
366
367 EstTangent(me; ipnt : Integer; VTang : out Vector from math)
368 is private;
369
370 EstSecnd(me; ipnt : Integer; VTang1, VTang2 : Vector from math;
371 Length : Real; VScnd : out Vector from math)
372 is private;
373
374 InitCutting(me; aBase : Base from PLib; CurvTol : Real;
375 aCurve : out Curve from FEmTool)
376 raises ConstructionError from Standard
377 is private;
378
379 AssemblingConstraints(me; Curve : Curve from FEmTool;
380 Parameters : Array1OfReal from TColStd;
381 CBLONG : Real from Standard;
382 A : out Assembly from FEmTool)
383 is private;
384
385 InitTthetaF(me : in out; ndimen : Integer from Standard;
386 typcon : Constraint from AppParCurves;
387 begin : Integer from Standard;
388 jndex : Integer from Standard)
389 returns Boolean
390 is private;
391
392
393fields
394 -- Description of the points to smooth and the constraints
f62de372 395mySSP : MultiLine from AppDef;
7fd59977 396myNbP3d : Integer;
397myNbP2d : Integer;
398myDimension : Integer;
399myFirstPoint : Integer;
400myLastPoint : Integer;
401myNbPoints : Integer;
402myTabPoints : HArray1OfReal;
403myConstraints : HArray1OfConstraintCouple;
404myNbConstraints : Integer;
405myTabConstraints : HArray1OfReal;
406myNbPassPoints : Integer;
407myNbTangPoints : Integer;
408myNbCurvPoints : Integer;
409myTypConstraints : HArray1OfInteger;
410myTtheta : HArray1OfReal;
411myTfthet : HArray1OfReal;
412
413 -- Context parameters
414myMaxDegree : Integer;
415myMaxSegment : Integer;
416myNbIterations: Integer;
417myTolerance : Real;
418
419 -- Options
420myContinuity : Shape from GeomAbs;
421myNivCont : Integer;
422myWithMinMax : Boolean;
423myWithCutting: Boolean;
424myPercent : Real[3];
425myCriterium : Real[4];
f62de372 426mySmoothCriterion : SmoothCriterion from AppDef;
7fd59977 427
428 -- output
429myParameters : HArray1OfReal;
430myKnots : HArray1OfReal;
431myMBSpCurve : MultiBSpCurve;
432
433myMaxError : Real;
434myMaxErrorIndex: Integer;
435myAverageError : Real;
436myIsCreated : Boolean;
437myIsDone : Boolean;
438myIsOverConstr : Boolean;
439
440end Variational;