0020716: Eliminate usage of "config.h" header file
[occt.git] / src / ViewerTest / ViewerTest_ObjectCommands.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 98f06a7..a05402d
@@ -1,35 +1,34 @@
-// File:      ViewerTest_ObjectsCommands.cxx
-// Created:   Thu Nov 12 15:50:42 1998
-// Author:    Robert COUBLANC
-// Copyright: OPEN CASCADE 1998
-
-
-//===============================================
+// Created on: 1998-11-12
+// Created by: Robert COUBLANC
+// Copyright (c) 1998-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-//    AIS Objects Creation : Datums (axis,trihedrons,lines,planes)
+// This file is part of Open CASCADE Technology software library.
 //
-//===============================================
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+// 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #include <ViewerTest.hxx>
 
-#include <string.h>
-
 #include <Quantity_NameOfColor.hxx>
 #include <Draw_Interpretor.hxx>
 #include <Draw.hxx>
 #include <Draw_Appli.hxx>
 #include <DBRep.hxx>
 
+#include <Font_BRepFont.hxx>
+#include <Font_FontMgr.hxx>
 #include <OSD_Chronometer.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <Visual3d_View.hxx>
 #include <V3d_Viewer.hxx>
 #include <V3d_View.hxx>
-#include <V3d_Plane.hxx>
 #include <V3d.hxx>
 
 #include <AIS_Shape.hxx>
@@ -67,8 +66,8 @@
 #include <AIS_InteractiveContext.hxx>
 #include <Geom_Plane.hxx>
 #include <gp_Pln.hxx>
-#include <AIS_AngleDimension.hxx>
 #include <TCollection_ExtendedString.hxx>
+#include <TCollection_HAsciiString.hxx>
 #include <GC_MakePlane.hxx>
 #include <gp_Circ.hxx>
 #include <AIS_Axis.hxx>
 #include <Graphic3d_ArrayOfQuadrangles.hxx>
 #include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
 #include <Graphic3d_ArrayOfPolygons.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Standard_Real.hxx>
 
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
+#include <AIS_Circle.hxx>
+#include <AIS_Drawer.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <Geom_Circle.hxx>
+#include <GC_MakeCircle.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Select3D_SensitiveCircle.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <StdFail_NotDone.hxx>
+#include <StdPrs_ShadedShape.hxx>
+#include <TopoDS_Wire.hxx>
+
+#include <AIS_MultipleConnectedInteractive.hxx>
+#include <AIS_ConnectedInteractive.hxx>
+#include <TopLoc_Location.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include <Select3D_SensitiveTriangle.hxx>
+#include <Select3D_SensitiveCurve.hxx>
+#include <Select3D_SensitivePoint.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <StdPrs_Curve.hxx>
+
+#include <BRepExtrema_ExtPC.hxx>
+#include <BRepExtrema_ExtPF.hxx>
+
+#include <Prs3d_VertexDrawMode.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
+
+#include <Image_AlienPixMap.hxx>
+#include <TColStd_HArray1OfAsciiString.hxx>
 
-#ifdef WNT
-#define _CRT_SECURE_NO_DEPRECATE
-#pragma warning (disable:4996)
+#ifdef _WIN32
+# define _CRT_SECURE_NO_DEPRECATE
+# pragma warning (disable:4996)
 #endif
 
 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
 extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
                                            const Handle(AIS_InteractiveObject)& theAISObj,
                                            Standard_Boolean theReplaceIfExists = Standard_True);
-Standard_IMPORT int ViewerMainLoop(Standard_Integer argc, const char** argv);
+extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
 extern Handle(AIS_InteractiveContext)& TheAISContext();
 
 
@@ -199,57 +232,56 @@ static int VTrihedron2D (Draw_Interpretor& di, Standard_Integer argc, const char
 
 //==============================================================================
 //function : VTriherdron
-//author   : ege
 //purpose  : Create a trihedron. If no arguments are set, the default
 //           trihedron (Oxyz) is created.
 //Draw arg : vtrihedron  name  [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw]
 //==============================================================================
 
-static int VTrihedron (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-
+static int VTrihedron (Draw_Interpretor& theDi,
+                       Standard_Integer  theArgsNb,
+                       const char**      theArgVec)
 {
-  // Verification des arguments
-  if ( argc<2 || argc>11) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
-
-  // Declarations et creation des objets par default
-  TCollection_AsciiString     name=argv[1];
-
-  if(argc > 5 && argc!=11)
-  {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
-
-  // Cas ou il y a des arguments
-  Standard_Real coord[9]={0.,0.,0.,0.,0.,1.,1.,0.,0.};
-  if (argc>2){
-    Standard_Integer i ;
-    for( i=0;i<=2;i++)
-      coord[i]= atof(argv[2+i]);
+  if (theArgsNb != 2 && theArgsNb != 5 && theArgsNb != 11)
+  {
+    theDi << theArgVec[0] << " Syntax error\n";
+    return 1;
+  }
 
-    if(argc>5){
-      for(i=0;i<=2;i++){
-        coord[3+i] = atof(argv[6+i]);
-        coord[6+i] = atof(argv[8+i]);
-      }
+  gp_Pnt anOrigin (0.0, 0.0, 0.0);
+  gp_Dir aDirZ = gp::DZ();
+  gp_Dir aDirX = gp::DX();
+  Standard_Integer anArgIter = 2; // 1st is an IO name
+  if (anArgIter < theArgsNb)
+  {
+    anOrigin.SetX (Draw::Atof (theArgVec[anArgIter++]));
+    anOrigin.SetY (Draw::Atof (theArgVec[anArgIter++]));
+    anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter++]));
+    if (anArgIter < theArgsNb)
+    {
+      Standard_Real aX = Draw::Atof (theArgVec[anArgIter++]);
+      Standard_Real aY = Draw::Atof (theArgVec[anArgIter++]);
+      Standard_Real aZ = Draw::Atof (theArgVec[anArgIter++]);
+      aDirZ.SetCoord (aX, aY, aZ);
+
+      aX = Draw::Atof (theArgVec[anArgIter++]);
+      aY = Draw::Atof (theArgVec[anArgIter++]);
+      aZ = Draw::Atof (theArgVec[anArgIter++]);
+      aDirX.SetCoord (aX, aY, aZ);
     }
   }
-  gp_Pnt ThePoint(coord[0],coord[1],coord[2]);
-  gp_Dir TheZVector(coord[3],coord[4],coord[5]);
-  gp_Dir TheXVector(coord[6],coord[7],coord[8]);
-
-  if ( !TheZVector.IsNormal(TheXVector,PI/180)) {di<<argv[0]<<" VectorX is not normal to VectorZ"<<"\n"; return 1;}
 
-  Handle(Geom_Axis2Placement) OrigineAndAxii=new Geom_Axis2Placement(ThePoint,TheZVector,TheXVector);
-
-  // Creation du triedre
-  Handle(AIS_Trihedron) aShape= new AIS_Trihedron(OrigineAndAxii);
-  GetMapOfAIS().Bind(aShape,name);
-  TheAISContext()->Display(aShape);
+  if (!aDirZ.IsNormal (aDirX, M_PI / 180.0))
+  {
+    theDi << theArgVec[0] << " - VectorX is not normal to VectorZ\n";
+    return 1;
+  }
 
+  Handle(Geom_Axis2Placement) aPlacement = new Geom_Axis2Placement (anOrigin, aDirZ, aDirX);
+  Handle(AIS_Trihedron) aShape = new AIS_Trihedron (aPlacement);
+  VDisplayAISObject (theArgVec[1], aShape);
   return 0;
 }
 
-
-
-
 //==============================================================================
 //function : VSize
 //author   : ege
@@ -267,19 +299,16 @@ static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv
   Standard_Boolean             ThereIsCurrent;
   Standard_Real                value;
   Standard_Boolean             hascol;
-#ifdef DEB
-  Quantity_NameOfColor         col;
-#else
+
   Quantity_NameOfColor         col = Quantity_NOC_BLACK ;
-#endif
 
   // Verification des arguments
   if ( argc>3 ) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
 
   // Verification du nombre d'arguments
   if (argc==1)      {ThereIsName=Standard_False;value=100;}
-  else if (argc==2) {ThereIsName=Standard_False;value=atof(argv[1]);}
-  else              {ThereIsName=Standard_True;value=atof(argv[2]);}
+  else if (argc==2) {ThereIsName=Standard_False;value=Draw::Atof(argv[1]);}
+  else              {ThereIsName=Standard_True;value=Draw::Atof(argv[2]);}
 
   // On ferme le contexte local pour travailler dans le contexte global
   if(TheAISContext()->HasOpenedContext())
@@ -519,7 +548,7 @@ static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
   if (HasArg) {
     Standard_Real coord[6];
     for(Standard_Integer i=0;i<=5;i++){
-      coord[i]=atof(argv[2+i]);
+      coord[i]=Draw::Atof(argv[2+i]);
     }
     gp_Pnt p1(coord[0],coord[1],coord[2]), p2(coord[3],coord[4],coord[5]) ;
 
@@ -771,7 +800,7 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char
   if (HasArg) {
     Standard_Real thecoord[3];
     for(Standard_Integer i=0;i<=2;i++)
-      thecoord[i]=atof(argv[2+i]);
+      thecoord[i]=Draw::Atof(argv[2+i]);
     Handle(Geom_CartesianPoint )  myGeomPoint= new Geom_CartesianPoint (thecoord[0],thecoord[1],thecoord[2]);
     Handle(AIS_Point)  myAISPoint=new AIS_Point(myGeomPoint );
     GetMapOfAIS().Bind (myAISPoint,name);
@@ -836,7 +865,7 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char
 }
 
 //==============================================================================
-// Fonction        1st click   2de click  3de click
+// Function        1st click   2de click  3de click
 // vplane          Vertex      Vertex     Vertex
 //                 Vertex      Edge
 //                 Edge        Vertex
@@ -849,654 +878,877 @@ static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char
 
 //==============================================================================
 //function : VPlaneBuilder
-//purpose  : Build an AIS_Plane from selected entities or Named AIs components
-//Draw arg : vplane PlaneName [AxisName]  [PointName]
-//                            [PointName] [PointName] [PointName]
-//                            [PlaneName] [PointName]
+//purpose  : Build an AIS_Plane from selected entities or Named AIS components
+//Draw arg : vplane PlaneName [AxisName]  [PointName] [TypeOfSensitivity]
+//                            [PointName] [PointName] [PointName] [TypeOfSensitivity]
+//                            [PlaneName] [PointName] [TypeOfSensitivity]
 //==============================================================================
 
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopExp.hxx>
-#include <AIS_Plane.hxx>
-#include <Geom_CartesianPoint.hxx>
-#include <Geom_Plane.hxx>
-#include <BRepExtrema_ExtPC.hxx>
-#include <BRepExtrema_ExtPF.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <gp_Pln.hxx>
-#include <GC_MakePlane.hxx>
-
-static int VPlaneBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
+                                       Standard_Integer argc,
+                                       const char** argv)
 {
   // Declarations
-  Standard_Boolean HasArg;
-  TCollection_AsciiString name;
-  Standard_Integer myCurrentIndex;
+  Standard_Boolean hasArg;
+  TCollection_AsciiString aName;
+  Standard_Integer aCurrentIndex;
 
   // Verification
-  if (argc<2 || argc>5 ) {di<<" Syntaxe error"<<"\n";return 1;}
-  if (argc==5 || argc==4) HasArg=Standard_True;
-  else HasArg=Standard_False;
+  if (argc<2 || argc>6 )
+  {
+    std::cout<<" Syntax error\n";
+    return 1;
+  }
+  if (argc == 6 || argc==5 || argc==4)
+    hasArg=Standard_True;
+  else 
+    hasArg=Standard_False;
 
-  name=argv[1];
-  // Fermeture des contextes
+  aName=argv[1];
+  // Close all contexts
   TheAISContext()->CloseAllContexts();
 
-
-  // Il y a des arguments
-  if (HasArg) {
-    if (!GetMapOfAIS().IsBound2(argv[2] ) ) {di<<"vplane: error 1st name doesn't exist in the GetMapOfAIS()."<<"\n";return 1;}
-    // on recupere la shape dans la map
-    Handle(AIS_InteractiveObject) theShapeA =
+  // There are some arguments
+  if (hasArg)
+  {
+    if (!GetMapOfAIS().IsBound2(argv[2] ))
+    {
+      std::cout<<"vplane: error 1st name doesn't exist in the GetMapOfAIS()\n";
+      return 1;
+    }
+    // Get shape from map
+    Handle(AIS_InteractiveObject) aShapeA =
       Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[2] ));
 
-    // Le premier argument est un AIS_Point 1
-    if (!theShapeA.IsNull() &&
-      theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==1) {
-        // le deuxieme argument doit etre un AIS_Point aussi
-        if (argc<5 || !GetMapOfAIS().IsBound2(argv[3] ) ) {di<<"vplane: error 2de name doesn't exist in the GetMapOfAIS()."<<"\n";return 1;}
-        // on recupere la shape dans la map
-        Handle(AIS_InteractiveObject) theShapeB =
+    // The first argument is an AIS_Point
+    if (!aShapeA.IsNull() &&
+        aShapeA->Type()==AIS_KOI_Datum &&
+        aShapeA->Signature()==1)
+    {
+        // The second argument must also be an AIS_Point
+        if (argc<5 || !GetMapOfAIS().IsBound2(argv[3]))
+        {
+          std::cout<<"vplane: error 2nd name doesn't exist in the GetMapOfAIS()\n";
+          return 1;
+        }
+        // Get shape from map
+        Handle(AIS_InteractiveObject) aShapeB =
           Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[3]));
-        // si B n'est pas un AIS_Point
-        if (theShapeB.IsNull() ||
-          (!(theShapeB->Type()==AIS_KOI_Datum && theShapeB->Signature()==1)))
+        // If B is not an AIS_Point
+        if (aShapeB.IsNull() ||
+          (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
         {
-          di<<"vplane: error 2de object is expected to be an AIS_Point. "<<"\n";
+          std::cout<<"vplane: error 2nd object is expected to be an AIS_Point.\n";
           return 1;
         }
-        // le troisieme objet est un AIS_Point
-        if (!GetMapOfAIS().IsBound2(argv[4]) ) {di<<"vplane: error 3de name doesn't exist in the GetMapOfAIS()."<<"\n";return 1; }
-        // on recupere la shape dans la map
-        Handle(AIS_InteractiveObject) theShapeC =
+        // The third object is an AIS_Point
+        if (!GetMapOfAIS().IsBound2(argv[4]) ) 
+        {
+          std::cout<<"vplane: error 3d name doesn't exist in the GetMapOfAIS().\n";
+          return 1; 
+        }
+        // Get shape from map
+        Handle(AIS_InteractiveObject) aShapeC =
           Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[4]));
-        // si C n'est pas un AIS_Point
-        if (theShapeC.IsNull() ||
-          (!(theShapeC->Type()==AIS_KOI_Datum && theShapeC->Signature()==1)))
+        // If C is not an AIS_Point
+        if (aShapeC.IsNull() ||
+          (!(aShapeC->Type()==AIS_KOI_Datum && aShapeC->Signature()==1)))
         {
-          di<<"vplane: error 3de object is expected to be an AIS_Point. "<<"\n";
+          std::cout<<"vplane: error 3d object is expected to be an AIS_Point.\n";
           return 1;
         }
 
-        // Traitement des objets A,B,C
-        // Downcaste de AIS_IO en AIS_Point
-        Handle(AIS_Point) theAISPointA= *(Handle(AIS_Point)*)& theShapeA;
-        Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
-        Handle(AIS_Point) theAISPointC= *(Handle(AIS_Point)*)& theShapeC;
+        // Treatment of objects A, B, C
+        // Downcast an AIS_IO to AIS_Point
+        Handle(AIS_Point) anAISPointA = Handle(AIS_Point)::DownCast( aShapeA);
+        Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast( aShapeB);
+        Handle(AIS_Point) anAISPointC = Handle(AIS_Point)::DownCast( aShapeC);
 
-        Handle(Geom_Point ) myGeomPointA=  theAISPointA->Component();
-        Handle(Geom_CartesianPoint ) myCartPointA= *((Handle(Geom_CartesianPoint)*)&  myGeomPointA);
-        //      Handle(Geom_CartesianPoint ) myCartPointA= *(Handle(Geom_CartesianPoint)*)& (theAISPointA->Component() ) ;
+        Handle(Geom_CartesianPoint ) aCartPointA = 
+          Handle(Geom_CartesianPoint)::DownCast( anAISPointA->Component());
 
-        Handle(Geom_Point ) myGeomPointB =  theAISPointB->Component();
-        Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)&  theAISPointB);
-        //      Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint)*)& (theAISPointB->Component() ) ;
+        Handle(Geom_CartesianPoint ) aCartPointB = 
+          Handle(Geom_CartesianPoint)::DownCast( anAISPointB->Component());
 
-        Handle(Geom_Point ) myGeomPointBC=  theAISPointC->Component();
-        Handle(Geom_CartesianPoint ) myCartPointC= *((Handle(Geom_CartesianPoint)*)&  theAISPointC);
-        //      Handle(Geom_CartesianPoint ) myCartPointC= *(Handle(Geom_CartesianPoint)*)& (theAISPointC->Component() ) ;
+        Handle(Geom_CartesianPoint ) aCartPointC = 
+          Handle(Geom_CartesianPoint)::DownCast( anAISPointC->Component());
 
-        // Verification que les 3 points sont bien differents.
-        if (myCartPointB->X()==myCartPointA->X() && myCartPointB->Y()==myCartPointA->Y() && myCartPointB->Z()==myCartPointA->Z() ) {
+        // Verification that the three points are different
+        if(Abs(aCartPointB->X()-aCartPointA->X())<=Precision::Confusion() &&
+           Abs(aCartPointB->Y()-aCartPointA->Y())<=Precision::Confusion() &&
+           Abs(aCartPointB->Z()-aCartPointA->Z())<=Precision::Confusion())
+        {
           // B=A
-          di<<"vplane error: same points"<<"\n";return 1;
+          std::cout<<"vplane error: same points"<<"\n";return 1;
         }
-        if (myCartPointC->X()==myCartPointA->X() && myCartPointC->Y()==myCartPointA->Y() && myCartPointC->Z()==myCartPointA->Z() ) {
+        if(Abs(aCartPointC->X()-aCartPointA->X())<=Precision::Confusion() &&
+           Abs(aCartPointC->Y()-aCartPointA->Y())<=Precision::Confusion() &&
+           Abs(aCartPointC->Z()-aCartPointA->Z())<=Precision::Confusion())
+        {
           // C=A
-          di<<"vplane error: same points"<<"\n";return 1;
+          std::cout<<"vplane error: same points"<<"\n";return 1;
         }
-        if (myCartPointC->X()==myCartPointB->X() && myCartPointC->Y()==myCartPointB->Y() && myCartPointC->Z()==myCartPointB->Z() ) {
+        if(Abs(aCartPointC->X()-aCartPointB->X())<=Precision::Confusion() &&
+           Abs(aCartPointC->Y()-aCartPointB->Y())<=Precision::Confusion() &&
+           Abs(aCartPointC->Z()-aCartPointB->Z())<=Precision::Confusion())
+        {
           // C=B
-          di<<"vplane error: same points"<<"\n";return 1;
+          std::cout<<"vplane error: same points"<<"\n";return 1;
         }
 
-        gp_Pnt A= myCartPointA->Pnt();
-        gp_Pnt B= myCartPointB->Pnt();
-        gp_Pnt C= myCartPointC->Pnt();
+        gp_Pnt A = aCartPointA->Pnt();
+        gp_Pnt B = aCartPointB->Pnt();
+        gp_Pnt C = aCartPointC->Pnt();
 
-        // Construction de l'AIS_Plane
+        // Construction of AIS_Plane
         GC_MakePlane MkPlane (A,B,C);
-        Handle(Geom_Plane) myGeomPlane = MkPlane.Value();
-        Handle(AIS_Plane)  myAISPlane = new AIS_Plane(myGeomPlane );
-        GetMapOfAIS().Bind (myAISPlane,name );
-        TheAISContext()->Display(myAISPlane);
+        Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
+        Handle(AIS_Plane)  anAISPlane = new AIS_Plane(aGeomPlane );
+        GetMapOfAIS().Bind (anAISPlane,aName );
+        if (argc == 6)
+        {
+          Standard_Integer aType = Draw::Atoi (argv[5]);
+          if (aType != 0 && aType != 1)
+          {
+            std::cout << "vplane error: wrong type of sensitivity!\n"
+                      << "Should be one of the following values:\n"
+                      << "0 - Interior\n"
+                      << "1 - Boundary"
+                      << std::endl;
+            return 1;
+          }
+          else
+          {
+            anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
+          }
+        }
+        TheAISContext()->Display(anAISPlane);
       }
 
-      // si le premier argument est un AIS_Axis 2
-      // creation d'un plan orthogonal a l'axe passant par un point
-    else if (theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==2 ) {
-      // le deuxieme argument doit etre un AIS_Point
+      // The first argument is an AIS_Axis
+      // Creation of a plane orthogonal to the axis through a point
+    else if (aShapeA->Type()==AIS_KOI_Datum && aShapeA->Signature()==2 ) {
+      // The second argument should be an AIS_Point
       if (argc!=4 || !GetMapOfAIS().IsBound2(argv[3] ) )
       {
-        di<<"vplane: error 2de name doesn't exist in the GetMapOfAIS()."<<"\n";
+        std::cout<<"vplane: error 2d name doesn't exist in the GetMapOfAIS()\n";
         return 1;
       }
-      // on recupere la shape dans la map
-      Handle(AIS_InteractiveObject) theShapeB =
+      // Get shape from map
+      Handle(AIS_InteractiveObject) aShapeB =
         Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[3]));
-      // si B n'est pas un AIS_Point
-      if (theShapeB.IsNull() ||
-        (!(theShapeB->Type()==AIS_KOI_Datum && theShapeB->Signature()==1)))
+      // If B is not an AIS_Point
+      if (aShapeB.IsNull() ||
+        (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
       {
-        di<<"vplane: error 2de object is expected to be an AIS_Point. "<<"\n";
+        std::cout<<"vplane: error 2d object is expected to be an AIS_Point\n";
         return 1;
       }
 
-      // Traitement des objets A et B
-      Handle(AIS_Axis) theAISAxisA= *(Handle(AIS_Axis)*)& theShapeA;
-      Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
-
-      Handle(Geom_Line ) myGeomLineA = theAISAxisA ->Component();
-      Handle(Geom_Point) myGeomPointB= theAISPointB->Component()  ;
+      // Treatment of objects A and B
+      Handle(AIS_Axis) anAISAxisA = Handle(AIS_Axis)::DownCast(aShapeA);
+      Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast(aShapeB);
 
-      gp_Ax1 myAxis= myGeomLineA->Position();
-      Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint )*)& myGeomPointB;
+      Handle(Geom_Line ) aGeomLineA = anAISAxisA ->Component();
+      Handle(Geom_Point) aGeomPointB = anAISPointB->Component()  ;
 
-      // Pas de moyens de verifier que le point B n'est pas sur l'axe
+      gp_Ax1 anAxis = aGeomLineA->Position();
+      Handle(Geom_CartesianPoint) aCartPointB = 
+        Handle(Geom_CartesianPoint)::DownCast(aGeomPointB);
 
-      gp_Dir D=myAxis.Direction();
-      gp_Pnt B= myCartPointB->Pnt();
+      gp_Dir D =anAxis.Direction();
+      gp_Pnt B = aCartPointB->Pnt();
 
-      // Construction de l'AIS_Plane
-      Handle(Geom_Plane) myGeomPlane= new Geom_Plane(B,D);
-      Handle(AIS_Plane)  myAISPlane = new AIS_Plane(myGeomPlane,B );
-      GetMapOfAIS().Bind (myAISPlane,name );
-      TheAISContext()->Display(myAISPlane);
+      // Construction of AIS_Plane
+      Handle(Geom_Plane) aGeomPlane = new Geom_Plane(B,D);
+      Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane,B );
+      GetMapOfAIS().Bind (anAISPlane,aName );
+      if (argc == 5)
+      {
+        Standard_Integer aType = Draw::Atoi (argv[4]);
+        if (aType != 0 && aType != 1)
+        {
+          std::cout << "vplane error: wrong type of sensitivity!\n"
+                    << "Should be one of the following values:\n"
+                    << "0 - Interior\n"
+                    << "1 - Boundary"
+                    << std::endl;
+          return 1;
+        }
+        else
+        {
+          anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
+        }
+      }
+      TheAISContext()->Display(anAISPlane);
 
     }
-    // Si le premier argument est un AIS_Plane 7
-    // Creation d'un Plan parallele a ce plan passant par le point
-    else if (theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==7 ) {
-      // le deuxieme argument doit etre un AISPoint
-      if (argc!=4 || !GetMapOfAIS().IsBound2(argv[3] ) ) {
-        di<<"vplane: error 2de name doesn't exist in the GetMapOfAIS()."<<"\n";
+    // The first argumnet is an AIS_Plane
+    // Creation of a plane parallel to the plane passing through the point
+    else if (aShapeA->Type()==AIS_KOI_Datum && aShapeA->Signature()==7)
+    {
+      // The second argument should be an AIS_Point
+      if (argc!=4 || !GetMapOfAIS().IsBound2(argv[3]))
+      {
+        std::cout<<"vplane: error 2d name doesn't exist in the GetMapOfAIS()\n";
         return 1;
       }
-      // on recupere la shape dans la map
-      Handle(AIS_InteractiveObject) theShapeB =
+      // Get shape from map
+      Handle(AIS_InteractiveObject) aShapeB =
         Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[3]));
-      // si B n'est pas un AIS_Point
-      if (theShapeB.IsNull() ||
-        (!(theShapeB->Type()==AIS_KOI_Datum && theShapeB->Signature()==1)))
+      // B should be an AIS_Point
+      if (aShapeB.IsNull() ||
+         (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
       {
-        di<<"vplane: error 2de object is expected to be an AIS_Point. "<<"\n";
+        std::cout<<"vplane: error 2d object is expected to be an AIS_Point\n";
         return 1;
       }
 
-      // Traitement des objets A et B
-      Handle(AIS_Plane) theAISPlaneA= *(Handle(AIS_Plane)*)& theShapeA;
-      Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
+      // Treatment of objects A and B
+      Handle(AIS_Plane) anAISPlaneA = Handle(AIS_Plane)::DownCast(aShapeA);
+      Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast(aShapeB);
 
-      Handle (Geom_Plane) theNewGeomPlane= theAISPlaneA->Component();
-      Handle(Geom_Point) myGeomPointB= theAISPointB->Component()  ;
+      Handle(Geom_Plane) aNewGeomPlane= anAISPlaneA->Component();
+      Handle(Geom_Point) aGeomPointB = anAISPointB->Component();
 
-      Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint )*)& myGeomPointB;
-      gp_Pnt B= myCartPointB->Pnt();
-
-      // Construction de l'AIS_Plane
-      Handle(AIS_Plane)  myAISPlane = new AIS_Plane(theNewGeomPlane,B );
-      GetMapOfAIS().Bind (myAISPlane,name );
-      TheAISContext()->Display(myAISPlane);
+      Handle(Geom_CartesianPoint) aCartPointB = 
+        Handle(Geom_CartesianPoint)::DownCast(aGeomPointB);
+      gp_Pnt B= aCartPointB->Pnt();
 
+      // Construction of an AIS_Plane
+      Handle(AIS_Plane) anAISPlane = new AIS_Plane(aNewGeomPlane, B);
+      GetMapOfAIS().Bind (anAISPlane, aName);
+      if (argc == 5)
+      {
+        Standard_Integer aType = Draw::Atoi (argv[4]);
+        if (aType != 0 && aType != 1)
+        {
+          std::cout << "vplane error: wrong type of sensitivity!\n"
+                    << "Should be one of the following values:\n"
+                    << "0 - Interior\n"
+                    << "1 - Boundary"
+                    << std::endl;
+          return 1;
+        }
+        else
+        {
+          anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
+        }
+      }
+      TheAISContext()->Display(anAISPlane);
+    }
+    // Error
+    else
+    {
+      std::cout<<"vplane: error 1st object is not an AIS\n";
+      return 1;
     }
-    // Sinon erreur
-    else {di<<"vplane: error 1st object is not an AIS. "<<"\n";return 1;}
-
   }
