0023345: Crash when destroying OpenGl_Element
[occt.git] / src / QABugs / QABugs_3.cxx
1 // Created on: 2002-06-17
2 // Created by: QA Admin
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21 #include <QABugs.hxx>
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 #include<Draw_Interpretor.hxx>
26 #include<TopLoc_Location.hxx>
27 #include<TopoDS_Face.hxx>
28 #include<TopoDS.hxx>
29 #include<DBRep.hxx>
30 #include<Geom_Surface.hxx>
31 #include<BRep_Tool.hxx>
32 #include<GeomInt_IntSS.hxx>
33 #include<BRepBuilderAPI_MakeEdge.hxx>
34 #include <Standard_ErrorHandler.hxx>
35 #include<tcl.h>
36
37 static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
38 {
39   if(argc!=4)
40   {
41     di << "Usage : " << a[0] << " result Shape1 Shape2" << "\n";
42     return -1;
43   }
44
45   TopLoc_Location L1;
46   TopLoc_Location L2;
47   TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
48   TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
49   Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1);
50   Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2);
51   GeomInt_IntSS Inter;
52   Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
53   if (!Inter.IsDone()) {
54     di << "Intersection not done" << "\n";
55     return 1;
56   }
57   Standard_Integer nbsol = Inter.NbLines();
58   if(!nbsol) {
59     di << "The number of solutions is zero!"   << "\n";
60     return 0;
61   }
62   Handle(Geom_Curve) Sol = Inter.Line(1);
63   if(!Sol.IsNull()) {
64     DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol));
65       return 0;
66     } else di << "The first solution is Null!"   << "\n";
67
68   di << "fini" << "\n";
69   return 0;
70 }
71
72 #include<ViewerTest.hxx>
73 #include<AIS_InteractiveContext.hxx>
74 #include<AIS_Shape.hxx>
75   
76 static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
77 {
78   if(argc!=2)
79   {
80     di << "Usage : " << argv[0] << " shape" << "\n";
81     return -1;
82   }
83
84   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
85   if(myAISContext.IsNull()) {
86     di << "use 'vinit' command before " << argv[0] << "\n";
87     return -1;
88   }
89
90   TopoDS_Shape theShape =  DBRep::Get(argv[1]);
91
92   Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape ); 
93   myAISContext->Display( anAISShape, Standard_True );
94   myAISContext->OpenLocalContext(); 
95   myAISContext->ActivateStandardMode(TopAbs_FACE);
96   return 0;
97 }
98
99 static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
100 {
101   if(argc!=2)
102   {
103     di << "Usage : "<< argv[0] << " shape" << "\n";
104     return -1;
105   }
106
107   //  di.Eval("vinit");
108
109   TopoDS_Shape theShape =  DBRep::Get(argv[1]);
110
111 //  ViewerTest::GetAISContext(); 
112   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
113   if(myAISContext.IsNull()) {
114     di << "use 'vinit' command before " << argv[0] << "\n";
115     return -1;    
116   }
117   Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape ); 
118   myAISContext->Display( anAISShape, Standard_True );
119   myAISContext->OpenLocalContext(); 
120   myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
121 //  myAISContext->ActivateStandardMode(TopAbs_SOLID);
122 //  di.Eval("vfit");
123 //  cout << "vfini" << endl;
124   return 0;
125 }
126
127 #include<BRep_Builder.hxx>
128 #include<BRepTools_ShapeSet.hxx>
129 #include<BRepTools.hxx>
130 #include<BRepAdaptor_HSurface.hxx>
131 #include<TopOpeBRep_PointClassifier.hxx>
132 #include<Precision.hxx>
133 #ifdef WNT
134 #include<stdio.h>
135 #endif
136
137 static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
138   gp_Pnt2d uvSurf;
139   TopAbs_State state;
140   
141   if (argc == 3) {
142     // BUC60609 shape name
143   } else if ( argc == 5 ) {
144     // BUC60609 shape name U V
145   } else {
146     di << "Usage : "<< argv[0] << " shape name [U V]" << "\n";
147     return(-1);
148   }
149   
150   TCollection_AsciiString  aFilePath(argv[1]); 
151   
152   filebuf fic;
153   istream in(&fic);
154   if (!fic.open(aFilePath.ToCString(),ios::in)) {
155     di << "Cannot open file for reading : " << aFilePath << "\n";
156     return(-1);
157   }
158
159   TopoDS_Shape theShape;
160   char typ[255];
161   in >> typ;
162   if (!in.fail()) {
163     if( !strcmp(typ, "DBRep_DrawableShape") ){
164       BRep_Builder B;
165       BRepTools_ShapeSet S(B);
166       S.Read(in);
167       S.Read(theShape,in);
168     }else{
169       di << "Wrong entity type in " << aFilePath << "\n";
170       return(-1);
171     }
172   }
173
174   const TopoDS_Face &face = TopoDS::Face (theShape);
175
176   if(argc > 2){
177     DBRep::Set(argv[2],face);
178   }
179
180   Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
181   
182   BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
183
184   di << "The bounds of the trimmed face:" << "\n";
185   di << faceUMin << " <= U <= " << faceUMax << "\n";
186   di << faceVMin << " <= V <= " << faceVMax << "\n";
187   
188   Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
189   
190   TopOpeBRep_PointClassifier PClass;
191
192   di << "Now test the point classifier by inputting U,V values" << "\n";
193   di << "inside or outside the bounds displayed above" << "\n";
194   di << "Type stop to exit" << "\n";
195   
196   // Please register this:
197   // ***********************************************
198   // Note also that for periodic surfaces such as nimpod_1.topo,
199   // the U/V values may be +- 2pi compared to the actual face bounds
200   // (because U,V is probably coming from a Geom package routine).
201   // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
202   // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
203   // *************************************************
204
205   if (argc == 3) {
206     uvSurf = gp_Pnt2d(0.14,5.1);
207     state = PClass.Classify(face,uvSurf,Precision::PConfusion());
208     if(state == TopAbs_IN || state == TopAbs_ON){
209       di << "U=" << 0.14 << " V=" << 5.1 << "  classified INSIDE" << "\n";
210     }else{
211       di << "U=" << 0.14 << " V=" << 5.1 << "  classified OUTSIDE" << "\n";
212     }
213
214     uvSurf = gp_Pnt2d(1.28,5.1);
215     state = PClass.Classify(face,uvSurf,Precision::PConfusion());
216     if(state == TopAbs_IN || state == TopAbs_ON){
217       di << "U=" << 1.28 << " V=" << 5.1 << "  classified INSIDE" << "\n";
218     }else{
219       di << "U=" << 1.28 << " V=" << 5.1 << "  classified OUTSIDE" << "\n";
220     }
221   } else {
222     uvSurf = gp_Pnt2d(atof(argv[3]),atof(argv[4]));
223     state = PClass.Classify(face,uvSurf,Precision::PConfusion());
224     if(state == TopAbs_IN || state == TopAbs_ON){
225       di << "U=" << atof(argv[3]) << " V=" << atof(argv[4]) << "  classified INSIDE" << "\n";
226     }else{
227       di << "U=" << atof(argv[3]) << " V=" << atof(argv[4]) << "  classified OUTSIDE" << "\n";
228     }
229   }
230   return 0;
231 }
232
233
234 #if ! defined(WNT)
235 void stringerror(int state)
236 {
237  printf("%s",((state&ios::eofbit) !=0)? " [eof]": "");
238  printf("%s",((state&ios::failbit)!=0)? " [fail]":"");
239  printf("%s",((state&ios::badbit) !=0)? " [bad]": "");
240  printf("%s\n",(state==ios::goodbit)? " [ok]": "");
241 }
242
243
244 //#if defined(LIN)
245 //#include <strstream>
246 //#else
247 //#include <strstream.h>
248 //#endif
249 #ifdef HAVE_IOSTREAM
250 #include <iostream>
251 #include <sstream>
252 using namespace std;
253 #elif defined (HAVE_IOSTREAM_H)
254 #include <iostream.h>
255 #include <strstream.h>
256 #else
257 #error "check config.h file or compilation options: either HAVE_IOSTREAM or HAVE_IOSTREAM_H should be defined"
258 #endif
259 static int UKI61075(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** /*argv*/) {
260  double da,db;
261  char buffer1[128];
262 #ifndef USE_STL_STREAM
263  ostrstream stringout1(buffer1,sizeof(buffer1));
264  istrstream stringin1(buffer1,sizeof(buffer1));
265 #else
266  ostringstream stringout1(buffer1);
267  istringstream stringin1(buffer1); 
268 #endif
269  char buffer2[128];
270 #ifndef USE_STL_STREAM
271  ostrstream stringout2(buffer2,sizeof(buffer2));
272  istrstream stringin2(buffer2,sizeof(buffer2));
273 #else
274  ostringstream stringout2(buffer1);
275  istringstream stringin2(buffer1); 
276 #endif
277
278  stringout1.precision(17);
279  stringout2.precision(17);
280
281  da=-(DBL_MAX);
282  db=DBL_MAX;
283  printf("Valeurs originales :\n\t%.17lg %.17lg\n",da,db);
284
285  stringout1<<da<<' '<<db<<"\n";
286 #ifndef USE_STL_STREAM
287  buffer1[stringout1.pcount()]='\0';
288 #else
289  buffer1[stringout1.str().length()]= '\0' ;
290 #endif
291
292  printf("Valeurs ecrites dans le fichier :\n\t%s",buffer1);
293
294  da=db=0.;
295  stringin1>>da>>db;
296  printf("Valeurs relues :\n\t%.17lg %.17lg",da,db);
297  stringerror(stringin1.rdstate());
298
299  stringout2<<da<<' '<<db<<"\n";
300 #ifndef USE_STL_STREAM
301  buffer2[stringout2.pcount()]='\0';
302 #else
303  buffer2[stringout2.str().length()]='\0';
304 #endif
305
306  printf("Valeurs reecrites :\n\t%s",buffer2);
307
308  da=db=0.;
309  stringin2>>da>>db;
310  printf("Valeurs relues a nouveau :\n\t%.17lg %.17lg",da,db);
311  stringerror(stringin2.rdstate());
312  
313  return(0);
314 }
315 #endif
316
317 #include<BRepAlgoAPI_Section.hxx>
318 #include<BRepAlgo_Section.hxx>
319
320 #include<Geom_Plane.hxx>
321 #include<DrawTrSurf.hxx>
322
323 //static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane]";
324 static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane] [BRepAlgoAPI/BRepAlgo = 1/0]";
325
326 static int BUC60585(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
327   
328   //if(argc<2) {
329   //  cerr << "Usage : " << argv[0] << St << endl;
330   //  return -1;
331   //}
332   if(argc < 2 || argc > 6) {
333     di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
334     return 1;
335   }
336   Standard_Boolean IsBRepAlgoAPI = Standard_True;
337   if (argc == 6) {
338     Standard_Integer IsB = atoi(argv[5]);
339     if (IsB != 1) {
340       IsBRepAlgoAPI = Standard_False;
341 #if ! defined(BRepAlgo_def04)
342 //      di << "Error: There is not BRepAlgo_Section class" << "\n";
343 //      return 1;
344 #endif
345     }
346   }
347
348   
349   gp_Dir N;
350   if(!strcmp(argv[1],"trimsphere")) {
351 //////////////////////////////////////////
352 // Uncomment for trimmed sphere bug:
353 //    filename = "trimsphere.topo";
354     N=gp_Dir( 0.0, -1.0, 0.0 );
355 //////////////////////////////////////////
356   } else if(!strcmp(argv[1],"sphere")) {
357
358 //////////////////////////////////////////
359 // Uncomment for untrimmed sphere bug:
360
361 //    filename="sphere.topo";
362     N=gp_Dir( 0.0, -0.75103523489975432, -0.66026212668838646 );
363     
364 //////////////////////////////////////////
365   } else {
366     di << "Usage : " << argv[0] << St << "\n";
367     return -1;
368   }
369   
370   // MKV 30.03.05
371 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
372   const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
373 #else
374   Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
375 #endif
376
377   Standard_Character  *filename = new Standard_Character [strlen(DD)+17];
378   sprintf(filename,"%s/%s.topo",DD,argv[1]);
379
380   filebuf fic;
381   istream in(&fic);
382   if (!fic.open(filename,ios::in)) {
383     di << "Cannot open file for reading : " << filename << "\n";
384     delete [] filename;
385     return -1;
386   }
387   
388   // Read in the shape
389   
390   BRep_Builder B;
391   BRepTools_ShapeSet S(B);
392   S.Read(in);
393   TopoDS_Shape theShape;
394   S.Read(theShape,in);
395   
396   // Create the plane
397   
398   gp_Pnt O( 2036.25, -97.5, -1460.499755859375 );
399   gp_Dir A( 1.0,  0.0, 0.0 );
400   
401   gp_Ax3 PLA( O, N, A );
402   gp_Pln Pl(PLA);
403   
404   // Perform the section
405   
406 //#if ! defined(BRepAlgoAPI_def01)
407 //  BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
408 //#else
409 //  BRepAlgo_Section Sec( theShape, Pl, Standard_False);
410 //#endif
411
412   TopoDS_Shape res;
413   
414   try{
415     OCC_CATCH_SIGNALS
416 //      Sec.Approximation(Standard_True);
417
418     //Sec.Build();
419     //if(!Sec.IsDone()){
420     //  cout << "Error performing intersection: not done." << endl;
421     //  delete filename;
422     //  return -1;
423     //}
424     //res = Sec.Shape();
425
426     if (IsBRepAlgoAPI) {
427       di << "BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False)" <<"\n";
428       BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False);
429       Sec.Build();
430       if(!Sec.IsDone()){
431         di << "Error performing intersection: not done." << "\n";
432         delete [] filename;
433         return -1;
434       }
435       res = Sec.Shape();
436     } else {
437       di << "BRepAlgo_Section Sec( theShape, Pl, Standard_False)" <<"\n";
438       BRepAlgo_Section Sec( theShape, Pl, Standard_False);
439       Sec.Build();
440       if(!Sec.IsDone()){
441         di << "Error performing intersection: not done." << "\n";
442         delete [] filename;
443         return -1;
444       }
445       res = Sec.Shape();
446     }
447     
448   }catch(Standard_Failure){
449     Handle(Standard_Failure) error = Standard_Failure::Caught();
450     di << "Error performing intersection: not done." << "\n";
451     delete [] filename;
452     return -1;
453   }
454   
455   if(argc>3) DBRep::Set(argv[3],theShape);
456
457   if(argc>2) DBRep::Set(argv[2],res);
458
459   if(argc>4) {
460     Handle(Geom_Geometry) result;
461     Handle(Geom_Plane) C = new Geom_Plane(Pl);
462     result=C;
463     DrawTrSurf::Set(argv[4],result);
464   }
465   
466   di << "Done" << "\n";
467
468   delete [] filename;
469   
470   return 0;
471 }
472
473 #include<TopoDS_Compound.hxx>
474
475 static int BUC60547(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
476   if(argc!=2) {
477     di << "Usage : " << argv[0] << " name"   << "\n";
478     return -1;
479   }
480
481   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
482   if(myAISContext.IsNull()) {
483     di << "use 'vinit' command before " << argv[0] << "\n";
484     return -1;
485   }
486   
487   // MKV 30.03.05
488 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
489   const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
490 #else
491   Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
492 #endif
493
494   Standard_Character *Ch = new Standard_Character[strlen(argv[1])+3];
495
496   Standard_Character *FileName = new Standard_Character[strlen(DD)+13];
497  
498   TopoDS_Shape free_1,free_2,free_3,free_4;
499   BRep_Builder B;
500   sprintf(FileName,"%s/%s",DD,"buc60547a.brep");
501   BRepTools::Read(free_1,FileName,B);
502   sprintf(FileName,"%s/%s",DD,"buc60547b.brep");
503   BRepTools::Read(free_2,FileName,B);
504   sprintf(FileName,"%s/%s",DD,"buc60547c.brep");
505   BRepTools::Read(free_3,FileName,B);
506   sprintf(FileName,"%s/%s",DD,"buc60547d.brep");
507   BRepTools::Read(free_4,FileName,B);
508   sprintf(Ch,"%s_%i",argv[1],1);
509   DBRep::Set(Ch,free_1);
510   di << Ch << " ";
511   sprintf(Ch,"%s_%i",argv[1],2);
512   DBRep::Set(Ch,free_2);
513   di << Ch << " ";
514   sprintf(Ch,"%s_%i",argv[1],3);
515   DBRep::Set(Ch,free_3);
516   di << Ch << " ";
517   sprintf(Ch,"%s_%i",argv[1],4);
518   DBRep::Set(Ch,free_4);
519   di << Ch << " ";
520   
521 //  Handle(AIS_Shape) S1 = new AIS_Shape(free_1); 
522 //  Handle(AIS_Shape) S2 = new AIS_Shape(free_2); 
523 //  Handle(AIS_Shape) S3 = new AIS_Shape(free_3); 
524 //  Handle(AIS_Shape) S4 = new AIS_Shape(free_4);
525   
526 //  Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
527
528 //  myAISContext->Display(S1); 
529 //  myAISContext->Display(S2); 
530 //  myAISContext->Display(S3); 
531 //  myAISContext->Display(S4);
532
533 //  di.Eval("vfit");
534   
535   TopoDS_Compound Com; 
536   BRep_Builder bui;
537   bui.MakeCompound(Com); 
538   bui.Add(Com,free_1); 
539   bui.Add(Com,free_2); 
540   bui.Add(Com,free_3); 
541   bui.Add(Com,free_4); 
542
543   sprintf(Ch,"%s_%c",argv[1],'c');
544   DBRep::Set(Ch,Com);
545   di << Ch << " ";
546
547   Handle(AIS_Shape) SC = new AIS_Shape(Com);
548   myAISContext->Display(SC); // nothing on the screen If I save the compound :
549
550   sprintf(FileName,"%s/%s",DD,"free.brep");
551
552   BRepTools::Write(Com,FileName); 
553
554   delete [] Ch;
555   delete [] FileName;
556   
557   return 0;
558 }
559
560 #include<BRepBuilderAPI_MakeVertex.hxx>
561 #include<TCollection_ExtendedString.hxx>
562 #include<AIS_LengthDimension.hxx>
563
564 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
565 {
566   
567   Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
568   if(myAIScontext.IsNull()) {
569     di << "use 'vinit' command before " << a[0] << "\n";
570     return -1;
571   }
572   myAIScontext->EraseAll();
573   
574   TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0)); 
575   TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0)); 
576   
577   Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
578   Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
579   
580   myAIScontext->Display(Ve1); 
581   myAIScontext->Display(Ve2); 
582   
583   Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1)); 
584   TCollection_ExtendedString Ext1("Dim1"); 
585   Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1,atof(a[2]),Ext1); 
586   
587   myAIScontext->SetDisplayMode(Dim1, atoi(a[1]));
588   myAIScontext->Display(Dim1);
589   return 0;
590 }
591
592 #include<TopoDS_Wire.hxx>
593
594 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
595 {
596   if(argc!=2) {
597     di << "Usage : BUC60652 fase"   << "\n";
598     return 1;
599   }
600   TopoDS_Shape shape = DBRep::Get( argv[1] ); 
601   TopoDS_Face face = TopoDS::Face( shape ); 
602   TopoDS_Wire ow = BRepTools::OuterWire( face ); 
603   DBRep::Set( "w", ow ); 
604   return 0; 
605 }
606
607 #include <BRepAlgo_BooleanOperations.hxx>
608   
609 static Standard_Integer defNbPntMax = 30;
610 static Standard_Real defTol3d = 1.e-7;
611 static Standard_Real defTol2d = 1.e-7;
612 static Standard_Boolean defRelativeTol=Standard_True;
613 Standard_Integer NbPntMax = defNbPntMax;
614 Standard_Real Toler3d =defTol3d;
615 Standard_Real Toler2d = defTol2d;
616 Standard_Boolean RelativeTol= defRelativeTol;
617 //              //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
618 //== // ksection : operateur section appelant BRepAlgo_BooleanOperations
619 //=======================================================================
620 Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
621   if (n < 8) {
622     di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol"   << "\n";
623     return -1;
624   }
625   // a[1]= resultat
626   // a[2]= shell1
627   // a[3]= shell2
628   // a[4]= NbPntMax
629   // a[5]= Toler3d
630   // a[6]= Toler2d
631   // a[7]= RelativeTol
632   TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
633   TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
634   if (s1.IsNull() || s2.IsNull()) return 1;
635   NbPntMax=atoi(a[4]);
636   Toler3d=atof(a[5]);
637   Toler2d=atof(a[6]);
638   RelativeTol=atoi(a[7]);
639
640   di << "BRepAlgo_BooleanOperations myalgo" << "\n";
641   BRepAlgo_BooleanOperations myalgo;
642
643   myalgo.Shapes(s1, s2);
644   myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol);
645   TopoDS_Shape res; res = myalgo.Section();
646   DBRep::Set(a[1],res);
647   return 0;
648 }
649
650 #include <Geom_Axis2Placement.hxx>
651 #include <AIS_Trihedron.hxx>
652
653 static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
654 {
655   
656   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
657   if(myAISContext.IsNull()) {
658     di << "use 'vinit' command before " << a[0] << "\n";
659     return -1;
660   }
661   
662   Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY()); 
663   Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis); 
664   gp_Trsf aTrsf; 
665   gp_Vec trans(5,5,5); 
666   aTrsf.SetTranslation(trans); 
667   TopLoc_Location aLoc(aTrsf); 
668   myAISContext->SetLocation(atri,aLoc); 
669   myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
670   myAISContext->OpenLocalContext(Standard_False, 
671                                  Standard_True,Standard_False,Standard_False); 
672   myAISContext->Load(atri,3,Standard_True);
673
674   return 0;
675 }
676
677 #include <TopoDS_Solid.hxx>
678 #include <BRepPrimAPI_MakeBox.hxx>
679 #include <BRepPrimAPI_MakeSphere.hxx>
680
681 #include <BRepAlgoAPI_Fuse.hxx>
682 #include <BRepAlgo_Fuse.hxx>
683
684 #include <V3d_Plane.hxx>
685 #include <V3d_View.hxx>
686 #include <gce_MakePln.hxx>
687
688 static Standard_Integer BUC60698(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
689 {
690   if(argc > 2) {
691     di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
692     return 1;
693   }
694   Standard_Boolean IsBRepAlgoAPI = Standard_True;
695   if (argc == 2) {
696     Standard_Integer IsB = atoi(a[1]);
697     if (IsB != 1) {
698       IsBRepAlgoAPI = Standard_False;
699 #if ! defined(BRepAlgo_def01)
700 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
701 //      return 1;
702 #endif
703     }
704   }
705   
706   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
707   if(myAISContext.IsNull()) {
708     di << "use 'vinit' command before " << a[0] << "\n";
709     return -1;
710   }
711   TopoDS_Solid box = BRepPrimAPI_MakeBox(1,1,1).Solid();
712   TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(gp_Pnt(0.5,0.5,0.5),0.6).Shape();
713
714 //#if ! defined(BRepAlgoAPI_def01)
715 //  TopoDS_Shape fuse = BRepAlgoAPI_Fuse(box,sphere).Shape();
716 //#else
717 //  TopoDS_Shape fuse = BRepAlgo_Fuse(box,sphere).Shape();
718 //#endif
719
720   TopoDS_Shape fuse;
721   if (IsBRepAlgoAPI) {
722     di << "fuse = BRepAlgoAPI_Fuse(box,sphere).Shape()" <<"\n";
723     fuse = BRepAlgoAPI_Fuse(box,sphere).Shape();
724   } else {
725     di << "fuse = BRepAlgo_Fuse(box,sphere).Shape()" <<"\n";
726     fuse = BRepAlgo_Fuse(box,sphere).Shape();
727   }
728
729   Handle_AIS_Shape theAISShape = new AIS_Shape(fuse);
730   myAISContext->Display(theAISShape);
731   di.Eval("vfit");
732   gp_Pln thegpPln = gce_MakePln(gp_Pnt(0.5,0.5,0.5),gp_Dir(0,0,1));
733   Standard_Real A,B,C,D;
734   thegpPln.Coefficients(A,B,C,D);
735   Handle_V3d_Plane thePlane = new V3d_Plane(A,B,C,D);
736   myAISContext->CurrentViewer()->AddPlane (thePlane); // add to defined planes list
737   for (myAISContext->CurrentViewer()->InitActiveViews();
738        myAISContext->CurrentViewer()->MoreActiveViews ();
739        myAISContext->CurrentViewer()->NextActiveViews ()) {
740     try {
741       OCC_CATCH_SIGNALS
742       myAISContext->CurrentViewer()->ActiveView()->SetPlaneOn(thePlane);
743     }
744     catch(Standard_Failure) {
745       di << "SetPlaneOn catched 1" << "\n";
746     }
747 #ifdef WNT
748     catch(...) {
749       di << "SetPlaneOn catched 1" << "\n";
750     }
751 #endif
752   }//ActiveView loop
753   for (myAISContext->CurrentViewer()->InitDefinedViews();
754        myAISContext->CurrentViewer()->MoreDefinedViews ();
755        myAISContext->CurrentViewer()->NextDefinedViews ()) {
756     try {
757       OCC_CATCH_SIGNALS
758       myAISContext->CurrentViewer()->DefinedView()->SetPlaneOn(thePlane);
759     }
760     catch(Standard_Failure) {
761       di << "SetPlaneOn catched 1" << "\n";
762     }
763 #ifdef WNT
764     catch(...) {
765       di << "SetPlaneOn catched 2" << "\n";
766     }
767 #endif
768   }//DefinedView loop
769   myAISContext->UpdateCurrentViewer();
770   myAISContext->OpenLocalContext();
771   myAISContext->ActivateStandardMode(TopAbs_FACE);
772   return 0;
773 }
774
775 static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
776 {
777   
778   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
779   if(myAISContext.IsNull()) {
780     di << "use 'vinit' command before " << a[0] << "\n";
781     return -1;
782   }
783   TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
784   TopAbs_ShapeEnum theType = B1.ShapeType();
785   if ( theType == TopAbs_SOLID ) {
786     di << "It is a solid."   << "\n";
787   } else {
788     di << "It is not solid."   << "\n";
789   }
790   myAISContext->Display(new AIS_Shape(B1)); 
791   myAISContext->OpenLocalContext();
792   TopAbs_ShapeEnum amode = TopAbs_SOLID;
793   myAISContext->ActivateStandardMode(amode);
794   di.Eval("vfit");
795   di.Eval("QAMoveTo 200 200");
796   di.Eval("QASelect 200 200");
797   myAISContext->InitSelected() ;
798   if ( myAISContext->MoreSelected() ) {
799     if (myAISContext->HasSelectedShape() ) {
800       di << "has selected shape : OK"   << "\n";
801     } else {
802       di << "has selected shape : bugged - Faulty "   << "\n";
803     }
804   }
805   return 0;
806 }
807
808 static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
809 {
810   if(argc > 2) {
811     di << "Usage : " << argv[0] << " [1/0]" << "\n";
812     return -1;
813   }
814   
815   Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
816   if(myAIScontext.IsNull()) {
817     di << "use 'vinit' command before " << argv[0] << "\n";
818     return -1;
819   }
820   Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
821   
822   if((argc == 2) && (atof(argv[1]) == 0))
823     myV3dView->SetAntialiasingOff();
824   else
825     myV3dView->SetAntialiasingOn();
826   myV3dView->Update();
827   return 0;
828 }
829
830
831 #define DEFAULT_COLOR    Quantity_NOC_GOLDENROD
832
833 //=======================================================================
834 //function : GetColorFromName
835 //purpose  : get the Quantity_NameOfColor from a string
836 //=======================================================================
837
838 static Quantity_NameOfColor GetColorFromName( const char *name ) 
839
840   Quantity_NameOfColor ret = DEFAULT_COLOR;
841   
842   Standard_Boolean Found = Standard_False;
843   Standard_CString colstring;
844   for(Standard_Integer i=0;i<=514 && !Found;i++)
845     {
846       colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
847       if (!strcasecmp(name,colstring)) {
848         ret = (Quantity_NameOfColor)i;
849         Found = Standard_True;
850       }
851     }
852   
853   return ret;
854 }
855    
856 static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
857 {
858
859 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
860 if(myAISContext.IsNull()) { 
861     di << "use 'vinit' command before " << argv[0] << "\n";
862     return -1;
863   }
864
865 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
866
867 switch (argc){
868
869  case 2:
870    {
871      di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
872 //   setcolor <name> 
873 //   Change the background color of the view with a predefined name Graphic3d_NOC_<name>  
874
875      myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
876      myV3dView -> Redraw();
877    break;
878    }
879
880  case 3:
881    {
882      di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
883 //   setcolor <object> <name> 
884 //   Change the object color with a predefined name 
885
886      TopoDS_Shape aShape = DBRep::Get(argv[1]);
887      Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
888      myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
889      myAISContext->Display(myShape,Standard_True);
890      myAISContext->UpdateCurrentViewer();
891 //     return 0;
892    break;
893    }
894  case 4:
895    {
896      di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
897
898 //   setcolor <r> <g> <b> 
899 //   Change the background color of the view with the color values <r>,<g>,<b> 
900 //   A color value must be defined in the space [0.,1.] 
901
902      Standard_Real QuantityOfRed   = atoi(argv[1]);
903      Standard_Real QuantityOfGreen = atoi(argv[2]);
904      Standard_Real QuantityOfBlue  = atoi(argv[3]);
905      myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
906      myV3dView->Redraw();
907    break;
908    }
909
910  case 5:
911    {
912     di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
913
914 //  setcolor <object> <r> <g> <b> 
915 //  change the object color with RGB values. 
916
917
918     Standard_Real QuantityOfRed   = atof(argv[2]);
919     Standard_Real QuantityOfGreen = atof(argv[3]);
920     Standard_Real QuantityOfBlue  = atof(argv[4]);
921
922     TopoDS_Shape aShape = DBRep::Get(argv[1]);
923     Handle(AIS_InteractiveObject) myShape =  new AIS_Shape (aShape);
924     myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
925     myAISContext->Display(myShape,Standard_True);
926     myAISContext->UpdateCurrentViewer();
927 //  myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
928 //  myShape->Redisplay();
929    break;
930    }
931  }
932 return 0;
933 }
934
935 static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
936 {
937   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
938   if(myAISContext.IsNull()) { 
939     di << "use 'vinit' command before " << argv[0] << "\n";
940     return -1;
941   }
942   
943   if(argc != 2) {
944     di << "Usage : " << argv[0] << " 0/1" << "\n";
945   }
946
947   if(atoi(argv[1]) == 0) {
948     myAISContext->CloseAllContexts();
949     BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
950     Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
951     myAISContext->Display(aBox);
952   } else if(atoi(argv[1]) == 1) {
953     myAISContext->CloseAllContexts();
954     myAISContext->OpenLocalContext();
955     myAISContext->ActivateStandardMode(TopAbs_EDGE);
956   } else if(atoi(argv[1]) == 2) {
957     myAISContext->CloseAllContexts();
958     myAISContext->OpenLocalContext();
959     myAISContext->ActivateStandardMode(TopAbs_FACE);
960   } else {
961     di << "Usage : " << argv[0] << " 0/1" << "\n";
962     return -1;
963   }
964   
965   return 0;
966 }
967
968 #include <BRepBndLib.hxx>
969 #include <Bnd_HArray1OfBox.hxx>
970   
971 static Standard_Integer BUC60729 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** /*argv*/ )
972 {
973   Bnd_Box aMainBox;
974   TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
975
976   BRepBndLib::Add(aShape , aMainBox );
977
978   Standard_Integer siMaxNbrBox = 6;
979   Bnd_BoundSortBox m_BoundSortBox;
980   m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
981   TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
982   Standard_Integer i;
983
984
985 //  Bnd_Box __emptyBox; // Box is void !
986 //  Handle_Bnd_HArray1OfBox __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox ); 
987
988   for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ ) 
989     { 
990       const TopoDS_Shape& aFace = aExplorer.Current();
991       Bnd_Box aBox;
992       BRepBndLib::Add( aFace, aBox );
993       m_BoundSortBox.Add( aBox, i );
994 //      __aSetOfBox->SetValue( i, aBox ); 
995     } 
996 //  m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
997   
998   return 0;
999 }
1000
1001 static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
1002 {
1003   TCollection_AsciiString as1("");
1004   TCollection_AsciiString as2('\0');
1005   if((as1.ToCString()!=NULL) || (as1.ToCString() != ""))
1006     di << "Faulty : the first string is not zero string : " << as1.ToCString() << "\n";
1007
1008   if((as2.ToCString()!=NULL) || (as2.ToCString() != ""))
1009     di << "Faulty : the second string is not zero string : " << as2.ToCString() << "\n";
1010   
1011   return 0;
1012 }
1013
1014 #include <UnitsAPI.hxx>
1015
1016 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
1017 {
1018 di <<"Program Test" << "\n";
1019 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm 
1020 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG. 
1021
1022    return 0;
1023 }
1024
1025 #include <gp_Circ.hxx>
1026 #include <Geom_Circle.hxx>
1027 #include <GeomAPI.hxx>
1028 #include <Geom2d_CartesianPoint.hxx>
1029 #include <Geom2dGcc_QualifiedCurve.hxx>
1030 #include <Geom2dGcc_Circ2d2TanRad.hxx>
1031 #include <Geom2d_Circle.hxx>
1032 #include <ProjLib.hxx>
1033
1034 static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1035 {
1036   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1037   if(aContext.IsNull()) { 
1038     di << "use 'vinit' command before " << argv[0] << "\n";
1039     return -1;
1040   }
1041
1042   gp_Pnt pt3d(0, 20, 150);
1043   gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
1044   gp_Circ circ(anAx2, 50.0); 
1045   Handle_Geom_Circle gcir = new Geom_Circle(circ); 
1046   Handle_Geom_Plane pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0))); 
1047   Handle_Geom2d_Curve gcir1 = GeomAPI::To2d(gcir, pln->Pln()); 
1048   TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape(); 
1049   Handle_AIS_Shape ais1 = new AIS_Shape(sh1); 
1050   aContext->SetColor(ais1, Quantity_NOC_INDIANRED); 
1051   aContext->Display(ais1); 
1052   DBRep::Set("sh0",sh1);
1053   gp_Pnt2d thepoint; 
1054 //  local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint); 
1055   thepoint = ProjLib::Project(pln->Pln(),pt3d);
1056   Handle_Geom2d_CartesianPoint ThePoint = new Geom2d_CartesianPoint(thepoint); 
1057   Geom2dAdaptor_Curve acur1(gcir1) ; 
1058   Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ; 
1059   Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001); 
1060   printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions()); 
1061   Handle_Geom2d_Circle gccc; 
1062   if( cirtanrad.NbSolutions() ) { 
1063     for( int i = 1; i<=cirtanrad.NbSolutions(); i++) { 
1064       gp_Circ2d ccc = cirtanrad.ThisSolution(i); 
1065       gccc = new Geom2d_Circle(ccc); 
1066       TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
1067       Standard_Character aStr[5];
1068       sprintf(aStr,"sh%d",i);
1069       DBRep::Set(aStr,sh);
1070       Handle_AIS_Shape ais = new AIS_Shape(sh); 
1071       if( i ==1 ) 
1072         aContext->SetColor(ais, Quantity_NOC_GREEN); 
1073       if( i == 2) 
1074         aContext->SetColor(ais, Quantity_NOC_HOTPINK); 
1075       aContext->Display(ais); 
1076       Standard_Real ParSol1, ParSol2, ParArg1, ParArg2; 
1077       gp_Pnt2d PntSol1, PntSol2; 
1078       cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
1079       printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
1080       cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2); 
1081       printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
1082     }
1083   }
1084   return 0;
1085 }
1086
1087 #include <TColgp_Array2OfPnt.hxx>
1088 #include <Geom_BezierSurface.hxx>
1089 #include <BRepBuilderAPI_MakeFace.hxx>
1090 #include <BRepBuilderAPI_MakeWire.hxx>
1091 #include <Geom_OffsetSurface.hxx>
1092 #include <BRepFilletAPI_MakeFillet2d.hxx>
1093 #include <GeomProjLib.hxx>
1094 #include <Geom_TrimmedCurve.hxx>
1095
1096 static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1097 {
1098   if(argc == 4) {
1099     TopLoc_Location L1;
1100     TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
1101     TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
1102     Standard_Real f = 0.0, l = 0.0; 
1103     Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
1104     Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
1105     GC = new Geom_TrimmedCurve(GC, f, l); 
1106     Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS); 
1107     BRepBuilderAPI_MakeWire *myWire; 
1108     myWire = new BRepBuilderAPI_MakeWire(); 
1109     myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
1110     DBRep::Set(argv[1],myWire->Wire());
1111     return  0;
1112   }
1113   
1114   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1115   if(aContext.IsNull()) { 
1116     di << "use 'vinit' command before " << argv[0] << "\n";
1117     return -1;
1118   }
1119   
1120 //step 1. creating a Bezier Surface and a patch 
1121   TopoDS_Face FP; 
1122   TopoDS_Shape FP1; 
1123   TopoDS_Solid solid; 
1124   Handle(AIS_Shape) ais1; 
1125   Handle_AIS_Shape ais2; 
1126   Handle(Geom_BezierSurface) BZ1;
1127   TColgp_Array2OfPnt array1(1,3,1,3);
1128   array1.SetValue(1,1,gp_Pnt(0,100,0));
1129   array1.SetValue(1,2,gp_Pnt(200,100,0));
1130   array1.SetValue(1,3,gp_Pnt(400,100,0)); 
1131   array1.SetValue(2,1,gp_Pnt(0,200,100)); 
1132   array1.SetValue(2,2,gp_Pnt(200,200,100)); 
1133   array1.SetValue(2,3,gp_Pnt(400,200,100)); 
1134   array1.SetValue(3,1,gp_Pnt(0,300,0)); 
1135   array1.SetValue(3,2,gp_Pnt(200,300,0)); 
1136   array1.SetValue(3,3,gp_Pnt(400,300,0)); 
1137   BZ1 = new Geom_BezierSurface(array1);
1138   BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
1139   TopoDS_Face F1= bzf1.Face();
1140   ais1 = new AIS_Shape(F1);
1141   DBRep::Set("F1",F1);
1142   aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
1143   aContext->Display(ais1);
1144   BRep_Builder B;
1145   TopoDS_Shell shell;
1146   B.MakeShell(shell);
1147   B.Add(shell, bzf1); 
1148   B.MakeSolid(solid);
1149   B.Add(solid,shell); 
1150   gp_Dir D(0, 0, 1.0f); 
1151   BRepBuilderAPI_MakeWire mkw; 
1152   gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
1153   gp_Pnt p2 = gp_Pnt(350., 150., 260.); 
1154   BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2); 
1155   mkw.Add(*E1); 
1156   p1 = gp_Pnt(350., 150., 260.); 
1157   p2 = gp_Pnt(350., 250., 260.); 
1158   BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2); 
1159   mkw.Add(*E2); 
1160   p1 = gp_Pnt(350., 250., 260.); 
1161   p2 = gp_Pnt(300., 250.0, 260.); 
1162   BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
1163   mkw.Add(*E3); 
1164   p1 = gp_Pnt(300., 250.0, 260.); 
1165   p2 = gp_Pnt(200., 200.0, 260.); 
1166   BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2); 
1167   mkw.Add(*E4); 
1168   p1 = gp_Pnt(200., 200.0, 260.); 
1169   p2 = gp_Pnt(150., 200.0, 260.); 
1170   BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
1171   mkw.Add(*E5); 
1172   p1 = gp_Pnt(150., 200.0, 260.); 
1173   p2 = gp_Pnt(150., 150.0, 260.); 
1174   BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
1175   mkw.Add(*E6); 
1176   FP = BRepBuilderAPI_MakeFace(mkw.Wire()); 
1177   ais2 = new AIS_Shape( FP ); 
1178   aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False); 
1179   aContext->Display( ais2 );
1180
1181   DBRep::Set("FP",FP);
1182   
1183 //step 2. offseting the surface. 
1184   Handle_Geom_OffsetSurface offsurf; 
1185   offsurf = new Geom_OffsetSurface(BZ1, -100); 
1186   BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() ); 
1187   TopoDS_Face F2= bzf2.Face(); 
1188   Handle_AIS_Shape ais22 = new AIS_Shape(F2); 
1189   aContext->Display(ais22); 
1190   DBRep::Set("F2",F2);
1191   
1192 //step 3. filleting the patch. 
1193 //( I want to project wire of this patch on offseted surface above) 
1194   BRepFilletAPI_MakeFillet2d fillet( FP ); 
1195   TopExp_Explorer Ex; 
1196   Ex.Init(FP, TopAbs_VERTEX); 
1197   TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current()); 
1198   fillet.AddFillet(v1, 20); 
1199   di << "\n" << "Error is " << fillet.Status() << "\n";
1200 //  printf("\nError is %d ", fillet.Status()); 
1201   Ex.Next(); 
1202   TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current()); 
1203   fillet.AddFillet(V2, 20); 
1204   di << "\n" << "Error is " << fillet.Status() << "\n";
1205 //  printf("\nError is %d ", fillet.Status());
1206   fillet.Build(); 
1207   FP1 = fillet.Shape(); 
1208   ais2 = new AIS_Shape( FP1 ); 
1209   aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False); 
1210   aContext->Display( ais2 ); 
1211
1212   DBRep::Set("FP1",FP1);
1213   
1214 //step 4. Projecting the wire of this patch on offsetted surface. 
1215 //  TopExp_Explorer Ex; 
1216   BRepBuilderAPI_MakeWire *myWire; 
1217   myWire = new BRepBuilderAPI_MakeWire(); 
1218   for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next()) 
1219     { 
1220       TopoDS_Edge e1 = TopoDS::Edge(Ex.Current()); 
1221       Standard_Real f = 0.0, l = 0.0; 
1222       Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l);
1223       newBSplin = new Geom_TrimmedCurve(newBSplin, f, l); 
1224       Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf); 
1225       myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge()); 
1226     } 
1227   Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() ); 
1228   aContext->Display(ais33);
1229
1230   DBRep::Set("Wire",myWire->Wire());
1231   
1232   return 0;
1233 }
1234
1235 #include<GeomAPI_ExtremaCurveCurve.hxx>
1236
1237 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1238
1239 {
1240   if(argc < 3){
1241     printf("Usage: %s edge1 edge2",argv[0]);
1242     return(-1);
1243   }
1244  
1245         TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
1246         E2 = TopoDS::Edge(DBRep::Get(argv[2]));
1247
1248         Standard_Real fp , lp;
1249
1250         Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
1251         C2 = BRep_Tool::Curve(E2 , fp , lp);
1252
1253         GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
1254
1255         di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
1256
1257         return 0;
1258 }
1259
1260 #include <BRepBuilderAPI_MakePolygon.hxx>
1261 #include <BRepOffsetAPI_ThruSections.hxx>
1262
1263 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1264 {
1265   if(argc > 2) {
1266     di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1267     return 1;
1268   }
1269   Standard_Boolean IsBRepAlgoAPI = Standard_True;
1270   if (argc == 2) {
1271     Standard_Integer IsB = atoi(argv[1]);
1272     if (IsB != 1) {
1273       IsBRepAlgoAPI = Standard_False;
1274 #if ! defined(BRepAlgo_def01)
1275 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1276 //      return 1;
1277 #endif
1278     }
1279   }
1280
1281   double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
1282   double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
1283   double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
1284   double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
1285   BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
1286   gp_Pnt tmppnt;
1287   for (int i=0;i<4;i++) {
1288     tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
1289     bottompolygon1.Add(tmppnt);
1290     tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
1291     toppolygon1.Add(tmppnt);
1292     tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
1293     bottompolygon2.Add(tmppnt);
1294     tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
1295     toppolygon2.Add(tmppnt);
1296   }
1297   bottompolygon1.Close();
1298   DBRep::Set("B1",bottompolygon1.Shape());
1299   toppolygon1.Close();
1300   DBRep::Set("T1",toppolygon1.Shape());
1301   bottompolygon2.Close();
1302   DBRep::Set("B2",bottompolygon2.Shape());
1303   toppolygon2.Close();
1304   DBRep::Set("T2",toppolygon2.Shape());
1305   BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
1306   loft1.AddWire(bottompolygon1.Wire());
1307   loft1.AddWire(toppolygon1.Wire());
1308   loft1.Build();
1309   BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
1310   loft2.AddWire(bottompolygon2.Wire());
1311   loft2.AddWire(toppolygon2.Wire());
1312   loft2.Build();
1313   if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
1314     return 1;
1315   DBRep::Set("TS1",loft1.Shape());
1316   DBRep::Set("TS2",loft2.Shape());
1317
1318 //#if ! defined(BRepAlgoAPI_def01)
1319 //  BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1320 //#else
1321 //  BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1322 //#endif
1323   if (IsBRepAlgoAPI) {
1324     di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1325     BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1326     DBRep::Set("F",result.Shape());
1327   } else {
1328     di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1329     BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1330     DBRep::Set("F",result.Shape());
1331   }
1332
1333 //  DBRep::Set("F",result.Shape());
1334   return 0;
1335 }
1336
1337 #include <Geom_RectangularTrimmedSurface.hxx>
1338 #include <GC_MakeTrimmedCone.hxx>
1339
1340 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1341 {
1342   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1343   if(aContext.IsNull()) { 
1344     di << "use 'vinit' command before " << argv[0] << "\n";
1345     return -1;
1346   }
1347
1348   gp_Ax2  Cone_Ax;                                                                
1349   double R1=8, R2=16, H1=20, H2=40, angle;                                       
1350   gp_Pnt P0(0,0,0),                                                              
1351   P1(0,0,20), P2(0,0,45);                                                        
1352   angle = 2*M_PI;                                                                  
1353   Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1354   TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
1355   Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
1356   aContext->Display(ais1);
1357   aContext->SetColor(ais1, Quantity_NOC_BLUE1);
1358   
1359   Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
1360   TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
1361   Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
1362   aContext->Display(ais2);
1363   aContext->SetColor(ais2, Quantity_NOC_RED);
1364   return 0;
1365 }
1366
1367 #if ! defined(WNT)
1368 //#include <fstream.h>
1369 #ifdef HAVE_FSTREAM
1370 # include <fstream>
1371 #elif defined (HAVE_FSTREAM_H)
1372 # include <fstream.h> 
1373 #endif
1374 //#include <Standard_Stream.hxx>
1375 //==========================================================================
1376 //function : CoordLoad
1377 //           chargement d une face dans l explorer.
1378 //==========================================================================
1379 static Standard_Integer coordload (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1380
1381   char line[256];
1382   char X[30], Y[30];
1383   int fr;
1384   TopoDS_Vertex V1,V2;
1385   TopoDS_Edge Edge;
1386   TopoDS_Wire Wire;
1387   TopoDS_Face Face;
1388
1389   if (argc < 3) return 1;
1390
1391   ifstream file(argv[2], ios::in);
1392   if(!file)
1393     {
1394       di<<"unable to open "<<argv[2]<<" for input"<<"\n";
1395       return 2;
1396     }
1397   BRepBuilderAPI_MakeWire WB;
1398
1399   file.getline(line,80);
1400   for(int i=0;i<30;i++) X[i]=Y[i]=0;
1401   fr = sscanf(line,"%20c%20c",&X,&Y);
1402   V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1403
1404   for(;;)
1405     {
1406       file.getline(line,80);
1407       if (!file) break;
1408           for(int i=0;i<30;i++) X[i]=Y[i]=0;
1409           fr = sscanf(line,"%20c%20c",&X,&Y);
1410           V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1411           Edge = BRepBuilderAPI_MakeEdge(V1,V2);
1412           WB.Add(Edge);
1413           V1=V2;
1414   }
1415   
1416   file.close();
1417   if (WB.IsDone()) Wire = WB.Wire();
1418   Face = BRepBuilderAPI_MakeFace(Wire);
1419
1420   DBRep::Set (argv[1],Face);
1421   return 0;
1422 }
1423 #endif
1424
1425 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1426                                  Standard_Integer /*nb*/, 
1427                                  const char ** /*arg*/) 
1428 {
1429   TCollection_ExtendedString aString(1024*1024, 'A');
1430   return 0;
1431 }
1432
1433 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1434                                  Standard_Integer argc, 
1435                                  const char ** argv) 
1436 {
1437   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1438   if(aContext.IsNull()) { 
1439     di << "use 'vinit' command before " << argv[0] << "\n";
1440     return -1;
1441   }     
1442   if((argc != 2) && (argc != 3)) {
1443     di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
1444     return -1;
1445   }
1446   TopoDS_Shape aShape = DBRep::Get(argv[1]);
1447   Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1448 //  Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
1449   anIO->SetHilightMode((argc == 3) ? atoi(argv[2]) : 1);
1450   aContext->Display(anIO);
1451   return 0;
1452 }
1453
1454 //=======================================================================
1455 //function : buc60773
1456 //purpose  : 
1457 //=======================================================================
1458
1459 #include<TCollection_HAsciiString.hxx>
1460
1461 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1462 {
1463   Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1464   Standard_CString aStr = hAscii->ToCString();
1465   TCollection_AsciiString aAscii(aStr);  
1466   
1467   return 0;
1468 }
1469
1470 #include<BRepPrimAPI_MakeCylinder.hxx>
1471 #include<BRepPrimAPI_MakeCone.hxx>
1472
1473 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1474
1475 {
1476   if(argc > 2) {
1477     di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1478     return 1;
1479   }
1480   Standard_Boolean IsBRepAlgoAPI = Standard_True;
1481   if (argc == 2) {
1482     Standard_Integer IsB = atoi(argv[1]);
1483     if (IsB != 1) {
1484       IsBRepAlgoAPI = Standard_False;
1485 #if ! defined(BRepAlgo_def01)
1486 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1487 //      return 1;
1488 #endif
1489     }
1490   }
1491
1492   //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1493
1494   Standard_Real x11 = 36.085182;
1495   Standard_Real y11 = 20.0;
1496   Standard_Real z11 = 8.431413;
1497   Standard_Real x12 = 88.04671;
1498   Standard_Real y12 = 20.0;
1499   Standard_Real z12 = 38.931416;
1500   Standard_Real radius = 10.0;
1501
1502   gp_Pnt base1(x11, y11, z11);
1503   gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1504   gp_Ax2 axis1(base1, vect1);
1505   Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1506   BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1507
1508   TopoDS_Shape SCyl = cylinder.Shape();
1509   DBRep::Set("cyl", SCyl);
1510
1511    
1512   //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1513   Standard_Real x21 = 70.7262;
1514   Standard_Real y21 = 20.0;
1515   Standard_Real z21 = 28.431412;
1516   Standard_Real x22 = 105.36722;
1517   Standard_Real y22 = 20.0;
1518   Standard_Real z22 = 48.431416;
1519   Standard_Real radius1 = 6.0;
1520   Standard_Real radius2 = 3.0;
1521
1522   gp_Pnt base2(x21, y21, z21);
1523   gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1524   gp_Ax2 axis2(base2, vect2);
1525   Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1526   BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1527
1528   TopoDS_Shape SCon = cone.Shape();
1529   DBRep::Set("con", SCon);
1530
1531 //#if ! defined(BRepAlgoAPI_def01)
1532 //  BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1533 //#else
1534 //  BRepAlgo_Fuse SFuse(SCyl, SCon);
1535 //#endif
1536 //
1537 //  if(! SFuse.IsDone() )
1538 //    cout<<"Error: Boolean fuse operation failed !"<<endl;
1539 //
1540 //  TopoDS_Shape fuse = SFuse.Shape();
1541
1542   TopoDS_Shape fuse;
1543   if (IsBRepAlgoAPI) {
1544     di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
1545     BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1546     if(! SFuse.IsDone() )
1547       di<<"Error: Boolean fuse operation failed !"<<"\n";
1548     fuse = SFuse.Shape();
1549   } else {
1550     di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
1551     BRepAlgo_Fuse SFuse(SCyl, SCon);
1552     if(! SFuse.IsDone() )
1553       di<<"Error: Boolean fuse operation failed !"<<"\n";
1554     fuse = SFuse.Shape();
1555   }
1556
1557   DBRep::Set("fus", fuse);
1558         
1559   return 0;
1560 }
1561
1562 #include <Dico_DictionaryOfInteger.hxx>
1563 #include <TColStd_HSequenceOfAsciiString.hxx>
1564 #include <TopExp.hxx>
1565 #include <TopoDS_Iterator.hxx>
1566
1567 //---------------------------------------------------------------------------------------
1568
1569 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1570
1571 {  
1572   TopoDS_Shape aShape = DBRep::Get(argv[1]);
1573   if(aShape.IsNull())
1574   {
1575     di<<"Invalid input shape"<<"\n";
1576     return 1;
1577   }
1578   Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1579   Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1580   Standard_CString aString;
1581   Standard_Integer i=1,j=1,k=1,l=1,aa=1;
1582   TopExp_Explorer expl;
1583   Standard_Real f3d,l3d;
1584   for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1585   {
1586     // SURFACES
1587     TopoDS_Face aFace = TopoDS::Face (expl.Current());
1588     Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1589     aString = aSurface->DynamicType()->Name();
1590
1591     if(aDico->GetItem(aString,aa) != 0)
1592     {
1593       aDico->GetItem(aString,aa);
1594       aDico->SetItem(aString,aa+1);
1595     } else  {
1596       aDico->SetItem(aString,1);
1597       aSequence->Append(aString);
1598       aa=1;
1599       i++;
1600     }
1601   }
1602   // PCURVES
1603   for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1604   {
1605     TopoDS_Face aFace = TopoDS::Face (expl.Current());
1606     TopoDS_Iterator anIt(aFace);
1607     TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1608     TopoDS_Iterator it (aWire); 
1609     for (; it.More(); it.Next()) {
1610       TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1611     Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1612     aString = aCurve2d->DynamicType()->Name();
1613         if(aDico->GetItem(aString,aa) != 0)
1614         {         
1615           aDico->GetItem(aString,aa);
1616           aDico->SetItem(aString,aa+1);
1617         } else  {
1618           aDico->SetItem(aString,1);
1619           aSequence->Append(aString);
1620           i++;
1621           aa=1;
1622         }
1623     }
1624   }
1625   // 3d CURVES
1626   TopExp_Explorer exp;
1627   for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next()) 
1628   {
1629       TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1630       Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1631       if(aCurve3d.IsNull())
1632       {
1633         l++;
1634         goto aLabel;
1635       }
1636       aString = aCurve3d->DynamicType()->Name();
1637         if(aDico->GetItem(aString,aa) != 0)
1638         {
1639           aDico->GetItem(aString,aa);
1640           aDico->SetItem(aString,aa+1);
1641         } else  {
1642           aDico->SetItem(aString,1);
1643           aSequence->Append(aString);
1644           i++;
1645           aa=1;
1646         }
1647     aLabel:;
1648     }
1649   // Output 
1650   di<<"\n";
1651   for(j=1;j<i;j++)
1652     {
1653       aDico->GetItem(aSequence->Value(j),aa);
1654       di<<aa<<"   --   "<<aSequence->Value(j).ToCString()<<"\n";
1655     }    
1656
1657   di<<"\n";
1658   di<<"Degenerated edges :"<<"\n";
1659   di<<l<<"   --    "<<"Degenerated edges "<<"\n";
1660
1661   return 0;
1662
1663 }
1664
1665 #include <BRepBuilderAPI_Transform.hxx>
1666
1667 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1668 {
1669   if(argc > 2) {
1670     di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1671     return 1;
1672   }
1673   Standard_Boolean IsBRepAlgoAPI = Standard_True;
1674   if (argc == 2) {
1675     Standard_Integer IsB = atoi(argv[1]);
1676     if (IsB != 1) {
1677       IsBRepAlgoAPI = Standard_False;
1678 #if ! defined(BRepAlgo_def01)
1679 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1680 //      return 1;
1681 #endif
1682     }
1683   }
1684
1685   gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1686   BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1687   //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1688
1689   TopoDS_Shape sh1 = cyl.Shape();
1690   DBRep::Set("sh1",sh1);
1691   gp_Trsf trsf1, trsf2;
1692   trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1693                        gp_Pnt(0.000000,700.000000,-95.000000));
1694   trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1695                            gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1696   BRepBuilderAPI_Transform trans1(sh1, trsf1);
1697   TopoDS_Shape sh2 = trans1.Shape();
1698   DBRep::Set("sh2",sh2);
1699
1700 //#if ! defined(BRepAlgoAPI_def01)
1701 //  BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1702 //#else
1703 //  BRepAlgo_Fuse fuse1(sh1, sh2);
1704 //#endif
1705 //
1706 //  TopoDS_Shape fsh1 = fuse1.Shape();
1707
1708   TopoDS_Shape fsh1;
1709   if (IsBRepAlgoAPI) {
1710     di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
1711     BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1712     fsh1 = fuse1.Shape();
1713   } else {
1714     di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
1715     BRepAlgo_Fuse fuse1(sh1, sh2);
1716     fsh1 = fuse1.Shape();
1717   }
1718
1719   DBRep::Set("fsh1",fsh1);
1720   BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1721   TopoDS_Shape sh3 = trans2.Shape();
1722   DBRep::Set("sh3",sh3);
1723
1724 //#if ! defined(BRepAlgoAPI_def01)
1725 //  BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1726 //#else
1727 //  BRepAlgo_Fuse fuse2(fsh1,sh3);
1728 //#endif
1729 //
1730 //  TopoDS_Shape fsh2 = fuse2.Shape();
1731
1732   TopoDS_Shape fsh2;
1733   if (IsBRepAlgoAPI) {
1734     di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
1735     BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1736     fsh2 = fuse2.Shape();
1737   } else {
1738     di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
1739     BRepAlgo_Fuse fuse2(fsh1,sh3);
1740     fsh2 = fuse2.Shape();
1741   }
1742
1743   DBRep::Set("fsh2",fsh2);
1744   Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2);
1745 //  aContext->Display(aisp1);
1746   return 0;
1747 }
1748
1749 #include <ShapeBuild_Edge.hxx>
1750
1751 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1752 {
1753   TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1754   ShapeBuild_Edge().BuildCurve3d(e);
1755   DBRep::Set("ED",e);
1756   return 0;
1757 }
1758
1759
1760 #include<TDF_Label.hxx>
1761 #include<TDataStd_TreeNode.hxx>
1762
1763 #include<DDocStd.hxx>
1764
1765 #include<DDF.hxx>
1766
1767 #include<TDocStd_Modified.hxx>
1768 #include<TDF_ListIteratorOfDeltaList.hxx>
1769 #include<TDocStd_Document.hxx>
1770 #include<TDocStd_Application.hxx>
1771 #include<TDF_Delta.hxx>
1772 #include<TDataXtd_Constraint.hxx>
1773 #include<TPrsStd_AISPresentation.hxx>
1774 #include<TPrsStd_AISViewer.hxx>
1775 #include<TNaming_Builder.hxx>
1776 #include<TNaming_Naming.hxx>
1777 #include<TNaming_NamedShape.hxx>
1778   
1779 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1780   if(argc!=2) {
1781     di << "Usage : " << argv[0] << " D" << "\n";
1782     di<<1;
1783     return 0;
1784   }
1785
1786   Handle(TDF_Data) DF;
1787   if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1788   
1789   TDF_Label L1,L2;
1790   Handle(TDataStd_TreeNode) TN1,TN2;
1791
1792   DDF::AddLabel(DF,"0:2",L1);
1793   TN1 = TDataStd_TreeNode::Set(L1);
1794
1795   DDF::AddLabel(DF,"0:3",L2);
1796   TN2 = TDataStd_TreeNode::Set(L2);
1797
1798   TN1->Append(TN2);
1799   if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1800   if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1801
1802   di<<0;
1803   return 0;
1804 }
1805
1806 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1807   if(argc!=2) {
1808     di << "Usage : " << argv[0] << " D" << "\n";
1809     di<<-1;
1810     return 0;
1811   }
1812
1813   Handle(TDF_Data) DF;
1814   if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1815   
1816   TDF_Label L;
1817   DDF::FindLabel(DF,"0:1",L,Standard_False);
1818   Handle(TDocStd_Modified) MDF;
1819   if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1820     MDF = new TDocStd_Modified();
1821     L.Root().AddAttribute(MDF);
1822   }
1823
1824   di<<!MDF->IsEmpty();
1825   return 0;
1826 }
1827
1828 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1829   if(argc!=3) {
1830     di << "Usage : " << argv[0] << " D Label" << "\n";
1831     di<<1;
1832     return 0;
1833   }
1834
1835   Handle(TDF_Data) DF;
1836   if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1837   
1838   TDF_Label L;
1839   DDF::FindLabel(DF,argv[2],L,Standard_False);
1840
1841   TDocStd_Modified::Add(L);
1842   
1843   di<<0;
1844   return 0;
1845 }
1846
1847 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1848   if(argc!=2) {
1849     di << "Usage : " << argv[0] << " D" << "\n";
1850     di<<1;
1851     return 0;
1852   }
1853
1854
1855   Handle(TDF_Data) aDF;
1856   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1857
1858   Handle(TDocStd_Document) aDocument;
1859   if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1860    
1861   TDF_Label L;
1862   Handle(TDataStd_TreeNode) TN;
1863
1864   aDocument->NewCommand();
1865   DDF::AddLabel(aDF,"0:2",L);
1866   TN = TDataStd_TreeNode::Set(L);
1867
1868   aDocument->NewCommand();
1869   DDF::AddLabel(aDF,"0:3",L);
1870   TN = TDataStd_TreeNode::Set(L);
1871
1872   aDocument->NewCommand();
1873   DDF::AddLabel(aDF,"0:4",L);
1874   TN = TDataStd_TreeNode::Set(L);
1875   aDocument->NewCommand();
1876
1877   TDF_DeltaList Us,Rs;
1878   Us = aDocument->GetUndos();
1879   Rs = aDocument->GetUndos();
1880
1881   Standard_Integer i;
1882   char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};  
1883
1884   TDF_ListIteratorOfDeltaList IDL;
1885   for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1886     Handle(TDF_Delta) D = IDL.Value();
1887     TCollection_ExtendedString S(Names[i-1]);
1888     D->SetName(S);
1889 //    cout<<" U"<<i<<"="<<D->Name()<<endl;
1890   }
1891   
1892   aDocument->Undo();
1893   aDocument->Undo();
1894   
1895   Us = aDocument->GetUndos();
1896   Rs = aDocument->GetRedos();
1897
1898   for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1899     Handle(TDF_Delta) D = IDL.Value();
1900 //    cout<<" U"<<i<<"="<<D->Name()<<endl;
1901   }
1902
1903   TCollection_ExtendedString n2name ("n2");
1904   for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1905     Handle(TDF_Delta) D = IDL.Value();
1906     if ( i == 1 && ! D->Name().IsEqual (n2name) ) 
1907     {
1908       di << 4;
1909       return 0;
1910    }
1911   }
1912
1913   di<<0;
1914   return 0;
1915 }
1916
1917 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1918   if(argc!=3) {
1919     di << "Usage : " << argv[0] << " D Shape" << "\n";
1920     di<<1;
1921     return 0;
1922   }
1923
1924   Handle(TDF_Data) aDF;
1925   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1926   
1927   TopoDS_Shape s = DBRep::Get(argv[2]);
1928   if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1929   TDF_Label L;
1930   DDF::AddLabel(aDF, "0:2", L);
1931   TNaming_Builder SI (L);
1932   SI.Generated(s);
1933
1934   Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1935
1936   TNaming_Naming aNN;
1937   NS=aNN.Name(L,s,s);
1938 //  if (!NS->IsEmpty()) {di<<3;return 0;}
1939   if (NS->IsEmpty()) {di<<4;return 0;}
1940   di<<0;
1941   return 0;
1942 }
1943
1944 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1945   if(argc!=3) {
1946     di << "Usage : " << argv[0] << " D Shape" << "\n";
1947     di<<1;
1948     return 0;
1949   }
1950
1951   Handle(TDF_Data) aDF;
1952   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1953   
1954   TopoDS_Shape s = DBRep::Get(argv[2]);
1955   if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1956   TDF_Label L;
1957   DDF::AddLabel(aDF, "0:2", L);
1958   TNaming_Builder SI (L);
1959   SI.Generated(s);
1960
1961   Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1962
1963   TNaming_Naming aNN;
1964   NS=aNN.Name(L,s,s);
1965   if (NS->IsEmpty()) {di<<4;return 0;}
1966   di<<0;
1967   return 0;
1968 }
1969
1970 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1971   if (argc == 2) {
1972     TCollection_ExtendedString path (argv[1]); 
1973     Handle(TDocStd_Application) A;
1974     if (!DDocStd::Find(A)) {di<<1;return 0;}
1975     Handle(TDocStd_Document) D;
1976     Standard_Integer insession = A->IsInSession(path);
1977     if (insession > 0) {  
1978       di <<"document " << insession << "  is already in session" << "\n";
1979       di<<2;
1980       return 0;
1981     }
1982     PCDM_ReaderStatus Result = A->Open(path,D);
1983     if(Result==PCDM_RS_OK){
1984       di<<0;
1985       return 0; 
1986     }
1987   }
1988   di<<3;
1989   return 0;
1990 }
1991
1992 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1993   if(argc!=2) {
1994     di << "Usage : " << argv[0] << " D" << "\n";
1995     di<<1;
1996     return 0;
1997   }
1998
1999   Handle(TDF_Data) aDF;
2000   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2001   
2002   TDF_Label L;
2003   DDF::AddLabel(aDF, "0:2", L);
2004  
2005   Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
2006
2007   AISP->Set(L,TDataXtd_Constraint::GetID());
2008
2009   if (AISP->HasOwnMode()) {di<<3;return 0;}
2010   AISP->SetMode(3);
2011   Standard_Integer Mode = AISP->Mode();
2012   if (Mode!=3) {di<<4;return 0;}
2013   if (!AISP->HasOwnMode()) {di<<5;return 0;}
2014   AISP->UnsetMode();
2015   if (AISP->HasOwnMode()) {di<<6;return 0;}
2016   di<<0;
2017   return 0;
2018 }
2019
2020 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2021   if(argc!=2) {
2022     di << "Usage : " << argv[0] << " D" << "\n";
2023     di<<1;
2024     return 0;
2025   }
2026
2027   Handle(TDF_Data) aDF;
2028   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2029   
2030   TDF_Label L;
2031   DDF::AddLabel(aDF, "0:2", L);
2032   TDF_LabelMap LM;
2033   LM.Add(L);
2034   
2035   Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
2036 //  Handle(TNaming_Name) NN = new TNaming_Name;
2037   TNaming_Name NN;
2038
2039   NN.Type(TNaming_IDENTITY);
2040   NN.Append(NS);
2041   Standard_Boolean Res = NN.Solve(L,LM);
2042   
2043   if (Res!=Standard_False) {di<<3;return 0;}
2044   di<<0;
2045   return 0;
2046 }
2047
2048 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2049   if(argc!=2) {
2050     di << "Usage : " << argv[0] << " D" << "\n";
2051     di<<1;
2052     return 0;
2053   }
2054
2055
2056   Handle(TDocStd_Document) aDocument;
2057   if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
2058    
2059   if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
2060   if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
2061
2062   di<<0;
2063   return 0;
2064 }
2065
2066 //=======================================================================
2067 //function : AISWidth
2068 //purpose  : AISWidth (DOC,entry,[width])
2069 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
2070 //=======================================================================
2071
2072 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2073
2074   if (argc >= 3) {     
2075     Handle(TDocStd_Document) D;
2076     if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
2077     TDF_Label L;
2078     if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
2079
2080     Handle(TPrsStd_AISViewer) viewer;
2081     if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
2082
2083     Handle(TPrsStd_AISPresentation) prs;
2084     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {   
2085       if( argc == 4 ) {
2086         prs->SetWidth(atof(argv[3]));
2087         TPrsStd_AISViewer::Update(L);
2088       }
2089       else {
2090        if (prs->HasOwnWidth()){ 
2091 //         cout << "Width = " << prs->Width() << endl;
2092          di<<prs->Width();
2093        }
2094        else{
2095          di << "AISWidth: Warning : Width wasn't set" << "\n";
2096          di<<(-4);
2097        }
2098       }
2099       return 0;
2100     }
2101   }
2102   di << "AISWidth : Error"   << "\n";
2103   di<<(-5);
2104   return 0;
2105 }
2106
2107 //=======================================================================
2108 //function : BUC60921 ( & BUC60954 )
2109 //purpose  : Test memory allocation of OCAF in Undo/Redo operations
2110 //=======================================================================
2111
2112 static Standard_Integer BUC60921 (Draw_Interpretor& di,
2113                                   Standard_Integer nb, 
2114                                   const char ** arg) 
2115 {
2116   if (nb >= 4) {     
2117     Handle(TDocStd_Document) D;
2118     if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
2119     TDF_Label L;
2120     DDF::AddLabel(D->GetData(),arg[2],L);
2121
2122     BRep_Builder B;
2123     TopoDS_Shape S;
2124     BRepTools::Read ( S, arg[3], B );
2125     
2126     TNaming_Builder tnBuild(L);
2127     tnBuild.Generated(S);
2128 //    di << "File " << arg[3] << " added";
2129     di<<0;
2130     return 0;
2131   }
2132   di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label"   << "\n";
2133   di<<2;
2134   return 0;
2135 }
2136
2137 #include<IGESControl_Reader.hxx>
2138 #include<BRepPrimAPI_MakeHalfSpace.hxx>
2139
2140 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
2141 {
2142   //if(argc!=2)
2143   //  {
2144   //    cerr << "Usage : " << a[0] << " file.igs" << endl;
2145   //    return -1;
2146   //  }
2147   if(argc < 2 || argc > 3) {
2148     di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2149     return 1;
2150   }
2151   Standard_Boolean IsBRepAlgoAPI = Standard_True;
2152   if (argc == 3) {
2153     Standard_Integer IsB = atoi(a[2]);
2154     if (IsB != 1) {
2155       IsBRepAlgoAPI = Standard_False;
2156 #if ! defined(BRepAlgo_def01)
2157 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
2158 //      return 1;
2159 #endif
2160     }
2161   }
2162   
2163   Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext(); 
2164
2165   if(myContext.IsNull()) {
2166     di << "use 'vinit' command before " << a[0] << "\n";
2167     return -1;
2168   }
2169
2170 //  IGESControlStd_Reader reader;
2171   IGESControl_Reader reader;
2172   reader.ReadFile(a[1]);
2173   reader.TransferRoots();
2174   TopoDS_Shape shape = reader.OneShape();
2175   printf("\n iges1 shape type = %d", shape.ShapeType() );
2176   TopTools_IndexedMapOfShape list;
2177   TopExp::MapShapes(shape, TopAbs_FACE, list);
2178   printf("\n No. of faces = %d", list.Extent());
2179
2180   TopoDS_Shell shell;
2181   BRep_Builder builder;
2182   builder.MakeShell(shell);
2183   for(int i=1;i<=list.Extent(); i++) { 
2184     TopoDS_Face face = TopoDS::Face(list.FindKey(i));
2185     builder.Add(shell, face);
2186   }
2187
2188   BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
2189   TopoDS_Solid sol = half.Solid();
2190   gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
2191   BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
2192   TopoDS_Shape sh = cyl.Shape();
2193
2194 //#if ! defined(BRepAlgoAPI_def01)
2195 //  BRepAlgoAPI_Fuse fuse(sol, sh);
2196 //#else
2197 //  BRepAlgo_Fuse fuse(sol, sh);
2198 //#endif
2199 //
2200 //  sh = fuse.Shape();
2201
2202   if (IsBRepAlgoAPI) {
2203     di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
2204     BRepAlgoAPI_Fuse fuse(sol, sh);
2205     sh = fuse.Shape();
2206   } else {
2207     di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
2208     BRepAlgo_Fuse fuse(sol, sh);
2209     sh = fuse.Shape();
2210   }
2211
2212   Handle(AIS_Shape) res = new AIS_Shape(sh);
2213   myContext->Display( res );
2214   return 0;
2215 }
2216
2217 void QABugs::Commands_3(Draw_Interpretor& theCommands) {
2218   const char *group = "QABugs";
2219
2220   theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
2221   theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
2222   theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
2223   theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
2224 #if ! defined(WNT)
2225   theCommands.Add("UKI61075","UKI61075",__FILE__,UKI61075,group);
2226 #endif
2227   theCommands.Add("BUC60585",St,__FILE__,BUC60585,group);
2228   theCommands.Add("BUC60547","BUC60547 name",__FILE__,BUC60547,group);
2229   theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
2230   theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
2231   theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2232   theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
2233   theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
2234   theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
2235   theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
2236
2237   theCommands.Add("BUC60698","BUC60698 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60698,group);
2238
2239   theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
2240   theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
2241   theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
2242   theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
2243
2244   theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
2245   theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
2246   theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
2247   theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
2248   theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
2249   theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
2250
2251   theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
2252
2253   theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
2254
2255   theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
2256
2257 #if ! defined(WNT)
2258   theCommands.Add("coordload","load coord from file",__FILE__,coordload);
2259 #endif
2260
2261   theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
2262   theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
2263   theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group); 
2264   theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group); 
2265
2266   theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
2267
2268   theCommands.Add("statface","statface face",__FILE__,statface,group);
2269
2270   theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
2271
2272   theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
2273
2274   theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
2275   theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
2276   theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
2277   theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
2278   theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
2279   theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
2280   theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
2281   theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
2282   theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
2283   theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
2284   theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
2285   theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
2286
2287   theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );
2288
2289 }