0028726: Quantity_NameOfColor should be replaced by Quantity_Color in function input...
[occt.git] / src / XSDRAWSTLVRML / XSDRAWSTLVRML.cxx
index ac1b515..cd751ea 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <XSDRAWSTLVRML.ixx>
-#include <Draw_Interpretor.hxx>
-#include <TopoDS_Shape.hxx>
-#include <VrmlAPI.hxx>
-#include <OSD_Path.hxx>
-#include <StlAPI.hxx>
-#include <XSDRAW.hxx>
-#include <DBRep.hxx>
-#include <VrmlAPI_Writer.hxx>
-#include <Quantity_Color.hxx>
-#include <Quantity_HArray1OfColor.hxx>
-#include <StlAPI_Writer.hxx>
-#include <Draw_PluginMacro.hxx>
-#include <XSDRAW.hxx>
-#include <XSDRAWSTEP.hxx>
-#include <XSDRAWIGES.hxx>
+
 #include <AIS_InteractiveContext.hxx>
-#include <ViewerTest.hxx>
+#include <Aspect_TypeOfMarker.hxx>
+#include <Bnd_Box.hxx>
+#include <DBRep.hxx>
 #include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
 #include <Draw_ProgressIndicator.hxx>
-#include <RWStl.hxx>
-#include <Quantity_Color.hxx>
-#include <V3d_View.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <SelectMgr_SelectionManager.hxx>
-#include <StdSelect_ViewerSelector3d.hxx>
-
-#include <Aspect_TypeOfMarker.hxx>
 #include <Graphic3d_MaterialAspect.hxx>
-
-#include <StlMesh_Mesh.hxx>
-#include <StlMesh_SequenceOfMeshTriangle.hxx>
-
-#include <MeshVS_Mesh.hxx>
-#include <MeshVS_MeshPrsBuilder.hxx>
-#include <MeshVS_TextPrsBuilder.hxx>
+#include <MeshVS_DataMapOfIntegerAsciiString.hxx>
+#include <MeshVS_DeformedDataSource.hxx>
 #include <MeshVS_Drawer.hxx>
 #include <MeshVS_DrawerAttribute.hxx>
+#include <MeshVS_ElementalColorPrsBuilder.hxx>
+#include <MeshVS_Mesh.hxx>
 #include <MeshVS_MeshEntityOwner.hxx>
-#include <MeshVS_DataMapOfIntegerAsciiString.hxx>
+#include <MeshVS_MeshPrsBuilder.hxx>
 #include <MeshVS_NodalColorPrsBuilder.hxx>
-#include <MeshVS_ElementalColorPrsBuilder.hxx>
+#include <MeshVS_PrsBuilder.hxx>
+#include <MeshVS_TextPrsBuilder.hxx>
 #include <MeshVS_VectorPrsBuilder.hxx>
-#include <MeshVS_DeformedDataSource.hxx>
-
-#include <XSDRAWSTLVRML_DataSource.hxx>
-#include <XSDRAWSTLVRML_DataSource3D.hxx>
-#include <XSDRAWSTLVRML_DrawableMesh.hxx>
-
+#include <OSD_Path.hxx>
+#include <Quantity_Color.hxx>
+#include <Quantity_HArray1OfColor.hxx>
 #include <Quantity_NameOfColor.hxx>
+#include <RWStl.hxx>
+#include <SelectMgr_SelectionManager.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <StdSelect_ViewerSelector3d.hxx>
+#include <StlAPI.hxx>
+#include <StlAPI_Writer.hxx>
+#include <StlMesh_Mesh.hxx>
+#include <StlMesh_SequenceOfMeshTriangle.hxx>
 #include <TColgp_SequenceOfXYZ.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_Array1OfReal.hxx>
 #include <TColStd_HPackedMapOfInteger.hxx>
 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
