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