b311480e |
1 | -- Created on: 1996-02-14 |
2 | -- Created by: Joelle CHAUVET |
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 | -- Modified: Wed Jan 15 09:45:42 1997 |
18 | -- by: Joelle CHAUVET |
19 | -- G1135 : Constructor with criterion |
20 | -- G1135 : Private methods 'Init','InitGrid','Perform','ConvertBS', |
21 | -- 'ComputePatches','ComputeConstraints', |
22 | -- Compute3DErrors','ComputeCritError' |
23 | -- G1135 : Fields 'myConditions','myResults','myConstraints', |
24 | -- G1134 : Option 0 for myPrecisionCode |
7fd59977 |
25 | |
26 | class ApproxAFunc2Var from AdvApp2Var |
27 | |
28 | ---Purpose: Perform the approximation of <Func> F(U,V) |
29 | -- Arguments are : |
30 | -- Num1DSS, Num2DSS, Num3DSS :The numbers of 1,2,3 dimensional subspaces |
31 | -- OneDTol, TwoDTol, ThreeDTol: The tolerance of approximation in each |
32 | -- subspaces |
33 | -- OneDTolFr, TwoDTolFr, ThreeDTolFr: The tolerance of approximation on |
34 | -- the boundarys in each subspaces |
35 | -- [FirstInU, LastInU]: The Bounds in U of the Approximation |
36 | -- [FirstInV, LastInV]: The Bounds in V of the Approximation |
37 | -- FavorIso : Give preference to extract u-iso or v-iso on F(U,V) |
38 | -- This can be usefull to optimize the <Func> methode |
39 | -- ContInU, ContInV : Continuity waiting in u and v |
40 | -- PrecisCode : Precision on approximation's error mesurement |
41 | -- 1 : Fast computation and average precision |
42 | -- 2 : Average computation and good precision |
43 | -- 3 : Slow computation and very good precision |
44 | -- MaxDegInU : Maximum u-degree waiting in U |
45 | -- MaxDegInV : Maximum u-degree waiting in V |
46 | -- Warning: |
47 | -- MaxDegInU (resp. MaxDegInV) must be >= 2*iu (resp. iv) + 1, |
48 | -- where iu (resp. iv) = 0 if ContInU (resp. ContInV) = GeomAbs_C0, |
49 | -- = 1 if = GeomAbs_C1, |
50 | -- = 2 if = GeomAbs_C2. |
51 | -- MaxPatch : Maximun number of Patch waiting |
52 | -- number of Patch is number of u span * number of v span |
53 | -- Func : The external method to evaluate F(U,V) |
54 | -- Crit : To (re)defined condition of convergence |
55 | -- UChoice, VChoice : To define the way in U (or V) Knot insertion |
56 | -- Warning: |
57 | -- for the moment, the result is a 3D Surface |
58 | -- so Num1DSS and Num2DSS must be equals to 0 |
59 | -- and Num3DSS must be equal to 1. |
60 | -- Warning: |
61 | -- the Function of type EvaluatorFunc2Var from Approx |
41194117 |
62 | -- must be a subclass of AdvApp2Var_EvaluatorFunc2Var |
7fd59977 |
63 | -- |
64 | -- the result should be formatted in the following way : |
65 | -- <--Num1DSS--> <--2 * Num2DSS--> <--3 * Num3DSS--> |
66 | -- R[0,0] .... R[Num1DSS,0]..... R[Dimension-1,0] for the 1st parameter |
67 | -- R[0,i] .... R[Num1DSS,i]..... R[Dimension-1,i] for the ith parameter |
68 | -- R[0,N-1] .... R[Num1DSS,N-1].... R[Dimension-1,N-1] for the Nth parameter |
69 | -- |
70 | -- the order in which each Subspace appears should be consistent |
71 | -- with the tolerances given in the create function and the |
72 | -- results will be given in that order as well that is : |
73 | -- Surface(n) will correspond to the nth entry described by Num3DSS |
74 | |
75 | uses Array1OfInteger from TColStd, |
76 | HArray1OfInteger from TColStd, |
77 | Array1OfReal from TColStd, |
78 | Array1OfPnt2d from TColgp, |
79 | Array1OfPnt from TColgp, |
80 | HArray1OfReal from TColStd, |
81 | HArray1OfPnt2d from TColgp, |
82 | HArray1OfPnt from TColgp, |
83 | HArray2OfInteger from TColStd, |
84 | HArray2OfReal from TColStd, |
85 | HArray2OfPnt2d from TColgp, |
86 | HArray2OfPnt from TColgp, |
87 | HArray1OfSurface from TColGeom, |
88 | BSplineSurface from Geom, |
89 | Pnt from gp, |
90 | Pnt2d from gp, |
91 | Shape from GeomAbs, |
92 | IsoType from GeomAbs, |
93 | EvaluatorFunc2Var from AdvApp2Var, |
94 | Criterion from AdvApp2Var, |
95 | Context from AdvApp2Var, |
96 | Network from AdvApp2Var, |
97 | Framework from AdvApp2Var, |
98 | Cutting from AdvApprox |
99 | |
100 | |
101 | raises |
102 | |
103 | OutOfRange from Standard, |
104 | ConstructionError from Standard |
105 | |
106 | is |
107 | Create(Num1DSS : Integer ; |
108 | Num2DSS : Integer ; |
109 | Num3DSS : Integer ; |
110 | OneDTol : HArray1OfReal from TColStd ; |
111 | TwoDTol : HArray1OfReal from TColStd ; |
112 | ThreeDTol : HArray1OfReal from TColStd ; |
113 | OneDTolFr : HArray2OfReal from TColStd ; |
114 | TwoDTolFr : HArray2OfReal from TColStd ; |
115 | ThreeDTolFr: HArray2OfReal from TColStd ; |
116 | FirstInU : Real ; |
117 | LastInU : Real ; |
118 | FirstInV : Real ; |
119 | LastInV : Real ; |
120 | FavorIso : IsoType from GeomAbs ; |
121 | ContInU : Shape from GeomAbs ; |
122 | ContInV : Shape from GeomAbs ; |
123 | PrecisCode : Integer ; |
124 | MaxDegInU : Integer ; |
125 | MaxDegInV : Integer ; |
126 | MaxPatch : Integer ; |
127 | Func : EvaluatorFunc2Var from AdvApp2Var; |
128 | UChoice : in out Cutting from AdvApprox; |
129 | VChoice : in out Cutting from AdvApprox) |
130 | returns ApproxAFunc2Var from AdvApp2Var |
131 | raises ConstructionError; |
132 | |
133 | Create(Num1DSS : Integer ; |
134 | Num2DSS : Integer ; |
135 | Num3DSS : Integer ; |
136 | OneDTol : HArray1OfReal from TColStd ; |
137 | TwoDTol : HArray1OfReal from TColStd ; |
138 | ThreeDTol : HArray1OfReal from TColStd ; |
139 | OneDTolFr : HArray2OfReal from TColStd ; |
140 | TwoDTolFr : HArray2OfReal from TColStd ; |
141 | ThreeDTolFr: HArray2OfReal from TColStd ; |
142 | FirstInU : Real ; |
143 | LastInU : Real ; |
144 | FirstInV : Real ; |
145 | LastInV : Real ; |
146 | FavorIso : IsoType from GeomAbs ; |
147 | ContInU : Shape from GeomAbs ; |
148 | ContInV : Shape from GeomAbs ; |
149 | PrecisCode : Integer ; |
150 | MaxDegInU : Integer ; |
151 | MaxDegInV : Integer ; |
152 | MaxPatch : Integer ; |
153 | Func : EvaluatorFunc2Var from AdvApp2Var; |
154 | Crit : Criterion from AdvApp2Var; |
155 | UChoice : in out Cutting from AdvApprox; |
156 | VChoice : in out Cutting from AdvApprox) |
157 | returns ApproxAFunc2Var from AdvApp2Var |
158 | raises ConstructionError; |
159 | |
160 | |
161 | |
162 | Init(me : in out) |
163 | is private; |
164 | ---Purpose: Initialisation of the approximation ; used by Create |
165 | |
166 | InitGrid(me : in out; NbInt : Integer) |
167 | is private; |
168 | ---Purpose: Initialisation of the approximation with a grid of regular cuttings ; |
169 | -- used by Init and Perform |
170 | |
171 | Perform(me : in out; UChoice, VChoice : Cutting from AdvApprox; |
172 | Func : EvaluatorFunc2Var from AdvApp2Var) |
173 | is private; |
174 | ---Purpose: Computation of the approximation result ; used by Create |
175 | |
176 | |
177 | Perform(me : in out; UChoice, VChoice : Cutting from AdvApprox; |
178 | Func : EvaluatorFunc2Var from AdvApp2Var; |
179 | Crit : Criterion from AdvApp2Var) |
180 | is private; |
181 | ---Purpose: Computation of the approximation result ; used by Create |
182 | |
183 | |
184 | ComputePatches(me : in out; UChoice, VChoice : Cutting from AdvApprox; |
185 | Func : EvaluatorFunc2Var from AdvApp2Var) |
186 | is private; |
187 | ---Purpose: Computation of the polynomial approximations ; used by Perform |
188 | |
189 | |
190 | ComputePatches(me : in out; UChoice, VChoice : Cutting from AdvApprox; |
191 | Func : EvaluatorFunc2Var from AdvApp2Var; |
192 | Crit : Criterion from AdvApp2Var) |
193 | is private; |
194 | ---Purpose: Computation of the polynomial approximations ; used by Perform |
195 | |
196 | |
197 | ComputeConstraints(me : in out; UChoice, VChoice : Cutting from AdvApprox; |
198 | Func : EvaluatorFunc2Var from AdvApp2Var) |
199 | is private; |
200 | ---Purpose: Approximation of the constraints ; used by ComputePatches |
201 | |
202 | ComputeConstraints(me : in out; UChoice, VChoice : Cutting from AdvApprox; |
203 | Func : EvaluatorFunc2Var from AdvApp2Var; |
204 | Crit : Criterion from AdvApp2Var) |
205 | is private; |
206 | ---Purpose: Approximation of the constraints ; used by ComputePatches |
207 | |
208 | |
209 | Compute3DErrors(me : in out) |
210 | is private; |
211 | ---Purpose: Computation of the 3D errors on the approximation result ; used by Perform |
212 | |
213 | ComputeCritError(me : in out) |
214 | is private; |
215 | ---Purpose: Computation of the max value of the criterion on the approximation result ; |
216 | -- used by Perform |
217 | |
218 | ConvertBS(me : in out) |
219 | is private; |
220 | ---Purpose: Conversion of the approximation result in BSpline; used by Create |
221 | |
222 | |
223 | IsDone(me) |
224 | ---C++: inline |
225 | returns Boolean; |
226 | ---Purpose: True if the approximation succeeded within the imposed |
227 | -- tolerances and the wished continuities |
228 | -- |
229 | |
230 | HasResult(me) |
231 | ---C++: inline |
232 | returns Boolean; |
233 | ---Purpose: True if the approximation did come out with a result that |
234 | -- is not NECESSARELY within the required tolerance or a result |
235 | -- that is not recognized with the wished continuities |
236 | -- |
237 | |
238 | Surface (me; Index : Integer) |
239 | ---Purpose: returns the BSplineSurface of range Index |
240 | ---Warning: |
241 | -- Index must be equal to 1. |
242 | ---C++: inline |
243 | returns BSplineSurface from Geom; |
244 | |
245 | |
246 | UDegree(me) returns Integer ; |
247 | ---C++: inline |
248 | |
249 | VDegree(me) returns Integer ; |
250 | ---C++: inline |
251 | |
252 | |
253 | |
254 | NumSubSpaces(me; Dimension : Integer) returns Integer; |
255 | ---C++: inline |
256 | ---Warning: |
257 | -- Dimension must be equal to 1, 2 or 3. |
258 | |
259 | |
260 | |
261 | |
262 | MaxError (me; Dimension : Integer) returns HArray1OfReal from TColStd ; |
263 | ---Purpose: returns the errors max |
264 | ---Warning: |
265 | -- Dimension must be equal to 3. |
266 | |
267 | AverageError(me; Dimension : Integer) returns HArray1OfReal from TColStd ; |
268 | ---Purpose: returns the average errors |
269 | ---Warning: |
270 | -- Dimension must be equal to 3. |
271 | |
272 | UFrontError(me; Dimension : Integer) returns HArray1OfReal from TColStd ; |
273 | ---Purpose: returns the errors max on UFrontiers |
274 | -- Warning: |
275 | -- Dimension must be equal to 3. |
276 | |
277 | VFrontError(me; Dimension : Integer) returns HArray1OfReal from TColStd ; |
278 | ---Purpose: returns the errors max on VFrontiers |
279 | -- Warning: |
280 | -- Dimension must be equal to 3. |
281 | |
282 | |
283 | MaxError (me; Dimension : Integer ; Index : Integer) returns Real ; |
284 | ---Purpose: returns the error max of the BSplineSurface of range Index |
285 | ---Warning: |
286 | -- Dimension must be equal to 3, Index must be equal to 1. |
287 | |
288 | AverageError(me; Dimension : Integer; Index : Integer) returns Real ; |
289 | ---Purpose: returns the average error of the BSplineSurface of range Index |
290 | ---Warning: |
291 | -- Dimension must be equal to 3, Index must be equal to 1. |
292 | |
293 | UFrontError(me; Dimension : Integer; Index : Integer) returns Real ; |
294 | ---Purpose: returns the error max of the BSplineSurface of range Index on a UFrontier |
295 | ---Warning: |
296 | -- Dimension must be equal to 3, Index must be equal to 1. |
297 | |
298 | VFrontError(me; Dimension : Integer; Index : Integer) returns Real ; |
299 | ---Purpose: returns the error max of the BSplineSurface of range Index on a VFrontier |
300 | ---Warning: |
301 | -- Dimension must be equal to 3, Index must be equal to 1. |
302 | |
303 | CritError(me; Dimension : Integer; Index : Integer) returns Real ; |
304 | -- Computation of the max value of the criterion on the BSplineSurface of range Index |
305 | ---Warning: |
306 | -- Dimension must be equal to 3, Index must be equal to 1. |
307 | |
308 | Dump(me ; o : in out OStream); |
309 | ---Purpose: Prints on the stream o informations on the current state |
310 | -- of the object. |
311 | -- |
312 | |
313 | fields |
314 | -- |
315 | -- Input fields |
316 | -- |
317 | myNumSubSpaces : Integer[3] ; |
318 | -- Number of subspaces [0] = number of 1 dimensional subspaces |
319 | -- [1] = number of 2 dimensional subspaces |
320 | -- [2] = number of 3 dimensional subspaces |
321 | ---Warning: |
322 | -- for the moment, the result is a 3D Surface so |
323 | -- myNumSubSpaces[0] = Num1DSS = 0, |
324 | -- myNumSubSpaces[1] = Num2DSS = 0, |
325 | -- myNumSubSpaces[2] = Num3DSS = 1. |
326 | -- |
327 | |
328 | my1DTolerances : HArray1OfReal from TColStd ; |
329 | -- unused for the moment |
330 | my2DTolerances : HArray1OfReal from TColStd ; |
331 | -- unused for the moment |
332 | |
333 | my3DTolerances : HArray1OfReal from TColStd ; |
334 | -- one tolerance per subspace |
335 | |
336 | my1DTolOnFront : HArray2OfReal from TColStd ; |
337 | -- unused for the moment |
338 | my2DTolOnFront : HArray2OfReal from TColStd ; |
339 | -- unused for the moment |
340 | |
341 | my3DTolOnFront : HArray2OfReal from TColStd ; |
342 | -- 4 tolerances per subspace, |
343 | -- one for each frontier U=U0, U=U1, V=V0, V=V1 |
344 | |
345 | myFirstParInU : Real ; |
346 | -- U0 : first U parameter for the approximation |
347 | myLastParInU : Real ; |
348 | -- U1 : last U parameter for the approximation |
349 | myFirstParInV : Real ; |
350 | -- V0 : first V parameter for the approximation |
351 | myLastParInV : Real ; |
352 | -- V1 : last V parameter for the approximation |
353 | -- |
354 | -- |
355 | myFavoriteIso : IsoType from GeomAbs ; |
356 | myContInU : Shape from GeomAbs ; |
357 | myContInV : Shape from GeomAbs ; |
358 | -- continuity requested for the approximation |
359 | ---Warning: |
360 | -- The evaluator of the function to approximate must |
361 | -- provide the derivatives up to the requested order |
362 | -- |
363 | myPrecisionCode : Integer ; |
364 | myMaxDegInU : Integer ; |
365 | -- maximum U-degree for the approximation |
366 | myMaxDegInV : Integer ; |
367 | -- maximum V-degree for the approximation |
368 | ---Warning: |
369 | -- Because of the unstable evaluation after degree 14 |
370 | -- there are limited to 14 |
371 | myMaxPatches : Integer ; |
372 | -- maximum of patches allowed |
373 | -- |
7fd59977 |
374 | -- |
375 | myConditions : Context from AdvApp2Var; |
376 | myResult : Network from AdvApp2Var; |
377 | myConstraints : Framework from AdvApp2Var; |
378 | -- |
379 | -- |
380 | -- Output fields |
381 | -- |
382 | myDone : Boolean ; |
383 | -- tells if the approximation succeeded within the requested |
384 | -- tolerances and continuities. |
385 | -- |
386 | myHasResult : Boolean ; |
387 | -- tells if the approximation returned a result although |
388 | -- it might not be within the requested tolerances or |
389 | -- the BSpline result surface has not the wished continuities. |
390 | -- In those cases myDone will be false. |
391 | -- |
392 | -- |
393 | mySurfaces : HArray1OfSurface from TColGeom; |
394 | -- one surface per subspace |
395 | -- |
396 | myDegreeInU : Integer ; |
397 | myDegreeInV : Integer ; |
398 | -- |
399 | -- The Errors |
400 | -- 1DErrors and 2DErrors are unused for the moment |
401 | -- |
402 | my1DMaxError : HArray1OfReal from TColStd ; |
403 | my1DAverageError : HArray1OfReal from TColStd ; |
404 | my1DUFrontError : HArray1OfReal from TColStd ; |
405 | my1DVFrontError : HArray1OfReal from TColStd ; |
406 | |
407 | my2DMaxError : HArray1OfReal from TColStd ; |
408 | my2DAverageError : HArray1OfReal from TColStd ; |
409 | my2DUFrontError : HArray1OfReal from TColStd ; |
410 | my2DVFrontError : HArray1OfReal from TColStd ; |
411 | |
412 | -- each array contains one error |
413 | my3DMaxError : HArray1OfReal from TColStd ; |
414 | my3DAverageError : HArray1OfReal from TColStd ; |
415 | my3DUFrontError : HArray1OfReal from TColStd ; |
416 | my3DVFrontError : HArray1OfReal from TColStd ; |
417 | |
418 | myCriterionError : Real from Standard ; |
419 | |
420 | end ApproxAFunc2Var ; |
421 | |
422 | |
423 | |
424 | |
425 | |
426 | |