0027349: XtControl_Reader is not thread-safe
[occt.git] / src / QABugs / QABugs_11.cxx
index f962a08..5c7404a 100644 (file)
@@ -26,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>
@@ -74,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>
@@ -87,8 +89,9 @@
 #include <V3d_View.hxx>
 #include <BRepFeat_SplitShape.hxx>
 #include <BRepAlgoAPI_Section.hxx>
+#include <TColStd_PackedMapOfInteger.hxx>
 
-#if ! defined(WNT)
+#if ! defined(_WIN32)
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
 #else
 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
@@ -216,30 +219,30 @@ static Standard_Integer OCC136 (Draw_Interpretor& di, Standard_Integer argc, con
   anAISCtx->EraseAll();
 
   //load primitives to context
-  Handle(AIS_Shape) aSh1 = new AIS_Shape(aBox);
+  Handle(AIS_InteractiveObject) aSh1 = new AIS_Shape(aBox);
   anAISCtx->Display(aSh1);
 
-  Handle(AIS_Shape) aSh2 = new AIS_Shape(aSphere);
+  Handle(AIS_InteractiveObject) aSh2 = new AIS_Shape(aSphere);
   anAISCtx->Display(aSh2);
 
-  Handle(AIS_Shape) aSh3 = new AIS_Shape(aCone);
+  Handle(AIS_InteractiveObject) aSh3 = new AIS_Shape(aCone);
   anAISCtx->Display(aSh3);
 
-  Handle(AIS_Shape) aSh4 = new AIS_Shape(aCyl);
+  Handle(AIS_InteractiveObject) aSh4 = new AIS_Shape(aCyl);
   anAISCtx->Display(aSh4);
 
   //set selected
-  anAISCtx->InitCurrent();
-  anAISCtx->AddOrRemoveCurrentObject(aSh1);
-  anAISCtx->AddOrRemoveCurrentObject(aSh2);
-  anAISCtx->AddOrRemoveCurrentObject(aSh3);
-  anAISCtx->AddOrRemoveCurrentObject(aSh4);
+  anAISCtx->InitSelected();
+  anAISCtx->AddOrRemoveSelected(aSh1);
+  anAISCtx->AddOrRemoveSelected(aSh2);
+  anAISCtx->AddOrRemoveSelected(aSh3);
+  anAISCtx->AddOrRemoveSelected(aSh4);
 
   //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);
   return 0;
 }
 
@@ -373,7 +376,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;
   }
 
@@ -382,7 +385,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);
@@ -466,21 +469,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 = 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()) {
@@ -523,7 +526,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");
@@ -590,7 +593,6 @@ Standard_Integer  OCC165(Draw_Interpretor& di ,
 #include<BRepAlgo_Cut.hxx>
 
 #include<BRepPrimAPI_MakeHalfSpace.hxx>
-#include<Handle_Geom_CartesianPoint.hxx>
 #include<Geom_CartesianPoint.hxx>
 #include<AIS_Point.hxx>
 
@@ -674,7 +676,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];
@@ -738,12 +740,13 @@ 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;
@@ -757,7 +760,7 @@ 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;
   }
 
@@ -769,34 +772,34 @@ static Standard_Integer OCC381_Save (Draw_Interpretor& di, Standard_Integer nb,
 
   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 << "Error saving document: Could not store , no driver found to make it" << "\n";
+        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";
+        di << "Error saving document: Write access failure\n";
         break;
       }
       case PCDM_SS_Failure: {
-        di << "Error saving document: Write failure" << "\n" ;
+        di << "Error saving document: Write failure\n" ;
         break;
       }
       case PCDM_SS_Doc_IsNull: {
-        di << "Error saving document: No document to save" << "\n";
+        di << "Error saving document: No document to save\n";
         break ;
       }
       case PCDM_SS_No_Obj: {
-        di << "Error saving document: No objects written" << "\n";
+        di << "Error saving document: No objects written\n";
         break;
       }
       case PCDM_SS_Info_Section_Error: {
-        di << "Error saving document: Write info section failure" << "\n" ;
+        di << "Error saving document: Write info section failure\n" ;
         break;
       }
       default:
@@ -810,7 +813,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;
   }
 
