0031456: Visualization - move out Dimensions and Relations from package AIS to PrsDims
[occt.git] / src / QABugs / QABugs_3.cxx
index 0087bdb..4af0543 100644 (file)
@@ -4,8 +4,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -14,9 +14,6 @@
 // commercial license or contractual agreement.
 
 #include <QABugs.hxx>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
 #include <Draw.hxx>
 #include <Draw_Interpretor.hxx>
 #include <TopLoc_Location.hxx>
@@ -29,6 +26,8 @@
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Graphic3d_ClipPlane.hxx>
+#include <ViewerTest.hxx>
+#include <AIS_Shape.hxx>
 
 #include <fstream>
 
@@ -36,7 +35,7 @@ static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 {
   if(argc!=4)
   {
-    di << "Usage : " << a[0] << " result Shape1 Shape2" << "\n";
+    di << "Usage : " << a[0] << " result Shape1 Shape2\n";
     return -1;
   }
 
@@ -49,7 +48,7 @@ static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a
   GeomInt_IntSS Inter;
   Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
   if (!Inter.IsDone()) {
-    di << "Intersection not done" << "\n";
+    di << "Intersection not done\n";
     return 1;
   }
   Standard_Integer nbsol = Inter.NbLines();
@@ -63,174 +62,14 @@ static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a
       return 0;
     } else di << "The first solution is Null!"   << "\n";
 
-  di << "fini" << "\n";
-  return 0;
-}
-
-#include<ViewerTest.hxx>
-#include<AIS_InteractiveContext.hxx>
-#include<AIS_Shape.hxx>
-  
-static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
-  if(argc!=2)
-  {
-    di << "Usage : " << argv[0] << " shape" << "\n";
-    return -1;
-  }
-
-  Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
-  if(myAISContext.IsNull()) {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return -1;
-  }
-
-  TopoDS_Shape theShape =  DBRep::Get(argv[1]);
-
-  Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape ); 
-  myAISContext->Display( anAISShape, Standard_True );
-  myAISContext->OpenLocalContext(); 
-  myAISContext->ActivateStandardMode(TopAbs_FACE);
-  return 0;
-}
-
-static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
-  if(argc!=2)
-  {
-    di << "Usage : "<< argv[0] << " shape" << "\n";
-    return -1;
-  }
-
-  //  di.Eval("vinit");
-
-  TopoDS_Shape theShape =  DBRep::Get(argv[1]);
-
-//  ViewerTest::GetAISContext(); 
-  Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
-  if(myAISContext.IsNull()) {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return -1;    
-  }
-  Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape ); 
-  myAISContext->Display( anAISShape, Standard_True );
-  myAISContext->OpenLocalContext(); 
-  myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
-//  myAISContext->ActivateStandardMode(TopAbs_SOLID);
-//  di.Eval("vfit");
-//  cout << "vfini" << endl;
-  return 0;
-}
-
-#include<BRep_Builder.hxx>
-#include<BRepTools_ShapeSet.hxx>
-#include<BRepTools.hxx>
-#include<BRepAdaptor_HSurface.hxx>
-#include<TopOpeBRep_PointClassifier.hxx>
-#include<Precision.hxx>
-#ifdef WNT
-#include<stdio.h>
-#endif
-
-static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
-  gp_Pnt2d uvSurf;
-  TopAbs_State state;
-  
-  if (argc == 3) {
-    // BUC60609 shape name
-  } else if ( argc == 5 ) {
-    // BUC60609 shape name U V
-  } else {
-    di << "Usage : "<< argv[0] << " shape name [U V]" << "\n";
-    return(-1);
-  }
-  
-  TCollection_AsciiString  aFilePath(argv[1]); 
-  
-  filebuf fic;
-  istream in(&fic);
-  if (!fic.open(aFilePath.ToCString(),ios::in)) {
-    di << "Cannot open file for reading : " << aFilePath << "\n";
-    return(-1);
-  }
-
-  TopoDS_Shape theShape;
-  char typ[255];
-  in >> typ;
-  if (!in.fail()) {
-    if( !strcmp(typ, "DBRep_DrawableShape") ){
-      BRep_Builder B;
-      BRepTools_ShapeSet S(B);
-      S.Read(in);
-      S.Read(theShape,in);
-    }else{
-      di << "Wrong entity type in " << aFilePath << "\n";
-      return(-1);
-    }
-  }
-
-  const TopoDS_Face &face = TopoDS::Face (theShape);
-
-  if(argc > 2){
-    DBRep::Set(argv[2],face);
-  }
-
-  Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
-  
-  BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
-
-  di << "The bounds of the trimmed face:" << "\n";
-  di << faceUMin << " <= U <= " << faceUMax << "\n";
-  di << faceVMin << " <= V <= " << faceVMax << "\n";
-  
-  Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
-  
-  TopOpeBRep_PointClassifier PClass;
-
-  di << "Now test the point classifier by inputting U,V values" << "\n";
-  di << "inside or outside the bounds displayed above" << "\n";
-  di << "Type stop to exit" << "\n";
-  
-  // Please register this:
-  // ***********************************************
-  // Note also that for periodic surfaces such as nimpod_1.topo,
-  // the U/V values may be +- 2pi compared to the actual face bounds
-  // (because U,V is probably coming from a Geom package routine).
-  // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
-  // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
-  // *************************************************
-
-  if (argc == 3) {
-    uvSurf = gp_Pnt2d(0.14,5.1);
-    state = PClass.Classify(face,uvSurf,Precision::PConfusion());
-    if(state == TopAbs_IN || state == TopAbs_ON){
-      di << "U=" << 0.14 << " V=" << 5.1 << "  classified INSIDE" << "\n";
-    }else{
-      di << "U=" << 0.14 << " V=" << 5.1 << "  classified OUTSIDE" << "\n";
-    }
-
-    uvSurf = gp_Pnt2d(1.28,5.1);
-    state = PClass.Classify(face,uvSurf,Precision::PConfusion());
-    if(state == TopAbs_IN || state == TopAbs_ON){
-      di << "U=" << 1.28 << " V=" << 5.1 << "  classified INSIDE" << "\n";
-    }else{
-      di << "U=" << 1.28 << " V=" << 5.1 << "  classified OUTSIDE" << "\n";
-    }
-  } else {
-    uvSurf = gp_Pnt2d(Draw::Atof(argv[3]),Draw::Atof(argv[4]));
-    state = PClass.Classify(face,uvSurf,Precision::PConfusion());
-    if(state == TopAbs_IN || state == TopAbs_ON){
-      di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << "  classified INSIDE" << "\n";
-    }else{
-      di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << "  classified OUTSIDE" << "\n";
-    }
-  }
+  di << "fini\n";
   return 0;
 }
 
 #include<BRepBuilderAPI_MakeVertex.hxx>
 #include<TCollection_ExtendedString.hxx>
