summaryrefslogtreecommitdiff
path: root/src/GeometryTest/GeometryTest_ContinuityCommands.cxx
blob: df295b68f0d04b54edc1b371d24cc60fd938eb3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
// File:	Test.cxx
// Created:	Wed Jul 31 10:35:38 1996
// Author:	Herve LOUESSARD
//		<hl1@sgi29>



#include <LocalAnalysis.hxx>
#include <LocalAnalysis_SurfaceContinuity.hxx>
#include <LocalAnalysis_CurveContinuity.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <DrawTrSurf.hxx>
#include <GeometryTest.hxx>
#include <GeomAbs_Shape.hxx>
#include <Draw_Appli.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>

/*********************************************************************************/
void  InitEpsSurf(Standard_Real& epsnl,Standard_Real& epsdis, Standard_Real& epsangk1, 
			       Standard_Real& epsangk2, Standard_Real& epsangn1, 
			       Standard_Real& perce,Standard_Real& maxlen )
{ 
  epsnl  = 0.001;
  epsdis = 0.001;
  epsangk1 = 0.001 ; 
  epsangk2 = 0.001;
  epsangn1 = 0.001 ; 
  perce = 0.01;
  maxlen = 10000 ;
}

/*********************************************************************************/
void InitEpsCurv(Standard_Real&  epsnl ,Standard_Real&  epsdis, Standard_Real& epsangk1, 
			       Standard_Real& epsangk2, Standard_Real& epsangg1,
			       Standard_Real& epsangg2,Standard_Real& percent,
                               Standard_Real& maxlen)
{ 
  epsnl  = 0.001 ;
  epsdis = 0.001 ; 
  epsangk1= 0.001 ; 
  epsangk2= 0.001; 
  epsangg1= 0.001 ;
  epsangg2= 0.001 ; 
  percent= 0.01;
  maxlen= 10000; 
}			   
/*********************************************************************************/

static Standard_Integer surfaceCcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
{ Standard_Real U1, U2, V1, V2, u1, u2, v1, v2;
  GeomAbs_Shape TypeCont; 
  Standard_Integer ord;
  Standard_Boolean b1, b2, b3, b4;
  Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
  if (n<8) return 1;
 
  InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);

  Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
  if (surf1.IsNull()) return 1 ;
  
  Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
  if (surf2.IsNull()) return 1;
   
      U1 = atof(a[3]);
      U2 = atof(a[6]);
      V1 = atof(a[4]); 
      V2 = atof(a[7]); 

      ord = atoi(a[1]);

      surf1->Bounds(u1, u2, v1, v2);
      b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
      b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));

      surf2->Bounds(u1, u2, v1, v2);
      b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
      b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
     
      if (!((b1 && b2)&&(b3 && b4))) return 1;

 
       switch ( ord )
       { case 0 : { TypeCont=GeomAbs_C0;
                    switch(n)
			{ case 10  : epsC0= atof(a[9]);
			  case 9   : epsnl = atof(a[8]);
			  case 8 : {} break;
			  default : return 1;
			} 
	            LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
                    TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
		    //LocalAnalysis::Dump(RES,cout);
		    Standard_SStream aSStream;
		    LocalAnalysis::Dump(RES,aSStream);
		    di << aSStream;
		  } 
		  break;
	 case 1 : { TypeCont=GeomAbs_C1;
                     switch(n)
			{ case 11 : epsC1=atof(a[10]); 
                          case 10  : epsC0= atof(a[9]);
			  case 9  : epsnl = atof(a[8]);
			  case 8  : {} break;
			  default : return 1;
			} 
	            LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
                    TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
		    //LocalAnalysis::Dump(RES,cout);
		    Standard_SStream aSStream;
		    LocalAnalysis::Dump(RES,aSStream);
		    di << aSStream;
     
		  } 
		  break;
	 case 2 : { TypeCont=GeomAbs_C2;
                    switch(n)
		       {
                          case 12 : epsC2= atof(a[11]); 
                          case 11 : epsC1=atof(a[10]); 
                          case 10 : epsC0= atof(a[9]);
			  case 9  : epsnl = atof(a[8]);
			  case 8  : {} break;
			  default : return 1;
			} 
	            LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
                           TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen  );
                    //LocalAnalysis::Dump(RES,cout);    
		    Standard_SStream aSStream;
                    LocalAnalysis::Dump(RES,aSStream);    
		    di << aSStream;
		  }
		  break;

	 
        default : {} 
       }
   return 0; 
}