-#include <Standard_ErrorHandler.hxx>
+#include <TopoDS_Shape.hxx>
+#include <V3d_View.hxx>
+#include <ViewerTest.hxx>
+#include <VrmlAPI.hxx>
+#include <VrmlAPI_Writer.hxx>
+#include <VrmlData_DataMapOfShapeAppearance.hxx>
 #include <VrmlData_Scene.hxx>
 #include <VrmlData_ShapeConvert.hxx>
-#include <VrmlData_DataMapOfShapeAppearance.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <Bnd_Box.hxx>
+#include <XSDRAW.hxx>
+#include <XSDRAWIGES.hxx>
+#include <XSDRAWSTEP.hxx>
+#include <XSDRAWSTLVRML.hxx>
+#include <XSDRAWSTLVRML_DataSource.hxx>
+#include <XSDRAWSTLVRML_DataSource3D.hxx>
+#include <XSDRAWSTLVRML_DrawableMesh.hxx>
 
 // avoid warnings on 'extern "C"' functions returning C++ classes
-#ifdef WNT
+#ifdef _MSC_VER
 #pragma warning(4:4190)
 #endif
 
@@ -92,7 +86,7 @@ static Standard_Integer writestl
 {
   if (argc < 3 || argc > 4) {
     di << "Use: " << argv[0]
-    << " shape file [ascii/binary (0/1) : 1 by default]" << "\n";
+    << " shape file [ascii/binary (0/1) : 1 by default]\n";
   } else {
     TopoDS_Shape aShape = DBRep::Get(argv[1]);
     Standard_Boolean isASCIIMode = Standard_False;
@@ -130,7 +124,7 @@ static Standard_Integer writevrml
 {
   if (argc < 3 || argc > 5) 
   {
-    di << "wrong number of parameters" << "\n";
+    di << "wrong number of parameters\n";
     return 0;
   }
 
@@ -241,7 +235,7 @@ static Standard_Integer loadvrml
       }
     }
     else {
-      di << "cannot open file" << "\n";
+      di << "cannot open file\n";
     }
 
 
@@ -256,15 +250,15 @@ static Standard_Integer createmesh
 {
   if (argc<3)
   {
-    di << "Wrong number of parameters" << "\n";
-    di << "Use: " << argv[0] << " <mesh name> <stl file>" << "\n";
+    di << "Wrong number of parameters\n";
+    di << "Use: " << argv[0] << " <mesh name> <stl file>\n";
     return 0;
   }
 
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    di << "No active view. Please call 'vinit' first" << "\n";
+    di << "No active view. Please call 'vinit' first\n";
     return 0;
   }
 
@@ -273,11 +267,11 @@ static Standard_Integer createmesh
   Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
   Handle(StlMesh_Mesh) aSTLMesh = RWStl::ReadFile (aFile, aProgress);
 
-  di << "Reading OK..." << "\n";
+  di << "Reading OK...\n";
   Handle( XSDRAWSTLVRML_DataSource ) aDS = new XSDRAWSTLVRML_DataSource( aSTLMesh );
-  di << "Data source is created successful" << "\n";
+  di << "Data source is created successful\n";
   Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
-  di << "MeshVS_Mesh is created successful" << "\n";
+  di << "MeshVS_Mesh is created successful\n";
 
   aMesh->SetDataSource( aDS );
   aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
@@ -309,22 +303,22 @@ static Standard_Integer create3d
 {
   if (argc<2)
   {
-    di << "Wrong number of parameters" << "\n";
-    di << "Use: " << argv[0] << " <mesh name>" << "\n";
+    di << "Wrong number of parameters\n";
+    di << "Use: " << argv[0] << " <mesh name>\n";
     return 0;
   }
 
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    di << "No active view. Please call 'vinit' first" << "\n";
+    di << "No active view. Please call 'vinit' first\n";
     return 0;
   }
 
   Handle( XSDRAWSTLVRML_DataSource3D ) aDS = new XSDRAWSTLVRML_DataSource3D();
-  di << "Data source is created successful" << "\n";
+  di << "Data source is created successful\n";
   Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
-  di << "MeshVS_Mesh is created successful" << "\n";
+  di << "MeshVS_Mesh is created successful\n";
 
   aMesh->SetDataSource( aDS );
   aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
@@ -357,7 +351,7 @@ Handle( MeshVS_Mesh ) getMesh( const char* theName, Draw_Interpretor& di)
 
   if( aDrawMesh.IsNull() )
   {
-    di << "There is no such object" << "\n";
+    di << "There is no such object\n";
     return NULL;
   }
   else
@@ -365,7 +359,7 @@ Handle( MeshVS_Mesh ) getMesh( const char* theName, Draw_Interpretor& di)
     Handle( MeshVS_Mesh ) aMesh = aDrawMesh->GetMesh();
     if( aMesh.IsNull() )
     {
-      di << "There is invalid mesh" << "\n";
+      di << "There is invalid mesh\n";
       return NULL;
     }
     else
@@ -378,7 +372,7 @@ static Standard_Integer setcolor
 (Draw_Interpretor& di, Standard_Integer argc, const char** argv, Standard_Integer theParam )
 {
   if (argc<5)
-    di << "Wrong number of parameters" << "\n";
+    di << "Wrong number of parameters\n";
   else
   {
     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
@@ -393,9 +387,9 @@ static Standard_Integer setcolor
       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
 
       if( aContext.IsNull() )
-        di << "The context is null" << "\n";
+        di << "The context is null\n";
       else
-        aContext->Redisplay( aMesh );
+        aContext->Redisplay (aMesh, Standard_True);
     }
   }
   return 0;
@@ -417,7 +411,7 @@ static Standard_Integer meshmat
 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
 {
   if (argc<3)
-    di << "Wrong number of parameters" << "\n";
+    di << "Wrong number of parameters\n";
   else
   {
     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
@@ -431,7 +425,7 @@ static Standard_Integer meshmat
       if (argc == 4)
       {
         Standard_Real aTransparency = Draw::Atof(argv[3]);
-        aMatAsp.SetTransparency(aTransparency);
+        aMatAsp.SetTransparency (Standard_ShortReal (aTransparency));
       }
       aMesh->GetDrawer()->SetMaterial( MeshVS_DA_FrontMaterial, aMatAsp );
       aMesh->GetDrawer()->SetMaterial( MeshVS_DA_BackMaterial, aMatAsp );
@@ -439,9 +433,9 @@ static Standard_Integer meshmat
       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
 
       if( aContext.IsNull() )
-        di << "The context is null" << "\n";
+        di << "The context is null\n";
       else
-        aContext->Redisplay( aMesh );
+        aContext->Redisplay (aMesh, Standard_True);
     }
   }
   return 0;
@@ -451,7 +445,7 @@ static Standard_Integer shrink
 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
 {
   if (argc<3)
-    di << "Wrong number of parameters" << "\n";
+    di << "Wrong number of parameters\n";
   else
   {
     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
@@ -463,9 +457,9 @@ static Standard_Integer shrink
       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
 
       if( aContext.IsNull() )
-        di << "The context is null" << "\n";
+        di << "The context is null\n";
       else
-        aContext->Redisplay( aMesh );
+        aContext->Redisplay (aMesh, Standard_True);
     }
   }
   return 0;
@@ -476,24 +470,24 @@ static Standard_Integer closed (Draw_Interpretor& theDI, Standard_Integer theArg
 {
   if (theArgc < 3)
   {
-    theDI << "Wrong number of parameters." << "\n";
+    theDI << "Wrong number of parameters.\n";
   }
   else
   {
     Handle(MeshVS_Mesh) aMesh = getMesh (theArgv[1], theDI);
     if (!aMesh.IsNull())
     {
-      Standard_Integer aFlag = Draw::Atoi (theArgv[2]);
+      Standard_Boolean aFlag = Draw::Atoi (theArgv[2]) != 0;
       aMesh->GetDrawer()->SetBoolean (MeshVS_DA_SupressBackFaces, aFlag);
 
       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
       if (aContext.IsNull())
       {
-        theDI << "The context is null" << "\n";
+        theDI << "The context is null\n";
       }
       else
       {
-        aContext->Redisplay (aMesh);
+        aContext->Redisplay (aMesh, Standard_True);
       }
     }
   }
@@ -506,7 +500,7 @@ static Standard_Integer mdisplay
 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
 {
   if (argc<2)
-    di << "Wrong number of parameters" << "\n";
+    di << "Wrong number of parameters\n";
   else
   {
     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
@@ -515,13 +509,17 @@ static Standard_Integer mdisplay
       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
 
       if( aContext.IsNull() )
-        di << "The context is null" << "\n";
+        di << "The context is null\n";
       else
       {
-        if( aContext->HasOpenedContext() )
+        Standard_DISABLE_DEPRECATION_WARNINGS
+        if (aContext->HasOpenedContext())
+        {
           aContext->CloseLocalContext();
+        }
+        Standard_ENABLE_DEPRECATION_WARNINGS
 
-        aContext->Display( aMesh );
+        aContext->Display (aMesh, Standard_True);
       }
     }
   }
@@ -532,7 +530,7 @@ static Standard_Integer merase
 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
 {
   if (argc<2)
-    di << "Wrong number of parameters" << "\n";
+    di << "Wrong number of parameters\n";
   else
   {
     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
@@ -541,17 +539,21 @@ static Standard_Integer merase
       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
 
       if( aContext.IsNull() )
-        di << "The context is null" << "\n";
+        di << "The context is null\n";
       else
       {
-        if( aContext->HasOpenedContext() )
+        Standard_DISABLE_DEPRECATION_WARNINGS
+        if (aContext->HasOpenedContext())
+        {
           aContext->CloseLocalContext();
+        }
+        Standard_ENABLE_DEPRECATION_WARNINGS
 
-        aContext->Erase( aMesh );
+        aContext->Erase (aMesh, Standard_True);
       }
     }
     else
-      di << "Mesh is null" << "\n";
+      di << "Mesh is null\n";
   }
   return 0;
 }
@@ -561,8 +563,8 @@ static Standard_Integer hidesel
 {
   if (argc<2)
   {
-    di << "Wrong number of parameters" << "\n";
-    di << "Use: " << argv[0] << " <mesh name>" << "\n";
+    di << "Wrong number of parameters\n";
+    di << "Use: " << argv[0] << " <mesh name>\n";
     return 0;
   }
 
@@ -570,12 +572,12 @@ static Standard_Integer hidesel
   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
   if( aMesh.IsNull() )
   {
-    di << "The mesh is invalid" << "\n";
+    di << "The mesh is invalid\n";
     return 0;
   }
 
   if( aContext.IsNull() )
-    di << "The context is null" << "\n";
+    di << "The context is null\n";
   else
   {
     Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = aMesh->GetHiddenNodes();
@@ -604,10 +606,10 @@ static Standard_Integer hidesel
         }
       }
     }
-    aContext->ClearSelected();
+    aContext->ClearSelected (Standard_False);
     aMesh->SetHiddenNodes( aHiddenNodes );
     aMesh->SetHiddenElems( aHiddenElements );
-    aContext->Redisplay( aMesh );
+    aContext->Redisplay (aMesh, Standard_True);
   }
 
   return 0;
