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