@@ -826,27 +829,27 @@ static Standard_Integer OCC381_SaveAs (Draw_Interpretor& di, Standard_Integer nb
   if (theStatus != PCDM_SS_OK ) {
     switch ( theStatus ) {
       case PCDM_SS_DriverFailure: {
-        di << "Error saving document: Could not store , no driver found to make it" << "\n";
+        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";
+        di << "Error saving document: Write access failure\n";
         break;
       }
       case PCDM_SS_Failure: {
-        di << "Error saving document: Write failure" << "\n" ;
+        di << "Error saving document: Write failure\n" ;
         break;
       }
       case PCDM_SS_Doc_IsNull: {
-        di << "Error saving document: No document to save" << "\n";
+        di << "Error saving document: No document to save\n";
         break ;
       }
       case PCDM_SS_No_Obj: {
-        di << "Error saving document: No objects written" << "\n";
+        di << "Error saving document: No objects written\n";
         break;
       }
       case PCDM_SS_Info_Section_Error: {
-        di << "Error saving document: Write info section failure" << "\n" ;
+        di << "Error saving document: Write info section failure\n" ;
         break;
       }
       default:
@@ -916,10 +919,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;
 }
 
@@ -948,7 +951,7 @@ static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, co
   //  return 1;
   //}
   if(nb < 1 || nb > 2) {
-    di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+    di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
     return 1;
   }
   Standard_Boolean IsBRepAlgoAPI = Standard_True;
@@ -974,14 +977,14 @@ static Standard_Integer OCC277bug (Draw_Interpretor& di, Standard_Integer nb, co
 //#endif
   TopoDS_Shape fuse,comm;
   if (IsBRepAlgoAPI) {
-    di << "fuse = BRepAlgoAPI_Fuse( shape1, shape2 )" <<"\n";
-    di << "comm = BRepAlgoAPI_Common( shape1, shape2 )" <<"\n";
+    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";
+    di << "fuse = BRepAlgo_Fuse( shape1, shape2 )\n";
     fuse = BRepAlgo_Fuse( shape1, shape2 );
-    di << "comm = BRepAlgo_Common( shape1, shape2 )" <<"\n";
+    di << "comm = BRepAlgo_Common( shape1, shape2 )\n";
     comm = BRepAlgo_Common( shape1, shape2 );
   }
 
@@ -993,22 +996,22 @@ 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();
@@ -1022,17 +1025,17 @@ static Standard_Integer OCC333bug (Draw_Interpretor& di, Standard_Integer n, con
   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;
 }
@@ -1212,8 +1215,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)
@@ -1348,7 +1351,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;}
@@ -1448,7 +1455,7 @@ static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, con
   //  return 1;
   //}
   if(argc < 4 || argc > 5) {
-    di << "Usage : " << argv[0] << " shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+    di << "Usage : " << argv[0] << " shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]\n";
     return 1;
   }
   Standard_Boolean IsBRepAlgoAPI = Standard_True;
@@ -1456,9 +1463,9 @@ static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, con
     Standard_Integer IsB = Draw::Atoi(argv[4]);
     if (IsB != 1) {
       IsBRepAlgoAPI = Standard_False;
-//      di << "Error: There is not BRepAlgo_Fuse class" << "\n";
+//      di << "Error: There is not BRepAlgo_Fuse class\n";
 //      return 1;
-//      di << "Error: There is not BRepAlgo_Cut class" << "\n";
+//      di << "Error: There is not BRepAlgo_Cut class\n";
 //      return 1;
     }
   }
@@ -1533,10 +1540,10 @@ static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, con
 //#endif
   TopoDS_Shape wedge_common;
   if (IsBRepAlgoAPI) {
-    di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)" <<"\n";
+    di << "wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a)\n";
     wedge_common = BRepAlgoAPI_Fuse(wedge1a , wedge2a);
   } else {
-    di << "wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a)" <<"\n";
+    di << "wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a)\n";
     wedge_common = BRepAlgo_Fuse(wedge1a , wedge2a);
   }
 
@@ -1548,10 +1555,10 @@ static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, con
 //#endif
   TopoDS_Shape sub_etch1;
   if (IsBRepAlgoAPI) {
-    di << "sub_etch1 = BRepAlgoAPI_Cut(substrate, wedge_common)" <<"\n";
+    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";
+    di << "sub_etch1 = BRepAlgo_Cut(substrate, wedge_common)\n";
     sub_etch1 = BRepAlgo_Cut(substrate, wedge_common);
   }
 