/*********************************************************************************/

static Standard_Integer surfaceGcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
{ Standard_Real U1, U2, V1, V2,u1, u2, v1, v2;
  GeomAbs_Shape TypeCont; 
  Standard_Integer ord;
  Standard_Boolean b1, b2, b3, b4;
  Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
  
  if (n<8) return 1;
  InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);

  Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
  if (surf1.IsNull()) return 1 ;
  
  Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
  if (surf2.IsNull()) return 1;
   
      U1 = atof(a[3]);
      U2 = atof(a[6]);
      V1 = atof(a[4]); 
      V2 = atof(a[7]); 

      ord = atoi(a[1]);

      surf1->Bounds(u1, u2, v1, v2);
      b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
      b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));

      surf2->Bounds(u1, u2, v1, v2);
      b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
      b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
     
      if (!((b1 && b2)&&(b3 && b4))) return 1;

 
       switch ( ord )
       { 
	 case 1 : { TypeCont=GeomAbs_G1;
                     switch(n)
			 { case 11 : epsG1=atof(a[10]); 
                          case 10  : epsC0= atof(a[9]);
			  case 9  : epsnl = atof(a[8]);
			  case 8  : {} break;
			  default : return 1;
			} 
	           LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
                      TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
		    //LocalAnalysis::Dump(RES,cout);
		    Standard_SStream aSStream;
		    LocalAnalysis::Dump(RES,aSStream);
		    di << aSStream;
    
		  } 
		  break;
	 case 2 : { TypeCont=GeomAbs_G2;
                    switch(n)
		      {   case 13 : maxlen =atof (a[12]);
                          case 12 :  perce=atof(a[11]); 
                          case 11 : epsG1=atof(a[10]); 
                          case 10 : epsC0= atof(a[9]);
			  case 9  : epsnl = atof(a[8]);
			  case 8  : {} break;
			  default : return 1;
			} 
	           LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
                          TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen  ); 
		    //LocalAnalysis::Dump(RES,cout);
		    Standard_SStream aSStream;
		    LocalAnalysis::Dump(RES,aSStream);
		    di << aSStream;
		  }
		  break;

	 
        default : {} 
       }
   return 0;  
}

/*********************************************************************************/

static Standard_Integer curveGcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
{ Standard_Real U1, U2, u1, u2;
  GeomAbs_Shape  TypeCont; 
  Standard_Integer ord;
  Standard_Boolean b1, b2;
  Standard_Real  epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
  if (n<6) return 1; 
  
  Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
  if (curv1.IsNull()) return 1;
  Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
  if (curv2.IsNull()) return 1;

  U1 = atof(a[3]);
  U2 = atof(a[5]);
 
  ord = atoi(a[1]);

  u1=curv1->FirstParameter();
  u2=curv1->LastParameter();
  b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
   
  u1=curv2->FirstParameter();
  u2=curv2->LastParameter();   
  b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
     
  if (!(b1 && b2)) return 1;

  InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
  switch ( ord )
       { 
	  case 1 : {
                    switch(n)
			{ case 9 :  epsG1=atof(a[8]); 
                          case 8  : epsC0= atof(a[7]);
			  case 7  : epsnl = atof(a[6]);
			  case 6  : {} break;
			  default : return 1;
			}                         
                    TypeCont=GeomAbs_G1;
	            LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont, 
                    epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen  );
                    //LocalAnalysis::Dump(RES,cout); 
		    Standard_SStream aSStream;
                    LocalAnalysis::Dump(RES,aSStream); 
		    di << aSStream;
		  } 
		  break;
	 case 2 : { 
                    TypeCont=GeomAbs_G2;
                    switch(n)
		       {case 12 :maxlen =atof(a[11]);
			case  11 :percent=atof(a[10]);
                        case 10 : epsG2= atof(a[9]); 
                        case 9 : epsG1=atof(a[8]); 
                        case 8  : epsC0= atof(a[7]);
			case 7  : epsnl = atof(a[6]);
			case 6  : {} break;
			default : return 1;
			} 
	             LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
                         epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen  );
                     //LocalAnalysis::Dump(RES,cout);   
		    Standard_SStream aSStream;
		    LocalAnalysis::Dump(RES,aSStream);   
		    di << aSStream;
		  }
		  break; 
        default : {}
       }
    return 0; 
    }