@@ -618,8 +620,8 @@ static Standard_Integer showonly
 {
   if (argc<2)
   {
-    di << "Wrong number of parameters" << "\n";
-    di << "Use: " << argv[0] << " <mesh name>" << "\n";
+    di << "Wrong number of parameters\n";
+    di << "Use: " << argv[0] << " <mesh name>\n";
     return 0;
   }
 
@@ -628,12 +630,12 @@ static Standard_Integer showonly
   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
   if( aMesh.IsNull() )
   {
-    di << "The mesh is invalid" << "\n";
+    di << "The mesh is invalid\n";
     return 0;
   }
 
   if( aContext.IsNull() )
-    di << "The context is null" << "\n";
+    di << "The context is null\n";
   else
   {
     Handle(TColStd_HPackedMapOfInteger) aHiddenNodes =
@@ -658,7 +660,7 @@ static Standard_Integer showonly
     }
     aMesh->SetHiddenNodes( aHiddenNodes );
     aMesh->SetHiddenElems( aHiddenElements );
-    aContext->Redisplay( aMesh );
+    aContext->Redisplay (aMesh, Standard_True);
   }
 
   return 0;
@@ -669,8 +671,8 @@ static Standard_Integer showall
 {
   if (argc<2)
   {
-    di << "Wrong number of parameters" << "\n";
-    di << "Use: " << argv[0] << " <mesh name>" << "\n";
+    di << "Wrong number of parameters\n";
+    di << "Use: " << argv[0] << " <mesh name>\n";
     return 0;
   }
 
@@ -678,17 +680,17 @@ static Standard_Integer showall
   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
   if( aMesh.IsNull() )
   {
-    di << "The mesh is invalid" << "\n";
+    di << "The mesh is invalid\n";
     return 0;
   }
 
   if( aContext.IsNull() )
-    di << "The context is null" << "\n";
+    di << "The context is null\n";
   else
   {
     aMesh->SetHiddenNodes( new TColStd_HPackedMapOfInteger() );
     aMesh->SetHiddenElems( new TColStd_HPackedMapOfInteger() );
-    aContext->Redisplay( aMesh );
+    aContext->Redisplay (aMesh, Standard_True);
   }
 
   return 0;
@@ -704,15 +706,15 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
     OCC_CATCH_SIGNALS
       if ( argc < 4 )
       {
-        di << "Wrong number of parameters" << "\n";
-        di << "Use : meshcolors <mesh name> <mode> <isreflect>" << "\n";
-        di << "mode : {elem1|elem2|nodal|nodaltex|none}"<< "\n";
-        di << "       elem1 - different color for each element" << "\n";
-        di << "       elem2 - one color for one side"<<"\n";
-        di << "       nodal - different color for each node"<< "\n";
-        di << "       nodaltex - different color for each node with texture interpolation"<< "\n";
-        di << "       none  - clear"<< "\n";
-        di << "isreflect : {0|1} "<< "\n";
+        di << "Wrong number of parameters\n";
+        di << "Use : meshcolors <mesh name> <mode> <isreflect>\n";
+        di << "mode : {elem1|elem2|nodal|nodaltex|none}\n";
+        di << "       elem1 - different color for each element\n";
+        di << "       elem2 - one color for one side\n";
+        di << "       nodal - different color for each node\n";
+        di << "       nodaltex - different color for each node with texture interpolation\n";
+        di << "       none  - clear\n";
+        di << "isreflect : {0|1} \n";
 
         return 0;
       }
@@ -721,31 +723,31 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
 
       if ( aMesh.IsNull() )
       {
-        di << "Mesh not found" << "\n";
+        di << "Mesh not found\n";
         return 0;
       }
       Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
       if ( anIC.IsNull() )
       {
-        di << "The context is null" << "\n";
+        di << "The context is null\n";
         return 0;
       }
       if( !aMesh.IsNull() )
       {
         TCollection_AsciiString aMode = TCollection_AsciiString (argv[2]);
-        Quantity_Color aColor1( (Quantity_NameOfColor)( Quantity_NOC_BLUE1 ) );
-        Quantity_Color aColor2( (Quantity_NameOfColor)( Quantity_NOC_RED1 ) );
+        Quantity_Color aColor1(Quantity_NOC_BLUE1);
+        Quantity_Color aColor2(Quantity_NOC_RED1);
         if( aMode.IsEqual("elem1") || aMode.IsEqual("elem2") || aMode.IsEqual("nodal") || aMode.IsEqual("nodaltex") || aMode.IsEqual("none") )
         {
           Handle(MeshVS_PrsBuilder) aTempBuilder;
           Standard_Integer aReflection = Draw::Atoi(argv[3]);
 
           for (Standard_Integer aCount = 0 ; aCount < aMesh->GetBuildersCount(); aCount++ ){
-            aTempBuilder = Handle(MeshVS_PrsBuilder)::DownCast(aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder"));
+            aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder");
             if( !aTempBuilder.IsNull())
               aMesh->RemoveBuilderById(aTempBuilder->GetId());
 
-            aTempBuilder = Handle(MeshVS_PrsBuilder)::DownCast(aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder"));
+            aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder");
             if( !aTempBuilder.IsNull())
               aMesh->RemoveBuilderById(aTempBuilder->GetId());
           }
@@ -845,27 +847,22 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
             aBuilder->SetInvalidColor(Quantity_NOC_BLACK);
             aBuilder->SetTextureCoords(aScaleMap);
             aMesh->AddBuilder(aBuilder, Standard_True);
-
-            //set viewer to display texures
-            const Handle(V3d_Viewer)& aViewer = anIC->CurrentViewer();
-            for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
-                 aViewer->ActiveView()->SetSurfaceDetail(V3d_TEX_ALL);
           }
 
-          aMesh->GetDrawer()->SetBoolean ( MeshVS_DA_ColorReflection, Standard_Boolean(aReflection) );
+          aMesh->GetDrawer()->SetBoolean (MeshVS_DA_ColorReflection, aReflection != 0);
 
-          anIC->Redisplay( aMesh );
+          anIC->Redisplay (aMesh, Standard_True);
         }
         else
         {
-          di << "Wrong mode name" << "\n";
+          di << "Wrong mode name\n";
           return 0;
         }
       }
   }
   catch ( Standard_Failure )
   {
-    di << "Error" << "\n";
+    di << "Error\n";
   }
 
   return 0;
@@ -877,12 +874,12 @@ static Standard_Integer meshvectors( Draw_Interpretor& di,
 {
   if ( argc < 3 )
   {
-    di << "Wrong number of parameters" << "\n";
-    di << "Use : meshvectors <mesh name> < -mode {elem|nodal|none} > [-maxlen len] [-color name] [-arrowpart ratio] [-issimple {1|0}]" << "\n";
-    di << "Supported mode values:"<< "\n";
-    di << "       elem  - vector per element" << "\n";
-    di << "       nodal - vector per node"<< "\n";
-    di << "       none  - clear"<< "\n";
+    di << "Wrong number of parameters\n";
+    di << "Use : meshvectors <mesh name> < -mode {elem|nodal|none} > [-maxlen len] [-color name] [-arrowpart ratio] [-issimple {1|0}]\n";
+    di << "Supported mode values:\n";
+    di << "       elem  - vector per element\n";
+    di << "       nodal - vector per node\n";
+    di << "       none  - clear\n";
 
     return 0;
   }
@@ -891,13 +888,13 @@ static Standard_Integer meshvectors( Draw_Interpretor& di,
 
   if ( aMesh.IsNull() )
   {
-    di << "Mesh not found" << "\n";
+    di << "Mesh not found\n";
     return 0;
   }
   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
   if ( anIC.IsNull() )
   {
-    di << "The context is null" << "\n";
+    di << "The context is null\n";
     return 0;
   }
 
@@ -930,7 +927,7 @@ static Standard_Integer meshvectors( Draw_Interpretor& di,
       }
       else if (aParam == "-issimple")
       {
-        isSimplePrs = Draw::Atoi(argv[anIdx]);
+        isSimplePrs = Draw::Atoi(argv[anIdx]) != 0;
       }
       aParam.Clear();
     }
@@ -942,13 +939,13 @@ static Standard_Integer meshvectors( Draw_Interpretor& di,
 
   if( !aMode.IsEqual("elem") && !aMode.IsEqual("nodal") && !aMode.IsEqual("none") )
   {
-    di << "Wrong mode name" << "\n";
+    di << "Wrong mode name\n";
     return 0;
   }
 
   Handle(MeshVS_PrsBuilder) aTempBuilder;
 
-  aTempBuilder = Handle(MeshVS_PrsBuilder)::DownCast(aMesh->FindBuilder("MeshVS_VectorPrsBuilder"));
+  aTempBuilder = aMesh->FindBuilder("MeshVS_VectorPrsBuilder");
   if( !aTempBuilder.IsNull())
     aMesh->RemoveBuilderById(aTempBuilder->GetId());
 
@@ -970,18 +967,32 @@ static Standard_Integer meshvectors( Draw_Interpretor& di,
     Standard_Integer aNbNodes;
     MeshVS_EntityType aEntType;
 
+    TColStd_Array1OfReal aCoords(1, 3);
+    aCoords.Init (0.);
     TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllIDs );
     for ( ; anIter.More(); anIter.Next() )
     {
-      TColStd_Array1OfReal aCoords(1, 3);
-      if (anIsElement)
-        aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3));
+      Standard_Boolean IsValidData = Standard_False; 
+      if (anIsElement) {
+        aMesh->GetDataSource()->GetGeomType(anIter.Key(), anIsElement, aEntType);
+        if (aEntType == MeshVS_ET_Face)
+          IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3));
+      } else
+        IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
+
+      gp_Vec aNorm;
+      if(IsValidData)
+      { 
+        aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
+        if(aNorm.Magnitude() < gp::Resolution())
+        {
+          aNorm = gp_Vec(0,0,1); //method GetGeom(...) returns coordinates of nodes
+        }
+      }
       else
-        aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
-
-      gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
-      if( !aNorm.Magnitude() )
+      {
         aNorm = gp_Vec(0,0,1);
+      }
       aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized());
     }
 