-
-  // Il n'y a pas d'arguments
-  else {
-
-    // Fonction vplane
-    // Teste le constructeur AIS_Plane::AIS_Plane(Geom_Plane, Standard_Boolean )
-    if (!strcasecmp(argv[0] ,"vplane" ) ) {
+  // There are no arguments
+  else 
+  {
+    // Function vplane
+    // Test the constructor AIS_Plane::AIS_Plane(Geom_Plane, Standard_Boolean )
+    if (!strcasecmp(argv[0], "vplane"))
+    {
       TheAISContext()->OpenLocalContext();
-      myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
+      aCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
 
-      // Active les modes Vertex, Edge et Face
-      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
-      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
-      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
-      di<<"Select a vertex, a face or an edge. "<<"\n";
+      // Active modes Vertex, Edge and Face
+      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1));
+      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2));
+      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4));
+      std::cout<<"Select a vertex, a face or an edge\n";
 
-      // Boucle d'attente waitpick.
+      // Wait for picking
       Standard_Integer argcc = 5;
       const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
       const char **argvv = (const char **) buff;
       while (ViewerMainLoop( argcc, argvv) ) { }
-      // fin de la boucle
+      // end of the loop
 
-      TopoDS_Shape ShapeA;
-      for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-        ShapeA = TheAISContext()->SelectedShape();
+      TopoDS_Shape aShapeA;
+      for (TheAISContext()->InitSelected();
+           TheAISContext()->MoreSelected();
+           TheAISContext()->NextSelected())
+      {
+        aShapeA = TheAISContext()->SelectedShape();
       }
 
-      // ShapeA est un Vertex
-      if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
-        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
-        di<<" Select an edge or a different vertex."<<"\n";
+      // aShapeA is a Vertex
+      if (aShapeA.ShapeType()==TopAbs_VERTEX )
+      {
+        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4));
+        std::cout<<" Select an edge or a different vertex\n";
 
-        // Boucle d'attente waitpick.
+        // Wait for picking
         Standard_Integer argccc = 5;
         const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
         const char **argvvv = (const char **) bufff;
         while (ViewerMainLoop( argccc, argvvv) ) { }
-        // fin de la boucle
+        // end of the loop
 
-        TopoDS_Shape ShapeB;
-        for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-          ShapeB = TheAISContext()->SelectedShape();
+        TopoDS_Shape aShapeB;
+        for (TheAISContext()->InitSelected();
+          TheAISContext()->MoreSelected();
+          TheAISContext()->NextSelected())
+        {
+          aShapeB = TheAISContext()->SelectedShape();
         }
-        // ShapeB est un Vertex
-        if (ShapeB.ShapeType()==TopAbs_VERTEX ) {
-          // Si A et B sont le meme point
-          if (ShapeB.IsSame(ShapeA) ) {di<<" vplane: error, same points selected"<<"\n";return 1; }
-          TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) );
-          di<<" Select a different vertex."<<"\n";
+        // aShapeB is a Vertex
+        if (aShapeB.ShapeType()==TopAbs_VERTEX)
+        {
+          // A and B are the same
+          if (aShapeB.IsSame(aShapeA))
+          {
+            std::cout<<" vplane: error, same points selected\n";
+            return 1;
+          }
+          TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2));
+          std::cout<<" Select a different vertex\n";
 
-          // Boucle d'attente waitpick.
+          // Wait for picking
           Standard_Integer argcccc = 5;
           const char *buffff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
           const char **argvvvv = (const char **) buffff;
           while (ViewerMainLoop( argcccc, argvvvv) ) { }
-          // fin de la boucle
+          // end of the loop
 
-          TopoDS_Shape ShapeC;
-          for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-            ShapeC = TheAISContext()->SelectedShape();
+          TopoDS_Shape aShapeC;
+          for (TheAISContext()->InitSelected();
+               TheAISContext()->MoreSelected();
+               TheAISContext()->NextSelected())
+          {
+            aShapeC = TheAISContext()->SelectedShape();
+          }
+          // aShapeC is the same as A or B
+          if (aShapeC.IsSame(aShapeA)||aShapeC.IsSame(aShapeB))
+          {
+            std::cout<<" vplane: error, same points selected\n";
+            return 1;
           }
-          // ShapeC est aussi un vertex...
-          if (ShapeC.IsSame(ShapeA)||ShapeC.IsSame(ShapeB) ) {di<<" vplane: error, same points selected"<<"\n";return 1; }
-
-          // Fermeture du contexte local
-          TheAISContext()->CloseLocalContext(myCurrentIndex);
-
-          // Construction du plane
-          gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA ) );
-          gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB ) );
-          gp_Pnt C=BRep_Tool::Pnt(TopoDS::Vertex(ShapeC ) );
-          GC_MakePlane MkPlane(A,B,C);
-          Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
-          Handle(AIS_Plane) myAISPlane=new AIS_Plane (theGeomPlane );
-          GetMapOfAIS().Bind (myAISPlane ,name );
-          TheAISContext()->Display(myAISPlane);
 
+          // Close the local context
+          TheAISContext()->CloseLocalContext(aCurrentIndex);
+
+          // Construction of plane
+          gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(aShapeA));
+          gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(aShapeB));
+          gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(aShapeC));
+          GC_MakePlane MkPlane(A, B, C);
+          Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
+          Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
+          GetMapOfAIS().Bind (anAISPlane, aName);
+          TheAISContext()->Display(anAISPlane);
         }
-        // ShapeB est un edge
-        else  {
-          // il s'agit de verifier que le  vertex ShapeA n'est pas sur l'edge ShapeB
-          TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
-          TopoDS_Vertex VertA=TopoDS::Vertex(ShapeA);
-
-          BRepExtrema_ExtPC OrthoProj (VertA, EdgeB );
-          if (OrthoProj.SquareDistance(1)<1e-6 ) {
-            // Le vertex est sur l'edge
-            di<<" vplane: error point is on the edge."<<"\n";return 1;
-          }
-          else {
-            // le vertex n'appartient pes a l'edge on peut construire le plane
-            // Fermeture du contexte local
-            TheAISContext()->CloseLocalContext(myCurrentIndex);
-            // Construction du plane
-            gp_Pnt A=BRep_Tool::Pnt(VertA );
-            TopoDS_Vertex VBa,VBb;
-            TopExp::Vertices(EdgeB ,VBa ,VBb );
-            gp_Pnt Ba=BRep_Tool::Pnt(VBa);
-            gp_Pnt Bb=BRep_Tool::Pnt(VBb);
-            GC_MakePlane MkPlane (A,Ba,Bb);
-            Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
-            Handle(AIS_Plane) myAISPlane=new AIS_Plane (theGeomPlane );
-            GetMapOfAIS().Bind (myAISPlane ,name );
-            TheAISContext()->Display(myAISPlane);
+        // ShapeB is an edge
+        else
+        {
+          // Verify that the vertex is not on the edge ShapeB
+          TopoDS_Edge anEdgeB = TopoDS::Edge(aShapeB);
+          TopoDS_Vertex aVertA = TopoDS::Vertex(aShapeA);
 
+          BRepExtrema_ExtPC OrthoProj(aVertA, anEdgeB);
+          if (OrthoProj.SquareDistance(1)<Precision::Approximation())
+          {
+            // The vertex is on the edge
+            std::cout<<" vplane: error point is on the edge\n";
+            return 1;
+          }
+          else
+          {
+            // Close the local context
+            TheAISContext()->CloseLocalContext(aCurrentIndex);
+            // Construction of plane
+            gp_Pnt A = BRep_Tool::Pnt(aVertA);
+            TopoDS_Vertex aVBa, aVBb;
+            TopExp::Vertices(anEdgeB ,aVBa ,aVBb);
+            gp_Pnt aBa = BRep_Tool::Pnt(aVBa);
+            gp_Pnt aBb = BRep_Tool::Pnt(aVBb);
+            GC_MakePlane MkPlane (A, aBa, aBb);
+            Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
+            Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
+            GetMapOfAIS().Bind (anAISPlane, aName);
+            TheAISContext()->Display(anAISPlane);
           }
-
         }
-
       }
-      // ShapeA est un edge
-      else if (ShapeA.ShapeType()==TopAbs_EDGE ) {
-
-        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
-        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) );
-        di<<" Select a vertex that don't belong to the edge."<<"\n";
+      // aShapeA is an edge
+      else if (aShapeA.ShapeType()==TopAbs_EDGE)
+      {
+        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4));
+        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2));
+        std::cout<<" Select a vertex that don't belong to the edge\n";
 
-        // Boucle d'attente waitpick.
+        // Wait for picking
         Standard_Integer argccc = 5;
         const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
         const char **argvvv = (const char **) bufff;
         while (ViewerMainLoop( argccc, argvvv) ) { }
-        // fin de la boucle
+        // end of the loop
 
-        TopoDS_Shape ShapeB;
-        for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-          ShapeB = TheAISContext()->SelectedShape();
+        TopoDS_Shape aShapeB;
+        for (TheAISContext()->InitSelected();
+             TheAISContext()->MoreSelected();
+             TheAISContext()->NextSelected())
+        {
+          aShapeB = TheAISContext()->SelectedShape();
         }
-        // ShapeB est forcement un Vertex
-        // On verifie que le vertex ShapeB n'est pas sur l'edge ShapeA
-        TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
-        TopoDS_Vertex VertB=TopoDS::Vertex(ShapeB);
-
-        BRepExtrema_ExtPC OrthoProj (VertB,EdgeA );
-        if (OrthoProj.SquareDistance(1)<1e-6) {
-          // Le vertex est sur l'edge
-          di<<" vplane: error point is on the edge."<<"\n";return 1;
+        // aShapeB should be a Vertex
+        // Check that the vertex aShapeB is not on the edge
+        TopoDS_Edge anEdgeA = TopoDS::Edge(aShapeA);
+        TopoDS_Vertex aVertB = TopoDS::Vertex(aShapeB);
+
+        BRepExtrema_ExtPC OrthoProj (aVertB, anEdgeA);
+        if (OrthoProj.SquareDistance(1)<Precision::Approximation())
+        {
+          // The vertex is on the edge
+          std::cout<<" vplane: error point is on the edge\n";
+          return 1;
         }
-        else {
-          // le vertex n'appartient pas a l'edge on peut construire le plane
-          // Fermeture du contexte local
-          TheAISContext()->CloseLocalContext(myCurrentIndex);
-          // Construction du plane
-          gp_Pnt B=BRep_Tool::Pnt(VertB );
-          TopoDS_Vertex VAa,VAb;
-          TopExp::Vertices(EdgeA ,VAa ,VAb );
-          gp_Pnt Aa=BRep_Tool::Pnt(VAa);
-          gp_Pnt Ab=BRep_Tool::Pnt(VAb);
+        else
+        {
+          // Close the local context
+          TheAISContext()->CloseLocalContext(aCurrentIndex);
+          // Construction of plane
+          gp_Pnt B = BRep_Tool::Pnt(aVertB);
+          TopoDS_Vertex aVAa, aVAb;
+          TopExp::Vertices(anEdgeA, aVAa, aVAb);
+          gp_Pnt Aa = BRep_Tool::Pnt(aVAa);
+          gp_Pnt Ab = BRep_Tool::Pnt(aVAb);
           GC_MakePlane MkPlane (B,Aa,Ab);
-          Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
-          Handle(AIS_Plane) myAISPlane=new AIS_Plane (theGeomPlane );
-          GetMapOfAIS().Bind (myAISPlane ,name );
-          TheAISContext()->Display(myAISPlane);
-
+          Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
+          Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
+          GetMapOfAIS().Bind (anAISPlane ,aName);
+          TheAISContext()->Display(anAISPlane);
         }
-
-
       }
-      // ShapeA est une Face
-      else {
-        // Fermeture du contexte local: Plus rien a selectionner
-        TheAISContext()->CloseLocalContext(myCurrentIndex);
-        // Construction du plane
-        TopoDS_Face myFace=TopoDS::Face(ShapeA);
-        BRepAdaptor_Surface mySurface (myFace, Standard_False );
-        if (mySurface.GetType()==GeomAbs_Plane ) {
-          gp_Pln myPlane=mySurface.Plane();
-          Handle(Geom_Plane) theGeomPlane=new Geom_Plane (myPlane );
-          Handle(AIS_Plane) myAISPlane=new AIS_Plane (theGeomPlane );
-          GetMapOfAIS().Bind (myAISPlane ,name );
-          TheAISContext()->Display(myAISPlane);
-
+      // aShapeA is a Face
+      else
+      {
+        // Close the local context: nothing to select
+        TheAISContext()->CloseLocalContext(aCurrentIndex);
+        // Construction of plane
+        TopoDS_Face aFace = TopoDS::Face(aShapeA);
+        BRepAdaptor_Surface aSurface (aFace, Standard_False);
+        if (aSurface.GetType()==GeomAbs_Plane)
+        {
+          gp_Pln aPlane = aSurface.Plane();
+          Handle(Geom_Plane) aGeomPlane = new Geom_Plane(aPlane);
+          Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane);
+          GetMapOfAIS().Bind (anAISPlane, aName);
+          TheAISContext()->Display(anAISPlane);
         }
-        else {
-          di<<" vplane: error"<<"\n";return 1;
+        else
+        {
+          std::cout<<" vplane: error\n";
+          return 1;
         }
-
       }
-
     }
 
-    // Fonction vPlanePara
+    // Function vPlanePara
     // ===================
-    // teste le constructeur AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt )
-    else if (!strcasecmp(argv[0] ,"vplanepara" )) {
-
+    // test the constructor AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt)
+    else if (!strcasecmp(argv[0], "vplanepara"))
+    {
       TheAISContext()->OpenLocalContext();
-      myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
+      aCurrentIndex = TheAISContext()->IndexOfCurrentLocal();
 
-      // Active les modes Vertex et Face
-      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
-      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
-      di<<" Select a vertex or a face."<<"\n";
+      // Activate modes Vertex and Face
+      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1));
+      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4));
+      std::cout<<" Select a vertex or a face\n";
 
-      // Boucle d'attente waitpick.
+      // Wait for picking
       Standard_Integer argcc = 5;
       const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
       const char **argvv = (const char **) buff;
       while (ViewerMainLoop( argcc, argvv) ) { }
-      // fin de la boucle
+      // end of the loop
 
-      TopoDS_Shape ShapeA;
-      for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-        ShapeA = TheAISContext()->SelectedShape();
+      TopoDS_Shape aShapeA;
+      for (TheAISContext()->InitSelected();
+           TheAISContext()->MoreSelected();
+           TheAISContext()->NextSelected())
+      {
+        aShapeA = TheAISContext()->SelectedShape();
       }
 
-      if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
-        // ShapeA est un vertex
-        // On desactive le mode Vertex
-        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(1) );
-        di<<" Select a face."<<"\n";
+      if (aShapeA.ShapeType()==TopAbs_VERTEX )
+      {
+        // aShapeA is a vertex
+        // Deactivate the mode Vertex
+        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(1));
+        std::cout<<" Select a face\n";
 
-        // Boucle d'attente waitpick.
+        // Wait for picking
         Standard_Integer argccc = 5;
         const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
         const char **argvvv = (const char **) bufff;
         while (ViewerMainLoop( argccc, argvvv) ) { }
-        // fin de la boucle
+        // end of the loop
 
-        TopoDS_Shape ShapeB;
-        for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-          // Le vertex ShapeA peut etre dans la Face ShapeB
-          ShapeB = TheAISContext()->SelectedShape();
+        TopoDS_Shape aShapeB;
+        for (TheAISContext()->InitSelected();
+             TheAISContext()->MoreSelected();
+             TheAISContext()->NextSelected())
+        {
+          // A vertex ShapeA can be on Face ShapeB
+          aShapeB = TheAISContext()->SelectedShape();
         }
 
-        // Fermeture du context local
-        TheAISContext()->CloseLocalContext(myCurrentIndex);
-
-        // Construction du plane
-        gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA ) );
-
-        TopoDS_Face myFace=TopoDS::Face(ShapeB);
-        BRepAdaptor_Surface mySurface (myFace, Standard_False );
-        if (mySurface.GetType()==GeomAbs_Plane ) {
-          gp_Pln myPlane=mySurface.Plane();
-          // construit un plan parallele a theGeomPlane passant par A
-          myPlane.SetLocation(A);
-          Handle(Geom_Plane) theGeomPlane=new Geom_Plane (myPlane );
-          Handle(AIS_Plane) myAISPlane=new AIS_Plane (theGeomPlane ,A );
-          GetMapOfAIS().Bind (myAISPlane ,name );
-          TheAISContext()->Display(myAISPlane);
+        // Close the local context
+        TheAISContext()->CloseLocalContext(aCurrentIndex);
+
+        // Construction of plane
+        gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(aShapeA));
 
+        TopoDS_Face aFace = TopoDS::Face(aShapeB);
+        BRepAdaptor_Surface aSurface (aFace, Standard_False);
+        if (aSurface.GetType()==GeomAbs_Plane )
+        {
+          gp_Pln aPlane = aSurface.Plane();
+          // Construct a plane parallel to aGeomPlane through A
+          aPlane.SetLocation(A);
+          Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
+          Handle(AIS_Plane) aAISPlane = new AIS_Plane (aGeomPlane, A);
+          GetMapOfAIS().Bind (aAISPlane ,aName);
+          TheAISContext()->Display(aAISPlane);
         }
-        else {
-          di<<" vplane: error"<<"\n";return 1;
+        else
+        {
+          std::cout<<" vplanepara: error\n";
+          return 1;
         }
-
       }
-      else{
-        // ShapeA est une Face
-        // On desactive le mode Face
-        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
-        di<<" Select a vertex."<<"\n";
+      else
+      {
+        // ShapeA is a Face
+        // Deactive the mode Face
+        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4));
+        std::cout<<" Select a vertex\n";
 
-        // Boucle d'attente waitpick.
+        // Wait for picking
         Standard_Integer argccc = 5;
         const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
         const char **argvvv = (const char **) bufff;
         while (ViewerMainLoop( argccc, argvvv) ) { }
-        // fin de la boucle
+        // end of the loop
 
-        TopoDS_Shape ShapeB;
-        for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-          // Le vertex ShapeB peut etre dans la Face ShapeA
-          ShapeB = TheAISContext()->SelectedShape();
+        TopoDS_Shape aShapeB;
+        for (TheAISContext()->InitSelected();
+             TheAISContext()->MoreSelected();
+             TheAISContext()->NextSelected())
+        {
+          // A vertex ShapeB can be on Face ShapeA
+          aShapeB = TheAISContext()->SelectedShape();
         }
-        // Fermeture du context local
-        TheAISContext()->CloseLocalContext(myCurrentIndex);
-
-        // Construction du plane
-        gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB ) );
-
-        TopoDS_Face myFace=TopoDS::Face(ShapeA);
-        BRepAdaptor_Surface mySurface (myFace, Standard_False );
-        if (mySurface.GetType()==GeomAbs_Plane ) {
-          gp_Pln myPlane=mySurface.Plane();
-          myPlane.SetLocation(B);
-          Handle(Geom_Plane) theGeomPlane=new Geom_Plane (myPlane );
-          // construit un plan parallele a theGeomPlane passant par B
-          Handle(AIS_Plane) myAISPlane=new AIS_Plane (theGeomPlane ,B );
-          GetMapOfAIS().Bind (myAISPlane ,name );
-          TheAISContext()->Display(myAISPlane);
+        // Close the local context
+        TheAISContext()->CloseLocalContext(aCurrentIndex);
 
+        // Construction of plane
+        gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(aShapeB));
+
+        TopoDS_Face aFace=TopoDS::Face(aShapeA);
+        BRepAdaptor_Surface aSurface (aFace, Standard_False);
+        if (aSurface.GetType()==GeomAbs_Plane )
+        {
+          gp_Pln aPlane = aSurface.Plane();
+          aPlane.SetLocation(B);
+          Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
+          // Construct a plane parallel to aGeomPlane through B
+          Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, B);
+          GetMapOfAIS().Bind (anAISPlane, aName);
+          TheAISContext()->Display(anAISPlane);
         }
-        else {
-          di<<" vplane: error"<<"\n";return 1;
+        else
+        {
+          std::cout<<" vplanepara: error"<<"\n";return 1;
         }
-
       }
-
     }
 
-    // Fonction vplaneortho
+    // Function vplaneortho
     // ====================
-    // teste le constructeur AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt,gp_Pnt,gp_Pnt)
-    else {
-
+    // test the constructor AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt,gp_Pnt,gp_Pnt)
+    else
+    {
       TheAISContext()->OpenLocalContext();
-      myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
+      aCurrentIndex = TheAISContext()->IndexOfCurrentLocal();
 
-      // Active les modes Edge et Face
-      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
-      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
-      di<<" Select a face and an edge coplanar."<<"\n";
+      // Activate the modes Edge and Face
+      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2));
+      TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4));
+      std::cout<<" Select a face and an edge coplanar\n";
 
-      // Boucle d'attente waitpick.
+      // Wait for picking
       Standard_Integer argcc = 5;
       const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
       const char **argvv = (const char **) buff;
       while (ViewerMainLoop( argcc, argvv) ) { }
-      // fin de la boucle
+      // end of the loop
 
-      TopoDS_Shape ShapeA;
-      for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-        ShapeA = TheAISContext()->SelectedShape();
+      TopoDS_Shape aShapeA;
+      for (TheAISContext()->InitSelected();
+           TheAISContext()->MoreSelected();
+           TheAISContext()->NextSelected())
+      {
+        aShapeA = TheAISContext()->SelectedShape();
       }
 
-      if (ShapeA.ShapeType()==TopAbs_EDGE ) {
-        // ShapeA est un edge, on desactive le mode edge...
-        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) );
-        di<<" Select a face."<<"\n";
+      if (aShapeA.ShapeType()==TopAbs_EDGE )
+      {
+        // ShapeA is an edge, deactivate the mode Edge...
+        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2));
+        std::cout<<" Select a face\n";
 
-        // Boucle d'attente waitpick.
+        // Wait for picking
         Standard_Integer argccc = 5;
         const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
         const char **argvvv = (const char **) bufff;
         while (ViewerMainLoop( argccc, argvvv) ) { }
-        // fin de la boucle
+        // end of the loop
 
-        TopoDS_Shape ShapeB;
-        for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-          // L'edge ShapeA peut etre dans la Face ShapeB
-          ShapeB = TheAISContext()->SelectedShape();
+        TopoDS_Shape aShapeB;
+        for (TheAISContext()->InitSelected();
+             TheAISContext()->MoreSelected();
+             TheAISContext()->NextSelected())
+        {
+          // Edge ShapeA can be on Face ShapeB
+          aShapeB = TheAISContext()->SelectedShape();
         }
 
-        // Fermeture du context local
-        TheAISContext()->CloseLocalContext(myCurrentIndex);
+        // Close the local context
+        TheAISContext()->CloseLocalContext(aCurrentIndex);
 
-        // Construction du plane
-        TopoDS_Edge  EdgeA=TopoDS::Edge(ShapeA);
-        TopoDS_Vertex VAa,VAb;
-        // vi
-        TopExp::Vertices(EdgeA ,VAa ,VAb );
-        gp_Pnt Aa=BRep_Tool::Pnt(VAa);
-        gp_Pnt Ab=BRep_Tool::Pnt(VAb);
-        gp_Vec ab  (Aa,Ab);
+        // Construction of plane
+        TopoDS_Edge anEdgeA = TopoDS::Edge(aShapeA);
+        TopoDS_Vertex aVAa, aVAb;
+        TopExp::Vertices(anEdgeA, aVAa, aVAb);
+        gp_Pnt Aa = BRep_Tool::Pnt(aVAa);
+        gp_Pnt Ab = BRep_Tool::Pnt(aVAb);
+        gp_Vec ab (Aa,Ab);
 
         gp_Dir Dab (ab);