-#include<AIS_LengthDimension.hxx>
+#include<AIS_InteractiveContext.hxx>
+#include<PrsDim_LengthDimension.hxx>
 
 static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
 {
@@ -240,7 +79,7 @@ static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, c
     di << "use 'vinit' command before " << a[0] << "\n";
     return -1;
   }
-  myAIScontext->EraseAll();
+  myAIScontext->EraseAll (Standard_False);
   
   TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0)); 
   TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0)); 
@@ -248,12 +87,12 @@ static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, c
   Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
   Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
   
-  myAIScontext->Display(Ve1);
-  myAIScontext->Display(Ve2);
+  myAIScontext->Display (Ve1, Standard_False);
+  myAIScontext->Display (Ve2, Standard_False);
   
   Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1)); 
   TCollection_ExtendedString Ext1("Dim1"); 
-  Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln()); 
+  Handle(PrsDim_LengthDimension) Dim1 = new PrsDim_LengthDimension(V1,V2,Plane1->Pln());
   Dim1->SetCustomValue (Draw::Atof(a[2]));
 
   Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
@@ -264,12 +103,13 @@ static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, c
   anAspect->ArrowAspect()->SetLength (1.0);
   Dim1->SetDimensionAspect (anAspect);
 
-  myAIScontext->SetDisplayMode(Dim1, Draw::Atoi(a[1]));
-  myAIScontext->Display(Dim1);
+  myAIScontext->SetDisplayMode (Dim1, Draw::Atoi(a[1]), Standard_False);
+  myAIScontext->Display (Dim1, Standard_True);
   return 0;
 }
 
 #include<TopoDS_Wire.hxx>
+#include <BRepTools.hxx>
 
 static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
 {
@@ -284,282 +124,20 @@ static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, co
   return 0; 
 }
 
-#include <BRepAlgo_BooleanOperations.hxx>
-  
-static Standard_Integer defNbPntMax = 30;
-static Standard_Real defTol3d = 1.e-7;
-static Standard_Real defTol2d = 1.e-7;
-static Standard_Boolean defRelativeTol=Standard_True;
-Standard_Integer NbPntMax = defNbPntMax;
-Standard_Real Toler3d =defTol3d;
-Standard_Real Toler2d = defTol2d;
-Standard_Boolean RelativeTol= defRelativeTol;
-//              //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
-//== // ksection : operateur section appelant BRepAlgo_BooleanOperations
-//=======================================================================
-Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
-  if (n < 8) {
-    di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol"   << "\n";
-    return -1;
-  }
-  // a[1]= resultat
-  // a[2]= shell1
-  // a[3]= shell2
-  // a[4]= NbPntMax
-  // a[5]= Toler3d
-  // a[6]= Toler2d
-  // a[7]= RelativeTol
-  TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
-  TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
-  if (s1.IsNull() || s2.IsNull()) return 1;
-  NbPntMax=Draw::Atoi(a[4]);
-  Toler3d=Draw::Atof(a[5]);
-  Toler2d=Draw::Atof(a[6]);
-  RelativeTol=Draw::Atoi(a[7]);
-
-  di << "BRepAlgo_BooleanOperations myalgo" << "\n";
-  BRepAlgo_BooleanOperations myalgo;
-
-  myalgo.Shapes(s1, s2);
-  myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol);
-  TopoDS_Shape res; res = myalgo.Section();
-  DBRep::Set(a[1],res);
-  return 0;
-}
-
-#include <Geom_Axis2Placement.hxx>
-#include <AIS_Trihedron.hxx>
-
-static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
-{
-  
-  Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
-  if(myAISContext.IsNull()) {
-    di << "use 'vinit' command before " << a[0] << "\n";
-    return -1;
-  }
-  
-  Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY()); 
-  Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis); 
-  gp_Trsf aTrsf; 
-  gp_Vec trans(5,5,5); 
-  aTrsf.SetTranslation(trans); 
-  TopLoc_Location aLoc(aTrsf); 
-  myAISContext->SetLocation(atri,aLoc); 
-  myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
-  myAISContext->OpenLocalContext(Standard_False, 
-                                Standard_True,Standard_False,Standard_False); 
-  myAISContext->Load(atri,3,Standard_True);
-
-  return 0;
-}
-
 #include <TopoDS_Solid.hxx>
 #include <BRepPrimAPI_MakeBox.hxx>
 #include <BRepPrimAPI_MakeSphere.hxx>
 
 #include <BRepAlgoAPI_Fuse.hxx>
