1 -- Created on: 1996-02-14
2 -- Created by: Joelle CHAUVET
3 -- Copyright (c) 1996-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
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.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 -- Modified: Wed Jan 15 09:45:42 1997
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
26 class ApproxAFunc2Var from AdvApp2Var
28 ---Purpose: Perform the approximation of <Func> F(U,V)
30 -- Num1DSS, Num2DSS, Num3DSS :The numbers of 1,2,3 dimensional subspaces
31 -- OneDTol, TwoDTol, ThreeDTol: The tolerance of approximation in each
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
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
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.
61 -- the Function of type EvaluatorFunc2Var from Approx
62 -- must be a subclass of AdvApp2Var_EvaluatorFunc2Var
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
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
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,
93 EvaluatorFunc2Var from AdvApp2Var,
94 Criterion from AdvApp2Var,
95 Context from AdvApp2Var,
96 Network from AdvApp2Var,
97 Framework from AdvApp2Var,
98 Cutting from AdvApprox
103 OutOfRange from Standard,
104 ConstructionError from Standard
107 Create(Num1DSS : 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 ;
120 FavorIso : IsoType from GeomAbs ;
121 ContInU : Shape from GeomAbs ;
122 ContInV : Shape from GeomAbs ;
123 PrecisCode : Integer ;
124 MaxDegInU : Integer ;
125 MaxDegInV : 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;
133 Create(Num1DSS : 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 ;
146 FavorIso : IsoType from GeomAbs ;
147 ContInU : Shape from GeomAbs ;
148 ContInV : Shape from GeomAbs ;
149 PrecisCode : Integer ;
150 MaxDegInU : Integer ;
151 MaxDegInV : 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;
164 ---Purpose: Initialisation of the approximation ; used by Create
166 InitGrid(me : in out; NbInt : Integer)
168 ---Purpose: Initialisation of the approximation with a grid of regular cuttings ;
169 -- used by Init and Perform
171 Perform(me : in out; UChoice, VChoice : Cutting from AdvApprox;
172 Func : EvaluatorFunc2Var from AdvApp2Var)
174 ---Purpose: Computation of the approximation result ; used by Create
177 Perform(me : in out; UChoice, VChoice : Cutting from AdvApprox;
178 Func : EvaluatorFunc2Var from AdvApp2Var;
179 Crit : Criterion from AdvApp2Var)
181 ---Purpose: Computation of the approximation result ; used by Create
184 ComputePatches(me : in out; UChoice, VChoice : Cutting from AdvApprox;
185 Func : EvaluatorFunc2Var from AdvApp2Var)
187 ---Purpose: Computation of the polynomial approximations ; used by Perform
190 ComputePatches(me : in out; UChoice, VChoice : Cutting from AdvApprox;
191 Func : EvaluatorFunc2Var from AdvApp2Var;
192 Crit : Criterion from AdvApp2Var)
194 ---Purpose: Computation of the polynomial approximations ; used by Perform
197 ComputeConstraints(me : in out; UChoice, VChoice : Cutting from AdvApprox;
198 Func : EvaluatorFunc2Var from AdvApp2Var)
200 ---Purpose: Approximation of the constraints ; used by ComputePatches
202 ComputeConstraints(me : in out; UChoice, VChoice : Cutting from AdvApprox;
203 Func : EvaluatorFunc2Var from AdvApp2Var;
204 Crit : Criterion from AdvApp2Var)
206 ---Purpose: Approximation of the constraints ; used by ComputePatches
209 Compute3DErrors(me : in out)
211 ---Purpose: Computation of the 3D errors on the approximation result ; used by Perform
213 ComputeCritError(me : in out)
215 ---Purpose: Computation of the max value of the criterion on the approximation result ;
218 ConvertBS(me : in out)
220 ---Purpose: Conversion of the approximation result in BSpline; used by Create
226 ---Purpose: True if the approximation succeeded within the imposed
227 -- tolerances and the wished continuities
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
238 Surface (me; Index : Integer)
239 ---Purpose: returns the BSplineSurface of range Index
241 -- Index must be equal to 1.
243 returns BSplineSurface from Geom;
246 UDegree(me) returns Integer ;
249 VDegree(me) returns Integer ;
254 NumSubSpaces(me; Dimension : Integer) returns Integer;
257 -- Dimension must be equal to 1, 2 or 3.
262 MaxError (me; Dimension : Integer) returns HArray1OfReal from TColStd ;
263 ---Purpose: returns the errors max
265 -- Dimension must be equal to 3.
267 AverageError(me; Dimension : Integer) returns HArray1OfReal from TColStd ;
268 ---Purpose: returns the average errors
270 -- Dimension must be equal to 3.
272 UFrontError(me; Dimension : Integer) returns HArray1OfReal from TColStd ;
273 ---Purpose: returns the errors max on UFrontiers
275 -- Dimension must be equal to 3.
277 VFrontError(me; Dimension : Integer) returns HArray1OfReal from TColStd ;
278 ---Purpose: returns the errors max on VFrontiers
280 -- Dimension must be equal to 3.
283 MaxError (me; Dimension : Integer ; Index : Integer) returns Real ;
284 ---Purpose: returns the error max of the BSplineSurface of range Index
286 -- Dimension must be equal to 3, Index must be equal to 1.
288 AverageError(me; Dimension : Integer; Index : Integer) returns Real ;
289 ---Purpose: returns the average error of the BSplineSurface of range Index
291 -- Dimension must be equal to 3, Index must be equal to 1.
293 UFrontError(me; Dimension : Integer; Index : Integer) returns Real ;
294 ---Purpose: returns the error max of the BSplineSurface of range Index on a UFrontier
296 -- Dimension must be equal to 3, Index must be equal to 1.
298 VFrontError(me; Dimension : Integer; Index : Integer) returns Real ;
299 ---Purpose: returns the error max of the BSplineSurface of range Index on a VFrontier
301 -- Dimension must be equal to 3, Index must be equal to 1.
303 CritError(me; Dimension : Integer; Index : Integer) returns Real ;
304 -- Computation of the max value of the criterion on the BSplineSurface of range Index
306 -- Dimension must be equal to 3, Index must be equal to 1.
308 Dump(me ; o : in out OStream);
309 ---Purpose: Prints on the stream o informations on the current state
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
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.
328 my1DTolerances : HArray1OfReal from TColStd ;
329 -- unused for the moment
330 my2DTolerances : HArray1OfReal from TColStd ;
331 -- unused for the moment
333 my3DTolerances : HArray1OfReal from TColStd ;
334 -- one tolerance per subspace
336 my1DTolOnFront : HArray2OfReal from TColStd ;
337 -- unused for the moment
338 my2DTolOnFront : HArray2OfReal from TColStd ;
339 -- unused for the moment
341 my3DTolOnFront : HArray2OfReal from TColStd ;
342 -- 4 tolerances per subspace,
343 -- one for each frontier U=U0, U=U1, V=V0, V=V1
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
355 myFavoriteIso : IsoType from GeomAbs ;
356 myContInU : Shape from GeomAbs ;
357 myContInV : Shape from GeomAbs ;
358 -- continuity requested for the approximation
360 -- The evaluator of the function to approximate must
361 -- provide the derivatives up to the requested order
363 myPrecisionCode : Integer ;
364 myMaxDegInU : Integer ;
365 -- maximum U-degree for the approximation
366 myMaxDegInV : Integer ;
367 -- maximum V-degree for the approximation
369 -- Because of the unstable evaluation after degree 14
370 -- there are limited to 14
371 myMaxPatches : Integer ;
372 -- maximum of patches allowed
375 myConditions : Context from AdvApp2Var;
376 myResult : Network from AdvApp2Var;
377 myConstraints : Framework from AdvApp2Var;
383 -- tells if the approximation succeeded within the requested
384 -- tolerances and continuities.
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.
393 mySurfaces : HArray1OfSurface from TColGeom;
394 -- one surface per subspace
396 myDegreeInU : Integer ;
397 myDegreeInV : Integer ;
400 -- 1DErrors and 2DErrors are unused for the moment
402 my1DMaxError : HArray1OfReal from TColStd ;
403 my1DAverageError : HArray1OfReal from TColStd ;
404 my1DUFrontError : HArray1OfReal from TColStd ;
405 my1DVFrontError : HArray1OfReal from TColStd ;
407 my2DMaxError : HArray1OfReal from TColStd ;
408 my2DAverageError : HArray1OfReal from TColStd ;
409 my2DUFrontError : HArray1OfReal from TColStd ;
410 my2DVFrontError : HArray1OfReal from TColStd ;
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 ;
418 myCriterionError : Real from Standard ;
420 end ApproxAFunc2Var ;