Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1996-07-03 |
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. | |
7fd59977 | 16 | |
17 | #include <AdvApp2Var_ApproxAFunc2Var.hxx> | |
18 | #include <AdvApp2Var_EvaluatorFunc2Var.hxx> | |
19 | #include <AdvApp2Var_Criterion.hxx> | |
20 | #include <AdvApp2Var_Context.hxx> | |
21 | #include <AdvApp2Var_Patch.hxx> | |
22 | #include <AdvApp2Var_Network.hxx> | |
23 | #include <AdvApp2Var_Node.hxx> | |
24 | #include <AdvApp2Var_Iso.hxx> | |
25 | #include <AdvApp2Var_Strip.hxx> | |
26 | #include <AdvApp2Var_Framework.hxx> | |
27 | #include <AdvApprox_Cutting.hxx> | |
28 | ||
29 | #include <Standard_ConstructionError.hxx> | |
30 | #include <Standard_OutOfRange.hxx> | |
31 | #include <TColStd_HArray1OfInteger.hxx> | |
32 | #include <TColStd_HArray2OfInteger.hxx> | |
33 | #include <TColStd_HArray1OfReal.hxx> | |
34 | #include <TColStd_HArray2OfReal.hxx> | |
35 | ||
36 | #include <gp_XY.hxx> | |
37 | #include <gp_Pnt2d.hxx> | |
38 | #include <gp_Pnt.hxx> | |
39 | #include <TColgp_HArray2OfPnt.hxx> | |
40 | ||
41 | #include <Convert_GridPolynomialToPoles.hxx> | |
42 | ||
43 | #include <Geom_BezierSurface.hxx> | |
ec357c5c | 44 | #include <Geom_BSplineSurface.hxx> |
7fd59977 | 45 | |
46 | ||
47 | //======================================================================= | |
48 | //function : AdvApp2Var_ApproxAFunc2Var | |
49 | //purpose : | |
50 | //======================================================================= | |
51 | ||
cbff1e55 | 52 | AdvApp2Var_ApproxAFunc2Var::AdvApp2Var_ApproxAFunc2Var( |
53 | const Standard_Integer Num1DSS, | |
54 | const Standard_Integer Num2DSS, | |
55 | const Standard_Integer Num3DSS, | |
56 | const Handle(TColStd_HArray1OfReal)& OneDTol, | |
57 | const Handle(TColStd_HArray1OfReal)& TwoDTol, | |
58 | const Handle(TColStd_HArray1OfReal)& ThreeDTol, | |
59 | const Handle(TColStd_HArray2OfReal)& OneDTolFr, | |
60 | const Handle(TColStd_HArray2OfReal)& TwoDTolFr, | |
61 | const Handle(TColStd_HArray2OfReal)& ThreeDTolFr, | |
62 | const Standard_Real FirstInU, | |
63 | const Standard_Real LastInU, | |
64 | const Standard_Real FirstInV, | |
65 | const Standard_Real LastInV, | |
66 | const GeomAbs_IsoType FavorIso, | |
67 | const GeomAbs_Shape ContInU, | |
68 | const GeomAbs_Shape ContInV, | |
69 | const Standard_Integer PrecisCode, | |
70 | const Standard_Integer MaxDegInU, | |
71 | const Standard_Integer MaxDegInV, | |
72 | const Standard_Integer MaxPatch, | |
73 | const AdvApp2Var_EvaluatorFunc2Var& Func, | |
74 | AdvApprox_Cutting& UChoice, | |
75 | AdvApprox_Cutting& VChoice) | |
76 | : my1DTolerances (OneDTol), | |
77 | my2DTolerances (TwoDTol), | |
78 | my3DTolerances (ThreeDTol), | |
79 | my1DTolOnFront (OneDTolFr), | |
80 | my2DTolOnFront (TwoDTolFr), | |
81 | my3DTolOnFront (ThreeDTolFr), | |
82 | myFirstParInU (FirstInU), | |
83 | myLastParInU (LastInU), | |
84 | myFirstParInV (FirstInV), | |
85 | myLastParInV (LastInV), | |
86 | myFavoriteIso (FavorIso), | |
87 | myContInU (ContInU), | |
88 | myContInV (ContInV), | |
89 | myPrecisionCode (PrecisCode), | |
90 | myMaxDegInU (MaxDegInU), | |
91 | myMaxDegInV (MaxDegInV), | |
92 | myMaxPatches (MaxPatch), | |
93 | myDone (Standard_False), | |
94 | myHasResult (Standard_False), | |
95 | myDegreeInU (0), | |
96 | myDegreeInV (0), | |
97 | myCriterionError(0.0) | |
7fd59977 | 98 | { |
99 | myNumSubSpaces[0] = Num1DSS; | |
100 | myNumSubSpaces[1] = Num2DSS; | |
101 | myNumSubSpaces[2] = Num3DSS; | |
cbff1e55 | 102 | |
7fd59977 | 103 | Init(); |
41194117 | 104 | Perform(UChoice, VChoice, Func); |
7fd59977 | 105 | ConvertBS(); |
106 | } | |
107 | ||
108 | //======================================================================= | |
109 | //function : AdvApp2Var_ApproxAFunc2Var | |
110 | //purpose : | |
111 | //======================================================================= | |
112 | ||
cbff1e55 | 113 | AdvApp2Var_ApproxAFunc2Var::AdvApp2Var_ApproxAFunc2Var( |
114 | const Standard_Integer Num1DSS, | |
115 | const Standard_Integer Num2DSS, | |
116 | const Standard_Integer Num3DSS, | |
117 | const Handle(TColStd_HArray1OfReal)& OneDTol, | |
118 | const Handle(TColStd_HArray1OfReal)& TwoDTol, | |
119 | const Handle(TColStd_HArray1OfReal)& ThreeDTol, | |
120 | const Handle(TColStd_HArray2OfReal)& OneDTolFr, | |
121 | const Handle(TColStd_HArray2OfReal)& TwoDTolFr, | |
122 | const Handle(TColStd_HArray2OfReal)& ThreeDTolFr, | |
123 | const Standard_Real FirstInU, | |
124 | const Standard_Real LastInU, | |
125 | const Standard_Real FirstInV, | |
126 | const Standard_Real LastInV, | |
127 | const GeomAbs_IsoType FavorIso, | |
128 | const GeomAbs_Shape ContInU, | |
129 | const GeomAbs_Shape ContInV, | |
130 | const Standard_Integer PrecisCode, | |
131 | const Standard_Integer MaxDegInU, | |
132 | const Standard_Integer MaxDegInV, | |
133 | const Standard_Integer MaxPatch, | |
134 | const AdvApp2Var_EvaluatorFunc2Var& Func, | |
135 | const AdvApp2Var_Criterion& Crit, | |
136 | AdvApprox_Cutting& UChoice, | |
137 | AdvApprox_Cutting& VChoice) | |
138 | : my1DTolerances (OneDTol), | |
139 | my2DTolerances (TwoDTol), | |
140 | my3DTolerances (ThreeDTol), | |
141 | my1DTolOnFront (OneDTolFr), | |
142 | my2DTolOnFront (TwoDTolFr), | |
143 | my3DTolOnFront (ThreeDTolFr), | |
144 | myFirstParInU (FirstInU), | |
145 | myLastParInU (LastInU), | |
146 | myFirstParInV (FirstInV), | |
147 | myLastParInV (LastInV), | |
148 | myFavoriteIso (FavorIso), | |
149 | myContInU (ContInU), | |
150 | myContInV (ContInV), | |
151 | myPrecisionCode (PrecisCode), | |
152 | myMaxDegInU (MaxDegInU), | |
153 | myMaxDegInV (MaxDegInV), | |
154 | myMaxPatches (MaxPatch), | |
155 | myDone (Standard_False), | |
156 | myHasResult (Standard_False), | |
157 | myDegreeInU (0), | |
158 | myDegreeInV (0), | |
159 | myCriterionError(0.0) | |
7fd59977 | 160 | { |
161 | myNumSubSpaces[0] = Num1DSS; | |
162 | myNumSubSpaces[1] = Num2DSS; | |
163 | myNumSubSpaces[2] = Num3DSS; | |
cbff1e55 | 164 | |
7fd59977 | 165 | Init(); |
41194117 | 166 | Perform(UChoice, VChoice, Func, Crit); |
7fd59977 | 167 | ConvertBS(); |
168 | } | |
169 | ||
170 | //======================================================================= | |
171 | //function : Init | |
172 | //purpose : Initialisation of the approximation | |
173 | //======================================================================= | |
174 | ||
175 | void AdvApp2Var_ApproxAFunc2Var::Init() | |
176 | { | |
177 | Standard_Integer ifav,iu=0,iv=0,ndu,ndv; | |
178 | switch (myFavoriteIso) { | |
179 | case GeomAbs_IsoU : | |
180 | ifav = 1; | |
181 | break; | |
182 | case GeomAbs_IsoV : | |
183 | ifav = 2; | |
184 | break; | |
185 | default : | |
186 | ifav = 2; | |
187 | break; | |
188 | } | |
189 | switch (myContInU) { | |
190 | case GeomAbs_C0 : | |
191 | iu = 0; | |
192 | break; | |
193 | case GeomAbs_C1 : | |
194 | iu = 1; | |
195 | break; | |
196 | case GeomAbs_C2 : | |
197 | iu = 2; | |
198 | break; | |
199 | default : | |
200 | Standard_ConstructionError::Raise("AdvApp2Var_ApproxAFunc2Var : UContinuity Error"); | |
201 | } | |
202 | switch (myContInV) { | |
203 | case GeomAbs_C0 : | |
204 | iv = 0; | |
205 | break; | |
206 | case GeomAbs_C1 : | |
207 | iv = 1; | |
208 | break; | |
209 | case GeomAbs_C2 : | |
210 | iv = 2; | |
211 | break; | |
212 | default : | |
213 | Standard_ConstructionError::Raise("AdvApp2Var_ApproxAFunc2Var : VContinuity Error"); | |
214 | } | |
215 | ndu = Max(myMaxDegInU+1,2*iu+2); | |
216 | ndv = Max(myMaxDegInV+1,2*iv+2); | |
217 | if (ndu<2*iu+2) | |
218 | Standard_ConstructionError::Raise("AdvApp2Var_ApproxAFunc2Var : UMaxDegree Error"); | |
219 | if (ndv<2*iv+2) | |
220 | Standard_ConstructionError::Raise("AdvApp2Var_ApproxAFunc2Var : VMaxDegree Error"); | |
221 | myPrecisionCode = Max(0,Min(myPrecisionCode,3)); | |
222 | AdvApp2Var_Context Conditions(ifav,iu,iv,ndu,ndv, | |
223 | myPrecisionCode, | |
224 | myNumSubSpaces[0], | |
225 | myNumSubSpaces[1], | |
226 | myNumSubSpaces[2], | |
227 | my1DTolerances, | |
228 | my2DTolerances, | |
229 | my3DTolerances, | |
230 | my1DTolOnFront, | |
231 | my2DTolOnFront, | |
232 | my3DTolOnFront); | |
233 | myConditions = Conditions; | |
234 | InitGrid(1); | |
235 | } | |
236 | ||
237 | ||
238 | //======================================================================= | |
239 | //function : InitGrid | |
240 | //purpose : Initialisation of the approximation with regular cuttings | |
241 | //======================================================================= | |
242 | ||
243 | void AdvApp2Var_ApproxAFunc2Var::InitGrid(const Standard_Integer NbInt) | |
244 | { | |
245 | Standard_Integer iu=myConditions.UOrder(),iv=myConditions.VOrder(),iint; | |
246 | ||
247 | AdvApp2Var_Patch M0(myFirstParInU,myLastParInU,myFirstParInV,myLastParInV,iu,iv); | |
248 | ||
249 | AdvApp2Var_SequenceOfPatch Net; | |
250 | Net.Append(M0); | |
251 | ||
252 | TColStd_SequenceOfReal TheU,TheV; | |
253 | TheU.Append(myFirstParInU); | |
254 | TheV.Append(myFirstParInV); | |
255 | TheU.Append(myLastParInU); | |
256 | TheV.Append(myLastParInV); | |
257 | ||
258 | AdvApp2Var_Network Result(Net,TheU,TheV); | |
259 | ||
260 | ||
261 | gp_XY UV1(myFirstParInU,myFirstParInV); | |
262 | AdvApp2Var_Node C1(UV1,iu,iv); | |
263 | gp_XY UV2(myLastParInU,myFirstParInV); | |
264 | AdvApp2Var_Node C2(UV2,iu,iv); | |
265 | gp_XY UV4(myLastParInU,myLastParInV); | |
266 | AdvApp2Var_Node C4(UV4,iu,iv); | |
267 | gp_XY UV3(myFirstParInU,myLastParInV); | |
268 | AdvApp2Var_Node C3(UV3,iu,iv); | |
269 | AdvApp2Var_SequenceOfNode Bag; | |
270 | Bag.Append(C1); | |
271 | Bag.Append(C2); | |
272 | Bag.Append(C3); | |
273 | Bag.Append(C4); | |
274 | ||
275 | AdvApp2Var_Iso V0(GeomAbs_IsoV,myFirstParInV, | |
276 | myFirstParInU,myLastParInU,myFirstParInV,myLastParInV, | |
277 | 1,iu,iv); | |
278 | AdvApp2Var_Iso V1(GeomAbs_IsoV,myLastParInV, | |
279 | myFirstParInU,myLastParInU,myFirstParInV,myLastParInV, | |
280 | 2,iu,iv); | |
281 | AdvApp2Var_Iso U0(GeomAbs_IsoU,myFirstParInU, | |
282 | myFirstParInU,myLastParInU,myFirstParInV,myLastParInV, | |
283 | 3,iu,iv); | |
284 | AdvApp2Var_Iso U1(GeomAbs_IsoU,myLastParInU, | |
285 | myFirstParInU,myLastParInU,myFirstParInV,myLastParInV, | |
286 | 4,iu,iv); | |
287 | ||
288 | AdvApp2Var_Strip BU0,BV0; | |
289 | BU0.Append(V0); | |
290 | BU0.Append(V1); | |
291 | BV0.Append(U0); | |
292 | BV0.Append(U1); | |
293 | ||
294 | AdvApp2Var_SequenceOfStrip UStrip,VStrip; | |
295 | UStrip.Append(BU0); | |
296 | VStrip.Append(BV0); | |
297 | ||
298 | AdvApp2Var_Framework Constraints(Bag,UStrip,VStrip); | |
299 | ||
0d969553 | 300 | // regular cutting if NbInt>1 |
7fd59977 | 301 | Standard_Real deltu = (myLastParInU-myFirstParInU)/NbInt, |
302 | deltv = (myLastParInV-myFirstParInV)/NbInt; | |
303 | for (iint=1;iint<=NbInt-1;iint++) { | |
304 | Result.UpdateInU(myFirstParInU+iint*deltu); | |
305 | Constraints.UpdateInU(myFirstParInU+iint*deltu); | |
306 | Result.UpdateInV(myFirstParInV+iint*deltv); | |
307 | Constraints.UpdateInV(myFirstParInV+iint*deltv); | |
308 | } | |
309 | myResult = Result; | |
310 | myConstraints = Constraints; | |
311 | } | |
312 | ||
313 | //======================================================================= | |
314 | //function : Perform | |
315 | //purpose : Computation of the approximation | |
316 | //======================================================================= | |
317 | ||
318 | void AdvApp2Var_ApproxAFunc2Var::Perform(const AdvApprox_Cutting& UChoice, | |
319 | const AdvApprox_Cutting& VChoice, | |
320 | const AdvApp2Var_EvaluatorFunc2Var& Func) | |
321 | { | |
322 | ComputePatches(UChoice,VChoice,Func); | |
323 | myHasResult = myDone = Standard_True; | |
324 | Compute3DErrors(); | |
325 | } | |
326 | ||
327 | //======================================================================= | |
328 | //function : Perform | |
329 | //purpose : Computation of the approximation | |
330 | //======================================================================= | |
331 | ||
332 | void AdvApp2Var_ApproxAFunc2Var::Perform(const AdvApprox_Cutting& UChoice, | |
333 | const AdvApprox_Cutting& VChoice, | |
334 | const AdvApp2Var_EvaluatorFunc2Var& Func, | |
335 | const AdvApp2Var_Criterion& Crit) | |
336 | { | |
337 | ComputePatches(UChoice,VChoice,Func,Crit); | |
338 | myHasResult = myDone = Standard_True; | |
339 | Compute3DErrors(); | |
340 | ComputeCritError(); | |
341 | } | |
342 | ||
343 | //======================================================================= | |
344 | //function : ComputePatches | |
345 | //purpose : Computation of the polynomial approximations | |
346 | //======================================================================= | |
347 | ||
348 | void AdvApp2Var_ApproxAFunc2Var::ComputePatches(const AdvApprox_Cutting& UChoice, | |
349 | const AdvApprox_Cutting& VChoice, | |
350 | const AdvApp2Var_EvaluatorFunc2Var& Func) | |
351 | { | |
352 | Standard_Real Udec, Vdec; | |
353 | Standard_Boolean Umore, Vmore; | |
354 | Standard_Integer NbPatch, NbU, NbV, NumDec; | |
355 | Standard_Integer FirstNA; | |
356 | ||
357 | while (myResult.FirstNotApprox(FirstNA)) { | |
358 | ||
0d969553 | 359 | // complete the set of constraints |
7fd59977 | 360 | ComputeConstraints(UChoice, VChoice, Func); |
361 | ||
0d969553 | 362 | // discretization of constraints relative to the square |
7fd59977 | 363 | myResult(FirstNA).Discretise(myConditions,myConstraints,Func); |
364 | if ( ! myResult(FirstNA).IsDiscretised() ) { | |
365 | myHasResult = myDone = Standard_False; | |
366 | Standard_ConstructionError::Raise | |
367 | ("AdvApp2Var_ApproxAFunc2Var : Surface Discretisation Error"); | |
368 | } | |
369 | ||
0d969553 Y |
370 | // calculate the number and the type of autorized cuts |
371 | // depending on the max number of squares and the validity of next cuts. | |
7fd59977 | 372 | NbU = myResult.NbPatchInU(); |
373 | NbV = myResult.NbPatchInV(); | |
374 | NbPatch = NbU*NbV; | |
375 | Umore = UChoice.Value(myResult(FirstNA).U0(), myResult(FirstNA).U1(),Udec); | |
376 | Vmore = VChoice.Value(myResult(FirstNA).V0(), myResult(FirstNA).V1(),Vdec); | |
377 | ||
378 | NumDec = 0; | |
379 | if ( ((NbPatch+NbV)<=myMaxPatches) && ((NbPatch+NbU)>myMaxPatches) | |
380 | && (Umore) ) NumDec = 1; | |
381 | if ( ((NbPatch+NbV)>myMaxPatches) && ((NbPatch+NbU)<=myMaxPatches) | |
382 | && (Vmore) ) NumDec = 2; | |
383 | if ( ((NbPatch+NbV)<=myMaxPatches) && ((NbPatch+NbU)<=myMaxPatches) ) { | |
384 | if ( Umore ) NumDec = 3; | |
385 | if ( (NbV>NbU) && Vmore ) NumDec = 4; | |
386 | } | |
387 | if ( (NbU+1)*(NbV+1)<=myMaxPatches ) { | |
388 | if ( !Umore && !Vmore ) NumDec=0; | |
389 | if ( Umore && !Vmore ) NumDec=3; | |
390 | if ( !Umore && Vmore ) NumDec=4; | |
391 | if ( Umore && Vmore ) NumDec=5; | |
392 | } | |
393 | ||
0d969553 | 394 | // approximation of the square |
7fd59977 | 395 | myResult(FirstNA).MakeApprox(myConditions,myConstraints,NumDec); |
396 | ||
397 | if ( ! myResult(FirstNA).IsApproximated() ) { | |
398 | switch (myResult(FirstNA).CutSense()) { | |
399 | case 0 : | |
0d969553 | 400 | // It is not possible to cut : the result is preserved |
7fd59977 | 401 | if ( myResult(FirstNA).HasResult()) { |
402 | myResult(FirstNA).OverwriteApprox(); | |
403 | } | |
404 | else { | |
405 | myHasResult = myDone = Standard_False; | |
406 | Standard_ConstructionError::Raise | |
407 | ("AdvApp2Var_ApproxAFunc2Var : Surface Approximation Error"); | |
408 | } | |
409 | break; | |
410 | case 1 : | |
0d969553 | 411 | // It is necessary to cut in U |
7fd59977 | 412 | myResult.UpdateInU(Udec); |
413 | myConstraints.UpdateInU(Udec); | |
414 | break; | |
415 | case 2 : | |
0d969553 | 416 | // It is necessary to cut in V |
7fd59977 | 417 | myResult.UpdateInV(Vdec); |
418 | myConstraints.UpdateInV(Vdec); | |
419 | break; | |
420 | case 3 : | |
0d969553 | 421 | // It is necesary to cut in U and V |
7fd59977 | 422 | myResult.UpdateInU(Udec); |
423 | myConstraints.UpdateInU(Udec); | |
424 | myResult.UpdateInV(Vdec); | |
425 | myConstraints.UpdateInV(Vdec); | |
426 | break; | |
427 | default : | |
428 | myHasResult = myDone = Standard_False; | |
429 | Standard_ConstructionError::Raise | |
430 | ("AdvApp2Var_ApproxAFunc2Var : Surface Approximation Error"); | |
431 | } | |
432 | } | |
433 | } | |
434 | } | |
435 | ||
436 | //======================================================================= | |
437 | //function : ComputePatches | |
438 | //purpose : Computation of the polynomial approximations | |
439 | //======================================================================= | |
440 | ||
441 | void AdvApp2Var_ApproxAFunc2Var::ComputePatches(const AdvApprox_Cutting& UChoice, | |
442 | const AdvApprox_Cutting& VChoice, | |
443 | const AdvApp2Var_EvaluatorFunc2Var& Func, | |
444 | const AdvApp2Var_Criterion& Crit) | |
445 | { | |
96a95605 | 446 | Standard_Real Udec, Vdec, CritValue, m1=0.; |
7fd59977 | 447 | Standard_Boolean Umore, Vmore, CritAbs = (Crit.Type() == AdvApp2Var_Absolute); |
448 | Standard_Integer NbPatch, NbU, NbV, NbInt, NumDec; | |
449 | Standard_Integer FirstNA, decision=0; | |
450 | ||
451 | while (myResult.FirstNotApprox(FirstNA)) { | |
452 | ||
0d969553 | 453 | // complete the set of constraints |
7fd59977 | 454 | ComputeConstraints(UChoice, VChoice, Func, Crit); |
455 | if (decision>0) { | |
7fd59977 | 456 | m1 = 0.; |
457 | } | |
458 | ||
0d969553 | 459 | // discretize the constraints relative to the square |
7fd59977 | 460 | myResult(FirstNA).Discretise(myConditions,myConstraints,Func); |
461 | if ( ! myResult(FirstNA).IsDiscretised() ) { | |
462 | myHasResult = myDone = Standard_False; | |
463 | Standard_ConstructionError::Raise | |
464 | ("AdvApp2Var_ApproxAFunc2Var : Surface Discretisation Error"); | |
465 | } | |
466 | ||
0d969553 Y |
467 | // calculate the number and type of autorized cuts |
468 | // depending on the max number of squares and the validity of next cuts | |
7fd59977 | 469 | NbU = myResult.NbPatchInU(); |
470 | NbV = myResult.NbPatchInV(); | |
471 | NbPatch = NbU*NbV; | |
472 | NbInt = NbU; | |
473 | Umore = UChoice.Value(myResult(FirstNA).U0(), myResult(FirstNA).U1(),Udec); | |
474 | Vmore = VChoice.Value(myResult(FirstNA).V0(), myResult(FirstNA).V1(),Vdec); | |
475 | ||
476 | NumDec = 0; | |
477 | if ( ((NbPatch+NbV)<=myMaxPatches) && ((NbPatch+NbU)>myMaxPatches) | |
478 | && (Umore) ) NumDec = 1; | |
479 | if ( ((NbPatch+NbV)>myMaxPatches) && ((NbPatch+NbU)<=myMaxPatches) | |
480 | && (Vmore) ) NumDec = 2; | |
481 | if ( ((NbPatch+NbV)<=myMaxPatches) && ((NbPatch+NbU)<=myMaxPatches) ) { | |
482 | if ( Umore ) NumDec = 3; | |
483 | if ( (NbV>NbU) && Vmore ) NumDec = 4; | |
484 | } | |
485 | if ( (NbU+1)*(NbV+1)<=myMaxPatches ) { | |
486 | if ( !Umore && !Vmore ) NumDec=0; | |
487 | if ( Umore && !Vmore ) NumDec=1; | |
488 | if ( !Umore && Vmore ) NumDec=2; | |
489 | if ( Umore && Vmore ) NumDec=5; | |
490 | } | |
491 | ||
0d969553 | 492 | // approximation of the square |
7fd59977 | 493 | if ( CritAbs ) { |
494 | myResult(FirstNA).MakeApprox(myConditions,myConstraints,0); | |
495 | } | |
496 | else { | |
497 | myResult(FirstNA).MakeApprox(myConditions,myConstraints,NumDec); | |
498 | } | |
499 | if (NumDec>=3) NumDec = NumDec - 2; | |
500 | ||
0d969553 | 501 | // evaluation of the criterion on the square |
7fd59977 | 502 | if ( myResult(FirstNA).HasResult() ) { |
503 | Crit.Value(myResult(FirstNA),myConditions); | |
504 | CritValue = myResult(FirstNA).CritValue(); | |
505 | if (m1<CritValue) m1 = CritValue; | |
506 | } | |
0d969553 | 507 | // is it necessary to cut ? |
7fd59977 | 508 | decision = myResult(FirstNA).CutSense(Crit,NumDec); |
509 | Standard_Boolean Regular = (Crit.Repartition() == AdvApp2Var_Regular); | |
510 | // Standard_Boolean Regular = Standard_True; | |
511 | if (Regular && decision>0) { | |
512 | NbInt++; | |
513 | InitGrid(NbInt); | |
514 | } | |
515 | else { | |
516 | switch (decision) { | |
517 | case 0 : | |
0d969553 | 518 | // Impossible to cut : the result is preserved |
7fd59977 | 519 | if ( myResult(FirstNA).HasResult() ) { |
520 | myResult(FirstNA).OverwriteApprox(); | |
521 | } | |
522 | else { | |
523 | myHasResult = myDone = Standard_False; | |
524 | Standard_ConstructionError::Raise | |
525 | ("AdvApp2Var_ApproxAFunc2Var : Surface Approximation Error"); | |
526 | } | |
527 | break; | |
528 | case 1 : | |
0d969553 | 529 | // It is necessary to cut in U |
7fd59977 | 530 | myResult.UpdateInU(Udec); |
531 | myConstraints.UpdateInU(Udec); | |
532 | break; | |
533 | case 2 : | |
0d969553 | 534 | // It is necessary to cut in V |
7fd59977 | 535 | myResult.UpdateInV(Vdec); |
536 | myConstraints.UpdateInV(Vdec); | |
537 | break; | |
538 | case 3 : | |
0d969553 | 539 | // It is necessary to cut in U and V |
7fd59977 | 540 | myResult.UpdateInU(Udec); |
541 | myConstraints.UpdateInU(Udec); | |
542 | myResult.UpdateInV(Vdec); | |
543 | myConstraints.UpdateInV(Vdec); | |
544 | break; | |
545 | default : | |
546 | myHasResult = myDone = Standard_False; | |
547 | Standard_ConstructionError::Raise | |
548 | ("AdvApp2Var_ApproxAFunc2Var : Surface Approximation Error"); | |
549 | } | |
550 | } | |
551 | } | |
552 | } | |
553 | ||
554 | //======================================================================= | |
555 | //function : ComputeConstraints without Criterion | |
556 | //purpose : Approximation of the constraints | |
557 | //======================================================================= | |
558 | ||
559 | void AdvApp2Var_ApproxAFunc2Var::ComputeConstraints(const AdvApprox_Cutting& UChoice, | |
560 | const AdvApprox_Cutting& VChoice, | |
561 | const AdvApp2Var_EvaluatorFunc2Var& Func) | |
562 | { | |
563 | Standard_Real dec; | |
564 | Standard_Boolean more; | |
565 | Standard_Integer ind1, ind2, NbPatch, NbU, NbV; | |
566 | AdvApp2Var_Iso Is; | |
567 | Standard_Integer indN1, indN2; | |
568 | Standard_Integer iu = myConditions.UOrder(), iv = myConditions.VOrder(); | |
569 | AdvApp2Var_Node N1(iu,iv), N2(iu,iv); | |
570 | ||
571 | while ( myConstraints.FirstNotApprox(ind1, ind2, Is) ) { | |
572 | ||
0d969553 | 573 | // approximation of iso and calculation of constraints at extremities |
7fd59977 | 574 | indN1 = myConstraints.FirstNode(Is.Type(),ind1,ind2); |
575 | N1 = myConstraints.Node(indN1); | |
576 | indN2 = myConstraints.LastNode(Is.Type(),ind1,ind2); | |
577 | N2 = myConstraints.Node(indN2); | |
578 | ||
579 | Is.MakeApprox(myConditions, | |
580 | myFirstParInU, myLastParInU, | |
581 | myFirstParInV, myLastParInV, | |
582 | Func, N1 , N2); | |
583 | ||
584 | if (Is.IsApproximated()) { | |
0d969553 | 585 | // iso is approached at the required tolerance |
7fd59977 | 586 | myConstraints.ChangeIso(ind1,ind2,Is); |
587 | myConstraints.ChangeNode(indN1) = N1; | |
588 | myConstraints.ChangeNode(indN2) = N2; | |
589 | } | |
590 | ||
591 | else { | |
0d969553 | 592 | // Approximation is not satisfactory |
7fd59977 | 593 | NbU = myResult.NbPatchInU(); |
594 | NbV = myResult.NbPatchInV(); | |
595 | if (Is.Type()==GeomAbs_IsoV) { | |
596 | NbPatch = (NbU+1)*NbV; | |
597 | more = UChoice.Value(Is.T0(),Is.T1(),dec); | |
598 | } | |
599 | else { | |
600 | NbPatch = (NbV+1)*NbU; | |
601 | more = VChoice.Value(Is.T0(),Is.T1(),dec); | |
602 | } | |
603 | ||
604 | if (NbPatch<=myMaxPatches && more) { | |
0d969553 | 605 | // It is possible to cut iso |
7fd59977 | 606 | if (Is.Type()==GeomAbs_IsoV) { |
607 | myResult.UpdateInU(dec); | |
608 | myConstraints.UpdateInU(dec); | |
609 | } | |
610 | else { | |
611 | myResult.UpdateInV(dec); | |
612 | myConstraints.UpdateInV(dec); | |
613 | } | |
614 | } | |
615 | ||
616 | else { | |
0d969553 | 617 | // It is not possible to cut : the result is preserved |
7fd59977 | 618 | if (Is.HasResult()) { |
619 | Is.OverwriteApprox(); | |
620 | myConstraints.ChangeIso(ind1,ind2,Is); | |
621 | myConstraints.ChangeNode(indN1) = N1; | |
622 | myConstraints.ChangeNode(indN2) = N2; | |
623 | } | |
624 | else { | |
625 | myHasResult = myDone = Standard_False; | |
626 | Standard_ConstructionError::Raise | |
627 | ("AdvApp2Var_ApproxAFunc2Var : Curve Approximation Error"); | |
628 | } | |
629 | } | |
630 | } | |
631 | } | |
632 | } | |
633 | ||
634 | ||
635 | //======================================================================= | |
636 | //function : ComputeConstraints with Criterion | |
637 | //purpose : Approximation of the constraints | |
638 | //======================================================================= | |
639 | ||
640 | void AdvApp2Var_ApproxAFunc2Var::ComputeConstraints(const AdvApprox_Cutting& UChoice, | |
641 | const AdvApprox_Cutting& VChoice, | |
642 | const AdvApp2Var_EvaluatorFunc2Var& Func, | |
643 | const AdvApp2Var_Criterion& Crit) | |
644 | { | |
645 | Standard_Real dec; | |
646 | Standard_Boolean more, CritRel = (Crit.Type() == AdvApp2Var_Relative); | |
647 | Standard_Integer ind1, ind2, NbPatch, NbU, NbV; | |
648 | AdvApp2Var_Iso Is; | |
649 | Standard_Integer indN1, indN2; | |
650 | Standard_Integer iu = myConditions.UOrder(), iv = myConditions.VOrder(); | |
651 | AdvApp2Var_Node N1(iu,iv), N2(iu,iv); | |
652 | ||
653 | while ( myConstraints.FirstNotApprox(ind1, ind2, Is) ) { | |
654 | ||
0d969553 | 655 | // approximation of the iso and calculation of constraints at the extremities |
7fd59977 | 656 | indN1 = myConstraints.FirstNode(Is.Type(),ind1,ind2); |
657 | N1 = myConstraints.Node(indN1); | |
658 | indN2 = myConstraints.LastNode(Is.Type(),ind1,ind2); | |
659 | N2 = myConstraints.Node(indN2); | |
660 | ||
661 | Is.MakeApprox(myConditions, | |
662 | myFirstParInU, myLastParInU, | |
663 | myFirstParInV, myLastParInV, | |
664 | Func, N1 , N2); | |
665 | ||
666 | if (Is.IsApproximated()) { | |
0d969553 | 667 | // iso is approached at the required tolerance |
7fd59977 | 668 | myConstraints.ChangeIso(ind1,ind2,Is); |
669 | myConstraints.ChangeNode(indN1) = N1; | |
670 | myConstraints.ChangeNode(indN2) = N2; | |
671 | } | |
672 | ||
673 | else { | |
0d969553 | 674 | // Approximation is not satisfactory |
7fd59977 | 675 | NbU = myResult.NbPatchInU(); |
676 | NbV = myResult.NbPatchInV(); | |
677 | if (Is.Type()==GeomAbs_IsoV) { | |
678 | NbPatch = (NbU+1)*NbV; | |
679 | more = UChoice.Value(Is.T0(),Is.T1(),dec); | |
680 | } | |
681 | else { | |
682 | NbPatch = (NbV+1)*NbU; | |
683 | more = VChoice.Value(Is.T0(),Is.T1(),dec); | |
684 | } | |
685 | ||
0d969553 | 686 | // To force Overwrite if the criterion is Absolute |
7fd59977 | 687 | more = more && (CritRel); |
688 | ||
689 | if (NbPatch<=myMaxPatches && more) { | |
0d969553 | 690 | // It is possible to cut iso |
7fd59977 | 691 | if (Is.Type()==GeomAbs_IsoV) { |
692 | myResult.UpdateInU(dec); | |
693 | myConstraints.UpdateInU(dec); | |
694 | } | |
695 | else { | |
696 | myResult.UpdateInV(dec); | |
697 | myConstraints.UpdateInV(dec); | |
698 | } | |
699 | } | |
700 | ||
701 | else { | |
0d969553 | 702 | // It is not possible to cut: the result is preserved |
7fd59977 | 703 | if (Is.HasResult()) { |
704 | Is.OverwriteApprox(); | |
705 | myConstraints.ChangeIso(ind1,ind2,Is); | |
706 | myConstraints.ChangeNode(indN1) = N1; | |
707 | myConstraints.ChangeNode(indN2) = N2; | |
708 | } | |
709 | else { | |
710 | myHasResult = myDone = Standard_False; | |
711 | Standard_ConstructionError::Raise | |
712 | ("AdvApp2Var_ApproxAFunc2Var : Curve Approximation Error"); | |
713 | } | |
714 | } | |
715 | } | |
716 | } | |
717 | } | |
718 | ||
719 | //======================================================================= | |
720 | //function : Compute3DErrors | |
721 | //purpose : Computation of the 3D errors | |
722 | //======================================================================= | |
723 | ||
724 | void AdvApp2Var_ApproxAFunc2Var::Compute3DErrors() | |
725 | { | |
726 | ||
727 | Standard_Integer iesp,ipat; | |
728 | Standard_Real error_max,error_moy,error_U0,error_V0,error_U1,error_V1; | |
729 | Standard_Real Tol,F1Tol,F2Tol,F3Tol,F4Tol; | |
730 | if ( myNumSubSpaces[2] > 0 ) { | |
731 | my3DMaxError = new (TColStd_HArray1OfReal) (1,myNumSubSpaces[2]); | |
732 | my3DAverageError = new (TColStd_HArray1OfReal) (1,myNumSubSpaces[2]); | |
733 | my3DUFrontError = new (TColStd_HArray1OfReal) (1,myNumSubSpaces[2]); | |
734 | my3DVFrontError = new (TColStd_HArray1OfReal) (1,myNumSubSpaces[2]); | |
735 | for (iesp=1;iesp<=myNumSubSpaces[2];iesp++) { | |
736 | error_max = 0; | |
737 | error_moy = 0.; | |
738 | error_U0 = 0.; | |
739 | error_V0 = 0.; | |
740 | error_U1 = 0.; | |
741 | error_V1 = 0.; | |
742 | Tol = my3DTolerances->Value(iesp); | |
743 | F1Tol = my3DTolOnFront->Value(iesp,1); | |
744 | F2Tol = my3DTolOnFront->Value(iesp,2); | |
745 | F3Tol = my3DTolOnFront->Value(iesp,3); | |
746 | F4Tol = my3DTolOnFront->Value(iesp,4); | |
747 | for (ipat=1;ipat<=myResult.NbPatch();ipat++) { | |
748 | error_max = Max((myResult(ipat).MaxErrors())->Value(iesp),error_max); | |
749 | error_U0 = Max((myResult(ipat).IsoErrors())->Value(iesp,3),error_U0); | |
750 | error_U1 = Max((myResult(ipat).IsoErrors())->Value(iesp,4),error_U1); | |
751 | error_V0 = Max((myResult(ipat).IsoErrors())->Value(iesp,1),error_V0); | |
752 | error_V1 = Max((myResult(ipat).IsoErrors())->Value(iesp,2),error_V1); | |
753 | error_moy += (myResult(ipat).AverageErrors())->Value(iesp); | |
754 | } | |
755 | my3DMaxError->SetValue(iesp,error_max); | |
756 | my3DUFrontError->SetValue(iesp,Max(error_U0,error_U1)); | |
757 | my3DVFrontError->SetValue(iesp,Max(error_V0,error_V1)); | |
758 | error_moy /= (Standard_Real) myResult.NbPatch(); | |
759 | my3DAverageError->SetValue(iesp,error_moy); | |
760 | if ( error_max>Tol | |
761 | || error_U0>F3Tol || error_U1>F4Tol | |
762 | || error_V0>F1Tol || error_V1>F2Tol) { | |
763 | myDone = Standard_False; | |
764 | } | |
765 | } | |
766 | } | |
767 | } | |
768 | ||
769 | ||
770 | //======================================================================= | |
771 | //function : ComputeCritError | |
772 | //purpose : Computation of the max value of the Criterion | |
773 | //======================================================================= | |
774 | ||
775 | void AdvApp2Var_ApproxAFunc2Var::ComputeCritError() | |
776 | { | |
777 | ||
778 | Standard_Integer iesp,ipat; | |
779 | Standard_Real crit_max; | |
780 | if ( myNumSubSpaces[2] > 0 ) { | |
781 | for (iesp=1;iesp<=myNumSubSpaces[2];iesp++) { | |
782 | crit_max = 0.; | |
783 | for (ipat=1;ipat<=myResult.NbPatch();ipat++) { | |
784 | crit_max = Max((myResult(ipat).CritValue()),crit_max); | |
785 | } | |
786 | myCriterionError = crit_max; | |
787 | } | |
788 | } | |
789 | } | |
790 | ||
791 | //======================================================================= | |
792 | //function : ConvertBS | |
793 | //purpose : Convertion of the approximation in BSpline Surface | |
794 | //======================================================================= | |
795 | ||
796 | void AdvApp2Var_ApproxAFunc2Var::ConvertBS() | |
797 | { | |
0d969553 | 798 | // Homogeneization of degrees |
7fd59977 | 799 | Standard_Integer iu = myConditions.UOrder(), iv = myConditions.VOrder(); |
800 | Standard_Integer ncfu = myConditions.ULimit(), ncfv = myConditions.VLimit(); | |
801 | myResult.SameDegree(iu,iv,ncfu,ncfv); | |
802 | myDegreeInU = ncfu - 1; | |
803 | myDegreeInV = ncfv - 1; | |
804 | ||
0d969553 | 805 | // Calculate resulting surfaces |
7fd59977 | 806 | mySurfaces = new ( TColGeom_HArray1OfSurface) (1, myNumSubSpaces[2]); |
807 | ||
808 | Standard_Integer j; | |
809 | TColStd_Array1OfReal UKnots (1, myResult.NbPatchInU()+1); | |
810 | for (j=1; j<=UKnots.Length(); j++) { UKnots.SetValue(j, myResult.UParameter(j)); } | |
811 | ||
812 | TColStd_Array1OfReal VKnots (1, myResult.NbPatchInV()+1); | |
813 | for (j=1; j<=VKnots.Length(); j++) { VKnots.SetValue(j, myResult.VParameter(j)); } | |
814 | ||
0d969553 | 815 | // Prepare data for conversion grid of polynoms --> poles |
7fd59977 | 816 | Handle(TColStd_HArray1OfReal) Uint1 = |
817 | new (TColStd_HArray1OfReal) (1,2); | |
818 | Uint1->SetValue(1, -1); | |
819 | Uint1->SetValue(2, 1); | |
820 | Handle(TColStd_HArray1OfReal) Vint1 = | |
821 | new (TColStd_HArray1OfReal) (1,2); | |
822 | Vint1->SetValue(1, -1); | |
823 | Vint1->SetValue(2, 1); | |
824 | ||
825 | Handle(TColStd_HArray1OfReal) Uint2 = | |
826 | new (TColStd_HArray1OfReal) (1,myResult.NbPatchInU()+1); | |
827 | for (j=1; j<=Uint2->Length(); j++) { Uint2->SetValue(j, myResult.UParameter(j)); } | |
828 | Handle(TColStd_HArray1OfReal) Vint2 = | |
829 | new (TColStd_HArray1OfReal) (1,myResult.NbPatchInV()+1); | |
830 | for (j=1; j<=Vint2->Length(); j++) { Vint2->SetValue(j, myResult.VParameter(j)); } | |
831 | ||
832 | Standard_Integer nmax = myResult.NbPatchInU()*myResult.NbPatchInV(), | |
833 | Size_eq = myConditions.ULimit() * myConditions.VLimit() * 3; | |
834 | ||
835 | Handle(TColStd_HArray2OfInteger) NbCoeff = | |
836 | new (TColStd_HArray2OfInteger) (1, nmax, 1, 2); | |
837 | Handle(TColStd_HArray1OfReal) Poly = | |
838 | new (TColStd_HArray1OfReal) (1, nmax * Size_eq); | |
839 | ||
840 | Standard_Integer SSP, i; | |
841 | for (SSP=1; SSP <= myNumSubSpaces[2]; SSP++) { | |
842 | ||
0d969553 | 843 | // Creation of the grid of polynoms |
7fd59977 | 844 | Standard_Integer n=0,icf=1,ieq; |
845 | for (j=1; j<=myResult.NbPatchInV(); j++) { | |
846 | for (i=1; i<=myResult.NbPatchInU(); i++) { | |
847 | n++; | |
848 | NbCoeff->SetValue(n,1, myResult.Patch(i,j).NbCoeffInU()); | |
849 | NbCoeff->SetValue(n,2, myResult.Patch(i,j).NbCoeffInV()); | |
850 | for (ieq=1; ieq<=Size_eq;ieq++) { | |
851 | Poly->SetValue(icf,(myResult.Patch(i,j).Coefficients(SSP,myConditions)) | |
852 | ->Value(ieq)); | |
853 | icf++; | |
854 | } | |
855 | } | |
856 | } | |
857 | ||
0d969553 | 858 | // Conversion into poles |
7fd59977 | 859 | Convert_GridPolynomialToPoles CvP (myResult.NbPatchInU(),myResult.NbPatchInV(), |
860 | iu,iv,myMaxDegInU,myMaxDegInV,NbCoeff, | |
861 | Poly,Uint1,Vint1,Uint2,Vint2); | |
862 | if ( !CvP.IsDone() ) { myDone = Standard_False; } | |
863 | ||
0d969553 | 864 | // Conversion into BSpline |
7fd59977 | 865 | mySurfaces->ChangeValue(SSP) = new (Geom_BSplineSurface) |
866 | ( CvP.Poles()->Array2(), | |
867 | CvP.UKnots()->Array1(), CvP.VKnots()->Array1(), | |
868 | CvP.UMultiplicities()->Array1(), CvP.VMultiplicities()->Array1(), | |
869 | CvP.UDegree(), CvP.VDegree() ); | |
870 | } | |
871 | } | |
872 | ||
873 | //======================================================================= | |
874 | //function : MaxError | |
875 | //purpose : | |
876 | //======================================================================= | |
877 | ||
878 | Handle(TColStd_HArray1OfReal) | |
879 | AdvApp2Var_ApproxAFunc2Var::MaxError(const Standard_Integer Dimension) const | |
880 | { | |
881 | Handle (TColStd_HArray1OfReal) EPtr; | |
882 | if (Dimension <1 || Dimension >3) { | |
883 | Standard_OutOfRange::Raise | |
884 | ("AdvApp2Var_ApproxAFunc2Var::MaxError : Dimension must be equal to 1,2 or 3 !"); | |
885 | } | |
886 | switch (Dimension) { | |
887 | case 1: | |
888 | EPtr = my1DMaxError; | |
889 | break; | |
890 | case 2: | |
891 | EPtr = my2DMaxError; | |
892 | break; | |
893 | case 3: | |
894 | EPtr = my3DMaxError; | |
895 | break; | |
896 | } | |
897 | return EPtr; | |
898 | } | |
899 | ||
900 | //======================================================================= | |
901 | //function : AverageError | |
902 | //purpose : | |
903 | //======================================================================= | |
904 | ||
905 | Handle(TColStd_HArray1OfReal) | |
906 | AdvApp2Var_ApproxAFunc2Var::AverageError(const Standard_Integer Dimension) const | |
907 | { | |
908 | Handle (TColStd_HArray1OfReal) EPtr; | |
909 | if (Dimension <1 || Dimension >3) { | |
910 | Standard_OutOfRange::Raise | |
911 | ("AdvApp2Var_ApproxAFunc2Var::AverageError : Dimension must be equal to 1,2 or 3 !"); | |
912 | } | |
913 | switch (Dimension) { | |
914 | case 1: | |
915 | EPtr = my1DAverageError; | |
916 | break; | |
917 | case 2: | |
918 | EPtr = my2DAverageError; | |
919 | break; | |
920 | case 3: | |
921 | EPtr = my3DAverageError; | |
922 | break; | |
923 | } | |
924 | return EPtr; | |
925 | } | |
926 | ||
927 | //======================================================================= | |
928 | //function : UFrontError | |
929 | //purpose : | |
930 | //======================================================================= | |
931 | ||
932 | Handle(TColStd_HArray1OfReal) | |
933 | AdvApp2Var_ApproxAFunc2Var::UFrontError(const Standard_Integer Dimension) const | |
934 | { | |
935 | Handle (TColStd_HArray1OfReal) EPtr; | |
936 | if (Dimension <1 || Dimension >3) { | |
937 | Standard_OutOfRange::Raise | |
938 | ("AdvApp2Var_ApproxAFunc2Var::UFrontError : Dimension must be equal to 1,2 or 3 !"); | |
939 | } | |
940 | switch (Dimension) { | |
941 | case 1: | |
942 | EPtr = my1DUFrontError; | |
943 | break; | |
944 | case 2: | |
945 | EPtr = my2DUFrontError; | |
946 | break; | |
947 | case 3: | |
948 | EPtr = my3DUFrontError; | |
949 | break; | |
950 | } | |
951 | return EPtr; | |
952 | } | |
953 | ||
954 | //======================================================================= | |
955 | //function : VFrontError | |
956 | //purpose : | |
957 | //======================================================================= | |
958 | ||
959 | Handle(TColStd_HArray1OfReal) | |
960 | AdvApp2Var_ApproxAFunc2Var::VFrontError(const Standard_Integer Dimension) const | |
961 | { | |
962 | Handle (TColStd_HArray1OfReal) EPtr; | |
963 | if (Dimension <=0 || Dimension >3) { | |
964 | Standard_OutOfRange::Raise | |
965 | ("AdvApp2Var_ApproxAFunc2Var::VFrontError : Dimension must be equal to 1,2 or 3 !"); | |
966 | } | |
967 | switch (Dimension) { | |
968 | case 1: | |
969 | EPtr = my1DVFrontError; | |
970 | break; | |
971 | case 2: | |
972 | EPtr = my2DVFrontError; | |
973 | break; | |
974 | case 3: | |
975 | EPtr = my3DVFrontError; | |
976 | break; | |
977 | } | |
978 | return EPtr; | |
979 | } | |
980 | ||
981 | //======================================================================= | |
982 | //function : MaxError | |
983 | //purpose : | |
984 | //======================================================================= | |
985 | ||
986 | Standard_Real | |
987 | AdvApp2Var_ApproxAFunc2Var::MaxError(const Standard_Integer Dimension, | |
988 | const Standard_Integer SSPIndex) const | |
989 | { | |
990 | if (Dimension !=3 || SSPIndex !=1) { | |
991 | Standard_OutOfRange::Raise | |
992 | ("AdvApp2Var_ApproxAFunc2Var::MaxError: ONE Surface 3D only !"); | |
993 | } | |
994 | Handle (TColStd_HArray1OfReal) EPtr = MaxError(Dimension); | |
995 | return EPtr->Value(SSPIndex); | |
996 | } | |
997 | ||
998 | //======================================================================= | |
999 | //function : AverageError | |
1000 | //purpose : | |
1001 | //======================================================================= | |
1002 | ||
1003 | Standard_Real | |
1004 | AdvApp2Var_ApproxAFunc2Var::AverageError(const Standard_Integer Dimension, | |
1005 | const Standard_Integer SSPIndex) const | |
1006 | { | |
1007 | if (Dimension !=3 || SSPIndex !=1) { | |
1008 | Standard_OutOfRange::Raise | |
1009 | ("AdvApp2Var_ApproxAFunc2Var::AverageError : ONE Surface 3D only !"); | |
1010 | } | |
1011 | Handle (TColStd_HArray1OfReal) EPtr = AverageError(Dimension); | |
1012 | return EPtr->Value(SSPIndex); | |
1013 | } | |
1014 | ||
1015 | //======================================================================= | |
1016 | //function : UFrontError | |
1017 | //purpose : | |
1018 | //======================================================================= | |
1019 | ||
1020 | Standard_Real | |
1021 | AdvApp2Var_ApproxAFunc2Var::UFrontError(const Standard_Integer Dimension, | |
1022 | const Standard_Integer SSPIndex) const | |
1023 | { | |
1024 | if (Dimension !=3 || SSPIndex !=1) { | |
1025 | Standard_OutOfRange::Raise | |
1026 | ("AdvApp2Var_ApproxAFunc2Var::UFrontError : ONE Surface 3D only !"); | |
1027 | } | |
1028 | Handle (TColStd_HArray1OfReal) EPtr = UFrontError(Dimension); | |
1029 | return EPtr->Value(SSPIndex); | |
1030 | } | |
1031 | ||
1032 | //======================================================================= | |
1033 | //function : VFrontError | |
1034 | //purpose : | |
1035 | //======================================================================= | |
1036 | ||
1037 | Standard_Real | |
1038 | AdvApp2Var_ApproxAFunc2Var::VFrontError(const Standard_Integer Dimension, | |
1039 | const Standard_Integer SSPIndex) const | |
1040 | { | |
1041 | if (Dimension !=3 || SSPIndex !=1) { | |
1042 | Standard_OutOfRange::Raise | |
1043 | ("AdvApp2Var_ApproxAFunc2Var::VFrontError : ONE Surface 3D only !"); | |
1044 | } | |
1045 | Handle (TColStd_HArray1OfReal) EPtr = VFrontError(Dimension); | |
1046 | return EPtr->Value(SSPIndex); | |
1047 | } | |
1048 | ||
1049 | ||
1050 | //======================================================================= | |
1051 | //function : CritError | |
1052 | //purpose : | |
1053 | //======================================================================= | |
1054 | ||
1055 | Standard_Real | |
1056 | AdvApp2Var_ApproxAFunc2Var::CritError(const Standard_Integer Dimension, | |
1057 | const Standard_Integer SSPIndex) const | |
1058 | { | |
1059 | if (Dimension !=3 || SSPIndex !=1) { | |
1060 | Standard_OutOfRange::Raise | |
1061 | ("AdvApp2Var_ApproxAFunc2Var::CritError: ONE Surface 3D only !"); | |
1062 | } | |
1063 | return myCriterionError; | |
1064 | } | |
1065 | ||
1066 | //======================================================================= | |
1067 | //function : Dump | |
1068 | //purpose : | |
1069 | //======================================================================= | |
1070 | ||
1071 | void AdvApp2Var_ApproxAFunc2Var::Dump(Standard_OStream& o) const | |
1072 | { | |
1073 | Standard_Integer iesp=1,NbKU,NbKV,ik; | |
1074 | o<<endl; | |
1075 | if (!myHasResult) { o<<"No result"<<endl; } | |
1076 | else { | |
1077 | o<<"There is a result"; | |
1078 | if (myDone) { | |
1079 | o<<" within the requested tolerance "<<my3DTolerances->Value(iesp)<<endl; | |
1080 | } | |
1081 | else if (my3DMaxError->Value(iesp)>my3DTolerances->Value(iesp)) { | |
1082 | o<<" WITHOUT the requested tolerance "<<my3DTolerances->Value(iesp)<<endl; | |
1083 | } | |
1084 | else { | |
1085 | o<<" WITHOUT the requested continuities "<<endl; | |
1086 | } | |
1087 | o<<endl; | |
1088 | o<<"Result max error :"<<my3DMaxError->Value(iesp)<<endl; | |
1089 | o<<"Result average error :"<<my3DAverageError->Value(iesp)<<endl; | |
1090 | o<<"Result max error on U frontiers :"<<my3DUFrontError->Value(iesp)<<endl; | |
1091 | o<<"Result max error on V frontiers :"<<my3DVFrontError->Value(iesp)<<endl; | |
1092 | o<<endl; | |
1093 | o<<"Degree of Bezier patches in U : "<<myDegreeInU | |
1094 | <<" in V : "<<myDegreeInV<<endl; | |
1095 | o<<endl; | |
1096 | Handle(Geom_BSplineSurface) S | |
1097 | = Handle(Geom_BSplineSurface)::DownCast(mySurfaces->Value(iesp)); | |
1098 | o<<"Number of poles in U : "<<S->NbUPoles() | |
1099 | <<" in V : "<<S->NbVPoles()<<endl; | |
1100 | o<<endl; | |
1101 | NbKU = S->NbUKnots(); | |
1102 | NbKV = S->NbVKnots(); | |
1103 | o<<"Number of knots in U : "<<NbKU<<endl; | |
1104 | for (ik=1;ik<=NbKU;ik++) { | |
1105 | o<<" "<<ik<<" : "<<S->UKnot(ik)<<" mult : "<<S->UMultiplicity(ik)<<endl; | |
1106 | } | |
1107 | o<<endl; | |
1108 | o<<"Number of knots in V : "<<NbKV<<endl; | |
1109 | for (ik=1;ik<=NbKV;ik++) { | |
1110 | o<<" "<<ik<<" : "<<S->VKnot(ik)<<" mult : "<<S->VMultiplicity(ik)<<endl; | |
1111 | } | |
1112 | o<<endl; | |
1113 | } | |
1114 | } |