-#include <BRepAlgo_Fuse.hxx>
 
 #include <V3d_View.hxx>
 #include <gce_MakePln.hxx>
 
-static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
-{
-  
-  Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
-  if(myAISContext.IsNull()) {
-    di << "use 'vinit' command before " << a[0] << "\n";
-    return -1;
-  }
-  TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
-  TopAbs_ShapeEnum theType = B1.ShapeType();
-  if ( theType == TopAbs_SOLID ) {
-    di << "It is a solid."   << "\n";
-  } else {
-    di << "It is not solid."   << "\n";
-  }
-  myAISContext->Display(new AIS_Shape(B1)); 
-  myAISContext->OpenLocalContext();
-  TopAbs_ShapeEnum amode = TopAbs_SOLID;
-  myAISContext->ActivateStandardMode(amode);
-  di.Eval("vfit");
-  di.Eval("QAMoveTo 200 200");
-  di.Eval("QASelect 200 200");
-  myAISContext->InitSelected() ;
-  if ( myAISContext->MoreSelected() ) {
-    if (myAISContext->HasSelectedShape() ) {
-      di << "has selected shape : OK"   << "\n";
-    } else {
-      di << "has selected shape : bugged - Faulty "   << "\n";
-    }
-  }
-  return 0;
-}
-
-static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
-{
-  if(argc > 2) {
-    di << "Usage : " << argv[0] << " [1/0]" << "\n";
-    return -1;
-  }
-  
-  Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
-  if(myAIScontext.IsNull()) {
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return -1;
-  }
-  Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
-  
-  if((argc == 2) && (Draw::Atof(argv[1]) == 0))
-    myV3dView->SetAntialiasingOff();
-  else
-    myV3dView->SetAntialiasingOn();
-  myV3dView->Update();
-  return 0;
-}
-
-
-#define DEFAULT_COLOR    Quantity_NOC_GOLDENROD
-
-//=======================================================================
-//function : GetColorFromName
-//purpose  : get the Quantity_NameOfColor from a string
-//=======================================================================
-
-static Quantity_NameOfColor GetColorFromName( const char *name ) 
-{ 
-  Quantity_NameOfColor ret = DEFAULT_COLOR;
-  
-  Standard_Boolean Found = Standard_False;
-  Standard_CString colstring;
-  for(Standard_Integer i=0;i<=514 && !Found;i++)
-    {
-      colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
-      if (!strcasecmp(name,colstring)) {
-       ret = (Quantity_NameOfColor)i;
-       Found = Standard_True;
-      }
-    }
-  
-  return ret;
-}
-   
-static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
-{
-
-Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
-if(myAISContext.IsNull()) { 
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return -1;
-  }
-
-Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
-
-switch (argc){
-
- case 2:
-   {
-     di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
-//   setcolor <name> 
-//   Change the background color of the view with a predefined name Graphic3d_NOC_<name>  
-
-     myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
-     myV3dView -> Redraw();
-   break;
-   }
-
- case 3:
-   {
-     di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
-//   setcolor <object> <name> 
-//   Change the object color with a predefined name 
-
-     TopoDS_Shape aShape = DBRep::Get(argv[1]);
-     Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
-     myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
-     myAISContext->Display(myShape,Standard_True);
-     myAISContext->UpdateCurrentViewer();
-//     return 0;
-   break;
-   }
- case 4:
-   {
-     di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
-
-//   setcolor <r> <g> <b> 
-//   Change the background color of the view with the color values <r>,<g>,<b> 
-//   A color value must be defined in the space [0.,1.] 
-
-     Standard_Real QuantityOfRed   = Draw::Atoi(argv[1]);
-     Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]);
-     Standard_Real QuantityOfBlue  = Draw::Atoi(argv[3]);
-     myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
-     myV3dView->Redraw();
-   break;
-   }
-
- case 5:
-   {
-    di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
-
-//  setcolor <object> <r> <g> <b> 
-//  change the object color with RGB values. 
-
-
-    Standard_Real QuantityOfRed   = Draw::Atof(argv[2]);
-    Standard_Real QuantityOfGreen = Draw::Atof(argv[3]);
-    Standard_Real QuantityOfBlue  = Draw::Atof(argv[4]);
-
-    TopoDS_Shape aShape = DBRep::Get(argv[1]);
-    Handle(AIS_InteractiveObject) myShape =  new AIS_Shape (aShape);
-    myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
-    myAISContext->Display(myShape,Standard_True);
-    myAISContext->UpdateCurrentViewer();
-//  myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
-//  myShape->Redisplay();
-   break;
-   }
- }
-return 0;
-}
-
-static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
-{
-  Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
-  if(myAISContext.IsNull()) { 
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return -1;
-  }
-  
-  if(argc != 2) {
-    di << "Usage : " << argv[0] << " 0/1" << "\n";
-  }
-
-  if(Draw::Atoi(argv[1]) == 0) {
-    myAISContext->CloseAllContexts();
-    BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
-    Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
-    myAISContext->Display(aBox);
-  } else if(Draw::Atoi(argv[1]) == 1) {
-    myAISContext->CloseAllContexts();
-    myAISContext->OpenLocalContext();
-    myAISContext->ActivateStandardMode(TopAbs_EDGE);
-  } else if(Draw::Atoi(argv[1]) == 2) {
-    myAISContext->CloseAllContexts();
-    myAISContext->OpenLocalContext();
-    myAISContext->ActivateStandardMode(TopAbs_FACE);
-  } else {
-    di << "Usage : " << argv[0] << " 0/1" << "\n";
-    return -1;
-  }
-  
-  return 0;
-}
-
+#include <Bnd_BoundSortBox.hxx>
 #include <BRepBndLib.hxx>
 #include <Bnd_HArray1OfBox.hxx>
