0024750: Replace instantiations of TCollection generic classes by NCollection templat...
[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)
63{ Standard_Real U1, U2, V1, V2, u1, u2, v1, v2;
64 GeomAbs_Shape TypeCont;
65 Standard_Integer ord;
66 Standard_Boolean b1, b2, b3, b4;
67 Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
68 if (n<8) return 1;
69
70 InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
71
72 Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
73 if (surf1.IsNull()) return 1 ;
74
75 Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
76 if (surf2.IsNull()) return 1;
77
91322f44 78 U1 = Draw::Atof(a[3]);
79 U2 = Draw::Atof(a[6]);
80 V1 = Draw::Atof(a[4]);
81 V2 = Draw::Atof(a[7]);
7fd59977 82
91322f44 83 ord = Draw::Atoi(a[1]);
7fd59977 84
85 surf1->Bounds(u1, u2, v1, v2);
86 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
87 b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
88
89 surf2->Bounds(u1, u2, v1, v2);
90 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
91 b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
92
93 if (!((b1 && b2)&&(b3 && b4))) return 1;
94
95
96 switch ( ord )
97 { case 0 : { TypeCont=GeomAbs_C0;
98 switch(n)
91322f44 99 { case 10 : epsC0= Draw::Atof(a[9]);
100 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 101 case 8 : {} break;
102 default : return 1;
103 }
104 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
105 TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
106 //LocalAnalysis::Dump(RES,cout);
107 Standard_SStream aSStream;
108 LocalAnalysis::Dump(RES,aSStream);
109 di << aSStream;
110 }
111 break;
112 case 1 : { TypeCont=GeomAbs_C1;
113 switch(n)
91322f44 114 { case 11 : epsC1=Draw::Atof(a[10]);
115 case 10 : epsC0= Draw::Atof(a[9]);
116 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 117 case 8 : {} break;
118 default : return 1;
119 }
120 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
121 TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
122 //LocalAnalysis::Dump(RES,cout);
123 Standard_SStream aSStream;
124 LocalAnalysis::Dump(RES,aSStream);
125 di << aSStream;
126
127 }
128 break;
129 case 2 : { TypeCont=GeomAbs_C2;
130 switch(n)
131 {
91322f44 132 case 12 : epsC2= Draw::Atof(a[11]);
133 case 11 : epsC1=Draw::Atof(a[10]);
134 case 10 : epsC0= Draw::Atof(a[9]);
135 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 136 case 8 : {} break;
137 default : return 1;
138 }
139 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
140 TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
141 //LocalAnalysis::Dump(RES,cout);
142 Standard_SStream aSStream;
143 LocalAnalysis::Dump(RES,aSStream);
144 di << aSStream;
145 }
146 break;
147
148
149 default : {}
150 }
151 return 0;
152}
153
154/*********************************************************************************/
155
156static Standard_Integer surfaceGcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
157{ Standard_Real U1, U2, V1, V2,u1, u2, v1, v2;
158 GeomAbs_Shape TypeCont;
159 Standard_Integer ord;
160 Standard_Boolean b1, b2, b3, b4;
161 Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
162
163 if (n<8) return 1;
164 InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
165
166 Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
167 if (surf1.IsNull()) return 1 ;
168
169 Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
170 if (surf2.IsNull()) return 1;
171
91322f44 172 U1 = Draw::Atof(a[3]);
173 U2 = Draw::Atof(a[6]);
174 V1 = Draw::Atof(a[4]);
175 V2 = Draw::Atof(a[7]);
7fd59977 176
91322f44 177 ord = Draw::Atoi(a[1]);
7fd59977 178
179 surf1->Bounds(u1, u2, v1, v2);
180 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
181 b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
182
183 surf2->Bounds(u1, u2, v1, v2);
184 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
185 b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
186
187 if (!((b1 && b2)&&(b3 && b4))) return 1;
188
189
190 switch ( ord )
191 {
192 case 1 : { TypeCont=GeomAbs_G1;
193 switch(n)
91322f44 194 { case 11 : epsG1=Draw::Atof(a[10]);
195 case 10 : epsC0= Draw::Atof(a[9]);
196 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 197 case 8 : {} break;
198 default : return 1;
199 }
200 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
201 TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
202 //LocalAnalysis::Dump(RES,cout);
203 Standard_SStream aSStream;
204 LocalAnalysis::Dump(RES,aSStream);
205 di << aSStream;
206
207 }
208 break;
209 case 2 : { TypeCont=GeomAbs_G2;
210 switch(n)
91322f44 211 { case 13 : maxlen =Draw::Atof (a[12]);
212 case 12 : perce=Draw::Atof(a[11]);
213 case 11 : epsG1=Draw::Atof(a[10]);
214 case 10 : epsC0= Draw::Atof(a[9]);
215 case 9 : epsnl = Draw::Atof(a[8]);
7fd59977 216 case 8 : {} break;
217 default : return 1;
218 }
219 LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2,
220 TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
221 //LocalAnalysis::Dump(RES,cout);
222 Standard_SStream aSStream;
223 LocalAnalysis::Dump(RES,aSStream);
224 di << aSStream;
225 }
226 break;
227
228
229 default : {}
230 }
231 return 0;
232}
233
234/*********************************************************************************/
235
236static Standard_Integer curveGcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
237{ Standard_Real U1, U2, u1, u2;
238 GeomAbs_Shape TypeCont;
239 Standard_Integer ord;
240 Standard_Boolean b1, b2;
241 Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
242 if (n<6) return 1;
243
244 Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
245 if (curv1.IsNull()) return 1;
246 Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
247 if (curv2.IsNull()) return 1;
248
91322f44 249 U1 = Draw::Atof(a[3]);
250 U2 = Draw::Atof(a[5]);
7fd59977 251
91322f44 252 ord = Draw::Atoi(a[1]);
7fd59977 253
254 u1=curv1->FirstParameter();
255 u2=curv1->LastParameter();
256 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
257
258 u1=curv2->FirstParameter();
259 u2=curv2->LastParameter();
260 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
261
262 if (!(b1 && b2)) return 1;
263
264 InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
265 switch ( ord )
266 {
267 case 1 : {
268 switch(n)
91322f44 269 { case 9 : epsG1=Draw::Atof(a[8]);
270 case 8 : epsC0= Draw::Atof(a[7]);
271 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 272 case 6 : {} break;
273 default : return 1;
274 }
275 TypeCont=GeomAbs_G1;
276 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
277 epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
278 //LocalAnalysis::Dump(RES,cout);
279 Standard_SStream aSStream;
280 LocalAnalysis::Dump(RES,aSStream);
281 di << aSStream;
282 }
283 break;
284 case 2 : {
285 TypeCont=GeomAbs_G2;
286 switch(n)
91322f44 287 {case 12 :maxlen =Draw::Atof(a[11]);
288 case 11 :percent=Draw::Atof(a[10]);
289 case 10 : epsG2= Draw::Atof(a[9]);
290 case 9 : epsG1=Draw::Atof(a[8]);
291 case 8 : epsC0= Draw::Atof(a[7]);
292 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 293 case 6 : {} break;
294 default : return 1;
295 }
296 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
297 epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen );
298 //LocalAnalysis::Dump(RES,cout);
299 Standard_SStream aSStream;
300 LocalAnalysis::Dump(RES,aSStream);
301 di << aSStream;
302 }
303 break;
304 default : {}
305 }
306 return 0;
307 }
308
309/*********************************************************************************/
310
311static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
312{ Standard_Real U1, U2, u1, u2;
313 GeomAbs_Shape TypeCont;
314 Standard_Integer ord;
315 Standard_Boolean b1, b2;
316 Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
317 if (n<6) return 1;
318
319 Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
320 if (curv1.IsNull()) return 1;
321 Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
322 if (curv2.IsNull()) return 1;
323
91322f44 324 U1 = Draw::Atof(a[3]);
325 U2 = Draw::Atof(a[5]);
7fd59977 326
91322f44 327 ord = Draw::Atoi(a[1]);
7fd59977 328
329 u1=curv1->FirstParameter();
330 u2=curv1->LastParameter();
331 b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
332
333 u1=curv2->FirstParameter();
334 u2=curv2->LastParameter();
335 b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
336
337 if (!(b1 && b2)) return 1;
338
339
340 InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
341 switch ( ord )
342 { case 0 : { switch(n)
91322f44 343 { case 8 : epsC0= Draw::Atof(a[7]);
344 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 345 case 6 : {} break;
346 default : return 1;
347 }
348 TypeCont=GeomAbs_C0;
349 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
350 epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
351 //LocalAnalysis::Dump(RES,cout);
352 Standard_SStream aSStream;
353 LocalAnalysis::Dump(RES,aSStream);
354 di << aSStream;
355
356 } break;
357 case 1 : { switch(n)
91322f44 358 { case 9 : epsC1 =Draw::Atof(a[8]);
359 case 8 : epsC0= Draw::Atof(a[7]);
360 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 361 case 6 : {} break;
362 default : return 1;
363 }
364 TypeCont=GeomAbs_C1;
365 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
366 epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen );
367 //LocalAnalysis::Dump(RES,cout);
368 Standard_SStream aSStream;
369 LocalAnalysis::Dump(RES,aSStream);
370 di << aSStream;
371
372 } break;
373 case 2 : { TypeCont=GeomAbs_C2;
374 switch(n)
375 {
91322f44 376 case 10 : epsC2= Draw::Atof(a[9]);
377 case 9 : epsC1=Draw::Atof(a[8]);
378 case 8 : epsC0= Draw::Atof(a[7]);
379 case 7 : epsnl = Draw::Atof(a[6]);
7fd59977 380 case 6 : {} break;
381 default : return 1;
382 }
383 LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
384 epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen );
385 //LocalAnalysis::Dump(RES,cout);
386 Standard_SStream aSStream;
387 LocalAnalysis::Dump(RES,aSStream);
388 di << aSStream;
389 }
390 break;
391 default : {}
392 }
393 return 0;
394 }
395/***************************************************************************/
396void GeometryTest::ContinuityCommands( Draw_Interpretor& theCommands)
397{
398 static Standard_Boolean loaded = Standard_False;
399 if ( loaded) return;
400 loaded = Standard_True;
401
402 DrawTrSurf::BasicCommands(theCommands);
403 const char* g;
404
405 g = "GEOMETRY curves and surfaces continuity analysis ";
406
407
408
409 theCommands.Add("surfaceCcontinuity",
410 " surfaceCcontinuity order surf1 parU1 parV1 surf2 parU2 parV2 [eps_nul[ epsC0 [epsC1 [epsC2]]]]",
411 __FILE__,
412 surfaceCcontinuity ,g);
413
414 theCommands.Add("surfaceGcontinuity",
415 " surfaceGcontinuity order surf1 parU1 parV1 surf2 parU2 parV2 [eps_nul[ epsG0 [epsG1[percent [maxlen]]]]",
416 __FILE__,
417 surfaceGcontinuity ,g);
418
419 theCommands.Add("curveCcontinuity",
420 "curveCcontinuity order curv1 u1 curv2 u2 [epsnul [epsC0 [epsC1 [epsC2 ]]]] ",
421 __FILE__,
422 curveCcontinuity,g);
423
424
425 theCommands.Add("curveGcontinuity",
426 "curveGcontinuity order curv1 u1 curv2 u2 [epsnul [epsG0 [epsG1 [epsG2 [percent [maxlen ]]]]]] ",
427 __FILE__,
428 curveGcontinuity,g);
429}
430
431
432
433
434
435
436
437