-        // Creation de mon axe de rotation
-        gp_Ax1 myRotAxis (Aa,Dab);
-
-        TopoDS_Face myFace=TopoDS::Face(ShapeB);
-        // Il faut imperativement que l'edge soit parallele a la face
-        // vi
-        BRepExtrema_ExtPF myHauteurA (VAa , myFace );
-        BRepExtrema_ExtPF myHauteurB (VAb , myFace );
-        // on compare les deux hauteurs a la tolerance pres
-        if ( fabs(sqrt(myHauteurA.SquareDistance(1)) - sqrt (myHauteurB.SquareDistance(1)) )>0.1 ) {
-          // l'edge n'est pas parallele a la face
-          di<<" vplaneOrtho error: l'edge n'est pas parallele a la face."<<"\n";return 1;
+        // Creation of rotation axis
+        gp_Ax1 aRotAxis (Aa,Dab);
+
+        TopoDS_Face aFace = TopoDS::Face(aShapeB);
+        // The edge must be parallel to the face
+        BRepExtrema_ExtPF aHeightA (aVAa, aFace);
+        BRepExtrema_ExtPF aHeightB (aVAb, aFace);
+        // Compare to heights
+        if (fabs(sqrt(aHeightA.SquareDistance(1)) - sqrt(aHeightB.SquareDistance(1)))
+            >Precision::Confusion())
+        {
+          // the edge is not parallel to the face
+          std::cout<<" vplaneortho error: the edge is not parallel to the face\n";
+          return 1;
         }
-        // l'edge est OK
-        BRepAdaptor_Surface mySurface (myFace, Standard_False );
-        if (mySurface.GetType()==GeomAbs_Plane ) {
-          gp_Pln myPlane=mySurface.Plane();
-          // On effectue une rotation d'1/2 tour autour de l'axe de rotation
-          myPlane.Rotate(myRotAxis , PI/2 );
-
-          Handle(Geom_Plane) theGeomPlane=new Geom_Plane (myPlane );
-          // construit un plan parallele a theGeomPlane contenant l'edgeA (De centre le milieu de l'edgeA)
-          gp_Pnt theMiddle ((Aa.X()+Ab.X() )/2 ,(Aa.Y()+Ab.Y() )/2 ,(Aa.Z()+Ab.Z() )/2 );
-          Handle(AIS_Plane) myAISPlane=new AIS_Plane (theGeomPlane ,theMiddle );
-          GetMapOfAIS().Bind (myAISPlane ,name );
-          TheAISContext()->Display(myAISPlane);
-
+        // the edge is OK
+        BRepAdaptor_Surface aSurface (aFace, Standard_False);
+        if (aSurface.GetType()==GeomAbs_Plane)
+        {
+          gp_Pln aPlane = aSurface.Plane();
+          // It rotates a half turn round the axis of rotation
+          aPlane.Rotate(aRotAxis , M_PI/2);
+
+          Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
+          // constructed aGeomPlane parallel to a plane containing the edge (center mid-edge)
+          gp_Pnt aMiddle ((Aa.X()+Ab.X() )/2 ,(Aa.Y()+Ab.Y() )/2 ,(Aa.Z()+Ab.Z() )/2 );
+          Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, aMiddle);
+          GetMapOfAIS().Bind (anAISPlane, aName);
+          TheAISContext()->Display(anAISPlane);
         }
-        else {
-          di<<" vplaneOrtho: error"<<"\n";return 1;
+        else
+        {
+          std::cout<<" vplaneortho: error\n";
+          return 1;
         }
-
       }
+      else
+      {
+        // ShapeA is a Face, deactive the mode Face.
+        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4));
+        std::cout<<" Select an edge\n";
 
-      else {
-        // ShapeA est une Face, on desactive le mode face.
-        TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
-        di<<" Select an edge."<<"\n";
-
-        // Boucle d'attente waitpick.
+        // Wait for picking
         Standard_Integer argccc = 5;
         const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
         const char **argvvv = (const char **) bufff;
         while (ViewerMainLoop( argccc, argvvv) ) { }
-        // fin de la boucle
+        // end of the loop
 
-        TopoDS_Shape ShapeB;
-        for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
-          // L'edge ShapeB peut etre dans la Face ShapeA
-          ShapeB = TheAISContext()->SelectedShape();
+        TopoDS_Shape aShapeB;
+        for (TheAISContext()->InitSelected();
+             TheAISContext()->MoreSelected();
+             TheAISContext()->NextSelected())
+        {
+          // Edge ShapeB can be on Face ShapeA
+          aShapeB = TheAISContext()->SelectedShape();
         }
-
-        // Fermeture du context local
-        TheAISContext()->CloseLocalContext(myCurrentIndex);
-
-        // Construction du plane
-        TopoDS_Edge  EdgeB=TopoDS::Edge(ShapeB);
-        TopoDS_Vertex VBa,VBb;
-        TopExp::Vertices(EdgeB ,VBa ,VBb );
-        gp_Pnt Ba=BRep_Tool::Pnt(VBa);
-        gp_Pnt Bb=BRep_Tool::Pnt(VBb);
-        gp_Vec ab  (Ba,Bb);
+        // Close the local context
+        TheAISContext()->CloseLocalContext(aCurrentIndex);
+
+        // Construction of plane
+        TopoDS_Edge anEdgeB = TopoDS::Edge(aShapeB);
+        TopoDS_Vertex aVBa, aVBb;
+        TopExp::Vertices(anEdgeB, aVBa, aVBb);
+        gp_Pnt aBa = BRep_Tool::Pnt(aVBa);
+        gp_Pnt aBb = BRep_Tool::Pnt(aVBb);
+        gp_Vec ab (aBa,aBb);
         gp_Dir Dab (ab);
-        // Creation de mon axe de rotation
-        gp_Ax1 myRotAxis (Ba,Dab);
-
-        TopoDS_Face myFace=TopoDS::Face(ShapeA);
-        // Il faut imperativement que l'edge soit parallele a la face
-        BRepExtrema_ExtPF myHauteurA (VBa , myFace );
-        BRepExtrema_ExtPF myHauteurB (VBb , myFace );
-        // on compare les deux hauteurs a la tolerance pres
-        if ( fabs(sqrt(myHauteurA.SquareDistance(1)) - sqrt(myHauteurB.SquareDistance(1)) )>0.1 ) {
-          // l'edge n'est pas parallele a la face
-          di<<" vplaneOrtho error: l'edge n'est pas parallele a la face."<<"\n";return 1;
+        // Creation of rotation axe
+        gp_Ax1 aRotAxis (aBa,Dab);
+
+        TopoDS_Face aFace = TopoDS::Face(aShapeA);
+        // The edge must be parallel to the face
+        BRepExtrema_ExtPF aHeightA (aVBa, aFace);
+        BRepExtrema_ExtPF aHeightB (aVBb, aFace);
+        // Comparing the two heights
+        if (fabs(sqrt(aHeightA.SquareDistance(1)) - sqrt(aHeightB.SquareDistance(1)))
+            >Precision::Confusion())
+        {
+          // the edge is not parallel to the face
+          std::cout<<" vplaneortho error: the edge is not parallel to the face\n";
+          return 1;
         }
-        // l'edge est OK
-        BRepAdaptor_Surface mySurface (myFace, Standard_False );
-        if (mySurface.GetType()==GeomAbs_Plane ) {
-          gp_Pln myPlane=mySurface.Plane();
-          // On effectue une rotation d'1/2 tour autour de l'axe de rotation
-          myPlane.Rotate(myRotAxis , PI/2  );
-          Handle(Geom_Plane) theGeomPlane=new Geom_Plane (myPlane );
-          // construit un plan parallele a theGeomPlane contenant l'edgeA (De centre le milieu de l'edgeA)
-          gp_Pnt theMiddle ((Ba.X()+Bb.X() )/2 , (Ba.Y()+Bb.Y() )/2 , (Ba.Z()+Bb.Z() )/2 );
-          Handle(AIS_Plane) myAISPlane=new AIS_Plane (theGeomPlane ,theMiddle );
-          GetMapOfAIS().Bind (myAISPlane ,name );
-          TheAISContext()->Display(myAISPlane);
-
+        // The edge is OK
+        BRepAdaptor_Surface aSurface (aFace, Standard_False);
+        if (aSurface.GetType()==GeomAbs_Plane)
+        {
+          gp_Pln aPlane = aSurface.Plane();
+          // It rotates a half turn round the axis of rotation
+          aPlane.Rotate(aRotAxis , M_PI/2);
+          Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
+          // constructed aGeomPlane parallel to a plane containing the edge theGeomPlane (center mid-edge)
+          gp_Pnt aMiddle ((aBa.X()+aBb.X() )/2 , (aBa.Y()+aBb.Y() )/2 , (aBa.Z()+aBb.Z() )/2 );
+          Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, aMiddle);
+          GetMapOfAIS().Bind (anAISPlane ,aName);
+          TheAISContext()->Display(anAISPlane);
         }
-        else {
-          di<<" vplaneOrtho: error"<<"\n";return 1;
+        else
+        {
+          std::cout<<" vplaneortho: error\n";
+          return 1;
         }
-
       }
+    }
+  }
+  return 0;
+}
+
+//===============================================================================================
+//function : VChangePlane
+//purpose  :
+//===============================================================================================
+static int VChangePlane (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
+{
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+  if (aContextAIS.IsNull())
+  {
+    std::cout << theArgVec[0] << "AIS context is not available.\n";
+    return 1;
+  }
+
+  if (theArgsNb < 3 || theArgsNb > 11)
+  {
+    std::cerr << theArgVec[0] 
+              << ": incorrect number of command arguments.\n"
+              << "Type help for more information.\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aName (theArgVec[1]);
+
+  Handle(AIS_Plane) aPlane = GetMapOfAIS().IsBound2(aName)
+    ? Handle(AIS_Plane)::DownCast (GetMapOfAIS().Find2 (aName))
+    : NULL;
+
+  if ( aPlane.IsNull() )
+  {
+    std::cout << theArgVec[0] 
+              << ": there is no interactive plane with the given name."
+              << "Type help for more information.\n";
+    return 1;
+  }
+
+  Standard_Real aCenterX = aPlane->Center().X();
+  Standard_Real aCenterY = aPlane->Center().Y();
+  Standard_Real aCenterZ = aPlane->Center().Z();
+
+  Standard_Real aDirX = aPlane->Component()->Axis().Direction().X();
+  Standard_Real aDirY = aPlane->Component()->Axis().Direction().Y();
+  Standard_Real aDirZ = aPlane->Component()->Axis().Direction().Z();
 
+  Standard_Real aSizeX = 0.0;
+  Standard_Real aSizeY = 0.0;
+  aPlane->Size (aSizeX, aSizeY);
+  Standard_Boolean isUpdate = Standard_True;
+
+  TCollection_AsciiString aPName, aPValue;
+  for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
+  {
+    const TCollection_AsciiString anArg = theArgVec[anArgIt];
+    TCollection_AsciiString anArgCase = anArg;
+    anArgCase.UpperCase();
+    if (ViewerTest::SplitParameter (anArg, aPName, aPValue))
+    {
+      aPName.UpperCase();
+      if (aPName.IsEqual ("X"))
+      {
+        aCenterX = aPValue.RealValue();
+      }
+      else if (aPName.IsEqual ("Y"))
+      {
+        aCenterY = aPValue.RealValue();
+      }
+      else if (aPName.IsEqual ("Z"))
+      {
+        aCenterZ = aPValue.RealValue();
+      }
+      else if (aPName.IsEqual ("DX"))
+      {
+        aDirX = aPValue.RealValue();
+      }
+      else if (aPName.IsEqual ("DY"))
+      {
+        aDirY = aPValue.RealValue();
+      }
+      else if (aPName.IsEqual ("DZ"))
+      {
+        aDirZ = aPValue.RealValue();
+      }
+      else if (aPName.IsEqual ("SX"))
+      {
+        aSizeX = aPValue.RealValue();
+      }
+      else if (aPName.IsEqual ("SY"))
+      {
+        aSizeY = aPValue.RealValue();
+      }
+    }
+    else if (anArg.IsEqual ("NOUPDATE"))
+    {
+      isUpdate = Standard_False;
     }
+  }
 
+  gp_Dir aDirection (aDirX, aDirY, aDirZ);
+  gp_Pnt aCenterPnt (aCenterX, aCenterY, aCenterZ);
+  aPlane->SetCenter (aCenterPnt);
+  aPlane->SetComponent (new Geom_Plane (aCenterPnt, aDirection));
+  aPlane->SetSize (aSizeX, aSizeY);
+
+  if (isUpdate)
+  {
+    aContextAIS->Update (aPlane, Standard_True);
   }
-  return 0;
 
+  return 0;
 }
 
-
 //==============================================================================
 // Fonction  vline
 // ---------------  Uniquement par parametre. Pas de selection dans le viewer.
@@ -1574,8 +1826,8 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 
     Standard_Real coord[6];
     for(Standard_Integer i=0;i<=2;i++){
-      coord[i]=atof(argv[2+i]);
-      coord[i+3]=atof(argv[5+i]);
+      coord[i]=Draw::Atof(argv[2+i]);
+      coord[i+3]=Draw::Atof(argv[5+i]);
     }
 
     Handle(Geom_CartesianPoint ) myCartPointA=new Geom_CartesianPoint (coord[0],coord[1],coord[2] );
@@ -1656,6 +1908,107 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
   return 0;
 }
 
+//==============================================================================
+// class   : FilledCircle
+// purpose : creates filled circle based on AIS_InteractiveObject 
+//           and Geom_Circle.
+//           This class is used to check method Matches() of class 
+//           Select3D_SensitiveCircle with member myFillStatus = Standard_True, 
+//           because none of AIS classes provides creation of 
+//           Select3D_SensitiveCircle with member myFillStatus = Standard_True 
+//           (look method ComputeSelection() )
+//============================================================================== 
+
+Handle(Geom_Circle) CreateCircle(gp_Pnt theCenter, Standard_Real theRadius) 
+{
+  gp_Ax2 anAxes(theCenter, gp_Dir(gp_Vec(0., 0., 1.))); 
+  gp_Circ aCirc(anAxes, theRadius);
+  Handle(Geom_Circle) aCircle = new Geom_Circle(aCirc);
+  return aCircle;
+}
+
+DEFINE_STANDARD_HANDLE(FilledCircle, AIS_InteractiveObject)
+
+class FilledCircle : public AIS_InteractiveObject 
+{
+public:
+    // CASCADE RTTI
+    DEFINE_STANDARD_RTTI(FilledCircle); 
+
+    FilledCircle(gp_Pnt theCenter, Standard_Real theRadius);
+    FilledCircle(Handle(Geom_Circle) theCircle);
+
+private:
+    TopoDS_Face ComputeFace();
+
+    // Virtual methods implementation
+    void Compute (  const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                  const Handle(Prs3d_Presentation)& thePresentation,
+                  const Standard_Integer theMode);
+
+    void ComputeSelection (  const Handle(SelectMgr_Selection)& theSelection, 
+                           const Standard_Integer theMode);
+
+protected:
+    Handle(Geom_Circle) myCircle;
+    Standard_Boolean myFilledStatus;
+
+}; 
+
+IMPLEMENT_STANDARD_HANDLE(FilledCircle, AIS_InteractiveObject)
+IMPLEMENT_STANDARD_RTTIEXT(FilledCircle, AIS_InteractiveObject)
+
+FilledCircle::FilledCircle(gp_Pnt theCenter, Standard_Real theRadius) 
+{
+  myCircle = CreateCircle(theCenter, theRadius);
+  myFilledStatus = Standard_True;
+}
+
+FilledCircle::FilledCircle(Handle(Geom_Circle) theCircle) 
+{
+  myCircle = theCircle;
+  myFilledStatus = Standard_True;
+}
+
+TopoDS_Face FilledCircle::ComputeFace() 
+{
+  // Create edge from myCircle 
+  BRepBuilderAPI_MakeEdge anEdgeMaker(myCircle->Circ());
+  TopoDS_Edge anEdge = anEdgeMaker.Edge(); 
+
+  // Create wire from anEdge 
+  BRepBuilderAPI_MakeWire aWireMaker(anEdge);
+  TopoDS_Wire aWire = aWireMaker.Wire();
+
+  // Create face from aWire
+  BRepBuilderAPI_MakeFace aFaceMaker(aWire);
+  TopoDS_Face aFace = aFaceMaker.Face();
+
+  return aFace;
+}
+
+void FilledCircle::Compute(const Handle(PrsMgr_PresentationManager3d) &/*thePresentationManager*/, 
+                           const Handle(Prs3d_Presentation) &thePresentation, 
+                           const Standard_Integer theMode) 
+{
+  thePresentation->Clear();
+
+  TopoDS_Face aFace = ComputeFace();
+
+  if (aFace.IsNull()) return;
+  if (theMode != 0) return;
+
+  StdPrs_ShadedShape::Add(thePresentation, aFace, myDrawer);
+}
+
+void FilledCircle::ComputeSelection(const Handle(SelectMgr_Selection) &theSelection, 
+                                    const Standard_Integer /*theMode*/)
+{
+  Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
+  Handle(Select3D_SensitiveCircle) aSensitiveCircle = new Select3D_SensitiveCircle(anEntityOwner, 
+      myCircle, myFilledStatus);
+  theSelection->Add(aSensitiveCircle);
+}
 
 //==============================================================================
 // Fonction  vcircle
@@ -1665,254 +2018,374 @@ static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char*
 //==============================================================================
 //function : VCircleBuilder
 //purpose  : Build an AIS_Circle
-//Draw arg : vcircle CircleName PlaneName PointName Radius
-//                              PointName PointName PointName
+//Draw arg : vcircle CircleName PlaneName PointName Radius IsFilled
+//                              PointName PointName PointName IsFilled
 //==============================================================================
-#include <Geom_CartesianPoint.hxx>
-#include <Geom_Circle.hxx>
-#include <AIS_Circle.hxx>
-#include <GC_MakeCircle.hxx>
-#include <Geom_Plane.hxx>
-#include <gp_Pln.hxx>
 
-static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+void DisplayCircle (Handle (Geom_Circle) theGeomCircle,
+                    TCollection_AsciiString theName, 
+                    Standard_Boolean isFilled) 
+{
+  Handle(AIS_InteractiveObject) aCircle;
+  if (isFilled) 
+  {
+    aCircle = new FilledCircle(theGeomCircle);
+  }
+  else
+  {
+    aCircle = new AIS_Circle(theGeomCircle);
+    Handle(AIS_Circle)::DownCast (aCircle)->SetFilledCircleSens (Standard_False);
+  }
+
+  // Check if there is an object with given name
+  // and remove it from context
+  if (GetMapOfAIS().IsBound2(theName)) 
+  {
+    Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(theName);
+    Handle(AIS_InteractiveObject) anInterObj = 
+         Handle(AIS_InteractiveObject)::DownCast(anObj);
+    TheAISContext()->Remove(anInterObj, Standard_False);
+    GetMapOfAIS().UnBind2(theName);
+   }
+
+   // Bind the circle to its name
+   GetMapOfAIS().Bind(aCircle, theName);
+
+   // Display the circle
+   TheAISContext()->Display(aCircle);
+  
+}
+
+static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
 {
   Standard_Integer myCurrentIndex;
-  // verification of the arguments
-  if (argc>5 ||  argc<2 ) {di<<"vcircle error: expect 3 arguments."<<"\n";return 1; }
+  // Verification of the arguments
+  if (argc>6 || argc<2) 
+  { 
+    std::cout << "vcircle error: expect 4 arguments.\n"; 
+    return 1; // TCL_ERROR 
+  }
   TheAISContext()->CloseAllContexts();
 
-  // Il y a des arguments
-  if (argc==5 ) {
+  // There are all arguments
+  if (argc == 6) 
+  {
+    // Get arguments
+    TCollection_AsciiString aName(argv[1]);
+    Standard_Boolean isFilled = (Standard_Boolean)Draw::Atoi(argv[5]);
+
     Handle(AIS_InteractiveObject) theShapeA;
     Handle(AIS_InteractiveObject) theShapeB;
 
-    theShapeA=
-      Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[2]));
-    theShapeB=
-      Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[3]));
+    theShapeA =
+      Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[2]));
+    theShapeB =
+      Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[3]));
+
 
     // Arguments: AIS_Point AIS_Point AIS_Point
     // ========================================
-    if (!theShapeA.IsNull() && theShapeB.IsNull() &&
+    if (!theShapeA.IsNull() && !theShapeB.IsNull() &&
       theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==1)
     {
-      if (theShapeB->Type()!=AIS_KOI_Datum || theShapeB->Signature()!=1 ) {
-        di<<"vcircle error: 2de argument is unexpected to be a point."<<"\n";
-        return 1;
+      if (theShapeB->Type()!=AIS_KOI_Datum || theShapeB->Signature()!=1 ) 
+      {
+        std::cout << "vcircle error: 2d argument is unexpected to be a point.\n";
+        return 1; // TCL_ERROR 
       }
-      // Le troisieme objet doit etre un point
+      // The third object must be a point
       Handle(AIS_InteractiveObject) theShapeC =
-        Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[4]));
+        Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[4]));
       if (theShapeC.IsNull() ||
-        theShapeC->Type()!=AIS_KOI_Datum || theShapeC->Signature()!=1 ) {
-          di<<"vcircle error: 3de argument is unexpected to be a point."<<"\n";
-          return 1;
-        }
+        theShapeC->Type()!=AIS_KOI_Datum || theShapeC->Signature()!=1 ) 
+      {
+        std::cout << "vcircle error: 3d argument is unexpected to be a point.\n";
+        return 1; // TCL_ERROR 
+      }
         // tag
-        // On verifie que les 3 points sont differents.
-        Handle(AIS_Point) theAISPointA= *(Handle(AIS_Point)*)& theShapeA;
-        Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
-        Handle(AIS_Point) theAISPointC= *(Handle(AIS_Point)*)& theShapeC;
-
-        Handle(Geom_Point ) myGeomPointA=  theAISPointA->Component();
-        Handle(Geom_CartesianPoint ) myCartPointA= *((Handle(Geom_CartesianPoint)*)&  myGeomPointA);
-
-        Handle(Geom_Point ) myGeomPointB =  theAISPointB->Component();
-        Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)&  theAISPointB);
-
-        Handle(Geom_Point ) myGeomPointBC=  theAISPointC->Component();
-        Handle(Geom_CartesianPoint ) myCartPointC= *((Handle(Geom_CartesianPoint)*)&  theAISPointC);
+        // Verify that the three points are different
+        Handle(AIS_Point) theAISPointA = Handle(AIS_Point)::DownCast(theShapeA);
+        Handle(AIS_Point) theAISPointB = Handle(AIS_Point)::DownCast(theShapeB);
+        Handle(AIS_Point) theAISPointC = Handle(AIS_Point)::DownCast(theShapeC);
+        
+        Handle(Geom_Point) myGeomPointA = theAISPointA->Component();
+        Handle(Geom_CartesianPoint) myCartPointA = 
+          Handle(Geom_CartesianPoint)::DownCast(myGeomPointA);
+
+        Handle(Geom_Point) myGeomPointB = theAISPointB->Component();
+        Handle(Geom_CartesianPoint) myCartPointB =
+          Handle(Geom_CartesianPoint)::DownCast(myGeomPointB);
+
+        Handle(Geom_Point) myGeomPointC = theAISPointC->Component();
+        Handle(Geom_CartesianPoint) myCartPointC =
+          Handle(Geom_CartesianPoint)::DownCast(myGeomPointC);
 
         // Test A=B