@@ -1650,12 +1657,12 @@ 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;
   }
   
@@ -1667,15 +1674,15 @@ 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();
+    AISObj->ResetTransformation();
     if (!aContext->HasOpenedContext()) {
       aContext->OpenLocalContext();
     }
@@ -1698,8 +1705,16 @@ 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 {
+    Standard_OutOfRange::Raise();
+  }
+  catch (Standard_Failure) {
+    std::cout << "Caught successfully: ";
+    Standard_Failure::Caught()->Print (std::cout);
+    std::cout << endl;
+  }
   return 0;
 }
 
@@ -1751,7 +1766,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;
   }
 
@@ -1777,7 +1792,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;
@@ -1800,7 +1815,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;
   }
 
@@ -1858,7 +1873,7 @@ static Standard_Integer OCC1029_AISTransparency (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -1891,7 +1906,7 @@ static Standard_Integer OCC1030_AISColor (Draw_Interpretor& di,
       return 0; 
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -1925,7 +1940,7 @@ static Standard_Integer OCC1031_AISMaterial (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -1959,7 +1974,7 @@ static Standard_Integer OCC1032_AISWidth (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -1993,7 +2008,7 @@ static Standard_Integer OCC1033_AISMode (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -2027,7 +2042,7 @@ static Standard_Integer OCC1034_AISSelectionMode (Draw_Interpretor& di,
       return 0;
     }
   }
-  di << arg[0] << " : Error" << "\n";
+  di << arg[0] << " : Error\n";
   return 1;
 }
 
@@ -2044,7 +2059,7 @@ static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, co
   //  return -1;
   //}
   if(argc < 5 || argc > 6) {
-    di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
+    di << "Usage : " << argv[0] << " CylinderVariant(=1/2) cylinder1 cylinder2 cutshape [BRepAlgoAPI/BRepAlgo = 1/0]\n";
     return 1;
   }
   Standard_Boolean IsBRepAlgoAPI = Standard_True;
@@ -2052,7 +2067,7 @@ static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, co
     Standard_Integer IsB = Draw::Atoi(argv[5]);
     if (IsB != 1) {
       IsBRepAlgoAPI = Standard_False;
-//      di << "Error: There is not BRepAlgo_Cut class" << "\n";
+//      di << "Error: There is not BRepAlgo_Cut class\n";
 //      return 1;
     }
   }
@@ -2083,10 +2098,10 @@ static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, co
 //    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";
+      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";
+      di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
       o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
     }
   } else {
@@ -2103,10 +2118,10 @@ static Standard_Integer OCC1487 (Draw_Interpretor& di, Standard_Integer argc, co
 //    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";
+      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";
+      di << "o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ())\n";
       o_cut_shape = BRepAlgo_Cut (o_mc1.Solid (), o_mc2.Solid ());
     }
   }
@@ -2219,7 +2234,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;
   }
 
@@ -2238,7 +2253,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];
@@ -2251,7 +2266,7 @@ 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));
@@ -2261,7 +2276,7 @@ static Standard_Integer OCC5739_UniAbs (Draw_Interpretor& di, Standard_Integer a
   int res;
   if (!aUni.IsDone())
   {
-    di << argv[0] <<" : fail"<<"\n";
+    di << argv[0] <<" : fail\n";
     res = 1;
   }
   else
@@ -2286,7 +2301,7 @@ 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;
   }
 
@@ -2295,7 +2310,7 @@ static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, co
   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);
@@ -2305,8 +2320,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) {
@@ -2315,7 +2330,7 @@ static Standard_Integer OCC6046 (Draw_Interpretor& di, Standard_Integer argc, co
       di<<"\n";
     }
   }
-  di<<" done"<<"\n";
+  di<<" done\n";
 
   delete [] pv;
 
@@ -2326,7 +2341,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);
@@ -2350,14 +2365,15 @@ 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;
 }
 
-#ifdef WNT
+// 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];
@@ -2366,8 +2382,10 @@ static int StackOverflow (int i = -1)
     StackOverflow(i-1);
   return i;
 }
+#endif
 
 // 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)
@@ -2391,29 +2409,29 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "\n";
       Standard_Integer res, a =4, b = 0 ;
       res = a / b;
-      di << " 4 / 0 = " << res << "  Does not Caught... KO"<< "\n";
+      di << " 4 / 0 = " << res << "  Does not Caught... KO\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 << " Ok\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      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
   }