-  
+#include <TopExp_Explorer.hxx>
+
 static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
 {
   Bnd_Box aMainBox;
@@ -575,7 +153,7 @@ static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*ar
 
 
 //  Bnd_Box __emptyBox; // Box is void !
-//  Handle_Bnd_HArray1OfBox __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox ); 
+//  Handle(Bnd_HArray1OfBox) __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox ); 
 
   for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ ) 
     { 
@@ -607,7 +185,7 @@ static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/
 
 static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
 {
-di <<"Program Test" << "\n";
+di <<"Program Test\n";
 UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm 
 di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG. 
 
@@ -634,23 +212,23 @@ static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/
   gp_Pnt pt3d(0, 20, 150);
   gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
   gp_Circ circ(anAx2, 50.0); 
-  Handle_Geom_Circle gcir = new Geom_Circle(circ); 
-  Handle_Geom_Plane pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0))); 
-  Handle_Geom2d_Curve gcir1 = GeomAPI::To2d(gcir, pln->Pln()); 
+  Handle(Geom_Circle) gcir = new Geom_Circle(circ); 
+  Handle(Geom_Plane) pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0))); 
+  Handle(Geom2d_Curve) gcir1 = GeomAPI::To2d(gcir, pln->Pln()); 
   TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape(); 
-  Handle_AIS_Shape ais1 = new AIS_Shape(sh1); 
-  aContext->SetColor(ais1, Quantity_NOC_INDIANRED); 
-  aContext->Display(ais1); 
+  Handle(AIS_Shape) ais1 = new AIS_Shape(sh1); 
+  aContext->SetColor (ais1, Quantity_NOC_INDIANRED, Standard_False);
+  aContext->Display (ais1, Standard_False);
   DBRep::Set("sh0",sh1);
   gp_Pnt2d thepoint; 
 //  local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint); 
   thepoint = ProjLib::Project(pln->Pln(),pt3d);
-  Handle_Geom2d_CartesianPoint ThePoint = new Geom2d_CartesianPoint(thepoint); 
+  Handle(Geom2d_CartesianPoint) ThePoint = new Geom2d_CartesianPoint(thepoint); 
   Geom2dAdaptor_Curve acur1(gcir1) ; 
   Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ; 
   Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001); 
   printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions()); 
-  Handle_Geom2d_Circle gccc; 
+  Handle(Geom2d_Circle) gccc; 
   if( cirtanrad.NbSolutions() ) { 
     for( int i = 1; i<=cirtanrad.NbSolutions(); i++) { 
       gp_Circ2d ccc = cirtanrad.ThisSolution(i); 
@@ -659,12 +237,12 @@ static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/
       Standard_Character aStr[5];
       Sprintf(aStr,"sh%d",i);
       DBRep::Set(aStr,sh);
-      Handle_AIS_Shape ais = new AIS_Shape(sh); 
+      Handle(AIS_Shape) ais = new AIS_Shape(sh); 
       if( i ==1 ) 
-       aContext->SetColor(ais, Quantity_NOC_GREEN); 
+        aContext->SetColor (ais, Quantity_NOC_GREEN, Standard_False);
       if( i == 2) 
-       aContext->SetColor(ais, Quantity_NOC_HOTPINK); 
-      aContext->Display(ais); 
+        aContext->SetColor (ais, Quantity_NOC_HOTPINK, Standard_False);
+      aContext->Display (ais, Standard_False);
       Standard_Real ParSol1, ParSol2, ParArg1, ParArg2; 
       gp_Pnt2d PntSol1, PntSol2; 
       cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
@@ -673,6 +251,7 @@ static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/
       printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
     }
   }
+  aContext->UpdateCurrentViewer();
   return 0;
 }
 
@@ -714,7 +293,7 @@ static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, co
   TopoDS_Shape FP1; 
   TopoDS_Solid solid; 
   Handle(AIS_Shape) ais1; 
-  Handle_AIS_Shape ais2; 
+  Handle(AIS_Shape) ais2; 
   Handle(Geom_BezierSurface) BZ1;
   TColgp_Array2OfPnt array1(1,3,1,3);
   array1.SetValue(1,1,gp_Pnt(0,100,0));
@@ -732,11 +311,12 @@ static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, co
   ais1 = new AIS_Shape(F1);
   DBRep::Set("F1",F1);
   aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
-  aContext->Display(ais1);
+  aContext->Display (ais1, Standard_False);
   BRep_Builder B;
   TopoDS_Shell shell;
   B.MakeShell(shell);
   B.Add(shell, bzf1); 
+  shell.Closed (BRep_Tool::IsClosed (shell));
   B.MakeSolid(solid);
   B.Add(solid,shell); 
   gp_Dir D(0, 0, 1.0f); 
@@ -768,17 +348,17 @@ static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, co
   FP = BRepBuilderAPI_MakeFace(mkw.Wire()); 
   ais2 = new AIS_Shape( FP ); 
   aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False); 
-  aContext->Display( ais2 );
+  aContext->Display (ais2, Standard_False);
 
   DBRep::Set("FP",FP);
   
 //step 2. offseting the surface. 
-  Handle_Geom_OffsetSurface offsurf; 
+  Handle(Geom_OffsetSurface) offsurf; 
   offsurf = new Geom_OffsetSurface(BZ1, -100); 
   BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() ); 
   TopoDS_Face F2= bzf2.Face(); 