-        if (myCartPointA->X()==myCartPointB->X() && myCartPointA->Y()==myCartPointB->Y() && myCartPointA->Z()==myCartPointB->Z()  ) {
-          di<<"vcircle error: Same points."<<"\n";return 1;
+        if (Abs(myCartPointA->X()-myCartPointB->X()) <= Precision::Confusion() && 
+            Abs(myCartPointA->Y()-myCartPointB->Y()) <= Precision::Confusion() && 
+            Abs(myCartPointA->Z()-myCartPointB->Z()) <= Precision::Confusion() ) 
+        {
+          std::cout << "vcircle error: Same points.\n"; 
+          return 1; // TCL_ERROR 
         }
         // Test A=C
-        if (myCartPointA->X()==myCartPointC->X() && myCartPointA->Y()==myCartPointC->Y() && myCartPointA->Z()==myCartPointC->Z()  ) {
-          di<<"vcircle error: Same points."<<"\n";return 1;
+        if (Abs(myCartPointA->X()-myCartPointC->X()) <= Precision::Confusion() &&
+            Abs(myCartPointA->Y()-myCartPointC->Y()) <= Precision::Confusion() && 
+            Abs(myCartPointA->Z()-myCartPointC->Z()) <= Precision::Confusion() ) 
+        {
+          std::cout << "vcircle error: Same points.\n"; 
+          return 1; // TCL_ERROR 
         }
         // Test B=C
-        if (myCartPointB->X()==myCartPointC->X() && myCartPointB->Y()==myCartPointC->Y() && myCartPointB->Z()==myCartPointC->Z()  ) {
-          di<<"vcircle error: Same points."<<"\n";return 1;
+        if (Abs(myCartPointB->X()-myCartPointC->X()) <= Precision::Confusion() && 
+            Abs(myCartPointB->Y()-myCartPointC->Y()) <= Precision::Confusion() && 
+            Abs(myCartPointB->Z()-myCartPointC->Z()) <= Precision::Confusion() ) 
+        {
+          std::cout << "vcircle error: Same points.\n"; 
+          return 1;// TCL_ERROR 
         }
-        // Construction du cercle
-        GC_MakeCircle Cir=GC_MakeCircle (myCartPointA->Pnt(),myCartPointB->Pnt(),myCartPointC->Pnt() );
-        Handle (Geom_Circle) theGeomCircle=Cir.Value();
-        Handle(AIS_Circle) theAISCircle=new AIS_Circle(theGeomCircle );
-        GetMapOfAIS().Bind(theAISCircle,argv[1] );
-        TheAISContext()->Display(theAISCircle );
-
+        // Construction of the circle
+        GC_MakeCircle Cir = GC_MakeCircle (myCartPointA->Pnt(), 
+          myCartPointB->Pnt(), myCartPointC->Pnt() );
+        Handle (Geom_Circle) theGeomCircle;
+        try 
+        {
+          theGeomCircle = Cir.Value();
+        }
+        catch (StdFail_NotDone)
+        {
+          std::cout << "vcircle error: can't create circle\n";
+          return -1; // TCL_ERROR
+        }
+        
+        DisplayCircle(theGeomCircle, aName, isFilled);
     }
 
-    // Arguments: ASI_Plane AIS_Point Real
+    // Arguments: AIS_Plane AIS_Point Real
     // ===================================
-    else if (theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==7 ) {
-      if (theShapeB->Type()!=AIS_KOI_Datum || theShapeB->Signature()!=1 ) {
-        di<<"vcircle error: 2de element is a unexpected to be a point."<<"\n";return 1;
+    else if (theShapeA->Type() == AIS_KOI_Datum && 
+      theShapeA->Signature() == 7 ) 
+    {
+      if (theShapeB->Type() != AIS_KOI_Datum || 
+        theShapeB->Signature() != 1 ) 
+      {
+        std::cout << "vcircle error: 2d element is a unexpected to be a point.\n"; 
+        return 1; // TCL_ERROR 
+      }
+      // Check that the radius is >= 0
+      if (Draw::Atof(argv[4]) <= 0 ) 
+      {
+        std::cout << "vcircle error: the radius must be >=0.\n"; 
+        return 1; // TCL_ERROR 
       }
-      // On verifie que le rayon est bien >=0
-      if (atof(argv[4])<=0 ) {di<<"vcircle error: the radius must be >=0."<<"\n";return 1;  }
-
-      // On recupere la normale au Plane.
-      Handle(AIS_Plane) theAISPlane= *(Handle(AIS_Plane)*)& theShapeA;
-      Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
 
+      // Recover the normal to the plane
+      Handle(AIS_Plane) theAISPlane = Handle(AIS_Plane)::DownCast(theShapeA);
+      Handle(AIS_Point) theAISPointB = Handle(AIS_Point)::DownCast(theShapeB); 
 
-      //      Handle(Geom_Plane ) myGeomPlane= *(Handle(Geom_Plane)*)& (theAISPlane->Component() );
-      Handle(Geom_Plane ) myGeomPlane= theAISPlane->Component();
-      Handle(Geom_Point ) myGeomPointB =  theAISPointB->Component();
-      Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)&  theAISPointB);
+      Handle(Geom_Plane) myGeomPlane = theAISPlane->Component();
+      Handle(Geom_Point) myGeomPointB = theAISPointB->Component();
+      Handle(Geom_CartesianPoint) myCartPointB = 
+        Handle(Geom_CartesianPoint)::DownCast(myGeomPointB);
 
       gp_Pln mygpPlane = myGeomPlane->Pln();
       gp_Ax1 thegpAxe = mygpPlane.Axis();
       gp_Dir theDir = thegpAxe.Direction();
-      gp_Pnt theCenter=myCartPointB->Pnt();
-      Standard_Real TheR = atof(argv[4]);
-      GC_MakeCircle Cir=GC_MakeCircle (theCenter, theDir ,TheR);
-      Handle (Geom_Circle) theGeomCircle=Cir.Value();
-      Handle(AIS_Circle) theAISCircle=new AIS_Circle(theGeomCircle );
-      GetMapOfAIS().Bind(theAISCircle,argv[1] );
-      TheAISContext()->Display(theAISCircle );
+      gp_Pnt theCenter = myCartPointB->Pnt();
+      Standard_Real TheR = Draw::Atof(argv[4]);
+      GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,TheR);
+      Handle (Geom_Circle) theGeomCircle;
+      try 
+      {
+        theGeomCircle = Cir.Value();
+      }
+      catch (StdFail_NotDone)
+      {
+        std::cout << "vcircle error: can't create circle\n";
+        return -1; // TCL_ERROR
+      }
+
+      DisplayCircle(theGeomCircle, aName, isFilled);
 
     }
 
     // Error
-    else{
-      di<<"vcircle error: !st argument is a unexpected type."<<"\n";return 1;
+    else
+    {
+      std::cout << "vcircle error: 1st argument is a unexpected type.\n"; 
+      return 1; // TCL_ERROR 
     }
 
   }
-  // Pas d'arguments: selection dans le viewer
+  // No arguments: selection in the viewer
   // =========================================
-  else {
+  else 
+  {
+    // Get the name of the circle 
+    TCollection_AsciiString aName(argv[1]);
 
     TheAISContext()->OpenLocalContext();
-    myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
+    myCurrentIndex = TheAISContext()->IndexOfCurrentLocal();
 
-    // Active le mode Vertex et face.
+    // Activate selection mode for vertices and faces
     TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
     TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
-    di<<" Select a vertex or a face."<<"\n";
+    std::cout << " Select a vertex or a face\n";
 
-    // Boucle d'attente waitpick.
+    // Wait for picking
     Standard_Integer argcc = 5;
     const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
     const char **argvv = (const char **) buff;
     while (ViewerMainLoop( argcc, argvv) ) { }
-    // fin de la boucle
+    // end of the loop
 
     TopoDS_Shape ShapeA;
-    for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
+    for(TheAISContext()->InitSelected(); 
+      TheAISContext()->MoreSelected(); 
+      TheAISContext()->NextSelected() ) 
+    {
       ShapeA = TheAISContext()->SelectedShape();
     }
 
-    // ShapeA est un Vertex
-    if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
+    // ShapeA is a Vertex
+    if (ShapeA.ShapeType() == TopAbs_VERTEX ) 
+    {
       TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
-      di<<" Select a different vertex."<<"\n";
+      std::cout << " Select a different vertex\n";
 
       TopoDS_Shape ShapeB;
-      do {
-
-        // Boucle d'attente waitpick.
+      do 
+      {
+        // Wait for picking
         Standard_Integer argccc = 5;
         const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
         const char **argvvv = (const char **) bufff;
         while (ViewerMainLoop( argccc, argvvv) ) { }
-        // fin de la boucle
+        // end of the loop
 
-        for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
+        for(TheAISContext()->InitSelected(); 
+          TheAISContext()->MoreSelected(); 
+          TheAISContext()->NextSelected() ) 
+        {
           ShapeB = TheAISContext()->SelectedShape();
         }
-
-
       } while(ShapeB.IsSame(ShapeA) );
 
-      // Selection de ShapeC
-      di<<" Select the last vertex."<<"\n";
+      // Selection of ShapeC
+      std::cout << " Select the last vertex\n";
       TopoDS_Shape ShapeC;
-      do {
-
-        // Boucle d'attente waitpick.
+      do 
+      {
+        // Wait for picking
         Standard_Integer argcccc = 5;
         const char *buffff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
         const char **argvvvv = (const char **) buffff;
         while (ViewerMainLoop( argcccc, argvvvv) ) { }
-        // fin de la boucle
+        // end of the loop
 
-        for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
+        for(TheAISContext()->InitSelected(); 
+          TheAISContext()->MoreSelected(); 
+          TheAISContext()->NextSelected() ) 
+        {
           ShapeC = TheAISContext()->SelectedShape();
         }
-
-
       } while(ShapeC.IsSame(ShapeA) || ShapeC.IsSame(ShapeB) );
+      
+      // Get isFilled
+      Standard_Boolean isFilled;
+      std::cout << "Enter filled status (0 or 1)\n";
+      cin >> isFilled;
 
-      // Fermeture du context local
+      // Close the local context
       TheAISContext()->CloseLocalContext(myCurrentIndex);
 
-      // Construction du cercle
-      gp_Pnt   A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)  );
-      gp_Pnt   B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)  );
-      gp_Pnt   C=BRep_Tool::Pnt(TopoDS::Vertex(ShapeC)  );
+      // Construction of the circle
+      gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA));
+      gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB));
+      gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(ShapeC));
+
+      GC_MakeCircle Cir = GC_MakeCircle (A, B, C);
+      Handle (Geom_Circle) theGeomCircle;
+      try 
+      {
+        theGeomCircle = Cir.Value();
+      }
+      catch (StdFail_NotDone)
+      {
+        std::cout << "vcircle error: can't create circle\n";
+        return -1; // TCL_ERROR
+      }
 
-      GC_MakeCircle Cir=GC_MakeCircle (A,B,C );
-      Handle (Geom_Circle) theGeomCircle=Cir.Value();
-      Handle(AIS_Circle) theAISCircle=new AIS_Circle(theGeomCircle );
-      GetMapOfAIS().Bind(theAISCircle,argv[1] );
-      TheAISContext()->Display(theAISCircle );
+      DisplayCircle(theGeomCircle, aName, isFilled);
 
     }
-    // ShapeA est une face.
-    else  {
-      di<<" Select a vertex (in your face)."<<"\n";
+    // Shape is a face
+    else
+    {
+      std::cout << " Select a vertex (in your face)\n";
       TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
 
       TopoDS_Shape ShapeB;
-      // Boucle d'attente waitpick.
+      // Wait for picking
       Standard_Integer argccc = 5;
       const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
       const char **argvvv = (const char **) bufff;
       while (ViewerMainLoop( argccc, argvvv) ) { }
-      // fin de la boucle
+      // end of the loop
 
-      for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
+      for(TheAISContext()->InitSelected(); 
+        TheAISContext()->MoreSelected(); 
+        TheAISContext()->NextSelected() ) 
+      {
         ShapeB = TheAISContext()->SelectedShape();
       }
 
-      // Recuperation du rayon.
-      Standard_Integer theRad;
-      do {
-        di<<" Enter the value of the radius:"<<"\n";
-        cin>>theRad;
-      } while (theRad<=0);
+      // Recover the radius 
+      Standard_Real theRad;
+      do 
+      {
+        std::cout << " Enter the value of the radius:\n";
+        cin >> theRad;
+      } while (theRad <= 0);
+      
+      // Get filled status
+      Standard_Boolean isFilled;
+      std::cout << "Enter filled status (0 or 1)\n";
+      cin >> isFilled;
 
-      // Fermeture du context local
+      // Close the local context
       TheAISContext()->CloseLocalContext(myCurrentIndex);
-      // Construction du cercle.
+      // Construction of the circle
 
-      // On recupere la normale au Plane. tag
-      TopoDS_Face myFace=TopoDS::Face(ShapeA);
-      BRepAdaptor_Surface mySurface (myFace, Standard_False );
-      gp_Pln myPlane=mySurface.Plane();
-      Handle(Geom_Plane) theGeomPlane=new Geom_Plane (myPlane );
+      // Recover the normal to the plane. tag
+      TopoDS_Face myFace = TopoDS::Face(ShapeA);
+      BRepAdaptor_Surface mySurface (myFace, Standard_False);
+      gp_Pln myPlane = mySurface.Plane();
+      Handle(Geom_Plane) theGeomPlane = new Geom_Plane (myPlane);
       gp_Pln mygpPlane = theGeomPlane->Pln();
       gp_Ax1 thegpAxe = mygpPlane.Axis();
       gp_Dir theDir = thegpAxe.Direction();
 
-      // On recupere le centre.
-      gp_Pnt   theCenter=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)  );
+      // Recover the center
+      gp_Pnt theCenter = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB));
 
-      // On construit l'AIS_Circle
-      GC_MakeCircle Cir=GC_MakeCircle (theCenter, theDir ,theRad  );
-      Handle (Geom_Circle) theGeomCircle=Cir.Value();
-      Handle(AIS_Circle) theAISCircle=new AIS_Circle(theGeomCircle );
-      GetMapOfAIS().Bind(theAISCircle,argv[1] );
-      TheAISContext()->Display(theAISCircle );
+      // Construct the circle
+      GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,theRad);
+      Handle (Geom_Circle) theGeomCircle;
+      try 
+      {
+        theGeomCircle = Cir.Value();
+      }
+      catch (StdFail_NotDone)
+      {
+        std::cout << "vcircle error: can't create circle\n";
+        return -1; // TCL_ERROR
+      }
 
+      DisplayCircle(theGeomCircle, aName, isFilled);
+      
     }
 
-
   }
 
   return 0;
@@ -1927,26 +2400,21 @@ static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const cha
 //===============================================================================================
 #include <Graphic3d_Group.hxx>
 #include <Graphic3d_Structure.hxx>
-#include <Graphic3d_NameOfFont.hxx>
 #include <Graphic3d_AspectText3d.hxx>
-#include <Graphic2d_GraphicObject.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
 #include <Graphic3d_AspectFillArea3d.hxx>
 #include <Graphic3d_StructureManager.hxx>
 #include <Graphic3d_VerticalTextAlignment.hxx>
 #include <Graphic3d_HorizontalTextAlignment.hxx>
 
+#include <Font_NameOfFont.hxx>
+
 #include <Visual3d_ViewManager.hxx>
-#include <ViewerTest_Tool.ixx>
 
 #include <Standard_DefineHandle.hxx>
 
-#include <AIS_Drawer.hxx>
-
 #include <Prs3d_Root.hxx>
 #include <Prs3d_Text.hxx>
 #include <Prs3d_TextAspect.hxx>
-#include <Prs3d_Presentation.hxx>
 #include <Prs3d_ShadingAspect.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
 
@@ -1977,7 +2445,7 @@ public:
       Standard_Real Angle ,
       Standard_Boolean Zoom ,
       Standard_Real  Height,
-      OSD_FontAspect FontAspect,
+      Font_FontAspect FontAspect,
       Standard_CString Font
     );
 
@@ -1987,8 +2455,8 @@ private:
                   const Handle(Prs3d_Presentation)& aPresentation,
                   const Standard_Integer aMode);
 
-  void ComputeSelection (  const Handle(SelectMgr_Selection)& aSelection,
-                           const Standard_Integer aMode){} ;
+  void ComputeSelection (  const Handle(SelectMgr_Selection)& /*aSelection*/,
+                           const Standard_Integer /*aMode*/){} ;
 
 protected:
   TCollection_ExtendedString          aText;
@@ -2000,8 +2468,8 @@ protected:
   Standard_Real                       aHeight;
   Standard_Boolean                    aZoomable;
   Quantity_Color                      aColor;
-  Standard_CString                    aFont;
-  OSD_FontAspect                      aFontAspect;
+  TCollection_AsciiString             aFont;
+  Font_FontAspect                     aFontAspect;
   Graphic3d_HorizontalTextAlignment   aHJustification;
   Graphic3d_VerticalTextAlignment     aVJustification;
 };
@@ -2019,7 +2487,7 @@ MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt&
                           Standard_Real     angle       = 0.0 ,
                           Standard_Boolean  zoomable    = Standard_True,
                           Standard_Real     height      = 12.,
-                          OSD_FontAspect    fontAspect  = OSD_FA_Regular,
+                          Font_FontAspect   fontAspect  = Font_FA_Regular,
                           Standard_CString  font        = "Courier")
 {
   aText           = text;
@@ -2037,16 +2505,16 @@ MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt&
 
 
 //////////////////////////////////////////////////////////////////////////////
-void MyTextClass::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+void MyTextClass::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
                           const Handle(Prs3d_Presentation)& aPresentation,
-                          const Standard_Integer aMode)
+                          const Standard_Integer /*aMode*/)
 {
 
   aPresentation->Clear();
 
-  Handle_Prs3d_TextAspect asp = myDrawer->TextAspect();
+  Handle(Prs3d_TextAspect) asp = myDrawer->TextAspect();
 
-  asp->SetFont(aFont);
+  asp->SetFont(aFont.ToCString());
   asp->SetColor(aColor);
   asp->SetHeight(aHeight); // I am changing the myHeight value
 
@@ -2063,9 +2531,7 @@ void MyTextClass::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentat
   Graphic3d_Vertex vertices_text;
   vertices_text.SetCoord(aPosition.X(),aPosition.Y(),aPosition.Y());
   TheGroup->SetPrimitivesAspect(aspect);
-  TheGroup->BeginPrimitives();
   TheGroup->Text(aText,vertices_text,aHeight,Standard_True);
-  TheGroup->EndPrimitives();
   */
 };
 
@@ -2094,32 +2560,32 @@ static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char**
   }
 
   // Text position
-  const Standard_Real X = atof(argv[2]);
-  const Standard_Real Y = atof(argv[3]);
-  const Standard_Real Z = atof(argv[4]);
+  const Standard_Real X = Draw::Atof(argv[2]);
+  const Standard_Real Y = Draw::Atof(argv[3]);
+  const Standard_Real Z = Draw::Atof(argv[4]);
   const gp_Pnt pnt(X,Y,Z);
 
   // Text color
-  const Quantity_Parameter R = atof(argv[5])/255.;
-  const Quantity_Parameter G = atof(argv[6])/255.;
-  const Quantity_Parameter B = atof(argv[7])/255.;
+  const Quantity_Parameter R = Draw::Atof(argv[5])/255.;
+  const Quantity_Parameter G = Draw::Atof(argv[6])/255.;
+  const Quantity_Parameter B = Draw::Atof(argv[7])/255.;
   const Quantity_Color aColor( R, G, B, Quantity_TOC_RGB );
 
   // Text alignment
-  const int hor_align = atoi(argv[8]);
-  const int ver_align = atoi(argv[9]);
+  const int hor_align = Draw::Atoi(argv[8]);
+  const int ver_align = Draw::Atoi(argv[9]);
 
   // Text angle
-  const Standard_Real angle = atof(argv[10]);
+  const Standard_Real angle = Draw::Atof(argv[10]);
 
   // Text zooming
-  const Standard_Boolean zoom = atoi(argv[11]);
+  const Standard_Boolean zoom = Draw::Atoi(argv[11]);
 
   // Text height
-  const Standard_Real height = atof(argv[12]);
+  const Standard_Real height = Draw::Atof(argv[12]);
 
   // Text aspect
-  const OSD_FontAspect aspect = OSD_FontAspect(atoi(argv[13]));
+  const Font_FontAspect aspect = Font_FontAspect(Draw::Atoi(argv[13]));
 
   // Text font
   TCollection_AsciiString font;
@@ -2129,18 +2595,19 @@ static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char**
     font.AssignCat(argv[14]);
 
   // Text is multibyte
-  const Standard_Boolean isMultibyte = (argc < 16)? Standard_False : (atoi(argv[15]) != 0);
+  const Standard_Boolean isMultibyte = (argc < 16)? Standard_False : (Draw::Atoi(argv[15]) != 0);
 
   // Read text string
   TCollection_ExtendedString name;
   if (isMultibyte)
   {
     const char *str = argv[1];
-    while (*str)
+    while ( *str || *(str+1)=='\x0A' || *(str+1)=='\x0B' || *(str+1)=='\x0C' || *(str+1)=='\x0D'
+                 || *(str+1)=='\x07' || *(str+1)=='\x08' || *(str+1)=='\x09' )
     {
       unsigned short c1 = *str++;
       unsigned short c2 = *str++;
-      if (!c1 || !c2) break;
+      if (!c2) break;
       name += (Standard_ExtCharacter)((c1 << 8) | c2);
     }
   }
@@ -2162,7 +2629,6 @@ static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char**
 #include <gp_Pnt.hxx>
 #include <Graphic3d_ArrayOfPoints.hxx>
 #include <Graphic3d_ArrayOfPrimitives.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
 #include <Graphic3d_ArrayOfTriangles.hxx>
 #include <Poly_Array1OfTriangle.hxx>
 #include <Poly_Triangle.hxx>
@@ -2172,13 +2638,11 @@ static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char**
 #include <TShort_HArray1OfShortReal.hxx>
 
 #include <AIS_Triangulation.hxx>
-#include <Aspect_GraphicDevice.hxx>
 #include <StdPrs_ToolShadedShape.hxx>
 #include <Poly_Connect.hxx>
 #include <TColgp_Array1OfDir.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
 
-#include <AIS_Drawer.hxx>
 #include <TColStd_Array1OfInteger.hxx>
 #include <TColStd_HArray1OfInteger.hxx>
 #include <Prs3d_ShadingAspect.hxx>
@@ -2216,7 +2680,6 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
 
   int i, j;
   int jStart, jEnd, numOffset;
-  int numPts, numPolys;
   double x[3], n[3], deltaPhi, deltaTheta, phi, theta, radius;
   double startTheta, endTheta, startPhi, endPhi;
   int base, numPoles=0, thetaResolution, phiResolution;
@@ -2246,9 +2709,6 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
   localStartTheta = localStartTheta + (double)(start) * deltaTheta;
   localThetaResolution = end - start;
 
-  numPts =  mPhiResolution * localThetaResolution + 2;
-  numPolys =  mPhiResolution * 2 * localThetaResolution;
-
   // Create north pole if needed
   int number_point = 0;
   int number_pointArray = 0;
@@ -2264,15 +2724,15 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
 
   // Check data, determine increments, and convert to radians
   startTheta = (localStartTheta < localEndTheta ? localStartTheta : localEndTheta);
-  startTheta *= Standard_PI  / 180.0;
+  startTheta *= M_PI  / 180.0;
   endTheta = (localEndTheta > localStartTheta ? localEndTheta : localStartTheta);
-  endTheta *= Standard_PI  / 180.0;
+  endTheta *= M_PI  / 180.0;
 
 
   startPhi = ( mStartPhi <  mEndPhi ?  mStartPhi :  mEndPhi);
-  startPhi *= Standard_PI  / 180.0;
+  startPhi *= M_PI  / 180.0;
   endPhi = ( mEndPhi >  mStartPhi ?  mEndPhi :  mStartPhi);
-  endPhi *= Standard_PI  / 180.0;
+  endPhi *= M_PI  / 180.0;
 
   phiResolution =  mPhiResolution - numPoles;
   deltaPhi = (endPhi - startPhi) / ( mPhiResolution - 1);