@@ -2427,22 +2445,23 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       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";
-      Succes = Standard_False;
+      di << " 4.0 / 0.0 = " << res << "  Does not Caught... OK\n";
     }
     catch(Standard_DivideByZero) // Solaris, Windows w/o SSE2
     {
-      di << " Ok" << "\n";
+      di << " KO\n";
+      Succes = Standard_False;
     }
     catch(Standard_NumericError) // Linux, Windows with SSE2
     {
-      di << " Ok" << "\n";
+      di << " KO\n";
+      Succes = Standard_False;
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2458,16 +2477,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 << " "<<res<<"="<<i<<"+1  Does not Caught... (But) Ok\n";
     }
     catch(Standard_Overflow) {
-      di << " Ok"<< "\n";
+      di << " Ok\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2484,22 +2503,23 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       
       (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
 
-      di << "-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... KO"<< "\n";
-      Succes = Standard_False;
+      di << "-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... OK\n";
     }
     catch(Standard_Overflow) // Solaris, Windows w/o SSE2
     {
-      di << " Ok" << "\n";
+      di << " KO\n";
+      Succes = Standard_False;
     }
     catch(Standard_NumericError) // Linux, Windows with SSE2
     {
-      di << " Ok" << "\n";
+      di << " KO\n";
+      Succes = Standard_False;
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2516,21 +2536,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<<" -- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... (But) Ok\n";
     }
     catch(Standard_Underflow) // could be on Solaris, Windows w/o SSE2
     {
-      di << " Ok" << "\n";
+      di << " KO\n";
+      Succes = Standard_False;
     }
     catch(Standard_NumericError) // could be on Linux, Windows with SSE2
     {
-      di << " Ok" << "\n";
+      di << " KO\n";
+      Succes = Standard_False;
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2544,17 +2566,17 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "\n";
       Standard_Real res, r=-1;
       res = sqrt(r);
-      di<<" "<<res<<"=sqrt("<<r<<")  Does not Caught... KO"<<"\n";
-      Succes = Standard_False;
+      di<<" "<<res<<"=sqrt("<<r<<")  Does not Caught... OK\n";
     }
     catch(Standard_NumericError) {
-      di << " Ok"<< "\n";
+      di << " KO\n";
+      Succes = Standard_False;
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
@@ -2568,26 +2590,26 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "\n";
       int* pint=NULL;
       *pint = 4;
-      di << "  Does not Caught... KO"<<"\n";
+      di << "  Does not Caught... KO\n";
       Succes = Standard_False;
     }
-#ifdef WNT
+#ifdef _WIN32
     catch(OSD_Exception_ACCESS_VIOLATION)
 #else
     catch(OSD_SIGSEGV)
 #endif
     {
-      di << " Ok"<< "\n";
+      di << " Ok\n";
     } catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      di << ")... KO\n";
       Succes = Standard_False;
     }
   }
 
-#ifdef WNT
+#if defined(_WIN32) && !defined(_WIN64)
   {//==== Test Stack Overflow ===============================================
     try {
       OCC_CATCH_SIGNALS
@@ -2596,31 +2618,31 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       //cout.flush();
       di << "\n";
       StackOverflow();
-      di << "  Does not Caught... KO"<<"\n";
+      di << "  Does not Caught... KO\n";
       Succes = Standard_False;
     }
     catch(OSD_Exception_STACK_OVERFLOW) {
-      di << " Ok"<< "\n";
+      di << " Ok\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
-      di << ")... KO" << "\n";
+      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
 
@@ -2649,7 +2671,7 @@ static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, co
 
   if (argc > 3)
     {
-      di << "Usage : " << argv[0] << " [nCount] path" << "\n";
+      di << "Usage : " << argv[0] << " [nCount] path\n";
       return 1;
     }
 
@@ -2664,7 +2686,7 @@ static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, co
   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 {
@@ -2674,14 +2696,14 @@ static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, co
     }
   }
   catch(OSD_Exception_STACK_OVERFLOW) {
-    di << "Failed : STACK OVERFLOW\n" << "\n";
+    di << "Failed : STACK OVERFLOW\n\n";
   }
   catch (Standard_Failure) {
-    di << "Failed :\n" << "\n";
+    di << "Failed :\n\n";
     //cout << Standard_Failure::Caught() << endl;
     di << Standard_Failure::Caught()->GetMessageString();
   }
-  di << argv[0] << " : Finish" << "\n";
+  di << argv[0] << " : Finish\n";
   
   return 0;
 }