-  Handle_AIS_Shape ais22 = new AIS_Shape(F2); 
-  aContext->Display(ais22); 
+  Handle(AIS_Shape) ais22 = new AIS_Shape(F2); 
+  aContext->Display (ais22, Standard_False);
   DBRep::Set("F2",F2);
   
 //step 3. filleting the patch. 
@@ -788,18 +368,18 @@ static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, co
   Ex.Init(FP, TopAbs_VERTEX); 
   TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current()); 
   fillet.AddFillet(v1, 20); 
-  di << "\n" << "Error is " << fillet.Status() << "\n";
+  di << "\nError is " << fillet.Status() << "\n";
 //  printf("\nError is %d ", fillet.Status()); 
   Ex.Next(); 
   TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current()); 
   fillet.AddFillet(V2, 20); 
-  di << "\n" << "Error is " << fillet.Status() << "\n";
+  di << "\nError is " << fillet.Status() << "\n";
 //  printf("\nError is %d ", fillet.Status());
   fillet.Build(); 
   FP1 = fillet.Shape(); 
   ais2 = new AIS_Shape( FP1 ); 
   aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False); 
-  aContext->Display( ais2 ); 
+  aContext->Display (ais2, Standard_False);
 
   DBRep::Set("FP1",FP1);
   
@@ -811,13 +391,13 @@ static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, co
     { 
       TopoDS_Edge e1 = TopoDS::Edge(Ex.Current()); 
       Standard_Real f = 0.0, l = 0.0; 
-      Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l);
+      Handle(Geom_Curve) newBSplin = BRep_Tool::Curve(e1, f, l);
       newBSplin = new Geom_TrimmedCurve(newBSplin, f, l); 
       Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf); 
       myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge()); 
     } 
-  Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() ); 
-  aContext->Display(ais33);
+  Handle(AIS_Shape) ais33 = new AIS_Shape( myWire->Wire() ); 
+  aContext->Display (ais33, Standard_True);
 
   DBRep::Set("Wire",myWire->Wire());
   
@@ -854,21 +434,10 @@ static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 
 static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
-  if(argc > 2) {
-    di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+  if(argc != 1) {
+    di << "Usage : " << argv[0] << "\n";
     return 1;
   }
-  Standard_Boolean IsBRepAlgoAPI = Standard_True;
-  if (argc == 2) {
-    Standard_Integer IsB = Draw::Atoi(argv[1]);
-    if (IsB != 1) {
-      IsBRepAlgoAPI = Standard_False;
-#if ! defined(BRepAlgo_def01)
-//      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
-//      return 1;
-#endif
-    }
-  }
 
   double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
   double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
@@ -907,22 +476,10 @@ static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** a
   DBRep::Set("TS1",loft1.Shape());
   DBRep::Set("TS2",loft2.Shape());
 
-//#if ! defined(BRepAlgoAPI_def01)
-//  BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
-//#else
-//  BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
-//#endif
-  if (IsBRepAlgoAPI) {
-    di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
-    BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
-    DBRep::Set("F",result.Shape());
-  } else {
-    di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
-    BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
-    DBRep::Set("F",result.Shape());
-  }
+  di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())\n";
+  BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
+  DBRep::Set("F", result.Shape());
 
-//  DBRep::Set("F",result.Shape());
   return 0;
 }
 
@@ -944,14 +501,14 @@ static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/
   Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
   TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
   Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
-  aContext->Display(ais1);
-  aContext->SetColor(ais1, Quantity_NOC_BLUE1);
+  aContext->Display (ais1, Standard_False);
+  aContext->SetColor (ais1, Quantity_NOC_BLUE1, Standard_False);
   
   Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
   TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
   Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
-  aContext->Display(ais2);
-  aContext->SetColor(ais2, Quantity_NOC_RED);
+  aContext->Display (ais2, Standard_False);
+  aContext->SetColor (ais2, Quantity_NOC_RED, Standard_False);
   return 0;
 }
 
@@ -968,7 +525,7 @@ static Standard_Integer coordload (Draw_Interpretor& theDi,
     return 1;
   }
 
-  std::ifstream aFile (theArgVec[2], ios::in);
+  std::ifstream aFile (theArgVec[2], std::ios::in);
   if (!aFile)
   {
     theDi << "unable to open " << theArgVec[2] << " for input\n";
@@ -1034,14 +591,13 @@ static Standard_Integer BUC60876_ (Draw_Interpretor& di,
     return -1;
   }    
   if((argc != 2) && (argc != 3)) {
-    di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
+    di<< "usage : " << argv[0] << " shape [mode==1]\n";
     return -1;
   }
   TopoDS_Shape aShape = DBRep::Get(argv[1]);
   Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
-//  Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
   anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
-  aContext->Display(anIO);
+  aContext->Display (anIO, Standard_True);
   return 0;
 }
 