@@ -2332,7 +2792,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
 
   number_point = 3;
   for ( i=0; i < localThetaResolution; i++){
-    theta = localStartTheta * Standard_PI / 180.0 + i*deltaTheta;
+    theta = localStartTheta * M_PI / 180.0 + i*deltaTheta;
     for ( j = jStart; j < jEnd; j++){
         phi = startPhi + j*deltaPhi;
         radius =  mRadius * sin((double)phi);
@@ -2430,7 +2890,7 @@ Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z
 //author   : psn
 //purpose  : Create an AIS shape.
 //===============================================================================================
-static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
 {
   // check for errors
   Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
@@ -2442,49 +2902,25 @@ static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char*
   else if (argc < 3)
   {
     std::cout << "Use: " << argv[0]
-              << " shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]\n";
+              << " shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0]\n";
     return 1;
   }
 
   // read the arguments
   TCollection_AsciiString aShapeName (argv[1]);
-  Standard_Integer aResolution = atoi (argv[2]);
-  Standard_Real aCenterX = (argc > 5) ? atof (argv[3]) : 0.0;
-  Standard_Real aCenterY = (argc > 5) ? atof (argv[4]) : 0.0;
-  Standard_Real aCenterZ = (argc > 5) ? atof (argv[5]) : 0.0;
-  Standard_Real aRadius =  (argc > 6) ? atof (argv[6]) : 100.0;
-  Standard_Boolean isVBOEnabled = (argc > 7) ? atoi (argv[7]) : Standard_True;
-  Standard_Integer aRedrawsNb =   (argc > 8) ? atoi (argv[8]) : 1;
-  Standard_Boolean toShowEdges =  (argc > 9) ? atoi (argv[9]) : Standard_False;
-
-  if (aRedrawsNb <= 0)
-  {
-    aRedrawsNb = 1;
-  }
+  Standard_Integer aResolution = Draw::Atoi (argv[2]);
+  Standard_Real aCenterX = (argc > 5) ? Draw::Atof (argv[3]) : 0.0;
+  Standard_Real aCenterY = (argc > 5) ? Draw::Atof (argv[4]) : 0.0;
+  Standard_Real aCenterZ = (argc > 5) ? Draw::Atof (argv[5]) : 0.0;
+  Standard_Real aRadius =  (argc > 6) ? Draw::Atof (argv[6]) : 100.0;
+  Standard_Boolean toShowEdges = (argc > 7) ? Draw::Atoi (argv[7]) == 1 : Standard_False;
+  Standard_Boolean toPrintInfo = (argc > 8) ? Draw::Atoi (argv[8]) == 1 : Standard_True;
 
   // remove AIS object with given name from map
-  if (GetMapOfAIS().IsBound2 (aShapeName))
-  {
-    Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aShapeName);
-    Handle(AIS_InteractiveObject) anInterObj = Handle(AIS_InteractiveObject)::DownCast (anObj);
-    if (anInterObj.IsNull())
-    {
-      std::cout << "Shape name was used for non AIS viewer\n!";
-      return 1;
-    }
-    aContextAIS->Remove (anInterObj, Standard_False);
-    GetMapOfAIS().UnBind2 (aShapeName);
-  }
-
-  // enable/disable VBO
-  Handle(Graphic3d_GraphicDriver) aDriver =
-         Handle(Graphic3d_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Device()->GraphicDriver());
-  if (!aDriver.IsNull())
-  {
-    aDriver->EnableVBO (isVBOEnabled);
-  }
+  VDisplayAISObject (aShapeName, Handle(AIS_InteractiveObject)());
 
-  std::cout << "Compute Triangulation...\n";
+  if (toPrintInfo)
+    std::cout << "Compute Triangulation...\n";
   Handle(AIS_Triangulation) aShape
     = new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
                                                   aResolution,
@@ -2492,9 +2928,6 @@ static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char*
   Standard_Integer aNumberPoints    = aShape->GetTriangulation()->Nodes().Length();
   Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
 
-  // register the object in map
-  GetMapOfAIS().Bind (aShape, aShapeName);
-
   // stupid initialization of Green color in RGBA space as integer
   // probably wrong for big-endian CPUs
   Standard_Integer aRed    = 0;
@@ -2526,12 +2959,15 @@ static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char*
   aColorsSize >>= 20;
   aTrianglesSize >>= 20;
   aPolyConnectSize >>= 20;
-  std::cout << "NumberOfPoints:    " << aNumberPoints << "\n"
-            << "NumberOfTriangles: " << aNumberTriangles << "\n"
-            << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
-            << "Amount of memory for colors: " << aColorsSize << " Mb\n"
-            << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
-            << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
+  if (toPrintInfo)
+  {
+    std::cout << "NumberOfPoints:    " << aNumberPoints << "\n"
+      << "NumberOfTriangles: " << aNumberTriangles << "\n"
+      << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
+      << "Amount of memory for colors: " << aColorsSize << " Mb\n"
+      << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
+      << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
+  }
 
   // Setting material properties, very important for desirable visual result!
   Graphic3d_MaterialAspect aMat (Graphic3d_NOM_PLASTIC);
@@ -2557,246 +2993,37 @@ static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char*
   aShAsp->SetAspect (anAspect);
   aShape->Attributes()->SetShadingAspect (aShAsp);
 
-  aContextAIS->Display (aShape, Standard_False);
-
-  // Two viewer updates are needed in order to measure time spent on
-  // loading triangulation to graphic card memory + redrawing (1st update) and
-  // time spent on redrawing itself (2nd and all further updates)
-  OSD_Chronometer aTimer;
-  Standard_Real aUserSeconds, aSystemSeconds;
-  aTimer.Start();
-  const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
-  for (Standard_Integer anInteration = 0; anInteration < aRedrawsNb; ++anInteration)
-  {
-    for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
-    {
-      if (anInteration == 0)
-      {
-        aViewer->ActiveView()->Update();
-      }
-      else
-      {
-        aViewer->ActiveView()->Redraw();
-      }
-    }
-  }
-  aTimer.Show (aUserSeconds, aSystemSeconds);
-  aTimer.Stop();
-  std::cout << "Number of scene redrawings: " << aRedrawsNb << "\n"
-            << "CPU user time: "
-            << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * aUserSeconds
-            << " msec\n"
-            << "CPU system time: "
-            << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * aSystemSeconds
-            << " msec\n"
-            << "CPU average time of scene redrawing: "
-            << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * (aUserSeconds / (Standard_Real )aRedrawsNb)
-            << " msec\n";
+  VDisplayAISObject (aShapeName, aShape);
   return 0;
 }
 
-//===============================================================================================
-//function : VClipPlane
+//=============================================================================
+//function : VComputeHLR
 //purpose  :
-//===============================================================================================
-static int VClipPlane (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+//=============================================================================
+
+static int VComputeHLR (Draw_Interpretor& di,
+                        Standard_Integer argc,
+                        const char** argv)
 {
-  Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
-  Handle(V3d_View) aView = ViewerTest::CurrentView();
-  Standard_Real coeffA, coeffB, coeffC, coeffD;
-  if (aViewer.IsNull() || aView.IsNull())
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
+
+  if (aContextAIS.IsNull ())
   {
-    std::cout << "Viewer not initialized!\n";
+    di << "Please call vinit before\n";
     return 1;
   }
 
-  // count an active planes count
-  Standard_Integer aNewPlaneId = 1;
-  Standard_Integer anActivePlanes = 0;
-  for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aNewPlaneId)
+  if ( argc != 3 &&  argc != 12 )
   {
-    Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
-    if (aView->IsActivePlane (aPlaneV3d))
-    {
-      ++anActivePlanes;
-    }
-  }
-
-  if (argc == 1)
-  {
-    // just show info about existing planes
-    Standard_Integer aPlaneId = 1;
-    std::cout << "Active planes: " << anActivePlanes << " from maximal " << aView->View()->PlaneLimit() << "\n";
-    for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aPlaneId)
-    {
-      Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
-      aPlaneV3d->Plane (coeffA, coeffB, coeffC, coeffD);
-      gp_Pln aPlane (coeffA, coeffB, coeffC, coeffD);
-      const gp_Pnt& aLoc = aPlane.Location();
-      const gp_Dir& aNor = aPlane.Axis().Direction();
-      Standard_Boolean isActive = aView->IsActivePlane (aPlaneV3d);
-      std::cout << "Plane #" << aPlaneId
-        << " " << aLoc.X() << " " << aLoc.Y() << " " << aLoc.Z()
-        << " " << aNor.X() << " " << aNor.Y() << " " << aNor.Z()
-        << (isActive ? " on" : " off")
-        << (aPlaneV3d->IsDisplayed() ? ", displayed" : ", hidden")
-        << "\n";
-    }
-    if (aPlaneId == 1)
-    {
-      std::cout << "No defined clipping planes\n";
-    }
-    return 0;
-  }
-  else if (argc == 2 || argc == 3)
-  {
-    Standard_Integer aPlaneIdToOff = (argc == 3) ? atoi (argv[1]) : 1;
-    Standard_Boolean toIterateAll = (argc == 2);
-    TCollection_AsciiString isOnOffStr ((argc == 3) ? argv[2] : argv[1]);
-    isOnOffStr.LowerCase();
-    Standard_Integer aPlaneId = 1;
-    for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aPlaneId)
-    {
-      if (aPlaneIdToOff == aPlaneId || toIterateAll)
-      {
-        Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
-        if (isOnOffStr.Search ("off") >= 0)
-        {
-          aView->SetPlaneOff (aPlaneV3d);
-          std::cout << "Clipping plane #" << aPlaneId << " was disabled\n";
-        }
-        else if (isOnOffStr.Search ("on") >= 0)
-        {
-          // avoid z-fighting glitches
-          aPlaneV3d->Erase();
-          if (!aView->IsActivePlane (aPlaneV3d))
-          {
-            if (anActivePlanes < aView->View()->PlaneLimit())
-            {
-              aView->SetPlaneOn (aPlaneV3d);
-              std::cout << "Clipping plane #" << aPlaneId << " was enabled\n";
-            }
-            else
-            {
-              std::cout << "Maximal active planes limit exceeded (" << anActivePlanes << ")\n"
-                        << "You should disable or remove some existing plane to activate this one\n";
-            }
-          }
-          else
-          {
-            std::cout << "Clipping plane #" << aPlaneId << " was already enabled\n";
-          }
-        }
-        else if (isOnOffStr.Search ("del") >= 0 || isOnOffStr.Search ("rem") >= 0)
-        {
-          aPlaneV3d->Erase(); // not performed on destructor!!!
-          aView->SetPlaneOff (aPlaneV3d);
-          aViewer->DelPlane (aPlaneV3d);
-          std::cout << "Clipping plane #" << aPlaneId << " was removed\n";
-          if (toIterateAll)
-          {
-            for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->InitDefinedPlanes(), ++aPlaneId)
-            {
-              aPlaneV3d = aViewer->DefinedPlane();
-              aPlaneV3d->Erase(); // not performed on destructor!!!
-              aView->SetPlaneOff (aPlaneV3d);
-              aViewer->DelPlane (aPlaneV3d);
-              std::cout << "Clipping plane #" << aPlaneId << " was removed\n";
-            }
-            break;
-          }
-          else
-          {
-            break;
-          }
-        }
-        else if (isOnOffStr.Search ("disp") >= 0 || isOnOffStr.Search ("show") >= 0)
-        {
-          // avoid z-fighting glitches
-          aView->SetPlaneOff (aPlaneV3d);
-          aPlaneV3d->Display (aView);
-          std::cout << "Clipping plane #" << aPlaneId << " was shown and disabled\n";
-        }
-        else if (isOnOffStr.Search ("hide") >= 0)
-        {
-          aPlaneV3d->Erase();
-          std::cout << "Clipping plane #" << aPlaneId << " was hidden\n";
-        }
-        else
-        {
-          std::cout << "Usage: " << argv[0] << " [x y z dx dy dz] [planeId {on/off/del/display/hide}]\n";
-          return 1;
-        }
-      }
-    }
-    if (aPlaneIdToOff >= aPlaneId && !toIterateAll)
-    {
-      std::cout << "Clipping plane with id " << aPlaneIdToOff << " not found!\n";
-      return 1;
-    }
-    aView->Update();
-    return 0;
-  }
-  else if (argc != 7)
-  {
-    std::cout << "Usage: " << argv[0] << " [x y z dx dy dz] [planeId {on/off/del/display/hide}]\n";
-    return 1;
-  }
-
-  Standard_Real aLocX = atof (argv[1]);
-  Standard_Real aLocY = atof (argv[2]);
-  Standard_Real aLocZ = atof (argv[3]);
-  Standard_Real aNormDX = atof (argv[4]);
-  Standard_Real aNormDY = atof (argv[5]);
-  Standard_Real aNormDZ = atof (argv[6]);
-
-  Handle(V3d_Plane) aPlaneV3d = new V3d_Plane();
-  gp_Pln aPlane (gp_Pnt (aLocX, aLocY, aLocZ), gp_Dir (aNormDX, aNormDY, aNormDZ));
-  aPlane.Coefficients (coeffA, coeffB, coeffC, coeffD);
-  aPlaneV3d->SetPlane(coeffA, coeffB, coeffC, coeffD);
-
-  aViewer->AddPlane (aPlaneV3d); // add to defined planes list
-  std::cout << "Added clipping plane #" << aNewPlaneId << "\n";
-  if (anActivePlanes < aView->View()->PlaneLimit())
-  {
-    aView->SetPlaneOn (aPlaneV3d); // add to enabled planes list
-    aView->Update();
-  }
-  else
-  {
-    std::cout << "Maximal active planes limit exceeded (" << anActivePlanes << ")\n"
-              << "You should disable or remove some existing plane to activate the new one\n";
-  }
-  return 0;
-}
-
-//=============================================================================
-//function : VComputeHLR
-//purpose  :
-//=============================================================================
-
-static int VComputeHLR (Draw_Interpretor& di,
-                        Standard_Integer argc,
-                        const char** argv)
-{
-  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
-
-  if (aContextAIS.IsNull ())
-  {
-    di << "Please call vinit before\n";
-    return 1;
-  }
-
-  if ( argc != 3 &&  argc != 12 )
-  {
-    di << "Usage: " << argv[0] << " ShapeName HlrName "
-       << "[ eye_x eye_y eye_z dir_x dir_y dir_z upx upy upz ]" << "\n"
-       << "                    ShapeName - name of the initial shape\n"
-       << "                    HlrName - result hlr object from initial shape\n"
-       << "                    eye, dir are eye position and look direction\n"
-       << "                    up is the look up direction vector\n"
-       << "                    Use vtop to see projected hlr shape\n";
-    return 1;
+    di << "Usage: " << argv[0] << " ShapeName HlrName "
+       << "[ eye_x eye_y eye_z dir_x dir_y dir_z upx upy upz ]" << "\n"
+       << "                    ShapeName - name of the initial shape\n"
+       << "                    HlrName - result hlr object from initial shape\n"
+       << "                    eye, dir are eye position and look direction\n"
+       << "                    up is the look up direction vector\n"
+       << "                    Use vtop to see projected hlr shape\n";
+    return 1;
   }
 
   // shape and new object name
@@ -2835,9 +3062,9 @@ static int VComputeHLR (Draw_Interpretor& di,
   {
     gp_Dir anUp;
 
-    anEye.SetCoord (atof (argv[3]), atof (argv[4]), atof (argv[5]));
-    aDir.SetCoord (atof (argv[6]), atof (argv[7]), atof (argv[8]));
-    anUp.SetCoord (atof (argv[9]), atof (argv[10]), atof (argv[11]));
+    anEye.SetCoord (Draw::Atof (argv[3]), Draw::Atof (argv[4]), Draw::Atof (argv[5]));
+    aDir.SetCoord (Draw::Atof (argv[6]), Draw::Atof (argv[7]), Draw::Atof (argv[8]));
+    anUp.SetCoord (Draw::Atof (argv[9]), Draw::Atof (argv[10]), Draw::Atof (argv[11]));
     aProjAx.SetLocation (anEye);
     aProjAx.SetDirection (aDir);
     aProjAx.SetYDirection (anUp);
@@ -2912,9 +3139,11 @@ class MyPArrayObject : public AIS_InteractiveObject
 
 public:
 
-  MyPArrayObject (const Handle(Graphic3d_ArrayOfPrimitives) theArray)
+  MyPArrayObject (Handle(TColStd_HArray1OfAsciiString) theArrayDescription,
+                  Handle(Graphic3d_AspectMarker3d) theMarkerAspect = NULL)
   {
-    myArray = theArray;
+    myArrayDescription = theArrayDescription;
+    myMarkerAspect = theMarkerAspect;
   }
 
   DEFINE_STANDARD_RTTI(MyPArrayObject);
@@ -2925,170 +3154,94 @@ private:
                 const Handle(Prs3d_Presentation)& aPresentation,
                 const Standard_Integer aMode);
 
-  void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
-                         const Standard_Integer aMode) {};
+  void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+                         const Standard_Integer /*theMode*/);
+
+  bool CheckInputCommand (const TCollection_AsciiString theCommand,
+                          const Handle(TColStd_HArray1OfAsciiString) theArgsArray,
+                          Standard_Integer &theArgIndex,
+                          Standard_Integer theArgCount,
+                          Standard_Integer theMaxArgs);
 
 protected:
 
-  Handle(Graphic3d_ArrayOfPrimitives) myArray;
+  Handle(TColStd_HArray1OfAsciiString) myArrayDescription;
+  Handle(Graphic3d_AspectMarker3d) myMarkerAspect;
 
 };
 
 IMPLEMENT_STANDARD_HANDLE(MyPArrayObject, AIS_InteractiveObject)
 IMPLEMENT_STANDARD_RTTIEXT(MyPArrayObject, AIS_InteractiveObject)
 
-void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
                               const Handle(Prs3d_Presentation)& aPresentation,
-                              const Standard_Integer aMode)
-{
-  aPresentation->Clear();
-
-  Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPresentation);
-  aGroup->BeginPrimitives ();
-  aGroup->AddPrimitiveArray (myArray);
-  aGroup->EndPrimitives ();
-}
-
-static bool CheckInputCommand (const TCollection_AsciiString theCommand,
-                               const char **theArgStr, int &theArgIndex,
-                               int theArgCount, int theMaxArgs)
-{
-  // check if there is more elements than expected
-  if (theArgIndex >= theMaxArgs)
-    return false;
-
-  TCollection_AsciiString aStrCommand(theArgStr[theArgIndex]);
-  aStrCommand.LowerCase();
-  if (aStrCommand.Search(theCommand) != 1 ||
-      theArgIndex + (theArgCount - 1) >= theMaxArgs)
-    return false;
-
-  // go to the first data element
-  theArgIndex++;
-
-  // check data if it can be converted to numeric
-  for (int aElement = 0; aElement < theArgCount; aElement++, theArgIndex++)
-  {
-    aStrCommand = theArgStr[theArgIndex];
-    if (!aStrCommand.IsRealValue())
-      return false;
-  }
-
-  return true;
-}
-
-//=============================================================================
-//function : VDrawPArray
-//purpose  : Draws primitives array from list of vertexes, bounds, edges
-//=============================================================================
-
-static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+                              const Standard_Integer /*aMode*/)
 {
-  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
-  if (aContextAIS.IsNull())
-  {
-    di << "Call vinit before!\n";
-    return 1;
-  }
-  else if (argc < 3)
-  {
-    di << "Use: " << argv[0] << " Name TypeOfArray [EnableVBO={0 | 1}]"
-       << " [vertex] ... [bounds] ... [edges]\n"
-       << "  TypeOfArray={ points | segments | polylines | triangles |\n"
-       << "                trianglefan | trianglestrips | quads |\n"
-       << "                quadstrips | polygons }\n"
-       << "  vertex={ 'v' x y z [normal={ 'n' nx ny nz }] [color={ 'c' r g b }]"
-       << " [texel={ 't' tx ty }] } \n"
-       << "  bounds={ 'b' verticies_count [color={ 'c' r g b }] }\n"
-       << "  edges={ 'e' vertex_id [hidden_edge={'h'}] }\n";
-    return 1;
-  }
-
-  // read the arguments
-  TCollection_AsciiString aName (argv[1]);
-  TCollection_AsciiString anArrayType (argv[2]);
-  
-  // is argument list has an vbo flag
-  Standard_Boolean hasFlagVbo = Standard_False;
-  if (isdigit (argv[3][0]) && atoi (argv[3]) >= 0 && atoi (argv[3]) <= 1)
-    hasFlagVbo = Standard_True;
 
-  // parse number of verticies, bounds, edges
+  // Parsing array description
   Standard_Integer aVertexNum = 0, aBoundNum = 0, aEdgeNum = 0;
-  Standard_Boolean hasVColors, hasBColors, hasNormals, hasInfos, hasTexels;
-  hasVColors = hasNormals = hasBColors = hasInfos = hasTexels = Standard_False;
+  Standard_Boolean hasVColors, hasBColors, hasNormals, hasTexels;
+  hasVColors = hasNormals = hasBColors = hasTexels = Standard_False;
+
+  Standard_Integer anArgIndex = 0;
+  Standard_Integer anArgsCount = myArrayDescription->Length();
+  TCollection_AsciiString anArrayType = myArrayDescription->Value (anArgIndex++);
 
-  Standard_Integer aArgIndex = (hasFlagVbo) ? 4 : 3;
   TCollection_AsciiString aCommand;
-  while (aArgIndex < argc)
+  while (anArgIndex < anArgsCount)
   {
-    aCommand = argv[aArgIndex];
+    aCommand = myArrayDescription->Value (anArgIndex);
     aCommand.LowerCase();
-    if (!aCommand.IsAscii())
-    {
-      di << "Unexpected argument: #" << aArgIndex - 1 << " , "
-         << "should be an array element: 'v', 'b', 'e' \n";
-      break;
-    }
 
     // vertex command
-    if (CheckInputCommand ("v", argv, aArgIndex, 3, argc))
+    if (CheckInputCommand ("v", myArrayDescription, anArgIndex, 3, anArgsCount))
     {
       // vertex has a normal or normal with color or texel
-      if (CheckInputCommand ("n", argv, aArgIndex, 3, argc))
+      if (CheckInputCommand ("n", myArrayDescription, anArgIndex, 3, anArgsCount))
         hasNormals = Standard_True;
 
       // vertex has a color
-      if (CheckInputCommand ("c", argv, aArgIndex, 3, argc))
+      if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
         hasVColors = Standard_True;
 
       // vertex has a texel
-      if (CheckInputCommand ("t", argv, aArgIndex, 2, argc))
+      if (CheckInputCommand ("t", myArrayDescription, anArgIndex, 2, anArgsCount))
         hasTexels = Standard_True;
 
       aVertexNum++;
     }
     // bound command
-    else if (CheckInputCommand ("b", argv, aArgIndex, 1, argc))
+    else if (CheckInputCommand ("b", myArrayDescription, anArgIndex, 1, anArgsCount))
     {
       // bound has color
-      if (CheckInputCommand ("c", argv, aArgIndex, 3, argc))
+      if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
         hasBColors = Standard_True;
 
       aBoundNum++;
     }
     // edge command
-    else if (CheckInputCommand ("e", argv, aArgIndex, 1, argc))
+    else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
     {
-      // edge has a hide flag
-      if (CheckInputCommand ("h", argv, aArgIndex, 0, argc))
-        hasInfos = Standard_True;
-
       aEdgeNum++;
     }
     // unknown command
     else
-      aArgIndex++;
-  }
-
-  if (aVertexNum == 0)
-  {
-    di << "You should pass any verticies in the list of array elements\n";
-    return 1;
+      anArgIndex++;
   }
 
-  // create an array of primitives by types
   Handle(Graphic3d_ArrayOfPrimitives) anArray;
   if (anArrayType == "points")
+  {
     anArray = new Graphic3d_ArrayOfPoints (aVertexNum);
+  }
   else if (anArrayType == "segments")
     anArray = new Graphic3d_ArrayOfSegments (aVertexNum, aEdgeNum, hasVColors);
   else if (anArrayType == "polylines")
     anArray = new Graphic3d_ArrayOfPolylines (aVertexNum, aBoundNum, aEdgeNum,
-                                              hasVColors, hasBColors, hasInfos);
+                                              hasVColors, hasBColors);
   else if (anArrayType == "triangles")
     anArray = new Graphic3d_ArrayOfTriangles (aVertexNum, aEdgeNum, hasNormals,
-                                              hasVColors, hasTexels, hasInfos);
+                                              hasVColors, hasTexels);
   else if (anArrayType == "trianglefans")
     anArray = new Graphic3d_ArrayOfTriangleFans (aVertexNum, aBoundNum,
                                                  hasNormals, hasVColors,
@@ -3100,7 +3253,7 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
   else if (anArrayType == "quads")
     anArray = new Graphic3d_ArrayOfQuadrangles (aVertexNum, aEdgeNum,
                                                 hasNormals, hasVColors,
-                                                hasTexels, hasInfos);
+                                                hasTexels);
   else if (anArrayType == "quadstrips")
     anArray = new Graphic3d_ArrayOfQuadrangleStrips (aVertexNum, aBoundNum,
                                                      hasNormals, hasVColors,
@@ -3108,90 +3261,213 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
   else if (anArrayType == "polygons")
     anArray = new Graphic3d_ArrayOfPolygons (aVertexNum, aBoundNum, aEdgeNum,
                                              hasNormals, hasVColors, hasBColors,
-                                             hasTexels, hasInfos);
-  else
-  {
-    di << "Unexpected type of primitiives array\n";
-    return 1;
-  }
+                                             hasTexels);
 
-  // parse an array of primitives
-  aArgIndex = (hasFlagVbo) ? 4 : 3;
-  while (aArgIndex < argc)
+  anArgIndex = 1;
+  while (anArgIndex < anArgsCount)
   {
-    aCommand = argv[aArgIndex];
+    aCommand = myArrayDescription->Value (anArgIndex);
     aCommand.LowerCase();
     if (!aCommand.IsAscii())
       break;
 
     // vertex command
-    if (CheckInputCommand ("v", argv, aArgIndex, 3, argc))
+    if (CheckInputCommand ("v", myArrayDescription, anArgIndex, 3, anArgsCount))
     {
-      anArray->AddVertex (atof (argv[aArgIndex - 3]),
-                          atof (argv[aArgIndex - 2]),
-                          atof (argv[aArgIndex - 1]));
+      anArray->AddVertex (myArrayDescription->Value (anArgIndex - 3).RealValue(),
+                          myArrayDescription->Value (anArgIndex - 2).RealValue(),
+                          myArrayDescription->Value (anArgIndex - 1).RealValue());
+      const Standard_Integer aVertIndex = anArray->VertexNumber();
 
       // vertex has a normal or normal with color or texel
-      if (CheckInputCommand ("n", argv, aArgIndex, 3, argc))
-        anArray->SetVertexNormal (anArray->VertexNumber (),
-                                  atof (argv[aArgIndex - 3]),
-                                  atof (argv[aArgIndex - 2]),
-                                  atof (argv[aArgIndex - 1]));
+      if (CheckInputCommand ("n", myArrayDescription, anArgIndex, 3, anArgsCount))
+        anArray->SetVertexNormal (aVertIndex,
+                                  myArrayDescription->Value (anArgIndex - 3).RealValue(),
+                                  myArrayDescription->Value (anArgIndex - 2).RealValue(),
+                                  myArrayDescription->Value (anArgIndex - 1).RealValue());
       
-      if (CheckInputCommand ("c", argv, aArgIndex, 3, argc))
-        anArray->SetVertexColor (anArray->VertexNumber (),
-                                 atof (argv[aArgIndex - 3]),
-                                 atof (argv[aArgIndex - 2]),
-                                 atof (argv[aArgIndex - 1]));
+      if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
+        anArray->SetVertexColor (aVertIndex,
+                                 myArrayDescription->Value (anArgIndex - 3).RealValue(),
+                                 myArrayDescription->Value (anArgIndex - 2).RealValue(),
+                                 myArrayDescription->Value (anArgIndex - 1).RealValue());
       
-      if (CheckInputCommand ("t", argv, aArgIndex, 2, argc))
-        anArray->SetVertexTexel (anArray->VertexNumber (),
-                                 atof (argv[aArgIndex - 2]),
-                                 atof (argv[aArgIndex - 1]));
+      if (CheckInputCommand ("t", myArrayDescription, anArgIndex, 2, anArgsCount))
+        anArray->SetVertexTexel (aVertIndex,
+                                 myArrayDescription->Value (anArgIndex - 2).RealValue(),
+                                 myArrayDescription->Value (anArgIndex - 1).RealValue());
     }
     // bounds command
-    else if (CheckInputCommand ("b", argv, aArgIndex, 1, argc))
+    else if (CheckInputCommand ("b", myArrayDescription, anArgIndex, 1, anArgsCount))
     {
-      Standard_Integer aVertCount = atoi (argv[aArgIndex - 1]);
+      Standard_Integer aVertCount = myArrayDescription->Value (anArgIndex - 1).IntegerValue();
 
-      if (CheckInputCommand ("c", argv, aArgIndex, 3, argc))
+      if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
         anArray->AddBound (aVertCount,
-                           atof (argv[aArgIndex - 3]),
-                           atof (argv[aArgIndex - 2]),
-                           atof (argv[aArgIndex - 1]));
+                           myArrayDescription->Value (anArgIndex - 3).RealValue(),
+                           myArrayDescription->Value (anArgIndex - 2).RealValue(),
+                           myArrayDescription->Value (anArgIndex - 1).RealValue());
 
       else
         anArray->AddBound (aVertCount);
     }
     // edge command