@@ -2733,7 +2755,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));
@@ -2772,7 +2794,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" ;
     }
   }
 
@@ -2788,20 +2810,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;
@@ -2810,7 +2832,7 @@ 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;
   }
 
@@ -3020,7 +3042,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;
     }
 
@@ -3194,7 +3216,7 @@ Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const cha
   }
   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);
 
@@ -4000,7 +4022,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:
@@ -4472,7 +4494,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";
@@ -4507,7 +4529,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;
   }
 
@@ -4527,21 +4549,37 @@ 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->GetTransformPersistenceMode() != Graphic3d_TMF_2d)
+  {
+    aCS->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
+  }
+  Standard_Integer aWinWidth, aWinHeight;
+  V->Window()->Size (aWinWidth, aWinHeight);
+  aCS->SetSize (aWinWidth, aWinHeight);
   if ( !V.IsNull() ) {
     if (mode == 0) {
-      V->ColorScaleDisplay();
+      aContext->Display (aCS);
     }
     if (mode == 1) {
-      V->ColorScaleErase();
+      aContext->Erase (aCS);
       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;
@@ -4603,8 +4641,8 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
   progress->Show();
 
   if (readstat != IFSelect_RetDone) {
-    if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon"<<"\n";
-    else di<<"No model loaded"<<"\n";
+    if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon\n";
+    else di<<"No model loaded\n";
     return 1;
   }
 // Choice of treatment
@@ -4627,25 +4665,25 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
     }
 
     if (modepri == 0) {  //fin
-      di << "Bye and good luck! " << "\n";
+      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";
+      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());
+      XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
       progress->NewScope ( 80, "Translation" );
       progress->Show();
-      thesession->MapReader()->SetProgress ( progress );
+      thesession->TransferReader()->TransientProcess()->SetProgress ( progress );
       
       if (modepri == 1) Reader.SetReadVisible (Standard_True);
       Reader.TransferRoots();
       
-      thesession->MapReader()->SetProgress ( 0 );
+      thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
       progress->EndScope();
       progress->Show();
       // result in only one shape for all the roots
@@ -4664,7 +4702,7 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
       if ( answer == 1 || answer == 3) {
        TopoDS_Shape shape = Reader.OneShape();
        // save the shape
-       if (shape.IsNull()) { di<<"No Shape produced"<<"\n"; continue; }
+       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";
@@ -4676,7 +4714,7 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
        catch(Standard_Failure) {
          di << "** Exception : ";
          di << Standard_Failure::Caught()->GetMessageString();
-         di<<" ** Skip"<<"\n";
+         di<<" ** Skip\n";
          di << "Saving shape in variable Draw : " << fname << "\n";
          IGESToBRep::WriteShape (shape,1);
        }
@@ -4687,7 +4725,7 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
        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; }
+         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";
@@ -4699,7 +4737,7 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
          catch(Standard_Failure) {
            di << "** Exception : ";
            di << Standard_Failure::Caught()->GetMessageString();
-           di<<" ** Skip"<<"\n";
+           di<<" ** Skip\n";
          }
        }
       }
@@ -4713,12 +4751,12 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
       cout << " give the number of the Entity : " << flush;
       nent = XSDRAW::GetEntityNumber();
 
-      if (!Reader.TransferOne (nent)) di<<"Transfer entity n0 "<<nent<<" : no result"<<"\n";
+      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";
+       di<<"Now, "<<nbs<<" Shapes produced\n";
        TopoDS_Shape sh = Reader.Shape(nbs);
        DBRep::Set (shname,sh);
       }
@@ -4733,20 +4771,20 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
 //   *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";
+        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());
+        XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
         progress->NewScope ( 80, "Translation" );
         progress->Show();
-        thesession->MapReader()->SetProgress ( progress );
+        thesession->TransferReader()->TransientProcess()->SetProgress ( progress );
       
         Reader.SetReadVisible (Standard_True);
         Reader.TransferRoots();
       
-        thesession->MapReader()->SetProgress ( 0 );
+        thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
         progress->EndScope();
         progress->Show();
         