@@ -1067,21 +623,10 @@ static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n
 static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 
 {
-  if(argc > 2) {
-    di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+  if(argc != 1) {
+    di << "Usage : " << argv[0] << "\n";
     return 1;
   }
-  Standard_Boolean IsBRepAlgoAPI = Standard_True;
-  if (argc == 2) {
-    Standard_Integer IsB = Draw::Atoi(argv[1]);
-    if (IsB != 1) {
-      IsBRepAlgoAPI = Standard_False;
-#if ! defined(BRepAlgo_def01)
-//      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
-//      return 1;
-#endif
-    }
-  }
 
   //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
 
@@ -1122,38 +667,19 @@ static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** ar
   TopoDS_Shape SCon = cone.Shape();
   DBRep::Set("con", SCon);
 
-//#if ! defined(BRepAlgoAPI_def01)
-//  BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
-//#else
-//  BRepAlgo_Fuse SFuse(SCyl, SCon);
-//#endif
-//
-//  if(! SFuse.IsDone() )
-//    cout<<"Error: Boolean fuse operation failed !"<<endl;
-//
-//  TopoDS_Shape fuse = SFuse.Shape();
-
-  TopoDS_Shape fuse;
-  if (IsBRepAlgoAPI) {
-    di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
-    BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
-    if(! SFuse.IsDone() )
-      di<<"Error: Boolean fuse operation failed !"<<"\n";
-    fuse = SFuse.Shape();
-  } else {
-    di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
-    BRepAlgo_Fuse SFuse(SCyl, SCon);
-    if(! SFuse.IsDone() )
-      di<<"Error: Boolean fuse operation failed !"<<"\n";
-    fuse = SFuse.Shape();
+  di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)\n";
+  BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
+  if (!SFuse.IsDone()) {
+    di << "Error: Boolean fuse operation failed !\n";
+  }
+  else {
+    const TopoDS_Shape& fuse = SFuse.Shape();
+    DBRep::Set("fus", fuse);
   }
-
-  DBRep::Set("fus", fuse);
-       
   return 0;
 }
 
-#include <Dico_DictionaryOfInteger.hxx>
+#include <NCollection_DataMap.hxx>
 #include <TColStd_HSequenceOfAsciiString.hxx>
 #include <TopExp.hxx>
 #include <TopoDS_Iterator.hxx>
@@ -1166,13 +692,13 @@ static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/
   TopoDS_Shape aShape = DBRep::Get(argv[1]);
   if(aShape.IsNull())
   {
-    di<<"Invalid input shape"<<"\n";
+    di<<"Invalid input shape\n";
     return 1;
   }
-  Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
+  NCollection_DataMap<TCollection_AsciiString, Standard_Integer> aMap;
   Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
   Standard_CString aString;
-  Standard_Integer i=1,j=1,l=1,aa=1;
+  Standard_Integer l=0;
   TopExp_Explorer expl;
   Standard_Real f3d,l3d;
   for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
@@ -1182,15 +708,11 @@ static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/
     Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
     aString = aSurface->DynamicType()->Name();
 
-    if(aDico->GetItem(aString,aa) != 0)
-    {
-      aDico->GetItem(aString,aa);
-      aDico->SetItem(aString,aa+1);
-    } else  {
-      aDico->SetItem(aString,1);
+    if (aMap.IsBound(aString))
+      aMap.ChangeFind(aString)++;
+    else {
+      aMap.Bind(aString, 1);
       aSequence->Append(aString);
-      aa=1;
-      i++;
     }
   }
   // PCURVES
@@ -1202,55 +724,46 @@ static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/
     TopoDS_Iterator it (aWire); 
     for (; it.More(); it.Next()) {
       TopoDS_Edge Edge = TopoDS::Edge (it.Value());
-    Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
-    aString = aCurve2d->DynamicType()->Name();
-        if(aDico->GetItem(aString,aa) != 0)
-        {         
-          aDico->GetItem(aString,aa);
-          aDico->SetItem(aString,aa+1);
-        } else  {
-          aDico->SetItem(aString,1);
-          aSequence->Append(aString);
-          i++;
-          aa=1;
-        }
+      Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
+      aString = aCurve2d->DynamicType()->Name();
+      if(aMap.IsBound(aString))
+        aMap.ChangeFind(aString)++;
+      else  {
+        aMap.Bind(aString, 1);
+        aSequence->Append(aString);
+      }
     }
   }
   // 3d CURVES
   TopExp_Explorer exp;
   for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next()) 
   {
-      TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
-      Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
-      if(aCurve3d.IsNull())
+    TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
+    Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
+    if(aCurve3d.IsNull())
+    {
+      l++;
+    } else {
+      aString = aCurve3d->DynamicType()->Name();
+      if (aMap.IsBound(aString))
       {
-        l++;
-        goto aLabel;
+        aMap.ChangeFind(aString)++;
+      } else {
+        aMap.Bind(aString, 1);
+        aSequence->Append(aString);
       }
-      aString = aCurve3d->DynamicType()->Name();
-        if(aDico->GetItem(aString,aa) != 0)
-        {
-          aDico->GetItem(aString,aa);
-          aDico->SetItem(aString,aa+1);
-        } else  {
-          aDico->SetItem(aString,1);
-          aSequence->Append(aString);
-          i++;
-          aa=1;
-        }
-    aLabel:;
     }
+  }
   // Output 
   di<<"\n";
-  for(j=1;j<i;j++)
-    {
-      aDico->GetItem(aSequence->Value(j),aa);
-      di<<aa<<"   --   "<<aSequence->Value(j).ToCString()<<"\n";
-    }    
+
+  for (Standard_Integer i = 1; i <= aSequence->Length(); i++) {
+    di << aMap.Find(aSequence->Value(i)) << "   --   " << aSequence->Value(i).ToCString() << "\n";
+  }
 
   di<<"\n";
-  di<<"Degenerated edges :"<<"\n";
-  di<<l<<"   --    "<<"Degenerated edges "<<"\n";
+  di<<"Degenerated edges :\n";
+  di<<l<<"   --    Degenerated edges \n";
 
   return 0;
 