-    else if (CheckInputCommand ("e", argv, aArgIndex, 1, argc))
+    else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
     {
-      Standard_Integer aVertIndex = atoi (argv[aArgIndex - 1]);
-
-      // edge has/hasn't hide flag
-      if (CheckInputCommand ("h", argv, aArgIndex, 0, argc))
-        anArray->AddEdge (aVertIndex, Standard_False);
-      else
-        anArray->AddEdge (aVertIndex, Standard_True);
+      const Standard_Integer aVertIndex = myArrayDescription->Value (anArgIndex - 1).IntegerValue();
+      anArray->AddEdge (aVertIndex);
     }
     // unknown command
     else
-      aArgIndex++;
+      anArgIndex++;
+  }
+
+  aPresentation->Clear();
+  if (!myMarkerAspect.IsNull())
+  {
+    Prs3d_Root::CurrentGroup (aPresentation)->SetGroupPrimitivesAspect (myMarkerAspect);
+  }
+  Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (anArray);
+}
+
+void MyPArrayObject::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+                                       const Standard_Integer /*theMode*/)
+{
+  Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this);
+
+  Standard_Integer anArgIndex = 1;
+  while (anArgIndex < myArrayDescription->Length())
+  {
+    if (CheckInputCommand ("v", myArrayDescription, anArgIndex, 3, myArrayDescription->Length()))
+    {
+      gp_Pnt aPoint (myArrayDescription->Value (anArgIndex - 3).RealValue(),
+                     myArrayDescription->Value (anArgIndex - 2).RealValue(),
+                     myArrayDescription->Value (anArgIndex - 1).RealValue());
+      Handle(Select3D_SensitivePoint) aSensetivePoint = new Select3D_SensitivePoint (anEntityOwner, aPoint);
+      theSelection->Add (aSensetivePoint);
+    }
+    else
+    {
+      anArgIndex++;
+    }
+  }
+}
+
+bool MyPArrayObject::CheckInputCommand (const TCollection_AsciiString theCommand,
+                                       const Handle(TColStd_HArray1OfAsciiString) theArgsArray,
+                                       Standard_Integer &theArgIndex,
+                                       Standard_Integer theArgCount,
+                                       Standard_Integer theMaxArgs)
+{
+  // check if there is more elements than expected
+  if (theArgIndex >= theMaxArgs)
+    return false;
+
+  TCollection_AsciiString aStrCommand = theArgsArray->Value (theArgIndex);
+  aStrCommand.LowerCase();
+  if (aStrCommand.Search(theCommand) != 1 ||
+      theArgIndex + (theArgCount - 1) >= theMaxArgs)
+    return false;
+
+  // go to the first data element
+  theArgIndex++;
+
+  // check data if it can be converted to numeric
+  for (int aElement = 0; aElement < theArgCount; aElement++, theArgIndex++)
+  {
+    aStrCommand = theArgsArray->Value (theArgIndex);
+    if (!aStrCommand.IsRealValue())
+      return false;
+  }
+
+  return true;
+}
+
+//=============================================================================
+//function : VDrawPArray
+//purpose  : Draws primitives array from list of vertexes, bounds, edges
+//=============================================================================
+
+static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+  if (aContextAIS.IsNull())
+  {
+    di << "Call vinit before!\n";
+    return 1;
+  }
+  else if (argc < 3)
+  {
+    di << "Use: " << argv[0] << " Name TypeOfArray"
+       << " [vertex] ... [bounds] ... [edges]\n"
+       << "  TypeOfArray={ points | segments | polylines | triangles |\n"
+       << "                trianglefans | trianglestrips | quads |\n"
+       << "                quadstrips | polygons }\n"
+       << "  vertex={ 'v' x y z [normal={ 'n' nx ny nz }] [color={ 'c' r g b }]"
+       << " [texel={ 't' tx ty }] } \n"
+       << "  bounds={ 'b' verticies_count [color={ 'c' r g b }] }\n"
+       << "  edges={ 'e' vertex_id }\n";
+    return 1;
+  }
+
+  // read the arguments
+  Standard_Integer aArgIndex = 1;
+  TCollection_AsciiString aName (argv[aArgIndex++]);
+  TCollection_AsciiString anArrayType (argv[aArgIndex++]);
+
+  Standard_Boolean hasVertex = Standard_False;
+
+  Handle(TColStd_HArray1OfAsciiString) anArgsArray = new TColStd_HArray1OfAsciiString (0, argc - 2);
+  anArgsArray->SetValue (0, anArrayType);
+
+  if (anArrayType != "points"         &&
+      anArrayType != "segments"       &&
+      anArrayType != "polylines"      &&
+      anArrayType != "triangles"      &&
+      anArrayType != "trianglefans"   &&
+      anArrayType != "trianglestrips" &&
+      anArrayType != "quads"          &&
+      anArrayType != "quadstrips"     &&
+      anArrayType != "polygons")
+  {
+    di << "Unexpected type of primitives array\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aCommand;
+  for (Standard_Integer anArgIndex = 3; anArgIndex < argc; anArgIndex++)
+  {
+    aCommand = argv[anArgIndex];
+    aCommand.LowerCase();
+    if (!aCommand.IsAscii())
+    {
+      di << "Unexpected argument: #" << aArgIndex - 1 << " , "
+         << "should be an array element: 'v', 'b', 'e' \n";
+      break;
+    }
+
+    if (aCommand == "v")
+    {
+      hasVertex = Standard_True;
+    }
+
+    anArgsArray->SetValue (anArgIndex - 2, aCommand);
   }
 
-  if (hasFlagVbo)
+  if (!hasVertex)
   {
-    // enable / disable vbo
-    Handle(Graphic3d_GraphicDriver) aDriver =
-      Handle(Graphic3d_GraphicDriver)::DownCast (
-                      aContextAIS->CurrentViewer()->Device()->GraphicDriver());
+    di << "You should pass any verticies in the list of array elements\n";
+    return 1;
+  }
 
-    if (!aDriver.IsNull())
-      aDriver->EnableVBO ((Standard_Boolean) atoi (argv[3]));
+  Handle(Graphic3d_AspectMarker3d)    anAspPoints;
+  if (anArrayType == "points")
+  {
+    anAspPoints = new Graphic3d_AspectMarker3d (Aspect_TOM_POINT, Quantity_NOC_YELLOW, 1.0f);
   }
 
   // create primitives array object
-  Handle (MyPArrayObject) aPObject = new MyPArrayObject (anArray);
+  Handle(MyPArrayObject) aPObject = new MyPArrayObject (anArgsArray, anAspPoints);
 
   // register the object in map
   VDisplayAISObject (aName, aPObject);
@@ -3204,34 +3480,34 @@ static int VDrawPArray (Draw_Interpretor& di, Standard_Integer argc, const char*
 //purpose  : Change location of AIS interactive object
 //=======================================================================
 
-static Standard_Integer VSetLocation (Draw_Interpretor& di,
+static Standard_Integer VSetLocation (Draw_Interpretor& /*di*/,
                                       Standard_Integer argc,
                                       const char ** argv)
 {
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+    std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n";
     return 1;
   }
 
   if (argc != 5)
   {
-    di << "ERROR : Usage : " << argv[0] << " name x y z; new location" << "\n";
+    std::cout << "ERROR : Usage : " << argv[0] << " name x y z; new location" << "\n";
     return 1;
   }
 
   TCollection_AsciiString aName (argv[1]);
-  Standard_Real aX = atof (argv[2]);
-  Standard_Real aY = atof (argv[3]);
-  Standard_Real aZ = atof (argv[4]);
+  Standard_Real aX = Draw::Atof (argv[2]);
+  Standard_Real aY = Draw::Atof (argv[3]);
+  Standard_Real aZ = Draw::Atof (argv[4]);
 
   // find object
   ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
   Handle(AIS_InteractiveObject) anIObj;
   if (!aMap.IsBound2 (aName))
   {
-    di << "Use 'vdisplay' before" << "\n";
+    std::cout << "Use 'vdisplay' before" << "\n";
     return 1;
   }
   else
@@ -3241,7 +3517,7 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
     // not an AIS_InteractiveObject
     if (anIObj.IsNull())
     {
-      di << argv[1] << " : Not an AIS interactive object" << "\n";
+      std::cout << argv[1] << " : Not an AIS interactive object" << "\n";
       return 1;
     }
 
@@ -3255,12 +3531,1827 @@ static Standard_Integer VSetLocation (Draw_Interpretor& di,
   return 0;
 }
 
-//=======================================================================
-//function : ObjectsCommands
-//purpose  :
-//=======================================================================
+//===============================================================================================
+//function : VConnect
+//purpose  : Creates and displays AIS_ConnectedInteractive object from input object and location 
+//Draw arg : vconnect name Xo Yo Zo object1 object2 ... [color=NAME]
+//===============================================================================================
 
-void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
+static Standard_Integer VConnect (Draw_Interpretor& /*di*/, 
+                                  Standard_Integer argc, 
+                                  const char ** argv) 
+{
+  // Check the viewer
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << "vconnect error : call vinit before\n";
+    return 1; // TCL_ERROR
+  }
+  // Check argumnets 
+  if (argc < 6)
+  {
+    std::cout << "vconnect error: expect at least 5 arguments\n";
+    return 1; // TCL_ERROR
+  }
+
+  // Get values
+  Standard_Integer anArgIter = 1;
+  TCollection_AsciiString aName (argv[anArgIter++]);
+  Handle(AIS_MultipleConnectedInteractive) anOriginObject;
+  TCollection_AsciiString aColorString (argv[argc-1]);
+  Standard_CString aColorName = "";
+  Standard_Boolean hasColor = Standard_False;
+  if (aColorString.Search ("color=") != -1)
+  {
+    hasColor = Standard_True;
+    aColorString.Remove (1, 6);
+    aColorName = aColorString.ToCString();
+  }
+  Handle(AIS_InteractiveObject) anObject;
+
+  // AIS_MultipleConnectedInteractive
+  const Standard_Integer aNbShapes = hasColor ? (argc - 1) : argc;
+  for (Standard_Integer i = 5; i < aNbShapes; ++i)
+  {
+    TCollection_AsciiString anOriginObjectName (argv[i]);
+    if (aName.IsEqual (anOriginObjectName))
+    {
+      std::cout << "vconnect error: equal names for connected objects\n";
+      continue;
+    }
+    if (GetMapOfAIS().IsBound2 (anOriginObjectName))
+    {
+      Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
+      anObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
+      if (anObject.IsNull())
+      {
+        std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
+        continue;
+      }
+    }
+    else
+    {
+      Standard_CString aName = anOriginObjectName.ToCString();
+      TopoDS_Shape aTDShape = DBRep::Get (aName);
+      if (aTDShape.IsNull())
+      {
+        std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
+        continue;
+      }
+      anObject = new AIS_Shape (aTDShape);
+      anObject->SetColor (ViewerTest::GetColorFromName (aColorName));
+    }
+
+    if (anOriginObject.IsNull())
+    {
+      anOriginObject = new AIS_MultipleConnectedInteractive();
+    }
+
+    anOriginObject->Connect (anObject);
+  }
+  if (anOriginObject.IsNull())
+  {
+    std::cout << "vconect error : can't connect input objects\n";
+    return 1; // TCL_ERROR
+  }
+
+  // Get location data
+  Standard_Real aXo = Draw::Atof (argv[anArgIter++]);
+  Standard_Real aYo = Draw::Atof (argv[anArgIter++]);
+  Standard_Real aZo = Draw::Atof (argv[anArgIter++]);
+
+  // Create transformation
+  gp_Vec aTranslation (aXo, aYo, aZo);
+
+  gp_Trsf aTrsf; 
+  aTrsf.SetTranslationPart (aTranslation);
+  TopLoc_Location aLocation (aTrsf);
+
+  anOriginObject->SetLocalTransformation (aTrsf);
+
+  // Check if there is another object with given name
+  // and remove it from context
+  if(GetMapOfAIS().IsBound2(aName))
+  {
+    Handle(AIS_InteractiveObject) anObj = 
+      Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
+    TheAISContext()->Remove(anObj, Standard_False);
+    GetMapOfAIS().UnBind2(aName);
+  }
+
+  // Bind connected object to its name
+  GetMapOfAIS().Bind (anOriginObject, aName);
+
+  // Display connected object
+  TheAISContext()->Display (anOriginObject);
+
+  return 0;
+}
+
+//===============================================================================================
+//function : VConnectTo
+//purpose  : Creates and displays AIS_ConnectedInteractive object from input object and location 
+//Draw arg : vconnectto name Xo Yo Zo object
+//===============================================================================================
+
+static Standard_Integer VConnectTo (Draw_Interpretor& /*di*/, 
+                                    Standard_Integer argc, 
+                                    const char ** argv) 
+{
+  // Check the viewer
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << "vconnect error : call vinit before\n";
+    return 1; // TCL_ERROR
+  }
+  // Check argumnets 
+  if (argc != 6)
+  {
+    std::cout << "vconnect error: expect at least 5 arguments\n";
+    return 1; // TCL_ERROR
+  }
+
+  // Get values
+  Standard_Integer anArgIter = 1;
+  TCollection_AsciiString aName (argv[anArgIter++]);
+  Handle(AIS_InteractiveObject) anOriginObject;
+
+  TCollection_AsciiString anOriginObjectName(argv[5]);
+  if (aName.IsEqual (anOriginObjectName))
+  {
+    std::cout << "vconnect error: equal names for connected objects\n"; 
+    return 1; // TCL_ERROR
+  }
+  if (GetMapOfAIS().IsBound2 (anOriginObjectName))
+  {
+    Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (anOriginObjectName);
+    anOriginObject = Handle(AIS_InteractiveObject)::DownCast(anObj);
+    if (anOriginObject.IsNull())
+    {
+      std::cout << "Object " << anOriginObjectName << " is used for non AIS viewer\n";
+      return 1; // TCL_ERROR
+    }
+  }
+  else
+  {
+    Standard_CString aName = anOriginObjectName.ToCString();
+    TopoDS_Shape aTDShape = DBRep::Get (aName);
+    if (aTDShape.IsNull())
+    {
+      std::cout << "vconnect error: object " << anOriginObjectName << " doesn't exist\n";
+      return 1; // TCL_ERROR
+    }
+    anOriginObject = new AIS_Shape (aTDShape);
+  }
+  // Get location data
+  Standard_Real aXo = Draw::Atof (argv[anArgIter++]);
+  Standard_Real aYo = Draw::Atof (argv[anArgIter++]);
+  Standard_Real aZo = Draw::Atof (argv[anArgIter++]);
+
+  // Create transformation
+  gp_Vec aTranslation (aXo, aYo, aZo);
+
+  gp_Trsf aTrsf; 
+  aTrsf.SetTranslationPart (aTranslation);
+  Handle(AIS_ConnectedInteractive) aConnected;
+
+  aConnected = new AIS_ConnectedInteractive();
+
+  aConnected->Connect (anOriginObject, aTrsf);
+
+  // Check if there is another object with given name
+  // and remove it from context
+  if(GetMapOfAIS().IsBound2(aName))
+  {
+    Handle(AIS_InteractiveObject) anObj = 
+      Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
+    TheAISContext()->Remove(anObj, Standard_False);
+    GetMapOfAIS().UnBind2(aName);
+  }
+
+  // Bind connected object to its name
+  GetMapOfAIS().Bind (aConnected, aName);
+
+  // Display connected object
+  TheAISContext()->Display (aConnected);
+
+  return 0;
+}
+
+//=======================================================================
+//function : VDisconnect
+//purpose  :
+//=======================================================================
+static Standard_Integer VDisconnect (Draw_Interpretor& di,
+                                     Standard_Integer argc,
+                                     const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+    return 1;
+  }
+  
+  if (argc != 3)
+  {
+    std::cout << "ERROR : Usage : " << argv[0] << " name object" << "\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aName (argv[1]);
+  TCollection_AsciiString anObject (argv[2]);
+  Standard_Integer anObjectNumber = Draw::Atoi (argv[2]);
+
+  // find objects
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  Handle(AIS_MultipleConnectedInteractive) anAssembly;
+  if (!aMap.IsBound2 (aName) )
+  {
+    std::cout << "Use 'vdisplay' before" << "\n";
+    return 1;
+  }
+
+  anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
+  if (anAssembly.IsNull())
+  {
+    di << "Not an assembly" << "\n";
+    return 1;
+  }
+
+  Handle(AIS_InteractiveObject) anIObj;
+  if (!aMap.IsBound2 (anObject))
+  {
+    // try to interpret second argument as child number
+    if (anObjectNumber > 0 && anObjectNumber <= anAssembly->Children().Size())
+    {
+      Standard_Integer aCounter = 1;
+      for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next())
+      {
+        if (aCounter == anObjectNumber)
+        {
+          anIObj = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
+          break;
+        }
+        ++aCounter;
+      }
+    }
+    else
+    {
+      std::cout << "Use 'vdisplay' before" << "\n";
+      return 1;
+    }    
+  }
+
+  // if object was found by name
+  if (anIObj.IsNull())
+  {
+    anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject));
+  }
+
+  anAssembly->Disconnect (anIObj);
+  aContext->UpdateCurrentViewer();
+
+  return 0;
+}
+
+//=======================================================================
+//function : VAddConnected
+//purpose  :
+//=======================================================================
+static Standard_Integer VAddConnected (Draw_Interpretor& di,
+                                       Standard_Integer argc,
+                                       const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << argv[0] << "error : use 'vinit' command before " << "\n";
+    return 1;
+  }
+  
+  if (argc != 6)
+  {
+    std::cout << argv[0] << " error: expect 5 arguments\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aName (argv[1]);
+  TCollection_AsciiString anObject (argv[5]);
+  Standard_Real aX = Draw::Atof (argv[2]);
+  Standard_Real aY = Draw::Atof (argv[3]);
+  Standard_Real aZ = Draw::Atof (argv[4]);
+
+  // find object
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  Handle(AIS_MultipleConnectedInteractive) anAssembly;
+  if (!aMap.IsBound2 (aName) )
+  {
+    std::cout << "Use 'vdisplay' before" << "\n";
+    return 1;
+  }
+
+  anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
+  if (anAssembly.IsNull())
+  {
+    di << "Not an assembly" << "\n";
+    return 1;
+  }
+
+  Handle(AIS_InteractiveObject) anIObj;
+  if (!aMap.IsBound2 (anObject))
+  {
+      std::cout << "Use 'vdisplay' before" << "\n";
+      return 1; 
+  }
+
+  anIObj = Handle(AIS_InteractiveObject)::DownCast (aMap.Find2 (anObject));
+
+  gp_Trsf aTrsf;
+  aTrsf.SetTranslation (gp_Vec (aX, aY, aZ));
+  anAssembly->Connect (anIObj, aTrsf);
+  TheAISContext()->Display (anAssembly);
+  TheAISContext()->RecomputeSelectionOnly (anAssembly);
+  aContext->UpdateCurrentViewer();
+
+  return 0;
+}
+
+//=======================================================================
+//function : VListConnected
+//purpose  :
+//=======================================================================
+static Standard_Integer VListConnected (Draw_Interpretor& /*di*/,
+                                        Standard_Integer argc,
+                                        const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << argv[0] << "ERROR : use 'vinit' command before " << "\n";
+    return 1;
+  }
+  
+  if (argc != 2)
+  {
+    std::cout << "ERROR : Usage : " << argv[0] << " name" << "\n";
+    return 1;
+  }
+
+  TCollection_AsciiString aName (argv[1]);
+
+  // find object
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  Handle(AIS_MultipleConnectedInteractive) anAssembly;
+  if (!aMap.IsBound2 (aName) )
+  {
+    std::cout << "Use 'vdisplay' before" << "\n";
+    return 1;
+  }
+
+  anAssembly = Handle(AIS_MultipleConnectedInteractive)::DownCast (aMap.Find2 (aName));
+  if (anAssembly.IsNull())
+  {
+    std::cout << "Not an assembly" << "\n";
+    return 1;
+  }
+
+  std::cout << "Children of " << aName << ":\n";
+
+  Standard_Integer aCounter = 1;
+  for (PrsMgr_ListOfPresentableObjectsIter anIter (anAssembly->Children()); anIter.More(); anIter.Next())
+  {
+    if (GetMapOfAIS().IsBound1 (anIter.Value()))
+    {
+      TCollection_AsciiString aName = GetMapOfAIS().Find1 (anIter.Value());
+      std::cout << aCounter << ")  " << aName << "    (" << anIter.Value()->DynamicType()->Name() << ")";
+    }
+
+    std::cout << aCounter << ")  " << anIter.Value()->DynamicType()->Name();
+
+    Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (anIter.Value());
+    if (!aConnected.IsNull() && !aConnected->ConnectedTo().IsNull() && aMap.IsBound1 (aConnected->ConnectedTo()))
+    {
+      std::cout << " connected to " << aMap.Find1 (aConnected->ConnectedTo());
+    }
+    std::cout << std::endl;
+    
+    ++aCounter;
+  }
+
+  return 0;
+}
+
+namespace
+{
+  //! Checks if theMode is already turned on for theObj.
+  static Standard_Boolean InList (const Handle(AIS_InteractiveContext)& theAISContext,
+                                  const Handle(AIS_InteractiveObject)&  theObj,
+                                  const Standard_Integer                theMode)
+  {
+    TColStd_ListOfInteger anActiveModes;
+    theAISContext->ActivatedModes (theObj, anActiveModes);
+    for (TColStd_ListIteratorOfListOfInteger aModeIt (anActiveModes); aModeIt.More(); aModeIt.Next())
+    {
+      if (aModeIt.Value() == theMode)
+      {
+        return Standard_True;
+      }
+    }
+    return Standard_False;
+  }
+};
+
+//===============================================================================================
+//function : VSetSelectionMode
+//purpose  : Sets input selection mode for input object or for all displayed objects 
+//Draw arg : vselmode [object] mode On/Off (1/0)
+//===============================================================================================
+static Standard_Integer VSetSelectionMode (Draw_Interpretor& /*di*/,
+                                           Standard_Integer  theArgc,
+                                           const char**      theArgv)
+{
+  // Check errors
+  Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+  if (anAISContext.IsNull())
+  {
+    std::cerr << "Call vinit before!\n";
+    return 1;
+  }
+
+  // Check the arguments
+  if (theArgc != 3 && theArgc != 4)
+  {
+    std::cerr << "vselmode error : expects at least 2 arguments.\n"
+              << "Type help "<< theArgv[0] <<" for more information.";
+    return 1;
+  }
+
+  // get objects to change selection mode
+  AIS_ListOfInteractive aTargetIOs;
+  if (theArgc == 3)
+  {
+    anAISContext->DisplayedObjects (aTargetIOs);
+  }
+  else
+  {
+    // Check if there is an object with given name in context
+    const TCollection_AsciiString aNameIO (theArgv[1]);
+    if (GetMapOfAIS().IsBound2 (aNameIO))
+    {
+      Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aNameIO));
+      if (anIO.IsNull())
+      {
+        std::cerr << "vselmode error : object name is used for non AIS viewer\n"; 
+        return 1;
+      }
+      aTargetIOs.Append (anIO);
+    }
+  }
+
+  const Standard_Integer aSelectionMode = Draw::Atoi (theArgc == 3 ? theArgv[1] : theArgv[2]);
+  const Standard_Boolean toTurnOn       = Draw::Atoi (theArgc == 3 ? theArgv[2] : theArgv[3]);
+  if (aSelectionMode == 0 && anAISContext->HasOpenedContext())
+  {
+    anAISContext->CloseLocalContext();
+  }
+
+  if (aSelectionMode != 0 && toTurnOn) // Turn on specified mode
+  {
+    if (!anAISContext->HasOpenedContext())
+    {
+      anAISContext->OpenLocalContext (Standard_False);
+    }
+
+    for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next())
+    {
+      const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value();
+      if (!InList (anAISContext, anIO, aSelectionMode))
+      {
+        anAISContext->Load (anIO, -1, Standard_True);
+        anAISContext->Activate (anIO, aSelectionMode);
+      }
+    }
+  }
+
+  if (aSelectionMode != 0 && !toTurnOn) // Turn off specified mode
+  {
+    if (!anAISContext->HasOpenedContext())
+    {
+      return 0;
+    }
+
+    for (AIS_ListIteratorOfListOfInteractive aTargetIt (aTargetIOs); aTargetIt.More(); aTargetIt.Next())
+    {
+      const Handle(AIS_InteractiveObject)& anIO = aTargetIt.Value();
+      if (InList (anAISContext, anIO, aSelectionMode))
+      {
+        anAISContext->Deactivate (anIO, aSelectionMode);
+      }
+    }
+  }
+
+  return 0;
+}
+
+//==========================================================================
+//class   : Triangle 
+//purpose : creates Triangle based on AIS_InteractiveObject. 
+//          This class was implemented for testing Select3D_SensitiveTriangle
+//===========================================================================
+DEFINE_STANDARD_HANDLE(Triangle, AIS_InteractiveObject)
+class Triangle: public AIS_InteractiveObject 
+{
+public: 
+  // CASCADE RTTI
+  DEFINE_STANDARD_RTTI(FilledCircle); 
+  Triangle (const gp_Pnt& theP1, 
+            const gp_Pnt& theP2, 
+            const gp_Pnt& theP3);
+protected:
+  void Compute (  const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                  const Handle(Prs3d_Presentation)& thePresentation,
+                  const Standard_Integer theMode);
+
+  void ComputeSelection (  const Handle(SelectMgr_Selection)& theSelection, 
+                           const Standard_Integer theMode);
+private: 
+  gp_Pnt myPoint1;
+  gp_Pnt myPoint2;
+  gp_Pnt myPoint3;
+};
+IMPLEMENT_STANDARD_HANDLE(Triangle, AIS_InteractiveObject)
+IMPLEMENT_STANDARD_RTTIEXT(Triangle, AIS_InteractiveObject)
+
+Triangle::Triangle (const gp_Pnt& theP1,
+                    const gp_Pnt& theP2,
+                    const gp_Pnt& theP3)
+{
+  myPoint1 = theP1;
+  myPoint2 = theP2;
+  myPoint3 = theP3;
+}
+
+void Triangle::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
+                       const Handle(Prs3d_Presentation)& thePresentation,
+                       const Standard_Integer /*theMode*/)
+{
+  thePresentation->Clear();
+
+  BRepBuilderAPI_MakeEdge anEdgeMaker1(myPoint1, myPoint2),
+                          anEdgeMaker2(myPoint2, myPoint3),
+                          anEdgeMaker3(myPoint3, myPoint1);
+
+  TopoDS_Edge anEdge1 = anEdgeMaker1.Edge(),
+              anEdge2 = anEdgeMaker2.Edge(),
+              anEdge3 = anEdgeMaker3.Edge();
+  if(anEdge1.IsNull() || anEdge2.IsNull() || anEdge3.IsNull())
+    return;
+
+  BRepBuilderAPI_MakeWire aWireMaker(anEdge1, anEdge2, anEdge3);
+  TopoDS_Wire aWire = aWireMaker.Wire();
+  if(aWire.IsNull()) return;
+
+  BRepBuilderAPI_MakeFace aFaceMaker(aWire);
+  TopoDS_Face aFace = aFaceMaker.Face();
+  if(aFace.IsNull()) return;
+
+  StdPrs_ShadedShape::Add(thePresentation, aFace, myDrawer);
+}
+
+void Triangle::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection, 
+                                const Standard_Integer /*theMode*/)
+{
+  Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
+  Handle(Select3D_SensitiveTriangle) aSensTriangle = 
+    new Select3D_SensitiveTriangle(anEntityOwner, myPoint1, myPoint2, myPoint3);
+  theSelection->Add(aSensTriangle);
+}
+
+//===========================================================================
+//function : VTriangle 
+//Draw arg : vtriangle Name PointName PointName PointName
+//purpose  : creates and displays Triangle
+//===========================================================================
+
+//function: IsPoint
+//purpose : checks if the object with theName is AIS_Point, 
+//          if yes initialize thePoint from MapOfAIS
+Standard_Boolean IsPoint (const TCollection_AsciiString& theName,
+                          Handle(AIS_Point)& thePoint)
+{
+  Handle(AIS_InteractiveObject) anObject = 
+    Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(theName));
+  if(anObject.IsNull() || 
+     anObject->Type() != AIS_KOI_Datum || 
+     anObject->Signature() != 1)
+  {
+    return Standard_False;
+  }
+  thePoint = Handle(AIS_Point)::DownCast(anObject);
+  if(thePoint.IsNull())
+    return Standard_False;
+  return Standard_True;
+}
+
+//function: IsMatch
+//purpose: checks if thePoint1 is equal to thePoint2
+Standard_Boolean IsMatch (const Handle(Geom_CartesianPoint)& thePoint1,
+                          const Handle(Geom_CartesianPoint)& thePoint2)
+{
+  if(Abs(thePoint1->X()-thePoint2->X()) <= Precision::Confusion() &&
+     Abs(thePoint1->Y()-thePoint2->Y()) <= Precision::Confusion() &&
+     Abs(thePoint1->Z()-thePoint2->Z()) <= Precision::Confusion())
+  {
+    return Standard_True;
+  }
+  return Standard_False;
+}
+
+static Standard_Integer VTriangle (Draw_Interpretor& /*di*/,
+                                   Standard_Integer argc,
+                                   const char ** argv)
+{
+  // Check arguments
+  if (argc != 5)
+  {
+    std::cout<<"vtriangle error: expects 4 argumnets\n";
+    return 1; // TCL_ERROR
+  }
+
+  TheAISContext()->CloseAllContexts();
+
+  // Get and check values
+  TCollection_AsciiString aName(argv[1]);
+
+  Handle(AIS_Point) aPoint1, aPoint2, aPoint3;
+  if (!IsPoint(argv[2], aPoint1))
+  {
+    std::cout<<"vtriangle error: the 2nd argument must be a point\n";
+    return 1; // TCL_ERROR
+  }
+  if (!IsPoint(argv[3], aPoint2))
+  {
+    std::cout<<"vtriangle error: the 3d argument must be a point\n";
+    return 1; // TCL_ERROR
+  }
+  if (!IsPoint(argv[4], aPoint3))
+  {
+    std::cout<<"vtriangle error: the 4th argument must be a point\n";
+    return 1; // TCL_ERROR
+  }
+
+  // Check that points are different
+  Handle(Geom_CartesianPoint) aCartPoint1 = 
+    Handle(Geom_CartesianPoint)::DownCast(aPoint1->Component());
+  Handle(Geom_CartesianPoint) aCartPoint2 = 
+    Handle(Geom_CartesianPoint)::DownCast(aPoint2->Component());
+  // Test aPoint1 = aPoint2
+  if (IsMatch(aCartPoint1, aCartPoint2))
+  {
+    std::cout<<"vtriangle error: the 1st and the 2nd points are equal\n";
+    return 1; // TCL_ERROR
+  }
+  // Test aPoint2 = aPoint3
+  Handle(Geom_CartesianPoint) aCartPoint3 = 
+    Handle(Geom_CartesianPoint)::DownCast(aPoint3->Component());
+  if (IsMatch(aCartPoint2, aCartPoint3))
+  {
+    std::cout<<"vtriangle error: the 2nd and the 3d points are equal\n";
+    return 1; // TCL_ERROR
+  }
+  // Test aPoint3 = aPoint1
+  if (IsMatch(aCartPoint1, aCartPoint3))
+  {
+    std::cout<<"vtriangle error: the 1st and the 3d points are equal\n";
+    return 1; // TCL_ERROR
+  }
+
+  // Create triangle
+  Handle(Triangle) aTriangle = new Triangle(aCartPoint1->Pnt(),
+                                            aCartPoint2->Pnt(),
+                                            aCartPoint3->Pnt());
+
+  // Check if there is an object with given name
+  // and remove it from context
+  if (GetMapOfAIS().IsBound2(aName))
+  {
+    Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(aName);
+    Handle(AIS_InteractiveObject) anInterObj = 
+         Handle(AIS_InteractiveObject)::DownCast(anObj);
+    TheAISContext()->Remove(anInterObj, Standard_False);
+    GetMapOfAIS().UnBind2(aName);
+  }
+
+  // Bind triangle to its name
+  GetMapOfAIS().Bind(aTriangle, aName);
+
+  // Display triangle
+  TheAISContext()->Display(aTriangle);
+  return 0;
+}
+
+//class  : SegmentObject
+//purpose: creates segment based on AIS_InteractiveObject.
+//         This class was implemented for testing Select3D_SensitiveCurve
+DEFINE_STANDARD_HANDLE(SegmentObject, AIS_InteractiveObject)
+class SegmentObject: public AIS_InteractiveObject
+{
+public:
+  // CASCADE RTTI
+  DEFINE_STANDARD_RTTI(SegmentObject); 
+  SegmentObject (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2);
+protected:
+  void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                const Handle(Prs3d_Presentation)& thePresentation,
+                const Standard_Integer theMode);
+
+  void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, 
+                         const Standard_Integer theMode);
+private:
+  gp_Pnt myPoint1;
+  gp_Pnt myPoint2;
+};
+IMPLEMENT_STANDARD_HANDLE(SegmentObject, AIS_InteractiveObject)
+IMPLEMENT_STANDARD_RTTIEXT(SegmentObject, AIS_InteractiveObject)
+
+SegmentObject::SegmentObject (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2)
+{
+  myPoint1 = thePnt1;
+  myPoint2 = thePnt2;
+}
+
+void SegmentObject::Compute (const Handle(PrsMgr_PresentationManager3d) &/*thePresentationManager*/,
+                             const Handle(Prs3d_Presentation) &thePresentation,
+                             const Standard_Integer /*theMode*/)
+{
+  thePresentation->Clear();
+  BRepBuilderAPI_MakeEdge anEdgeMaker(myPoint1, myPoint2);
+  TopoDS_Edge anEdge = anEdgeMaker.Edge();
+  if (anEdge.IsNull())
+    return;
+  BRepAdaptor_Curve aCurveAdaptor(anEdge);
+  StdPrs_Curve::Add(thePresentation, aCurveAdaptor, myDrawer);
+}
+
+void SegmentObject::ComputeSelection (const Handle(SelectMgr_Selection) &theSelection,
+                                      const Standard_Integer /*theMode*/)
+{
+  Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
+  Handle(TColgp_HArray1OfPnt) anArray = new TColgp_HArray1OfPnt(1, 2);
+  anArray->SetValue(1, myPoint1);
+  anArray->SetValue(2, myPoint2);
+  Handle(Select3D_SensitiveCurve) aSensCurve = 
+    new Select3D_SensitiveCurve(anOwner, anArray);
+  theSelection->Add(aSensCurve);
+}
+
+//=======================================================================
+//function  : VSegment
+//Draw args : vsegment Name PointName PointName
+//purpose   : creates and displays Segment
+//=======================================================================
+static Standard_Integer VSegment (Draw_Interpretor& /*di*/,
+                                  Standard_Integer argc,
+                                  const char ** argv)
+{
+  // Check arguments
+  if(argc!=4)
+  {
+    std::cout<<"vsegment error: expects 3 arguments\n";
+    return 1; // TCL_ERROR
+  }
+
+  TheAISContext()->CloseAllContexts();
+
+  // Get and check arguments
+  TCollection_AsciiString aName(argv[1]);
+  Handle(AIS_Point) aPoint1, aPoint2;
+  if (!IsPoint(argv[2], aPoint1))
+  {
+    std::cout<<"vsegment error: the 2nd argument should be a point\n";
+    return 1; // TCL_ERROR
+  }
+  if (!IsPoint(argv[3], aPoint2))
+  {
+    std::cout<<"vsegment error: the 3d argument should be a point\n";
+    return 1; // TCL_ERROR
+  }
+  //Check that points are different
+  Handle(Geom_CartesianPoint) aCartPoint1 = 
+    Handle(Geom_CartesianPoint)::DownCast(aPoint1->Component());
+  Handle(Geom_CartesianPoint) aCartPoint2 = 
+    Handle(Geom_CartesianPoint)::DownCast(aPoint2->Component());
+  if(IsMatch(aCartPoint1, aCartPoint2))
+  {
+    std::cout<<"vsegment error: equal points\n";
+    return 1; // TCL_ERROR
+  }
+  
+  // Create segment
+  Handle(SegmentObject) aSegment = new SegmentObject(aCartPoint1->Pnt(), aCartPoint2->Pnt());
+  // Check if there is an object with given name
+  // and remove it from context
+  if (GetMapOfAIS().IsBound2(aName))
+  {
+    Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(aName);
+    Handle(AIS_InteractiveObject) anInterObj = 
+         Handle(AIS_InteractiveObject)::DownCast(anObj);
+    TheAISContext()->Remove(anInterObj, Standard_False);
+    GetMapOfAIS().UnBind2(aName);
+  }
+
+  // Bind segment to its name
+  GetMapOfAIS().Bind(aSegment, aName);
+
+  // Display segment
+  TheAISContext()->Display(aSegment);
+  return 0;
+}
+
+//=======================================================================
+//function : VObjZLayer
+//purpose  : Set or get z layer id for presentable object
+//=======================================================================
+
+static Standard_Integer VObjZLayer (Draw_Interpretor& di,
+                                    Standard_Integer argc,
+                                    const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    di << argv[0] << "Call 'vinit' before!\n";
+    return 1;
+  }
+
+  // get operation
+  TCollection_AsciiString aOperation;
+  if (argc >= 2)
+    aOperation = TCollection_AsciiString (argv [1]);
+
+  // check for correct arguments
+  if (!(argc == 4 && aOperation.IsEqual ("set")) &&
+      !(argc == 3 && aOperation.IsEqual ("get")))
+  {
+    di << "Usage : " << argv[0] << " set/get object [layerid]\n";
+    di << " set - set layer id for interactive object, layerid - z layer id\n";
+    di << " get - get layer id of interactive object\n";
+    di << " argument layerid should be passed for set operation only\n";
+    return 1;
+  }
+
+  // find object
+  TCollection_AsciiString aName (argv[2]);
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  if (!aMap.IsBound2 (aName))
+  {
+    di << "Use 'vdisplay' before" << "\n";
+    return 1;
+  }
+
+  // find interactive object
+  Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
+  Handle(AIS_InteractiveObject) anInterObj =
+    Handle(AIS_InteractiveObject)::DownCast (anObj);
+  if (anInterObj.IsNull())
+  {
+    di << "Not an AIS interactive object!\n";
+    return 1;
+  }
+
+  // process operation
+  if (aOperation.IsEqual ("set"))
+  {
+    Standard_Integer aLayerId = Draw::Atoi (argv [3]);
+    aContext->SetZLayer (anInterObj, aLayerId);
+  }
+  else if (aOperation.IsEqual ("get"))
+  {
+    di << "Z layer id: " << aContext->GetZLayer (anInterObj);
+  }
+  
+  return 0;
+}
+
+//=======================================================================
+//function : VPolygonOffset
+//purpose  : Set or get polygon offset parameters
+//=======================================================================
+static Standard_Integer VPolygonOffset(Draw_Interpretor& /*di*/,
+                                       Standard_Integer argc,
+                                       const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << argv[0] << " Call 'vinit' before!\n";
+    return 1;
+  }
+
+  if (argc > 2 && argc != 5)
+  {
+    std::cout << "Usage : " << argv[0] << " [object [mode factor units]] - sets/gets polygon offset parameters for an object,"
+      "without arguments prints the default values" << std::endl;
+    return 1;
+  }
+
+  // find object
+  Handle(AIS_InteractiveObject) anInterObj;
+  if (argc >= 2)
+  {
+    TCollection_AsciiString aName (argv[1]);
+    ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+    if (!aMap.IsBound2 (aName))
+    {
+      std::cout << "Use 'vdisplay' before" << std::endl;
+      return 1;
+    }
+
+    // find interactive object
+    Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
+    anInterObj = Handle(AIS_InteractiveObject)::DownCast (anObj);
+    if (anInterObj.IsNull())
+    {
+      std::cout << "Not an AIS interactive object!" << std::endl;
+      return 1;
+    }
+  }
+
+  Standard_Integer aMode;
+  Standard_ShortReal    aFactor, aUnits;
+  if (argc == 5)
+  {
+    aMode   = Draw::Atoi(argv[2]);
+    aFactor = (Standard_ShortReal) Draw::Atof(argv[3]);
+    aUnits  = (Standard_ShortReal) Draw::Atof(argv[4]);
+
+    anInterObj->SetPolygonOffsets(aMode, aFactor, aUnits);
+    aContext->UpdateCurrentViewer();
+    return 0;
+  }
+  else if (argc == 2)
+  {
+    if (anInterObj->HasPolygonOffsets())
+    {
+      anInterObj->PolygonOffsets(aMode, aFactor, aUnits);
+      std::cout << "Current polygon offset parameters for " << argv[1] << ":" << std::endl;
+      std::cout << "\tMode: "   << aMode   << std::endl;
+      std::cout << "\tFactor: " << aFactor << std::endl;
+      std::cout << "\tUnits: "  << aUnits  << std::endl;
+      return 0;
+    }
+    else
+    {
+      std::cout << "Specific polygon offset parameters are not set for " << argv[1] << std::endl;
+    }
+  }
+
+  std::cout << "Default polygon offset parameters:" << std::endl;
+  aContext->DefaultDrawer()->ShadingAspect()->Aspect()->PolygonOffsets(aMode, aFactor, aUnits);
+  std::cout << "\tMode: "   << aMode   << std::endl;
+  std::cout << "\tFactor: " << aFactor << std::endl;
+  std::cout << "\tUnits: "  << aUnits  << std::endl;
+
+  return 0;
+}
+
+//=======================================================================
+//function : VShowFaceBoundaries
+//purpose  : Set face boundaries drawing on/off for ais object
+//=======================================================================
+static Standard_Integer VShowFaceBoundary (Draw_Interpretor& /*di*/,
+                                           Standard_Integer argc,
+                                           const char ** argv)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext ();
+  if (aContext.IsNull ())
+  {
+    std::cout << argv[0] << " Call 'vinit' before!\n";
+    return 1;
+  }
+
+  if ((argc != 3 && argc < 6) || argc > 8)
+  {
+    std::cout << "Usage :\n " << argv[0]
+              << " ObjectName isOn [R G B [LineWidth [LineStyle]]]\n"
+              << "   ObjectName - name of AIS interactive object. \n"
+              << "                if ObjectName = \"\", then set as default\n"
+              << "                settings for all newly displayed objects\n"
+              << "   isOn       - flag indicating whether the boundaries\n"
+              << "                should be turned on or off (can be set\n"
+              << "                to 0 (off) or 1 (on)).\n"
+              << "   R, G, B    - red, green and blue components of boundary\n"
+              << "                color in range (0 - 255).\n"
+              << "                (default is (0, 0, 0)\n"
+              << "   LineWidth  - line width\n"
+              << "                (default is 1)\n"
+              << "   LineStyle  - line fill style :\n"
+              << "                 0 - solid  \n"
+              << "                 1 - dashed \n"
+              << "                 2 - dot    \n"
+              << "                 3 - dashdot\n"
+              << "                 (default is solid)";
+    return 1;
+  }
+
+  TCollection_AsciiString aName (argv[1]);
+
+  Quantity_Parameter aRed      = 0.0;
+  Quantity_Parameter aGreen    = 0.0;
+  Quantity_Parameter aBlue     = 0.0;
+  Standard_Real      aWidth    = 1.0;
+  Aspect_TypeOfLine  aLineType = Aspect_TOL_SOLID;
+  
+  // find object
+  Handle(AIS_InteractiveObject) anInterObj;
+
+  // if name is empty - apply attributes for default aspect
+  if (!aName.IsEmpty ())
+  {
+    ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS ();
+    if (!aMap.IsBound2 (aName))
+    {
+      std::cout << "Use 'vdisplay' on " << aName << " before" << std::endl;
+      return 1;
+    }
+
+    // find interactive object
+    Handle(Standard_Transient) anObj = GetMapOfAIS ().Find2 (aName);
+    anInterObj = Handle(AIS_InteractiveObject)::DownCast (anObj);
+    if (anInterObj.IsNull ())
+    {
+      std::cout << "Not an AIS interactive object!" << std::endl;
+      return 1;
+    }
+  }
+  
+  const Handle(Prs3d_Drawer)& aDrawer = (aName.IsEmpty ()) ?
+    TheAISContext ()->DefaultDrawer () : anInterObj->Attributes ();
+
+  // turn boundaries on/off
+  Standard_Boolean isBoundaryDraw = (Draw::Atoi (argv[2]) == 1);
+  aDrawer->SetFaceBoundaryDraw (isBoundaryDraw);
+  
+  // set boundary line color
+  if (argc >= 6)
+  {
+    // Text color
+    aRed   = Draw::Atof (argv[3])/255.;
+    aGreen = Draw::Atof (argv[4])/255.;
+    aBlue  = Draw::Atof (argv[5])/255.;
+  }
+
+  // set line width
+  if (argc >= 7)
+  {
+    aWidth = (Standard_Real)Draw::Atof (argv[6]);
+  }
+
+  // select appropriate line type
+  if (argc == 8)
+  {
+    switch (Draw::Atoi (argv[7]))
+    {
+      case 1: aLineType = Aspect_TOL_DASH;    break;
+      case 2: aLineType = Aspect_TOL_DOT;     break;
+      case 3: aLineType = Aspect_TOL_DOTDASH; break;
+      default:
+        aLineType = Aspect_TOL_SOLID;
+    }
+  }
+
+  Quantity_Color aColor (aRed, aGreen, aBlue, Quantity_TOC_RGB);
+
+  Handle(Prs3d_LineAspect) aBoundaryAspect = 
+    new Prs3d_LineAspect (aColor, aLineType, aWidth);
+
+  aDrawer->SetFaceBoundaryAspect (aBoundaryAspect);
+
+  TheAISContext()->Redisplay (anInterObj);
+  
+  return 0;
+}
+
+// This class is used for testing markers.
+DEFINE_STANDARD_HANDLE(ViewerTest_MarkersArrayObject, AIS_InteractiveObject)
+class ViewerTest_MarkersArrayObject : public AIS_InteractiveObject
+{
+
+public:
+
+  ViewerTest_MarkersArrayObject (const gp_XYZ& theStartPoint,
+                                 const Standard_Integer& thePointsOnSide,
+                                 Handle(Graphic3d_AspectMarker3d) theMarkerAspect = NULL)
+  {
+    myStartPoint = theStartPoint;
+    myPointsOnSide = thePointsOnSide;
+    myMarkerAspect = theMarkerAspect;
+  }
+
+  DEFINE_STANDARD_RTTI(MyPArrayObject);
+
+private:
+
+  void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                const Handle(Prs3d_Presentation)& aPresentation,
+                const Standard_Integer aMode);
+
+  void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+                         const Standard_Integer /*theMode*/);
+
+protected:
+
+  gp_XYZ myStartPoint;
+  Standard_Integer myPointsOnSide;
+  Handle(Graphic3d_AspectMarker3d) myMarkerAspect;
+};
+
+IMPLEMENT_STANDARD_HANDLE(ViewerTest_MarkersArrayObject, AIS_InteractiveObject)
+IMPLEMENT_STANDARD_RTTIEXT(ViewerTest_MarkersArrayObject, AIS_InteractiveObject)
+
+void ViewerTest_MarkersArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
+                              const Handle(Prs3d_Presentation)& aPresentation,
+                              const Standard_Integer /*aMode*/)
+{
+  Handle(Graphic3d_ArrayOfPrimitives) anArray = new Graphic3d_ArrayOfPoints ((Standard_Integer )Pow (myPointsOnSide, 3), myPointsOnSide != 1);
+  if (myPointsOnSide == 1)
+  {
+    anArray->AddVertex (myStartPoint);
+  }
+  else
+  {
+    for (Standard_Real i = 1; i <= myPointsOnSide; i++)
+    {
+      for (Standard_Real j = 1; j <= myPointsOnSide; j++)
+      {
+        for (Standard_Real k = 1; k <= myPointsOnSide; k++)
+        {
+          anArray->AddVertex (myStartPoint.X() + i, myStartPoint.Y() + j, myStartPoint.Z() + k);
+          anArray->SetVertexColor (anArray->VertexNumber(),
+                                   i / myPointsOnSide,
+                                   j / myPointsOnSide,
+                                   k / myPointsOnSide);
+        }
+      }
+    }
+  }
+
+  aPresentation->Clear();
+  if (!myMarkerAspect.IsNull())
+  {
+    Prs3d_Root::CurrentGroup (aPresentation)->SetGroupPrimitivesAspect (myMarkerAspect);
+  }
+  Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (anArray);
+}
+
+void ViewerTest_MarkersArrayObject::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
+                                       const Standard_Integer /*theMode*/)
+{
+  Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner (this);
+
+  if (myPointsOnSide == 1)
+  {
+    gp_Pnt aPoint (myStartPoint);
+    Handle(Select3D_SensitivePoint) aSensetivePoint = new Select3D_SensitivePoint (anEntityOwner, aPoint);
+    theSelection->Add (aSensetivePoint);
+  }
+  else
+  {
+    for (Standard_Real i = 1; i <= myPointsOnSide; i++)
+    {
+      for (Standard_Real j = 1; j <= myPointsOnSide; j++)
+      {
+        for (Standard_Real k = 1; k <= myPointsOnSide; k++)
+        {
+          gp_Pnt aPoint (myStartPoint.X() + i, myStartPoint.Y() + j, myStartPoint.Z() + k);
+          Handle(Select3D_SensitivePoint) aSensetivePoint = new Select3D_SensitivePoint (anEntityOwner, aPoint);
+          theSelection->Add (aSensetivePoint);
+        }
+      }
+    }
+  }
+}
+//=======================================================================
+//function : VMarkersTest
+//purpose  : Draws an array of markers for testing purposes.
+//=======================================================================
+static Standard_Integer VMarkersTest (Draw_Interpretor&,
+                                      Standard_Integer  theArgNb,
+                                      const char**      theArgVec)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cerr << "Call 'vinit' before!\n";
+    return 1;
+  }
+
+  if (theArgNb < 5)
+  {
+    std::cerr << "Usage :\n " << theArgVec[0]
+              << "name X Y Z [PointsOnSide=10] [MarkerType=0] [Scale=1.0] [FileName=ImageFile]\n";
+    return 1;
+  }
+
+  Standard_Integer anArgIter = 1;
+
+  TCollection_AsciiString aName (theArgVec[anArgIter++]);
+  TCollection_AsciiString aFileName;
+  gp_XYZ aPnt (Atof (theArgVec[anArgIter]),
+               Atof (theArgVec[anArgIter + 1]),
+               Atof (theArgVec[anArgIter + 2]));
+  anArgIter += 3;
+
+  Standard_Integer aPointsOnSide = 10;
+  Standard_Integer aMarkerType   = -1;
+  Standard_Real    aScale        = 1.0;
+  for (; anArgIter < theArgNb; ++anArgIter)
+  {
+    const TCollection_AsciiString anArg (theArgVec[anArgIter]);
+    if (anArg.Search ("PointsOnSide=") > -1)
+    {
+      aPointsOnSide = anArg.Token ("=", 2).IntegerValue();
+    }
+    else if (anArg.Search ("MarkerType=") > -1)
+    {
+      aMarkerType = anArg.Token ("=", 2).IntegerValue();
+    }
+    else if (anArg.Search ("Scale=") > -1)
+    {
+      aScale = anArg.Token ("=", 2).RealValue();
+    }
+    else if (anArg.Search ("FileName=") > -1)
+    {
+      aFileName = anArg.Token ("=", 2);
+    }
+    else
+    {
+      std::cerr << "Wrong argument: " << anArg << "\n";
+      return 1;
+    }
+  }
+
+  Handle(Graphic3d_AspectMarker3d) anAspect;
+  Handle(Image_AlienPixMap) anImage;
+  Quantity_Color aColor (Quantity_NOC_GREEN1);
+  if ((aMarkerType == Aspect_TOM_USERDEFINED || aMarkerType < 0)
+   && !aFileName.IsEmpty())
+  {
+    anImage = new Image_AlienPixMap();
+    if (!anImage->Load (aFileName))
+    {
+      std::cerr << "Could not load image from file '" << aFileName << "'!\n";
+      return 1;
+    }
+    anAspect = new Graphic3d_AspectMarker3d (anImage);
+  }
+  else
+  {
+    anAspect = new Graphic3d_AspectMarker3d (aMarkerType >= 0 ? (Aspect_TypeOfMarker )aMarkerType : Aspect_TOM_POINT, aColor, aScale);
+  }
+
+  Handle(ViewerTest_MarkersArrayObject) aMarkersArray = new ViewerTest_MarkersArrayObject (aPnt, aPointsOnSide, anAspect);
+  VDisplayAISObject (aName, aMarkersArray);
+
+  return 0;
+}
+
+//! Auxiliary function to parse font aspect style argument
+static Standard_Boolean parseFontStyle (const TCollection_AsciiString& theArg,
+                                        Font_FontAspect&               theAspect)
+{
+  if (theArg == "regular"
+   || *theArg.ToCString() == 'r')
+  {
+    theAspect = Font_FA_Regular;
+    return Standard_True;
+  }
+  else if (theArg == "bolditalic")
+  {
+    theAspect = Font_FA_BoldItalic;
+    return Standard_True;
+  }
+  else if (theArg == "bold"
+        || *theArg.ToCString() == 'b')
+  {
+    theAspect = Font_FA_Bold;
+    return Standard_True;
+  }
+  else if (theArg == "italic"
+        || *theArg.ToCString() == 'i')
+  {
+    theAspect = Font_FA_Italic;
+    return Standard_True;
+  }
+  return Standard_False;
+}
+
+//! Auxiliary function
+static TCollection_AsciiString fontStyleString (const Font_FontAspect theAspect)
+{
+  switch (theAspect)
+  {
+    case Font_FA_Regular:    return "regular";
+    case Font_FA_BoldItalic: return "bolditalic";
+    case Font_FA_Bold:       return "bold";
+    case Font_FA_Italic:     return "italic";
+    default:                 return "undefined";
+  }
+}
+
+//=======================================================================
+//function : TextToBrep
+//purpose  : Tool for conversion text to occt-shapes
+//=======================================================================
+
+static int TextToBRep (Draw_Interpretor& /*theDI*/,
+                       Standard_Integer  theArgNb,
+                       const char**      theArgVec)
+{
+  // Check arguments
+  if (theArgNb < 5)
+  {
+    std::cerr << "Error: " << theArgVec[0] << " - invalid syntax\n";
+    return 1;
+  }
+
+  Standard_Integer    anArgIter = 1;
+  Standard_CString    aResName  = theArgVec[anArgIter++];
+  Standard_CString    aText     = theArgVec[anArgIter++];
+  Standard_CString    aFontName = theArgVec[anArgIter++];
+  const Standard_Real aSize     = Atof (theArgVec[anArgIter++]);
+
+  Font_BRepFont    aFont;
+  Font_FontAspect  aFontAspect      = Font_FA_Regular;
+  Standard_Boolean isCompositeCurve = Standard_False;
+  gp_Ax3           aPenAx3 (gp::XOY());
+  gp_Pnt           aPenLoc;
+  while (anArgIter < theArgNb)
+  {
+    const TCollection_AsciiString anArg (theArgVec[anArgIter++]);
+    TCollection_AsciiString anArgCase (anArg);
+    anArgCase.LowerCase();
+    if (anArgCase.Search ("x=") > -1)
+    {
+      aPenLoc.SetX (anArg.Token ("=", 2).RealValue());
+    }
+    else if (anArgCase.Search ("y=") > -1)
+    {
+      aPenLoc.SetY (anArg.Token ("=", 2).RealValue());
+    }
+    else if (anArgCase.Search ("z=") > -1)
+    {
+      aPenLoc.SetZ (anArg.Token ("=", 2).RealValue());
+    }
+    else if (anArgCase.Search ("composite=") > -1)
+    {
+      isCompositeCurve = (anArg.Token ("=", 2).IntegerValue() == 1);
+    }
+    else if (parseFontStyle (anArgCase, aFontAspect))
+    {
+      //
+    }
+    else
+    {
+      std::cerr << "Warning! Unknown argument '" << anArg.ToCString() << "'\n";
+    }
+  }
+
+  aFont.SetCompositeCurveMode (isCompositeCurve);
+  if (!aFont.Init (aFontName, aFontAspect, aSize))
+  {
+    std::cerr << "Font initialization error\n";
+    return 1;
+  }
+
+  aPenAx3.SetLocation (aPenLoc);
+  DBRep::Set (aResName, aFont.RenderText (aText, aPenAx3));
+  return 0;
+}
+
+//=======================================================================
+//function : VFont
+//purpose  : Font management
+//=======================================================================
+
+static int VFont (Draw_Interpretor& theDI,
+                  Standard_Integer  theArgNb,
+                  const char**      theArgVec)
+{
+  Handle(Font_FontMgr) aMgr = Font_FontMgr::GetInstance();
+  if (theArgNb < 2)
+  {
+    // just print the list of available fonts
+    Standard_Boolean isFirst = Standard_True;
+    for (Font_NListOfSystemFont::Iterator anIter (aMgr->GetAvailableFonts());
+         anIter.More(); anIter.Next())
+    {
+      const Handle(Font_SystemFont)& aFont = anIter.Value();
+      if (!isFirst)
+      {
+        theDI << "\n";
+      }
+
+      theDI << aFont->FontName()->String()
+            << " " << fontStyleString (aFont->FontAspect())
+            << " " << aFont->FontPath()->String();
+      isFirst = Standard_False;
+    }
+    return 0;
+  }
+
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+  {
+    const TCollection_AsciiString anArg (theArgVec[anArgIter]);
+    TCollection_AsciiString anArgCase (anArg);
+    anArgCase.LowerCase();
+    if (anArgCase == "find")
+    {
+      if (++anArgIter >= theArgNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg.ToCString() << "'!\n";
+        return 1;
+      }
+
+      Standard_CString aFontName   = theArgVec[anArgIter];
+      Font_FontAspect  aFontAspect = Font_FA_Undefined;
+      if (++anArgIter < theArgNb)
+      {
+        anArgCase = theArgVec[anArgIter];
+        anArgCase.LowerCase();
+        if (!parseFontStyle (anArgCase, aFontAspect))
+        {
+          --anArgIter;
+        }
+      }
+      Handle(Font_SystemFont) aFont = aMgr->FindFont (new TCollection_HAsciiString (aFontName), aFontAspect, -1);
+      if (aFont.IsNull())
+      {
+        std::cerr << "Error: font '" << aFontName << "' is not found!\n";
+        continue;
+      }
+
+      theDI << aFont->FontName()->String()
+            << " " << fontStyleString (aFont->FontAspect())
+            << " " << aFont->FontPath()->String();
+    }
+    else if (anArgCase == "add"
+          || anArgCase == "register")
+    {
+      if (++anArgIter >= theArgNb)
+      {
+        std::cerr << "Wrong syntax at argument '" << anArg.ToCString() << "'!\n";
+        return 1;
+      }
+      Standard_CString aFontPath   = theArgVec[anArgIter];
+      Standard_CString aFontName   = NULL;
+      Font_FontAspect  aFontAspect = Font_FA_Undefined;
+      if (++anArgIter < theArgNb)
+      {
+        if (!parseFontStyle (anArgCase, aFontAspect))
+        {
+          aFontName = theArgVec[anArgIter];
+        }
+        if (++anArgIter < theArgNb)
+        {
+          anArgCase = theArgVec[anArgIter];
+          anArgCase.LowerCase();
+          if (!parseFontStyle (anArgCase, aFontAspect))
+          {
+            --anArgIter;
+          }
+        }
+      }
+
+      Handle(Font_SystemFont) aFont = aMgr->CheckFont (aFontPath);
+      if (aFont.IsNull())
+      {
+        std::cerr << "Error: font '" << aFontPath << "' is not found!\n";
+        continue;
+      }
+
+      if (aFontAspect != Font_FA_Undefined
+       || aFontName   != NULL)
+      {
+        if (aFontAspect == Font_FA_Undefined)
+        {
+          aFontAspect = aFont->FontAspect();
+        }
+        Handle(TCollection_HAsciiString) aName = aFont->FontName();
+        if (aFontName != NULL)
+        {
+          aName = new TCollection_HAsciiString (aFontName);
+        }
+        aFont = new Font_SystemFont (aName, aFontAspect, new TCollection_HAsciiString (aFontPath));
+      }
+
+      aMgr->RegisterFont (aFont, Standard_True);
+      theDI << aFont->FontName()->String()
+            << " " << fontStyleString (aFont->FontAspect())
+            << " " << aFont->FontPath()->String();
+    }
+    else
+    {
+      std::cerr << "Warning! Unknown argument '" << anArg.ToCString() << "'\n";
+    }
+  }
+
+  return 0;
+}
+
+//=======================================================================
+//function : VSetEdgeType
+//purpose  : Edges type management
+//=======================================================================
+
+static int VSetEdgeType (Draw_Interpretor& theDI,
+                         Standard_Integer  theArgNum,
+                         const char**      theArgs)
+{
+  if (theArgNum < 4 || theArgNum > 9)
+  {
+    theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
+          << theArgs[0] << "' for more information.\n";
+    return 1;
+  }
+
+  Standard_Boolean isForceRedisplay = Standard_False;
+
+  // Get shape name
+  TCollection_AsciiString aName(theArgs[1]);
+  if (!GetMapOfAIS().IsBound2 (aName))
+  {
+    theDI <<  theArgs[0] << " error: wrong object name.\n";
+    return 1;
+  }
+  
+  Handle(AIS_InteractiveObject) anObject = 
+    Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
+  
+  // Enable trianle edge mode
+  anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOn();
+
+  // Parse parameters
+  for (Standard_Integer anIt = 2; anIt < theArgNum; ++anIt)
+  {
+    TCollection_AsciiString aParam ((theArgs[anIt]));
+    if (aParam.Value (1) == '-' && !aParam.IsRealValue())
+    {
+      if (aParam.IsEqual ("-type"))
+      {
+        if (theArgNum <= anIt + 1)
+        {
+          theDI <<  theArgs[0] << " error: wrong number of values for parameter '"
+                << aParam.ToCString() << "'.\n";
+          return 1;
+        }
+
+        TCollection_AsciiString aType = theArgs[++anIt];
+        aType.UpperCase();
+
+        if (aType.IsEqual ("SOLID"))
+        {
+          anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_SOLID);
+        }
+        else if (aType.IsEqual ("DASH"))
+        {
+          anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DASH);
+        }
+        else if (aType.IsEqual ("DOT"))
+        {
+          anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DOT);
+        }
+        else if (aType.IsEqual ("DOTDASH"))
+        {
+          anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType(Aspect_TOL_DOTDASH);
+        }
+        else
+        {
+          theDI <<  theArgs[0] << " error: wrong line type: '" << aType.ToCString() << "'.\n";
+          return 1;
+        }
+        
+      }
+      else if (aParam.IsEqual ("-color"))
+      {
+        if (theArgNum <= anIt + 3)
+        {
+          theDI <<  theArgs[0] << " error: wrong number of values for parameter '"
+                << aParam.ToCString() << "'.\n";
+          return 1;
+        }
+
+        Quantity_Parameter aR = Draw::Atof(theArgs[++anIt]);
+        Quantity_Parameter aG = Draw::Atof(theArgs[++anIt]);
+        Quantity_Parameter aB = Draw::Atof(theArgs[++anIt]);
+        Quantity_Color aColor = Quantity_Color (aR > 1 ? aR / 255.0 : aR,
+                                                aG > 1 ? aG / 255.0 : aG,
+                                                aB > 1 ? aB / 255.0 : aB,
+                                                Quantity_TOC_RGB);
+
+        anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeColor (aColor);
+      }
+      else if (aParam.IsEqual ("-force"))
+      {
+        isForceRedisplay = Standard_True;
+      }
+      else
+      {
+        theDI <<  theArgs[0] << " error: unknown parameter '"
+              << aParam.ToCString() << "'.\n";
+        return 1;
+      }
+    }
+  }
+
+  // Update shape presentation as aspect parameters were changed
+  if (isForceRedisplay)
+  {
+    ViewerTest::GetAISContext()->Redisplay (anObject);
+  }
+  else
+  {
+    anObject->SetAspect (anObject->Attributes()->ShadingAspect());
+  }
+
+  //Update view
+  ViewerTest::CurrentView()->Redraw();
+
+  return 0;
+}
+
+//=======================================================================
+//function : VUnsetEdgeType
+//purpose  : Unsets edges visibility in shading mode
+//=======================================================================
+
+static int VUnsetEdgeType (Draw_Interpretor& theDI,
+                         Standard_Integer  theArgNum,
+                         const char**      theArgs)
+{
+  if (theArgNum != 2 && theArgNum != 3)
+  {
+    theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
+          << theArgs[0] << "' for more information.\n";
+    return 1;
+  }
+
+  Standard_Boolean isForceRedisplay = Standard_False;
+
+  // Get shape name
+  TCollection_AsciiString aName (theArgs[1]);
+  if (!GetMapOfAIS().IsBound2 (aName))
+  {
+    theDI <<  theArgs[0] << " error: wrong object name.\n";
+    return 1;
+  }
+
+  Handle(AIS_InteractiveObject) anObject = 
+    Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(aName));
+
+  // Enable trianle edge mode
+  anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOff();
+
+  // Parse parameters
+  if (theArgNum == 3)
+  {
+    TCollection_AsciiString aParam ((theArgs[2]));
+    if (aParam.IsEqual ("-force"))
+    {
+      isForceRedisplay = Standard_True;
+    }
+    else
+    {
+       theDI <<  theArgs[0] << " error: unknown parameter '"
+              << aParam.ToCString() << "'.\n";
+       return 1;
+    }
+  }
+
+  // Update shape presentation as aspect parameters were changed
+  if (isForceRedisplay)
+  {
+    ViewerTest::GetAISContext()->Redisplay (anObject);
+  }
+  else
+  {
+    anObject->SetAspect (anObject->Attributes()->ShadingAspect());
+  }
+
+  //Update view
+  ViewerTest::CurrentView()->Redraw();
+
+  return 0;
+}
+
+
+//=======================================================================
+//function : VVertexMode
+//purpose  : Switches vertex display mode for AIS_Shape or displays the current value
+//=======================================================================
+
+static int VVertexMode (Draw_Interpretor& theDI,
+                         Standard_Integer  theArgNum,
+                         const char**      theArgs)
+{
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  if (aContext.IsNull())
+  {
+    std::cout << "Error: no view available, call 'vinit' before!" << std::endl;
+    return 1;
+  }
+
+  // No arguments --> print the current default vertex draw mode
+  if (theArgNum == 1)
+  {
+    Prs3d_VertexDrawMode aCurrMode = aContext->DefaultDrawer()->VertexDrawMode();
+    theDI <<  "Default vertex draw mode: " << (aCurrMode == Prs3d_VDM_Isolated ? "'isolated'" : "'all'") << "\n";
+    return 0;
+  }
+
+  // -set argument --> change the default vertex draw mode and the mode for all displayed or given object(s)
+  TCollection_AsciiString aParam (theArgs[1]);
+  if (aParam == "-set")
+  {
+    if (theArgNum == 2)
+    {
+      std::cout << "Error: '-set' option not followed by the mode and optional object name(s)" << std::endl;
+      std::cout << "Type 'help vvertexmode' for usage hints" << std::endl;
+      return 1;
+    }
+
+    TCollection_AsciiString aModeStr (theArgs[2]);
+    Prs3d_VertexDrawMode aNewMode =
+       aModeStr == "isolated" ? Prs3d_VDM_Isolated :
+      (aModeStr == "all"      ? Prs3d_VDM_All :
+                                Prs3d_VDM_Inherited);
+
+    Standard_Boolean aRedrawNeeded = Standard_False;
+    AIS_ListOfInteractive anObjs;
+
+    // No object(s) specified -> use all displayed
+    if (theArgNum == 3)
+    {
+      theDI << "Setting the default vertex draw mode and updating all displayed objects...\n";
+      aContext->DisplayedObjects (anObjs);
+      aContext->DefaultDrawer()->SetVertexDrawMode (aNewMode);
+      aRedrawNeeded = Standard_True;
+    }
+
+    Handle(AIS_InteractiveObject) anObject;
+    for (Standard_Integer aCount = 3; aCount < theArgNum; aCount++)
+    {
+      TCollection_AsciiString aName (theArgs[aCount]);
+      if (!GetMapOfAIS().IsBound2 (aName))
+      {
+        theDI << "Warning: wrong object name ignored - " << theArgs[0] << "\n";
+        continue;
+      }
+      anObject = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(aName));
+      anObjs.Append (anObject);
+    }
+
+    for (AIS_ListIteratorOfListOfInteractive anIt (anObjs); anIt.More(); anIt.Next())
+    {
+      anObject = anIt.Value();
+      anObject->Attributes()->SetVertexDrawMode (aNewMode);
+      aContext->Redisplay (anObject, Standard_False);
+      aRedrawNeeded = Standard_True;
+    }
+
+    if (aRedrawNeeded)
+      ViewerTest::CurrentView()->Redraw();
+
+    return 0;
+  }
+
+  if (theArgNum > 2)
+  {
+    std::cout << "Error: invalid number of arguments" << std::endl;
+    std::cout << "Type 'help vvertexmode' for usage hints" << std::endl;
+    return 1;
+  }
+
+  // One argument (object name) --> print the current vertex draw mode for the object
+  Handle(AIS_InteractiveObject) anObject =
+    Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aParam));
+  Prs3d_VertexDrawMode aCurrMode = anObject->Attributes()->VertexDrawMode();
+  theDI <<  "Object's vertex draw mode: " << (aCurrMode == Prs3d_VDM_Isolated ? "'isolated'" : "'all'") << "\n";
+  return 0;
+}
+
+//=======================================================================
+//function : ObjectsCommands
+//purpose  :
+//=======================================================================
+
+void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
 {
   const char *group ="AISObjects";
   theCommands.Add("vtrihedron",
@@ -3296,9 +5387,23 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__,VPointBuilder,group);
 
   theCommands.Add("vplane",
-    "vplane  PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] ",
+    "vplane  PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] [TypeOfSensitivity]",
     __FILE__,VPlaneBuilder,group);
 
+  theCommands.Add ("vchangeplane", "vchangeplane usage: \n"
+    "   vchangeplane <plane_name>"
+    " [x=center_x y=center_y z=center_z]"
+    " [dx=dir_x dy=dir_y dz=dir_z]"
+    " [sx=size_x sy=size_y]"
+    " [noupdate]\n"
+    "   - changes parameters of the plane:\n"
+    "   - x y z     - center\n"
+    "   - dx dy dz  - normal\n"
+    "   - sx sy     - plane sizes\n"
+    "   - noupdate  - do not update/redisplay the plane in context\n"
+    "   Please enter coordinates in format \"param=value\" in arbitrary order.",
+    __FILE__, VChangePlane, group);
+
   theCommands.Add("vplanepara",
     "vplanepara  PlaneName  ",
     __FILE__,VPlaneBuilder,group);
@@ -3312,7 +5417,7 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__,VLineBuilder,group);
 
   theCommands.Add("vcircle",
-    "vcircle CircleName [PointName/PlaneName] [PointName] [Radius] ",
+    "vcircle CircleName [PointName PointName PointName IsFilled]\n\t\t\t\t\t[PlaneName PointName Radius IsFilled]",
     __FILE__,VCircleBuilder,group);
 
   theCommands.Add("vdrawtext",
@@ -3320,13 +5425,9 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__,VDrawText,group);
 
   theCommands.Add("vdrawsphere",
-    "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]\n",
+    "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0] [ToPrintInfo=1]\n",
     __FILE__,VDrawSphere,group);
 
