0028643: Coding rules - eliminate GCC compiler warnings -Wmisleading-indentation
[occt.git] / src / QABugs / QABugs_11.cxx
index 8f11173..ef0c381 100644 (file)
@@ -1,28 +1,23 @@
 // Created on: 2002-03-20
 // Created by: QA Admin
-// Copyright (c) 2002-2012 OPEN CASCADE SAS
+// Copyright (c) 2002-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// 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.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #include <stdio.h>
 
 #include <QABugs.hxx>
 
+#include <Draw.hxx>
 #include <Draw_Interpretor.hxx>
 #include <DBRep.hxx>
 #include <DrawTrSurf.hxx>
@@ -31,6 +26,7 @@
 #include <AIS_Shape.hxx>
 #include <TopoDS_Shape.hxx>
 
+#include <Geom_Surface.hxx>
 #include <Geom_Axis2Placement.hxx>
 #include <gp.hxx>
 #include <gp_Trsf.hxx>
@@ -79,6 +75,7 @@
 #include <TColStd_Array1OfInteger.hxx>
 #include <Geom_BSplineCurve.hxx>
 #include <TColgp_Array1OfPnt.hxx>
+#include <AIS_ColorScale.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
 #include <IGESData_IGESModel.hxx>
 #include <IGESData_IGESEntity.hxx>
 #include <V3d_View.hxx>
+#include <BRepFeat_SplitShape.hxx>
+#include <BRepAlgoAPI_Section.hxx>
+#include <TColStd_PackedMapOfInteger.hxx>
 
-#include <tcl.h>
-
-#if ! defined(WNT)
+#if ! defined(_WIN32)
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
 #else
 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
@@ -124,7 +122,7 @@ static Standard_Integer  OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/
   Graphic3d_MaterialAspect mat(Graphic3d_NOM_PLASTIC);
   AS->SetMaterial(mat);
   AS->SetColor(Quantity_NOC_RED);
-  myAISContext->Display(AS);
+  myAISContext->Display (AS, Standard_False);
 
   gp_Trsf TouchTrsf;
   TouchTrsf.SetTranslation(gp_Vec(20, 20, 0));
@@ -162,7 +160,7 @@ static Standard_Integer  OCC128 (Draw_Interpretor& di, Standard_Integer /*argc*/
 //
 //    Standard_Integer aNum = -1;
 //
-//    if(atoi(argv[2])) {
+//    if(Draw::Atoi(argv[2])) {
 //      aNum = anAISCtx->OpenLocalContext();
 //    }
 //
@@ -217,34 +215,35 @@ static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, con
     return 1;
   }
 
-  if(anAISCtx->HasOpenedContext()) anAISCtx->CloseAllContexts();
-  anAISCtx->EraseAll();
+  anAISCtx->EraseAll (Standard_False);
 
   //load primitives to context
-  Handle(AIS_Shape) aSh1 = new AIS_Shape(aBox);
-  anAISCtx->Display(aSh1);
+  Handle(AIS_InteractiveObject) aSh1 = new AIS_Shape(aBox);
+  anAISCtx->Display (aSh1, Standard_False);
 
-  Handle(AIS_Shape) aSh2 = new AIS_Shape(aSphere);
-  anAISCtx->Display(aSh2);
+  Handle(AIS_InteractiveObject) aSh2 = new AIS_Shape(aSphere);
+  anAISCtx->Display (aSh2, Standard_False);
 
-  Handle(AIS_Shape) aSh3 = new AIS_Shape(aCone);
-  anAISCtx->Display(aSh3);
+  Handle(AIS_InteractiveObject) aSh3 = new AIS_Shape(aCone);
+  anAISCtx->Display (aSh3, Standard_False);
 
-  Handle(AIS_Shape) aSh4 = new AIS_Shape(aCyl);
-  anAISCtx->Display(aSh4);
+  Handle(AIS_InteractiveObject) aSh4 = new AIS_Shape(aCyl);
+  anAISCtx->Display (aSh4, Standard_False);
 
   //set selected
-  anAISCtx->InitCurrent();
-  anAISCtx->AddOrRemoveCurrentObject(aSh1);
-  anAISCtx->AddOrRemoveCurrentObject(aSh2);
-  anAISCtx->AddOrRemoveCurrentObject(aSh3);
-  anAISCtx->AddOrRemoveCurrentObject(aSh4);
+  anAISCtx->InitSelected();
+  anAISCtx->AddOrRemoveSelected (aSh1, Standard_False);
+  anAISCtx->AddOrRemoveSelected (aSh2, Standard_False);
+  anAISCtx->AddOrRemoveSelected (aSh3, Standard_False);
+  anAISCtx->AddOrRemoveSelected (aSh4, Standard_False);
 
   //remove all this objects from context
-  anAISCtx->Clear(aSh1, Standard_False);
-  anAISCtx->Clear(aSh2, Standard_False);
-  anAISCtx->Clear(aSh3, Standard_False);
-  anAISCtx->Clear(aSh4, Standard_False);
+  anAISCtx->Remove (aSh1, Standard_False);
+  anAISCtx->Remove (aSh2, Standard_False);
+  anAISCtx->Remove (aSh3, Standard_False);
+  anAISCtx->Remove (aSh4, Standard_False);
+
+  anAISCtx->UpdateCurrentViewer();
   return 0;
 }
 
@@ -253,7 +252,7 @@ static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** a
     printf("Usage: %s  iges_input [name]\n",argv[0]);
     return(1);
   }
-  Standard_Character *Ch;
+  Standard_Character *Ch = NULL;
 
   if(argc > 2) {
     Ch = new Standard_Character[strlen(argv[2])+3];
@@ -272,60 +271,13 @@ static int BUC60610(Draw_Interpretor& di, Standard_Integer argc, const char ** a
     di << "Num points = " << plin.NbPoints() << "\n";
     if(argc > 2) {
       i++;
-      sprintf(Ch,"%s_%i",argv[2],1);
+      Sprintf(Ch,"%s_%i",argv[2],1);
       DBRep::Set(Ch,E);
     }
   }
   return (1);
 }
 
-static Standard_Integer BUC60661(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
-{
-  if(argc!=2)
-    {
-      di << "Usage : " << a[0] << " file.igs" << "\n";
-      return -1;
-    }
-
-  Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
-
-  if(myContext.IsNull()) {
-    di << "use 'vinit' command before " << a[0] << "\n";
-    return -1;
-  }
-
-  // MKV 30.03.05
-#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
-  const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
-#else
-  Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY);
-#endif
-
-  Standard_Character  *file1 = new Standard_Character [strlen(DD)+strlen(a[1])+2];
-  sprintf(file1,"%s/%s",DD,a[1]);
-
-  IGESToBRep_Reader reader;
-  Standard_Integer status = reader.LoadFile(file1);
-  if( !status ) {
-    IGESToBRep::Init();
-      reader.TransferRoots();
-      TopoDS_Shape shape = reader.OneShape();
-
-      Handle(AIS_Shape) importedShape = new AIS_Shape(shape);
-
-      Handle(V3d_Viewer) myPView = myContext->CurrentViewer();
-
-      if( ! myPView.IsNull() && (myPView->DefaultVisualization() == V3d_WIREFRAME) )
-       importedShape->SetDisplayMode(AIS_WireFrame);
-      else importedShape->SetDisplayMode(AIS_Shaded);
-      myContext->Display(importedShape);
-    }
-
-  printf("\n End of my  IGES to 3D-viewer *****************>\n");
-  return 0;
-}
-
-
 //====================================================
 //
 // Following code is inserted from
@@ -358,7 +310,7 @@ static int OCC105(Draw_Interpretor& di, Standard_Integer argc, const char ** arg
   }
 //  TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get("aa.brep"));
   TopoDS_Wire myTopoDSWire = TopoDS::Wire(DBRep::Get(argv[1]));
-  Standard_Real l = 0.5; //atof(argv[2]);
+  Standard_Real l = 0.5; //Draw::Atof(argv[2]);
   // Find the first vertex of the wire
   BRepTools_WireExplorer wire_exp(myTopoDSWire);
   TopoDS_Vertex vlast;
@@ -425,7 +377,7 @@ static int pipe_OCC9 (Draw_Interpretor& di,
                      Standard_Integer n, const char ** a)
 {
   if (n < 6) {
-    di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]" << "\n";
+    di << "Usage: " << a[0] << " result path cur1 cur2 radius [tolerance]\n";
     return 1;
   }
 