@@ -989,7 +1000,7 @@ static Standard_Integer meshvectors( Draw_Interpretor& di,
     aMesh->GetDrawer()->SetDouble ( MeshVS_DA_VectorArrowPart, anArrowPart );
   }
 
-  anIC->Redisplay( aMesh );
+  anIC->Redisplay (aMesh, Standard_True);
 
   return 0;
 }
@@ -1001,8 +1012,8 @@ static Standard_Integer meshtext( Draw_Interpretor& di,
 {
   if ( argc < 2 )
   {
-    di << "Wrong number of parameters" << "\n";
-    di << "Use : meshtext <mesh name>" << "\n";
+    di << "Wrong number of parameters\n";
+    di << "Use : meshtext <mesh name>\n";
     return 0;
   }
 
@@ -1010,14 +1021,14 @@ static Standard_Integer meshtext( Draw_Interpretor& di,
 
   if ( aMesh.IsNull() )
   {
-    di << "Mesh not found" << "\n";
+    di << "Mesh not found\n";
     return 0;
   }
 
   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
   if ( anIC.IsNull() )
   {
-    di << "The context is null" << "\n";
+    di << "The context is null\n";
     return 0;
   }
 
@@ -1041,8 +1052,8 @@ static Standard_Integer meshdeform( Draw_Interpretor& di,
 {
   if ( argc < 3 )
   {
-    di << "Wrong number of parameters" << "\n";
-    di << "Use : meshdeform <mesh name> < -mode {on|off} > [-scale scalefactor]" << "\n";
+    di << "Wrong number of parameters\n";
+    di << "Use : meshdeform <mesh name> < -mode {on|off} > [-scale scalefactor]\n";
     return 0;
   }
 
@@ -1050,13 +1061,13 @@ static Standard_Integer meshdeform( Draw_Interpretor& di,
 
   if ( aMesh.IsNull() )
   {
-    di << "Mesh not found" << "\n";
+    di << "Mesh not found\n";
     return 0;
   }
   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
   if ( anIC.IsNull() )
   {
-    di << "The context is null" << "\n";
+    di << "The context is null\n";
     return 0;
   }
 
@@ -1086,7 +1097,7 @@ static Standard_Integer meshdeform( Draw_Interpretor& di,
 
   if(!aMode.IsEqual("on") && !aMode.IsEqual("off"))
   {
-    di << "Wrong mode name" << "\n";
+    di << "Wrong mode name\n";
     return 0;
   }
 
@@ -1112,7 +1123,7 @@ static Standard_Integer meshdeform( Draw_Interpretor& di,
 
   aMesh->SetDataSource(aDefDS);
 
-  anIC->Redisplay( aMesh );
+  anIC->Redisplay (aMesh, Standard_False);
 
   Handle( V3d_View ) aView = ViewerTest::CurrentView();
   if ( !aView.IsNull() )
@@ -1130,22 +1141,22 @@ static Standard_Integer mesh_edge_width( Draw_Interpretor& di,
     OCC_CATCH_SIGNALS
       if ( argc < 3 )
       {
-        di << "Wrong number of parameters" << "\n";
-        di << "Use : mesh_edge_width <mesh name> <width>" << "\n";
+        di << "Wrong number of parameters\n";
+        di << "Use : mesh_edge_width <mesh name> <width>\n";
         return 0;
       }
 
       Handle(MeshVS_Mesh) aMesh = getMesh( argv[ 1 ], di );
       if ( aMesh.IsNull() )
       {
-        di << "Mesh not found" << "\n";
+        di << "Mesh not found\n";
         return 0;
       }
 
       const char* aWidthStr = argv[ 2 ];
       if ( aWidthStr == 0 || Draw::Atof( aWidthStr ) <= 0 )
       {
-        di << "Width must be real value more than zero" << "\n";
+        di << "Width must be real value more than zero\n";
         return 0;
       }
 
@@ -1154,23 +1165,23 @@ static Standard_Integer mesh_edge_width( Draw_Interpretor& di,
       Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
       if ( anIC.IsNull() )
       {
-        di << "The context is null" << "\n";
+        di << "The context is null\n";
         return 0;
       }
 
       Handle(MeshVS_Drawer) aDrawer = aMesh->GetDrawer();
       if ( aDrawer.IsNull() )
       {
-        di << "The drawer is null" << "\n";
+        di << "The drawer is null\n";
         return 0;
       }
 
       aDrawer->SetDouble( MeshVS_DA_EdgeWidth, aWidth );
-      anIC->Redisplay( aMesh );
+      anIC->Redisplay (aMesh, Standard_True);
   }
   catch ( Standard_Failure )
   {
-    di << "Error" << "\n";
+    di << "Error\n";
   }
 
   return 0;
@@ -1184,14 +1195,14 @@ static Standard_Integer meshinfo(Draw_Interpretor& di,
 {
   if ( argc != 2 )
   {
-    di << "Wrong number of parameters. Use : meshinfo mesh" << "\n";
+    di << "Wrong number of parameters. Use : meshinfo mesh\n";
     return 0;
   }
 
   Handle(MeshVS_Mesh) aMesh = getMesh(argv[ 1 ], di);
   if ( aMesh.IsNull() )
   {
-    di << "Mesh not found" << "\n";
+    di << "Mesh not found\n";
     return 0;
   }
 
@@ -1252,7 +1263,7 @@ void XSDRAWSTLVRML::Factory(Draw_Interpretor& theDI)
   XSDRAWSTLVRML::InitCommands(theDI);
   XSDRAW::LoadDraw(theDI);
 #ifdef OCCT_DEBUG
-  theDI << "Draw Plugin : All TKXSDRAW commands are loaded" << "\n";
+  theDI << "Draw Plugin : All TKXSDRAW commands are loaded\n";
 #endif
 }