-  theCommands.Add("vclipplane",
-    "vclipplane : vclipplane [x y z dx dy dz] [planeId {on/off/del/display/hide}]",
-    __FILE__,VClipPlane,group);
-
   theCommands.Add ("vsetlocation",
         "vsetlocation : name x y z; set new location for an interactive object",
         __FILE__, VSetLocation, group);
@@ -3337,6 +5438,107 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
     __FILE__, VComputeHLR, group);
 
   theCommands.Add("vdrawparray",
-    "vdrawparray : vdrawparray Name TypeOfArray [EnableVbo=1] [vertex = { 'v' x y z [vertex_normal = { 'n' x y z }] [vertex_color = { 'c' r g b }] ] ... [bound = { 'b' vertex_count [bound_color = { 'c' r g b }] ] ... [edge = { 'e' vertex_id [edge_hidden = { 'h' }] ]",
+    "vdrawparray : vdrawparray Name TypeOfArray [vertex = { 'v' x y z [vertex_normal = { 'n' x y z }] [vertex_color = { 'c' r g b }] ] ... [bound = { 'b' vertex_count [bound_color = { 'c' r g b }] ] ... [edge = { 'e' vertex_id ]",
     __FILE__,VDrawPArray,group);
+
+  theCommands.Add("vconnect", 
+    "vconnect : assembly_name Xo Yo Zo object1 object2 ..."
+    "  Makes an assembly of object instances located in point (Xo Yo Zo).",
+    __FILE__, VConnect, group);
+
+  theCommands.Add("vconnectto",
+    "vconnectto : instance_name Xo Yo Zo object"
+    "  Makes an instance 'instance_name' of 'object' with position (Xo Yo Zo).", 
+    __FILE__, VConnectTo,group);
+
+  theCommands.Add("vdisconnect",
+    "vdisconnect assembly_name (object_name | object_number | 'all')"
+    "  Disconnects all objects from assembly or disconnects object by name or number (use vlistconnected to enumerate assembly children).",
+    __FILE__,VDisconnect,group);
+
+  theCommands.Add("vaddconnected",
+    "vaddconnected assembly_name object_name"
+    "Adds object to assembly.",
+    __FILE__,VAddConnected,group);
+
+  theCommands.Add("vlistconnected",
+    "vlistconnected assembly_name"
+    "Lists objects in assembly.",
+    __FILE__,VListConnected,group);
+
+
+  theCommands.Add("vselmode", 
+    "vselmode : [object] mode_number is_turned_on=(1|0)\n"
+    "  switches selection mode for the determined object or\n"
+    "  for all objects in context.\n"
+    "  mode_number is non-negative integer that has different\n"
+    "    meaning for different interactive object classes.\n"
+    "    For shapes the following mode_number values are allowed:\n"
+    "      0 - shape\n"
+    "      1 - vertex\n"
+    "      2 - edge\n"
+    "      3 - wire\n"
+    "      4 - face\n"
+    "      5 - shell\n"
+    "      6 - solid\n"
+    "      7 - compsolid\n"
+    "      8 - compound\n"
+    "  is_turned_on is:\n"
+    "    1 if mode is to be switched on\n"
+    "    0 if mode is to be switched off\n", 
+    __FILE__, VSetSelectionMode, group);
+
+  theCommands.Add("vtriangle",
+    "vtriangle Name PointName PointName PointName", 
+    __FILE__, VTriangle,group);
+
+  theCommands.Add("vsegment",
+    "vsegment Name PointName PointName", 
+    __FILE__, VSegment,group);
+
+  theCommands.Add("vobjzlayer",
+    "vobjzlayer : set/get object [layerid] - set or get z layer id for the interactive object",
+    __FILE__, VObjZLayer, group);
+  
+  theCommands.Add("vpolygonoffset",
+    "vpolygonoffset : [object [mode factor units]] - sets/gets polygon offset parameters for an object, without arguments prints the default values",
+    __FILE__, VPolygonOffset, group);
+
+  theCommands.Add ("vshowfaceboundary",
+    "vshowfaceboundary : ObjectName isOn (1/0) [R G B [LineWidth [LineStyle]]]"
+    "- turns on/off drawing of face boundaries for ais object "
+    "and defines boundary line style.",
+    __FILE__, VShowFaceBoundary, group);
+
+  theCommands.Add ("vmarkerstest",
+                   "vmarkerstest: name X Y Z [PointsOnSide=10] [MarkerType=0] [Scale=1.0] [FileName=ImageFile]\n",
+                   __FILE__, VMarkersTest, group);
+
+  theCommands.Add ("text2brep",
+                   "text2brep: res text fontName fontSize [x=0.0 y=0.0 z=0.0 composite=1 {regular,bold,italic,bolditalic=regular}]\n",
+                   __FILE__, TextToBRep, group);
+  theCommands.Add ("vfont",
+                            "vfont [add pathToFont [fontName] [regular,bold,italic,bolditalic=undefined]]"
+                   "\n\t\t:        [find fontName [regular,bold,italic,bolditalic=undefined]]",
+                   __FILE__, VFont, group);
+  
+  theCommands.Add ("vsetedgetype",
+                   "vsetedgetype usage:\n"
+                   "vsetedgetype ShapeName [-force] [-type {solid, dash, dot}] [-color R G B] "
+                   "\n\t\t:        Sets edges type and color for input shape",
+                   __FILE__, VSetEdgeType, group);
+
+  theCommands.Add ("vunsetedgetype",
+                   "vunsetedgetype usage:\n"
+                   "vunsetedgetype ShapeName [-force]"
+                   "\n\t\t:        Unsets edges type and color for input shape",
+                   __FILE__, VUnsetEdgeType, group);
+
+  theCommands.Add ("vvertexmode",
+                   "vvertexmode [name | -set {isolated | all | inherited} [name1 name2 ...]]\n"
+                   "vvertexmode - prints the default vertex draw mode\n"
+                   "vvertexmode name - prints the vertex draw mode of the given object\n"
+                   "vvertexmode -set {isolated | all | inherited} - sets the default vertex draw mode and updates the mode for all displayed objects\n"
+                   "vvertexmode -set {isolated | all | inherited} name1 name2 ... - sets the vertex draw mode for the specified object(s)\n",
+                   __FILE__, VVertexMode, group);
 }