@@ -1260,21 +773,10 @@ static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/
 
 static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
 {
-  if(argc > 2) {
-    di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+  if(argc != 1) {
+    di << "Usage : " << argv[0] << "\n";
     return 1;
   }
-  Standard_Boolean IsBRepAlgoAPI = Standard_True;
-  if (argc == 2) {
-    Standard_Integer IsB = Draw::Atoi(argv[1]);
-    if (IsB != 1) {
-      IsBRepAlgoAPI = Standard_False;
-#if ! defined(BRepAlgo_def01)
-//      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
-//      return 1;
-#endif
-    }
-  }
 
   gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
   BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
@@ -1291,52 +793,21 @@ static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, co
   TopoDS_Shape sh2 = trans1.Shape();
   DBRep::Set("sh2",sh2);
 
-//#if ! defined(BRepAlgoAPI_def01)
-//  BRepAlgoAPI_Fuse fuse1(sh1, sh2);
-//#else
-//  BRepAlgo_Fuse fuse1(sh1, sh2);
-//#endif
-//
-//  TopoDS_Shape fsh1 = fuse1.Shape();
-
-  TopoDS_Shape fsh1;
-  if (IsBRepAlgoAPI) {
-    di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
-    BRepAlgoAPI_Fuse fuse1(sh1, sh2);
-    fsh1 = fuse1.Shape();
-  } else {
-    di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
-    BRepAlgo_Fuse fuse1(sh1, sh2);
-    fsh1 = fuse1.Shape();
-  }
-
+  di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)\n";
+  BRepAlgoAPI_Fuse fuse1(sh1, sh2);
+  TopoDS_Shape fsh1 = fuse1.Shape();
   DBRep::Set("fsh1",fsh1);
+
   BRepBuilderAPI_Transform trans2(fsh1, trsf2);
   TopoDS_Shape sh3 = trans2.Shape();
   DBRep::Set("sh3",sh3);
 
-//#if ! defined(BRepAlgoAPI_def01)
-//  BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
-//#else
-//  BRepAlgo_Fuse fuse2(fsh1,sh3);
-//#endif
-//
-//  TopoDS_Shape fsh2 = fuse2.Shape();
-
-  TopoDS_Shape fsh2;
-  if (IsBRepAlgoAPI) {
-    di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
-    BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
-    fsh2 = fuse2.Shape();
-  } else {
-    di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
-    BRepAlgo_Fuse fuse2(fsh1,sh3);
-    fsh2 = fuse2.Shape();
-  }
-
+  di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)\n";
+  BRepAlgoAPI_Fuse fuse2(fsh1, sh3);
+  const TopoDS_Shape& fsh2 = fuse2.Shape();
   DBRep::Set("fsh2",fsh2);
-  Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2);
-//  aContext->Display(aisp1);
+
+  Handle(AIS_Shape) aisp1 = new AIS_Shape(fsh2);
   return 0;
 }
 
@@ -1372,7 +843,7 @@ static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*ar
   
 static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=2) {
-    di << "Usage : " << argv[0] << " D" << "\n";
+    di << "Usage : " << argv[0] << " D\n";
     di<<1;
     return 0;
   }
@@ -1399,7 +870,7 @@ static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 
 static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=2) {
-    di << "Usage : " << argv[0] << " D" << "\n";
+    di << "Usage : " << argv[0] << " D\n";
     di<<-1;
     return 0;
   }
@@ -1421,7 +892,7 @@ static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char **
 
 static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=3) {
-    di << "Usage : " << argv[0] << " D Label" << "\n";
+    di << "Usage : " << argv[0] << " D Label\n";
     di<<1;
     return 0;
   }
@@ -1440,7 +911,7 @@ static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char **
 
 static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=2) {
-    di << "Usage : " << argv[0] << " D" << "\n";
+    di << "Usage : " << argv[0] << " D\n";
     di<<1;
     return 0;
   }
@@ -1480,7 +951,7 @@ static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** a
     Handle(TDF_Delta) D = IDL.Value();
     TCollection_ExtendedString S(Names[i-1]);
     D->SetName(S);
-//    cout<<" U"<<i<<"="<<D->Name()<<endl;
+//    std::cout<<" U"<<i<<"="<<D->Name()<<std::endl;
   }
   
   aDocument->Undo();
@@ -1491,7 +962,7 @@ static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 
   for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
     Handle(TDF_Delta) D = IDL.Value();
-//    cout<<" U"<<i<<"="<<D->Name()<<endl;
+//    std::cout<<" U"<<i<<"="<<D->Name()<<std::endl;
   }
 
   TCollection_ExtendedString n2name ("n2");
@@ -1510,7 +981,7 @@ static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 
 static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=3) {
-    di << "Usage : " << argv[0] << " D Shape" << "\n";
+    di << "Usage : " << argv[0] << " D Shape\n";
     di<<1;
     return 0;
   }
@@ -1519,7 +990,7 @@ static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** a
   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
   
   TopoDS_Shape s = DBRep::Get(argv[2]);
-  if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
+  if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
   TDF_Label L;
   DDF::AddLabel(aDF, "0:2", L);
   TNaming_Builder SI (L);
@@ -1537,7 +1008,7 @@ static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 
 static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=3) {
-    di << "Usage : " << argv[0] << " D Shape" << "\n";
+    di << "Usage : " << argv[0] << " D Shape\n";
     di<<1;
     return 0;
   }
@@ -1546,7 +1017,7 @@ static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** a
   if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
   
   TopoDS_Shape s = DBRep::Get(argv[2]);
-  if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
+  if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
   TDF_Label L;
   DDF::AddLabel(aDF, "0:2", L);
   TNaming_Builder SI (L);
