0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / GeometryTest / GeometryTest_ContinuityCommands.cxx
CommitLineData
b311480e 1// Created on: 1996-07-31
2// Created by: Herve LOUESSARD
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23
24#include <LocalAnalysis.hxx>
25#include <LocalAnalysis_SurfaceContinuity.hxx>
26#include <LocalAnalysis_CurveContinuity.hxx>
27#include <Geom_Surface.hxx>
28#include <Geom_Curve.hxx>
29#include <Geom2d_TrimmedCurve.hxx>
30#include <Geom2d_Curve.hxx>
31#include <DrawTrSurf.hxx>
32#include <GeometryTest.hxx>
33#include <GeomAbs_Shape.hxx>
34#include <Draw_Appli.hxx>
35#include <Draw.hxx>
36#include <Draw_Interpretor.hxx>
37
38/*********************************************************************************/
39void InitEpsSurf(Standard_Real& epsnl,Standard_Real& epsdis, Standard_Real& epsangk1,
40 Standard_Real& epsangk2, Standard_Real& epsangn1,
41 Standard_Real& perce,Standard_Real& maxlen )
42{
43 epsnl = 0.001;
44 epsdis = 0.001;
45 epsangk1 = 0.001 ;
46 epsangk2 = 0.001;
47 epsangn1 = 0.001 ;
48 perce = 0.01;
49 maxlen = 10000 ;
50}
51
52/*********************************************************************************/
53void InitEpsCurv(Standard_Real& epsnl ,Standard_Real& epsdis, Standard_Real& epsangk1,
54 Standard_Real& epsangk2, Standard_Real& epsangg1,
55 Standard_Real& epsangg2,Standard_Real& percent,
56 Standard_Real& maxlen)
57{
58 epsnl = 0.001 ;
59 epsdis = 0.001 ;
60 epsangk1= 0.001 ;
61 epsangk2= 0.001;
62 epsangg1= 0.001 ;
63 epsangg2= 0.001 ;
64 percent= 0.01;
65 maxlen= 10000;
66}
67/*********************************************************************************/
68
69static Standard_Integer surfaceCcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
70{ Standard_Real U1, U2, V1, V2, u1, u2, v1, v2;
71 GeomAbs_Shape TypeCont;
72 Standard_Integer ord;
73 Standard_Boolean b1, b2, b3, b4;
74 Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
75 if (n<8) return 1;
76
77 InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
78
79 Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
80 if (surf1.IsNull()) return 1 ;
81
82 Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
83 if (surf2.IsNull()) return 1;
84
91322f44 85 U1 = Draw::Atof(a[3]);
86 U2 = Draw::Atof(a[6]);
87 V1 = Draw::Atof(a[4]);
88 V2 = Draw::Atof(a[7]);
7fd59977 89
91322f44 90 ord = Draw::Atoi(a[1]);
7fd59977 91
92 surf1->Bounds(u1, u2, v1, v2);
93 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
94 b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
95
96 surf2->Bounds(u1, u2, v1, v2);
97 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
98 b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
99
100 if (!((b1 && b2)&&(b3 && b4))) return 1;
101
102
103 switch ( ord )
104 { case 0 : { TypeCont=GeomAbs_C0;
105 switch(n)
91322f44 106 { case 10 : epsC0= Draw::Atof(a[9]);
107 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 108 case 8 : {} break;
109 default : return 1;
110 }
111 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
112 TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
113 //LocalAnalysis::Dump(RES,cout);
114 Standard_SStream aSStream;
115 LocalAnalysis::Dump(RES,aSStream);
116 di << aSStream;
117 }
118 break;
119 case 1 : { TypeCont=GeomAbs_C1;
120 switch(n)
91322f44 121 { case 11 : epsC1=Draw::Atof(a[10]);
122 case 10 : epsC0= Draw::Atof(a[9]);
123 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 124 case 8 : {} break;
125 default : return 1;
126 }
127 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
128 TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
129 //LocalAnalysis::Dump(RES,cout);
130 Standard_SStream aSStream;
131 LocalAnalysis::Dump(RES,aSStream);
132 di << aSStream;
133
134 }
135 break;
136 case 2 : { TypeCont=GeomAbs_C2;
137 switch(n)
138 {
91322f44 139 case 12 : epsC2= Draw::Atof(a[11]);
140 case 11 : epsC1=Draw::Atof(a[10]);
141 case 10 : epsC0= Draw::Atof(a[9]);
142 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 143 case 8 : {} break;
144 default : return 1;
145 }
146 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
147 TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
148 //LocalAnalysis::Dump(RES,cout);
149 Standard_SStream aSStream;
150 LocalAnalysis::Dump(RES,aSStream);
151 di << aSStream;
152 }
153 break;
154
155
156 default : {}
157 }
158 return 0;
159}
160
161/*********************************************************************************/
162
163static Standard_Integer surfaceGcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
164{ Standard_Real U1, U2, V1, V2,u1, u2, v1, v2;
165 GeomAbs_Shape TypeCont;
166 Standard_Integer ord;
167 Standard_Boolean b1, b2, b3, b4;
168 Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
169
170 if (n<8) return 1;
171 InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
172
173 Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
174 if (surf1.IsNull()) return 1 ;
175
176 Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
177 if (surf2.IsNull()) return 1;
178
91322f44 179 U1 = Draw::Atof(a[3]);
180 U2 = Draw::Atof(a[6]);
181 V1 = Draw::Atof(a[4]);
182 V2 = Draw::Atof(a[7]);
7fd59977 183
91322f44 184 ord = Draw::Atoi(a[1]);
7fd59977 185
186 surf1->Bounds(u1, u2, v1, v2);
187 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
188 b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
189
190 surf2->Bounds(u1, u2, v1, v2);
191 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
192 b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
193
194 if (!((b1 && b2)&&(b3 && b4))) return 1;
195
196
197 switch ( ord )
198 {
199 case 1 : { TypeCont=GeomAbs_G1;
200 switch(n)
91322f44 201 { case 11 : epsG1=Draw::Atof(a[10]);
202 case 10 : epsC0= Draw::Atof(a[9]);
203 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 204 case 8 : {} break;
205 default : return 1;
206 }
207 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
208 TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
209 //LocalAnalysis::Dump(RES,cout);
210 Standard_SStream aSStream;
211 LocalAnalysis::Dump(RES,aSStream);
212 di << aSStream;
213
214 }
215 break;
216 case 2 : { TypeCont=GeomAbs_G2;
217 switch(n)
91322f44 218 { case 13 : maxlen =Draw::Atof (a[12]);
219 case 12 : perce=Draw::Atof(a[11]);
220 case 11 : epsG1=Draw::Atof(a[10]);
221 case 10 : epsC0= Draw::Atof(a[9]);
222 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 223 case 8 : {} break;
224 default : return 1;
225 }
226 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
227 TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
228 //LocalAnalysis::Dump(RES,cout);
229 Standard_SStream aSStream;
230 LocalAnalysis::Dump(RES,aSStream);
231 di << aSStream;
232 }
233 break;
234
235
236 default : {}
237 }
238 return 0;
239}
240
241/*********************************************************************************/
242
243static Standard_Integer curveGcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
244{ Standard_Real U1, U2, u1, u2;
245 GeomAbs_Shape TypeCont;
246 Standard_Integer ord;
247 Standard_Boolean b1, b2;
248 Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
249 if (n<6) return 1;
250
251 Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
252 if (curv1.IsNull()) return 1;
253 Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
254 if (curv2.IsNull()) return 1;
255
91322f44 256 U1 = Draw::Atof(a[3]);
257 U2 = Draw::Atof(a[5]);
7fd59977 258
91322f44 259 ord = Draw::Atoi(a[1]);
7fd59977 260
261 u1=curv1->FirstParameter();
262 u2=curv1->LastParameter();
263 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
264
265 u1=curv2->FirstParameter();
266 u2=curv2->LastParameter();
267 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
268
269 if (!(b1 && b2)) return 1;
270
271 InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
272 switch ( ord )
273 {
274 case 1 : {
275 switch(n)
91322f44 276 { case 9 : epsG1=Draw::Atof(a[8]);
277 case 8 : epsC0= Draw::Atof(a[7]);
278 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 279 case 6 : {} break;
280 default : return 1;
281 }
282 TypeCont=GeomAbs_G1;
283 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
284 epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
285 //LocalAnalysis::Dump(RES,cout);
286 Standard_SStream aSStream;
287 LocalAnalysis::Dump(RES,aSStream);
288 di << aSStream;
289 }
290 break;
291 case 2 : {
292 TypeCont=GeomAbs_G2;
293 switch(n)
91322f44 294 {case 12 :maxlen =Draw::Atof(a[11]);
295 case 11 :percent=Draw::Atof(a[10]);
296 case 10 : epsG2= Draw::Atof(a[9]);
297 case 9 : epsG1=Draw::Atof(a[8]);
298 case 8 : epsC0= Draw::Atof(a[7]);
299 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 300 case 6 : {} break;
301 default : return 1;
302 }
303 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
304 epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen );
305 //LocalAnalysis::Dump(RES,cout);
306 Standard_SStream aSStream;
307 LocalAnalysis::Dump(RES,aSStream);
308 di << aSStream;
309 }
310 break;
311 default : {}
312 }
313 return 0;
314 }
315
316/*********************************************************************************/
317
318static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
319{ Standard_Real U1, U2, u1, u2;
320 GeomAbs_Shape TypeCont;
321 Standard_Integer ord;
322 Standard_Boolean b1, b2;
323 Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
324 if (n<6) return 1;
325
326 Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
327 if (curv1.IsNull()) return 1;
328 Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
329 if (curv2.IsNull()) return 1;
330
91322f44 331 U1 = Draw::Atof(a[3]);
332 U2 = Draw::Atof(a[5]);
7fd59977 333
91322f44 334 ord = Draw::Atoi(a[1]);
7fd59977 335
336 u1=curv1->FirstParameter();
337 u2=curv1->LastParameter();
338 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
339
340 u1=curv2->FirstParameter();
341 u2=curv2->LastParameter();
342 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
343
344 if (!(b1 && b2)) return 1;
345
346
347 InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
348 switch ( ord )
349 { case 0 : { switch(n)
91322f44 350 { case 8 : epsC0= Draw::Atof(a[7]);
351 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 352 case 6 : {} break;
353 default : return 1;
354 }
355 TypeCont=GeomAbs_C0;
356 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
357 epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
358 //LocalAnalysis::Dump(RES,cout);
359 Standard_SStream aSStream;
360 LocalAnalysis::Dump(RES,aSStream);
361 di << aSStream;
362
363 } break;
364 case 1 : { switch(n)
91322f44 365 { case 9 : epsC1 =Draw::Atof(a[8]);
366 case 8 : epsC0= Draw::Atof(a[7]);
367 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 368 case 6 : {} break;
369 default : return 1;
370 }
371 TypeCont=GeomAbs_C1;
372 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
373 epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
374 //LocalAnalysis::Dump(RES,cout);
375 Standard_SStream aSStream;
376 LocalAnalysis::Dump(RES,aSStream);
377 di << aSStream;
378
379 } break;
380 case 2 : { TypeCont=GeomAbs_C2;
381 switch(n)
382 {
91322f44 383 case 10 : epsC2= Draw::Atof(a[9]);
384 case 9 : epsC1=Draw::Atof(a[8]);
385 case 8 : epsC0= Draw::Atof(a[7]);
386 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 387 case 6 : {} break;
388 default : return 1;
389 }
390 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
391 epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen );
392 //LocalAnalysis::Dump(RES,cout);
393 Standard_SStream aSStream;
394 LocalAnalysis::Dump(RES,aSStream);
395 di << aSStream;
396 }
397 break;
398 default : {}
399 }
400 return 0;
401 }
402/***************************************************************************/
403void GeometryTest::ContinuityCommands( Draw_Interpretor& theCommands)
404{
405 static Standard_Boolean loaded = Standard_False;
406 if ( loaded) return;
407 loaded = Standard_True;
408
409 DrawTrSurf::BasicCommands(theCommands);
410 const char* g;
411
412 g = "GEOMETRY curves and surfaces continuity analysis ";
413
414
415
416 theCommands.Add("surfaceCcontinuity",
417 " surfaceCcontinuity order surf1 parU1 parV1 surf2 parU2 parV2 [eps_nul[ epsC0 [epsC1 [epsC2]]]]",
418 __FILE__,
419 surfaceCcontinuity ,g);
420
421 theCommands.Add("surfaceGcontinuity",
422 " surfaceGcontinuity order surf1 parU1 parV1 surf2 parU2 parV2 [eps_nul[ epsG0 [epsG1[percent [maxlen]]]]",
423 __FILE__,
424 surfaceGcontinuity ,g);
425
426 theCommands.Add("curveCcontinuity",
427 "curveCcontinuity order curv1 u1 curv2 u2 [epsnul [epsC0 [epsC1 [epsC2 ]]]] ",
428 __FILE__,
429 curveCcontinuity,g);
430
431
432 theCommands.Add("curveGcontinuity",
433 "curveGcontinuity order curv1 u1 curv2 u2 [epsnul [epsG0 [epsG1 [epsG2 [percent [maxlen ]]]]]] ",
434 __FILE__,
435 curveGcontinuity,g);
436}
437
438
439
440
441
442
443
444