@@ -434,7 +386,7 @@ static int pipe_OCC9 (Draw_Interpretor& di,
   for (i=2 ; i<=4; i++) {
     Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast( DrawTrSurf::Get(a[i]) );
     if (aC.IsNull()) {
-      di << a[i] << " is not a curve" << "\n";
+      di << a[i] << " is not a curve\n";
       return 1;
     }
     aCurveSeq.Append(aC);
@@ -443,14 +395,19 @@ static int pipe_OCC9 (Draw_Interpretor& di,
   GeomFill_Pipe aPipe(Handle(Geom_Curve)::DownCast( aCurveSeq(1) ),
                      Handle(Geom_Curve)::DownCast( aCurveSeq(2) ),
                      Handle(Geom_Curve)::DownCast( aCurveSeq(3) ),
-                     atof (a[5]) );
+                     Draw::Atof (a[5]) );
 
   if (n == 7) {
-    aPipe.Perform(atof (a[6]), Standard_True);
+    aPipe.Perform(Draw::Atof (a[6]), Standard_True);
   } else {
     aPipe.Perform(Standard_True/*, Standard_True*/);
   }
 
+  if (!aPipe.IsDone()) {
+    di << "GeomFill_Pipe cannot make a surface\n";
+    return 1;
+  }
+
   Handle(Geom_Surface) aSurf = aPipe.Surface();
 
   DrawTrSurf::Set(a[1], aSurf);
@@ -518,21 +475,21 @@ Standard_Integer  OCC157(Draw_Interpretor& di,
 //static Standard_Integer findplanarsurface(Draw_Interpretor&, Standard_Integer n, const char ** a)
 {
   if (n<3) {
-    di << "bad number of arguments" <<"\n";
+    di << "bad number of arguments\n";
     return 1;
   }
 
   // try to read a shape:
   TopoDS_Shape inputShape=DBRep::Get(a[2]);
   if (inputShape.IsNull() || inputShape.ShapeType() != TopAbs_WIRE) {
-    di << "Invalid input shape"<< "\n";
+    di << "Invalid input shape\n";
     return 1;
   }
-  Standard_Real toler = atof(a[3]);
+  Standard_Real toler = Draw::Atof(a[3]);
   TopoDS_Wire aWire = TopoDS::Wire(inputShape);
   BRepLib_FindSurface FS(aWire, toler, Standard_True);
   if(FS.Found()) {
-    di<<"OCC157: OK; Planar surface is found"<<"\n";
+    di<<"OCC157: OK; Planar surface is found\n";
     Handle(Geom_Surface) aSurf = FS.Surface();
     BRepBuilderAPI_MakeFace aMakeFace(aSurf,aWire,Standard_True);
     if(aMakeFace.IsDone()) {
@@ -575,7 +532,7 @@ Standard_Integer  OCC165(Draw_Interpretor& di ,
  {
    if (n > 2)
      {
-       di <<"Usage : " << a[0] << " [file]"<<"\n";
+       di <<"Usage : " << a[0] << " [file]\n";
        return 1;
      }
        di.Eval ("axo");
@@ -639,10 +596,8 @@ Standard_Integer  OCC165(Draw_Interpretor& di ,
 }
 
 #include<BRepAlgoAPI_Cut.hxx>
-#include<BRepAlgo_Cut.hxx>
 
 #include<BRepPrimAPI_MakeHalfSpace.hxx>
-#include<Handle_Geom_CartesianPoint.hxx>
 #include<Geom_CartesianPoint.hxx>
 #include<AIS_Point.hxx>
 
@@ -653,71 +608,55 @@ Standard_Integer  OCC165(Draw_Interpretor& di ,
 static Standard_Integer OCC297 (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
 
 {
-
   Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
-  if(myAISContext.IsNull()) {
+  if (myAISContext.IsNull()) {
     di << "use 'vinit' command before " << argv[0] << "\n";
     return -1;
   }
+  
+  gp_Pnt pt1_(250., 250., 0.);
+  gp_Pnt pt2_(-250., 250., 0.);
+  gp_Pnt pt3_(-250., -250., 0.);
+  gp_Pnt pt4_(250., -250., 0.);
+  BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
+  BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
+  BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
+  BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
+
+  BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
+  BRepBuilderAPI_MakeFace face_(wire_);
+  TopoDS_Face sh_ = face_.Face();
+
+  int up = 1;
+
+  gp_Pnt g_pnt;
+  if (up)
+    g_pnt = gp_Pnt(0, 0, -100);
+  else
+    g_pnt = gp_Pnt(0, 0, 100);
 
+  myAISContext->EraseAll(Standard_False);
+  Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
+  Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
+  myAISContext->Display(AISPoint, Standard_True);
 
-    gp_Pnt pt1_(250.,250.,0.);
-    gp_Pnt pt2_(-250.,250.,0.);
-    gp_Pnt pt3_(-250.,-250.,0.);
-    gp_Pnt pt4_(250.,-250.,0.);
-    BRepBuilderAPI_MakeEdge edg1_(pt1_, pt2_);
-    BRepBuilderAPI_MakeEdge edg2_(pt2_, pt3_);
-    BRepBuilderAPI_MakeEdge edg3_(pt3_, pt4_);
-    BRepBuilderAPI_MakeEdge edg4_(pt4_, pt1_);
-
-    BRepBuilderAPI_MakeWire wire_(edg1_, edg2_, edg3_, edg4_);
-    BRepBuilderAPI_MakeFace face_(wire_);
-    TopoDS_Face sh_ = face_.Face();
-
-    int up = 1;
-
-    gp_Pnt g_pnt;
-    if(up)
-        g_pnt = gp_Pnt(0,0,-100);
-    else
-          g_pnt = gp_Pnt(0,0,100);
-
-    myAISContext->EraseAll(Standard_False);
-        Handle(Geom_CartesianPoint) GEOMPoint = new Geom_CartesianPoint(g_pnt);
-        Handle(AIS_Point) AISPoint = new AIS_Point(GEOMPoint);
-    myAISContext->Display(AISPoint);
-
-    BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
-    TopoDS_Solid sol1_ = half_.Solid();
-//         Handle(AIS_Shape) AISHalf = new AIS_Shape(sol1_);
-//         AISHalf->SetColor(Quantity_NOC_GREEN);
-//     myAISContext->Display(AISHalf);
-
-  DBRep::Set("Face",sol1_);
-
-    gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
+  BRepPrimAPI_MakeHalfSpace half_(sh_, g_pnt);
+  TopoDS_Solid sol1_ = half_.Solid();
 
-    Standard_Real x=0., y=0., z=-80.;
+  DBRep::Set("Face", sol1_);
 
-    BRepPrimAPI_MakeBox box(gp_Pnt(x,y,z),gp_Pnt(x+150,y+200,z+200));
-//         Handle(AIS_Shape) AISBox = new AIS_Shape(box);
-//         AISBox->SetColor(Quantity_NOC_BLUE1);
-//     myAISContext->Display(AISBox);
+  gp_Ax1 ax1_(gp_Pnt(0., 0., -100.), gp_Dir(0., 0., 1.));
 
DBRep::Set("Box",box.Shape());
 Standard_Real x = 0., y = 0., z = -80.;
 
-//     BRepAlgoAPI_Cut cut( sol1_, box.Shape() );
-//         //BRepAlgoAPI_Cut cut(  box.Shape(), sol1_ );
-//     TopoDS_Shape sh1_ = cut.Shape();
-//         Handle(AIS_Shape) AISCut = new AIS_Shape(sh1_);
-//         AISCut->SetColor(Quantity_NOC_RED);
-//     myAISContext->Display(AISCut);
+  BRepPrimAPI_MakeBox box(gp_Pnt(x, y, z), gp_Pnt(x + 150, y + 200, z + 200));
 
-//  DBRep::Set("Cut",sh1_);
+  DBRep::Set("Box", box.Shape());
 
   return 0;
 
 }
+
 #include<GProp_GProps.hxx>
 #include<BRepGProp.hxx>
 
@@ -726,7 +665,7 @@ static Standard_Integer OCC305 (Draw_Interpretor& di,Standard_Integer argc, cons
 {
   if (argc != 2)
   {
-    di <<"Usage : " << argv[0] << " file"<<"\n";
+    di <<"Usage : " << argv[0] << " file\n";
     return 1;
   }
   Standard_CString file = argv[1];
@@ -790,12 +729,12 @@ static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/,
 
   BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
   Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
+  myAISContext->SetAutoActivateSelection (Standard_False);
   myAISContext->Display(anAISBox, 1);
-  anAISBox->SetSelectionMode(-1);
-  Standard_Integer myLocContInd = myAISContext->OpenLocalContext();
-  myAISContext->CloseLocalContext(myLocContInd);
-  Standard_Integer aSelMode = ((Handle(AIS_InteractiveObject)) anAISBox)->SelectionMode();
-  if(aSelMode != -1)
+
+  TColStd_ListOfInteger anActivatedModes;
+  myAISContext->ActivatedModes (anAISBox, anActivatedModes);
+  if(anActivatedModes.Extent() != 1 || anActivatedModes.First() != -1 )
     return 1;
 
   return 0;
@@ -809,35 +748,49 @@ static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/,
 static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
 {
   if (nb != 2) {
-    di << "Usage: " << a[0] << " Doc" << "\n";
+    di << "Usage: " << a[0] << " Doc\n";
     return 1;
   }
 
   Handle(TDocStd_Document) D;
   if (!DDocStd::GetDocument(a[1],D)) return 1;
 
-  Handle(TDocStd_Application) A;
-  if (!DDocStd::Find(A)) return 1;
+  Handle(TDocStd_Application) A = DDocStd::GetApplication();
 
   TCollection_ExtendedString theStatusMessage;
   if (!D->IsSaved()) {
-    di << "this document has never been saved" << "\n";
+    di << "this document has never been saved\n";
     return 0;
   }
   PCDM_StoreStatus theStatus = A->Save(D, theStatusMessage);
   if (theStatus != PCDM_SS_OK ) {
     switch ( theStatus ) {
-    case PCDM_SS_DriverFailure: {
-      di << " Could not store , no driver found to make it " <<"\n" ;
-      break ;
-    }
-    case PCDM_SS_WriteFailure: {
-      di << " Write access failure " << "\n" ;
-      break;
-    }
-    case PCDM_SS_Failure: {
-      di << " Write failure " << "\n" ;
-    }
+      case PCDM_SS_DriverFailure: {
+        di << "Error saving document: Could not store , no driver found to make it\n";
+        break ;
+      }
+      case PCDM_SS_WriteFailure: {
+        di << "Error saving document: Write access failure\n";
+        break;
+      }
+      case PCDM_SS_Failure: {
+        di << "Error saving document: Write failure\n" ;
+        break;
+      }
+      case PCDM_SS_Doc_IsNull: {
+        di << "Error saving document: No document to save\n";
+        break ;
+      }
+      case PCDM_SS_No_Obj: {
+        di << "Error saving document: No objects written\n";
+        break;
+      }
+      case PCDM_SS_Info_Section_Error: {
+        di << "Error saving document: Write info section failure\n" ;
+        break;
+      }
+      default:
+          break;
     }
     return 1;
   }
@@ -847,7 +800,7 @@ static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb,
 static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
 {
   if (nb != 3) {
-    di << "Usage: " << a[0] << " Doc Path" << "\n";
+    di << "Usage: " << a[0] << " Doc Path\n";
     return 1;
   }
 
@@ -855,24 +808,38 @@ static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb
   if (!DDocStd::GetDocument(a[1],D)) return 1;
 
   TCollection_ExtendedString path (a[2]);
-  Handle(TDocStd_Application) A;
-  if (!DDocStd::Find(A)) return 1;
+  Handle(TDocStd_Application) A = DDocStd::GetApplication();
 
   TCollection_ExtendedString theStatusMessage;
   PCDM_StoreStatus theStatus = A->SaveAs(D,path, theStatusMessage);
   if (theStatus != PCDM_SS_OK ) {
     switch ( theStatus ) {
-    case PCDM_SS_DriverFailure: {
-      di << " Could not store , no driver found to make it " <<"\n" ;
-      break ;
-    }
-    case PCDM_SS_WriteFailure: {
-      di << " Write access failure " << "\n" ;
-      break;
-    }
-    case PCDM_SS_Failure: {
-      di << " Write failure " << "\n" ;
-    }
+      case PCDM_SS_DriverFailure: {
+        di << "Error saving document: Could not store , no driver found to make it\n";
+        break ;
+      }
+      case PCDM_SS_WriteFailure: {
+        di << "Error saving document: Write access failure\n";
+        break;
+      }
+      case PCDM_SS_Failure: {
+        di << "Error saving document: Write failure\n" ;
+        break;
+      }
+      case PCDM_SS_Doc_IsNull: {
+        di << "Error saving document: No document to save\n";
+        break ;
+      }
+      case PCDM_SS_No_Obj: {
+        di << "Error saving document: No objects written\n";
+        break;
+      }
+      case PCDM_SS_Info_Section_Error: {
+        di << "Error saving document: Write info section failure\n" ;
+        break;
+      }
+      default:
+          break;
     }
     return 1;
   }
@@ -882,76 +849,47 @@ static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb
 
 #include <BRepClass3d_SolidClassifier.hxx>
 
-Standard_Integer OCC299bug (Draw_Interpretor& di,
-                           Standard_Integer n,
-                           const char ** a)
+Standard_Integer OCC299bug (Draw_Interpretor& theDi,
+                            Standard_Integer  theArgNb,
+                            const char**      theArgVec)
 {
-  char sbf[512];
-
-  if (n < 3) {
-    di << "Usage : " << a[0] << " Solid Point [Tolerance=1.e-7]" << "\n";
+  if (theArgNb < 3)
+  {
+    theDi << "Usage : " << theArgVec[0] << " Solid Point [Tolerance=1.e-7]\n";
     return -1;
   }
 
-  TopoDS_Shape aS = DBRep::Get(a[1]);
-  if (aS.IsNull()) {
-    sprintf(sbf, " Null Shape is not allowed here\n");
-    di<<sbf;
+  TopoDS_Shape aS = DBRep::Get (theArgVec[1]);
+  if (aS.IsNull())
+  {
+    theDi << " Null Shape is not allowed here\n";
     return 1;
   }
-
-  if (aS.ShapeType()!=TopAbs_SOLID) {
-    sprintf(sbf, " Shape type must be SOLID\n");
-    di<<sbf;
+  else if (aS.ShapeType() != TopAbs_SOLID)
+  {
+    theDi << " Shape type must be SOLID\n";
     return 1;
   }
-  //
-  Standard_Real aTol=1.e-7;
-  TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN");
-  TopAbs_State aState = TopAbs_UNKNOWN;
-  gp_Pnt aP(8., 9., 10.);
-
-  if (!DrawTrSurf::GetPoint(a[2], aP) ) {
-    sprintf(sbf, " Null Point is not allowed here\n");
-    di<<sbf;
+
+  gp_Pnt aP (8., 9., 10.);
+  if (!DrawTrSurf::GetPoint (theArgVec[2], aP))
+  {
+    theDi << " Null Point is not allowed here\n";
     return 1;
   }
+  const Standard_Real aTol = (theArgNb == 4) ? Draw::Atof (theArgVec[3]) : 1.e-7;
 
-  aTol=1.e-7;
-  if (n==4) {
-    aTol=atof(a[3]);
-  }
-  //
-  BRepClass3d_SolidClassifier aSC(aS);
-  aSC.Perform(aP,aTol);
-  //
-  aState = aSC.State();
-  //
-  sprintf(sbf, "The point is "); di<<sbf;
-  //
-  switch (aState) {
-  case TopAbs_IN:
-    sprintf(sbf, sIN.ToCString());
-    break;
-  case TopAbs_OUT:
-    sprintf(sbf, sOUT.ToCString());
-    break;
-  case TopAbs_ON:
-    sprintf(sbf, sON.ToCString());
-    break;
-  case TopAbs_UNKNOWN:
-    sprintf(sbf, sUNKNOWN.ToCString());
-    break;
-  default:
-    sprintf(sbf, sUNKNOWN.ToCString());
-    break;
-  }
-  di<<sbf;
-       //
-  sprintf(sbf, " shape\n");
-  di<<sbf;
+  BRepClass3d_SolidClassifier aSC (aS);
+  aSC.Perform (aP, aTol);
 
-  return 0;
+  switch (aSC.State())
+  {
+    case TopAbs_IN:      theDi << "The point is IN shape\n";      return 0;
+    case TopAbs_OUT:     theDi << "The point is OUT of shape\n";  return 0;
+    case TopAbs_ON:      theDi << "The point is ON shape\n";      return 0;
+    case TopAbs_UNKNOWN:
+    default:             theDi << "The point is UNKNOWN shape\n"; return 0;
+  }
 }
 
 #include <OSD_Process.hxx>
@@ -967,10 +905,10 @@ static Standard_Integer OCC309bug (Draw_Interpretor& di, Standard_Integer nb, co
   OSD_Path d = p.CurrentDirectory();
   TCollection_AsciiString s;
   d.SystemName(s);
-  di << "*" <<  s.ToCString() << "*" << "\n";
+  di << "*" <<  s.ToCString() << "*\n";
   d.UpTrek();
   d.SystemName(s);
-  di <<  "*" <<  s.ToCString() <<  "*" <<"\n";
+  di <<  "*" <<  s.ToCString() <<  "*\n";
   return 0;
 }
 
@@ -989,26 +927,13 @@ static Standard_Integer OCC310bug (Draw_Interpretor& di, Standard_Integer nb, co
 
 #include <BRepAlgoAPI_Fuse.hxx>
 #include <BRepAlgoAPI_Common.hxx>
-#include <BRepAlgo_Fuse.hxx>
-#include <BRepAlgo_Common.hxx>
 
 static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, const char ** a)
 {
-  //if (nb != 1) {
-  //  cout << "Usage: " << a[0] << endl;
-  //  return 1;
-  //}
-  if(nb < 1 || nb > 2) {
-    di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+  if(nb != 1) {
+    di << "Usage : " << a[0] << "\n";
     return 1;
   }
-  Standard_Boolean IsBRepAlgoAPI = Standard_True;
-  if (nb == 2) {
-    Standard_Integer IsB = atoi(a[1]);
-    if (IsB != 1) {
-      IsBRepAlgoAPI = Standard_False;
-    }
-  }
 
   BRepPrimAPI_MakeBox box1( 100, 100, 100 );
   BRepPrimAPI_MakeBox box2( gp_Pnt( 50, 50,50 ), 200, 200, 200 );
@@ -1016,25 +941,11 @@ static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, co
   TopoDS_Shape shape1 = box1.Shape();
   TopoDS_Shape shape2 = box2.Shape();
 
-//#if ! defined(BRepAlgoAPI_def01)
-//  TopoDS_Shape fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
-//  TopoDS_Shape comm = BRepAlgoAPI_Common( shape1, shape2 );
-//#else
-//  TopoDS_Shape fuse = BRepAlgo_Fuse( shape1, shape2 );
-//  TopoDS_Shape comm = BRepAlgo_Common( shape1, shape2 );
-//#endif
   TopoDS_Shape fuse,comm;
-  if (IsBRepAlgoAPI) {
-    di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )" <<"\n";
-    di << "comm = BRepAlgoAPI_Common( shape1, shape2 )" <<"\n";
-    fuse = BRepAlgoAPI_Fuse( shape1, shape2 );
-    comm = BRepAlgoAPI_Common( shape1, shape2 );
-  } else {
-    di << "fuse = BRepAlgo_Fuse( shape1, shape2 )" <<"\n";
-    fuse = BRepAlgo_Fuse( shape1, shape2 );
-    di << "comm = BRepAlgo_Common( shape1, shape2 )" <<"\n";
-    comm = BRepAlgo_Common( shape1, shape2 );
-  }
+  di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )\n";
+  di << "comm = BRepAlgoAPI_Common( shape1, shape2 )\n";
+  fuse = BRepAlgoAPI_Fuse(shape1, shape2).Shape();
+  comm = BRepAlgoAPI_Common(shape1, shape2).Shape();
 
   return 0;
 }
@@ -1044,46 +955,46 @@ static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, co
 static Standard_Integer OCC333bug (Draw_Interpretor& di, Standard_Integer n, const char ** a)
 {
   if( n < 3) {
-    di<<"-1"<<"\n";
-    di << "Usage: " << a[0] << " edge1 edge2 [toler domaindist]" << "\n";
+    di<<"-1\n";
+    di << "Usage: " << a[0] << " edge1 edge2 [toler domaindist]\n";
     return 1;
   }
   TopoDS_Shape Sh1 = DBRep::Get(a[1]);
   TopoDS_Shape Sh2 = DBRep::Get(a[2]);
   if(Sh1.IsNull() || Sh2.IsNull()) {
-    di<<"-2"<<"\n";
-    di<<"Invalid arguments"<<"\n";
+    di<<"-2\n";
+    di<<"Invalid arguments\n";
     return 1;
   }
   TopoDS_Edge e1 = TopoDS::Edge(Sh1);
   TopoDS_Edge e2 = TopoDS::Edge(Sh2);
   if(e1.IsNull() || e2.IsNull()) {
-    di<<"-3"<<"\n";
-    di<<"Invalid type of arguments"<<"\n";
+    di<<"-3\n";
+    di<<"Invalid type of arguments\n";
     return 1;
   }
   Standard_Real aTol = Precision::Confusion();
   Standard_Real aDistDomain = 0.0;
   Standard_Integer k = 3;
   if(k < n)
-    aTol = atof(a[k++]);
+    aTol = Draw::Atof(a[k++]);
   if(k < n)
-    aDistDomain = atof(a[k++]);
+    aDistDomain = Draw::Atof(a[k++]);
 
   ShapeAnalysis_Edge sae;
   if(sae.CheckOverlapping(e1,e2,aTol,aDistDomain)) {
     if(aDistDomain ==0.0) {
-      di<<"1"<<"\n";
-      di<<"Edges is overlaping comletly"<<"\n";
+      di<<"1\n";
+      di<<"Edges is overlaping comletly\n";
     } else {
-      di<<"2"<<"\n";
-      di<<"Edges is overlaped"<<"\n";
+      di<<"2\n";
+      di<<"Edges is overlaped\n";
       di<<"with tolerance = "<<aTol<<"\n";
       di<<"on segment length = "<<aDistDomain<<"\n";
     }
   } else {
-    di<<"3"<<"\n";
-    di<<"Edges is not overlaped"<<"\n";
+    di<<"3\n";
+    di<<"Edges is not overlaped\n";
   }
   return 0;
 }
@@ -1113,8 +1024,7 @@ static Standard_Integer OCC363 (Draw_Interpretor& di, Standard_Integer argc, con
     if(argc < 3) { di <<"Error OCC363 : Use : OCC363 document filename\n"; return 1; }
 
     // 2. Retrieve DDocStd application
-    Handle(TDocStd_Application) App;
-    if (!DDocStd::Find(App)) { di << "Error OCC363 : There is no current DDocStd application\n";return 1;}
+    Handle(TDocStd_Application) App = DDocStd::GetApplication();
 
     // 3. Open document
     TCollection_ExtendedString name(argv[2]);
@@ -1201,9 +1111,9 @@ static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, con
 
     // 2. Initialize parameters
     gp_Pnt2d p2d;
-    p2d.SetX ( atof(argv[2]) );
-    p2d.SetY ( atof(argv[3]) );
-    Standard_Real precuv = atof (argv[4] );
+    p2d.SetX ( Draw::Atof(argv[2]) );
+    p2d.SetY ( Draw::Atof(argv[3]) );
+    Standard_Real precuv = Draw::Atof (argv[4] );
 
     // 3. Read shape
     BRep_Builder B;
@@ -1263,8 +1173,8 @@ static Standard_Integer OCC377 (Draw_Interpretor& di, Standard_Integer argc, con
       di << "Reversed Wire " << i << ": point ( " << p2d.X() << ", " << p2d.Y() << " ) is " << TmpString.ToCString() << "\n";
 
       // 4.3. Compare results (they must be same)
-      if(stat1 ==stat2) di << "OCC377 OK" << "\n";
-      else {di << "OCC377 FAULTY" << "\n"; return 0;}
+      if(stat1 ==stat2) di << "OCC377 OK\n";
+      else {di << "OCC377 FAULTY\n"; return 0;}
     }
   }
   catch(Standard_Failure)
@@ -1399,7 +1309,11 @@ static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, cons
     if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
 
     // 3. Build mesh
-    BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, M_PI/6);
+    BRepMesh_FastDiscret::Parameters aMeshParams;
+    aMeshParams.Relative = Standard_True;
+    aMeshParams.Deflection = 0.2;
+    aMeshParams.Angle = M_PI / 6;
+    BRepMesh_IncrementalMesh aMesh(aShape, aMeshParams);
 
   }
   catch (Standard_Failure) {di << "OCC369 Exception \n" ;return 0;}
@@ -1416,14 +1330,14 @@ static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, con
     di<<"Usage : " << argv[0] << " LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix\n";
     return 1;
   }
-  Standard_Integer LowerVector = atoi(argv[1]);
-  Standard_Integer UpperVector = atoi(argv[2]);
-  Standard_Real InitialValueVector = atof(argv[3]);
-  Standard_Integer LowerRowMatrix = atoi(argv[4]);
-  Standard_Integer UpperRowMatrix = atoi(argv[5]);
-  Standard_Integer LowerColMatrix = atoi(argv[6]);
-  Standard_Integer UpperColMatrix = atoi(argv[7]);
-  Standard_Real InitialValueMatrix = atof(argv[8]);
+  Standard_Integer LowerVector = Draw::Atoi(argv[1]);
+  Standard_Integer UpperVector = Draw::Atoi(argv[2]);
+  Standard_Real InitialValueVector = Draw::Atof(argv[3]);
+  Standard_Integer LowerRowMatrix = Draw::Atoi(argv[4]);
+  Standard_Integer UpperRowMatrix = Draw::Atoi(argv[5]);
+  Standard_Integer LowerColMatrix = Draw::Atoi(argv[6]);
+  Standard_Integer UpperColMatrix = Draw::Atoi(argv[7]);
+  Standard_Real InitialValueMatrix = Draw::Atof(argv[8]);
 
   math_Vector Vector1(LowerVector, UpperVector);
   math_Vector Vector2(LowerVector, UpperVector);
@@ -1445,6 +1359,9 @@ static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, con
   di << aSStream1;
   di<<"\n";
 
+  if (Matrix.RowNumber() > 1) {
+    Matrix(Matrix.LowerRow() + 1, Matrix.LowerCol()) += 1.;
+  }
   Vector2.TMultiply(Vector, Matrix);
 
   //Vector2.Dump(cout);
@@ -1463,60 +1380,18 @@ static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, con
 //=======================================================================
 static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
 {
-  try
-  {
-    OCC_CATCH_SIGNALS
-    GeomPlate_BuildPlateSurface aBuilder;
-    aBuilder.Perform();
-  }
-  catch (Standard_RangeError) { di << "OCC525 Exception \n" ;return 0; }
-  //catch (...) { di << "OCC525 Exception \n" ;return 0; }
+  GeomPlate_BuildPlateSurface aBuilder;
+  aBuilder.Perform();
 
-  di << "OCC525 OK \n";
-  return 0;
-}
-
-#include <Viewer2dTest.hxx>
-#include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
-
-#include <AIS2D_InteractiveContext.hxx>
-#include <V2d_View.hxx>
-#include <AIS2D_InteractiveObject.hxx>
-#include <TColStd_HSequenceOfInteger.hxx>
-
-#if ! defined(WNT)
-extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
-#else
-Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
-#endif
-
-//=======================================================================
-//function :  OCC543
-//purpose  :
-//=======================================================================
-static Standard_Integer OCC543 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
-  Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
-  if(aContext.IsNull()) {
-    di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
-    return -1;
-  }
-  if(argc != 2){
-    di<<"Usage : " << argv[0] << " name\n";
-    return -1;
+  if (aBuilder.IsDone())
+  {
+    di << "Error in OCC525. Null result is expected.\n";
   }
-  Handle(V2d_View) V = Viewer2dTest::CurrentView();
-
-  TCollection_AsciiString name = argv[1];
-
-  if (!GetMapOfAIS2D().IsBound2(name)) {
-//    di << "There is not an object with name " << name.ToCString() << "\n";
-//    return -1;
+  else
+  {
+    di << "OCC525 OK \n";
   }
 
-  Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name);
-  Standard_Integer PickedIndex = aShape->PickedIndex();
-  di << "PickedIndex = " << PickedIndex << "\n";
   return 0;
 }
 
@@ -1525,35 +1400,16 @@ static Standard_Integer OCC543 (Draw_Interpretor& di, Standard_Integer argc, con
 #include <gce_MakeTranslation.hxx>
 #include <BRepBuilderAPI_Transform.hxx>
 #include <BRepPrimAPI_MakeWedge.hxx>
-#include <BRepAlgoAPI_Fuse.hxx>
-#include <BRepAlgoAPI_Cut.hxx>
-#include <BRepAlgo_Fuse.hxx>
-#include <BRepAlgo_Cut.hxx>
 //=======================================================================
 //function :  OCC578
 //purpose  :
 //=======================================================================
 static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
-  //if (argc!=4) {
-  //  di<<"Usage : " << argv[0] << " shape1 shape2 shape3\n";
-  //  return 1;
-  //}
-  if(argc < 4 || argc > 5) {
-    di << "Usage : " << argv[0] << " shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+  if(argc != 4) {
+    di << "Usage : " << argv[0] << " shape1 shape2 shape3\n";
     return 1;
   }
-  Standard_Boolean IsBRepAlgoAPI = Standard_True;
-  if (argc == 5) {
-    Standard_Integer IsB = atoi(argv[4]);
-    if (IsB != 1) {
-      IsBRepAlgoAPI = Standard_False;
-//      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
-//      return 1;
-//      di << "Error: There is not BRepAlgo_Cut class" << "\n";
-//      return 1;
-    }
-  }
 
   gp_Pnt P0(0,0,0.0);
   double xperiod = 1.0;
@@ -1618,35 +1474,12 @@ static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, con
 
 
   // combine wedges
-//#if ! defined(BRepAlgoAPI_def01)
-//  TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
-//#else
-//  TopoDS_Shape wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
-//#endif
-  TopoDS_Shape wedge_common;
-  if (IsBRepAlgoAPI) {
-    di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)" <<"\n";
-    wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
-  } else {
-    di << "wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a)" <<"\n";
-    wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
-  }
-
-  // remove wedge area from substrate
-//#if ! defined(BRepAlgoAPI_def01)
-//  TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
-//#else
-//  TopoDS_Shape sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
-//#endif
-  TopoDS_Shape sub_etch1;
-  if (IsBRepAlgoAPI) {
-    di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)" <<"\n";
-    sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common);
-  } else {
-    di << "sub_etch1 = BRepAlgo_Cut(substrate, wedge_common)" <<"\n";
-    sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
-  }
+  di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)\n";
+  TopoDS_Shape wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a).Shape();
 
+  di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)\n";
+  TopoDS_Shape sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common).Shape();
   if (sub_etch1.IsNull()) {
     di<<" Null shape3 is not allowed\n";
     return 1;
@@ -1656,34 +1489,6 @@ static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, con
   return 0;
 }
 
-#include <Graphic2d_DisplayList.hxx>
-#include <Graphic2d_View.hxx>
-
-//=======================================================================
-//function :  OCC627
-//purpose  :
-//=======================================================================
-static Standard_Integer OCC627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
-  Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
-  if(aContext.IsNull()) {
-    di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
-    return -1;
-  }
-  if(argc != 1){
-    di<<"Usage : " << argv[0] << "\n";
-    return -1;
-  }
-
-  Handle(V2d_View) V = Viewer2dTest::CurrentView();
-  Handle(Graphic2d_View) View = V->View();
-  Handle(Graphic2d_DisplayList) DisplayList = View->DisplayList();
-  Standard_Integer Length = DisplayList->Length();
-  di << "Length = " << Length << "\n";
-
-  return 0;
-}
-
 #include <Standard_GUID.hxx>
 //=======================================================================
 //function :  OCC669
@@ -1770,16 +1575,16 @@ static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, con
 {
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if(aContext.IsNull()) { 
-    di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+    di << argv[0] << "ERROR : use 'vinit' command before \n";
     return 1;
   }
 
   if ( argc != 2) {
-    di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation" << "\n";
+    di << "ERROR : Usage : " << argv[0] << " shape ; Deactivate the current transformation\n";
     return 1;
   }
   
-  Standard_Boolean updateviewer = Standard_True, PutInCollector = Standard_True;
+  Standard_Boolean updateviewer = Standard_True;
 
   ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
   
@@ -1787,19 +1592,17 @@ static Standard_Integer OCC708 (Draw_Interpretor& di, Standard_Integer argc, con
   Handle(AIS_InteractiveObject) AISObj;
 
   if(!aMap.IsBound2(aName)) {
-    di << "Use 'vdisplay' before" << "\n";
+    di << "Use 'vdisplay' before\n";
     return 1;
   } else {
     AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
     if(AISObj.IsNull()){
-      di << argv[1] << " : No interactive object" << "\n";
+      di << argv[1] << " : No interactive object\n";
       return 1;
     } 
-    AISObj->UnsetTransformation();
-    if (!aContext->HasOpenedContext()) {
-      aContext->OpenLocalContext();
-    }
-    aContext->Erase(AISObj, updateviewer, PutInCollector);
+    AISObj->ResetTransformation();
+
+    aContext->Erase(AISObj, updateviewer);
     aContext->UpdateCurrentViewer();
     aContext->Display(AISObj, updateviewer);
     aContext->UpdateCurrentViewer();
@@ -1818,8 +1621,15 @@ static Standard_Integer OCC670 (Draw_Interpretor& di, Standard_Integer argc, con
     di<<"Usage : " << argv[0] << "\n";
     return -1;
   }
-  TColStd_Array2OfInteger Array2OfInteger(1,1,1,1);
-  Array2OfInteger.SetValue(5,5,55);
+
+  // check that exception initialized without message string can be safely handled and printed
+  try {
+    throw Standard_OutOfRange();
+  }
+  catch (Standard_Failure const& anException) {
+    std::cout << "Caught successfully: ";
+    std::cout << anException << endl;
+  }
   return 0;
 }
 
@@ -1839,10 +1649,10 @@ static Standard_Integer OCC867(Draw_Interpretor& di, Standard_Integer argc, cons
   gp_Pnt aPoint3d;        
   DrawTrSurf::GetPoint(argv[1],aPoint3d);
   Handle (Geom_Surface) aSurface=DrawTrSurf::GetSurface(argv[2]);
-  Standard_Real             Umin=atof(argv[3]);
-  Standard_Real             Usup=atof(argv[4]);
-  Standard_Real             Vmin=atof(argv[5]);
-  Standard_Real             Vsup=atof(argv[6]);
+  Standard_Real             Umin=Draw::Atof(argv[3]);
+  Standard_Real             Usup=Draw::Atof(argv[4]);
+  Standard_Real             Vmin=Draw::Atof(argv[5]);
+  Standard_Real             Vsup=Draw::Atof(argv[6]);
  
   if (aSurface.IsNull()) {
     di << argv[2] << " Null surface \n" ;
@@ -1871,7 +1681,7 @@ static Standard_Integer OCC909 (Draw_Interpretor& di, Standard_Integer argc, con
   TopoDS_Wire awire = TopoDS::Wire(DBRep::Get(argv[1])); //read the wire
   TopoDS_Face aface = TopoDS::Face(DBRep::Get(argv[2])); //read the face
   if (awire.IsNull() || aface.IsNull()) {
-    di << "Null object" << "\n";
+    di << "Null object\n";
     return 1;
   }
 
@@ -1897,7 +1707,7 @@ static Standard_Integer OCC921 (Draw_Interpretor& di, Standard_Integer argc, con
 {
   if (argc != 2)
   {
-    di <<"Usage : " << argv[0] << " face"<<"\n";
+    di <<"Usage : " << argv[0] << " face\n";
     return 1;
   }
   Standard_Real u1, u2, v1, v2;
@@ -1920,7 +1730,7 @@ static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, cons
 {
   if (argc != 2)
   {
-    di <<"Usage : " << argv[0] << " expression"<<"\n";
+    di <<"Usage : " << argv[0] << " expression\n";
     return 1;
   }
 
@@ -1969,7 +1779,7 @@ static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
     Handle(TPrsStd_AISPresentation) prs;
     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {   
       if( nb == 4 ) {
-       prs->SetTransparency(atof(arg[3]));
+       prs->SetTransparency(Draw::Atof(arg[3]));
        TPrsStd_AISViewer::Update(L);
       }
       else {
@@ -1978,7 +1788,7 @@ static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -2003,7 +1813,7 @@ static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
     Handle(TPrsStd_AISPresentation) prs;
     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {   
       if( nb == 4 ) {
-       prs->SetColor((Quantity_NameOfColor)atoi(arg[3]));
+       prs->SetColor((Quantity_NameOfColor)Draw::Atoi(arg[3]));
        TPrsStd_AISViewer::Update(L);
       }
       else
@@ -2011,7 +1821,7 @@ static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
       return 0; 
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -2036,7 +1846,7 @@ static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
     Handle(TPrsStd_AISPresentation) prs;
     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {   
       if( nb == 4 ) {
-       prs->SetMaterial((Graphic3d_NameOfMaterial)atoi(arg[3]));
+       prs->SetMaterial((Graphic3d_NameOfMaterial)Draw::Atoi(arg[3]));
        TPrsStd_AISViewer::Update(L);
       }
       else {
@@ -2045,7 +1855,7 @@ static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -2070,7 +1880,7 @@ static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
     Handle(TPrsStd_AISPresentation) prs;
     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {   
       if( nb == 4 ) {
-       prs->SetWidth(atof(arg[3]));
+       prs->SetWidth(Draw::Atof(arg[3]));
        TPrsStd_AISViewer::Update(L);
       }
       else {
@@ -2079,7 +1889,7 @@ static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -2104,7 +1914,7 @@ static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
     Handle(TPrsStd_AISPresentation) prs;
     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {   
       if( nb == 4 ) {
-       prs->SetMode(atoi(arg[3]));
+       prs->SetMode(Draw::Atoi(arg[3]));
        TPrsStd_AISViewer::Update(L);
       }
       else {
@@ -2113,7 +1923,7 @@ static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -2138,7 +1948,7 @@ static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
     Handle(TPrsStd_AISPresentation) prs;
     if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {   
       if( nb == 4 ) {
-       prs->SetSelectionMode(atoi(arg[3]));
+       prs->SetSelectionMode(Draw::Atoi(arg[3]));
        TPrsStd_AISViewer::Update(L);
       }
       else {
@@ -2147,37 +1957,22 @@ static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
-#include<BRepAlgoAPI_Cut.hxx>
-#include<BRepAlgo_Cut.hxx>
 //=======================================================================
 //function :  OCC1487
 //purpose  :
 //=======================================================================
 static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
-  //if(argc != 5) {
-  //  cerr << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape" << endl;
-  //  return -1;
-  //}
-  if(argc < 5 || argc > 6) {
-    di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+  if(argc != 5) {
+    di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape\n";
     return 1;
   }
-  Standard_Boolean IsBRepAlgoAPI = Standard_True;
-  if (argc == 6) {
-    Standard_Integer IsB = atoi(argv[5]);
-    if (IsB != 1) {
-      IsBRepAlgoAPI = Standard_False;
-//      di << "Error: There is not BRepAlgo_Cut class" << "\n";
-//      return 1;
-    }
-  }
 
-  Standard_Integer CaseNumber = atoi(argv[1]);
+  Standard_Integer CaseNumber = Draw::Atoi(argv[1]);
 
   //BRepPrimAPI_MakeCylinder o_mc1 (gp_Ax2 (gp_Pnt(0,-50,140), gp_Dir(1,0,0)), 50,1000);
   gp_Dir myDir(1,0,0);
@@ -2197,18 +1992,8 @@ static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, co
     BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
 
     cyl2 = o_mc2.Shape();
-//#if ! defined(BRepAlgoAPI_def01)
-//    o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
-//#else
-//    o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
-//#endif
-    if (IsBRepAlgoAPI) {
-      di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
-      o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
-    } else {
-      di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
-      o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
-    }
+    di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
+    o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ()).Shape();
   } else {
     //BRepPrimAPI_MakeCylinder o_mc2 (gp_Ax2 (gp_Pnt(978.34936, -50.0, 127.5),gp_Dir(sin(M_PI/3), 0.0, 0.5)), 5, 150);
     gp_Dir myDir_mc2(sin(M_PI/3), 0.0, 0.5);
@@ -2217,18 +2002,8 @@ static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, co
     BRepPrimAPI_MakeCylinder o_mc2 (myAx2_mc2, 5, 150);
 
     cyl2 = o_mc2.Shape();
-//#if ! defined(BRepAlgoAPI_def01)
-//    o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
-//#else
-//    o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
-//#endif
-    if (IsBRepAlgoAPI) {
-      di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
-      o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ());
-    } else {
-      di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())" <<"\n";
-      o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
-    }
+    di << "o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
+    o_cut_shape = BRepAlgoAPI_Cut (o_mc1.Solid (), o_mc2.Solid ()).Shape();
   }
 
   DBRep::Set(argv[2],cyl1);
@@ -2255,9 +2030,6 @@ TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,cons
 
   TopoDS_Shape ShapeCut = aBoolenaOperation.Shape();
 
-//#ifdef OCC40 
-//  Handle_TopOpeBRepBuild_HBuilder build = aBoolenaOperation.Builder();
-//#endif 
   TopTools_ListIteratorOfListOfShape its;
 
   TopoDS_Compound result;
@@ -2272,11 +2044,7 @@ TopoDS_Shape OCC1077_boolbl(BRepAlgoAPI_BooleanOperation& aBoolenaOperation,cons
       BRepFilletAPI_MakeFillet fill(cutsol);
       fill.SetParams(ta, t3d, t2d, t3d, t2d, fl);
       fill.SetContinuity(blend_cont, tapp_angle);
-//#ifdef OCC40
-//      its = build->Section();
-//#else //OCC40DEV
       its = aBoolenaOperation.SectionEdges();
-//#endif
       while (its.More())
        {
          TopoDS_Edge E = TopoDS::Edge(its.Value());
@@ -2322,7 +2090,7 @@ TopoDS_Shape OCC1077_Bug()
   TopoDS_Shape theCylinder3 = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, - 10, 0),
                                                              gp_Dir(0, 1, 0)), 3, 20).Shape();
   TopoDS_Shape theTmp1 = OCC1077_cut_blend(theCommon,theCylinder1,0.7);
-  Handle_ShapeFix_Shape fixer = new ShapeFix_Shape(theTmp1);
+  Handle(ShapeFix_Shape) fixer = new ShapeFix_Shape(theTmp1);
   fixer->Perform();
   theTmp1 = fixer->Shape();
   TopoDS_Shape theTmp2 = OCC1077_cut_blend(theTmp1,theCylinder2,0.7);
@@ -2339,7 +2107,7 @@ TopoDS_Shape OCC1077_Bug()
 static Standard_Integer OCC1077 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
   if(argc < 1 || argc > 2) {
-    di << "Usage : " << argv[0] << " result" << "\n";
+    di << "Usage : " << argv[0] << " result\n";
     return 1;
   }
 
@@ -2358,7 +2126,7 @@ static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer a
 {
   if (argc < 4)
   {
-    di << "Usage : " << argv[0] << " name shape step" << "\n";
+    di << "Usage : " << argv[0] << " name shape step\n";
     return 1;
   }
   const char *name = argv[1];
@@ -2371,17 +2139,17 @@ static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer a
     TopoDS_Shape wire = DBRep::Get(argv[2]);
     if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE)
     {
-      di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected"<<"\n";
+      di << argv[0] <<" Faulty : incorrect 1st parameter, curve or wire expected\n";
       return 1;
     }
     adapCurve = new BRepAdaptor_CompCurve(TopoDS::Wire(wire));
   }
-  double step = atof(argv[3]);
+  double step = Draw::Atof(argv[3]);
   GCPnts_UniformAbscissa aUni(*adapCurve, step);
   int res;
   if (!aUni.IsDone())
   {
-    di << argv[0] <<" : fail"<<"\n";
+    di << argv[0] <<" : fail\n";
     res = 1;
   }
   else
@@ -2392,7 +2160,7 @@ static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer a
       double par = aUni.Parameter(i+1);
       gp_Pnt p = adapCurve->Value(par);
       char n[20], *pname=n;
-      sprintf(n,"%s_%d",name,i+1);
+      Sprintf(n,"%s_%d",name,i+1);
       DrawTrSurf::Set(pname,p);
       di<<pname<<" ";
     }
@@ -2406,16 +2174,16 @@ static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, co
 {
   if (argc != 3)
   {
-    di << "Usage : " << argv[0] << " nb_of_vectors size" << "\n";
+    di << "Usage : " << argv[0] << " nb_of_vectors size\n";
     return 1;
   }
 
-  Standard_Integer nb = atoi(argv[1]);
-  Standard_Integer sz = atoi(argv[2]);
+  Standard_Integer nb = Draw::Atoi(argv[1]);
+  Standard_Integer sz = Draw::Atoi(argv[2]);
   Standard_Real val = 10;
   math_Vector **pv = new math_Vector *[nb];
 
-  di<<"creating "<<nb<<" vectors "<<sz<<" elements each..."<<"\n";
+  di<<"creating "<<nb<<" vectors "<<sz<<" elements each...\n";
   Standard_Integer i;
   for (i=0; i < nb; i++) {
     pv[i] = new math_Vector (1, sz, val);
@@ -2425,8 +2193,8 @@ static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, co
       di<<"\n";
     }
   }
-  di<<" done"<<"\n";
-  di<<"deleting them ..."<<"\n";
+  di<<" done\n";
+  di<<"deleting them ...\n";
   for (i=0; i < nb; i++) {
     delete pv[i];
     if ((i % (nb/10)) == 0) {
@@ -2435,7 +2203,7 @@ static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, co
       di<<"\n";
     }
   }
-  di<<" done"<<"\n";
+  di<<" done\n";
 
   delete [] pv;
 
@@ -2446,7 +2214,7 @@ static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, co
 {
   if (argc != 2)
   {
-    di << "Usage : " << argv[0] << " wire" << "\n";
+    di << "Usage : " << argv[0] << " wire\n";
     return 1;
   }
   TopoDS_Shape shape = DBRep::Get(argv[1],TopAbs_WIRE);
@@ -2470,43 +2238,34 @@ static Standard_Integer OCC5698 (Draw_Interpretor& di, Standard_Integer argc, co
   if (error_dist > Precision::Confusion()) {
     //cout.precision(3);
     di<<"error_dist = "<<error_dist<<
-      "  ( "<<error_dist/need_length*100<<" %)"<<"\n";
+      "  ( "<<error_dist/need_length*100<<" %)\n";
     return 0;
   }
-  di<<"OK"<<"\n";
+  di<<"OK\n";
   return 0;
 }
 
-static char sarr[2000];
-static int si=1;
-static int StackOverflow(int i = -1)
+// stack overflow can be successfully handled only on 32-bit Windows
+#if defined(_WIN32) && !defined(_WIN64)
+static int StackOverflow (int i = -1)
 {
   char arr[2000];
-  if (si == 1) {
-    si = 0;
-    memcpy(arr,sarr,2000);
-    arr[1999]=0;
-    int n = strlen(arr), s=0;
-    while (n--)
-      s += StackOverflow(i-1);
-    return i + s + StackOverflow(i-1);
-  }
-  else if (i != 0) {
-    return i + StackOverflow(i-1);
-  }
-  si = 1;
+  memset (arr, 0, sizeof(arr));
+  if (i < 0)
+    StackOverflow(i-1);
   return i;
 }
+#endif
 
-#ifdef WNT
 // this code does not work with optimize mode on Windows
+#if defined(_MSC_VER)
 #pragma optimize( "", off )
 #endif
 static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
   if (argc != 1)
     {
-      di << "Usage : " << argv[0] << "\n";
+      cout << "Usage : " << argv[0] << "\n";
       return 1;
     }
   Standard_Boolean Succes;
@@ -2517,62 +2276,61 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Divide ByZero (Integer) ========================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Integer) Divide By Zero..." << endl;
       di << "(Integer) Divide By Zero...";
       //cout.flush();
       di << "\n";
       Standard_Integer res, a =4, b = 0 ;
       res = a / b;
-      di << " 4 / 0 = " << res << "  Does not Caught... KO"<< "\n";
+      di << "Error: 4 / 0 = " << res << " - no exception is raised!\n";
       Succes = Standard_False;
     }
-#if defined(SOLARIS) || defined(WNT)
+#if defined(SOLARIS) || defined(_WIN32)
     catch(Standard_DivideByZero)
 #else
     catch(Standard_NumericError)
 #endif
     {
-      di << " Ok"<< "\n";
+      di << "Caught, OK\n";
     }
-    catch(Standard_Failure) {
-      //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
+    catch(Standard_Failure const& anException) {
       di << " Caught (";
-      di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << anException.GetMessageString();
+      di << ")... KO\n";
       Succes = Standard_False;
     }
-#ifndef NO_CXX_EXCEPTION
     // this case tests if (...) supersedes (Standard_*),
     // the normal behaviour is not
     catch(...) {
-      di<<" unknown exception... (But) Ok"<<"\n";
+      di<<" unknown exception... (But) Ok\n";
     }
-#endif
   }
 
   {//==== Test Divide ByZero (Real) ===========================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Real) Divide By Zero..." << endl;
       di << "(Real) Divide By Zero...";
       //cout.flush();
       di << "\n";
       Standard_Real res, a= 4.0, b=0.0;
       res = a / b;
-      di << " 4.0 / 0.0 = " << res << "  Does not Caught... KO"<< "\n";
+      di << "Error: 4.0 / 0.0 = " << res << " - no exception is raised!\n";
       Succes = Standard_False;
     }
-#if defined(SOLARIS) || defined(WNT)
-    catch(Standard_DivideByZero)
-#else
-    catch(Standard_NumericError)
-#endif
+    catch(Standard_DivideByZero) // Solaris, Windows w/o SSE2
+    {
+      di << "Caught, OK\n";
+    }
+    catch(Standard_NumericError) // Linux, Windows with SSE2
     {
-      di << " Ok"<< "\n";
+      di << "Caught, OK\n";
     }
-    catch(Standard_Failure) {
+    catch(Standard_Failure const& anException) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
-      di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << anException.GetMessageString();
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2580,6 +2338,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Overflow (Integer) =============================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Integer) Overflow..." << endl;
       di << "(Integer) Overflow...";
       //cout.flush();
       di << "\n";
@@ -2587,16 +2346,16 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       res = i + 1;
       //++++ cout << " -- "<<res<<"="<<i<<"+1   Does not Caught... KO"<< endl;
       //++++ Succes = Standard_False;
-      di << " "<<res<<"="<<i<<"+1  Does not Caught... (But) Ok"<< "\n";
+      di << "Not caught: " << i << " + 1 = " << res << ", still OK\n";
     }
     catch(Standard_Overflow) {
-      di << " Ok"<< "\n";
+      di << "Caught, OK\n";
     }
-    catch(Standard_Failure) {
+    catch(Standard_Failure const& anException) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
-      di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << anException.GetMessageString();
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2604,30 +2363,31 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Overflow (Real) ================================================ 
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Real) Overflow..." << endl;
       di << "(Real) Overflow...";
       //cout.flush();
       di << "\n";
       Standard_Real res, r=RealLast();
       res = r * r;
       
-      sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
+      (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
 
-      di << "-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... KO"<< "\n";
+      di << "Error: " << r << "*" << r << " = " << res << " - no exception is raised!\n";
       Succes = Standard_False;
     }
-#if defined(SOLARIS) || defined(WNT)
-    catch(Standard_Overflow)
-#else
-    catch(Standard_NumericError)
-#endif
+    catch(Standard_Overflow) // Solaris, Windows w/o SSE2
+    {
+      di << "Caught, OK\n";
+    }
+    catch(Standard_NumericError) // Linux, Windows with SSE2
     {
-      di << " Ok"<< "\n";
+      di << "Caught, OK\n";
     }
-    catch(Standard_Failure) {
+    catch(Standard_Failure const& anException) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
-      di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << anException.GetMessageString();
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2635,6 +2395,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Underflow (Real) ===============================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Real) Underflow" << endl; // to have message in log even if process crashed
       di << "(Real) Underflow";
       //cout.flush();
       di << "\n";
@@ -2643,21 +2404,23 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       //res = res + 1.;
       //++++ cout<<"-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... KO"<<endl;
       //++++ Succes = Standard_False;
-      di<<" -- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... (But) Ok"<<"\n";
+      di << "Not caught: " << r << "*" << r << " = " << res << ", still OK\n";
     }
-#if defined(SOLARIS) || defined(WNT)
-    catch(Standard_Underflow)
-#else
-    catch(Standard_NumericError)
-#endif
+    catch(Standard_Underflow) // could be on Solaris, Windows w/o SSE2
+    {
+      di << "Exception caught, KO\n";
+      Succes = Standard_False;
+    }
+    catch(Standard_NumericError) // could be on Linux, Windows with SSE2
     {
-      di << " Ok"<< "\n";
+      di << "Exception caught, KO\n";
+      Succes = Standard_False;
     }
-    catch(Standard_Failure) {
+    catch(Standard_Failure const& anException) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
-      di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << anException.GetMessageString();
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2665,22 +2428,23 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Invalid Operation (Real) ===============================================
     try{
       OCC_CATCH_SIGNALS
+      cout << "(Real) Invalid Operation..." << endl;
       di << "(Real) Invalid Operation...";
       //cout.flush();
       di << "\n";
       Standard_Real res, r=-1;
       res = sqrt(r);
-      di<<" "<<res<<"=sqrt("<<r<<")  Does not Caught... KO"<<"\n";
+      di << "Error: swrt(-1) = " << res << " - no exception is raised!\n";
       Succes = Standard_False;
     }
     catch(Standard_NumericError) {
-      di << " Ok"<< "\n";
+      di << "Caught, OK\n";
     }
-    catch(Standard_Failure) {
+    catch(Standard_Failure const& anException) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
-      di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << anException.GetMessageString();
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2688,63 +2452,65 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
   {//==== Test Access Violation ===============================================
     try {
       OCC_CATCH_SIGNALS
+      cout << "Segmentation Fault..." << endl;
       di << "Segmentation Fault...";
       //cout.flush();
       di << "\n";
       int* pint=NULL;
       *pint = 4;
-      di << "  Does not Caught... KO"<<"\n";
+      di << "Error: writing by NULL address - no exception is raised!\n";
       Succes = Standard_False;
     }
-#ifdef WNT
+#ifdef _WIN32
     catch(OSD_Exception_ACCESS_VIOLATION)
 #else
     catch(OSD_SIGSEGV)
 #endif
     {
-      di << " Ok"<< "\n";
-    } catch(Standard_Failure) {
+      di << "Caught, OK\n";
+    } catch(Standard_Failure const& anException) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
-      di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << anException.GetMessageString();
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
 
-#ifdef WNT
+#if defined(_WIN32) && !defined(_WIN64)
   {//==== Test Stack Overflow ===============================================
     try {
       OCC_CATCH_SIGNALS
+      cout << "Stack Overflow..." << endl;
       di << "Stack Overflow...";
       //cout.flush();
       di << "\n";
       StackOverflow();
-      di << "  Does not Caught... KO"<<"\n";
+      di << "Error - no exception is raised!\n";
       Succes = Standard_False;
     }
     catch(OSD_Exception_STACK_OVERFLOW) {
-      di << " Ok"<< "\n";
+      di << "Caught, OK\n";
     }
-    catch(Standard_Failure) {
+    catch(Standard_Failure const& anException) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
-      di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << anException.GetMessageString();
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
 #endif
 
  if(Succes) {
-   di << "TestExcept: Successfull completion" << "\n";
+   di << "TestExcept: Successfull completion\n";
  } else {
-   di << "TestExcept: failure" << "\n";
+   di << "TestExcept: failure\n";
  }
 
   return 0;
 }
-#ifdef WNT
+#if defined(_MSC_VER)
 #pragma optimize( "", on )
 #endif
 
@@ -2769,43 +2535,40 @@ static TopoDS_Compound AddTestStructure(int nCount_)
 
 static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
-  int nCount = 10;
-
-  if (argc > 2)
-    {
-      di << "Usage : " << argv[0] << " [nCount]" << "\n";
-      return 1;
-    }
+  if (argc != 2 && argc != 3)
+  {
+    std::cout << "Usage : " << argv[0] << " [nCount] path\n";
+    return 1;
+  }
 
-  if (argc > 1)
-    nCount = atoi(argv[1]);
+  int nCount = (argc > 2 ? Draw::Atoi(argv[1]) : 10);
+  TCollection_AsciiString aFilePath (argv[argc > 2 ? 2 : 1]);
   STEPCAFControl_Writer writer;
-  Handle_TDocStd_Document document;
+  Handle(TDocStd_Document) document;
   document = new TDocStd_Document("Pace Test-StepExporter-");
-  Handle_XCAFDoc_ShapeTool shapeTool;
+  Handle(XCAFDoc_ShapeTool) shapeTool;
   shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
   shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
   STEPControl_StepModelType mode = STEPControl_AsIs;
   if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
-    di << "Failed to set assembly mode for step data\n" << "\n";
+    di << "Failed to set assembly mode for step data\n\n";
     return 0;
   }
   try {
     OCC_CATCH_SIGNALS
     if( writer.Transfer(document, mode)) {
-      IFSelect_ReturnStatus stat =
-       writer.Write("TestExportStructure.step");
+       writer.Write(aFilePath.ToCString());
     }
   }
   catch(OSD_Exception_STACK_OVERFLOW) {
-    di << "Failed : STACK OVERFLOW\n" << "\n";
+    di << "Failed : STACK OVERFLOW\n\n";
   }
-  catch (Standard_Failure) {
-    di << "Failed :\n" << "\n";
+  catch (Standard_Failure const& anException) {
+    di << "Failed :\n\n";
     //cout << Standard_Failure::Caught() << endl;
-    di << Standard_Failure::Caught()->GetMessageString();
+    di << anException.GetMessageString();
   }
-  di << argv[0] << " : Finish" << "\n";
+  di << argv[0] << " : Finish\n";
   
   return 0;
 }
@@ -2857,7 +2620,7 @@ static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, co
 {
   if (argc != 4)
   {
-    di << "Usage : " << argv[0] << " edge1 edge2 plane" << "\n";
+    di << "Usage : " << argv[0] << " edge1 edge2 plane\n";
     return 1;
   }
   TopoDS_Edge theEdge1 = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
@@ -2896,7 +2659,7 @@ static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, co
     Standard_Integer i;
     for (i=1; i<=NbPoints; i++) {
       gp_Pnt2d aPi = anInter.Point(i);
-      di << "Point.X(" << i << ") = " << aPi.X() << "   " << "Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
+      di << "Point.X(" << i << ") = " << aPi.X() << "   Point.Y(" << i << ") = " << aPi.Y() << "\n" ;
     }
   }
 
@@ -2912,20 +2675,20 @@ static Standard_Integer OCC8169 (Draw_Interpretor& di, Standard_Integer argc, co
   
     Standard_Real aDist = aP1.Distance(aP2);
   
-    di << "aP1.X() = " << aP1.X() << "   " << "aP1.Y() = " << aP1.Y() << "\n" ;
-    di << "aP2.X() = " << aP2.X() << "   " << "aP2.Y() = " << aP2.Y() << "\n" ;
+    di << "aP1.X() = " << aP1.X() << "   aP1.Y() = " << aP1.Y() << "\n" ;
+    di << "aP2.X() = " << aP2.X() << "   aP2.Y() = " << aP2.Y() << "\n" ;
 
     di << "Distance = " << aDist << "\n" ;
 
     di << "Confusion = " << aConfusion << "\n" ;
 
     if (aDist > aConfusion) {
-      di << "\n" << argv[0] << " Faulty" << "\n" ;
+      di << "\n" << argv[0] << " Faulty\n" ;
     } else {
-      di << "\n" << argv[0] << " OK" << "\n" ;
+      di << "\n" << argv[0] << " OK\n" ;
     }
   } else {
-    di << "\n" << argv[0] << " OK" << "\n" ;
+    di << "\n" << argv[0] << " OK\n" ;
   }
 
   return 0;
@@ -2934,12 +2697,12 @@ static Standard_Integer OCC10138 (Draw_Interpretor& di, Standard_Integer argc, c
 {
   if (argc != 3)
   {
-    di << "Usage : " << argv[0] << " lower upper" << "\n";
+    di << "Usage : " << argv[0] << " lower upper\n";
     return 1;
   }
 
-  Standard_Integer LOWER = atoi(argv[1]);
-  Standard_Integer UPPER = atoi(argv[2]);
+  Standard_Integer LOWER = Draw::Atoi(argv[1]);
+  Standard_Integer UPPER = Draw::Atoi(argv[2]);
 
   //! 0. Create an empty document with several test labels
   Handle(TDocStd_Document) doc = new TDocStd_Document("XmlOcaf");
@@ -3144,7 +2907,7 @@ static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, co
 
   if (argc < 3 || IsEvenArgc)
     {
-      di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]" << "\n";
+      di << "Usage : " << argv[0] << " index1 value1 ... [indexN valueN]\n";
       return 1;
     }
 
@@ -3152,8 +2915,8 @@ static Standard_Integer OCC7639 (Draw_Interpretor& di, Standard_Integer argc, co
   NCollection_Vector<int> vec;
   for (i = 0; i < argc - 1; i++) {
     i++;
-    aValue = atoi(argv[i]);
-    aPosition = atoi(argv[i+1]);
+    aValue = Draw::Atoi(argv[i]);
+    aPosition = Draw::Atoi(argv[i+1]);
     vec.SetValue(aValue, aPosition);
   }
   NCollection_Vector<int>::Iterator it(vec);
@@ -3254,18 +3017,6 @@ static Standard_Integer OCC7068 (Draw_Interpretor& di, Standard_Integer argc, co
     }
   }
 
-  // ObjectsInCollector
-  AIS_ListOfInteractive ListOfIO_2;
-  AISContext->ObjectsInCollector(ListOfIO_2);
-  di<< "ObjectsInCollector = " << ListOfIO_2.Extent() <<"\n";
-  if (!ListOfIO_2.IsEmpty() ) {
-    AIS_ListIteratorOfListOfInteractive iter;
-    for (iter.Initialize(ListOfIO_2); iter.More() ; iter.Next() ) {
-      Handle(AIS_InteractiveObject) aIO=iter.Value();
-      di<< GetMapOfAIS().Find1(aIO).ToCString() <<"\n";
-    }
-  }
-
   return 0;
 }
 
@@ -3280,7 +3031,7 @@ static Standard_Integer OCC11457 (Draw_Interpretor& di, Standard_Integer argc, c
   BRepBuilderAPI_MakePolygon W;
   j = 3;
   for (i = 1; i <= np; i ++) {
-    W.Add(gp_Pnt(atof(argv[j]),atof(argv[j+1]),atof(argv[j+2])));
+    W.Add(gp_Pnt(Draw::Atof(argv[j]),Draw::Atof(argv[j+1]),Draw::Atof(argv[j+2])));
     j += 3;
   }
   W.Close();
@@ -3298,12 +3049,12 @@ static Standard_Integer OCC13963 (Draw_Interpretor& di, Standard_Integer argc, c
   gp_Ax2 aPln (gp_Pnt(0.,0.,0.),
                gp_Dir(1., -1., 0.));
   gp_GTrsf aTrf;
-  aTrf.SetAffinity (aPln, atof(argv[4]));
-  gp_XYZ aOrigin (atof(argv[1]),atof(argv[2]),atof(argv[3]));
+  aTrf.SetAffinity (aPln, Draw::Atof(argv[4]));
+  gp_XYZ aOrigin (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
   gp_XYZ aResult (aOrigin);
   aTrf.Transforms(aResult);
   char sbf[512];
-  sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
+  Sprintf(sbf, "( %8.3f %8.3f %8.3f ) => ( %8.3f %8.3f %8.3f )\n",
           aOrigin.X(), aOrigin.Y(), aOrigin.Z(),
           aResult.X(), aResult.Y(), aResult.Z());
   di<<sbf;
@@ -3326,11 +3077,11 @@ Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const cha
 
   Standard_Real aDeflection = 0.45110277533;
   if (argc > 2) {
-    aDeflection = atof(argv[2]);
+    aDeflection = Draw::Atof(argv[2]);
   }
   di<<"deflection="<< aDeflection << "\n";
 
-  BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI/9.);
+  BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI / 9.);
   TopLoc_Location aLocation;
   Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);
 
@@ -3352,7 +3103,7 @@ static Standard_Integer OCC15489 (Draw_Interpretor& di, Standard_Integer argc, c
   }
   try
     {
-      gp_Lin2d aLin2d (atof(argv[1]),atof(argv[2]),atof(argv[3]));
+      gp_Lin2d aLin2d (Draw::Atof(argv[1]),Draw::Atof(argv[2]),Draw::Atof(argv[3]));
       gp_Pnt2d anOrigin = aLin2d.Location();
       di << "X_0 = " << anOrigin.X() << "   Y_0 = " << anOrigin.Y() << "\n" ;
     }
@@ -3546,11 +3297,10 @@ int TestSetGet(const Handle(TDocStd_Document)& doc)
   if (getboollist->Last() != Standard_True)
     return 3;
   const TDataStd_ListOfByte& boollist = getboollist->List();
-  TDataStd_ListIteratorOfListOfByte itr_boollist(boollist);
-  for (; itr_boollist.More(); itr_boollist.Next())
+  for (TDataStd_ListIteratorOfListOfByte itr_boollist(boollist); itr_boollist.More(); itr_boollist.Next())
   {
-    if (itr_boollist.Value() != Standard_True &&
-       itr_boollist.Value() != Standard_False)
+    if (itr_boollist.Value() != 1
+     && itr_boollist.Value() != 0)
     {
       return 4;
     }
@@ -4136,7 +3886,7 @@ int TestOpenSave(TCollection_ExtendedString aFile1,
 {
   // Std
   Handle(TDocStd_Document) doc_std, doc_std_open;
-  app->NewDocument("MDTV-Standard", doc_std);
+  app->NewDocument("BinOcaf", doc_std);
   // TDataStd_Tick:
   TDataStd_Tick::Set(doc_std->Main());
   // TDataStd_IntegerList:
@@ -4608,7 +4358,7 @@ static Standard_Integer OCC16782 (Draw_Interpretor& di, Standard_Integer argc, c
   int good = 0;
   
   Handle(TDocStd_Document) doc;
-  app->NewDocument("MDTV-Standard", doc);
+  app->NewDocument("BinOcaf", doc);
   doc->SetUndoLimit(10);
 
   di <<"\nTestSetGet start\n";
@@ -4643,7 +4393,7 @@ static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, c
 {
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if(aContext.IsNull()) { 
-    di << argv[0] << " ERROR : use 'vinit' command before " << "\n";
+    di << argv[0] << " ERROR : use 'vinit' command before \n";
     return -1;
   }
 
@@ -4655,7 +4405,7 @@ static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, c
   Standard_Integer mode = 0;
   if (argc == 2)
   {
-    mode = atoi(argv[1]);
+    mode = Draw::Atoi(argv[1]);
   }
   if (mode > 2 || mode < 0)
   {
@@ -4663,21 +4413,38 @@ static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, c
     return 1;
   }
   Handle(V3d_View) V = ViewerTest::CurrentView();
+  static Handle(AIS_ColorScale) aCS;
+  if (aCS.IsNull())
+  {
+    aCS = new AIS_ColorScale();
+  }
+  if (aCS->ZLayer() != Graphic3d_ZLayerId_TopOSD)
+  {
+    aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD);
+  }
+  if (aCS->TransformPersistence().IsNull()
+   || aCS->TransformPersistence()->Mode() != Graphic3d_TMF_2d)
+  {
+    aContext->SetTransformPersistence (aCS, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
+  }
+  Standard_Integer aWinWidth, aWinHeight;
+  V->Window()->Size (aWinWidth, aWinHeight);
+  aCS->SetSize (aWinWidth, aWinHeight);
   if ( !V.IsNull() ) {
     if (mode == 0) {
-      V->ColorScaleDisplay();
+      aContext->Display (aCS, Standard_True);
     }
     if (mode == 1) {
-      V->ColorScaleErase();
+      aContext->Erase (aCS, Standard_False);
       V->UpdateLights();
       V->Update();
     }
     if (mode == 2) {
-      Standard_Boolean IsDisplayed = V->ColorScaleIsDisplayed();
+      Standard_Boolean IsDisplayed = aContext->IsDisplayed (aCS);
       if (IsDisplayed)
-       di <<"ColorScaleIsDisplayed = " << "1" << "\n";
+       di <<"ColorScaleIsDisplayed = 1\n";
       else
-       di <<"ColorScaleIsDisplayed = " << "0" << "\n";
+       di <<"ColorScaleIsDisplayed = 0\n";
     }
   }
   return 0;
@@ -4689,316 +4456,10 @@ static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, c
 #include <Draw_ProgressIndicator.hxx>
 #include <XSControl_WorkSession.hxx>
 #include <Transfer_TransientProcess.hxx>
-#include <XSDRAW_Commands.hxx>
 #include <TColStd_HSequenceOfTransient.hxx>
 #include <Message_ProgressSentry.hxx>
 #include <XSControl_TransferReader.hxx>
 
-static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) 
-{
-  DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
-  if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
-
-  // Progress indicator
-  Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
-  progress->SetScale ( 0, 100, 1 );
-  progress->Show();
-  IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
-  if (ctl.IsNull())
-    ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
-
-  TCollection_AsciiString fnom,rnom;
-
-  Standard_Boolean modfic = XSDRAW::FileAndVar
-    (argv[1],argv[2],"IGESBREP",fnom,rnom);
-  if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
-  else        di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
-  di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
-  IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
-
-#ifdef CHRONOMESURE
-  OSD_Timer Chr; Chr.Reset();
-  IDT_SetLevel(3);
-#endif
-
-
-// Reading the file
-  progress->NewScope ( 20, "Loading" ); // On average loading takes 20% 
-  progress->Show();
-
-  // *New* 
-  //In order to decrease number of produced edges during translation it is possible to set following parameter
-  Interface_Static::SetIVal("read.iges.bspline.continuity",0);
-  // *New* 
-
-  if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
-  else  if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
-
-  progress->EndScope();
-  progress->Show();
-
-  if (readstat != IFSelect_RetDone) {
-    if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
-    else di<<"No model loaded"<<"\n";
-    return 1;
-  }
-// Choice of treatment
-  Standard_Boolean fromtcl = (argc > 3);
-  Standard_Integer modepri = 1, nent, nbs;
-  if (fromtcl) modepri = 4;
-
-  while (modepri) {
-    //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka 
-    //mode OnlyVisible does not work.
-    // nent = Reader.NbRootsForTransfer();
-    if (!fromtcl) {
-      cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<flush;
-      modepri = -1;
-      
-// amv 26.09.2003 : this is used to avoid error of enter's simbol        
-      char str[80];                                                             
-      cin>>str;                                                                 
-      modepri = atoi(str);   
-    }
-
-    if (modepri == 0) {  //fin
-      di << "Bye and good luck! " << "\n";
-      break;
-    } 
-
-    else if (modepri <= 2) {  // 1 : Visible Roots, 2 : All Roots
-      di << "All Geometry Transfer"<<"\n";
-      di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
-      di<<"  To modify : command  param read.iges.bspline.continuity"<<"\n";
-      Handle(XSControl_WorkSession) thesession = Reader.WS();
-      thesession->ClearContext();
-      XSDRAW::SetTransferProcess (thesession->MapReader());
-      progress->NewScope ( 80, "Translation" );
-      progress->Show();
-      thesession->MapReader()->SetProgress ( progress );
-      
-      if (modepri == 1) Reader.SetReadVisible (Standard_True);
-      Reader.TransferRoots();
-      
-      thesession->MapReader()->SetProgress ( 0 );
-      progress->EndScope();
-      progress->Show();
-      // result in only one shape for all the roots
-      //        or in one shape for one root.
-      di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
-      Standard_Integer answer = 1;
-      if (Reader.NbShapes() > 1) {
-       cout << " pass(0)  one shape for all (1)\n or one shape per root (2)\n + WriteBRep (one for all : 3) (one per root : 4) : " << flush;
-        answer = -1;
-        //amv 26.09.2003                                                        
-        char str_a[80];                                                         
-        cin >> str_a;                                                           
-        answer = atoi(str_a);    
-      }
-      if ( answer == 0) continue;
-      if ( answer == 1 || answer == 3) {
-       TopoDS_Shape shape = Reader.OneShape();
-       // save the shape
-       if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
-       char fname[110];
-       sprintf(fname, "%s", rnom.ToCString());
-       di << "Saving shape in variable Draw : " << fname << "\n";
-       if (answer == 3) IGESToBRep::WriteShape (shape,1);
-       try {
-         OCC_CATCH_SIGNALS
-         DBRep::Set(fname,shape);
-       }
-       catch(Standard_Failure) {
-         di << "** Exception : ";
-         di << Standard_Failure::Caught()->GetMessageString();
-         di<<" ** Skip"<<"\n";
-         di << "Saving shape in variable Draw : " << fname << "\n";
-         IGESToBRep::WriteShape (shape,1);
-       }
-      }
-       
-      else if (answer == 2 || answer == 4) {
-       Standard_Integer numshape = Reader.NbShapes();
-       for (Standard_Integer inum = 1; inum <= numshape; inum++) {
-         // save all the shapes
-         TopoDS_Shape shape = Reader.Shape(inum);
-         if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
-         char fname[110];
-         sprintf(fname, "%s_%d", rnom.ToCString(),inum);
-         di << "Saving shape in variable Draw : " << fname << "\n";
-         if (answer == 4) IGESToBRep::WriteShape (shape,inum);
-         try {
-           OCC_CATCH_SIGNALS
-           DBRep::Set(fname,shape);
-         }
-         catch(Standard_Failure) {
-           di << "** Exception : ";
-           di << Standard_Failure::Caught()->GetMessageString();
-           di<<" ** Skip"<<"\n";
-         }
-       }
-      }
-      else return 0;
-    }
-
-    else if (modepri == 3) {  // One Entity
-      cout << "Only One Entity"<<endl;
-      cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<endl;
-      cout<<"  To modify : command  param read.iges.bspline.continuity"<<endl;
-      cout << " give the number of the Entity : " << flush;
-      nent = XSDRAW::GetEntityNumber();
-
-      if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
-      else {
-       nbs = Reader.NbShapes();
-       char shname[30];  sprintf (shname,"%s_%d",rnom.ToCString(),nent);
-       di<<"Transfer entity n0 "<<nent<<" OK  -> DRAW Shape: "<<shname<<"\n";
-       di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
-       TopoDS_Shape sh = Reader.Shape(nbs);
-       DBRep::Set (shname,sh);
-      }
-    }
-
-    else if (modepri == 4) {   // Selection
-      Standard_Integer answer = 1;
-      Handle(TColStd_HSequenceOfTransient)  list;
-
-//  Selection, nommee ou via tcl. tcl : raccourcis admis
-//   * donne iges-visible + xst-transferrable-roots
-//   *r donne xst-model-roots (TOUTES racines)
-
-      if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {         
-        di << "All Geometry Transfer"<<"\n";
-        di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<"\n";
-        di<<"  To modify : command  param read.iges.bspline.continuity"<<"\n";
-        Handle(XSControl_WorkSession) thesession = Reader.WS();
-        thesession->ClearContext();
-        XSDRAW::SetTransferProcess (thesession->MapReader());
-        progress->NewScope ( 80, "Translation" );
-        progress->Show();
-        thesession->MapReader()->SetProgress ( progress );
-      
-        Reader.SetReadVisible (Standard_True);
-        Reader.TransferRoots();
-      
-        thesession->MapReader()->SetProgress ( 0 );
-        progress->EndScope();
-        progress->Show();
-        
-        // result in only one shape for all the roots
-        TopoDS_Shape shape = Reader.OneShape();
-        // save the shape
-        char fname[110];
-        sprintf(fname, "%s", rnom.ToCString());
-        di << "Saving shape in variable Draw : " << fname << "\n";
-        try {
-          OCC_CATCH_SIGNALS
-          DBRep::Set(fname,shape);
-        }
-        catch(Standard_Failure) {
-          di << "** Exception : ";
-         di << Standard_Failure::Caught()->GetMessageString();
-         di<<" ** Skip"<<"\n";
-          di << "Saving shape in variable Draw : " << fname << "\n";
-          IGESToBRep::WriteShape (shape,1);
-        }                                                                             
-        return 0;
-      }
-   
-      if(fromtcl) {
-       modepri = 0;    // d office, une seule passe
-       if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
-         di<<"All Roots : ";
-         list = XSDRAW::GetList ("xst-model-roots");
-       }
-        else {
-         TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
-         di<<"List given by "<<compart.ToCString()<<" : ";
-         list = XSDRAW::GetList (compart.ToCString());
-       }
-       if (list.IsNull()) {
-          di<<"No list defined. Give a selection name or * for all visible transferrable roots"<<"\n";
-          continue;
-        }
-      }
-      else {
-       cout<<"Name of Selection :"<<flush;
-       list = XSDRAW::GetList();
-       if (list.IsNull()) { cout<<"No list defined"<<endl; continue; }
-      }
-
-      Standard_Integer nbl = list->Length();
-      di<<"Nb entities selected : "<<nbl<<"\n";
-      if (nbl == 0) continue;
-      while (answer) {
-       if (!fromtcl) {
-         cout<<"Choice: 0 abandon  1 transfer all  2 with confirmation  3 list n0s ents :"<<flush;
-          answer = -1;
-          // anv 26.09.2003                                                     
-          char str_answer[80];                                                  
-          cin>>str_answer;                                                      
-          answer = atoi(str_answer);    
-       }
-       if (answer <= 0 || answer > 3) continue;
-       if (answer == 3) {
-         for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
-           Handle(Standard_Transient) ent = list->Value(ill);
-           di<<"  ";// model->Print(ent,di);
-         }
-         di<<"\n";
-       }
-       if (answer == 1 || answer == 2) {
-         Standard_Integer nbt = 0;
-         Handle(XSControl_WorkSession) thesession = Reader.WS();
-       
-         XSDRAW::SetTransferProcess (thesession->MapReader());
-          progress->NewScope ( 80, "Translation" );
-          progress->Show();
-          thesession->MapReader()->SetProgress ( progress );
-
-          Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
-         for (Standard_Integer ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
-         
-           nent = Reader.Model()->Number(list->Value(ill));
-           if (nent == 0) continue;
-           if (!Reader.TransferOne(nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
-           else {
-             nbs = Reader.NbShapes();
-             char shname[30];  sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
-             di<<"Transfer entity n0 "<<nent<<" OK  -> DRAW Shape: "<<shname<<"\n";
-             di<<"Now, "<<nbs<<" Shapes produced"<<"\n";
-             TopoDS_Shape sh = Reader.Shape(nbs);
-             DBRep::Set (shname,sh);
-              nbt++;
-           }
-         }
-         thesession->MapReader()->SetProgress ( 0 );
-          progress->EndScope();
-          progress->Show();
-         di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
-         answer = 0;  // on ne reboucle pas
-       }
-      }
-    }
-    else di<<"Unknown mode n0 "<<modepri<<"\n";
-  }
-
-  // *New* 
-  //In order to clear memory after IGES reading you could add the following code
-  Handle(XSControl_TransferReader) TR = Reader.WS()->TransferReader();
-  Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
-  TP->Clear();
-  TR->Clear(2);
-  Reader.WS()->Model()->Clear();
-  Standard_Integer i =1;
-  for( ; i <= 7; i++)
-    Reader.WS()->ClearData(i);
-  // *New* 
-
-  return 0;
-}
-
 #include <Geom_Plane.hxx>
 static Standard_Integer OCC20766 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
@@ -5008,10 +4469,10 @@ static Standard_Integer OCC20766 (Draw_Interpretor& di, Standard_Integer argc, c
     return 1;
   }
 
-  Standard_Real A = atof(argv[2]);
-  Standard_Real B = atof(argv[3]);
-  Standard_Real C = atof(argv[4]);
-  Standard_Real D = atof(argv[5]);
+  Standard_Real A = Draw::Atof(argv[2]);
+  Standard_Real B = Draw::Atof(argv[3]);
+  Standard_Real C = Draw::Atof(argv[4]);
+  Standard_Real D = Draw::Atof(argv[5]);
 
   Handle(Geom_Geometry) result;
 
@@ -5026,10 +4487,10 @@ static Standard_Integer OCC20627 (Draw_Interpretor& di, Standard_Integer argc, c
 {
   if(argc!=2)
     {
-      di << "Usage : " << argv[0] << " MaxNbr" << "\n";
+      di << "Usage : " << argv[0] << " MaxNbr\n";
       return -1;
     }
-  Standard_Integer aMaxNbr = atoi(argv[1]);
+  Standard_Integer aMaxNbr = Draw::Atoi(argv[1]);
 
   for (Standard_Integer i=0;i<aMaxNbr;i++)
     {
@@ -5049,15 +4510,15 @@ Standard_Integer OCC22762 (Draw_Interpretor& di, Standard_Integer argc, const ch
 {
     if (argc!=7)
        {
-           di << "Wrong number of arguments" << "\n";
+           di << "Wrong number of arguments\n";
            return -1;
        }
-    Standard_Real X1_Pnt = atof(argv[1]);
-    Standard_Real Y1_Pnt = atof(argv[2]);
-    Standard_Real Z1_Pnt = atof(argv[3]);
-    Standard_Real X2_Pnt = atof(argv[4]);
-    Standard_Real Y2_Pnt = atof(argv[5]);
-    Standard_Real Z2_Pnt = atof(argv[6]);
+    Standard_Real X1_Pnt = Draw::Atof(argv[1]);
+    Standard_Real Y1_Pnt = Draw::Atof(argv[2]);
+    Standard_Real Z1_Pnt = Draw::Atof(argv[3]);
+    Standard_Real X2_Pnt = Draw::Atof(argv[4]);
+    Standard_Real Y2_Pnt = Draw::Atof(argv[5]);
+    Standard_Real Z2_Pnt = Draw::Atof(argv[6]);
     
     Graphic3d_Vector AV1(X1_Pnt, Y1_Pnt, Z1_Pnt);
     Graphic3d_Vector AV2(X2_Pnt, Y2_Pnt, Z2_Pnt);
@@ -5075,7 +4536,7 @@ Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const ch
 {
   if(argc!=9)
     {
-      di << "Usage : " << argv[0] << " shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf" << "\n";
+      di << "Usage : " << argv[0] << " shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf\n";
       return -1;
     }
 
@@ -5086,15 +4547,15 @@ Standard_Integer OCC17424 (Draw_Interpretor& di, Standard_Integer argc, const ch
     return 1;
   }
 
-  Standard_Real X_Pnt = atof(argv[2]);
-  Standard_Real Y_Pnt = atof(argv[3]);
-  Standard_Real Z_Pnt = atof(argv[4]);
+  Standard_Real X_Pnt = Draw::Atof(argv[2]);
+  Standard_Real Y_Pnt = Draw::Atof(argv[3]);
+  Standard_Real Z_Pnt = Draw::Atof(argv[4]);
 
-  Standard_Real X_Dir = atof(argv[5]);
-  Standard_Real Y_Dir = atof(argv[6]);
-  Standard_Real Z_Dir = atof(argv[7]);
+  Standard_Real X_Dir = Draw::Atof(argv[5]);
+  Standard_Real Y_Dir = Draw::Atof(argv[6]);
+  Standard_Real Z_Dir = Draw::Atof(argv[7]);
 
-  Standard_Real PInf  = atof(argv[8]);
+  Standard_Real PInf  = Draw::Atof(argv[8]);
 
   IntCurvesFace_ShapeIntersector intersector;
   intersector.Load(shape, Precision::Intersection());
@@ -5133,8 +4594,8 @@ Standard_Integer OCC22301 (Draw_Interpretor& di, Standard_Integer argc, const ch
   for (Standard_Integer i = 0; i < 2; i++)
     aPartMask.Add(i);
   
-  di << "aFullMask = 1111" << "\n";
-  di << "aPartMask = 1100" << "\n";
+  di << "aFullMask = 1111\n";
+  di << "aPartMask = 1100\n";
   
   Standard_Boolean isAffected;
   
@@ -5179,10 +4640,10 @@ Standard_Integer OCC22744 (Draw_Interpretor& di, Standard_Integer argc, const ch
   
   TCollection_ExtendedString anExtString;
   
-  Standard_ExtCharacter aNonAsciiChar = 0xff00;
+  Standard_ExtCharacter aNonAsciiChar = 0x0f00;
   anExtString.Insert(1, aNonAsciiChar);
 
-  di << "Is ASCII: " << ( anExtString.IsAscii() ? "true" : "false" ) << "\n";
+  di << "Is ASCII: " << ( anExtString.IsAscii() ? "true : Error" : "false : OK" ) << "\n";
   NCollection_DataMap<TCollection_ExtendedString, Standard_Integer> aMap;
   aMap.Bind(anExtString, 0);
   
@@ -5197,17 +4658,17 @@ Standard_Integer OCC22558 (Draw_Interpretor& di, Standard_Integer argc, const ch
        return 1;
     }
     
-    Standard_Real X_vec = atof(argv[1]);
-    Standard_Real Y_vec = atof(argv[2]);
-    Standard_Real Z_vec = atof(argv[3]);
+    Standard_Real X_vec = Draw::Atof(argv[1]);
+    Standard_Real Y_vec = Draw::Atof(argv[2]);
+    Standard_Real Z_vec = Draw::Atof(argv[3]);
     
-    Standard_Real X_dir = atof(argv[4]);
-    Standard_Real Y_dir = atof(argv[5]);
-    Standard_Real Z_dir = atof(argv[6]);
+    Standard_Real X_dir = Draw::Atof(argv[4]);
+    Standard_Real Y_dir = Draw::Atof(argv[5]);
+    Standard_Real Z_dir = Draw::Atof(argv[6]);
     
-    Standard_Real X_pnt = atof(argv[7]);
-    Standard_Real Y_pnt = atof(argv[8]);
-    Standard_Real Z_pnt = atof(argv[9]);
+    Standard_Real X_pnt = Draw::Atof(argv[7]);
+    Standard_Real Y_pnt = Draw::Atof(argv[8]);
+    Standard_Real Z_pnt = Draw::Atof(argv[9]);
     
     gp_Dir toSym(X_vec, Y_vec, Z_vec);
     gp_Dir dir(X_dir, Y_dir, Z_dir);
@@ -5228,14 +4689,14 @@ Standard_Integer OCC22736 (Draw_Interpretor& di, Standard_Integer argc, const ch
     return 1;
   }
 
-  Standard_Real X_mirrorFirstPoint = atof(argv[1]);
-  Standard_Real Y_mirrorFirstPoint = atof(argv[2]);
-  Standard_Real X_mirrorSecondPoint = atof(argv[3]);
-  Standard_Real Y_mirrorSecondPoint = atof(argv[4]);
-  Standard_Real X_p1 = atof(argv[5]);
-  Standard_Real Y_p1 = atof(argv[6]);
-  Standard_Real X_p2 = atof(argv[7]);
-  Standard_Real Y_p2 = atof(argv[8]);
+  Standard_Real X_mirrorFirstPoint = Draw::Atof(argv[1]);
+  Standard_Real Y_mirrorFirstPoint = Draw::Atof(argv[2]);
+  Standard_Real X_mirrorSecondPoint = Draw::Atof(argv[3]);
+  Standard_Real Y_mirrorSecondPoint = Draw::Atof(argv[4]);
+  Standard_Real X_p1 = Draw::Atof(argv[5]);
+  Standard_Real Y_p1 = Draw::Atof(argv[6]);
+  Standard_Real X_p2 = Draw::Atof(argv[7]);
+  Standard_Real Y_p2 = Draw::Atof(argv[8]);
   
   gp_Trsf2d identityTransformation;
 
@@ -5280,53 +4741,73 @@ Standard_Integer OCC22736 (Draw_Interpretor& di, Standard_Integer argc, const ch
   return 0;
 }
 
-#include <BOPTColStd_CArray1OfInteger.hxx>
-//=======================================================================
-//function : DumpArray
-//purpose  : 
-//=======================================================================
-void DumpArray(const BOPTColStd_CArray1OfInteger& aC,
-              Draw_Interpretor& aDI)
+Standard_Integer OCC23429(Draw_Interpretor& /*di*/,
+                          Standard_Integer narg, const char** a)
 {
-  Standard_Integer iLength, iFactLength, iBlockLength;
-  //
-  iLength=aC.Length();
-  iFactLength=aC.FactLength();
-  iBlockLength=aC.BlockLength();
-  //
-  aDI<< "Length: " <<iLength << "\n";
-  aDI<< "FactLength: " <<iFactLength << "\n";
-  aDI<< "BlockLength: " <<iBlockLength << "\n";
+  if (narg < 4) return 1;
+  
+  TopoDS_Shape aShape = DBRep::Get(a[2]);
+  if (aShape.IsNull()) return 1;
+  
+  BRepFeat_SplitShape Spls(aShape);
+  Spls.SetCheckInterior(Standard_False);
+
+  TopoDS_Shape aTool = DBRep::Get(a[3]);
+
+  BRepAlgoAPI_Section Builder(aShape, aTool, Standard_False);
+  Builder.ComputePCurveOn1(Standard_True);
+  if (narg == 5)
+    Builder.Approximation(Standard_True); 
+  Builder.Build();
+  TopoDS_Shape aSection = Builder.Shape();
+
+  TopExp_Explorer ExpSec(aSection, TopAbs_EDGE);
+  for (; ExpSec.More(); ExpSec.Next())
+  {
+    TopoDS_Edge anEdge = TopoDS::Edge(ExpSec.Current());
+    Handle(Geom2d_Curve) thePCurve;
+    Handle(Geom_Surface) theSurface;
+    TopLoc_Location theLoc;
+    Standard_Real fpar, lpar;
+    BRep_Tool::CurveOnSurface(anEdge, thePCurve, theSurface, theLoc, fpar, lpar);
+    TopoDS_Face aFace;
+    TopExp_Explorer ExpShape(aShape, TopAbs_FACE);
+    for (; ExpShape.More(); ExpShape.Next())
+    {
+      aFace = TopoDS::Face(ExpShape.Current());
+      TopLoc_Location aLoc;
+      Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace, aLoc);
+      if (aSurface == theSurface && aLoc == theLoc)
+        break;
+    }
+    Spls.Add(anEdge, aFace);
+  }
+
+  TopoDS_Shape Result = Spls.Shape();
+  DBRep::Set(a[1], Result);
+
+  return 0;
 }
-//=======================================================================
-//function : bcarray
-//purpose  : 
-//=======================================================================
-Standard_Integer bcarray (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+
+#include <ExprIntrp_GenExp.hxx>
+Standard_Integer CR23403 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
        
-  if (argc != 1) {
-    di << "Usage : " << argv[0] << "\n";
+  if (argc != 2) {
+    di << "Usage : " << argv[0] << " string\n";
     return 1;
   }
 
-  Standard_Integer i, aBL;
-  BOPTColStd_CArray1OfInteger aC;
-  //
-  aBL=100000;
-  aC.SetBlockLength(aBL);
-  //
-  for (i=1; i<=10; ++i) {
-    aC.Append(-i*10);
+  Standard_CString aString = argv[1];
+  Handle(ExprIntrp_GenExp) myExpr = ExprIntrp_GenExp::Create();
+  try {
+    OCC_CATCH_SIGNALS
+    myExpr->Process( aString );
   }
-  di<< "\nstate before release the unused memory\n";
-  DumpArray(aC, di);
-  //
-  aC.Purge();
-  //
-  di<< "\nstate after release the unused memory\n";
-  DumpArray(aC, di);
-  //
+  catch(Standard_Failure const& anException) {
+    di << "Exception : " << anException.GetMessageString() << "\n";
+  }
+
   return 0;
 }
 
@@ -5340,7 +4821,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
 
   theCommands.Add("OCC136", "OCC136", __FILE__, OCC136, group);
   theCommands.Add("BUC60610","BUC60610 iges_input [name]",__FILE__,BUC60610,group);
-  theCommands.Add("BUC60661","BUC60661 file.igs",__FILE__,BUC60661,  group);
 
 //====================================================
 //
@@ -5372,7 +4852,7 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC310","OCC310", __FILE__, OCC310bug, group);
 
   //theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
-  theCommands.Add("OCC277","OCC277 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC277bug, group);
+  theCommands.Add("OCC277","OCC277", __FILE__, OCC277bug, group);
 
   theCommands.Add("OCC333","OCC333 edge1 edge2 [toler domaindist]; Check overlapping edges", __FILE__, OCC333bug, group);
 
@@ -5385,10 +4865,8 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC369", "OCC369 Shape", __FILE__, OCC369, group);
   theCommands.Add("OCC524", "OCC524 LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix", __FILE__, OCC524, group);
   theCommands.Add("OCC525", "OCC525", __FILE__, OCC525, group);
-  theCommands.Add("OCC543", "OCC543 name", __FILE__, OCC543, group);
   //theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
-  theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC578, group);
-  theCommands.Add("OCC627", "OCC627", __FILE__, OCC627, group);
+  theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
   theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group);
   theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group);
   theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group);
@@ -5407,14 +4885,14 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC1034_AISSelectionMode", "OCC1034_AISSelectionMode (DOC, entry, [selectionmode])", __FILE__, OCC1034_AISSelectionMode, group); 
 
   //theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
-  theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC1487, group);
+  theCommands.Add("OCC1487", "OCC1487 CylinderVariant(=1/2) cylinder1 cylinder2 cutshape", __FILE__, OCC1487, group);
 
   theCommands.Add("OCC1077", "OCC1077 result", __FILE__, OCC1077, group);
   theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
   theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
   theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
   theCommands.Add("OCC6143", "OCC6143", __FILE__, OCC6143, group);
-  theCommands.Add("OCC7141", "OCC7141 [nCount]", __FILE__, OCC7141, group);
+  theCommands.Add("OCC7141", "OCC7141 [nCount] aPath", __FILE__, OCC7141, group);
   theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
   theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);
   theCommands.Add("OCC10138", "OCC10138 lower upper", __FILE__, OCC10138, group);
@@ -5428,7 +4906,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC15755", "OCC15755 file shape", __FILE__, OCC15755, group);
   theCommands.Add("OCC16782", "OCC16782 file.std file.xml file.cbf", __FILE__, OCC16782, group);
   theCommands.Add("OCC12584", "OCC12584 [mode = 0/1/2]", __FILE__, OCC12584, group);
-  theCommands.Add("OCC18612", "OCC18612 [file else already loaded model] [name DRAW]", __FILE__, OCC18612igesbrep, group);
   theCommands.Add("OCC20766", "OCC20766 plane a b c d", __FILE__, OCC20766, group);
   theCommands.Add("OCC20627", "OCC20627", __FILE__, OCC20627, group);
   theCommands.Add("OCC17424", "OCC17424  shape X_Pnt Y_Pnt Z_Pnt X_Dir Y_Dir Z_Dir PInf", __FILE__, OCC17424, group);
@@ -5436,8 +4913,9 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC22586", "OCC22586 shape resshape", __FILE__, OCC22586, group);
   theCommands.Add("OCC22736", "OCC22736 X_mirrorFirstPoint Y_mirrorFirstPoint X_mirrorSecondPoint Y_mirrorSecondPoint X_p1 Y_p1 X_p2 Y_p2", __FILE__, OCC22736, group);
   theCommands.Add("OCC22744", "OCC22744", __FILE__, OCC22744, group);
-  theCommands.Add("bcarray", "bcarray", __FILE__, bcarray, group);
   theCommands.Add("OCC22762", "OCC22762 x1 y1 z1 x2 y2 z3", __FILE__, OCC22762, group);
   theCommands.Add("OCC22558", "OCC22558 x_vec y_vec z_vec x_dir y_dir z_dit x_pnt y_pnt z_pnt", __FILE__, OCC22558, group);
+  theCommands.Add("CR23403", "CR23403 string", __FILE__, CR23403, group);
+  theCommands.Add("OCC23429", "OCC23429 res shape tool [appr]", __FILE__, OCC23429, group);
   return;
 }