0022627: Change OCCT memory management defaults
[occt.git] / src / GeometryTest / GeometryTest_ContinuityCommands.cxx
1 // File:        Test.cxx
2 // Created:     Wed Jul 31 10:35:38 1996
3 // Author:      Herve LOUESSARD
4 //              <hl1@sgi29>
5
6
7
8 #include <LocalAnalysis.hxx>
9 #include <LocalAnalysis_SurfaceContinuity.hxx>
10 #include <LocalAnalysis_CurveContinuity.hxx>
11 #include <Geom_Surface.hxx>
12 #include <Geom_Curve.hxx>
13 #include <Geom2d_TrimmedCurve.hxx>
14 #include <Geom2d_Curve.hxx>
15 #include <DrawTrSurf.hxx>
16 #include <GeometryTest.hxx>
17 #include <GeomAbs_Shape.hxx>
18 #include <Draw_Appli.hxx>
19 #include <Draw.hxx>
20 #include <Draw_Interpretor.hxx>
21
22 /*********************************************************************************/
23 void  InitEpsSurf(Standard_Real& epsnl,Standard_Real& epsdis, Standard_Real& epsangk1, 
24                                Standard_Real& epsangk2, Standard_Real& epsangn1, 
25                                Standard_Real& perce,Standard_Real& maxlen )
26
27   epsnl  = 0.001;
28   epsdis = 0.001;
29   epsangk1 = 0.001 ; 
30   epsangk2 = 0.001;
31   epsangn1 = 0.001 ; 
32   perce = 0.01;
33   maxlen = 10000 ;
34 }
35
36 /*********************************************************************************/
37 void InitEpsCurv(Standard_Real&  epsnl ,Standard_Real&  epsdis, Standard_Real& epsangk1, 
38                                Standard_Real& epsangk2, Standard_Real& epsangg1,
39                                Standard_Real& epsangg2,Standard_Real& percent,
40                                Standard_Real& maxlen)
41
42   epsnl  = 0.001 ;
43   epsdis = 0.001 ; 
44   epsangk1= 0.001 ; 
45   epsangk2= 0.001; 
46   epsangg1= 0.001 ;
47   epsangg2= 0.001 ; 
48   percent= 0.01;
49   maxlen= 10000; 
50 }                          
51 /*********************************************************************************/
52
53 static Standard_Integer surfaceCcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
54 { Standard_Real U1, U2, V1, V2, u1, u2, v1, v2;
55   GeomAbs_Shape TypeCont; 
56   Standard_Integer ord;
57   Standard_Boolean b1, b2, b3, b4;
58   Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
59   if (n<8) return 1;
60  
61   InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
62
63   Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
64   if (surf1.IsNull()) return 1 ;
65   
66   Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
67   if (surf2.IsNull()) return 1;
68    
69       U1 = atof(a[3]);
70       U2 = atof(a[6]);
71       V1 = atof(a[4]); 
72       V2 = atof(a[7]); 
73
74       ord = atoi(a[1]);
75
76       surf1->Bounds(u1, u2, v1, v2);
77       b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
78       b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
79
80       surf2->Bounds(u1, u2, v1, v2);
81       b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
82       b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
83      
84       if (!((b1 && b2)&&(b3 && b4))) return 1;
85
86  
87        switch ( ord )
88        { case 0 : { TypeCont=GeomAbs_C0;
89                     switch(n)
90                         { case 10  : epsC0= atof(a[9]);
91                           case 9   : epsnl = atof(a[8]);
92                           case 8 : {} break;
93                           default : return 1;
94                         } 
95                     LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
96                     TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
97                     //LocalAnalysis::Dump(RES,cout);
98                     Standard_SStream aSStream;
99                     LocalAnalysis::Dump(RES,aSStream);
100                     di << aSStream;
101                   } 
102                   break;
103          case 1 : { TypeCont=GeomAbs_C1;
104                      switch(n)
105                         { case 11 : epsC1=atof(a[10]); 
106                           case 10  : epsC0= atof(a[9]);
107                           case 9  : epsnl = atof(a[8]);
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                   } 
119                   break;
120          case 2 : { TypeCont=GeomAbs_C2;
121                     switch(n)
122                        {
123                           case 12 : epsC2= atof(a[11]); 
124                           case 11 : epsC1=atof(a[10]); 
125                           case 10 : epsC0= atof(a[9]);
126                           case 9  : epsnl = atof(a[8]);
127                           case 8  : {} break;
128                           default : return 1;
129                         } 
130                     LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
131                            TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen  );
132                     //LocalAnalysis::Dump(RES,cout);    
133                     Standard_SStream aSStream;
134                     LocalAnalysis::Dump(RES,aSStream);    
135                     di << aSStream;
136                   }
137                   break;
138
139          
140         default : {} 
141        }
142    return 0; 
143 }
144
145 /*********************************************************************************/
146
147 static Standard_Integer surfaceGcontinuity (Draw_Interpretor& di, Standard_Integer n, const char** a)
148 { Standard_Real U1, U2, V1, V2,u1, u2, v1, v2;
149   GeomAbs_Shape TypeCont; 
150   Standard_Integer ord;
151   Standard_Boolean b1, b2, b3, b4;
152   Standard_Real epsnl,epsC0,epsC1,epsC2,epsG1,maxlen,perce;
153   
154   if (n<8) return 1;
155   InitEpsSurf(epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen);
156
157   Handle(Geom_Surface) surf1 = DrawTrSurf::GetSurface(a[2]);
158   if (surf1.IsNull()) return 1 ;
159   
160   Handle(Geom_Surface) surf2 = DrawTrSurf::GetSurface(a[5]);
161   if (surf2.IsNull()) return 1;
162    
163       U1 = atof(a[3]);
164       U2 = atof(a[6]);
165       V1 = atof(a[4]); 
166       V2 = atof(a[7]); 
167
168       ord = atoi(a[1]);
169
170       surf1->Bounds(u1, u2, v1, v2);
171       b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
172       b3 = ((((V1>=v1)&&(V1<=v2))||((V1<=v1)&&(V1>=v2))));
173
174       surf2->Bounds(u1, u2, v1, v2);
175       b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
176       b4 = ((((V2>=v1)&&(V2<=v2))||((V2<=v1)&&(V2>=v2))));
177      
178       if (!((b1 && b2)&&(b3 && b4))) return 1;
179
180  
181        switch ( ord )
182        { 
183          case 1 : { TypeCont=GeomAbs_G1;
184                      switch(n)
185                          { case 11 : epsG1=atof(a[10]); 
186                           case 10  : epsC0= atof(a[9]);
187                           case 9  : epsnl = atof(a[8]);
188                           case 8  : {} break;
189                           default : return 1;
190                         } 
191                    LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
192                       TypeCont,epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen );
193                     //LocalAnalysis::Dump(RES,cout);
194                     Standard_SStream aSStream;
195                     LocalAnalysis::Dump(RES,aSStream);
196                     di << aSStream;
197     
198                   } 
199                   break;
200          case 2 : { TypeCont=GeomAbs_G2;
201                     switch(n)
202                       {   case 13 : maxlen =atof (a[12]);
203                           case 12 :  perce=atof(a[11]); 
204                           case 11 : epsG1=atof(a[10]); 
205                           case 10 : epsC0= atof(a[9]);
206                           case 9  : epsnl = atof(a[8]);
207                           case 8  : {} break;
208                           default : return 1;
209                         } 
210                    LocalAnalysis_SurfaceContinuity RES (surf1, U1, V1, surf2, U2, V2, 
211                           TypeCont, epsnl,epsC0,epsC1,epsC2,epsG1,perce,maxlen  ); 
212                     //LocalAnalysis::Dump(RES,cout);
213                     Standard_SStream aSStream;
214                     LocalAnalysis::Dump(RES,aSStream);
215                     di << aSStream;
216                   }
217                   break;
218
219          
220         default : {} 
221        }
222    return 0;  
223 }
224
225 /*********************************************************************************/
226
227 static Standard_Integer curveGcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
228 { Standard_Real U1, U2, u1, u2;
229   GeomAbs_Shape  TypeCont; 
230   Standard_Integer ord;
231   Standard_Boolean b1, b2;
232   Standard_Real  epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
233   if (n<6) return 1; 
234   
235   Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
236   if (curv1.IsNull()) return 1;
237   Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
238   if (curv2.IsNull()) return 1;
239
240   U1 = atof(a[3]);
241   U2 = atof(a[5]);
242  
243   ord = atoi(a[1]);
244
245   u1=curv1->FirstParameter();
246   u2=curv1->LastParameter();
247   b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
248    
249   u1=curv2->FirstParameter();
250   u2=curv2->LastParameter();   
251   b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
252      
253   if (!(b1 && b2)) return 1;
254
255   InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
256   switch ( ord )
257        { 
258           case 1 : {
259                     switch(n)
260                         { case 9 :  epsG1=atof(a[8]); 
261                           case 8  : epsC0= atof(a[7]);
262                           case 7  : epsnl = atof(a[6]);
263                           case 6  : {} break;
264                           default : return 1;
265                         }                         
266                     TypeCont=GeomAbs_G1;
267                     LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont, 
268                     epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen  );
269                     //LocalAnalysis::Dump(RES,cout); 
270                     Standard_SStream aSStream;
271                     LocalAnalysis::Dump(RES,aSStream); 
272                     di << aSStream;
273                   } 
274                   break;
275          case 2 : { 
276                     TypeCont=GeomAbs_G2;
277                     switch(n)
278                        {case 12 :maxlen =atof(a[11]);
279                         case  11 :percent=atof(a[10]);
280                         case 10 : epsG2= atof(a[9]); 
281                         case 9 : epsG1=atof(a[8]); 
282                         case 8  : epsC0= atof(a[7]);
283                         case 7  : epsnl = atof(a[6]);
284                         case 6  : {} break;
285                         default : return 1;
286                         } 
287                      LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont,
288                          epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen  );
289                      //LocalAnalysis::Dump(RES,cout);   
290                     Standard_SStream aSStream;
291                     LocalAnalysis::Dump(RES,aSStream);   
292                     di << aSStream;
293                   }
294                   break; 
295         default : {}
296        }
297     return 0; 
298     }
299
300 /*********************************************************************************/
301
302 static Standard_Integer curveCcontinuity(Draw_Interpretor& di, Standard_Integer n, const char** a)
303 { Standard_Real U1, U2, u1, u2;
304   GeomAbs_Shape  TypeCont; 
305   Standard_Integer ord;
306   Standard_Boolean b1, b2;
307   Standard_Real  epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, maxlen,percent;
308   if (n<6) return 1; 
309   
310   Handle(Geom_Curve) curv1 = DrawTrSurf::GetCurve(a[2]);
311   if (curv1.IsNull()) return 1;
312   Handle(Geom_Curve) curv2 = DrawTrSurf::GetCurve(a[4]);
313   if (curv2.IsNull()) return 1;
314
315    U1 = atof(a[3]);
316    U2 = atof(a[5]);
317  
318    ord = atoi(a[1]);
319
320    u1=curv1->FirstParameter();
321    u2=curv1->LastParameter();
322    b1 = ((((U1>=u1)&&(U1<=u2))||((U1<=u1)&&(U1>=u2))));
323    
324    u1=curv2->FirstParameter();
325    u2=curv2->LastParameter();   
326    b2 = ((((U2>=u1)&&(U2<=u2))||((U2<=u1)&&(U2>=u2))));
327      
328    if (!(b1 && b2)) return 1;
329
330
331    InitEpsCurv( epsnl,epsC0, epsC1, epsC2, epsG1, epsG2, percent,maxlen);
332    switch ( ord )
333        { case 0 : {  switch(n)
334                         { case 8  : epsC0= atof(a[7]);
335                           case 7  : epsnl = atof(a[6]);
336                           case 6  : {} break;
337                           default : return 1;
338                         }                     
339                       TypeCont=GeomAbs_C0;
340                       LocalAnalysis_CurveContinuity  RES (curv1, U1, curv2, U2, TypeCont,
341                        epsnl,epsC0, epsC1, epsC2, epsG1,epsG2,percent,maxlen  );
342                      //LocalAnalysis::Dump(RES,cout);
343                      Standard_SStream aSStream;
344                      LocalAnalysis::Dump(RES,aSStream);
345                      di << aSStream;
346
347                    }  break;
348          case 1 : { switch(n)
349                         { case 9 : epsC1 =atof(a[8]);
350                           case 8  : epsC0= atof(a[7]);
351                           case 7  : epsnl = atof(a[6]);
352                           case 6  : {} break;
353                           default : return 1;
354                         }                          
355                     TypeCont=GeomAbs_C1;
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 2 : {  TypeCont=GeomAbs_C2;
365                      switch(n)
366                        {
367                           case 10 : epsC2= atof(a[9]); 
368                           case 9  : epsC1=atof(a[8]); 
369                           case 8  : epsC0= atof(a[7]);
370                           case 7  : epsnl = atof(a[6]);
371                           case 6  : {} break;
372                           default : return 1;
373                         } 
374                     LocalAnalysis_CurveContinuity RES (curv1, U1, curv2, U2, TypeCont, 
375                     epsnl,epsC0, epsC1, epsC2, epsG1, epsG2,percent,maxlen  );
376                     //LocalAnalysis::Dump(RES,cout);   
377                     Standard_SStream aSStream;
378                     LocalAnalysis::Dump(RES,aSStream);   
379                     di << aSStream;
380                   }
381                   break; 
382         default : {}
383        }
384     return 0;
385     }
386 /***************************************************************************/
387 void GeometryTest::ContinuityCommands( Draw_Interpretor& theCommands)
388 {
389   static Standard_Boolean loaded = Standard_False;
390   if ( loaded) return;
391   loaded = Standard_True;
392
393   DrawTrSurf::BasicCommands(theCommands);
394   const char* g;
395
396   g = "GEOMETRY curves and surfaces continuity analysis ";
397
398
399
400   theCommands.Add("surfaceCcontinuity",
401                   " surfaceCcontinuity   order surf1 parU1 parV1 surf2 parU2 parV2  [eps_nul[ epsC0 [epsC1 [epsC2]]]]",  
402                   __FILE__,
403                   surfaceCcontinuity ,g);
404
405   theCommands.Add("surfaceGcontinuity",
406                   " surfaceGcontinuity   order surf1 parU1 parV1 surf2 parU2 parV2  [eps_nul[ epsG0 [epsG1[percent [maxlen]]]]",  
407                   __FILE__,
408                   surfaceGcontinuity ,g);  
409
410   theCommands.Add("curveCcontinuity",
411                   "curveCcontinuity   order curv1 u1  curv2  u2   [epsnul  [epsC0 [epsC1  [epsC2 ]]]]  ",
412                   __FILE__,
413                   curveCcontinuity,g);
414
415  
416   theCommands.Add("curveGcontinuity",
417                   "curveGcontinuity   order  curv1 u1  curv2  u2   [epsnul  [epsG0  [epsG1  [epsG2 [percent  [maxlen ]]]]]] ",
418                    __FILE__,
419                   curveGcontinuity,g);
420 }
421
422
423
424
425
426
427
428