68d67895a9616361e5811e2c3a6e80d073b6fd43
[occt.git] / src / QABUC / QABUC.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 <QABUC.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   printf("\nError is %d ", fillet.Status()); 
1241   Ex.Next(); 
1242   TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current()); 
1243   fillet.AddFillet(V2, 20); 
1244   printf("\nError is %d ", fillet.Status());
1245   fillet.Build(); 
1246   FP1 = fillet.Shape(); 
1247   ais2 = new AIS_Shape( FP1 ); 
1248   aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False); 
1249   aContext->Display( ais2 ); 
1250
1251   DBRep::Set("FP1",FP1);
1252   
1253 //step 4. Projecting the wire of this patch on offsetted surface. 
1254 //  TopExp_Explorer Ex; 
1255   BRepBuilderAPI_MakeWire *myWire; 
1256   myWire = new BRepBuilderAPI_MakeWire(); 
1257   for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next()) 
1258     { 
1259       TopoDS_Edge e1 = TopoDS::Edge(Ex.Current()); 
1260       Standard_Real f = 0.0, l = 0.0; 
1261       Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l);
1262       newBSplin = new Geom_TrimmedCurve(newBSplin, f, l); 
1263       Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf); 
1264       myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge()); 
1265     } 
1266   Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() ); 
1267   aContext->Display(ais33);
1268
1269   DBRep::Set("Wire",myWire->Wire());
1270   
1271   return 0;
1272 }
1273
1274 #include<GeomAPI_ExtremaCurveCurve.hxx>
1275
1276 static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1277
1278 {
1279   if(argc < 3){
1280     printf("Usage: %s edge1 edge2",argv[0]);
1281     return(-1);
1282   }
1283  
1284         TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
1285         E2 = TopoDS::Edge(DBRep::Get(argv[2]));
1286
1287         Standard_Real fp , lp;
1288
1289         Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
1290         C2 = BRep_Tool::Curve(E2 , fp , lp);
1291
1292         GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
1293
1294         di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
1295
1296         return 0;
1297 }
1298
1299 #include <BRepBuilderAPI_MakePolygon.hxx>
1300 #include <BRepOffsetAPI_ThruSections.hxx>
1301
1302 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1303 {
1304   if(argc > 2) {
1305     di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1306     return 1;
1307   }
1308   Standard_Boolean IsBRepAlgoAPI = Standard_True;
1309   if (argc == 2) {
1310     Standard_Integer IsB = atoi(argv[1]);
1311     if (IsB != 1) {
1312       IsBRepAlgoAPI = Standard_False;
1313 #if ! defined(BRepAlgo_def01)
1314 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1315 //      return 1;
1316 #endif
1317     }
1318   }
1319
1320   double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
1321   double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
1322   double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
1323   double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
1324   BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
1325   gp_Pnt tmppnt;
1326   for (int i=0;i<4;i++) {
1327     tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
1328     bottompolygon1.Add(tmppnt);
1329     tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
1330     toppolygon1.Add(tmppnt);
1331     tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
1332     bottompolygon2.Add(tmppnt);
1333     tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
1334     toppolygon2.Add(tmppnt);
1335   }
1336   bottompolygon1.Close();
1337   DBRep::Set("B1",bottompolygon1.Shape());
1338   toppolygon1.Close();
1339   DBRep::Set("T1",toppolygon1.Shape());
1340   bottompolygon2.Close();
1341   DBRep::Set("B2",bottompolygon2.Shape());
1342   toppolygon2.Close();
1343   DBRep::Set("T2",toppolygon2.Shape());
1344   BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
1345   loft1.AddWire(bottompolygon1.Wire());
1346   loft1.AddWire(toppolygon1.Wire());
1347   loft1.Build();
1348   BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
1349   loft2.AddWire(bottompolygon2.Wire());
1350   loft2.AddWire(toppolygon2.Wire());
1351   loft2.Build();
1352   if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
1353     return 1;
1354   DBRep::Set("TS1",loft1.Shape());
1355   DBRep::Set("TS2",loft2.Shape());
1356
1357 //#if ! defined(BRepAlgoAPI_def01)
1358 //  BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1359 //#else
1360 //  BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1361 //#endif
1362   if (IsBRepAlgoAPI) {
1363     di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1364     BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
1365     DBRep::Set("F",result.Shape());
1366   } else {
1367     di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
1368     BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
1369     DBRep::Set("F",result.Shape());
1370   }
1371
1372 //  DBRep::Set("F",result.Shape());
1373   return 0;
1374 }
1375
1376 #include <Geom_RectangularTrimmedSurface.hxx>
1377 #include <GC_MakeTrimmedCone.hxx>
1378
1379 static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
1380 {
1381   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1382   if(aContext.IsNull()) { 
1383     di << "use 'vinit' command before " << argv[0] << "\n";
1384     return -1;
1385   }
1386
1387   gp_Ax2  Cone_Ax;                                                                
1388   double R1=8, R2=16, H1=20, H2=40, angle;                                       
1389   gp_Pnt P0(0,0,0),                                                              
1390   P1(0,0,20), P2(0,0,45);                                                        
1391   angle = 2*M_PI;                                                                  
1392   Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1393   TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
1394   Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
1395   aContext->Display(ais1);
1396   aContext->SetColor(ais1, Quantity_NOC_BLUE1);
1397   
1398   Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
1399   TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
1400   Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
1401   aContext->Display(ais2);
1402   aContext->SetColor(ais2, Quantity_NOC_RED);
1403   return 0;
1404 }
1405
1406 #if ! defined(WNT)
1407 //#include <fstream.h>
1408 #ifdef HAVE_FSTREAM
1409 # include <fstream>
1410 #elif defined (HAVE_FSTREAM_H)
1411 # include <fstream.h> 
1412 #endif
1413 //#include <Standard_Stream.hxx>
1414 //==========================================================================
1415 //function : CoordLoad
1416 //           chargement d une face dans l explorer.
1417 //==========================================================================
1418 static Standard_Integer coordload (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1419
1420   char line[256];
1421   char X[30], Y[30];
1422   int fr;
1423   TopoDS_Vertex V1,V2;
1424   TopoDS_Edge Edge;
1425   TopoDS_Wire Wire;
1426   TopoDS_Face Face;
1427
1428   if (argc < 3) return 1;
1429
1430   ifstream file(argv[2], ios::in);
1431   if(!file)
1432     {
1433       di<<"unable to open "<<argv[2]<<" for input"<<"\n";
1434       return 2;
1435     }
1436   BRepBuilderAPI_MakeWire WB;
1437
1438   file.getline(line,80);
1439   for(int i=0;i<30;i++) X[i]=Y[i]=0;
1440   fr = sscanf(line,"%20c%20c",&X,&Y);
1441   V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1442
1443   for(;;)
1444     {
1445       file.getline(line,80);
1446       if (!file) break;
1447           for(int i=0;i<30;i++) X[i]=Y[i]=0;
1448           fr = sscanf(line,"%20c%20c",&X,&Y);
1449           V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(atof(X),atof(Y),0.0));
1450           Edge = BRepBuilderAPI_MakeEdge(V1,V2);
1451           WB.Add(Edge);
1452           V1=V2;
1453   }
1454   
1455   file.close();
1456   if (WB.IsDone()) Wire = WB.Wire();
1457   Face = BRepBuilderAPI_MakeFace(Wire);
1458
1459   DBRep::Set (argv[1],Face);
1460   return 0;
1461 }
1462 #endif
1463
1464 static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1465                                  Standard_Integer /*nb*/, 
1466                                  const char ** /*arg*/) 
1467 {
1468   TCollection_ExtendedString aString(1024*1024, 'A');
1469   return 0;
1470 }
1471
1472 static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1473                                  Standard_Integer argc, 
1474                                  const char ** argv) 
1475 {
1476   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1477   if(aContext.IsNull()) { 
1478     di << "use 'vinit' command before " << argv[0] << "\n";
1479     return -1;
1480   }     
1481   if((argc != 2) && (argc != 3)) {
1482     di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
1483     return -1;
1484   }
1485   TopoDS_Shape aShape = DBRep::Get(argv[1]);
1486   Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1487 //  Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
1488   anIO->SetHilightMode((argc == 3) ? atoi(argv[2]) : 1);
1489   aContext->Display(anIO);
1490   return 0;
1491 }
1492
1493 //=======================================================================
1494 //function : buc60773
1495 //purpose  : 
1496 //=======================================================================
1497
1498 #include<TCollection_HAsciiString.hxx>
1499
1500 static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1501 {
1502   Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1503   Standard_CString aStr = hAscii->ToCString();
1504   TCollection_AsciiString aAscii(aStr);  
1505   
1506   return 0;
1507 }
1508
1509 #include<BRepPrimAPI_MakeCylinder.hxx>
1510 #include<BRepPrimAPI_MakeCone.hxx>
1511
1512 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1513
1514 {
1515   if(argc > 2) {
1516     di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1517     return 1;
1518   }
1519   Standard_Boolean IsBRepAlgoAPI = Standard_True;
1520   if (argc == 2) {
1521     Standard_Integer IsB = atoi(argv[1]);
1522     if (IsB != 1) {
1523       IsBRepAlgoAPI = Standard_False;
1524 #if ! defined(BRepAlgo_def01)
1525 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1526 //      return 1;
1527 #endif
1528     }
1529   }
1530
1531   //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1532
1533   Standard_Real x11 = 36.085182;
1534   Standard_Real y11 = 20.0;
1535   Standard_Real z11 = 8.431413;
1536   Standard_Real x12 = 88.04671;
1537   Standard_Real y12 = 20.0;
1538   Standard_Real z12 = 38.931416;
1539   Standard_Real radius = 10.0;
1540
1541   gp_Pnt base1(x11, y11, z11);
1542   gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1543   gp_Ax2 axis1(base1, vect1);
1544   Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1545   BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1546
1547   TopoDS_Shape SCyl = cylinder.Shape();
1548   DBRep::Set("cyl", SCyl);
1549
1550    
1551   //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1552   Standard_Real x21 = 70.7262;
1553   Standard_Real y21 = 20.0;
1554   Standard_Real z21 = 28.431412;
1555   Standard_Real x22 = 105.36722;
1556   Standard_Real y22 = 20.0;
1557   Standard_Real z22 = 48.431416;
1558   Standard_Real radius1 = 6.0;
1559   Standard_Real radius2 = 3.0;
1560
1561   gp_Pnt base2(x21, y21, z21);
1562   gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1563   gp_Ax2 axis2(base2, vect2);
1564   Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1565   BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1566
1567   TopoDS_Shape SCon = cone.Shape();
1568   DBRep::Set("con", SCon);
1569
1570 //#if ! defined(BRepAlgoAPI_def01)
1571 //  BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1572 //#else
1573 //  BRepAlgo_Fuse SFuse(SCyl, SCon);
1574 //#endif
1575 //
1576 //  if(! SFuse.IsDone() )
1577 //    cout<<"Error: Boolean fuse operation failed !"<<endl;
1578 //
1579 //  TopoDS_Shape fuse = SFuse.Shape();
1580
1581   TopoDS_Shape fuse;
1582   if (IsBRepAlgoAPI) {
1583     di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
1584     BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1585     if(! SFuse.IsDone() )
1586       di<<"Error: Boolean fuse operation failed !"<<"\n";
1587     fuse = SFuse.Shape();
1588   } else {
1589     di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
1590     BRepAlgo_Fuse SFuse(SCyl, SCon);
1591     if(! SFuse.IsDone() )
1592       di<<"Error: Boolean fuse operation failed !"<<"\n";
1593     fuse = SFuse.Shape();
1594   }
1595
1596   DBRep::Set("fus", fuse);
1597         
1598   return 0;
1599 }
1600
1601 #include <Dico_DictionaryOfInteger.hxx>
1602 #include <TColStd_HSequenceOfAsciiString.hxx>
1603 #include <TopExp.hxx>
1604 #include <TopoDS_Iterator.hxx>
1605
1606 //---------------------------------------------------------------------------------------
1607
1608 static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1609
1610 {  
1611   TopoDS_Shape aShape = DBRep::Get(argv[1]);
1612   if(aShape.IsNull())
1613   {
1614     di<<"Invalid input shape"<<"\n";
1615     return 1;
1616   }
1617   Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1618   Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1619   Standard_CString aString;
1620   Standard_Integer i=1,j=1,k=1,l=1,aa=1;
1621   TopExp_Explorer expl;
1622   Standard_Real f3d,l3d;
1623   for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1624   {
1625     // SURFACES
1626     TopoDS_Face aFace = TopoDS::Face (expl.Current());
1627     Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1628     aString = aSurface->DynamicType()->Name();
1629
1630     if(aDico->GetItem(aString,aa) != 0)
1631     {
1632       aDico->GetItem(aString,aa);
1633       aDico->SetItem(aString,aa+1);
1634     } else  {
1635       aDico->SetItem(aString,1);
1636       aSequence->Append(aString);
1637       aa=1;
1638       i++;
1639     }
1640   }
1641   // PCURVES
1642   for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1643   {
1644     TopoDS_Face aFace = TopoDS::Face (expl.Current());
1645     TopoDS_Iterator anIt(aFace);
1646     TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1647     TopoDS_Iterator it (aWire); 
1648     for (; it.More(); it.Next()) {
1649       TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1650     Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1651     aString = aCurve2d->DynamicType()->Name();
1652         if(aDico->GetItem(aString,aa) != 0)
1653         {         
1654           aDico->GetItem(aString,aa);
1655           aDico->SetItem(aString,aa+1);
1656         } else  {
1657           aDico->SetItem(aString,1);
1658           aSequence->Append(aString);
1659           i++;
1660           aa=1;
1661         }
1662     }
1663   }
1664   // 3d CURVES
1665   TopExp_Explorer exp;
1666   for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next()) 
1667   {
1668       TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1669       Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1670       if(aCurve3d.IsNull())
1671       {
1672         l++;
1673         goto aLabel;
1674       }
1675       aString = aCurve3d->DynamicType()->Name();
1676         if(aDico->GetItem(aString,aa) != 0)
1677         {
1678           aDico->GetItem(aString,aa);
1679           aDico->SetItem(aString,aa+1);
1680         } else  {
1681           aDico->SetItem(aString,1);
1682           aSequence->Append(aString);
1683           i++;
1684           aa=1;
1685         }
1686     aLabel:;
1687     }
1688   // Output 
1689   di<<"\n";
1690   for(j=1;j<i;j++)
1691     {
1692       aDico->GetItem(aSequence->Value(j),aa);
1693       di<<aa<<"   --   "<<aSequence->Value(j).ToCString()<<"\n";
1694     }    
1695
1696   di<<"\n";
1697   di<<"Degenerated edges :"<<"\n";
1698   di<<l<<"   --    "<<"Degenerated edges "<<"\n";
1699
1700   return 0;
1701
1702 }
1703
1704 #include <BRepBuilderAPI_Transform.hxx>
1705
1706 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1707 {
1708   if(argc > 2) {
1709     di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1710     return 1;
1711   }
1712   Standard_Boolean IsBRepAlgoAPI = Standard_True;
1713   if (argc == 2) {
1714     Standard_Integer IsB = atoi(argv[1]);
1715     if (IsB != 1) {
1716       IsBRepAlgoAPI = Standard_False;
1717 #if ! defined(BRepAlgo_def01)
1718 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1719 //      return 1;
1720 #endif
1721     }
1722   }
1723
1724   gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1725   BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1726   //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1727
1728   TopoDS_Shape sh1 = cyl.Shape();
1729   DBRep::Set("sh1",sh1);
1730   gp_Trsf trsf1, trsf2;
1731   trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1732                        gp_Pnt(0.000000,700.000000,-95.000000));
1733   trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1734                            gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1735   BRepBuilderAPI_Transform trans1(sh1, trsf1);
1736   TopoDS_Shape sh2 = trans1.Shape();
1737   DBRep::Set("sh2",sh2);
1738
1739 //#if ! defined(BRepAlgoAPI_def01)
1740 //  BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1741 //#else
1742 //  BRepAlgo_Fuse fuse1(sh1, sh2);
1743 //#endif
1744 //
1745 //  TopoDS_Shape fsh1 = fuse1.Shape();
1746
1747   TopoDS_Shape fsh1;
1748   if (IsBRepAlgoAPI) {
1749     di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
1750     BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1751     fsh1 = fuse1.Shape();
1752   } else {
1753     di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
1754     BRepAlgo_Fuse fuse1(sh1, sh2);
1755     fsh1 = fuse1.Shape();
1756   }
1757
1758   DBRep::Set("fsh1",fsh1);
1759   BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1760   TopoDS_Shape sh3 = trans2.Shape();
1761   DBRep::Set("sh3",sh3);
1762
1763 //#if ! defined(BRepAlgoAPI_def01)
1764 //  BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1765 //#else
1766 //  BRepAlgo_Fuse fuse2(fsh1,sh3);
1767 //#endif
1768 //
1769 //  TopoDS_Shape fsh2 = fuse2.Shape();
1770
1771   TopoDS_Shape fsh2;
1772   if (IsBRepAlgoAPI) {
1773     di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
1774     BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1775     fsh2 = fuse2.Shape();
1776   } else {
1777     di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
1778     BRepAlgo_Fuse fuse2(fsh1,sh3);
1779     fsh2 = fuse2.Shape();
1780   }
1781
1782   DBRep::Set("fsh2",fsh2);
1783   Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2);
1784 //  aContext->Display(aisp1);
1785   return 0;
1786 }
1787
1788 #include <ShapeBuild_Edge.hxx>
1789
1790 static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1791 {
1792   TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1793   ShapeBuild_Edge().BuildCurve3d(e);
1794   DBRep::Set("ED",e);
1795   return 0;
1796 }
1797
1798
1799 #include<TDF_Label.hxx>
1800 #include<TDataStd_TreeNode.hxx>
1801
1802 #include<DDocStd.hxx>
1803
1804 #include<DDF.hxx>
1805
1806 #include<TDocStd_Modified.hxx>
1807 #include<TDF_ListIteratorOfDeltaList.hxx>
1808 #include<TDocStd_Document.hxx>
1809 #include<TDocStd_Application.hxx>
1810 #include<TDF_Delta.hxx>
1811 #include<TDataXtd_Constraint.hxx>
1812 #include<TPrsStd_AISPresentation.hxx>
1813 #include<TPrsStd_AISViewer.hxx>
1814 #include<TNaming_Builder.hxx>
1815 #include<TNaming_Naming.hxx>
1816 #include<TNaming_NamedShape.hxx>
1817   
1818 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1819   if(argc!=2) {
1820     di << "Usage : " << argv[0] << " D" << "\n";
1821     di<<1;
1822     return 0;
1823   }
1824
1825   Handle(TDF_Data) DF;
1826   if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1827   
1828   TDF_Label L1,L2;
1829   Handle(TDataStd_TreeNode) TN1,TN2;
1830
1831   DDF::AddLabel(DF,"0:2",L1);
1832   TN1 = TDataStd_TreeNode::Set(L1);
1833
1834   DDF::AddLabel(DF,"0:3",L2);
1835   TN2 = TDataStd_TreeNode::Set(L2);
1836
1837   TN1->Append(TN2);
1838   if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1839   if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1840
1841   di<<0;
1842   return 0;
1843 }
1844
1845 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1846   if(argc!=2) {
1847     di << "Usage : " << argv[0] << " D" << "\n";
1848     di<<-1;
1849     return 0;
1850   }
1851
1852   Handle(TDF_Data) DF;
1853   if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1854   
1855   TDF_Label L;
1856   DDF::FindLabel(DF,"0:1",L,Standard_False);
1857   Handle(TDocStd_Modified) MDF;
1858   if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1859     MDF = new TDocStd_Modified();
1860     L.Root().AddAttribute(MDF);
1861   }
1862
1863   di<<!MDF->IsEmpty();
1864   return 0;
1865 }
1866
1867 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1868   if(argc!=3) {
1869     di << "Usage : " << argv[0] << " D Label" << "\n";
1870     di<<1;
1871     return 0;
1872   }
1873
1874   Handle(TDF_Data) DF;
1875   if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1876   
1877   TDF_Label L;
1878   DDF::FindLabel(DF,argv[2],L,Standard_False);
1879
1880   TDocStd_Modified::Add(L);
1881   
1882   di<<0;
1883   return 0;
1884 }
1885
1886 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1887   if(argc!=2) {
1888     di << "Usage : " << argv[0] << " D" << "\n";
1889     di<<1;
1890     return 0;
1891   }
1892
1893
1894   Handle(TDF_Data) aDF;
1895   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1896
1897   Handle(TDocStd_Document) aDocument;
1898   if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1899    
1900   TDF_Label L;
1901   Handle(TDataStd_TreeNode) TN;
1902
1903   aDocument->NewCommand();
1904   DDF::AddLabel(aDF,"0:2",L);
1905   TN = TDataStd_TreeNode::Set(L);
1906
1907   aDocument->NewCommand();
1908   DDF::AddLabel(aDF,"0:3",L);
1909   TN = TDataStd_TreeNode::Set(L);
1910
1911   aDocument->NewCommand();
1912   DDF::AddLabel(aDF,"0:4",L);
1913   TN = TDataStd_TreeNode::Set(L);
1914   aDocument->NewCommand();
1915
1916   TDF_DeltaList Us,Rs;
1917   Us = aDocument->GetUndos();
1918   Rs = aDocument->GetUndos();
1919
1920   Standard_Integer i;
1921   char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};  
1922
1923   TDF_ListIteratorOfDeltaList IDL;
1924   for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1925     Handle(TDF_Delta) D = IDL.Value();
1926     TCollection_ExtendedString S(Names[i-1]);
1927     D->SetName(S);
1928 //    cout<<" U"<<i<<"="<<D->Name()<<endl;
1929   }
1930   
1931   aDocument->Undo();
1932   aDocument->Undo();
1933   
1934   Us = aDocument->GetUndos();
1935   Rs = aDocument->GetRedos();
1936
1937   for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1938     Handle(TDF_Delta) D = IDL.Value();
1939 //    cout<<" U"<<i<<"="<<D->Name()<<endl;
1940   }
1941
1942   TCollection_ExtendedString n2name ("n2");
1943   for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1944     Handle(TDF_Delta) D = IDL.Value();
1945     if ( i == 1 && ! D->Name().IsEqual (n2name) ) 
1946     {
1947       di << 4;
1948       return 0;
1949    }
1950   }
1951
1952   di<<0;
1953   return 0;
1954 }
1955
1956 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1957   if(argc!=3) {
1958     di << "Usage : " << argv[0] << " D Shape" << "\n";
1959     di<<1;
1960     return 0;
1961   }
1962
1963   Handle(TDF_Data) aDF;
1964   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1965   
1966   TopoDS_Shape s = DBRep::Get(argv[2]);
1967   if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1968   TDF_Label L;
1969   DDF::AddLabel(aDF, "0:2", L);
1970   TNaming_Builder SI (L);
1971   SI.Generated(s);
1972
1973   Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1974
1975   TNaming_Naming aNN;
1976   NS=aNN.Name(L,s,s);
1977 //  if (!NS->IsEmpty()) {di<<3;return 0;}
1978   if (NS->IsEmpty()) {di<<4;return 0;}
1979   di<<0;
1980   return 0;
1981 }
1982
1983 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1984   if(argc!=3) {
1985     di << "Usage : " << argv[0] << " D Shape" << "\n";
1986     di<<1;
1987     return 0;
1988   }
1989
1990   Handle(TDF_Data) aDF;
1991   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1992   
1993   TopoDS_Shape s = DBRep::Get(argv[2]);
1994   if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1995   TDF_Label L;
1996   DDF::AddLabel(aDF, "0:2", L);
1997   TNaming_Builder SI (L);
1998   SI.Generated(s);
1999
2000   Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
2001
2002   TNaming_Naming aNN;
2003   NS=aNN.Name(L,s,s);
2004   if (NS->IsEmpty()) {di<<4;return 0;}
2005   di<<0;
2006   return 0;
2007 }
2008
2009 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2010   if (argc == 2) {
2011     TCollection_ExtendedString path (argv[1]); 
2012     Handle(TDocStd_Application) A;
2013     if (!DDocStd::Find(A)) {di<<1;return 0;}
2014     Handle(TDocStd_Document) D;
2015     Standard_Integer insession = A->IsInSession(path);
2016     if (insession > 0) {  
2017       di <<"document " << insession << "  is already in session" << "\n";
2018       di<<2;
2019       return 0;
2020     }
2021     PCDM_ReaderStatus Result = A->Open(path,D);
2022     if(Result==PCDM_RS_OK){
2023       di<<0;
2024       return 0; 
2025     }
2026   }
2027   di<<3;
2028   return 0;
2029 }
2030
2031 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2032   if(argc!=2) {
2033     di << "Usage : " << argv[0] << " D" << "\n";
2034     di<<1;
2035     return 0;
2036   }
2037
2038   Handle(TDF_Data) aDF;
2039   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2040   
2041   TDF_Label L;
2042   DDF::AddLabel(aDF, "0:2", L);
2043  
2044   Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
2045
2046   AISP->Set(L,TDataXtd_Constraint::GetID());
2047
2048   if (AISP->HasOwnMode()) {di<<3;return 0;}
2049   AISP->SetMode(3);
2050   Standard_Integer Mode = AISP->Mode();
2051   if (Mode!=3) {di<<4;return 0;}
2052   if (!AISP->HasOwnMode()) {di<<5;return 0;}
2053   AISP->UnsetMode();
2054   if (AISP->HasOwnMode()) {di<<6;return 0;}
2055   di<<0;
2056   return 0;
2057 }
2058
2059 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2060   if(argc!=2) {
2061     di << "Usage : " << argv[0] << " D" << "\n";
2062     di<<1;
2063     return 0;
2064   }
2065
2066   Handle(TDF_Data) aDF;
2067   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
2068   
2069   TDF_Label L;
2070   DDF::AddLabel(aDF, "0:2", L);
2071   TDF_LabelMap LM;
2072   LM.Add(L);
2073   
2074   Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
2075 //  Handle(TNaming_Name) NN = new TNaming_Name;
2076   TNaming_Name NN;
2077
2078   NN.Type(TNaming_IDENTITY);
2079   NN.Append(NS);
2080   Standard_Boolean Res = NN.Solve(L,LM);
2081   
2082   if (Res!=Standard_False) {di<<3;return 0;}
2083   di<<0;
2084   return 0;
2085 }
2086
2087 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2088   if(argc!=2) {
2089     di << "Usage : " << argv[0] << " D" << "\n";
2090     di<<1;
2091     return 0;
2092   }
2093
2094
2095   Handle(TDocStd_Document) aDocument;
2096   if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
2097    
2098   if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
2099   if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
2100
2101   di<<0;
2102   return 0;
2103 }
2104
2105 //=======================================================================
2106 //function : AISWidth
2107 //purpose  : AISWidth (DOC,entry,[width])
2108 // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
2109 //=======================================================================
2110
2111 static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
2112
2113   if (argc >= 3) {     
2114     Handle(TDocStd_Document) D;
2115     if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
2116     TDF_Label L;
2117     if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
2118
2119     Handle(TPrsStd_AISViewer) viewer;
2120     if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
2121
2122     Handle(TPrsStd_AISPresentation) prs;
2123     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {   
2124       if( argc == 4 ) {
2125         prs->SetWidth(atof(argv[3]));
2126         TPrsStd_AISViewer::Update(L);
2127       }
2128       else {
2129        if (prs->HasOwnWidth()){ 
2130 //         cout << "Width = " << prs->Width() << endl;
2131          di<<prs->Width();
2132        }
2133        else{
2134          di << "AISWidth: Warning : Width wasn't set" << "\n";
2135          di<<(-4);
2136        }
2137       }
2138       return 0;
2139     }
2140   }
2141   di << "AISWidth : Error"   << "\n";
2142   di<<(-5);
2143   return 0;
2144 }
2145
2146 //=======================================================================
2147 //function : BUC60921 ( & BUC60954 )
2148 //purpose  : Test memory allocation of OCAF in Undo/Redo operations
2149 //=======================================================================
2150
2151 static Standard_Integer BUC60921 (Draw_Interpretor& di,
2152                                   Standard_Integer nb, 
2153                                   const char ** arg) 
2154 {
2155   if (nb >= 4) {     
2156     Handle(TDocStd_Document) D;
2157     if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
2158     TDF_Label L;
2159     DDF::AddLabel(D->GetData(),arg[2],L);
2160
2161     BRep_Builder B;
2162     TopoDS_Shape S;
2163     BRepTools::Read ( S, arg[3], B );
2164     
2165     TNaming_Builder tnBuild(L);
2166     tnBuild.Generated(S);
2167 //    di << "File " << arg[3] << " added";
2168     di<<0;
2169     return 0;
2170   }
2171   di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label"   << "\n";
2172   di<<2;
2173   return 0;
2174 }
2175
2176 #include<IGESControl_Reader.hxx>
2177 #include<BRepPrimAPI_MakeHalfSpace.hxx>
2178
2179 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
2180 {
2181   //if(argc!=2)
2182   //  {
2183   //    cerr << "Usage : " << a[0] << " file.igs" << endl;
2184   //    return -1;
2185   //  }
2186   if(argc < 2 || argc > 3) {
2187     di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
2188     return 1;
2189   }
2190   Standard_Boolean IsBRepAlgoAPI = Standard_True;
2191   if (argc == 3) {
2192     Standard_Integer IsB = atoi(a[2]);
2193     if (IsB != 1) {
2194       IsBRepAlgoAPI = Standard_False;
2195 #if ! defined(BRepAlgo_def01)
2196 //      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
2197 //      return 1;
2198 #endif
2199     }
2200   }
2201   
2202   Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext(); 
2203
2204   if(myContext.IsNull()) {
2205     di << "use 'vinit' command before " << a[0] << "\n";
2206     return -1;
2207   }
2208
2209 //  IGESControlStd_Reader reader;
2210   IGESControl_Reader reader;
2211   reader.ReadFile(a[1]);
2212   reader.TransferRoots();
2213   TopoDS_Shape shape = reader.OneShape();
2214   printf("\n iges1 shape type = %d", shape.ShapeType() );
2215   TopTools_IndexedMapOfShape list;
2216   TopExp::MapShapes(shape, TopAbs_FACE, list);
2217   printf("\n No. of faces = %d", list.Extent());
2218
2219   TopoDS_Shell shell;
2220   BRep_Builder builder;
2221   builder.MakeShell(shell);
2222   for(int i=1;i<=list.Extent(); i++) { 
2223     TopoDS_Face face = TopoDS::Face(list.FindKey(i));
2224     builder.Add(shell, face);
2225   }
2226
2227   BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
2228   TopoDS_Solid sol = half.Solid();
2229   gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
2230   BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
2231   TopoDS_Shape sh = cyl.Shape();
2232
2233 //#if ! defined(BRepAlgoAPI_def01)
2234 //  BRepAlgoAPI_Fuse fuse(sol, sh);
2235 //#else
2236 //  BRepAlgo_Fuse fuse(sol, sh);
2237 //#endif
2238 //
2239 //  sh = fuse.Shape();
2240
2241   if (IsBRepAlgoAPI) {
2242     di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
2243     BRepAlgoAPI_Fuse fuse(sol, sh);
2244     sh = fuse.Shape();
2245   } else {
2246     di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
2247     BRepAlgo_Fuse fuse(sol, sh);
2248     sh = fuse.Shape();
2249   }
2250
2251   Handle(AIS_Shape) res = new AIS_Shape(sh);
2252   myContext->Display( res );
2253   return 0;
2254 }
2255
2256 void QABUC::Commands(Draw_Interpretor& theCommands) {
2257   const char *group = "QABUC";
2258
2259   theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
2260   theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
2261   theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
2262   theCommands.Add("BUC60609","BUC60609 shape [name] [interactive (0|1)]",__FILE__,BUC60609,group);
2263 #if ! defined(WNT)
2264   theCommands.Add("UKI61075","UKI61075",__FILE__,UKI61075,group);
2265 #endif
2266   theCommands.Add("BUC60585",St,__FILE__,BUC60585,group);
2267   theCommands.Add("BUC60547","BUC60547 name",__FILE__,BUC60547,group);
2268   theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
2269   theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
2270   theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
2271   theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
2272   theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
2273   theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
2274   theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
2275
2276   theCommands.Add("BUC60698","BUC60698 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60698,group);
2277
2278   theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
2279   theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
2280   theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
2281   theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
2282
2283   theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
2284   theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
2285   theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
2286   theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
2287   theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
2288   theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
2289
2290   theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
2291
2292   theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
2293
2294   theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
2295
2296 #if ! defined(WNT)
2297   theCommands.Add("coordload","load coord from file",__FILE__,coordload);
2298 #endif
2299
2300   theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
2301   theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
2302   theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group); 
2303   theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group); 
2304
2305   theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
2306
2307   theCommands.Add("statface","statface face",__FILE__,statface,group);
2308
2309   theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
2310
2311   theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
2312
2313   theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
2314   theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
2315   theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
2316   theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
2317   theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
2318   theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
2319   theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
2320   theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
2321   theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
2322   theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
2323   theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
2324   theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
2325
2326   theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );
2327
2328 }