@@ -4763,7 +4801,7 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
         catch(Standard_Failure) {
           di << "** Exception : ";
          di << Standard_Failure::Caught()->GetMessageString();
-         di<<" ** Skip"<<"\n";
+         di<<" ** Skip\n";
           di << "Saving shape in variable Draw : " << fname << "\n";
           IGESToBRep::WriteShape (shape,1);
         }                                                                             
@@ -4782,7 +4820,7 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
          list = XSDRAW::GetList (compart.ToCString());
        }
        if (list.IsNull()) {
-          di<<"No list defined. Give a selection name or * for all visible transferrable roots"<<"\n";
+          di<<"No list defined. Give a selection name or * for all visible transferrable roots\n";
           continue;
         }
       }
@@ -4816,28 +4854,28 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
          Standard_Integer nbt = 0;
          Handle(XSControl_WorkSession) thesession = Reader.WS();
        
-         XSDRAW::SetTransferProcess (thesession->MapReader());
+         XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
           progress->NewScope ( 80, "Translation" );
           progress->Show();
-          thesession->MapReader()->SetProgress ( progress );
+          thesession->TransferReader()->TransientProcess()->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";
+           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";
+             di<<"Now, "<<nbs<<" Shapes produced\n";
              TopoDS_Shape sh = Reader.Shape(nbs);
              DBRep::Set (shname,sh);
               nbt++;
            }
          }
-         thesession->MapReader()->SetProgress ( 0 );
+         thesession->TransferReader()->TransientProcess()->SetProgress ( 0 );
           progress->EndScope();
           progress->Show();
          di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
@@ -4850,8 +4888,8 @@ static Standard_Integer OCC18612igesbrep (Draw_Interpretor& di, Standard_Integer
 
   // *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();
+  const Handle(XSControl_TransferReader) &TR = Reader.WS()->TransferReader();
+  const Handle(Transfer_TransientProcess) &TP = TR->TransientProcess();
   TP->Clear();
   TR->Clear(2);
   Reader.WS()->Model()->Clear();
@@ -4890,7 +4928,7 @@ 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 = Draw::Atoi(argv[1]);
@@ -4913,7 +4951,7 @@ 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 = Draw::Atof(argv[1]);
@@ -4939,7 +4977,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;
     }
 
@@ -4997,8 +5035,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;
   
@@ -5217,12 +5255,14 @@ Standard_Integer CR23403 (Draw_Interpretor& di, Standard_Integer argc, const cha
 
 #include <Quantity_NameOfColor.hxx>
 #include <TopAbs_ShapeEnum.hxx>
+#include <Geom_Curve.hxx>
+#include <AIS_InteractiveObject.hxx>
 Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
   // Check the command arguments
   if (argc != 2)
   {
-    di <<"Error: "<<argv[0]<<" - invalid number of arguments"<< "\n";
+    di <<"Error: "<<argv[0]<<" - invalid number of arguments\n";
     di << "Usage : " << argv[0] << " mode(0/1)\n";
     return 1; //TCL_ERROR
   }
@@ -5234,7 +5274,7 @@ Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const cha
   Handle(AIS_InteractiveContext) aisContext = ViewerTest::GetAISContext();
   if (aisContext.IsNull())
   {
-    di <<"Error: call 'vinit' first"<< "\n";
+    di <<"Error: call 'vinit' first\n";
     return 1; //TCL_ERROR
   }
 
@@ -5248,7 +5288,7 @@ Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const cha
   Handle(Geom_Axis2Placement) trihedronAxis = new Geom_Axis2Placement(gp::XOY());
   Handle(AIS_Trihedron) trihedron = new AIS_Trihedron(trihedronAxis);
   if (aMode)
-    trihedron->UnsetSelectionMode(); // this line causes an exception on OpenLocalContext
+    aisContext->SetAutoActivateSelection (Standard_False); // if selection must not be activated
   trihedron->SetSize(20);
   trihedron->SetColor(Quantity_NOC_GRAY30);
   trihedron->SetArrowColor(Quantity_NOC_GRAY30);
@@ -5263,7 +5303,7 @@ Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const cha
   aisContext->OpenLocalContext();
   //aisContext->ActivateStandardMode(TopAbs_ShapeEnum::TopAbs_EDGE);
   aisContext->ActivateStandardMode(TopAbs_EDGE);
-  aisContext->SetSensitivity(8);
+  aisContext->SetPixelTolerance(8);
 
   return 0; //TCL_OK
 }