/*********************************************************************************/

static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
{ Standard_Real U1, U2, u1, u2;
  GeomAbs_Shape  TypeCont; 
  Standard_Integer ord;
  Standard_Boolean b1, b2;
  Standard_Real  epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
  if (n<6) return 1; 
  
  Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
  if (curv1.IsNull()) return 1;
  Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
  if (curv2.IsNull()) return 1;

   U1 = atof(a[3]);
   U2 = atof(a[5]);
 
   ord = atoi(a[1]);

   u1=curv1->FirstParameter();
   u2=curv1->LastParameter();
   b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
   
   u1=curv2->FirstParameter();
   u2=curv2->LastParameter();   
   b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
     
   if (!(b1 && b2)) return 1;


   InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
   switch ( ord )
       { case 0 : {  switch(n)
			{ case 8  : epsC0= atof(a[7]);
			  case 7  : epsnl = atof(a[6]);
			  case 6  : {} break;
			  default : return 1;
			}                     
                      TypeCont=GeomAbs_C0;
	              LocalAnalysis_CurveContinuity  RES (curv1, U1, curv2, U2, TypeCont,
                       epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen  );
		     //LocalAnalysis::Dump(RES,cout);
		     Standard_SStream aSStream;
		     LocalAnalysis::Dump(RES,aSStream);
		     di << aSStream;

		   }  break;
	 case 1 : { switch(n)
			{ case 9 : epsC1 =atof(a[8]);
                          case 8  : epsC0= atof(a[7]);
			  case 7  : epsnl = atof(a[6]);
			  case 6  : {} break;
			  default : return 1;
			}                          
                    TypeCont=GeomAbs_C1;
	            LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont, 
                    epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen  );
                    //LocalAnalysis::Dump(RES,cout); 
		    Standard_SStream aSStream;
                    LocalAnalysis::Dump(RES,aSStream); 
		    di << aSStream;
	           
		  } break;
	 case 2 : {  TypeCont=GeomAbs_C2;
                     switch(n)
		       {
                          case 10 : epsC2= atof(a[9]); 
                          case 9  : epsC1=atof(a[8]); 
                          case 8  : epsC0= atof(a[7]);
			  case 7  : epsnl = atof(a[6]);
			  case 6  : {} break;
			  default : return 1;
			} 
	            LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont, 
                    epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen  );
                    //LocalAnalysis::Dump(RES,cout);   
		    Standard_SStream aSStream;
                    LocalAnalysis::Dump(RES,aSStream);   
		    di << aSStream;
		  }
		  break; 
        default : {}
       }
    return 0;
    }
/***************************************************************************/
void GeometryTest::ContinuityCommands( Draw_Interpretor& theCommands)
{
  static Standard_Boolean loaded = Standard_False;
  if ( loaded) return;
  loaded = Standard_True;

  DrawTrSurf::BasicCommands(theCommands);
  const char* g;

  g = "GEOMETRY curves and surfaces continuity analysis ";



  theCommands.Add("surfaceCcontinuity",
		  " surfaceCcontinuity   order surf1 parU1 parV1 surf2 parU2 parV2  [eps_nul[ epsC0 [epsC1 [epsC2]]]]",  
		  __FILE__,
		  surfaceCcontinuity ,g);

  theCommands.Add("surfaceGcontinuity",
		  " surfaceGcontinuity   order surf1 parU1 parV1 surf2 parU2 parV2  [eps_nul[ epsG0 [epsG1[percent [maxlen]]]]",  
		  __FILE__,
		  surfaceGcontinuity ,g);  

  theCommands.Add("curveCcontinuity",
		  "curveCcontinuity   order curv1 u1  curv2  u2   [epsnul  [epsC0 [epsC1  [epsC2 ]]]]  ",
		  __FILE__,
		  curveCcontinuity,g);

 
  theCommands.Add("curveGcontinuity",
		  "curveGcontinuity   order  curv1 u1  curv2  u2   [epsnul  [epsG0  [epsG1  [epsG2 [percent  [maxlen ]]]]]] ",
		   __FILE__,
		  curveGcontinuity,g);
}