0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[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
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 <LocalAnalysis.hxx>
18#include <LocalAnalysis_SurfaceContinuity.hxx>
19#include <LocalAnalysis_CurveContinuity.hxx>
20#include <Geom_Surface.hxx>
21#include <Geom_Curve.hxx>
22#include <Geom2d_TrimmedCurve.hxx>
23#include <Geom2d_Curve.hxx>
24#include <DrawTrSurf.hxx>
25#include <GeometryTest.hxx>
26#include <GeomAbs_Shape.hxx>
27#include <Draw_Appli.hxx>
28#include <Draw.hxx>
29#include <Draw_Interpretor.hxx>
30
31/*********************************************************************************/
32void InitEpsSurf(Standard_Real& epsnl,Standard_Real& epsdis, Standard_Real& epsangk1,
33 Standard_Real& epsangk2, Standard_Real& epsangn1,
34 Standard_Real& perce,Standard_Real& maxlen )
35{
36 epsnl = 0.001;
37 epsdis = 0.001;
38 epsangk1 = 0.001 ;
39 epsangk2 = 0.001;
40 epsangn1 = 0.001 ;
41 perce = 0.01;
42 maxlen = 10000 ;
43}
44
45/*********************************************************************************/
46void InitEpsCurv(Standard_Real& epsnl ,Standard_Real& epsdis, Standard_Real& epsangk1,
47 Standard_Real& epsangk2, Standard_Real& epsangg1,
48 Standard_Real& epsangg2,Standard_Real& percent,
49 Standard_Real& maxlen)
50{
51 epsnl = 0.001 ;
52 epsdis = 0.001 ;
53 epsangk1= 0.001 ;
54 epsangk2= 0.001;
55 epsangg1= 0.001 ;
56 epsangg2= 0.001 ;
57 percent= 0.01;
58 maxlen= 10000;
59}
60/*********************************************************************************/
61
62static Standard_Integer surfaceCcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
b1811c1d 63{
64 Standard_Real U1, U2, V1, V2, u1, u2, v1, v2;
7fd59977 65 GeomAbs_Shape TypeCont;
66 Standard_Integer ord;
67 Standard_Boolean b1, b2, b3, b4;
68 Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
69 if (n<8) return 1;
70
71 InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
72
73 Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
74 if (surf1.IsNull()) return 1 ;
75
76 Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
77 if (surf2.IsNull()) return 1;
78
b1811c1d 79 U1 = Draw::Atof(a[3]);
80 U2 = Draw::Atof(a[6]);
81 V1 = Draw::Atof(a[4]);
82 V2 = Draw::Atof(a[7]);
7fd59977 83
b1811c1d 84 ord = Draw::Atoi(a[1]);
7fd59977 85
b1811c1d 86 surf1->Bounds(u1, u2, v1, v2);
87 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
88 b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
7fd59977 89
b1811c1d 90 surf2->Bounds(u1, u2, v1, v2);
91 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
92 b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
7fd59977 93
b1811c1d 94 if (!((b1 && b2)&&(b3 && b4))) return 1;
95
96 switch ( ord )
97 {
98 case 0 :
99 {
100 TypeCont = GeomAbs_C0;
101 switch(n)
102 {
103 case 10: epsC0 = Draw::Atof(a[9]);
104 Standard_FALLTHROUGH
105 case 9 : epsnl = Draw::Atof(a[8]);
106 Standard_FALLTHROUGH
107 case 8 : break;
108 default :
109 std::cerr << "Error: invalid number of arguments: expected to get 8 - 10 parameters" << std::endl;
110 return 1;
111 }
112 }
113 break;
114
115 case 1 :
116 {
117 TypeCont = GeomAbs_C1;
118 switch(n)
119 {
120 case 11 : epsC1 = Draw::Atof(a[10]);
121 Standard_FALLTHROUGH
122 case 10 : epsC0 = Draw::Atof(a[9]);
123 Standard_FALLTHROUGH
124 case 9 : epsnl = Draw::Atof(a[8]);
125 Standard_FALLTHROUGH
126 case 8 : break;
127 default :
128 std::cerr << "Error: invalid number of arguments: expected to get 8 - 11 parameters" << std::endl;
129 return 1;
130 }
131 }
132 break;
133
134 case 2 :
135 {
136 TypeCont = GeomAbs_C2;
137 switch(n)
138 {
139 case 12 : epsC2 = Draw::Atof(a[11]);
140 Standard_FALLTHROUGH
141 case 11 : epsC1 = Draw::Atof(a[10]);
142 Standard_FALLTHROUGH
143 case 10 : epsC0 = Draw::Atof(a[9]);
144 Standard_FALLTHROUGH
145 case 9 : epsnl = Draw::Atof(a[8]);
146 Standard_FALLTHROUGH
147 case 8 : break;
148 default :
149 std::cerr << "Error: invalid number of arguments: expected to get 8 - 12 parameters" << std::endl;
150 return 1;
151 }
152 }
153 break;
154 default:
155 std::cerr << "Error: invalid value of parameter 1 (" << a[1] << "): should be 0, 1, or 2" << std::endl;
156 return 1;
157 }
158
159 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
160 TypeCont, epsnl, epsC0, epsC1, epsC2, epsG1, perce, maxlen);
161 //LocalAnalysis::Dump(RES,cout);
162 Standard_SStream aSStream;
163 LocalAnalysis::Dump(RES,aSStream);
164 di << aSStream;
165 return 0;
7fd59977 166}
167
168/*********************************************************************************/
169
170static Standard_Integer surfaceGcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
b1811c1d 171{
172 Standard_Real U1, U2, V1, V2,u1, u2, v1, v2;
7fd59977 173 GeomAbs_Shape TypeCont;
174 Standard_Integer ord;
175 Standard_Boolean b1, b2, b3, b4;
176 Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
177
178 if (n<8) return 1;
179 InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
180
181 Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
182 if (surf1.IsNull()) return 1 ;
183
184 Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
185 if (surf2.IsNull()) return 1;
186
b1811c1d 187 U1 = Draw::Atof(a[3]);
188 U2 = Draw::Atof(a[6]);
189 V1 = Draw::Atof(a[4]);
190 V2 = Draw::Atof(a[7]);
7fd59977 191
b1811c1d 192 ord = Draw::Atoi(a[1]);
7fd59977 193
b1811c1d 194 surf1->Bounds(u1, u2, v1, v2);
195 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
196 b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
7fd59977 197
b1811c1d 198 surf2->Bounds(u1, u2, v1, v2);
199 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
200 b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
7fd59977 201
b1811c1d 202 if (!((b1 && b2)&&(b3 && b4))) return 1;
203
204
205 switch ( ord )
206 {
207 case 1 :
208 {
209 TypeCont = GeomAbs_G1;
210 switch(n)
211 {
212 case 11 : epsG1 = Draw::Atof(a[10]);
213 Standard_FALLTHROUGH
214 case 10 : epsC0 = Draw::Atof(a[9]);
215 Standard_FALLTHROUGH
216 case 9 : epsnl = Draw::Atof(a[8]);
217 Standard_FALLTHROUGH
218 case 8 : break;
219 default :
220 std::cerr << "Error: invalid number of arguments: expected to get 8 - 11 parameters" << std::endl;
221 return 1;
222 }
223 }
224 break;
225
226 case 2 :
227 {
228 TypeCont = GeomAbs_G2;
229 switch(n)
230 {
231 case 13 : maxlen = Draw::Atof (a[12]);
232 Standard_FALLTHROUGH
233 case 12 : perce = Draw::Atof(a[11]);
234 Standard_FALLTHROUGH
235 case 11 : epsG1 = Draw::Atof(a[10]);
236 Standard_FALLTHROUGH
237 case 10 : epsC0 = Draw::Atof(a[9]);
238 Standard_FALLTHROUGH
239 case 9 : epsnl = Draw::Atof(a[8]);
240 Standard_FALLTHROUGH
241 case 8 : break;
242 default :
243 std::cerr << "Error: invalid number of arguments: expected to get 8 - 13 parameters" << std::endl;
244 return 1;
245 }
246 }
247 break;
248 default:
249 std::cerr << "Error: invalid value of parameter 1 (" << a[1] << "): should be 1 or 2" << std::endl;
250 return 1;
251 }
252
253 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
254 TypeCont, epsnl, epsC0, epsC1, epsC2, epsG1, perce, maxlen);
255 //LocalAnalysis::Dump(RES,cout);
256 Standard_SStream aSStream;
257 LocalAnalysis::Dump(RES,aSStream);
258 di << aSStream;
259 return 0;
7fd59977 260}
261
262/*********************************************************************************/
263
264static Standard_Integer curveGcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
b1811c1d 265{
266 Standard_Real U1, U2, u1, u2;
7fd59977 267 GeomAbs_Shape TypeCont;
268 Standard_Integer ord;
269 Standard_Boolean b1, b2;
270 Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
271 if (n<6) return 1;
272
273 Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
274 if (curv1.IsNull()) return 1;
275 Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
276 if (curv2.IsNull()) return 1;
277
91322f44 278 U1 = Draw::Atof(a[3]);
279 U2 = Draw::Atof(a[5]);
7fd59977 280
91322f44 281 ord = Draw::Atoi(a[1]);
7fd59977 282
283 u1=curv1->FirstParameter();
284 u2=curv1->LastParameter();
285 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
286
287 u1=curv2->FirstParameter();
288 u2=curv2->LastParameter();
289 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
290
291 if (!(b1 && b2)) return 1;
292
293 InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
294 switch ( ord )
b1811c1d 295 {
296 case 1 :
297 {
298 TypeCont = GeomAbs_G1;
299 switch(n)
300 {
301 case 9 : epsG1 = Draw::Atof(a[8]);
302 Standard_FALLTHROUGH
303 case 8 : epsC0 = Draw::Atof(a[7]);
304 Standard_FALLTHROUGH
305 case 7 : epsnl = Draw::Atof(a[6]);
306 Standard_FALLTHROUGH
307 case 6 : break;
308 default :
309 std::cerr << "Error: invalid number of arguments: expected to get 6 - 8 parameters" << std::endl;
310 return 1;
311 }
312 }
313 break;
314 case 2 :
315 {
316 TypeCont = GeomAbs_G2;
317 switch(n)
318 {
319 case 12 : maxlen = Draw::Atof(a[11]);
320 Standard_FALLTHROUGH
321 case 11 : percent = Draw::Atof(a[10]);
322 Standard_FALLTHROUGH
323 case 10 : epsG2 = Draw::Atof(a[9]);
324 Standard_FALLTHROUGH
325 case 9 : epsG1 = Draw::Atof(a[8]);
326 Standard_FALLTHROUGH
327 case 8 : epsC0 = Draw::Atof(a[7]);
328 Standard_FALLTHROUGH
329 case 7 : epsnl = Draw::Atof(a[6]);
330 Standard_FALLTHROUGH
331 case 6 : break;
332 default :
333 std::cerr << "Error: invalid number of arguments: expected to get 6 - 12 parameters" << std::endl;
334 return 1;
335 }
7fd59977 336 }
b1811c1d 337 break;
338
339 default:
340 std::cerr << "Error: invalid value of parameter 1 (" << a[1] << "): should be 1 or 2" << std::endl;
341 return 1;
342 }
343
344 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
345 epsnl, epsC0, epsC1, epsC2, epsG1, epsG2, percent, maxlen);
346 //LocalAnalysis::Dump(RES,cout);
347 Standard_SStream aSStream;
348 LocalAnalysis::Dump(RES,aSStream);
349 di << aSStream;
350 return 0;
351}
7fd59977 352
353/*********************************************************************************/
354
355static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
b1811c1d 356{
357 Standard_Real U1, U2, u1, u2;
7fd59977 358 GeomAbs_Shape TypeCont;
359 Standard_Integer ord;
360 Standard_Boolean b1, b2;
361 Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
362 if (n<6) return 1;
363
364 Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
365 if (curv1.IsNull()) return 1;
366 Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
367 if (curv2.IsNull()) return 1;
368
b1811c1d 369 U1 = Draw::Atof(a[3]);
370 U2 = Draw::Atof(a[5]);
7fd59977 371
b1811c1d 372 ord = Draw::Atoi(a[1]);
373
374 u1=curv1->FirstParameter();
375 u2=curv1->LastParameter();
376 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
377
378 u1=curv2->FirstParameter();
379 u2=curv2->LastParameter();
380 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
381
382 if (!(b1 && b2)) return 1;
383
384 InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
385 switch ( ord )
386 {
387 case 0 :
388 {
389 TypeCont = GeomAbs_C0;
390 switch(n)
391 {
392 case 8 : epsC0 = Draw::Atof(a[7]);
393 Standard_FALLTHROUGH
394 case 7 : epsnl = Draw::Atof(a[6]);
395 Standard_FALLTHROUGH
396 case 6 : break;
397 default :
398 std::cerr << "Error: invalid number of arguments: expected to get 6 - 8 parameters" << std::endl;
399 return 1;
400 }
401 }
402 break;
403 case 1 :
404 {
405 TypeCont = GeomAbs_C1;
406 switch(n)
407 {
408 case 9 : epsC1 = Draw::Atof(a[8]);
409 Standard_FALLTHROUGH
410 case 8 : epsC0 = Draw::Atof(a[7]);
411 Standard_FALLTHROUGH
412 case 7 : epsnl = Draw::Atof(a[6]);
413 Standard_FALLTHROUGH
414 case 6 : break;
415 default :
416 std::cerr << "Error: invalid number of arguments: expected to get 6 - 9 parameters" << std::endl;
417 return 1;
418 }
419 }
420 break;
421
422 case 2 :
423 {
424 TypeCont = GeomAbs_C2;
425 switch(n)
426 {
427 case 10 : epsC2 = Draw::Atof(a[9]);
428 Standard_FALLTHROUGH
429 case 9 : epsC1 = Draw::Atof(a[8]);
430 Standard_FALLTHROUGH
431 case 8 : epsC0 = Draw::Atof(a[7]);
432 Standard_FALLTHROUGH
433 case 7 : epsnl = Draw::Atof(a[6]);
434 Standard_FALLTHROUGH
435 case 6 : break;
436 default :
437 std::cerr << "Error: invalid number of arguments: expected to get 6 - 10 parameters" << std::endl;
438 return 1;
439 }
7fd59977 440 }
b1811c1d 441 break;
442
443 default:
444 std::cerr << "Error: invalid value of parameter 1 (" << a[1] << "): should be 0, 1, or 2" << std::endl;
445 return 1;
446 }
447
448 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
449 epsnl, epsC0, epsC1, epsC2, epsG1, epsG2, percent, maxlen);
450 //LocalAnalysis::Dump(RES,cout);
451 Standard_SStream aSStream;
452 LocalAnalysis::Dump(RES,aSStream);
453 di << aSStream;
454 return 0;
455}
456
7fd59977 457/***************************************************************************/
458void GeometryTest::ContinuityCommands( Draw_Interpretor& theCommands)
459{
460 static Standard_Boolean loaded = Standard_False;
461 if ( loaded) return;
462 loaded = Standard_True;
463
464 DrawTrSurf::BasicCommands(theCommands);
465 const char* g;
466
467 g = "GEOMETRY curves and surfaces continuity analysis ";
468
7fd59977 469 theCommands.Add("surfaceCcontinuity",
470 " surfaceCcontinuity order surf1 parU1 parV1 surf2 parU2 parV2 [eps_nul[ epsC0 [epsC1 [epsC2]]]]",
471 __FILE__,
472 surfaceCcontinuity ,g);
473
474 theCommands.Add("surfaceGcontinuity",
475 " surfaceGcontinuity order surf1 parU1 parV1 surf2 parU2 parV2 [eps_nul[ epsG0 [epsG1[percent [maxlen]]]]",
476 __FILE__,
477 surfaceGcontinuity ,g);
478
479 theCommands.Add("curveCcontinuity",
480 "curveCcontinuity order curv1 u1 curv2 u2 [epsnul [epsC0 [epsC1 [epsC2 ]]]] ",
481 __FILE__,
482 curveCcontinuity,g);
483
484
485 theCommands.Add("curveGcontinuity",
486 "curveGcontinuity order curv1 u1 curv2 u2 [epsnul [epsG0 [epsG1 [epsG2 [percent [maxlen ]]]]]] ",
487 __FILE__,
488 curveGcontinuity,g);
489}
490
491
492
493
494
495
496
497