@@ -1564,12 +1035,11 @@ static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if (argc == 2) {
     TCollection_ExtendedString path (argv[1]); 
-    Handle(TDocStd_Application) A;
-    if (!DDocStd::Find(A)) {di<<1;return 0;}
+    Handle(TDocStd_Application) A = DDocStd::GetApplication();
     Handle(TDocStd_Document) D;
     Standard_Integer insession = A->IsInSession(path);
     if (insession > 0) {  
-      di <<"document " << insession << "  is already in session" << "\n";
+      di <<"document " << insession << "  is already in session\n";
       di<<2;
       return 0;
     }
@@ -1585,7 +1055,7 @@ static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 
 static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=2) {
-    di << "Usage : " << argv[0] << " D" << "\n";
+    di << "Usage : " << argv[0] << " D\n";
     di<<1;
     return 0;
   }
@@ -1596,9 +1066,8 @@ static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** a
   TDF_Label L;
   DDF::AddLabel(aDF, "0:2", L);
  
-  Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
-
-  AISP->Set(L,TDataXtd_Constraint::GetID());
+  Handle(TPrsStd_AISPresentation) AISP = 
+    TPrsStd_AISPresentation::Set(L,TDataXtd_Constraint::GetID());
 
   if (AISP->HasOwnMode()) {di<<3;return 0;}
   AISP->SetMode(3);
@@ -1613,7 +1082,7 @@ static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 
 static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=2) {
-    di << "Usage : " << argv[0] << " D" << "\n";
+    di << "Usage : " << argv[0] << " D\n";
     di<<1;
     return 0;
   }
@@ -1641,7 +1110,7 @@ static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** a
 
 static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
   if(argc!=2) {
-    di << "Usage : " << argv[0] << " D" << "\n";
+    di << "Usage : " << argv[0] << " D\n";
     di<<1;
     return 0;
   }
@@ -1682,11 +1151,11 @@ static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** a
       }
       else {
        if (prs->HasOwnWidth()){ 
-//         cout << "Width = " << prs->Width() << endl;
+//         std::cout << "Width = " << prs->Width() << std::endl;
          di<<prs->Width();
        }
        else{
-         di << "AISWidth: Warning : Width wasn't set" << "\n";
+         di << "AISWidth: Warning : Width wasn't set\n";
          di<<(-4);
        }
       }
@@ -1733,27 +1202,11 @@ static Standard_Integer BUC60921 (Draw_Interpretor& di,
 
 static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
 {
-  //if(argc!=2)
-  //  {
-  //    cerr << "Usage : " << a[0] << " file.igs" << endl;
-  //    return -1;
-  //  }
-  if(argc < 2 || argc > 3) {
-    di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+  if (argc != 2) {
+    di << "Usage : " << a[0] << " file.igs\n";
     return 1;
   }
-  Standard_Boolean IsBRepAlgoAPI = Standard_True;
-  if (argc == 3) {
-    Standard_Integer IsB = Draw::Atoi(a[2]);
-    if (IsB != 1) {
-      IsBRepAlgoAPI = Standard_False;
-#if ! defined(BRepAlgo_def01)
-//      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
-//      return 1;
-#endif
-    }
-  }
-  
+
   Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext(); 
 
   if(myContext.IsNull()) {
@@ -1778,6 +1231,7 @@ static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, c
     TopoDS_Face face = TopoDS::Face(list.FindKey(i));
     builder.Add(shell, face);
   }
+  shell.Closed (BRep_Tool::IsClosed (shell));
 
   BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
   TopoDS_Solid sol = half.Solid();
@@ -1785,26 +1239,12 @@ static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, c
   BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
   TopoDS_Shape sh = cyl.Shape();
 
-//#if ! defined(BRepAlgoAPI_def01)
-//  BRepAlgoAPI_Fuse fuse(sol, sh);
-//#else
-//  BRepAlgo_Fuse fuse(sol, sh);
-//#endif
-//
-//  sh = fuse.Shape();
-
-  if (IsBRepAlgoAPI) {
-    di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
-    BRepAlgoAPI_Fuse fuse(sol, sh);
-    sh = fuse.Shape();
-  } else {
-    di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
-    BRepAlgo_Fuse fuse(sol, sh);
-    sh = fuse.Shape();
-  }
+  di << "BRepAlgoAPI_Fuse fuse(sol, sh)\n";
+  BRepAlgoAPI_Fuse fuse(sol, sh);
+  sh = fuse.Shape();
 
   Handle(AIS_Shape) res = new AIS_Shape(sh);
-  myContext->Display( res );
+  myContext->Display (res, Standard_True);
   return 0;
 }
 
@@ -1812,23 +1252,9 @@ void QABugs::Commands_3(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
   theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
-  theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
-  theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
-  theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
   theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
   theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
-  theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
-  theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
-  theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
-  theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);  
-  theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
-
-  theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
-  theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
-  theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
-  theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
-
-  theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
+  
   theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
   theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
   theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
@@ -1837,7 +1263,7 @@ void QABugs::Commands_3(Draw_Interpretor& theCommands) {
 
   theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
 
-  theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
+  theCommands.Add("OCC10006","OCC10006",__FILE__,OCC10006,group);
 
   theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
 
@@ -1848,11 +1274,11 @@ void QABugs::Commands_3(Draw_Interpretor& theCommands) {
   theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group); 
   theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group); 
 
-  theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
+  theCommands.Add("TestCMD","TestCMD",__FILE__,TestCMD,group);
 
   theCommands.Add("statface","statface face",__FILE__,statface,group);
 
-  theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
+  theCommands.Add("BUC60841","BUC60841",__FILE__,BUC60841,group);
 
   theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
 
@@ -1869,6 +1295,6 @@ void QABugs::Commands_3(Draw_Interpretor& theCommands) {
   theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
   theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
 
-  theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );
+  theCommands.Add("BUC60951","BUC60951 file.igs",__FILE__,BUC60951_, group );
 
 }