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