]> OCCT Git - occt.git/commitdiff
// Updating XDEDRAW module
authordpasukhi <dpasukhi@opencascade.com>
Sat, 7 Jan 2023 16:13:54 +0000 (16:13 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Thu, 9 Mar 2023 17:37:51 +0000 (17:37 +0000)
18 files changed:
src/IGESCAFControl/IGESCAFControl_Writer.cxx
src/RWGltf/RWGltf_ConfigurationNode.hxx
src/RWGltf/RWGltf_Provider.cxx
src/RWStl/RWStl_ConfigurationNode.cxx
src/RWStl/RWStl_ConfigurationNode.hxx
src/RWStl/RWStl_Provider.cxx
src/STEPCAFControl/STEPCAFControl_Provider.cxx
src/STEPControl/STEPControl_Writer.cxx
src/XDEDRAW/XDEDRAW_Common.cxx
src/XSControl/XSControl.cxx
src/XSControl/XSControl_Controller.cxx
src/XSControl/XSControl_FuncShape.cxx
src/XSControl/XSControl_Functions.cxx
src/XSControl/XSControl_WorkSession.hxx
src/XSControl/XSControl_Writer.cxx
src/XSDRAW/XSDRAW.cxx
src/XSDRAWIGES/XSDRAWIGES.cxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx

index 706a3e93d7e6dbe2732acdfe42a5f6a4e72eee71..fbbc053e8153e7b61edea17ac5035ea38dad5aa0 100644 (file)
@@ -35,6 +35,7 @@
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Shape.hxx>
+#include <Transfer_FinderProcess.hxx>
 #include <Transfer_TransientListBinder.hxx>
 #include <TransferBRep.hxx>
 #include <TransferBRep_ShapeMapper.hxx>
index df01849bb5e173afdc0de3eda61ea3fc33f4a8af..381d6aafb7c1602574f79b8f14fcab723cd47682 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <DE_ConfigurationNode.hxx>
 #include <RWMesh_CoordinateSystem.hxx>
+#include <RWGltf_DracoParameters.hxx>
 #include <RWGltf_WriterTrsfFormat.hxx>
 #include <RWMesh_NameFormat.hxx>
 
@@ -107,10 +108,12 @@ public:
     RWGltf_WriterTrsfFormat WriteTrsfFormat = RWGltf_WriterTrsfFormat_Compact; //!< Transformation format to write into glTF file
     RWMesh_NameFormat WriteNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct; //!< Name format for exporting Nodes
     RWMesh_NameFormat WriteMeshNameFormat = RWMesh_NameFormat_Product; //!< Name format for exporting Meshes
+    RWGltf_DracoParameters WriteDracoParameters; //!< Defines draco compression parameters
     bool WriteForcedUVExport = false; //!< Export UV coordinates even if there are no mapped texture
     bool WriteEmbedTexturesInGlb = true; //!< Flag to write image textures into GLB file
     bool WriteMergeFaces = false; //!< Flag to merge faces within a single part
     bool WriteSplitIndices16 = false; //!< Flag to prefer keeping 16-bit indexes while merging face
+    bool WriteParallel = false; //!< Flag to use multithreading
   } InternalParameters;
 };
 
index ecd3d1d9e46e75bd780902ceeb3a072de764f8eb..6ae3b23cf7b9f84f96c56367410cf017851245e4 100644 (file)
@@ -145,12 +145,14 @@ bool RWGltf_Provider::Write(const TCollection_AsciiString& thePath,
   anExt.LowerCase();
   RWGltf_CafWriter aWriter(thePath, anExt.EndsWith(".glb"));
   aWriter.SetCoordinateSystemConverter(aConverter);
+  aWriter.SetCompressionParameters(aNode->InternalParameters.WriteDracoParameters);
   aWriter.SetTransformationFormat(aNode->InternalParameters.WriteTrsfFormat);
   aWriter.SetNodeNameFormat(aNode->InternalParameters.WriteNodeNameFormat);
   aWriter.SetMeshNameFormat(aNode->InternalParameters.WriteMeshNameFormat);
   aWriter.SetForcedUVExport(aNode->InternalParameters.WriteForcedUVExport);
   aWriter.SetToEmbedTexturesInGlb(aNode->InternalParameters.WriteEmbedTexturesInGlb);
   aWriter.SetMergeFaces(aNode->InternalParameters.WriteMergeFaces);
+  aWriter.SetParallel(aNode->InternalParameters.WriteParallel);
   aWriter.SetSplitIndices16(aNode->InternalParameters.WriteSplitIndices16);
   if (!aWriter.Perform(theDocument, aFileInfo, theProgress))
   {
index 990f24c73734533f5fd2c9b5618abe7dadfd714a..fa674d1a18a94ec816ce55804135600c166c34dc 100644 (file)
@@ -56,8 +56,8 @@ bool RWStl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theRes
 
   InternalParameters.ReadMergeAngle = 
     theResource->RealVal("read.merge.angle", InternalParameters.ReadMergeAngle, aScope);
-  InternalParameters.ReadBRep = 
-    theResource->BooleanVal("read.brep", InternalParameters.ReadBRep, aScope);
+  //InternalParameters.ReadBRep = 
+  //  theResource->BooleanVal("read.brep", InternalParameters.ReadBRep, aScope);
   InternalParameters.WriteAscii = 
     theResource->BooleanVal("write.ascii", InternalParameters.WriteAscii, aScope);
   return true;
@@ -84,11 +84,11 @@ TCollection_AsciiString RWStl_ConfigurationNode::Save() const
   aResult += aScope + "read.merge.angle :\t " + InternalParameters.ReadMergeAngle + "\n";
   aResult += "!\n";
 
-  aResult += "!\n";
-  aResult += "!Setting up Boundary Representation flag\n";
-  aResult += "!Default value: false. Available values: \"on\", \"off\"\n";
-  aResult += aScope + "read.brep :\t " + InternalParameters.ReadBRep + "\n";
-  aResult += "!\n";
+  //aResult += "!\n";
+  //aResult += "!Setting up Boundary Representation flag\n";
+  //aResult += "!Default value: false. Available values: \"on\", \"off\"\n";
+  //aResult += aScope + "read.brep :\t " + InternalParameters.ReadBRep + "\n";
+  //aResult += "!\n";
 
   aResult += "!\n";
   aResult += "!Write parameters:\n";
index b1e33d7ee2beadfa1566772fe3f392b05ea2eb95..4d73eb0a4c43984b9a8bdaa05e0deddbe1a708f5 100644 (file)
@@ -84,11 +84,17 @@ public:
   Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
 
 public:
+  enum ReadMode_ShapeType
+  {
+    ReadMode_ShapeType_MultiMesh = 0,
+    ReadMode_ShapeType_SingleMesh,
+    ReadMode_ShapeType_CompShape,
+  };
   struct RWStl_InternalSection
   {
     // Read
     double ReadMergeAngle = 90.; //!< Input merge angle value
-    bool ReadBRep = false; //!< Setting up Boundary Representation flag
+    ReadMode_ShapeType ReadShapeType = ReadMode_ShapeType_SingleMesh; //!< Defines result type of transferred shape
 
     // Write
     bool WriteAscii = true; //!< Setting up writing mode (Ascii or Binary)
index 3dcddf7c92a5dcede66506ff96bf8eee32edd7d7..9c07bf6363a1ee49b2c9159d6e2c35424be71f54 100644 (file)
@@ -139,27 +139,71 @@ bool RWStl_Provider::Read(const TCollection_AsciiString& thePath,
       return false;
     }
   }
-  if (!aNode->InternalParameters.ReadBRep)
+  switch (aNode->InternalParameters.ReadShapeType)
   {
-    Handle(Poly_Triangulation) aTriangulation =
-      RWStl::ReadFile(thePath.ToCString(), aMergeAngle, theProgress);
+    case(RWStl_ConfigurationNode::ReadMode_ShapeType_MultiMesh):
+    {
+      NCollection_Sequence<Handle(Poly_Triangulation)> aTriangList;
+      // Read STL file to the triangulation list.
+      RWStl::ReadFile(thePath.ToCString(), aMergeAngle, aTriangList, theProgress);
+      BRep_Builder aB;
+      TopoDS_Face aFace;
+      if (aTriangList.Size() == 1)
+      {
+        aB.MakeFace(aFace);
+        aB.UpdateFace(aFace, aTriangList.First());
+        theShape = aFace;
+      }
+      else
+      {
+        TopoDS_Compound aCmp;
+        for (NCollection_Sequence<Handle(Poly_Triangulation)>::Iterator anIt(aTriangList);
+             anIt.More(); anIt.Next())
+        {
+          if (aCmp.IsNull())
+          {
+            aB.MakeCompound(aCmp);
+          }
+          if (aFace.IsNull())
+          {
+            aB.MakeFace(aFace);
+          }
+          aB.UpdateFace(aFace, anIt.Value());
+          aB.Add(aCmp, aFace);
+        }
+        theShape = aCmp;
+      }
+      break;
+    }
+    case(RWStl_ConfigurationNode::ReadMode_ShapeType_SingleMesh):
+    {
+      // Read STL file to the triangulation.
+      Handle(Poly_Triangulation) aTriangulation =
+        RWStl::ReadFile(thePath.ToCString(), aMergeAngle, theProgress);
 
-    TopoDS_Face aFace;
-    BRep_Builder aB;
-    aB.MakeFace(aFace);
-    aB.UpdateFace(aFace, aTriangulation);
-    theShape = aFace;
-  }
-  else
-  {
-    Standard_DISABLE_DEPRECATION_WARNINGS
-      if (!StlAPI::Read(theShape, thePath.ToCString()))
+      if (!aTriangulation.IsNull())
       {
-        Message::SendFail() << "Error: RWStl_Provider : [" <<
-          thePath << "] : Cannot read any relevant data from the STL file";
-        return false;
+        TopoDS_Face aFace;
+        BRep_Builder aB;
+        aB.MakeFace(aFace);
+        aB.UpdateFace(aFace, aTriangulation);
+        theShape = aFace;
       }
-    Standard_ENABLE_DEPRECATION_WARNINGS
+      break;
+    }
+    case(RWStl_ConfigurationNode::ReadMode_ShapeType_CompShape):
+    {
+      Standard_DISABLE_DEPRECATION_WARNINGS
+        StlAPI::Read(theShape, thePath.ToCString());
+      Standard_ENABLE_DEPRECATION_WARNINGS
+        break;
+    }
+  }
+  if (theShape.IsNull())
+  {
+    Message::SendFail() << "Error: RWStl_Provider : [" <<
+      thePath << "] : Cannot read any relevant data from the STL file";
+    return false;
   }
   return true;
 }
index 0d11d51b55d7f342407b73540d85eeef543e2796..f5a007359cbf1ef0c26d8ff6736a00a537c35fd5 100644 (file)
@@ -340,7 +340,7 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
   if (!aReader.Transfer(theDocument, theProgress))
   {
     Message::SendFail() << "Error: STEPCAFControl_Provider : [" <<
-      aFile << "] : Cannot read any relevant data from the IGES file";
+      aFile << "] : Cannot read any relevant data from the STEP file";
     resetStatic();
     return false;
   }
@@ -398,7 +398,7 @@ bool STEPCAFControl_Provider::Read(std::istream& theIStream,
   if (!aReader.Transfer(theDocument, theProgress))
   {
     Message::SendFail() << "Error: STEPCAFControl_Provider : "
-      << "Cannot read any relevant data from the IGES file";
+      << "Cannot read any relevant data from the STEP file";
     resetStatic();
     return false;
   }
index 96756267ecef40b98ea084f916dbcd9ea9fb88c3..b03b39a70bae4694b8b114cd38701cc30b31fe50 100644 (file)
@@ -25,6 +25,7 @@
 #include <XSAlgo.hxx>
 #include <XSAlgo_AlgoContainer.hxx>
 #include <XSControl_WorkSession.hxx>
+#include <XSControl_TransferWriter.hxx>
 #include <UnitsMethods.hxx>
 
 //=======================================================================
index af05ce164e7ae22c5c06ef54b354071a077c0f33..585f64e0e54677e0efe6d9e19f9bd5ed2311b8b6 100644 (file)
@@ -96,6 +96,7 @@ static void CollectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS
   {
     return;
   }
+  theMap.Bind(theName, theWS);
   for (XSControl_WorkSessionMap::Iterator anIter(theWS->ReferenceWS());
        anIter.More(); anIter.Next())
   {
@@ -108,15 +109,15 @@ static void CollectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS
 //purpose  : Set current file if many files are read
 //=======================================================================
 static Standard_Integer SetCurWS(Draw_Interpretor& theDI,
-                                 Standard_Integer theArgc,
-                                 const char** theArgv)
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if (theArgc < 2)
+  if (theNbArgs < 2)
   {
-    theDI << "Use: " << theArgv[0] << " filename \n";
+    theDI << "Use: " << theArgVec[0] << " filename \n";
     return 1;
   }
-  const TCollection_AsciiString aSessionName(theArgv[1]);
+  const TCollection_AsciiString aSessionName(theArgVec[1]);
   Handle(XSControl_WorkSession) aSession;
   if (!THE_PREVIOUS_WORK_SESSIONS.Find(aSessionName, aSession))
   {
@@ -140,11 +141,11 @@ static Standard_Integer SetCurWS(Draw_Interpretor& theDI,
 //purpose  : List all files recorded after translation
 //=======================================================================
 static Standard_Integer GetDicWSList(Draw_Interpretor& theDI,
-                                     Standard_Integer theArgc,
-                                     const char** theArgv)
+                                     Standard_Integer theNbArgs,
+                                     const char** theArgVec)
 {
-  (void)theArgc;
-  (void)theArgv;
+  (void)theNbArgs;
+  (void)theArgVec;
   Message::SendInfo() << "Active sessions list:";
   TCollection_AsciiString aWSs;
   for (XSControl_WorkSessionMap::Iterator anIter(THE_PREVIOUS_WORK_SESSIONS);
@@ -160,11 +161,11 @@ static Standard_Integer GetDicWSList(Draw_Interpretor& theDI,
 //purpose  : Return name of file which is current
 //=======================================================================
 static Standard_Integer GetCurWS(Draw_Interpretor& theDI,
-                                 Standard_Integer theArgc,
-                                 const char** theArgv)
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  (void)theArgc;
-  (void)theArgv;
+  (void)theNbArgs;
+  (void)theArgVec;
   Handle(XSControl_WorkSession) WS = XSDRAW::Session();
   theDI << "\"" << WS->LoadedFile() << "\"";
   return 0;
@@ -194,26 +195,24 @@ static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = null
 //purpose  : Apply fromshape command to all the loaded WSs
 //=======================================================================
 static Standard_Integer FromShape(Draw_Interpretor& theDI,
-                                  Standard_Integer theArgc,
-                                  const char** theArgv)
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
 {
-  if (theArgc < 2)
+  if (theNbArgs < 2)
   {
-    theDI << theArgv[0] << " shape: search for shape origin among all last tranalated files\n";
+    theDI << theArgVec[0] << " shape: search for shape origin among all last tranalated files\n";
     return 0;
   }
 
   char command[256];
-  Sprintf(command, "fromshape %.200s -1", theArgv[1]);
-  NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> DictWS = thedictws;
-  if (DictWS.IsEmpty()) return theDI.Eval(command);
+  Sprintf(command, "fromshape %.200s -1", theArgVec[1]);
+  XSControl_WorkSessionMap DictWS = THE_PREVIOUS_WORK_SESSIONS;
+  if (DictWS.IsEmpty())
+    return theDI.Eval(command);
 
   Handle(XSControl_WorkSession) WS = XSDRAW::Session();
-
-  NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>::Iterator DicIt(DictWS);
-  //  theDI << "Searching for shape among all the loaded files:\n";
-  Standard_Integer num = 0;
-  for (; DicIt.More(); DicIt.Next(), num++)
+  for (XSControl_WorkSessionMap::Iterator DicIt(DictWS);
+       DicIt.More(); DicIt.Next())
   {
     Handle(XSControl_WorkSession) CurrentWS =
       Handle(XSControl_WorkSession)::DownCast(DicIt.Value());
@@ -230,23 +229,23 @@ static Standard_Integer FromShape(Draw_Interpretor& theDI,
 //purpose  : Read IGES to DECAF document
 //=======================================================================
 static Standard_Integer ReadIges(Draw_Interpretor& theDI,
-                                 Standard_Integer theArgc,
-                                 const char** theArgv)
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if (theArgc < 3)
+  if (theNbArgs < 3)
   {
-    theDI << "Use: " << theArgv[0] << " Doc filename [mode]: read IGES file to a document\n";
+    theDI << "Use: " << theArgVec[0] << " Doc filename [mode]: read IGES file to a document\n";
     return 0;
   }
   Handle(IGESCAFControl_ConfigurationNode) aNode =
     new IGESCAFControl_ConfigurationNode();
   Standard_Integer onlyvisible = Interface_Static::IVal("read.iges.onlyvisible");
   aNode->InternalParameters.ReadOnlyVisible = onlyvisible == 1;
-  if (theArgc == 4)
+  if (theNbArgs == 4)
   {
     Standard_Boolean aMode = Standard_True;
-    for (Standard_Integer i = 0; theArgv[3][i]; i++)
-      switch (theArgv[3][i])
+    for (Standard_Integer i = 0; theArgVec[3][i]; i++)
+      switch (theArgVec[3][i])
       {
         case '-': aMode = Standard_False; break;
         case '+': aMode = Standard_True; break;
@@ -256,13 +255,13 @@ static Standard_Integer ReadIges(Draw_Interpretor& theDI,
       }
   }
   Handle(TDocStd_Document) aDoc;
-  if (!DDocStd::GetDocument(theArgv[1], aDoc, Standard_False))
+  if (!DDocStd::GetDocument(theArgVec[1], aDoc, Standard_False))
   {
     Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
     anApp->NewDocument("BinXCAF", aDoc);
-    TDataStd_Name::Set(aDoc->GetData()->Root(), theArgv[1]);
+    TDataStd_Name::Set(aDoc->GetData()->Root(), theArgVec[1]);
     Handle(DDocStd_DrawDocument) aDrawD = new DDocStd_DrawDocument(aDoc);
-    Draw::Set(theArgv[1], aDrawD);
+    Draw::Set(theArgVec[1], aDrawD);
   }
   aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
   Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
@@ -270,13 +269,13 @@ static Standard_Integer ReadIges(Draw_Interpretor& theDI,
     new IGESCAFControl_Provider(aNode);
   aProvider->SetToUpdateStaticParameters(false);
   Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
-  if (!aProvider->Read(theArgv[2], aDoc, aWS, aProgress->Start()))
+  if (!aProvider->Read(theArgVec[2], aDoc, aWS, aProgress->Start()))
   {
     theDI << "Error: Can't read IGES file\n";
     return 1;
   }
-  CollectActiveWorkSessions(aWS, theArgv[2], THE_PREVIOUS_WORK_SESSIONS);
-  Message::SendInfo() << "Document saved with name " << theArgv[1];
+  CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS);
+  Message::SendInfo() << "Document saved with name " << theArgVec[1];
   return 0;
 }
 
@@ -286,28 +285,28 @@ static Standard_Integer ReadIges(Draw_Interpretor& theDI,
 //=======================================================================
 //=======================================================================
 static Standard_Integer WriteIges(Draw_Interpretor& theDI,
-                                  Standard_Integer theArgc,
-                                  const char** theArgv)
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
 {
-  if (theArgc < 3)
+  if (theNbArgs < 3)
   {
-    theDI << "Use: " << theArgv[0] << " Doc filename [mode]: write document to IGES file\n";
+    theDI << "Use: " << theArgVec[0] << " Doc filename [mode]: write document to IGES file\n";
     return 0;
   }
   Handle(IGESCAFControl_ConfigurationNode) aNode =
     new IGESCAFControl_ConfigurationNode();
   Handle(TDocStd_Document) aDoc;
-  DDocStd::GetDocument(theArgv[1], aDoc);
+  DDocStd::GetDocument(theArgVec[1], aDoc);
   if (aDoc.IsNull())
   {
-    theDI << theArgv[1] << " is not a document\n";
+    theDI << theArgVec[1] << " is not a document\n";
     return 1;
   }
-  if (theArgc == 4)
+  if (theNbArgs == 4)
   {
     Standard_Boolean aMode = Standard_True;
-    for (Standard_Integer i = 0; theArgv[3][i]; i++)
-      switch (theArgv[3][i])
+    for (Standard_Integer i = 0; theArgVec[3][i]; i++)
+      switch (theArgVec[3][i])
       {
         case '-': aMode = Standard_False; break;
         case '+': aMode = Standard_True; break;
@@ -322,7 +321,7 @@ static Standard_Integer WriteIges(Draw_Interpretor& theDI,
     new IGESCAFControl_Provider(aNode);
   aProvider->SetToUpdateStaticParameters(false);
   Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
-  const TCollection_AsciiString aPath = theArgv[2];
+  const TCollection_AsciiString aPath = theArgVec[2];
   if (!aProvider->Write(aPath, aDoc, aWS, aProgress->Start()))
   {
     theDI << "Error: Can't write IGES file\n";
@@ -337,16 +336,16 @@ static Standard_Integer WriteIges(Draw_Interpretor& theDI,
 //purpose  : Read STEP file to DECAF document 
 //=======================================================================
 static Standard_Integer ReadStep(Draw_Interpretor& theDI,
-                                 Standard_Integer theArgc,
-                                 const char** theArgv)
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
 
   Standard_CString aDocName = NULL;
   TCollection_AsciiString aFilePath, aModeStr;
   bool aToTestStream = false;
-  for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter)
+  for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
   {
-    TCollection_AsciiString anArgCase(theArgv[anArgIter]);
+    TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
     anArgCase.LowerCase();
     if (anArgCase == "-stream")
     {
@@ -354,19 +353,19 @@ static Standard_Integer ReadStep(Draw_Interpretor& theDI,
     }
     else if (aDocName == NULL)
     {
-      aDocName = theArgv[anArgIter];
+      aDocName = theArgVec[anArgIter];
     }
     else if (aFilePath.IsEmpty())
     {
-      aFilePath = theArgv[anArgIter];
+      aFilePath = theArgVec[anArgIter];
     }
     else if (aModeStr.IsEmpty())
     {
-      aModeStr = theArgv[anArgIter];
+      aModeStr = theArgVec[anArgIter];
     }
     else
     {
-      theDI << "Syntax error at '" << theArgv[anArgIter] << "'\n";
+      theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
       return 1;
     }
   }
@@ -440,8 +439,8 @@ static Standard_Integer ReadStep(Draw_Interpretor& theDI,
 //purpose  : Write DECAF document to STEP
 //=======================================================================
 static Standard_Integer WriteStep(Draw_Interpretor& theDI,
-                                  Standard_Integer theArgc,
-                                  const char** theArgv)
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
 {
   Handle(TDocStd_Document) aDoc;
   TCollection_AsciiString aDocName, aFilePath;
@@ -449,9 +448,9 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI,
     new STEPCAFControl_ConfigurationNode();
   bool aHasModeArg = false, aToTestStream = false;
   TDF_Label aLabel;
-  for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter)
+  for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
   {
-    TCollection_AsciiString anArgCase(theArgv[anArgIter]);
+    TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
     anArgCase.LowerCase();
     if (anArgCase == "-stream")
     {
@@ -459,18 +458,18 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI,
     }
     else if (aDocName.IsEmpty())
     {
-      Standard_CString aDocNameStr = theArgv[anArgIter];
+      Standard_CString aDocNameStr = theArgVec[anArgIter];
       DDocStd::GetDocument(aDocNameStr, aDoc);
       if (aDoc.IsNull())
       {
-        theDI << "Syntax error: '" << theArgv[anArgIter] << "' is not a document\n";
+        theDI << "Syntax error: '" << theArgVec[anArgIter] << "' is not a document\n";
         return 1;
       }
       aDocName = aDocNameStr;
     }
     else if (aFilePath.IsEmpty())
     {
-      aFilePath = theArgv[anArgIter];
+      aFilePath = theArgVec[anArgIter];
     }
     else if (!aHasModeArg)
     {
@@ -520,15 +519,15 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI,
     else if (aNode->InternalParameters.WriteMultiPrefix.IsEmpty()
              && anArgCase.Search(":") == -1)
     {
-      aNode->InternalParameters.WriteMultiPrefix = theArgv[anArgIter];
+      aNode->InternalParameters.WriteMultiPrefix = theArgVec[anArgIter];
     }
     else if (aLabel.IsNull())
     {
-      aNode->InternalParameters.WriteLabels.Append(theArgv[anArgIter]);
+      aNode->InternalParameters.WriteLabels.Append(theArgVec[anArgIter]);
     }
     else
     {
-      theDI << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'\n";
+      theDI << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'\n";
       return 1;
     }
   }
@@ -572,28 +571,28 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI,
 //purpose  :
 //=======================================================================
 static Standard_Integer Expand(Draw_Interpretor& theDI,
-                               Standard_Integer theArgc,
-                               const char** theArgv)
+                               Standard_Integer theNbArgs,
+                               const char** theArgVec)
 {
-  if (theArgc < 3)
+  if (theNbArgs < 3)
   {
-    theDI << "Use: " << theArgv[0]
+    theDI << "Use: " << theArgVec[0]
       << " Doc recurs(0/1) or Doc recurs(0/1) label1 label2 ... or Doc recurs(0/1 shape1 shape2 ...\n";
     return 1;
   }
   Handle(TDocStd_Document) Doc;
-  DDocStd::GetDocument(theArgv[1], Doc);
+  DDocStd::GetDocument(theArgVec[1], Doc);
   if (Doc.IsNull())
   {
-    theDI << theArgv[1] << " is not a document\n"; return 1;
+    theDI << theArgVec[1] << " is not a document\n"; return 1;
   }
 
   Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
   Standard_Boolean recurs = Standard_False;
-  if (atoi(theArgv[2]) != 0)
+  if (atoi(theArgVec[2]) != 0)
     recurs = Standard_True;
 
-  if (theArgc == 3)
+  if (theNbArgs == 3)
   {
     if (!XCAFDoc_Editor::Expand(Doc->Main(), recurs))
     {
@@ -603,14 +602,14 @@ static Standard_Integer Expand(Draw_Interpretor& theDI,
   }
   else
   {
-    for (Standard_Integer i = 3; i < theArgc; i++)
+    for (Standard_Integer i = 3; i < theNbArgs; i++)
     {
       TDF_Label aLabel;
-      TDF_Tool::Label(Doc->GetData(), theArgv[i], aLabel);
+      TDF_Tool::Label(Doc->GetData(), theArgVec[i], aLabel);
       if (aLabel.IsNull())
       {
         TopoDS_Shape aShape;
-        aShape = DBRep::Get(theArgv[i]);
+        aShape = DBRep::Get(theArgVec[i]);
         aLabel = aShapeTool->FindShape(aShape);
       }
 
@@ -624,7 +623,7 @@ static Standard_Integer Expand(Draw_Interpretor& theDI,
       }
       else
       {
-        theDI << theArgv[i] << " is not a shape\n"; return 1;
+        theDI << theArgVec[i] << " is not a shape\n"; return 1;
       }
     }
   }
@@ -636,46 +635,46 @@ static Standard_Integer Expand(Draw_Interpretor& theDI,
 //purpose  :
 //=======================================================================
 static Standard_Integer Extract(Draw_Interpretor& theDI,
-                                Standard_Integer theArgc,
-                                const char** theArgv)
+                                Standard_Integer theNbArgs,
+                                const char** theArgVec)
 {
-  if (theArgc < 4)
+  if (theNbArgs < 4)
   {
-    theDI << "Use: " << theArgv[0] << "dstDoc [dstAssmblSh] srcDoc srcLabel1 srcLabel2 ...\n";
+    theDI << "Use: " << theArgVec[0] << "dstDoc [dstAssmblSh] srcDoc srcLabel1 srcLabel2 ...\n";
     return 1;
   }
 
   Handle(TDocStd_Document) aSrcDoc, aDstDoc;
-  DDocStd::GetDocument(theArgv[1], aDstDoc);
+  DDocStd::GetDocument(theArgVec[1], aDstDoc);
   if (aDstDoc.IsNull())
   {
-    theDI << "Error " << theArgv[1] << " is not a document\n";
+    theDI << "Error " << theArgVec[1] << " is not a document\n";
     return 1;
   }
   TDF_Label aDstLabel;
   Standard_Integer anArgInd = 3;
-  TDF_Tool::Label(aDstDoc->GetData(), theArgv[2], aDstLabel);
+  TDF_Tool::Label(aDstDoc->GetData(), theArgVec[2], aDstLabel);
   Handle(XCAFDoc_ShapeTool) aDstShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDstDoc->Main());
   if (aDstLabel.IsNull())
   {
     aDstLabel = aDstShapeTool->Label();
     anArgInd = 2; // to get Src Doc
   }
-  DDocStd::GetDocument(theArgv[anArgInd++], aSrcDoc);
+  DDocStd::GetDocument(theArgVec[anArgInd++], aSrcDoc);
   if (aSrcDoc.IsNull())
   {
-    theDI << "Error " << theArgv[anArgInd] << " is not a document\n";
+    theDI << "Error " << theArgVec[anArgInd] << " is not a document\n";
     return 1;
   }
 
   TDF_LabelSequence aSrcShapes;
-  for (; anArgInd < theArgc; anArgInd++)
+  for (; anArgInd < theNbArgs; anArgInd++)
   {
     TDF_Label aSrcLabel;
-    TDF_Tool::Label(aSrcDoc->GetData(), theArgv[anArgInd], aSrcLabel);
+    TDF_Tool::Label(aSrcDoc->GetData(), theArgVec[anArgInd], aSrcLabel);
     if (aSrcLabel.IsNull())
     {
-      theDI << "[" << theArgv[anArgInd] << "] is not valid Src label\n";
+      theDI << "[" << theArgVec[anArgInd] << "] is not valid Src label\n";
       return 1;
     }
     aSrcShapes.Append(aSrcLabel);
@@ -699,12 +698,12 @@ static Standard_Integer Extract(Draw_Interpretor& theDI,
 //purpose  :
 //=======================================================================
 static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
-                                 Standard_Integer  theArgc,
-                                 const char** theArgv)
+                                 Standard_Integer  theNbArgs,
+                                 const char** theArgVec)
 {
-  if (theArgc < 3)
+  if (theNbArgs < 3)
   {
-    theDI.PrintHelp(theArgv[0]);
+    theDI.PrintHelp(theArgVec[0]);
     return 1;
   }
   Handle(Vrml_ConfigurationNode) aNode =
@@ -714,13 +713,13 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
   Standard_CString aDocName = NULL;
   TCollection_AsciiString aFilePath;
   aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
-  for (Standard_Integer anArgIt = 1; anArgIt < theArgc; anArgIt++)
+  for (Standard_Integer anArgIt = 1; anArgIt < theNbArgs; anArgIt++)
   {
-    TCollection_AsciiString anArg(theArgv[anArgIt]);
+    TCollection_AsciiString anArg(theArgVec[anArgIt]);
     anArg.LowerCase();
-    if (anArgIt + 1 < theArgc && anArg == "-fileunit")
+    if (anArgIt + 1 < theNbArgs && anArg == "-fileunit")
     {
-      const TCollection_AsciiString aUnitStr(theArgv[++anArgIt]);
+      const TCollection_AsciiString aUnitStr(theArgVec[++anArgIt]);
       aNode->InternalParameters.ReadFileUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString());
       if (aNode->InternalParameters.ReadFileUnit <= 0.0)
       {
@@ -728,27 +727,27 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
         return 1;
       }
     }
-    else if (anArgIt + 1 < theArgc && anArg == "-filecoordsys")
+    else if (anArgIt + 1 < theNbArgs && anArg == "-filecoordsys")
     {
-      if (!parseCoordinateSystem(theArgv[++anArgIt], aNode->InternalParameters.ReadFileCoordinateSys))
+      if (!parseCoordinateSystem(theArgVec[++anArgIt], aNode->InternalParameters.ReadFileCoordinateSys))
       {
-        theDI << "Error: unknown coordinate system '" << theArgv[anArgIt] << "'\n";
+        theDI << "Error: unknown coordinate system '" << theArgVec[anArgIt] << "'\n";
         return 1;
       }
     }
-    else if (anArgIt + 1 < theArgc && anArg == "-systemcoordsys")
+    else if (anArgIt + 1 < theNbArgs && anArg == "-systemcoordsys")
     {
-      if (!parseCoordinateSystem(theArgv[++anArgIt], aNode->InternalParameters.ReadSystemCoordinateSys))
+      if (!parseCoordinateSystem(theArgVec[++anArgIt], aNode->InternalParameters.ReadSystemCoordinateSys))
       {
-        theDI << "Error: unknown coordinate system '" << theArgv[anArgIt] << "'\n";
+        theDI << "Error: unknown coordinate system '" << theArgVec[anArgIt] << "'\n";
         return 1;
       }
     }
     else if (anArg == "-fillincomplete")
     {
       aNode->InternalParameters.ReadFillIncomplete = true;
-      if (anArgIt + 1 < theArgc &&
-          Draw::ParseOnOff(theArgv[anArgIt + 1], aNode->InternalParameters.ReadFillIncomplete))
+      if (anArgIt + 1 < theNbArgs &&
+          Draw::ParseOnOff(theArgVec[anArgIt + 1], aNode->InternalParameters.ReadFillIncomplete))
       {
         ++anArgIt;
       }
@@ -759,16 +758,16 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
     }
     else if (aDocName == nullptr)
     {
-      aDocName = theArgv[anArgIt];
+      aDocName = theArgVec[anArgIt];
       DDocStd::GetDocument(aDocName, aDoc, Standard_False);
     }
     else if (aFilePath.IsEmpty())
     {
-      aFilePath = theArgv[anArgIt];
+      aFilePath = theArgVec[anArgIt];
     }
     else
     {
-      theDI << "Syntax error at '" << theArgv[anArgIt] << "'\n";
+      theDI << "Syntax error at '" << theArgVec[anArgIt] << "'\n";
       return 1;
     }
   }
@@ -796,7 +795,6 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
   }
   Handle(Vrml_Provider) aProvider =
     new Vrml_Provider(aNode);
-
   Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
   Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
   if (!aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start()))
@@ -816,24 +814,24 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
 //purpose  : Write DECAF document to Vrml
 //=======================================================================
 static Standard_Integer WriteVrml(Draw_Interpretor& theDI,
-                                  Standard_Integer theArgc,
-                                  const char** theArgv)
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
 {
-  if (theArgc < 3)
+  if (theNbArgs < 3)
   {
-    theDI << "Use: " << theArgv[0] << " Doc filename: write document to Vrml file\n";
+    theDI << "Use: " << theArgVec[0] << " Doc filename: write document to Vrml file\n";
     return 0;
   }
 
   Handle(TDocStd_Document) aDoc;
-  DDocStd::GetDocument(theArgv[1], aDoc);
+  DDocStd::GetDocument(theArgVec[1], aDoc);
   if (aDoc.IsNull())
   {
-    theDI << theArgv[1] << " is not a document\n";
+    theDI << theArgVec[1] << " is not a document\n";
     return 1;
   }
 
-  if (theArgc < 3 || theArgc > 5)
+  if (theNbArgs < 3 || theNbArgs > 5)
   {
     theDI << "wrong number of parameters\n";
     return 0;
@@ -846,12 +844,12 @@ static Standard_Integer WriteVrml(Draw_Interpretor& theDI,
 
   Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
   Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
-  if (!aProvider->Write(theArgv[2], aDoc, aWS, aProgress->Start()))
+  if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start()))
   {
-    theDI << "Error: file writing failed '" << theArgv[2] << "'\n";
+    theDI << "Error: file writing failed '" << theArgVec[2] << "'\n";
     return 1;
   }
-  CollectActiveWorkSessions(aWS, theArgv[2], THE_PREVIOUS_WORK_SESSIONS);
+  CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS);
   return 0;
 }
 
index 7b74aedce832a1f47481ac4e6aeaf833e5079077..779d7e40b3b474dddddf302a20673ff723ec4731 100644 (file)
@@ -27,6 +27,6 @@ Handle(XSControl_WorkSession)  XSControl::Session
 {
   Handle(XSControl_Vars) avars;
   Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
-  if (!WS.IsNull()) avars = WS->Vars();
+  //if (!WS.IsNull()) avars = WS->Vars();
   return avars;
 }
index 08ddcf2b2213d364199790f4d4b117317c4e39bf..3fd69c2d1f7e0e2fe21aa1d52a6bfe7b23649b14 100644 (file)
@@ -44,6 +44,7 @@
 #include <Transfer_Binder.hxx>
 #include <Transfer_SimpleBinderOfTransient.hxx>
 #include <Transfer_TransientMapper.hxx>
+#include <Transfer_FinderProcess.hxx>
 #include <TransferBRep_ShapeMapper.hxx>
 #include <XSControl_ConnectedShapes.hxx>
 #include <XSControl_Controller.hxx>
index d161a2c06476c8a1b85b924c4aafc179b999f750..2c1b347eb5eabb523c10b2021a04a66b2ff57005 100644 (file)
@@ -19,6 +19,7 @@
 #include <IFSelect_Functions.hxx>
 #include <IFSelect_SessionPilot.hxx>
 #include <Interface_Macros.hxx>
+#include <Interface_InterfaceModel.hxx>
 #include <Message.hxx>
 #include <Message_Messenger.hxx>
 #include <ShapeExtend_Explorer.hxx>
@@ -29,6 +30,7 @@
 #include <TopoDS_Iterator.hxx>
 #include <TopTools_HSequenceOfShape.hxx>
 #include <Transfer_SimpleBinderOfTransient.hxx>
+#include <Transfer_FinderProcess.hxx>
 #include <Transfer_TransientListBinder.hxx>
 #include <Transfer_TransientProcess.hxx>
 #include <TransferBRep.hxx>
@@ -39,6 +41,7 @@
 #include <XSControl_Controller.hxx>
 #include <XSControl_FuncShape.hxx>
 #include <XSControl_TransferReader.hxx>
+#include <XSControl_TransferWriter.hxx>
 #include <XSControl_Vars.hxx>
 #include <XSControl_WorkSession.hxx>
 
@@ -780,7 +783,7 @@ Standard_Integer  XSControl_FuncShape::MoreShapes
     for (i = n1; i <= n2 ; i ++) {
       const char* nomshh = &nomsh[0];
       sprintf (nomsh,"%s%d",nom,i);
-      TopoDS_Shape Shape = session->Vars()->GetShape(nomshh);
+      TopoDS_Shape Shape;// = session->Vars()->GetShape(nomshh);
       if (Shape.IsNull()) continue;
       list->Append(Shape);
       nbsh ++;
@@ -789,7 +792,7 @@ Standard_Integer  XSControl_FuncShape::MoreShapes
     return nbsh;
   }
   const char* a1 = (const char *)name;
-  TopoDS_Shape Shape = session->Vars()->GetShape(a1);
+  TopoDS_Shape Shape;// = session->Vars()->GetShape(a1);
   if (Shape.IsNull()) { sout<<"not a shape draw:"<<a1<<std::endl; return 0; }
   list->Append(Shape);
   return 1;
index efe8bb8e3fc82265f6fda79c39d0daaeef291d8d..a5771e33589771c6e89a8df6e28b48f267116a61 100644 (file)
@@ -27,6 +27,7 @@
 #include <XSControl_Functions.hxx>
 #include <XSControl_SelectForTransfer.hxx>
 #include <XSControl_TransferReader.hxx>
+#include <XSControl_TransferWriter.hxx>
 #include <XSControl_WorkSession.hxx>
 
 // #######################################################################
index 951c6a6a34c5bf2e6d732c7ea64533f815e17047..35fde18c56cbba0eb4e56b312aaf33b78c803264 100644 (file)
 
 #include <IFSelect_WorkSession.hxx>
 #include <IFSelect_ReturnStatus.hxx>
+#include <Message_ProgressRange.hxx>
 
 class XSControl_Controller;
 class XSControl_TransferReader;
+class XSControl_TransferWriter;
 class XSControl_Vars;
 class Transfer_TransientProcess;
 class Interface_InterfaceModel;
index ec8e89527ce8504e75a0586d326068d7e8e95144..69d1099e93e2ca33495ad3a7bb37c2f0c9d87b2c 100644 (file)
@@ -16,6 +16,7 @@
 #include <Interface_InterfaceModel.hxx>
 #include <TopoDS_Shape.hxx>
 #include <XSControl_Controller.hxx>
+#include <XSControl_TransferWriter.hxx>
 #include <XSControl_WorkSession.hxx>
 #include <XSControl_Writer.hxx>
 
index c4638e2427e94ee3d579e7229c512f7bfb7de483..a573725be1688d00186f91e38d93d2cec77cba5b 100644 (file)
@@ -98,7 +98,7 @@ static Standard_Integer XSTEPDRAWRUN (Draw_Interpretor& di, Standard_Integer arg
   deja = 1;
   thepilot   = new IFSelect_SessionPilot("XSTEP-DRAW>");
   Handle(XSControl_WorkSession) WS = new XSControl_WorkSession;
-  WS->SetVars (new XSDRAW_Vars);
+  //WS->SetVars (new XSDRAW_Vars);
   thepilot->SetSession (WS);
 
   IFSelect_Functions::Init();
index 1a7cb4f5cb8ef5abf928ef57066a39fea48e06c4..6e29a6ecb31d59d9f69935c6d20740c51a5c465f 100644 (file)
@@ -36,6 +36,7 @@
 #include <TColStd_HSequenceOfTransient.hxx>
 #include <TColStd_MapOfTransient.hxx>
 #include <TopoDS_Shape.hxx>
+#include <Transfer_FinderProcess.hxx>
 #include <Transfer_IteratorOfProcessForTransient.hxx>
 #include <Transfer_TransientProcess.hxx>
 #include <XSControl.hxx>
index 62aaad6e2efaf1cc2033a73f72fdc2fcfa0829df..828b5eadc11f31aec7151c345f170712f9f40c16 100644 (file)
@@ -16,8 +16,8 @@
 #include <XSDRAWSTLVRML.hxx>
 
 #include <AIS_InteractiveContext.hxx>
-#include <Aspect_TypeOfMarker.hxx>
-#include <Bnd_Box.hxx>
+//#include <Aspect_TypeOfMarker.hxx>
+//#include <Bnd_Box.hxx>
 #include <BRep_Builder.hxx>
 #include <BRepLib_PointCloudShape.hxx>
 #include <DBRep.hxx>
 #include <MeshVS_VectorPrsBuilder.hxx>
 #include <OSD_Path.hxx>
 #include <Quantity_Color.hxx>
-#include <Quantity_HArray1OfColor.hxx>
+//#include <Quantity_HArray1OfColor.hxx>
 #include <Quantity_NameOfColor.hxx>
-#include <RWGltf_DracoParameters.hxx>
-#include <RWGltf_CafReader.hxx>
-#include <RWGltf_CafWriter.hxx>
+#include <RWGltf_ConfigurationNode.hxx>
+#include <RWGltf_Provider.hxx>
+//#include <RWGltf_DracoParameters.hxx>
+//#include <RWGltf_CafReader.hxx>
+//#include <RWGltf_CafWriter.hxx>
 #include <RWMesh_FaceIterator.hxx>
 #include <RWStl.hxx>
-#include <RWObj.hxx>
-#include <RWObj_CafReader.hxx>
-#include <RWObj_CafWriter.hxx>
-#include <RWPly_CafWriter.hxx>
+#include <RWStl_ConfigurationNode.hxx>
+#include <RWStl_Provider.hxx>
+//#include <RWObj.hxx>
+#include <RWObj_ConfigurationNode.hxx>
+#include <RWObj_Provider.hxx>
+//#include <RWObj_CafReader.hxx>
+//#include <RWObj_CafWriter.hxx>
+#include <RWPly_ConfigurationNode.hxx>
+#include <RWPly_Provider.hxx>
+//#include <RWPly_CafWriter.hxx>
 #include <RWPly_PlyWriterContext.hxx>
-#include <SelectMgr_SelectionManager.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <StdSelect_ViewerSelector3d.hxx>
-#include <StlAPI.hxx>
-#include <StlAPI_Writer.hxx>
-#include <TColgp_SequenceOfXYZ.hxx>
+//#include <SelectMgr_SelectionManager.hxx>
+//#include <Standard_ErrorHandler.hxx>
+//#include <StdSelect_ViewerSelector3d.hxx>
+//#include <StlAPI.hxx>
+//#include <StlAPI_Writer.hxx>
+//#include <TColgp_SequenceOfXYZ.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TColStd_Array1OfReal.hxx>
 #include <TColStd_HPackedMapOfInteger.hxx>
 #include <UnitsMethods.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 <Vrml_ConfigurationNode.hxx>
+#include <Vrml_Provider.hxx>
+//#include <VrmlAPI.hxx>
+//#include <VrmlAPI_Writer.hxx>
+//#include <VrmlData_DataMapOfShapeAppearance.hxx>
+//#include <VrmlData_Scene.hxx>
+//#include <VrmlData_ShapeConvert.hxx>
 #include <XCAFDoc_DocumentTool.hxx>
 #include <XCAFDoc_ShapeTool.hxx>
 #include <XCAFPrs_DocumentExplorer.hxx>
 #include <stdio.h>
 #endif
 
-extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
-                                           const Handle(AIS_InteractiveObject)& theAISObj,
-                                           Standard_Boolean theReplaceIfExists = Standard_True);
+extern Standard_Boolean VDisplayAISObject(const TCollection_AsciiString& theName,
+                                          const Handle(AIS_InteractiveObject)& theAISObj,
+                                          Standard_Boolean theReplaceIfExists = Standard_True);
 
-//! Parse RWMesh_NameFormat enumeration.
-static bool parseNameFormat (const char* theArg,
-                             RWMesh_NameFormat& theFormat)
+//=============================================================================
+//function : parseNameFormat
+//purpose  : Parse RWMesh_NameFormat enumeration
+//=============================================================================
+static bool parseNameFormat(const char* theArg,
+                            RWMesh_NameFormat& theFormat)
 {
-  TCollection_AsciiString aName (theArg);
+  TCollection_AsciiString aName(theArg);
   aName.LowerCase();
   if (aName == "empty")
   {
     theFormat = RWMesh_NameFormat_Empty;
   }
   else if (aName == "product"
-        || aName == "prod")
+           || aName == "prod")
   {
     theFormat = RWMesh_NameFormat_Product;
   }
   else if (aName == "instance"
-        || aName == "inst")
+           || aName == "inst")
   {
     theFormat = RWMesh_NameFormat_Instance;
   }
   else if (aName == "instanceorproduct"
-        || aName == "instance||product"
-        || aName == "instance|product"
-        || aName == "instorprod"
-        || aName == "inst||prod"
-        || aName == "inst|prod")
+           || aName == "instance||product"
+           || aName == "instance|product"
+           || aName == "instorprod"
+           || aName == "inst||prod"
+           || aName == "inst|prod")
   {
     theFormat = RWMesh_NameFormat_InstanceOrProduct;
   }
   else if (aName == "productorinstance"
-        || aName == "product||instance"
-        || aName == "product|instance"
-        || aName == "prodorinst"
-        || aName == "prod||inst"
-        || aName == "prod|inst")
+           || aName == "product||instance"
+           || aName == "product|instance"
+           || aName == "prodorinst"
+           || aName == "prod||inst"
+           || aName == "prod|inst")
   {
     theFormat = RWMesh_NameFormat_ProductOrInstance;
   }
   else if (aName == "productandinstance"
-        || aName == "prodandinst"
-        || aName == "product&instance"
-        || aName == "prod&inst")
+           || aName == "prodandinst"
+           || aName == "product&instance"
+           || aName == "prod&inst")
   {
     theFormat = RWMesh_NameFormat_ProductAndInstance;
   }
   else if (aName == "productandinstanceandocaf"
-        || aName == "verbose"
-        || aName == "debug")
+           || aName == "verbose"
+           || aName == "debug")
   {
     theFormat = RWMesh_NameFormat_ProductAndInstanceAndOcaf;
   }
@@ -157,11 +170,14 @@ static bool parseNameFormat (const char* theArg,
   return true;
 }
 
-//! Parse RWMesh_CoordinateSystem enumeration.
-static bool parseCoordinateSystem (const char* theArg,
-                                   RWMesh_CoordinateSystem& theSystem)
+//=============================================================================
+//function : parseCoordinateSystem
+//purpose  : Parse RWMesh_CoordinateSystem enumeration
+//=============================================================================
+static bool parseCoordinateSystem(const char* theArg,
+                                  RWMesh_CoordinateSystem& theSystem)
 {
-  TCollection_AsciiString aCSStr (theArg);
+  TCollection_AsciiString aCSStr(theArg);
   aCSStr.LowerCase();
   if (aCSStr == "zup")
   {
@@ -178,80 +194,108 @@ static bool parseCoordinateSystem (const char* theArg,
   return Standard_True;
 }
 
+//=======================================================================
+//function : GetLengthUnit
+//purpose  : Gets length unit value from static interface and document in M
+//=======================================================================
+static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr)
+{
+  if (!theDoc.IsNull())
+  {
+    Standard_Real aUnit = 1.;
+    if (XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aUnit,
+        UnitsMethods_LengthUnit_Millimeter))
+    {
+      return aUnit;
+    }
+  }
+  XSAlgo::AlgoContainer()->PrepareForTransfer();
+  return UnitsMethods::GetCasCadeLengthUnit();
+}
+
 //=============================================================================
 //function : ReadGltf
 //purpose  : Reads glTF file
 //=============================================================================
-static Standard_Integer ReadGltf (Draw_Interpretor& theDI,
-                                  Standard_Integer theNbArgs,
-                                  const char** theArgVec)
+static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
   TCollection_AsciiString aDestName, aFilePath;
+  Handle(RWGltf_ConfigurationNode) aNode =
+    new RWGltf_ConfigurationNode();
   Standard_Boolean toUseExistingDoc = Standard_False;
-  Standard_Boolean toListExternalFiles = Standard_False;
-  Standard_Boolean isParallel = Standard_False;
-  Standard_Boolean isDoublePrec = Standard_False;
-  Standard_Boolean toSkipLateDataLoading = Standard_False;
-  Standard_Boolean toKeepLateData = Standard_True;
-  Standard_Boolean toPrintDebugInfo = Standard_False;
-  Standard_Boolean toLoadAllScenes = Standard_False;
-  Standard_Boolean toPrintAssetInfo = Standard_False;
+  //Standard_Boolean toListExternalFiles = Standard_False;
+  //Standard_Boolean isParallel = Standard_False;
+  //Standard_Boolean isDoublePrec = Standard_False;
+  //Standard_Boolean toSkipLateDataLoading = Standard_False;
+  //Standard_Boolean toKeepLateData = Standard_True;
+  //Standard_Boolean toPrintDebugInfo = Standard_False;
+  //Standard_Boolean toLoadAllScenes = Standard_False;
+  //Standard_Boolean toPrintAssetInfo = Standard_False;
   Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readgltf");
   for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
   {
-    TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+    TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
     anArgCase.LowerCase();
     if (!isNoDoc
-     && (anArgCase == "-nocreate"
-      || anArgCase == "-nocreatedoc"))
+        && (anArgCase == "-nocreate"
+        || anArgCase == "-nocreatedoc"))
     {
-      toUseExistingDoc = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+      toUseExistingDoc = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArgCase == "-parallel")
     {
-      isParallel = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.ReadParallel =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArgCase == "-doubleprec"
-          || anArgCase == "-doubleprecision"
-          || anArgCase == "-singleprec"
-          || anArgCase == "-singleprecision")
+             || anArgCase == "-doubleprecision"
+             || anArgCase == "-singleprec"
+             || anArgCase == "-singleprecision")
     {
-      isDoublePrec = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
-      if (anArgCase.StartsWith ("-single"))
+      aNode->InternalParameters.ReadSinglePrecision =
+        !Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+      if (anArgCase.StartsWith("-single"))
       {
-        isDoublePrec = !isDoublePrec;
+        aNode->InternalParameters.ReadSinglePrecision =
+          Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
       }
     }
     else if (anArgCase == "-skiplateloading")
     {
-      toSkipLateDataLoading = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.ReadSkipLateDataLoading =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArgCase == "-keeplate")
     {
-      toKeepLateData = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.ReadKeepLateData =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArgCase == "-allscenes")
     {
-      toLoadAllScenes = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.ReadLoadAllScenes =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArgCase == "-toprintinfo"
-          || anArgCase == "-toprintdebuginfo")
-    {
-      toPrintDebugInfo = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
-    }
-    else if (anArgCase == "-listexternalfiles"
-          || anArgCase == "-listexternals"
-          || anArgCase == "-listexternal"
-          || anArgCase == "-external"
-          || anArgCase == "-externalfiles")
-    {
-      toListExternalFiles = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
-    }
-    else if (anArgCase == "-assetinfo"
-          || anArgCase == "-metadata")
-    {
-      toPrintAssetInfo = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
-    }
+             || anArgCase == "-toprintdebuginfo")
+    {
+      aNode->InternalParameters.ReadPrintDebugMessages =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+    }
+    //else if (anArgCase == "-listexternalfiles"
+    //      || anArgCase == "-listexternals"
+    //      || anArgCase == "-listexternal"
+    //      || anArgCase == "-external"
+    //      || anArgCase == "-externalfiles")
+    //{
+    //  toListExternalFiles = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+    //}
+    //else if (anArgCase == "-assetinfo"
+    //      || anArgCase == "-metadata")
+    //{
+    //  toPrintAssetInfo = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+    //}
     else if (aDestName.IsEmpty())
     {
       aDestName = theArgVec[anArgIter];
@@ -262,107 +306,100 @@ static Standard_Integer ReadGltf (Draw_Interpretor& theDI,
     }
     else
     {
-      Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+      theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
       return 1;
     }
   }
-  if (aFilePath.IsEmpty() && !aDestName.IsEmpty())
-  {
-    if (toListExternalFiles || toPrintAssetInfo)
-    {
-      std::swap (aFilePath, aDestName);
-    }
-  }
-  if (aFilePath.IsEmpty())
+  //if (aFilePath.IsEmpty() && !aDestName.IsEmpty())
+  //{
+  //  if (toListExternalFiles || toPrintAssetInfo)
+  //  {
+  //    std::swap (aFilePath, aDestName);
+  //  }
+  //}
+  if (aFilePath.IsEmpty() || aDestName.IsEmpty())
   {
-    Message::SendFail() << "Syntax error: wrong number of arguments";
+    theDI << "Syntax error: wrong number of arguments\n";
     return 1;
   }
 
-  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
   Handle(TDocStd_Document) aDoc;
   if (!aDestName.IsEmpty()
-   && !isNoDoc)
+      && !isNoDoc)
   {
     Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
     Standard_CString aNameVar = aDestName.ToCString();
-    DDocStd::GetDocument (aNameVar, aDoc, Standard_False);
+    DDocStd::GetDocument(aNameVar, aDoc, Standard_False);
     if (aDoc.IsNull())
     {
       if (toUseExistingDoc)
       {
-        Message::SendFail() << "Error: document with name " << aDestName << " does not exist";
+        theDI << "Error: document with name " << aDestName << " does not exist\n";
         return 1;
       }
-      anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
+      anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
     }
     else if (!toUseExistingDoc)
     {
-      Message::SendFail() << "Error: document with name " << aDestName << " already exists";
+      theDI << "Error: document with name " << aDestName << " already exists\n";
       return 1;
     }
   }
 
-  Standard_Real aScaleFactorM = 1.;
-  if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM, UnitsMethods_LengthUnit_Meter))
-  {
-    XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
-    aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
-  }
-
-  RWGltf_CafReader aReader;
-  aReader.SetSystemLengthUnit (aScaleFactorM);
-  aReader.SetSystemCoordinateSystem (RWMesh_CoordinateSystem_Zup);
-  aReader.SetDocument (aDoc);
-  aReader.SetParallel (isParallel);
-  aReader.SetDoublePrecision (isDoublePrec);
-  aReader.SetToSkipLateDataLoading (toSkipLateDataLoading);
-  aReader.SetToKeepLateData (toKeepLateData);
-  aReader.SetToPrintDebugMessages (toPrintDebugInfo);
-  aReader.SetLoadAllScenes (toLoadAllScenes);
-  if (aDestName.IsEmpty())
-  {
-    aReader.ProbeHeader (aFilePath);
-  }
-  else
+  aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
+  Handle(RWGltf_Provider) aProvider =
+    new RWGltf_Provider(aNode);
+  Standard_Boolean aReadStat = Standard_False;
+  Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+  if (isNoDoc)
   {
-    aReader.Perform (aFilePath, aProgress->Start());
-    if (isNoDoc)
-    {
-      DBRep::Set (aDestName.ToCString(), aReader.SingleShape());
-    }
-    else
+    TopoDS_Shape aResShape;
+    aReadStat = aProvider->Read(aFilePath, aResShape, aWS, aProgress->Start());
+    if (aReadStat)
     {
-      Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
-      TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName);
-      Draw::Set (aDestName.ToCString(), aDrawDoc);
+      DBRep::Set(aDestName.ToCString(), aResShape);
     }
   }
-
-  bool isFirstLine = true;
-  if (toPrintAssetInfo)
+  else
   {
-    for (TColStd_IndexedDataMapOfStringString::Iterator aKeyIter (aReader.Metadata()); aKeyIter.More(); aKeyIter.Next())
+    aReadStat = aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start());
+    if (aReadStat)
     {
-      if (!isFirstLine)
-      {
-        theDI << "\n";
-      }
-      isFirstLine = false;
-      theDI << aKeyIter.Key() << ": " << aKeyIter.Value();
+      Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
+      TDataStd_Name::Set(aDoc->GetData()->Root(), aDestName);
+      Draw::Set(aDestName.ToCString(), aDrawDoc);
     }
   }
-  if (toListExternalFiles)
+  if (!aReadStat)
   {
-    if (!isFirstLine)
-    {
-      theDI << "\n";
-    }
-    for (NCollection_IndexedMap<TCollection_AsciiString>::Iterator aFileIter (aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next())
-    {
-      theDI << "\"" << aFileIter.Value() << "\" ";
-    }
+    theDI << "Cannot read any relevant data from the GLTF file\n";
+    return 1;
   }
+  //bool isFirstLine = true;
+  //if (toPrintAssetInfo)
+  //{
+  //  for (TColStd_IndexedDataMapOfStringString::Iterator aKeyIter (aReader.Metadata()); aKeyIter.More(); aKeyIter.Next())
+  //  {
+  //    if (!isFirstLine)
+  //    {
+  //      theDI << "\n";
+  //    }
+  //    isFirstLine = false;
+  //    theDI << aKeyIter.Key() << ": " << aKeyIter.Value();
+  //  }
+  //}
+  //if (toListExternalFiles)
+  //{
+  //  if (!isFirstLine)
+  //  {
+  //    theDI << "\n";
+  //  }
+  //  for (NCollection_IndexedMap<TCollection_AsciiString>::Iterator aFileIter (aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next())
+  //  {
+  //    theDI << "\"" << aFileIter.Value() << "\" ";
+  //  }
+  //}
 
   return 0;
 }
@@ -371,144 +408,141 @@ static Standard_Integer ReadGltf (Draw_Interpretor& theDI,
 //function : WriteGltf
 //purpose  : Writes glTF file
 //=============================================================================
-static Standard_Integer WriteGltf (Draw_Interpretor& theDI,
-                                   Standard_Integer theNbArgs,
-                                   const char** theArgVec)
+static Standard_Integer WriteGltf(Draw_Interpretor& theDI,
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
 {
   TCollection_AsciiString aGltfFilePath;
   Handle(TDocStd_Document) aDoc;
+  TopoDS_Shape aShape;
   Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
-  TColStd_IndexedDataMapOfStringString aFileInfo;
-  RWGltf_WriterTrsfFormat aTrsfFormat = RWGltf_WriterTrsfFormat_Compact;
-  RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup;
-  bool toForceUVExport = false, toEmbedTexturesInGlb = true;
-  bool toMergeFaces = false, toSplitIndices16 = false;
-  bool isParallel = false;
-  RWMesh_NameFormat aNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct;
-  RWMesh_NameFormat aMeshNameFormat = RWMesh_NameFormat_Product;
-  RWGltf_DracoParameters aDracoParameters;
+  Handle(RWGltf_ConfigurationNode) aNode =
+    new RWGltf_ConfigurationNode();
+  //TColStd_IndexedDataMapOfStringString aFileInfo;
+  //RWGltf_WriterTrsfFormat aTrsfFormat = RWGltf_WriterTrsfFormat_Compact;
+  //RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup;
+  //bool toForceUVExport = false, toEmbedTexturesInGlb = true;
+  //bool toMergeFaces = false, toSplitIndices16 = false;
+  //bool isParallel = false;
+  //RWMesh_NameFormat aNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct;
+  //RWMesh_NameFormat aMeshNameFormat = RWMesh_NameFormat_Product;
+  //RWGltf_DracoParameters aDracoParameters;
   for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
   {
-    TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+    TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
     anArgCase.LowerCase();
     if (anArgCase == "-comments"
-     && anArgIter + 1 < theNbArgs)
+        && anArgIter + 1 < theNbArgs)
     {
-      aFileInfo.Add ("Comments", theArgVec[++anArgIter]);
+      aNode->InternalParameters.WriteComment = theArgVec[++anArgIter];
     }
     else if (anArgCase == "-author"
-          && anArgIter + 1 < theNbArgs)
+             && anArgIter + 1 < theNbArgs)
     {
-      aFileInfo.Add ("Author", theArgVec[++anArgIter]);
+      aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter];
     }
     else if (anArgCase == "-forceuvexport"
-          || anArgCase == "-forceuv")
+             || anArgCase == "-forceuv")
     {
-      toForceUVExport = true;
+      aNode->InternalParameters.WriteForcedUVExport = true;
       if (anArgIter + 1 < theNbArgs
-       && Draw::ParseOnOff (theArgVec[anArgIter + 1], toForceUVExport))
+          && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteForcedUVExport))
       {
         ++anArgIter;
       }
     }
     else if (anArgCase == "-mergefaces")
     {
-      toMergeFaces = true;
+      aNode->InternalParameters.WriteMergeFaces = true;
       if (anArgIter + 1 < theNbArgs
-       && Draw::ParseOnOff (theArgVec[anArgIter + 1], toMergeFaces))
+          && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteMergeFaces))
       {
         ++anArgIter;
       }
     }
     else if (anArgCase == "-splitindices16"
-          || anArgCase == "-splitindexes16"
-          || anArgCase == "-splitindices"
-          || anArgCase == "-splitindexes"
-          || anArgCase == "-splitind")
+             || anArgCase == "-splitindexes16"
+             || anArgCase == "-splitindices"
+             || anArgCase == "-splitindexes"
+             || anArgCase == "-splitind")
     {
-      toSplitIndices16 = true;
+      aNode->InternalParameters.WriteSplitIndices16 = true;
       if (anArgIter + 1 < theNbArgs
-       && Draw::ParseOnOff (theArgVec[anArgIter + 1], toSplitIndices16))
+          && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteSplitIndices16))
       {
         ++anArgIter;
       }
     }
     else if (anArgIter + 1 < theNbArgs
-          && (anArgCase == "-systemcoordinatesystem"
-           || anArgCase == "-systemcoordsystem"
-           || anArgCase == "-systemcoordsys"
-           || anArgCase == "-syscoordsys"))
+             && (anArgCase == "-systemcoordinatesystem"
+             || anArgCase == "-systemcoordsystem"
+             || anArgCase == "-systemcoordsys"
+             || anArgCase == "-syscoordsys"))
     {
-      if (!parseCoordinateSystem (theArgVec[++anArgIter], aSystemCoordSys))
+      if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS))
       {
-        Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+        theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n";
         return 1;
       }
     }
     else if (anArgCase == "-trsfformat"
-          && anArgIter + 1 < theNbArgs)
+             && anArgIter + 1 < theNbArgs)
     {
-      TCollection_AsciiString aTrsfStr (theArgVec[++anArgIter]);
+      TCollection_AsciiString aTrsfStr(theArgVec[++anArgIter]);
       aTrsfStr.LowerCase();
       if (aTrsfStr == "compact")
       {
-        aTrsfFormat = RWGltf_WriterTrsfFormat_Compact;
+        aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_Compact;
       }
       else if (aTrsfStr == "mat4")
       {
-        aTrsfFormat = RWGltf_WriterTrsfFormat_Mat4;
+        aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_Mat4;
       }
       else if (aTrsfStr == "trs")
       {
-        aTrsfFormat = RWGltf_WriterTrsfFormat_TRS;
+        aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_TRS;
       }
       else
       {
-        Message::SendFail() << "Syntax error at '" << anArgCase << "'";
+        theDI << "Syntax error at '" << anArgCase << "'\n";
         return 1;
       }
     }
     else if (anArgCase == "-nodenameformat"
-          || anArgCase == "-nodename")
+             || anArgCase == "-nodename")
     {
       ++anArgIter;
       if (anArgIter >= theNbArgs
-      || !parseNameFormat (theArgVec[anArgIter], aNodeNameFormat))
+          || !parseNameFormat(theArgVec[anArgIter], aNode->InternalParameters.WriteNodeNameFormat))
       {
-        Message::SendFail() << "Syntax error at '" << anArgCase << "'";
+        theDI << "Syntax error at '" << anArgCase << "'\n";
         return 1;
       }
     }
     else if (anArgCase == "-meshnameformat"
-          || anArgCase == "-meshname")
+             || anArgCase == "-meshname")
     {
       ++anArgIter;
       if (anArgIter >= theNbArgs
-      || !parseNameFormat (theArgVec[anArgIter], aMeshNameFormat))
+          || !parseNameFormat(theArgVec[anArgIter], aNode->InternalParameters.WriteMeshNameFormat))
       {
-        Message::SendFail() << "Syntax error at '" << anArgCase << "'";
+        theDI << "Syntax error at '" << anArgCase << "'\n";
         return 1;
       }
     }
     else if (aDoc.IsNull())
     {
       Standard_CString aNameVar = theArgVec[anArgIter];
-      DDocStd::GetDocument (aNameVar, aDoc, false);
+      DDocStd::GetDocument(aNameVar, aDoc, false);
       if (aDoc.IsNull())
       {
-        TopoDS_Shape aShape = DBRep::Get (aNameVar);
+        aShape = DBRep::Get(aNameVar);
         if (aShape.IsNull())
         {
-          Message::SendFail() << "Syntax error: '" << aNameVar << "' is not a shape nor document";
+          theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n";
           return 1;
         }
-
-        anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
-        Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
-        // auto-naming doesn't generate meaningful instance names
-        //aShapeTool->SetAutoNaming (false);
-        aNodeNameFormat = RWMesh_NameFormat_Product;
-        aShapeTool->AddShape (aShape);
+        aNode->InternalParameters.WriteNodeNameFormat = RWMesh_NameFormat_Product;
       }
     }
     else if (aGltfFilePath.IsEmpty())
@@ -517,107 +551,127 @@ static Standard_Integer WriteGltf (Draw_Interpretor& theDI,
     }
     else if (anArgCase == "-texturesSeparate")
     {
-      toEmbedTexturesInGlb = false;
+      aNode->InternalParameters.WriteEmbedTexturesInGlb = false;
     }
     else if (anArgCase == "-draco")
     {
-      aDracoParameters.DracoCompression = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WriteDracoParameters.DracoCompression =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArgCase == "-compressionlevel" && (anArgIter + 1) < theNbArgs
-             && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.CompressionLevel))
+             && Draw::ParseInteger(theArgVec[anArgIter + 1],
+             aNode->InternalParameters.WriteDracoParameters.CompressionLevel))
     {
       ++anArgIter;
     }
     else if (anArgCase == "-quantizepositionbits" && (anArgIter + 1) < theNbArgs
-             && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizePositionBits))
+             && Draw::ParseInteger(theArgVec[anArgIter + 1],
+             aNode->InternalParameters.WriteDracoParameters.QuantizePositionBits))
     {
       ++anArgIter;
     }
     else if (anArgCase == "-quantizenormalbits" && (anArgIter + 1) < theNbArgs
-             && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeNormalBits))
+             && Draw::ParseInteger(theArgVec[anArgIter + 1],
+             aNode->InternalParameters.WriteDracoParameters.QuantizeNormalBits))
     {
       ++anArgIter;
     }
     else if (anArgCase == "-quantizetexcoordbits" && (anArgIter + 1) < theNbArgs
-             && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeTexcoordBits))
+             && Draw::ParseInteger(theArgVec[anArgIter + 1],
+             aNode->InternalParameters.WriteDracoParameters.QuantizeTexcoordBits))
     {
       ++anArgIter;
     }
     else if (anArgCase == "-quantizecolorbits" && (anArgIter + 1) < theNbArgs
-             && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeColorBits))
+             && Draw::ParseInteger(theArgVec[anArgIter + 1],
+             aNode->InternalParameters.WriteDracoParameters.QuantizeColorBits))
     {
       ++anArgIter;
     }
     else if (anArgCase == "-quantizegenericbits" && (anArgIter + 1) < theNbArgs
-             && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeGenericBits))
+             && Draw::ParseInteger(theArgVec[anArgIter + 1],
+             aNode->InternalParameters.WriteDracoParameters.QuantizeGenericBits))
     {
       ++anArgIter;
     }
     else if (anArgCase == "-unifiedquantization")
     {
-      aDracoParameters.UnifiedQuantization = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WriteDracoParameters.UnifiedQuantization =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArgCase == "-parallel")
     {
-      isParallel = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WriteParallel =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else
     {
-      Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+      theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
       return 1;
     }
   }
   if (aGltfFilePath.IsEmpty())
   {
-    Message::SendFail() << "Syntax error: wrong number of arguments";
+    theDI << "Syntax error: wrong number of arguments\n";
     return 1;
   }
 
-  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
 
   TCollection_AsciiString anExt = aGltfFilePath;
   anExt.LowerCase();
-  Standard_Real aScaleFactorM = 1.;
-  if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM, UnitsMethods_LengthUnit_Meter))
-  {
-    XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
-    aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
-  }
-
-  RWGltf_CafWriter aWriter (aGltfFilePath, anExt.EndsWith (".glb"));
-  aWriter.SetTransformationFormat (aTrsfFormat);
-  aWriter.SetNodeNameFormat (aNodeNameFormat);
-  aWriter.SetMeshNameFormat (aMeshNameFormat);
-  aWriter.SetForcedUVExport (toForceUVExport);
-  aWriter.SetToEmbedTexturesInGlb (toEmbedTexturesInGlb);
-  aWriter.SetMergeFaces (toMergeFaces);
-  aWriter.SetSplitIndices16 (toSplitIndices16);
-  aWriter.SetParallel(isParallel);
-  aWriter.SetCompressionParameters(aDracoParameters);
-  aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (aScaleFactorM);
-  aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (aSystemCoordSys);
-  aWriter.Perform (aDoc, aFileInfo, aProgress->Start());
+  aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
+  Handle(RWGltf_Provider) aProvider =
+    new RWGltf_Provider(aNode);
+  Standard_Boolean aWriteStat = Standard_False;
+  Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+  if (!aDoc.IsNull())
+  {
+    aWriteStat = aProvider->Write(aGltfFilePath, aDoc, aWS, aProgress->Start());
+  }
+  else if (!aShape.IsNull())
+  {
+    aWriteStat = aProvider->Write(aGltfFilePath, aShape, aWS, aProgress->Start());
+  }
+  if (!aWriteStat)
+  {
+    theDI << "Cannot write any relevant data to the GLTF file\n";
+    return 1;
+  }
   return 0;
 }
 
-static Standard_Integer writestl
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+//=============================================================================
+//function : writestl
+//purpose  :
+//=============================================================================
+static Standard_Integer writestl(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if (argc < 3 || argc > 4) {
-    di << "Use: " << argv[0]
-    << " shape file [ascii/binary (0/1) : 1 by default]\n";
-  } else {
-    TopoDS_Shape aShape = DBRep::Get(argv[1]);
+  if (theNbArgs < 3 || theNbArgs > 4)
+  {
+    theDI << "Use: " << theArgVec[0]
+      << " shape file [ascii/binary (0/1) : 1 by default]\n";
+  }
+  else
+  {
+    TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
     Standard_Boolean isASCIIMode = Standard_False;
-    if (argc == 4) {
-      isASCIIMode = (Draw::Atoi(argv[3]) == 0);
+    if (theNbArgs == 4)
+    {
+      isASCIIMode = (Draw::Atoi(theArgVec[3]) == 0);
+    }
+    Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode();
+    aNode->GlobalParameters.LengthUnit = GetLengthUnit();
+    Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
+    aNode->InternalParameters.WriteAscii = isASCIIMode;
+    Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+    Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
+    if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start()))
+    {
+      theDI << "Error: Mesh writing has been failed.\n";
     }
-    StlAPI_Writer aWriter;
-    aWriter.ASCIIMode() = isASCIIMode;
-    Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di);
-    Standard_Boolean isOK = aWriter.Write (aShape, argv[2], aProgress->Start());
-    if (!isOK)
-       di << "** Error **: Mesh writing has been failed.\n";
   }
   return 0;
 }
@@ -631,12 +685,14 @@ static Standard_Integer readstl(Draw_Interpretor& theDI,
                                 const char** theArgv)
 {
   TCollection_AsciiString aShapeName, aFilePath;
-  bool toCreateCompOfTris = false;
-  bool anIsMulti = false;
-  double aMergeAngle = M_PI / 2.0;
+  Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode();
+  aNode->GlobalParameters.LengthUnit = GetLengthUnit();
+  //bool toCreateCompOfTris = false;
+  //bool anIsMulti = false;
+  //double aMergeAngle = M_PI / 2.0;
   for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter)
   {
-    TCollection_AsciiString anArg (theArgv[anArgIter]);
+    TCollection_AsciiString anArg(theArgv[anArgIter]);
     anArg.LowerCase();
     if (aShapeName.IsEmpty())
     {
@@ -648,111 +704,78 @@ static Standard_Integer readstl(Draw_Interpretor& theDI,
     }
     else if (anArg == "-brep")
     {
-      toCreateCompOfTris = true;
+      Standard_Boolean toCreateCompOfTris = Standard_True;
       if (anArgIter + 1 < theArgc
-       && Draw::ParseOnOff (theArgv[anArgIter + 1], toCreateCompOfTris))
+          && Draw::ParseOnOff(theArgv[anArgIter + 1], toCreateCompOfTris))
       {
         ++anArgIter;
       }
+      if (!toCreateCompOfTris)
+      {
+        aNode->InternalParameters.ReadShapeType =
+          RWStl_ConfigurationNode::ReadMode_ShapeType_CompShape;
+      }
     }
     else if (anArg == "-multi")
     {
-      anIsMulti = true;
+      Standard_Boolean anIsMulti = Standard_True;
       if (anArgIter + 1 < theArgc
-       && Draw::ParseOnOff (theArgv[anArgIter + 1], anIsMulti))
+          && Draw::ParseOnOff(theArgv[anArgIter + 1], anIsMulti))
       {
         ++anArgIter;
       }
+      if (anIsMulti)
+      {
+        aNode->InternalParameters.ReadShapeType =
+          RWStl_ConfigurationNode::ReadMode_ShapeType_MultiMesh;
+      }
     }
     else if (anArg == "-mergeangle"
-          || anArg == "-smoothangle"
-          || anArg == "-nomergeangle"
-          || anArg == "-nosmoothangle")
+             || anArg == "-smoothangle"
+             || anArg == "-nomergeangle"
+             || anArg == "-nosmoothangle")
     {
-      if (anArg.StartsWith ("-no"))
+      if (anArg.StartsWith("-no"))
       {
-        aMergeAngle = M_PI / 2.0;
+        aNode->InternalParameters.ReadMergeAngle = M_PI / 2.0;
       }
       else
       {
-        aMergeAngle = M_PI / 4.0;
+        aNode->InternalParameters.ReadMergeAngle = M_PI / 4.0;
         if (anArgIter + 1 < theArgc
-         && Draw::ParseReal (theArgv[anArgIter + 1], aMergeAngle))
+            && Draw::ParseReal(theArgv[anArgIter + 1], aNode->InternalParameters.ReadMergeAngle))
         {
-          if (aMergeAngle < 0.0 || aMergeAngle > 90.0)
+          if (aNode->InternalParameters.ReadMergeAngle < 0.0 ||
+              aNode->InternalParameters.ReadMergeAngle > 90.0)
           {
             theDI << "Syntax error: angle should be within [0,90] range";
             return 1;
           }
-
           ++anArgIter;
-          aMergeAngle = aMergeAngle * M_PI / 180.0;
         }
       }
     }
     else
     {
-      Message::SendFail() << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'";
+      theDI << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'\n";
       return 1;
     }
   }
   if (aFilePath.IsEmpty())
   {
-    Message::SendFail() << "Syntax error: not enough arguments";
+    theDI << "Syntax error: not enough arguments\n";
     return 1;
   }
-
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+  Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
   TopoDS_Shape aShape;
-  if (!toCreateCompOfTris)
+  Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+  if (!aProvider->Read(aFilePath, aShape, aWS, aProgress->Start()))
   {
-    Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI,1);
-    if(anIsMulti)
-    {
-      NCollection_Sequence<Handle(Poly_Triangulation)> aTriangList;
-      // Read STL file to the triangulation list.
-      RWStl::ReadFile(aFilePath.ToCString(),aMergeAngle,aTriangList,aProgress->Start());
-      BRep_Builder aB;
-      TopoDS_Face aFace;
-      if (aTriangList.Size() == 1)
-      {
-        aB.MakeFace (aFace);
-        aB.UpdateFace (aFace,aTriangList.First());
-        aShape = aFace;
-      }
-      else
-      {
-        TopoDS_Compound aCmp;
-        aB.MakeCompound (aCmp);
-      
-        NCollection_Sequence<Handle(Poly_Triangulation)>::Iterator anIt (aTriangList);
-        for (; anIt.More(); anIt.Next())
-        { 
-          aB.MakeFace (aFace);
-          aB.UpdateFace (aFace,anIt.Value());
-          aB.Add (aCmp,aFace);
-        }
-        aShape = aCmp;
-      }
-    }
-    else
-    {
-      // Read STL file to the triangulation.
-      Handle(Poly_Triangulation) aTriangulation = RWStl::ReadFile (aFilePath.ToCString(),aMergeAngle,aProgress->Start());
-
-      TopoDS_Face aFace;
-      BRep_Builder aB;
-      aB.MakeFace (aFace);
-      aB.UpdateFace (aFace,aTriangulation);
-      aShape = aFace;
-    }
-  }
-  else
-  {
-    Standard_DISABLE_DEPRECATION_WARNINGS
-    StlAPI::Read(aShape, aFilePath.ToCString());
-    Standard_ENABLE_DEPRECATION_WARNINGS
+    theDI << "Cannot read any relevant data from the STL file\n";
+    return 1;
   }
-  DBRep::Set (aShapeName.ToCString(), aShape);
+  DBRep::Set(aShapeName.ToCString(), aShape);
   return 0;
 }
 
@@ -760,92 +783,95 @@ static Standard_Integer readstl(Draw_Interpretor& theDI,
 //function : ReadObj
 //purpose  : Reads OBJ file
 //=============================================================================
-static Standard_Integer ReadObj (Draw_Interpretor& theDI,
-                                 Standard_Integer theNbArgs,
-                                 const char** theArgVec)
+static Standard_Integer ReadObj(Draw_Interpretor& theDI,
+                                Standard_Integer theNbArgs,
+                                const char** theArgVec)
 {
   TCollection_AsciiString aDestName, aFilePath;
+  Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode();
+  aNode->GlobalParameters.LengthUnit = GetLengthUnit();
   Standard_Boolean toUseExistingDoc = Standard_False;
-  Standard_Real aFileUnitFactor = -1.0;
-  RWMesh_CoordinateSystem aResultCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
-  Standard_Boolean toListExternalFiles = Standard_False, isSingleFace = Standard_False, isSinglePrecision = Standard_False;
+  //Standard_Real aFileUnitFactor = -1.0;
+  //RWMesh_CoordinateSystem aResultCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
+  //Standard_Boolean toListExternalFiles = Standard_False, isSingleFace = Standard_False, isSinglePrecision = Standard_False;
   Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readobj");
   for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
   {
-    TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+    TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
     anArgCase.LowerCase();
     if (anArgIter + 1 < theNbArgs
-     && (anArgCase == "-unit"
-      || anArgCase == "-units"
-      || anArgCase == "-fileunit"
-      || anArgCase == "-fileunits"))
-    {
-      const TCollection_AsciiString aUnitStr (theArgVec[++anArgIter]);
-      aFileUnitFactor = UnitsAPI::AnyToSI (1.0, aUnitStr.ToCString());
-      if (aFileUnitFactor <= 0.0)
+        && (anArgCase == "-unit"
+        || anArgCase == "-units"
+        || anArgCase == "-fileunit"
+        || anArgCase == "-fileunits"))
+    {
+      const TCollection_AsciiString aUnitStr(theArgVec[++anArgIter]);
+      aNode->InternalParameters.FileLengthUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString());
+      if (aNode->InternalParameters.FileLengthUnit <= 0.0)
       {
-        Message::SendFail() << "Syntax error: wrong length unit '" << aUnitStr << "'";
+        theDI << "Syntax error: wrong length unit '" << aUnitStr << "'\n";
         return 1;
       }
     }
     else if (anArgIter + 1 < theNbArgs
-          && (anArgCase == "-filecoordinatesystem"
-           || anArgCase == "-filecoordsystem"
-           || anArgCase == "-filecoordsys"))
+             && (anArgCase == "-filecoordinatesystem"
+             || anArgCase == "-filecoordsystem"
+             || anArgCase == "-filecoordsys"))
     {
-      if (!parseCoordinateSystem (theArgVec[++anArgIter], aFileCoordSys))
+      if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.FileCS))
       {
-        Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+        theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n";
         return 1;
       }
     }
     else if (anArgIter + 1 < theNbArgs
-          && (anArgCase == "-resultcoordinatesystem"
-           || anArgCase == "-resultcoordsystem"
-           || anArgCase == "-resultcoordsys"
-           || anArgCase == "-rescoordsys"))
+             && (anArgCase == "-resultcoordinatesystem"
+             || anArgCase == "-resultcoordsystem"
+             || anArgCase == "-resultcoordsys"
+             || anArgCase == "-rescoordsys"))
     {
-      if (!parseCoordinateSystem (theArgVec[++anArgIter], aResultCoordSys))
+      if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS))
       {
-        Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+        theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n";
         return 1;
       }
     }
     else if (anArgCase == "-singleprecision"
-          || anArgCase == "-singleprec")
+             || anArgCase == "-singleprec")
     {
-      isSinglePrecision = Standard_True;
+      aNode->InternalParameters.ReadSinglePrecision = Standard_True;
       if (anArgIter + 1 < theNbArgs
-       && Draw::ParseOnOff (theArgVec[anArgIter + 1], isSinglePrecision))
+          && Draw::ParseOnOff(theArgVec[anArgIter + 1],
+          aNode->InternalParameters.ReadSinglePrecision))
       {
         ++anArgIter;
       }
     }
     else if (isNoDoc
-          && (anArgCase == "-singleface"
-           || anArgCase == "-singletriangulation"))
+             && (anArgCase == "-singleface"
+             || anArgCase == "-singletriangulation"))
     {
-      isSingleFace = Standard_True;
+      aNode->InternalParameters.ReadCreateShapes = Standard_True;
     }
     else if (!isNoDoc
-          && (anArgCase == "-nocreate"
-           || anArgCase == "-nocreatedoc"))
+             && (anArgCase == "-nocreate"
+             || anArgCase == "-nocreatedoc"))
     {
       toUseExistingDoc = Standard_True;
       if (anArgIter + 1 < theNbArgs
-       && Draw::ParseOnOff (theArgVec[anArgIter + 1], toUseExistingDoc))
+          && Draw::ParseOnOff(theArgVec[anArgIter + 1], toUseExistingDoc))
       {
         ++anArgIter;
       }
     }
-    else if (anArgCase == "-listexternalfiles"
-          || anArgCase == "-listexternals"
-          || anArgCase == "-listexternal"
-          || anArgCase == "-external"
-          || anArgCase == "-externalfiles")
-    {
-      toListExternalFiles = Standard_True;
-    }
+    //else if (anArgCase == "-listexternalfiles"
+    //         || anArgCase == "-listexternals"
+    //         || anArgCase == "-listexternal"
+    //         || anArgCase == "-external"
+    //         || anArgCase == "-externalfiles")
+    //{
+    //  toListExternalFiles = Standard_True;
+    //}
     else if (aDestName.IsEmpty())
     {
       aDestName = theArgVec[anArgIter];
@@ -856,92 +882,64 @@ static Standard_Integer ReadObj (Draw_Interpretor& theDI,
     }
     else
     {
-      Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+      theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
       return 1;
     }
   }
   if (aFilePath.IsEmpty())
   {
-    Message::SendFail() << "Syntax error: wrong number of arguments";
+    theDI << "Syntax error: wrong number of arguments\n";
     return 1;
   }
-
-  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
   Handle(TDocStd_Document) aDoc;
-  if (!isNoDoc
-   && !toListExternalFiles)
+  if (!isNoDoc)
   {
     Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
     Standard_CString aNameVar = aDestName.ToCString();
-    DDocStd::GetDocument (aNameVar, aDoc, Standard_False);
+    DDocStd::GetDocument(aNameVar, aDoc, Standard_False);
     if (aDoc.IsNull())
     {
       if (toUseExistingDoc)
       {
-        Message::SendFail() << "Error: document with name " << aDestName << " does not exist";
+        theDI << "Error: document with name " << aDestName << " does not exist\n";
         return 1;
       }
-      anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
+      anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
     }
     else if (!toUseExistingDoc)
     {
-      Message::SendFail() << "Error: document with name " << aDestName << " already exists";
+      theDI << "Error: document with name " << aDestName << " already exists\n";
       return 1;
     }
   }
-  Standard_Real aScaleFactorM = 1.;
-  if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM, UnitsMethods_LengthUnit_Meter))
-  {
-    XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
-    aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
-  }
-
-  RWObj_CafReader aReader;
-  aReader.SetSinglePrecision (isSinglePrecision);
-  aReader.SetSystemLengthUnit (aScaleFactorM);
-  aReader.SetSystemCoordinateSystem (aResultCoordSys);
-  aReader.SetFileLengthUnit (aFileUnitFactor);
-  aReader.SetFileCoordinateSystem (aFileCoordSys);
-  aReader.SetDocument (aDoc);
-  if (isSingleFace)
-  {
-    RWObj_TriangulationReader aSimpleReader;
-    aSimpleReader.SetSinglePrecision (isSinglePrecision);
-    aSimpleReader.SetCreateShapes (Standard_False);
-    aSimpleReader.SetTransformation (aReader.CoordinateSystemConverter());
-    aSimpleReader.Read (aFilePath.ToCString(), aProgress->Start());
-
-    Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
-    TopoDS_Face aFace;
-    BRep_Builder aBuiler;
-    aBuiler.MakeFace (aFace);
-    aBuiler.UpdateFace (aFace, aTriangulation);
-    DBRep::Set (aDestName.ToCString(), aFace);
-    return 0;
-  }
-
-  if (toListExternalFiles)
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+  Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
+  Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+  Standard_Boolean aReadStat = Standard_False;
+  if (isNoDoc)
   {
-    aReader.ProbeHeader (aFilePath);
-    for (NCollection_IndexedMap<TCollection_AsciiString>::Iterator aFileIter (aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next())
+    TopoDS_Shape aShape;
+    aReadStat = aProvider->Read(aFilePath, aShape, aWS, aProgress->Start());
+    if (aReadStat)
     {
-      theDI << "\"" << aFileIter.Value() << "\" ";
+      DBRep::Set(aDestName.ToCString(), aShape);
     }
   }
   else
   {
-    aReader.Perform (aFilePath, aProgress->Start());
-    if (isNoDoc)
-    {
-      DBRep::Set (aDestName.ToCString(), aReader.SingleShape());
-    }
-    else
+    aReadStat = aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start());
+    if (aReadStat)
     {
-      Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
-      TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName);
-      Draw::Set (aDestName.ToCString(), aDrawDoc);
+      Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
+      TDataStd_Name::Set(aDoc->GetData()->Root(), aDestName);
+      Draw::Set(aDestName.ToCString(), aDrawDoc);
     }
   }
+  if (!aReadStat)
+  {
+    theDI << "Cannot read any relevant data from the Obj file\n";
+    return 1;
+  }
   return 0;
 }
 
@@ -949,83 +947,84 @@ static Standard_Integer ReadObj (Draw_Interpretor& theDI,
 //function : WriteObj
 //purpose  : Writes OBJ file
 //=============================================================================
-static Standard_Integer WriteObj (Draw_Interpretor& theDI,
-                                  Standard_Integer theNbArgs,
-                                  const char** theArgVec)
+static Standard_Integer WriteObj(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
   TCollection_AsciiString anObjFilePath;
   Handle(TDocStd_Document) aDoc;
+  Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode();
+  aNode->GlobalParameters.LengthUnit = GetLengthUnit();
   Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
-  TColStd_IndexedDataMapOfStringString aFileInfo;
-  Standard_Real aFileUnitFactor = -1.0;
-  RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
+  //TColStd_IndexedDataMapOfStringString aFileInfo;
+  //Standard_Real aFileUnitFactor = -1.0;
+  //RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
   for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
   {
-    TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+    TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
     anArgCase.LowerCase();
-        if (anArgIter + 1 < theNbArgs
-     && (anArgCase == "-unit"
-      || anArgCase == "-units"
-      || anArgCase == "-fileunit"
-      || anArgCase == "-fileunits"))
-    {
-      const TCollection_AsciiString aUnitStr (theArgVec[++anArgIter]);
-      aFileUnitFactor = UnitsAPI::AnyToSI (1.0, aUnitStr.ToCString());
-      if (aFileUnitFactor <= 0.0)
+    if (anArgIter + 1 < theNbArgs
+        && (anArgCase == "-unit"
+        || anArgCase == "-units"
+        || anArgCase == "-fileunit"
+        || anArgCase == "-fileunits"))
+    {
+      const TCollection_AsciiString aUnitStr(theArgVec[++anArgIter]);
+      aNode->InternalParameters.FileLengthUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString());
+      if (aNode->InternalParameters.FileLengthUnit <= 0.0)
       {
-        Message::SendFail() << "Syntax error: wrong length unit '" << aUnitStr << "'";
+        theDI << "Syntax error: wrong length unit '" << aUnitStr << "'\n";
         return 1;
       }
     }
     else if (anArgIter + 1 < theNbArgs
-          && (anArgCase == "-filecoordinatesystem"
-           || anArgCase == "-filecoordsystem"
-           || anArgCase == "-filecoordsys"))
+             && (anArgCase == "-filecoordinatesystem"
+             || anArgCase == "-filecoordsystem"
+             || anArgCase == "-filecoordsys"))
     {
-      if (!parseCoordinateSystem (theArgVec[++anArgIter], aFileCoordSys))
+      if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.FileCS))
       {
-        Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+        theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n";
         return 1;
       }
     }
     else if (anArgIter + 1 < theNbArgs
-          && (anArgCase == "-systemcoordinatesystem"
-           || anArgCase == "-systemcoordsystem"
-           || anArgCase == "-systemcoordsys"
-           || anArgCase == "-syscoordsys"))
+             && (anArgCase == "-systemcoordinatesystem"
+             || anArgCase == "-systemcoordsystem"
+             || anArgCase == "-systemcoordsys"
+             || anArgCase == "-syscoordsys"))
     {
-      if (!parseCoordinateSystem (theArgVec[++anArgIter], aSystemCoordSys))
+      if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS))
       {
-        Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+        theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n";
         return 1;
       }
     }
     else if (anArgCase == "-comments"
-          && anArgIter + 1 < theNbArgs)
+             && anArgIter + 1 < theNbArgs)
     {
-      aFileInfo.Add ("Comments", theArgVec[++anArgIter]);
+      aNode->InternalParameters.WriteComment = theArgVec[++anArgIter];
     }
     else if (anArgCase == "-author"
-          && anArgIter + 1 < theNbArgs)
+             && anArgIter + 1 < theNbArgs)
     {
-      aFileInfo.Add ("Author", theArgVec[++anArgIter]);
+      aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter];
     }
     else if (aDoc.IsNull())
     {
       Standard_CString aNameVar = theArgVec[anArgIter];
-      DDocStd::GetDocument (aNameVar, aDoc, false);
+      DDocStd::GetDocument(aNameVar, aDoc, false);
       if (aDoc.IsNull())
       {
-        TopoDS_Shape aShape = DBRep::Get (aNameVar);
+        TopoDS_Shape aShape = DBRep::Get(aNameVar);
         if (aShape.IsNull())
         {
-          Message::SendFail() << "Syntax error: '" << aNameVar << "' is not a shape nor document";
+          theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n";
           return 1;
         }
-
-        anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
-        Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
-        aShapeTool->AddShape (aShape);
+        anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
+        Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
+        aShapeTool->AddShape(aShape);
       }
     }
     else if (anObjFilePath.IsEmpty())
@@ -1034,67 +1033,69 @@ static Standard_Integer WriteObj (Draw_Interpretor& theDI,
     }
     else
     {
-      Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+      theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
       return 1;
     }
   }
   if (anObjFilePath.IsEmpty())
   {
-    Message::SendFail() << "Syntax error: wrong number of arguments";
+    theDI << "Syntax error: wrong number of arguments\n";
     return 1;
   }
-
-  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
-
-  const Standard_Real aSystemUnitFactor = UnitsMethods::GetCasCadeLengthUnit() * 0.001;
-  RWObj_CafWriter aWriter (anObjFilePath);
-  aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (aSystemUnitFactor);
-  aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (aSystemCoordSys);
-  aWriter.ChangeCoordinateSystemConverter().SetOutputLengthUnit (aFileUnitFactor);
-  aWriter.ChangeCoordinateSystemConverter().SetOutputCoordinateSystem (aFileCoordSys);
-  aWriter.Perform (aDoc, aFileInfo, aProgress->Start());
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+  Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
+  Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+  if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start()))
+  {
+    theDI << "Error: Mesh writing has been failed.\n";
+  }
   return 0;
 }
 
-static Standard_Integer writevrml
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+//=============================================================================
+//function : writevrml
+//purpose  :
+//=============================================================================
+static Standard_Integer writevrml(Draw_Interpretor& theDI,
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
 {
-  if (argc < 3 || argc > 5) 
+  if (theNbArgs < 3 || theNbArgs > 5)
   {
-    di << "wrong number of parameters\n";
+    theDI << "wrong number of parameters\n";
     return 0;
   }
-
-  TopoDS_Shape aShape = DBRep::Get(argv[1]);
-
+  TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
   // Get the optional parameters
   Standard_Integer aVersion = 2;
   Standard_Integer aType = 1;
-  if (argc >= 4)
+  if (theNbArgs >= 4)
   {
-    aVersion = Draw::Atoi(argv[3]);
-    if (argc == 5)
-      aType = Draw::Atoi(argv[4]);
+    aVersion = Draw::Atoi(theArgVec[3]);
+    if (theNbArgs == 5)
+      aType = Draw::Atoi(theArgVec[4]);
   }
-
   // Bound parameters
   aVersion = Max(1, aVersion);
   aVersion = Min(2, aVersion);
   aType = Max(0, aType);
   aType = Min(2, aType);
-
-  VrmlAPI_Writer writer;
-
-  switch (aType)
-  {
-  case 0: writer.SetRepresentation(VrmlAPI_ShadedRepresentation); break;
-  case 1: writer.SetRepresentation(VrmlAPI_WireFrameRepresentation); break;
-  case 2: writer.SetRepresentation(VrmlAPI_BothRepresentation); break;
-  }
-
-  if (!writer.Write(aShape, argv[2], aVersion))
-  {
-    di << "Error: File " << argv[2] << " was not written\n";
+  Handle(Vrml_ConfigurationNode) aNode =
+    new Vrml_ConfigurationNode();
+  aNode->GlobalParameters.LengthUnit = GetLengthUnit();
+  Handle(Vrml_Provider) aProvider =
+    new Vrml_Provider(aNode);
+  aNode->InternalParameters.WriterVersion =
+    (Vrml_ConfigurationNode::WriteMode_WriterVersion)aVersion;
+  aNode->InternalParameters.WriteRepresentationType =
+    (Vrml_ConfigurationNode::WriteMode_RepresentationType)aType;
+
+  Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+  if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start()))
+  {
+    theDI << "Error: file writing failed '" << theArgVec[2] << "'\n";
+    return 1;
   }
 
   return 0;
@@ -1104,205 +1105,161 @@ static Standard_Integer writevrml
 //function : loadvrml
 //purpose  :
 //=======================================================================
-
-static Standard_Integer loadvrml
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer loadvrml(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if (argc<3) di << "wrong number of parameters"    << "\n";
-  else {
-    TopoDS_Shape aShape ;
-    VrmlData_DataMapOfShapeAppearance aShapeAppMap;
-
-    //-----------------------------------------------------------
-    std::filebuf aFic;
-    std::istream aStream (&aFic);
-
-    if (aFic.open(argv[2], std::ios::in)) {
-
-      // Get path of the VRML file.
-      OSD_Path aPath(argv[2]);
-      TCollection_AsciiString aVrmlDir(".");
-      TCollection_AsciiString aDisk = aPath.Disk();
-      TCollection_AsciiString aTrek = aPath.Trek();
-      if (!aTrek.IsEmpty())
-      {
-        if (!aDisk.IsEmpty())
-          aVrmlDir = aDisk;
-        else
-          aVrmlDir.Clear();
-        aTrek.ChangeAll('|', '/');
-        aVrmlDir += aTrek;
-      }
-
-      VrmlData_Scene aScene;
-      XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
-      Standard_Real anOCCUnitMM = UnitsMethods::GetCasCadeLengthUnit();
-      aScene.SetLinearScale(1000. / anOCCUnitMM);
-
-      aScene.SetVrmlDir (aVrmlDir);
-      aScene << aStream;
-      const char * aStr = 0L;
-      switch (aScene.Status()) {
-
-      case VrmlData_StatusOK:
-        {
-          aShape = aScene.GetShape(aShapeAppMap);
-          break;
-        }
-      case VrmlData_EmptyData:            aStr = "EmptyData"; break;
-      case VrmlData_UnrecoverableError:   aStr = "UnrecoverableError"; break;
-      case VrmlData_GeneralError:         aStr = "GeneralError"; break;
-      case VrmlData_EndOfFile:            aStr = "EndOfFile"; break;
-      case VrmlData_NotVrmlFile:          aStr = "NotVrmlFile"; break;
-      case VrmlData_CannotOpenFile:       aStr = "CannotOpenFile"; break;
-      case VrmlData_VrmlFormatError:      aStr = "VrmlFormatError"; break;
-      case VrmlData_NumericInputError:    aStr = "NumericInputError"; break;
-      case VrmlData_IrrelevantNumber:     aStr = "IrrelevantNumber"; break;
-      case VrmlData_BooleanInputError:    aStr = "BooleanInputError"; break;
-      case VrmlData_StringInputError:     aStr = "StringInputError"; break;
-      case VrmlData_NodeNameUnknown:      aStr = "NodeNameUnknown"; break;
-      case VrmlData_NonPositiveSize:      aStr = "NonPositiveSize"; break;
-      case VrmlData_ReadUnknownNode:      aStr = "ReadUnknownNode"; break;
-      case VrmlData_NonSupportedFeature:  aStr = "NonSupportedFeature"; break;
-      case VrmlData_OutputStreamUndefined:aStr = "OutputStreamUndefined"; break;
-      case VrmlData_NotImplemented:       aStr = "NotImplemented"; break;
-      default:
-        break;
-      }
-      if (aStr) {
-        di << " ++ VRML Error: " << aStr << " in line "
-          << aScene.GetLineError() << "\n";
-      }
-      else {
-        DBRep::Set(argv[1],aShape);
-      }
-    }
-    else {
-      di << "cannot open file\n";
-    }
-
-
-    //-----------------------------------------------------------
+  if (theNbArgs < 3)
+  {
+    theDI << "Error: wrong number of parameters" << "\n";
+    return 1;
+  }
+  Handle(Vrml_ConfigurationNode) aNode =
+    new Vrml_ConfigurationNode();
+  aNode->GlobalParameters.LengthUnit = GetLengthUnit();
+  Handle(Vrml_Provider) aProvider =
+    new Vrml_Provider(aNode);
+  TopoDS_Shape aShape;
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+  Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+  if (!aProvider->Read(theArgVec[2], aShape, aWS, aProgress->Start()))
+  {
+    theDI << "Error: file reading failed '" << theArgVec[2] << "'\n";
+    return 1;
   }
+  DBRep::Set(theArgVec[1], aShape);
   return 0;
 }
 
-//-----------------------------------------------------------------------------
-static Standard_Integer createmesh
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+//=======================================================================
+//function : createmesh
+//purpose  :
+//=======================================================================
+static Standard_Integer createmesh(Draw_Interpretor& theDI,
+                                   Standard_Integer theNbArgs,
+                                   const char** theArgVec)
 {
-  if (argc<3)
+  if (theNbArgs < 3)
   {
-    di << "Wrong number of parameters\n";
-    di << "Use: " << argv[0] << " <mesh name> <stl file>\n";
+    theDI << "Wrong number of parameters\n";
+    theDI << "Use: " << theArgVec[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";
+    theDI << "No active view. Please call 'vinit' first\n";
     return 0;
   }
 
   // Progress indicator
-  OSD_Path aFile( argv[2] );
-  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
-  Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile (aFile, aProgress->Start());
+  OSD_Path aFile(theArgVec[2]);
+  Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+  Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile(aFile, aProgress->Start());
 
-  di << "Reading OK...\n";
-  Handle( XSDRAWSTLVRML_DataSource ) aDS = new XSDRAWSTLVRML_DataSource( aSTLMesh );
-  di << "Data source is created successful\n";
-  Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
-  di << "MeshVS_Mesh is created successful\n";
+  theDI << "Reading OK...\n";
+  Handle(XSDRAWSTLVRML_DataSource) aDS = new XSDRAWSTLVRML_DataSource(aSTLMesh);
+  theDI << "Data source is created successful\n";
+  Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh();
+  theDI << "MeshVS_Mesh is created successful\n";
 
-  aMesh->SetDataSource( aDS );
-  aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
+  aMesh->SetDataSource(aDS);
+  aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True);
 
-  aMesh->GetDrawer()->SetColor( MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW );
+  aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW);
 
   // Hide all nodes by default
   Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
   const Standard_Integer aLen = aSTLMesh->NbNodes();
-  for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
-    aNodes->ChangeMap().Add( anIndex );
-  aMesh->SetHiddenNodes( aNodes );
-  aMesh->SetSelectableNodes ( aNodes );
+  for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++)
+    aNodes->ChangeMap().Add(anIndex);
+  aMesh->SetHiddenNodes(aNodes);
+  aMesh->SetSelectableNodes(aNodes);
 
-  VDisplayAISObject(argv[1], aMesh);
-  aContext->Deactivate( aMesh );
+  VDisplayAISObject(theArgVec[1], aMesh);
+  aContext->Deactivate(aMesh);
 
-  Draw::Set( argv[1], new XSDRAWSTLVRML_DrawableMesh( aMesh ) );
-  Handle( V3d_View ) aView = ViewerTest::CurrentView();
-  if ( !aView.IsNull() )
+  Draw::Set(theArgVec[1], new XSDRAWSTLVRML_DrawableMesh(aMesh));
+  Handle(V3d_View) aView = ViewerTest::CurrentView();
+  if (!aView.IsNull())
     aView->FitAll();
 
   return 0;
 }
-//-----------------------------------------------------------------------------
 
-static Standard_Integer create3d
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+//=======================================================================
+//function : create3d
+//purpose  :
+//=======================================================================
+static Standard_Integer create3d(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if (argc<2)
+  if (theNbArgs < 2)
   {
-    di << "Wrong number of parameters\n";
-    di << "Use: " << argv[0] << " <mesh name>\n";
+    theDI << "Wrong number of parameters\n";
+    theDI << "Use: " << theArgVec[0] << " <mesh name>\n";
     return 0;
   }
 
   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
   if (aContext.IsNull())
   {
-    di << "No active view. Please call 'vinit' first\n";
+    theDI << "No active view. Please call 'vinit' first\n";
     return 0;
   }
 
-  Handle( XSDRAWSTLVRML_DataSource3D ) aDS = new XSDRAWSTLVRML_DataSource3D();
-  di << "Data source is created successful\n";
-  Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
-  di << "MeshVS_Mesh is created successful\n";
+  Handle(XSDRAWSTLVRML_DataSource3D) aDS = new XSDRAWSTLVRML_DataSource3D();
+  theDI << "Data source is created successful\n";
+  Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh();
+  theDI << "MeshVS_Mesh is created successful\n";
 
-  aMesh->SetDataSource( aDS );
-  aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
+  aMesh->SetDataSource(aDS);
+  aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True);
 
-  aMesh->GetDrawer()->SetColor( MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW );
+  aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW);
 
   // Hide all nodes by default
   Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
   Standard_Integer aLen = aDS->GetAllNodes().Extent();
-  for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
-    aNodes->ChangeMap().Add( anIndex );
-  aMesh->SetHiddenNodes( aNodes );
-  aMesh->SetSelectableNodes ( aNodes );
+  for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++)
+    aNodes->ChangeMap().Add(anIndex);
+  aMesh->SetHiddenNodes(aNodes);
+  aMesh->SetSelectableNodes(aNodes);
 
-  VDisplayAISObject(argv[1], aMesh);
-  aContext->Deactivate( aMesh );
+  VDisplayAISObject(theArgVec[1], aMesh);
+  aContext->Deactivate(aMesh);
 
-  Draw::Set( argv[1], new XSDRAWSTLVRML_DrawableMesh( aMesh ) );
-  Handle( V3d_View ) aView = ViewerTest::CurrentView();
-  if ( !aView.IsNull() )
+  Draw::Set(theArgVec[1], new XSDRAWSTLVRML_DrawableMesh(aMesh));
+  Handle(V3d_View) aView = ViewerTest::CurrentView();
+  if (!aView.IsNull())
     aView->FitAll();
 
   return 0;
 }
 
-Handle( MeshVS_Mesh ) getMesh( const char* theName, Draw_Interpretor& di)
+//=======================================================================
+//function : getMesh
+//purpose  :
+//=======================================================================
+Handle(MeshVS_Mesh) getMesh(const char* theName,
+                            Draw_Interpretor& theDI)
 {
-  Handle( XSDRAWSTLVRML_DrawableMesh ) aDrawMesh =
-    Handle( XSDRAWSTLVRML_DrawableMesh )::DownCast( Draw::Get( theName ) );
+  Handle(XSDRAWSTLVRML_DrawableMesh) aDrawMesh =
+    Handle(XSDRAWSTLVRML_DrawableMesh)::DownCast(Draw::Get(theName));
 
-  if( aDrawMesh.IsNull() )
+  if (aDrawMesh.IsNull())
   {
-    di << "There is no such object\n";
+    theDI << "There is no such object\n";
     return NULL;
   }
   else
   {
-    Handle( MeshVS_Mesh ) aMesh = aDrawMesh->GetMesh();
-    if( aMesh.IsNull() )
+    Handle(MeshVS_Mesh) aMesh = aDrawMesh->GetMesh();
+    if (aMesh.IsNull())
     {
-      di << "There is invalid mesh\n";
+      theDI << "There is invalid mesh\n";
       return NULL;
     }
     else
@@ -1310,106 +1267,136 @@ Handle( MeshVS_Mesh ) getMesh( const char* theName, Draw_Interpretor& di)
   }
 }
 
-//-----------------------------------------------------------------------------
-static Standard_Integer setcolor
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv, Standard_Integer theParam )
+//=======================================================================
+//function : setcolor
+//purpose  :
+//=======================================================================
+static Standard_Integer setcolor(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec,
+                                 Standard_Integer theParam)
 {
-  if (argc<5)
-    di << "Wrong number of parameters\n";
+  if (theNbArgs < 5)
+    theDI << "Wrong number of parameters\n";
   else
   {
-    Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
-    if( !aMesh.IsNull() )
+    Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+    if (!aMesh.IsNull())
     {
-      Standard_Real aRed = Draw::Atof (argv[2]);
-      Standard_Real aGreen = Draw::Atof (argv[3]);
-      Standard_Real aBlue = Draw::Atof (argv[4]);
-      aMesh->GetDrawer()->SetColor( (MeshVS_DrawerAttribute)theParam,
-                                    Quantity_Color( aRed, aGreen, aBlue, Quantity_TOC_RGB ) );
+      Standard_Real aRed = Draw::Atof(theArgVec[2]);
+      Standard_Real aGreen = Draw::Atof(theArgVec[3]);
+      Standard_Real aBlue = Draw::Atof(theArgVec[4]);
+      aMesh->GetDrawer()->SetColor((MeshVS_DrawerAttribute)theParam,
+                                   Quantity_Color(aRed, aGreen, aBlue, Quantity_TOC_RGB));
 
-      Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
+      Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
 
-      if( aContext.IsNull() )
-        di << "The context is null\n";
+      if (aContext.IsNull())
+        theDI << "The context is null\n";
       else
-        aContext->Redisplay (aMesh, Standard_True);
+        aContext->Redisplay(aMesh, Standard_True);
     }
   }
   return 0;
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer meshcolor
-(Draw_Interpretor& theInterp, Standard_Integer argc, const char** argv )
+
+//=======================================================================
+//function : meshcolor
+//purpose  :
+//=======================================================================
+static Standard_Integer meshcolor(Draw_Interpretor& theInterp,
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
 {
-  return setcolor( theInterp, argc, argv, MeshVS_DA_InteriorColor );
+  return setcolor(theInterp, theNbArgs, theArgVec, MeshVS_DA_InteriorColor);
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer linecolor
-(Draw_Interpretor& theInterp, Standard_Integer argc, const char** argv )
+
+//=======================================================================
+//function : linecolor
+//purpose  :
+//=======================================================================
+static Standard_Integer linecolor(Draw_Interpretor& theInterp,
+                                  Standard_Integer theNbArgs,
+                                  const char** theArgVec)
 {
-  return setcolor( theInterp, argc, argv, MeshVS_DA_EdgeColor );
+  return setcolor(theInterp, theNbArgs, theArgVec, MeshVS_DA_EdgeColor);
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer meshmat
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+
+//=======================================================================
+//function : meshmat
+//purpose  :
+//=======================================================================
+static Standard_Integer meshmat(Draw_Interpretor& theDI,
+                                Standard_Integer theNbArgs,
+                                const char** theArgVec)
 {
-  if (argc<3)
-    di << "Wrong number of parameters\n";
+  if (theNbArgs < 3)
+    theDI << "Wrong number of parameters\n";
   else
   {
-    Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
-    if( !aMesh.IsNull() )
+    Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+    if (!aMesh.IsNull())
     {
-      Standard_Integer aMaterial = Draw::Atoi (argv[2]);
+      Standard_Integer aMaterial = Draw::Atoi(theArgVec[2]);
 
       Graphic3d_MaterialAspect aMatAsp =
         (Graphic3d_MaterialAspect)(Graphic3d_NameOfMaterial)aMaterial;
 
-      if (argc == 4)
+      if (theNbArgs == 4)
       {
-        Standard_Real aTransparency = Draw::Atof(argv[3]);
-        aMatAsp.SetTransparency (Standard_ShortReal (aTransparency));
+        Standard_Real aTransparency = Draw::Atof(theArgVec[3]);
+        aMatAsp.SetTransparency(Standard_ShortReal(aTransparency));
       }
-      aMesh->GetDrawer()->SetMaterial( MeshVS_DA_FrontMaterial, aMatAsp );
-      aMesh->GetDrawer()->SetMaterial( MeshVS_DA_BackMaterial, aMatAsp );
+      aMesh->GetDrawer()->SetMaterial(MeshVS_DA_FrontMaterial, aMatAsp);
+      aMesh->GetDrawer()->SetMaterial(MeshVS_DA_BackMaterial, aMatAsp);
 
-      Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
+      Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
 
-      if( aContext.IsNull() )
-        di << "The context is null\n";
+      if (aContext.IsNull())
+        theDI << "The context is null\n";
       else
-        aContext->Redisplay (aMesh, Standard_True);
+        aContext->Redisplay(aMesh, Standard_True);
     }
   }
   return 0;
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer shrink
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+
+//=======================================================================
+//function : shrink
+//purpose  :
+//=======================================================================
+static Standard_Integer shrink(Draw_Interpretor& theDI,
+                               Standard_Integer theNbArgs,
+                               const char** theArgVec)
 {
-  if (argc<3)
-    di << "Wrong number of parameters\n";
+  if (theNbArgs < 3)
+    theDI << "Wrong number of parameters\n";
   else
   {
-    Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
-    if( !aMesh.IsNull() )
+    Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+    if (!aMesh.IsNull())
     {
-      Standard_Real aShrinkCoeff = Draw::Atof (argv[2]);
-      aMesh->GetDrawer()->SetDouble( MeshVS_DA_ShrinkCoeff, aShrinkCoeff );
+      Standard_Real aShrinkCoeff = Draw::Atof(theArgVec[2]);
+      aMesh->GetDrawer()->SetDouble(MeshVS_DA_ShrinkCoeff, aShrinkCoeff);
 
-      Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
+      Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
 
-      if( aContext.IsNull() )
-        di << "The context is null\n";
+      if (aContext.IsNull())
+        theDI << "The context is null\n";
       else
-        aContext->Redisplay (aMesh, Standard_True);
+        aContext->Redisplay(aMesh, Standard_True);
     }
   }
   return 0;
 }
 
-//-----------------------------------------------------------------------------
-static Standard_Integer closed (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
+//=======================================================================
+//function : closed
+//purpose  :
+//=======================================================================
+static Standard_Integer closed(Draw_Interpretor& theDI,
+                               Standard_Integer theArgc,
+                               const char** theArgv)
 {
   if (theArgc < 3)
   {
@@ -1417,96 +1404,109 @@ static Standard_Integer closed (Draw_Interpretor& theDI, Standard_Integer theArg
   }
   else
   {
-    Handle(MeshVS_Mesh) aMesh = getMesh (theArgv[1], theDI);
+    Handle(MeshVS_Mesh) aMesh = getMesh(theArgv[1], theDI);
     if (!aMesh.IsNull())
     {
-      Standard_Boolean aFlag = Draw::Atoi (theArgv[2]) != 0;
-      aMesh->GetDrawer()->SetBoolean (MeshVS_DA_SupressBackFaces, aFlag);
+      Standard_Boolean aFlag = Draw::Atoi(theArgv[2]) != 0;
+      aMesh->GetDrawer()->SetBoolean(MeshVS_DA_SupressBackFaces, aFlag);
 
-      Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
+      Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
       if (aContext.IsNull())
       {
         theDI << "The context is null\n";
       }
       else
       {
-        aContext->Redisplay (aMesh, Standard_True);
+        aContext->Redisplay(aMesh, Standard_True);
       }
     }
   }
   return 0;
 }
 
-//-----------------------------------------------------------------------------
-
-static Standard_Integer mdisplay
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+//=======================================================================
+//function : mdisplay
+//purpose  :
+//=======================================================================
+static Standard_Integer mdisplay(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if (argc<2)
-    di << "Wrong number of parameters\n";
+  if (theNbArgs < 2)
+    theDI << "Wrong number of parameters\n";
   else
   {
-    Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
-    if( !aMesh.IsNull() )
+    Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+    if (!aMesh.IsNull())
     {
-      Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
+      Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
 
-      if( aContext.IsNull() )
-        di << "The context is null\n";
+      if (aContext.IsNull())
+        theDI << "The context is null\n";
       else
       {
-        aContext->Display (aMesh, Standard_True);
+        aContext->Display(aMesh, Standard_True);
       }
     }
   }
   return 0;
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer merase
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+
+//=======================================================================
+//function : merase
+//purpose  :
+//=======================================================================
+static Standard_Integer merase(Draw_Interpretor& theDI,
+                               Standard_Integer theNbArgs,
+                               const char** theArgVec)
 {
-  if (argc<2)
-    di << "Wrong number of parameters\n";
+  if (theNbArgs < 2)
+    theDI << "Wrong number of parameters\n";
   else
   {
-    Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
-    if( !aMesh.IsNull() )
+    Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+    if (!aMesh.IsNull())
     {
-      Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
+      Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
 
-      if( aContext.IsNull() )
-        di << "The context is null\n";
+      if (aContext.IsNull())
+        theDI << "The context is null\n";
       else
       {
-        aContext->Erase (aMesh, Standard_True);
+        aContext->Erase(aMesh, Standard_True);
       }
     }
     else
-      di << "Mesh is null\n";
+      theDI << "Mesh is null\n";
   }
   return 0;
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer hidesel
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+
+//=======================================================================
+//function : hidesel
+//purpose  :
+//=======================================================================
+static Standard_Integer hidesel(Draw_Interpretor& theDI,
+                                Standard_Integer theNbArgs,
+                                const char** theArgVec)
 {
-  if (argc<2)
+  if (theNbArgs < 2)
   {
-    di << "Wrong number of parameters\n";
-    di << "Use: " << argv[0] << " <mesh name>\n";
+    theDI << "Wrong number of parameters\n";
+    theDI << "Use: " << theArgVec[0] << " <mesh name>\n";
     return 0;
   }
 
-  Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
-  Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
-  if( aMesh.IsNull() )
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+  if (aMesh.IsNull())
   {
-    di << "The mesh is invalid\n";
+    theDI << "The mesh is invalid\n";
     return 0;
   }
 
-  if( aContext.IsNull() )
-    di << "The context is null\n";
+  if (aContext.IsNull())
+    theDI << "The context is null\n";
   else
   {
     Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = aMesh->GetHiddenNodes();
@@ -1519,311 +1519,332 @@ static Standard_Integer hidesel
     {
       aHiddenElements = new TColStd_HPackedMapOfInteger();
     }
-    for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
+    for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
     {
-      Handle( MeshVS_MeshEntityOwner ) anOwner =
-        Handle( MeshVS_MeshEntityOwner )::DownCast( aContext->SelectedOwner() );
-      if( !anOwner.IsNull() )
+      Handle(MeshVS_MeshEntityOwner) anOwner =
+        Handle(MeshVS_MeshEntityOwner)::DownCast(aContext->SelectedOwner());
+      if (!anOwner.IsNull())
       {
-        if( anOwner->Type()==MeshVS_ET_Node )
+        if (anOwner->Type() == MeshVS_ET_Node)
         {
-          aHiddenNodes->ChangeMap().Add( anOwner->ID() );
+          aHiddenNodes->ChangeMap().Add(anOwner->ID());
         }
         else
         {
-          aHiddenElements->ChangeMap().Add( anOwner->ID() );
+          aHiddenElements->ChangeMap().Add(anOwner->ID());
         }
       }
     }
-    aContext->ClearSelected (Standard_False);
-    aMesh->SetHiddenNodes( aHiddenNodes );
-    aMesh->SetHiddenElems( aHiddenElements );
-    aContext->Redisplay (aMesh, Standard_True);
+    aContext->ClearSelected(Standard_False);
+    aMesh->SetHiddenNodes(aHiddenNodes);
+    aMesh->SetHiddenElems(aHiddenElements);
+    aContext->Redisplay(aMesh, Standard_True);
   }
 
   return 0;
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer showonly
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+
+//=======================================================================
+//function : showonly
+//purpose  :
+//=======================================================================
+static Standard_Integer showonly(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if (argc<2)
+  if (theNbArgs < 2)
   {
-    di << "Wrong number of parameters\n";
-    di << "Use: " << argv[0] << " <mesh name>\n";
+    theDI << "Wrong number of parameters\n";
+    theDI << "Use: " << theArgVec[0] << " <mesh name>\n";
     return 0;
   }
 
 
-  Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
-  Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
-  if( aMesh.IsNull() )
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+  if (aMesh.IsNull())
   {
-    di << "The mesh is invalid\n";
+    theDI << "The mesh is invalid\n";
     return 0;
   }
 
-  if( aContext.IsNull() )
-    di << "The context is null\n";
+  if (aContext.IsNull())
+    theDI << "The context is null\n";
   else
   {
     Handle(TColStd_HPackedMapOfInteger) aHiddenNodes =
       new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes());
     Handle(TColStd_HPackedMapOfInteger) aHiddenElements =
       new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllElements());
-    for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
+    for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
     {
-      Handle( MeshVS_MeshEntityOwner ) anOwner =
-        Handle( MeshVS_MeshEntityOwner )::DownCast( aContext->SelectedOwner() );
-      if( !anOwner.IsNull() )
+      Handle(MeshVS_MeshEntityOwner) anOwner =
+        Handle(MeshVS_MeshEntityOwner)::DownCast(aContext->SelectedOwner());
+      if (!anOwner.IsNull())
       {
-        if( anOwner->Type() == MeshVS_ET_Node )
+        if (anOwner->Type() == MeshVS_ET_Node)
         {
-          aHiddenNodes->ChangeMap().Remove( anOwner->ID() );
+          aHiddenNodes->ChangeMap().Remove(anOwner->ID());
         }
         else
         {
-          aHiddenElements->ChangeMap().Remove( anOwner->ID() );
+          aHiddenElements->ChangeMap().Remove(anOwner->ID());
         }
       }
     }
-    aMesh->SetHiddenNodes( aHiddenNodes );
-    aMesh->SetHiddenElems( aHiddenElements );
-    aContext->Redisplay (aMesh, Standard_True);
+    aMesh->SetHiddenNodes(aHiddenNodes);
+    aMesh->SetHiddenElems(aHiddenElements);
+    aContext->Redisplay(aMesh, Standard_True);
   }
 
   return 0;
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer showall
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
+
+//=======================================================================
+//function : showonly
+//purpose  :
+//=======================================================================
+static Standard_Integer showall(Draw_Interpretor& theDI,
+                                Standard_Integer theNbArgs,
+                                const char** theArgVec)
 {
-  if (argc<2)
+  if (theNbArgs < 2)
   {
-    di << "Wrong number of parameters\n";
-    di << "Use: " << argv[0] << " <mesh name>\n";
+    theDI << "Wrong number of parameters\n";
+    theDI << "Use: " << theArgVec[0] << " <mesh name>\n";
     return 0;
   }
 
-  Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
-  Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
-  if( aMesh.IsNull() )
+  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+  Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+  if (aMesh.IsNull())
   {
-    di << "The mesh is invalid\n";
+    theDI << "The mesh is invalid\n";
     return 0;
   }
 
-  if( aContext.IsNull() )
-    di << "The context is null\n";
+  if (aContext.IsNull())
+    theDI << "The context is null\n";
   else
   {
-    aMesh->SetHiddenNodes( new TColStd_HPackedMapOfInteger() );
-    aMesh->SetHiddenElems( new TColStd_HPackedMapOfInteger() );
-    aContext->Redisplay (aMesh, Standard_True);
+    aMesh->SetHiddenNodes(new TColStd_HPackedMapOfInteger());
+    aMesh->SetHiddenElems(new TColStd_HPackedMapOfInteger());
+    aContext->Redisplay(aMesh, Standard_True);
   }
 
   return 0;
 }
 
-//-----------------------------------------------------------------------------
-static Standard_Integer meshcolors( Draw_Interpretor& di,
-                                    Standard_Integer argc,
-                                    const char** argv )
+//=======================================================================
+//function : meshcolors
+//purpose  :
+//=======================================================================
+static Standard_Integer meshcolors(Draw_Interpretor& theDI,
+                                   Standard_Integer theNbArgs,
+                                   const char** theArgVec)
 {
   try
   {
     OCC_CATCH_SIGNALS
-      if ( argc < 4 )
+      if (theNbArgs < 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";
+        theDI << "Wrong number of parameters\n";
+        theDI << "Use : meshcolors <mesh name> <mode> <isreflect>\n";
+        theDI << "mode : {elem1|elem2|nodal|nodaltex|none}\n";
+        theDI << "       elem1 - different color for each element\n";
+        theDI << "       elem2 - one color for one side\n";
+        theDI << "       nodal - different color for each node\n";
+        theDI << "       nodaltex - different color for each node with texture interpolation\n";
+        theDI << "       none  - clear\n";
+        theDI << "isreflect : {0|1} \n";
 
         return 0;
       }
 
-      Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
+    Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
 
-      if ( aMesh.IsNull() )
-      {
-        di << "Mesh not found\n";
-        return 0;
-      }
-      Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
-      if ( anIC.IsNull() )
-      {
-        di << "The context is null\n";
-        return 0;
-      }
-      if( !aMesh.IsNull() )
+    if (aMesh.IsNull())
+    {
+      theDI << "Mesh not found\n";
+      return 0;
+    }
+    Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
+    if (anIC.IsNull())
+    {
+      theDI << "The context is null\n";
+      return 0;
+    }
+    if (!aMesh.IsNull())
+    {
+      TCollection_AsciiString aMode = TCollection_AsciiString(theArgVec[2]);
+      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"))
       {
-        TCollection_AsciiString aMode = TCollection_AsciiString (argv[2]);
-        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(theArgVec[3]);
+
+        for (Standard_Integer aCount = 0; aCount < aMesh->GetBuildersCount(); aCount++)
         {
-          Handle(MeshVS_PrsBuilder) aTempBuilder;
-          Standard_Integer aReflection = Draw::Atoi(argv[3]);
+          aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder");
+          if (!aTempBuilder.IsNull())
+            aMesh->RemoveBuilderById(aTempBuilder->GetId());
 
-          for (Standard_Integer aCount = 0 ; aCount < aMesh->GetBuildersCount(); aCount++ ){
-            aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder");
-            if( !aTempBuilder.IsNull())
-              aMesh->RemoveBuilderById(aTempBuilder->GetId());
+          aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder");
+          if (!aTempBuilder.IsNull())
+            aMesh->RemoveBuilderById(aTempBuilder->GetId());
+        }
 
-            aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder");
-            if( !aTempBuilder.IsNull())
-              aMesh->RemoveBuilderById(aTempBuilder->GetId());
-          }
+        if (aMode.IsEqual("elem1") || aMode.IsEqual("elem2"))
+        {
+          Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder(
+            aMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask);
+          // Color
+          const TColStd_PackedMapOfInteger& anAllElements = aMesh->GetDataSource()->GetAllElements();
+          TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllElements);
 
-          if( aMode.IsEqual("elem1") || aMode.IsEqual("elem2") )
-          {
-            Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder(
-                aMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask );
-              // Color
-            const TColStd_PackedMapOfInteger& anAllElements = aMesh->GetDataSource()->GetAllElements();
-            TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllElements );
-
-            if( aMode.IsEqual("elem1") )
-              for ( ; anIter.More(); anIter.Next() )
-              {
-                Quantity_Color aColor( (Quantity_NameOfColor)( anIter.Key() % Quantity_NOC_WHITE ) );
-                aBuilder->SetColor1( anIter.Key(), aColor );
-              }
-            else
-              for ( ; anIter.More(); anIter.Next() )
-                aBuilder->SetColor2( anIter.Key(), aColor1, aColor2 );
-
-            aMesh->AddBuilder( aBuilder, Standard_True );
-          }
+          if (aMode.IsEqual("elem1"))
+            for (; anIter.More(); anIter.Next())
+            {
+              Quantity_Color aColor((Quantity_NameOfColor)(anIter.Key() % Quantity_NOC_WHITE));
+              aBuilder->SetColor1(anIter.Key(), aColor);
+            }
+          else
+            for (; anIter.More(); anIter.Next())
+              aBuilder->SetColor2(anIter.Key(), aColor1, aColor2);
+
+          aMesh->AddBuilder(aBuilder, Standard_True);
+        }
 
 
-          if( aMode.IsEqual("nodal") )
+        if (aMode.IsEqual("nodal"))
+        {
+          Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
+            aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
+          aMesh->AddBuilder(aBuilder, Standard_True);
+
+          // Color
+          const TColStd_PackedMapOfInteger& anAllNodes =
+            aMesh->GetDataSource()->GetAllNodes();
+          TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllNodes);
+          for (; anIter.More(); anIter.Next())
           {
-            Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
-                aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask );
-            aMesh->AddBuilder( aBuilder, Standard_True );
-
-            // Color
-            const TColStd_PackedMapOfInteger& anAllNodes =
-              aMesh->GetDataSource()->GetAllNodes();
-            TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllNodes );
-            for ( ; anIter.More(); anIter.Next() )
-            {
-              Quantity_Color aColor( (Quantity_NameOfColor)(
-                anIter.Key() % Quantity_NOC_WHITE ) );
-              aBuilder->SetColor( anIter.Key(), aColor );
-            }
-            aMesh->AddBuilder( aBuilder, Standard_True );
+            Quantity_Color aColor((Quantity_NameOfColor)(
+              anIter.Key() % Quantity_NOC_WHITE));
+            aBuilder->SetColor(anIter.Key(), aColor);
           }
+          aMesh->AddBuilder(aBuilder, Standard_True);
+        }
 
-          if(aMode.IsEqual("nodaltex"))
+        if (aMode.IsEqual("nodaltex"))
+        {
+          // assign nodal builder to the mesh
+          Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
+            aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
+          aMesh->AddBuilder(aBuilder, Standard_True);
+          aBuilder->UseTexture(Standard_True);
+
+          // prepare color map for texture
+          Aspect_SequenceOfColor aColorMap;
+          aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_RED);
+          aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_YELLOW);
+          aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_BLUE1);
+
+          // prepare scale map for mesh - it will be assigned to mesh as texture coordinates
+          // make mesh color interpolated from minimum X coord to maximum X coord
+          Handle(MeshVS_DataSource) aDataSource = aMesh->GetDataSource();
+          Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ;
+
+          // get bounding box for calculations
+          aDataSource->GetBoundingBox().Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ);
+          Standard_Real aDelta = aMaxX - aMinX;
+
+          // assign color scale map values (0..1) to nodes
+          TColStd_DataMapOfIntegerReal aScaleMap;
+          TColStd_Array1OfReal aCoords(1, 3);
+          Standard_Integer     aNbNodes;
+          MeshVS_EntityType    aType;
+
+          // iterate nodes
+          const TColStd_PackedMapOfInteger& anAllNodes =
+            aMesh->GetDataSource()->GetAllNodes();
+          TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllNodes);
+          for (; anIter.More(); anIter.Next())
           {
-            // assign nodal builder to the mesh
-            Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
-                   aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
-            aMesh->AddBuilder(aBuilder, Standard_True);
-            aBuilder->UseTexture(Standard_True);
-
-            // prepare color map for texture
-            Aspect_SequenceOfColor aColorMap;
-            aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_RED);
-            aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_YELLOW);
-            aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_BLUE1);
-
-            // prepare scale map for mesh - it will be assigned to mesh as texture coordinates
-            // make mesh color interpolated from minimum X coord to maximum X coord
-            Handle(MeshVS_DataSource) aDataSource = aMesh->GetDataSource();
-            Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ;
-
-            // get bounding box for calculations
-            aDataSource->GetBoundingBox().Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ);
-            Standard_Real aDelta = aMaxX - aMinX;
-
-            // assign color scale map values (0..1) to nodes
-            TColStd_DataMapOfIntegerReal aScaleMap;
-            TColStd_Array1OfReal aCoords(1, 3);
-            Standard_Integer     aNbNodes;
-            MeshVS_EntityType    aType;
-
-            // iterate nodes
-            const TColStd_PackedMapOfInteger& anAllNodes =
-                  aMesh->GetDataSource()->GetAllNodes();
-            TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllNodes);
-            for (; anIter.More(); anIter.Next())
+            //get node coordinates to aCoord variable
+            aDataSource->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aType);
+
+            Standard_Real aScaleValue;
+            try
+            {
+              OCC_CATCH_SIGNALS
+                aScaleValue = (aCoords.Value(1) - (Standard_Real)aMinX) / aDelta;
+            }
+            catch (Standard_Failure const&)
             {
-              //get node coordinates to aCoord variable
-              aDataSource->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aType);
-
-              Standard_Real aScaleValue;
-              try {
-                OCC_CATCH_SIGNALS
-                aScaleValue = (aCoords.Value(1) - (Standard_Real) aMinX) / aDelta;
-              } catch(Standard_Failure const&) {
-                aScaleValue = 0;
-              }
-
-              aScaleMap.Bind(anIter.Key(), aScaleValue);
+              aScaleValue = 0;
             }
 
-            //set color map for builder and a color for invalid scale value
-            aBuilder->SetColorMap(aColorMap);
-            aBuilder->SetInvalidColor(Quantity_NOC_BLACK);
-            aBuilder->SetTextureCoords(aScaleMap);
-            aMesh->AddBuilder(aBuilder, Standard_True);
+            aScaleMap.Bind(anIter.Key(), aScaleValue);
           }
 
-          aMesh->GetDrawer()->SetBoolean (MeshVS_DA_ColorReflection, aReflection != 0);
-
-          anIC->Redisplay (aMesh, Standard_True);
-        }
-        else
-        {
-          di << "Wrong mode name\n";
-          return 0;
+          //set color map for builder and a color for invalid scale value
+          aBuilder->SetColorMap(aColorMap);
+          aBuilder->SetInvalidColor(Quantity_NOC_BLACK);
+          aBuilder->SetTextureCoords(aScaleMap);
+          aMesh->AddBuilder(aBuilder, Standard_True);
         }
+
+        aMesh->GetDrawer()->SetBoolean(MeshVS_DA_ColorReflection, aReflection != 0);
+
+        anIC->Redisplay(aMesh, Standard_True);
+      }
+      else
+      {
+        theDI << "Wrong mode name\n";
+        return 0;
       }
+    }
   }
-  catch ( Standard_Failure const& )
+  catch (Standard_Failure const&)
   {
-    di << "Error\n";
+    theDI << "Error\n";
   }
 
   return 0;
 }
-//-----------------------------------------------------------------------------
-static Standard_Integer meshvectors( Draw_Interpretor& di,
-                                     Standard_Integer argc,
-                                     const char** argv )
+
+//=======================================================================
+//function : meshvectors
+//purpose  :
+//=======================================================================
+static Standard_Integer meshvectors(Draw_Interpretor& theDI,
+                                    Standard_Integer theNbArgs,
+                                    const char** theArgVec)
 {
-  if ( argc < 3 )
+  if (theNbArgs < 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";
+    theDI << "Wrong number of parameters\n";
+    theDI << "Use : meshvectors <mesh name> < -mode {elem|nodal|none} > [-maxlen len] [-color name] [-arrowpart ratio] [-issimple {1|0}]\n";
+    theDI << "Supported mode values:\n";
+    theDI << "       elem  - vector per element\n";
+    theDI << "       nodal - vector per node\n";
+    theDI << "       none  - clear\n";
 
     return 0;
   }
 
-  Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
+  Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
 
-  if ( aMesh.IsNull() )
+  if (aMesh.IsNull())
   {
-    di << "Mesh not found\n";
+    theDI << "Mesh not found\n";
     return 0;
   }
   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
-  if ( anIC.IsNull() )
+  if (anIC.IsNull())
   {
-    di << "The context is null\n";
+    theDI << "The context is null\n";
     return 0;
   }
 
@@ -1834,173 +1855,183 @@ static Standard_Integer meshvectors( Draw_Interpretor& di,
   Standard_Real           anArrowPart(0.1);
   Standard_Boolean        isSimplePrs(Standard_False);
 
-  for (Standard_Integer anIdx = 2; anIdx < argc; anIdx++)
+  for (Standard_Integer anIdx = 2; anIdx < theNbArgs; anIdx++)
   {
     if (!aParam.IsEmpty())
     {
       if (aParam == "-mode")
       {
-        aMode       = argv[anIdx];
+        aMode = theArgVec[anIdx];
       }
       else if (aParam == "-maxlen")
       {
-        aMaxlen     = Draw::Atof(argv[anIdx]);
+        aMaxlen = Draw::Atof(theArgVec[anIdx]);
       }
       else if (aParam == "-color")
       {
-        if (!Quantity_Color::ColorFromName (argv[anIdx], aColor))
+        if (!Quantity_Color::ColorFromName(theArgVec[anIdx], aColor))
         {
-          Message::SendFail() << "Syntax error at " << aParam;
+          theDI << "Syntax error at " << aParam << "\n";
           return 1;
         }
       }
       else if (aParam == "-arrowpart")
       {
-        anArrowPart = Draw::Atof(argv[anIdx]);
+        anArrowPart = Draw::Atof(theArgVec[anIdx]);
       }
       else if (aParam == "-issimple")
       {
-        isSimplePrs = Draw::Atoi(argv[anIdx]) != 0;
+        isSimplePrs = Draw::Atoi(theArgVec[anIdx]) != 0;
       }
       aParam.Clear();
     }
-    else if (argv[anIdx][0] == '-')
+    else if (theArgVec[anIdx][0] == '-')
     {
-      aParam = argv[anIdx];
+      aParam = theArgVec[anIdx];
     }
   }
 
-  if( !aMode.IsEqual("elem") && !aMode.IsEqual("nodal") && !aMode.IsEqual("none") )
+  if (!aMode.IsEqual("elem") && !aMode.IsEqual("nodal") && !aMode.IsEqual("none"))
   {
-    di << "Wrong mode name\n";
+    theDI << "Wrong mode name\n";
     return 0;
   }
 
   Handle(MeshVS_PrsBuilder) aTempBuilder;
 
   aTempBuilder = aMesh->FindBuilder("MeshVS_VectorPrsBuilder");
-  if!aTempBuilder.IsNull())
+  if (!aTempBuilder.IsNull())
     aMesh->RemoveBuilderById(aTempBuilder->GetId());
 
-  if( !aMode.IsEqual("none") )
+  if (!aMode.IsEqual("none"))
   {
-    Handle(MeshVS_VectorPrsBuilder) aBuilder = new MeshVS_VectorPrsBuilder( aMesh.operator->(), 
-                                                                            aMaxlen,
-                                                                            aColor,
-                                                                            MeshVS_DMF_VectorDataPrs,
-                                                                            0,
-                                                                            -1,
-                                                                            MeshVS_BP_Vector,
-                                                                            isSimplePrs);
+    Handle(MeshVS_VectorPrsBuilder) aBuilder = new MeshVS_VectorPrsBuilder(aMesh.operator->(),
+                                                                           aMaxlen,
+                                                                           aColor,
+                                                                           MeshVS_DMF_VectorDataPrs,
+                                                                           0,
+                                                                           -1,
+                                                                           MeshVS_BP_Vector,
+                                                                           isSimplePrs);
 
     Standard_Boolean anIsElement = aMode.IsEqual("elem");
     const TColStd_PackedMapOfInteger& anAllIDs = anIsElement ? aMesh->GetDataSource()->GetAllElements() :
-                                                               aMesh->GetDataSource()->GetAllNodes();
+      aMesh->GetDataSource()->GetAllNodes();
 
     Standard_Integer aNbNodes;
     MeshVS_EntityType aEntType;
 
     TColStd_Array1OfReal aCoords(1, 3);
-    aCoords.Init (0.);
-    TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllIDs );
-    for ( ; anIter.More(); anIter.Next() )
+    aCoords.Init(0.);
+    TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllIDs);
+    for (; anIter.More(); anIter.Next())
     {
-      Standard_Boolean IsValidData = Standard_False; 
-      if (anIsElement) {
+      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
+      }
+      else
         IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
 
       gp_Vec aNorm;
-      if(IsValidData)
-      { 
+      if (IsValidData)
+      {
         aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
-        if(aNorm.Magnitude() < gp::Resolution())
+        if (aNorm.Magnitude() < gp::Resolution())
         {
-          aNorm = gp_Vec(0,0,1); //method GetGeom(...) returns coordinates of nodes
+          aNorm = gp_Vec(0, 0, 1); //method GetGeom(...) returns coordinates of nodes
         }
       }
       else
       {
-        aNorm = gp_Vec(0,0,1);
+        aNorm = gp_Vec(0, 0, 1);
       }
       aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized());
     }
 
-    aMesh->AddBuilder( aBuilder, Standard_False );
-    aMesh->GetDrawer()->SetDouble ( MeshVS_DA_VectorArrowPart, anArrowPart );
+    aMesh->AddBuilder(aBuilder, Standard_False);
+    aMesh->GetDrawer()->SetDouble(MeshVS_DA_VectorArrowPart, anArrowPart);
   }
 
-  anIC->Redisplay (aMesh, Standard_True);
+  anIC->Redisplay(aMesh, Standard_True);
 
   return 0;
 }
-//-----------------------------------------------------------------------------
 
-static Standard_Integer meshtext( Draw_Interpretor& di,
-                                  Standard_Integer argc,
-                                  const char** argv )
+//=======================================================================
+//function : meshtext
+//purpose  :
+//=======================================================================
+static Standard_Integer meshtext(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if ( argc < 2 )
+  if (theNbArgs < 2)
   {
-    di << "Wrong number of parameters\n";
-    di << "Use : meshtext <mesh name>\n";
+    theDI << "Wrong number of parameters\n";
+    theDI << "Use : meshtext <mesh name>\n";
     return 0;
   }
 
-  Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
+  Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
 
-  if ( aMesh.IsNull() )
+  if (aMesh.IsNull())
   {
-    di << "Mesh not found\n";
+    theDI << "Mesh not found\n";
     return 0;
   }
 
   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
-  if ( anIC.IsNull() )
+  if (anIC.IsNull())
   {
-    di << "The context is null\n";
+    theDI << "The context is null\n";
     return 0;
   }
 
   // Prepare triangle labels
   MeshVS_DataMapOfIntegerAsciiString aLabels;
   Standard_Integer aLen = aMesh->GetDataSource()->GetAllElements().Extent();
-  for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ ){
-    aLabels.Bind( anIndex, TCollection_AsciiString( anIndex ) );
+  for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++)
+  {
+    aLabels.Bind(anIndex, TCollection_AsciiString(anIndex));
   }
 
-  Handle(MeshVS_TextPrsBuilder) aTextBuilder = new MeshVS_TextPrsBuilder( aMesh.operator->(), 20., Quantity_NOC_YELLOW );
-  aTextBuilder->SetTexts( Standard_True, aLabels );
-  aMesh->AddBuilder( aTextBuilder );
+  Handle(MeshVS_TextPrsBuilder) aTextBuilder = new MeshVS_TextPrsBuilder(aMesh.operator->(), 20., Quantity_NOC_YELLOW);
+  aTextBuilder->SetTexts(Standard_True, aLabels);
+  aMesh->AddBuilder(aTextBuilder);
 
   return 0;
 }
 
-static Standard_Integer meshdeform( Draw_Interpretor& di,
-                                    Standard_Integer argc,
-                                    const char** argv )
+//=======================================================================
+//function : meshdeform
+//purpose  :
+//=======================================================================
+static Standard_Integer meshdeform(Draw_Interpretor& theDI,
+                                   Standard_Integer theNbArgs,
+                                   const char** theArgVec)
 {
-  if ( argc < 3 )
+  if (theNbArgs < 3)
   {
-    di << "Wrong number of parameters\n";
-    di << "Use : meshdeform <mesh name> < -mode {on|off} > [-scale scalefactor]\n";
+    theDI << "Wrong number of parameters\n";
+    theDI << "Use : meshdeform <mesh name> < -mode {on|off} > [-scale scalefactor]\n";
     return 0;
   }
 
-  Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
+  Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
 
-  if ( aMesh.IsNull() )
+  if (aMesh.IsNull())
   {
-    di << "Mesh not found\n";
+    theDI << "Mesh not found\n";
     return 0;
   }
   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
-  if ( anIC.IsNull() )
+  if (anIC.IsNull())
   {
-    di << "The context is null\n";
+    theDI << "The context is null\n";
     return 0;
   }
 
@@ -2008,134 +2039,140 @@ static Standard_Integer meshdeform( Draw_Interpretor& di,
   TCollection_AsciiString aMode("off");
   Standard_Real           aScale(1.0);
 
-  for (Standard_Integer anIdx = 2; anIdx < argc; anIdx++)
+  for (Standard_Integer anIdx = 2; anIdx < theNbArgs; anIdx++)
   {
     if (!aParam.IsEmpty())
     {
       if (aParam == "-mode")
       {
-        aMode = argv[anIdx];
+        aMode = theArgVec[anIdx];
       }
       else if (aParam == "-scale")
       {
-        aScale = Draw::Atof(argv[anIdx]);
+        aScale = Draw::Atof(theArgVec[anIdx]);
       }
       aParam.Clear();
     }
-    else if (argv[anIdx][0] == '-')
+    else if (theArgVec[anIdx][0] == '-')
     {
-      aParam = argv[anIdx];
+      aParam = theArgVec[anIdx];
     }
   }
 
-  if(!aMode.IsEqual("on") && !aMode.IsEqual("off"))
+  if (!aMode.IsEqual("on") && !aMode.IsEqual("off"))
   {
-    di << "Wrong mode name\n";
+    theDI << "Wrong mode name\n";
     return 0;
   }
 
-  Handle ( MeshVS_DeformedDataSource ) aDefDS =
-    new MeshVS_DeformedDataSource( aMesh->GetDataSource() , aScale );
+  Handle(MeshVS_DeformedDataSource) aDefDS =
+    new MeshVS_DeformedDataSource(aMesh->GetDataSource(), aScale);
 
   const TColStd_PackedMapOfInteger& anAllIDs = aMesh->GetDataSource()->GetAllNodes();
 
   Standard_Integer aNbNodes;
   MeshVS_EntityType aEntType;
 
-  TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllIDs );
-  for ( ; anIter.More(); anIter.Next() )
+  TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllIDs);
+  for (; anIter.More(); anIter.Next())
   {
     TColStd_Array1OfReal aCoords(1, 3);
     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);
+    if (!aNorm.Magnitude())
+      aNorm = gp_Vec(0, 0, 1);
     aDefDS->SetVector(anIter.Key(), aNorm.Normalized());
   }
 
   aMesh->SetDataSource(aDefDS);
 
-  anIC->Redisplay (aMesh, Standard_False);
+  anIC->Redisplay(aMesh, Standard_False);
 
-  Handle( V3d_View ) aView = ViewerTest::CurrentView();
-  if ( !aView.IsNull() )
+  Handle(V3d_View) aView = ViewerTest::CurrentView();
+  if (!aView.IsNull())
     aView->FitAll();
 
   return 0;
 }
 
-static Standard_Integer mesh_edge_width( Draw_Interpretor& di,
-                                        Standard_Integer argc,
-                                        const char** argv )
+//=======================================================================
+//function : mesh_edge_width
+//purpose  :
+//=======================================================================
+static Standard_Integer mesh_edge_width(Draw_Interpretor& theDI,
+                                        Standard_Integer theNbArgs,
+                                        const char** theArgVec)
 {
   try
   {
     OCC_CATCH_SIGNALS
-      if ( argc < 3 )
+      if (theNbArgs < 3)
       {
-        di << "Wrong number of parameters\n";
-        di << "Use : mesh_edge_width <mesh name> <width>\n";
+        theDI << "Wrong number of parameters\n";
+        theDI << "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";
-        return 0;
-      }
+    Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+    if (aMesh.IsNull())
+    {
+      theDI << "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";
-        return 0;
-      }
+    const char* aWidthStr = theArgVec[2];
+    if (aWidthStr == 0 || Draw::Atof(aWidthStr) <= 0)
+    {
+      theDI << "Width must be real value more than zero\n";
+      return 0;
+    }
 
-      double aWidth = Draw::Atof( aWidthStr );
+    double aWidth = Draw::Atof(aWidthStr);
 
-      Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
-      if ( anIC.IsNull() )
-      {
-        di << "The context is null\n";
-        return 0;
-      }
+    Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
+    if (anIC.IsNull())
+    {
+      theDI << "The context is null\n";
+      return 0;
+    }
 
-      Handle(MeshVS_Drawer) aDrawer = aMesh->GetDrawer();
-      if ( aDrawer.IsNull() )
-      {
-        di << "The drawer is null\n";
-        return 0;
-      }
+    Handle(MeshVS_Drawer) aDrawer = aMesh->GetDrawer();
+    if (aDrawer.IsNull())
+    {
+      theDI << "The drawer is null\n";
+      return 0;
+    }
 
-      aDrawer->SetDouble( MeshVS_DA_EdgeWidth, aWidth );
-      anIC->Redisplay (aMesh, Standard_True);
+    aDrawer->SetDouble(MeshVS_DA_EdgeWidth, aWidth);
+    anIC->Redisplay(aMesh, Standard_True);
   }
-  catch ( Standard_Failure const& )
+  catch (Standard_Failure const&)
   {
-    di << "Error\n";
+    theDI << "Error\n";
   }
 
   return 0;
 }
 
-//-----------------------------------------------------------------------------
-
-static Standard_Integer meshinfo(Draw_Interpretor& di,
-                                 Standard_Integer argc,
-                                 const char** argv)
+//=======================================================================
+//function : meshinfo
+//purpose  :
+//=======================================================================
+static Standard_Integer meshinfo(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
-  if ( argc != 2 )
+  if (theNbArgs != 2)
   {
-    di << "Wrong number of parameters. Use : meshinfo mesh\n";
+    theDI << "Wrong number of parameters. Use : meshinfo mesh\n";
     return 0;
   }
 
-  Handle(MeshVS_Mesh) aMesh = getMesh(argv[ 1 ], di);
-  if ( aMesh.IsNull() )
+  Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+  if (aMesh.IsNull())
   {
-    di << "Mesh not found\n";
+    theDI << "Mesh not found\n";
     return 0;
   }
 
@@ -2143,10 +2180,10 @@ static Standard_Integer meshinfo(Draw_Interpretor& di,
   if (!stlMeshSource.IsNull())
   {
     const TColStd_PackedMapOfInteger& nodes = stlMeshSource->GetAllNodes();
-    const TColStd_PackedMapOfInteger& tris  = stlMeshSource->GetAllElements();
+    const TColStd_PackedMapOfInteger& tris = stlMeshSource->GetAllElements();
 
-    di << "Nb nodes = " << nodes.Extent() << "\n";
-    di << "Nb triangles = " << tris.Extent() << "\n";
+    theDI << "Nb nodes = " << nodes.Extent() << "\n";
+    theDI << "Nb triangles = " << tris.Extent() << "\n";
   }
 
   return 0;
@@ -2156,115 +2193,126 @@ static Standard_Integer meshinfo(Draw_Interpretor& di,
 //function : writeply
 //purpose  : write PLY file
 //=======================================================================
-static Standard_Integer WritePly (Draw_Interpretor& theDI,
-                                  Standard_Integer theNbArgs,
-                                  const char** theArgVec)
+static Standard_Integer WritePly(Draw_Interpretor& theDI,
+                                 Standard_Integer theNbArgs,
+                                 const char** theArgVec)
 {
   Handle(TDocStd_Document) aDoc;
   Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
   TCollection_AsciiString aShapeName, aFileName;
-
+  Handle(RWPly_ConfigurationNode) aNode = new RWPly_ConfigurationNode();
   Standard_Real aDist = 0.0;
   Standard_Real aDens = Precision::Infinite();
-  Standard_Real aTol  = Precision::Confusion();
-  bool hasColors = true, hasNormals = true, hasTexCoords = false, hasPartId = true, hasFaceId = false;
+  Standard_Real aTol = Precision::Confusion();
+  //bool hasColors = true, hasNormals = true, hasTexCoords = false, hasPartId = true, hasFaceId = false;
+  //TColStd_IndexedDataMapOfStringString aFileInfo;
   bool isPntSet = false, isDensityPoints = false;
-  TColStd_IndexedDataMapOfStringString aFileInfo;
   for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
   {
-    TCollection_AsciiString anArg (theArgVec[anArgIter]);
+    TCollection_AsciiString anArg(theArgVec[anArgIter]);
     anArg.LowerCase();
     if (anArg == "-normal")
     {
-      hasNormals = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WriteNormals =
+        Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArg == "-nonormal")
     {
-      hasNormals = !Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WriteNormals =
+        !Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArg == "-color"
-          || anArg == "-nocolor"
-          || anArg == "-colors"
-          || anArg == "-nocolors")
+             || anArg == "-nocolor"
+             || anArg == "-colors"
+             || anArg == "-nocolors")
     {
-      hasColors = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WriteColors =
+        Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArg == "-uv"
-          || anArg == "-nouv")
+             || anArg == "-nouv")
     {
-      hasTexCoords = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WriteTexCoords =
+        Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if (anArg == "-partid")
     {
-      hasPartId = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
-      hasFaceId = hasFaceId && !hasPartId;
+      aNode->InternalParameters.WritePartId =
+        Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WriteFaceId =
+        aNode->InternalParameters.WriteFaceId &&
+        !aNode->InternalParameters.WritePartId;
     }
     else if (anArg == "-surfid"
-          || anArg == "-surfaceid"
-          || anArg == "-faceid")
+             || anArg == "-surfaceid"
+             || anArg == "-faceid")
     {
-      hasFaceId = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
-      hasPartId = hasPartId && !hasFaceId;
+      aNode->InternalParameters.WriteFaceId =
+        Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter);
+      aNode->InternalParameters.WritePartId =
+        aNode->InternalParameters.WritePartId &&
+        !aNode->InternalParameters.WriteFaceId;
     }
     else if (anArg == "-pntset"
-          || anArg == "-pntcloud"
-          || anArg == "-pointset"
-          || anArg == "-pointcloud"
-          || anArg == "-cloud"
-          || anArg == "-points")
+             || anArg == "-pntcloud"
+             || anArg == "-pointset"
+             || anArg == "-pointcloud"
+             || anArg == "-cloud"
+             || anArg == "-points")
     {
-      isPntSet = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+      isPntSet = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
     }
     else if ((anArg == "-dist"
-           || anArg == "-distance")
-          && anArgIter + 1 < theNbArgs
-          && Draw::ParseReal (theArgVec[anArgIter + 1], aDist))
+             || anArg == "-distance")
+             && anArgIter + 1 < theNbArgs
+             && Draw::ParseReal(theArgVec[anArgIter + 1], aDist))
     {
       ++anArgIter;
       isPntSet = true;
       if (aDist < 0.0)
       {
-        theDI << "Syntax error: -distance value should be >= 0.0";
+        theDI << "Syntax error: -distance value should be >= 0.0\n";
         return 1;
       }
-      aDist = Max (aDist, Precision::Confusion());
+      aDist = Max(aDist, Precision::Confusion());
     }
     else if ((anArg == "-dens"
-           || anArg == "-density")
-          && anArgIter + 1 < theNbArgs
-          && Draw::ParseReal (theArgVec[anArgIter + 1], aDens))
+             || anArg == "-density")
+             && anArgIter + 1 < theNbArgs
+             && Draw::ParseReal(theArgVec[anArgIter + 1], aDens))
     {
       ++anArgIter;
       isDensityPoints = Standard_True;
       isPntSet = true;
       if (aDens <= 0.0)
       {
-        theDI << "Syntax error: -density value should be > 0.0";
+        theDI << "Syntax error: -density value should be > 0.0\n";
         return 1;
       }
     }
     else if ((anArg == "-tol"
-           || anArg == "-tolerance")
-          && anArgIter + 1 < theNbArgs
-          && Draw::ParseReal (theArgVec[anArgIter + 1], aTol))
+             || anArg == "-tolerance")
+             && anArgIter + 1 < theNbArgs
+             && Draw::ParseReal(theArgVec[anArgIter + 1], aTol))
     {
       ++anArgIter;
       isPntSet = true;
       if (aTol < Precision::Confusion())
       {
-        theDI << "Syntax error: -tol value should be >= " << Precision::Confusion();
+        theDI << "Syntax error: -tol value should be >= "
+          << Precision::Confusion() << "\n";
         return 1;
       }
     }
     else if (anArg == "-comments"
-          && anArgIter + 1 < theNbArgs)
+             && anArgIter + 1 < theNbArgs)
     {
-      aFileInfo.Add ("Comments", theArgVec[++anArgIter]);
+      aNode->InternalParameters.WriteComment = theArgVec[++anArgIter];
     }
     else if (anArg == "-author"
-          && anArgIter + 1 < theNbArgs)
+             && anArgIter + 1 < theNbArgs)
     {
-      aFileInfo.Add ("Author", theArgVec[++anArgIter]);
+      aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter];
     }
     else if (aDoc.IsNull())
     {
@@ -2274,15 +2322,15 @@ static Standard_Integer WritePly (Draw_Interpretor& theDI,
       }
 
       Standard_CString aNameVar = theArgVec[anArgIter];
-      DDocStd::GetDocument (aNameVar, aDoc, false);
+      DDocStd::GetDocument(aNameVar, aDoc, false);
       if (aDoc.IsNull())
       {
-        TopoDS_Shape aShape = DBRep::Get (aNameVar);
+        TopoDS_Shape aShape = DBRep::Get(aNameVar);
         if (!aShape.IsNull())
         {
-          anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
-          Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
-          aShapeTool->AddShape (aShape);
+          anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
+          Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
+          aShapeTool->AddShape(aShape);
         }
       }
     }
@@ -2292,256 +2340,263 @@ static Standard_Integer WritePly (Draw_Interpretor& theDI,
     }
     else
     {
-      theDI << "Syntax error at '" << theArgVec[anArgIter] << "'";
+      theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
       return 1;
     }
   }
   if (aDoc.IsNull()
-  && !aShapeName.IsEmpty())
+      && !aShapeName.IsEmpty())
   {
-    theDI << "Syntax error: '" << aShapeName << "' is not a shape nor document";
+    theDI << "Syntax error: '" << aShapeName << "' is not a shape nor document\n";
     return 1;
   }
   else if (aDoc.IsNull()
-        || aFileName.IsEmpty())
+           || aFileName.IsEmpty())
   {
-    theDI << "Syntax error: wrong number of arguments";
-    return 1;
-  }
-
-  TDF_LabelSequence aRootLabels;
-  Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
-  aShapeTool->GetFreeShapes (aRootLabels);
-  if (aRootLabels.IsEmpty())
-  {
-    theDI << "Error: empty document";
+    theDI << "Syntax error: wrong number of arguments\n";
     return 1;
   }
+  aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
 
   if (isPntSet)
   {
+    TDF_LabelSequence aRootLabels;
+    Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
+    aShapeTool->GetFreeShapes(aRootLabels);
+    if (aRootLabels.IsEmpty())
+    {
+      theDI << "Error: empty document\n";
+      return 1;
+    }
     class PointCloudPlyWriter : public BRepLib_PointCloudShape, public RWPly_PlyWriterContext
     {
     public:
-      PointCloudPlyWriter (Standard_Real theTol)
-      : BRepLib_PointCloudShape (TopoDS_Shape(), theTol) {}
+      PointCloudPlyWriter(Standard_Real theTol)
+        : BRepLib_PointCloudShape(TopoDS_Shape(), theTol)
+      {}
 
-      void AddFaceColor (const TopoDS_Shape& theFace, const Graphic3d_Vec4ub& theColor)
-      { myFaceColor.Bind (theFace, theColor); }
+      void AddFaceColor(const TopoDS_Shape& theFace, const Graphic3d_Vec4ub& theColor)
+      {
+        myFaceColor.Bind(theFace, theColor);
+      }
 
     protected:
-      virtual void addPoint (const gp_Pnt& thePoint,
-                             const gp_Vec& theNorm,
-                             const gp_Pnt2d& theUV,
-                             const TopoDS_Shape& theFace)
+      virtual void addPoint(const gp_Pnt& thePoint,
+                            const gp_Vec& theNorm,
+                            const gp_Pnt2d& theUV,
+                            const TopoDS_Shape& theFace)
       {
         Graphic3d_Vec4ub aColor;
-        myFaceColor.Find (theFace, aColor);
-        RWPly_PlyWriterContext::WriteVertex (thePoint,
-                                             Graphic3d_Vec3 ((float )theNorm.X(), (float )theNorm.Y(), (float )theNorm.Z()),
-                                             Graphic3d_Vec2 ((float )theUV.X(), (float )theUV.Y()),
-                                             aColor);
+        myFaceColor.Find(theFace, aColor);
+        RWPly_PlyWriterContext::WriteVertex(thePoint,
+                                            Graphic3d_Vec3((float)theNorm.X(), (float)theNorm.Y(), (float)theNorm.Z()),
+                                            Graphic3d_Vec2((float)theUV.X(), (float)theUV.Y()),
+                                            aColor);
       }
 
     private:
       NCollection_DataMap<TopoDS_Shape, Graphic3d_Vec4ub> myFaceColor;
     };
 
-    PointCloudPlyWriter aPlyCtx (aTol);
-    aPlyCtx.SetNormals (hasNormals);
-    aPlyCtx.SetColors (hasColors);
-    aPlyCtx.SetTexCoords (hasTexCoords);
+    PointCloudPlyWriter aPlyCtx(aTol);
+    aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals);
+    aPlyCtx.SetColors(aNode->InternalParameters.WriteColors);
+    aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords);
 
     TopoDS_Compound aComp;
-    BRep_Builder().MakeCompound (aComp);
-    for (XCAFPrs_DocumentExplorer aDocExplorer (aDoc, aRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes);
+    BRep_Builder().MakeCompound(aComp);
+    for (XCAFPrs_DocumentExplorer aDocExplorer(aDoc, aRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes);
          aDocExplorer.More(); aDocExplorer.Next())
     {
       const XCAFPrs_DocumentNode& aDocNode = aDocExplorer.Current();
-      for (RWMesh_FaceIterator aFaceIter (aDocNode.RefLabel, aDocNode.Location, true, aDocNode.Style); aFaceIter.More(); aFaceIter.Next())
+      for (RWMesh_FaceIterator aFaceIter(aDocNode.RefLabel, aDocNode.Location, true, aDocNode.Style); aFaceIter.More(); aFaceIter.Next())
       {
-        BRep_Builder().Add (aComp, aFaceIter.Face());
-        Graphic3d_Vec4ub aColorVec (255);
+        BRep_Builder().Add(aComp, aFaceIter.Face());
+        Graphic3d_Vec4ub aColorVec(255);
         if (aFaceIter.HasFaceColor())
         {
           Graphic3d_Vec4 aColorF = aFaceIter.FaceColor();
-          aColorVec.SetValues ((unsigned char )int(aColorF.r() * 255.0f),
-                               (unsigned char )int(aColorF.g() * 255.0f),
-                               (unsigned char )int(aColorF.b() * 255.0f),
-                               (unsigned char )int(aColorF.a() * 255.0f));
+          aColorVec.SetValues((unsigned char)int(aColorF.r() * 255.0f),
+                              (unsigned char)int(aColorF.g() * 255.0f),
+                              (unsigned char)int(aColorF.b() * 255.0f),
+                              (unsigned char)int(aColorF.a() * 255.0f));
         }
-        aPlyCtx.AddFaceColor (aFaceIter.Face(), aColorVec);
+        aPlyCtx.AddFaceColor(aFaceIter.Face(), aColorVec);
       }
     }
-    aPlyCtx.SetShape (aComp);
+    aPlyCtx.SetShape(aComp);
 
     Standard_Integer aNbPoints = isDensityPoints
-                               ? aPlyCtx.NbPointsByDensity (aDens)
-                               : aPlyCtx.NbPointsByTriangulation();
+      ? aPlyCtx.NbPointsByDensity(aDens)
+      : aPlyCtx.NbPointsByTriangulation();
     if (aNbPoints <= 0)
     {
-      theDI << "Error: unable to generate points";
-      return 0;
+      theDI << "Error: unable to generate points\n";
+      return 1;
     }
 
-    if (!aPlyCtx.Open (aFileName)
-     || !aPlyCtx.WriteHeader (aNbPoints, 0, TColStd_IndexedDataMapOfStringString()))
+    if (!aPlyCtx.Open(aFileName)
+        || !aPlyCtx.WriteHeader(aNbPoints, 0, TColStd_IndexedDataMapOfStringString()))
     {
-      theDI << "Error: unable to create file '" << aFileName << "'";
-      return 0;
+      theDI << "Error: unable to create file '" << aFileName << "'\n";
+      return 1;
     }
 
     Standard_Boolean isDone = isDensityPoints
-                            ? aPlyCtx.GeneratePointsByDensity (aDens)
-                            : aPlyCtx.GeneratePointsByTriangulation();
+      ? aPlyCtx.GeneratePointsByDensity(aDens)
+      : aPlyCtx.GeneratePointsByTriangulation();
     if (!isDone)
     {
-      theDI << "Error: Point cloud was not generated in file '" << aFileName << "'";
+      theDI << "Error: Point cloud was not generated in file '" << aFileName << "'\n";
+      return 1;
     }
     else if (!aPlyCtx.Close())
     {
-      theDI << "Error: Point cloud file '" << aFileName << "' was not written";
+      theDI << "Error: Point cloud file '" << aFileName << "' was not written\n";
+      return 1;
     }
     else
     {
-      theDI << aNbPoints;
+      theDI << aNbPoints << "\n";
     }
   }
   else
   {
-    Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
-    RWPly_CafWriter aPlyCtx (aFileName);
-    aPlyCtx.SetNormals (hasNormals);
-    aPlyCtx.SetColors (hasColors);
-    aPlyCtx.SetTexCoords (hasTexCoords);
-    aPlyCtx.SetPartId (hasPartId);
-    aPlyCtx.SetFaceId (hasFaceId);
-    aPlyCtx.Perform (aDoc, aFileInfo, aProgress->Start());
+    Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+    Handle(RWPly_Provider) aProvider = new RWPly_Provider(aNode);
+    Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+    if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start()))
+    {
+      theDI << "Error: file writing failed '" << theArgVec[2] << "'\n";
+      return 1;
+    }
   }
   return 0;
 }
 
-//-----------------------------------------------------------------------------
-
-void  XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
+//=======================================================================
+//function : InitCommands
+//purpose  :
+//=======================================================================
+void XSDRAWSTLVRML::InitCommands(Draw_Interpretor& theCommands)
 {
   const char* g = "XSTEP-STL/VRML";  // Step transfer file commands
   //XSDRAW::LoadDraw(theCommands);
 
-  theCommands.Add ("ReadGltf",
-                   "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]"
-                   "\n\t\t: Read glTF file into XDE document."
-                   "\n\t\t:   -listExternalFiles do not read mesh and only list external files"
-                   "\n\t\t:   -noCreateDoc read into existing XDE document"
-                   "\n\t\t:   -doublePrecision store triangulation with double or single floating point"
-                   "\n\t\t:                    precision (single by default)"
-                   "\n\t\t:   -skipLateLoading data loading is skipped and can be performed later"
-                   "\n\t\t:                    (false by default)"
-                   "\n\t\t:   -keepLate data is loaded into itself with preservation of information"
-                   "\n\t\t:             about deferred storage to load/unload this data later."
-                   "\n\t\t:   -allScenes load all scenes defined in the document instead of default one (false by default)"
-                   "\n\t\t:   -toPrintDebugInfo print additional debug information during data reading"
-                   "\n\t\t:   -assetInfo print asset information",
-                   __FILE__, ReadGltf, g);
-  theCommands.Add ("readgltf",
-                   "readgltf shape file"
-                   "\n\t\t: Same as ReadGltf but reads glTF file into a shape instead of a document.",
-                   __FILE__, ReadGltf, g);
-  theCommands.Add ("WriteGltf",
-                   "WriteGltf Doc file [-trsfFormat {compact|TRS|mat4}]=compact"
-                   "\n\t\t:            [-systemCoordSys {Zup|Yup}]=Zup"
-                   "\n\t\t:            [-comments Text] [-author Name]"
-                   "\n\t\t:            [-forceUVExport]=0 [-texturesSeparate]=0 [-mergeFaces]=0 [-splitIndices16]=0"
-                   "\n\t\t:            [-nodeNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=instOrProd"
-                   "\n\t\t:            [-meshNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=product"
-                   "\n\t\t:            [-draco]=0 [-compressionLevel {0-10}]=7 [-quantizePositionBits Value]=14 [-quantizeNormalBits Value]=10"
-                   "\n\t\t:            [-quantizeTexcoordBits Value]=12 [-quantizeColorBits Value]=8 [-quantizeGenericBits Value]=12"
-                   "\n\t\t:            [-unifiedQuantization]=0 [-parallel]=0"
-                   "\n\t\t: Write XDE document into glTF file."
-                   "\n\t\t:   -trsfFormat       preferred transformation format"
-                   "\n\t\t:   -systemCoordSys   system coordinate system; Zup when not specified"
-                   "\n\t\t:   -mergeFaces       merge Faces within the same Mesh"
-                   "\n\t\t:   -splitIndices16   split Faces to keep 16-bit indices when -mergeFaces is enabled"
-                   "\n\t\t:   -forceUVExport    always export UV coordinates"
-                   "\n\t\t:   -texturesSeparate write textures to separate files"
-                   "\n\t\t:   -nodeNameFormat   name format for Nodes"
-                   "\n\t\t:   -meshNameFormat   name format for Meshes"
-                   "\n\t\t:   -draco            use Draco compression 3D geometric meshes"
-                   "\n\t\t:   -compressionLevel draco compression level [0-10] (by default 7), a value of 0 will apply sequential encoding and preserve face order"
-                   "\n\t\t:   -quantizePositionBits quantization bits for position attribute when using Draco compression (by default 14)"
-                   "\n\t\t:   -quantizeNormalBits   quantization bits for normal attribute when using Draco compression (by default 10)"
-                   "\n\t\t:   -quantizeTexcoordBits quantization bits for texture coordinate attribute when using Draco compression (by default 12)"
-                   "\n\t\t:   -quantizeColorBits    quantization bits for color attribute when using Draco compression (by default 8)"
-                   "\n\t\t:   -quantizeGenericBits  quantization bits for skinning attribute (joint indices and joint weights)"
-                   "\n                        and custom attributes when using Draco compression (by default 12)"
-                   "\n\t\t:   -unifiedQuantization  quantization is applied on each primitive separately if this option is false"
-                   "\n\t\t:   -parallel             use multithreading for Draco compression",
-                   __FILE__, WriteGltf, g);
-  theCommands.Add ("writegltf",
-                   "writegltf shape file",
-                   __FILE__, WriteGltf, g);
-  theCommands.Add ("writevrml", "shape file [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 1 by default]",__FILE__,writevrml,g);
-  theCommands.Add ("writestl",  "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]",__FILE__,writestl,g);
-  theCommands.Add ("readstl",
-                   "readstl shape file [-brep] [-mergeAngle Angle] [-multi]"
-                   "\n\t\t: Reads STL file and creates a new shape with specified name."
-                   "\n\t\t: When -brep is specified, creates a Compound of per-triangle Faces."
-                   "\n\t\t: Single triangulation-only Face is created otherwise (default)."
-                   "\n\t\t: -mergeAngle specifies maximum angle in degrees between triangles to merge equal nodes; disabled by default."
-                   "\n\t\t: -multi creates a face per solid in multi-domain files; ignored when -brep is set.",
-                   __FILE__, readstl, g);
-  theCommands.Add ("loadvrml" , "shape file",__FILE__,loadvrml,g);
-  theCommands.Add ("ReadObj",
-                   "ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
-           "\n\t\t:                  [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
-           "\n\t\t:                  [-listExternalFiles] [-noCreateDoc]"
-           "\n\t\t: Read OBJ file into XDE document."
-           "\n\t\t:   -fileUnit       length unit of OBJ file content;"
-           "\n\t\t:   -fileCoordSys   coordinate system defined by OBJ file; Yup when not specified."
-           "\n\t\t:   -resultCoordSys result coordinate system; Zup when not specified."
-           "\n\t\t:   -singlePrecision truncate vertex data to single precision during read; FALSE by default."
-           "\n\t\t:   -listExternalFiles do not read mesh and only list external files."
-           "\n\t\t:   -noCreateDoc    read into existing XDE document.",
-                   __FILE__, ReadObj, g);
-  theCommands.Add ("readobj",
-                   "readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
-           "\n\t\t:                    [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
-           "\n\t\t:                    [-singleFace]"
-           "\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document."
-           "\n\t\t:   -singleFace merge OBJ content into a single triangulation Face.",
-           __FILE__, ReadObj, g);
-  theCommands.Add ("WriteObj",
-                   "WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
-           "\n\t\t:                   [-systemCoordSys {Zup|Yup}]"
-           "\n\t\t:                   [-comments Text] [-author Name]"
-           "\n\t\t: Write XDE document into OBJ file."
-           "\n\t\t:   -fileUnit       length unit of OBJ file content;"
-           "\n\t\t:   -fileCoordSys   coordinate system defined by OBJ file; Yup when not specified."
-           "\n\t\t:   -systemCoordSys system coordinate system; Zup when not specified.",
-                   __FILE__, WriteObj, g);
-  theCommands.Add ("writeobj",
-                   "writeobj shape file",
-                   __FILE__, WriteObj, g);
-
-  theCommands.Add ("meshfromstl",     "creates MeshVS_Mesh from STL file",            __FILE__, createmesh,      g );
-  theCommands.Add ("mesh3delem",      "creates 3d element mesh to test",              __FILE__, create3d,        g );
-  theCommands.Add ("meshshadcolor",   "change MeshVS_Mesh shading color",             __FILE__, meshcolor,       g );
-  theCommands.Add ("meshlinkcolor",   "change MeshVS_Mesh line color",                __FILE__, linecolor,       g );
-  theCommands.Add ("meshmat",         "change MeshVS_Mesh material and transparency", __FILE__, meshmat,         g );
-  theCommands.Add ("meshshrcoef",     "change MeshVS_Mesh shrink coeff",              __FILE__, shrink,          g );
-  theCommands.Add ("meshclosed",      "meshclosed meshname (0/1) \nChange MeshVS_Mesh drawing mode. 0 - not closed object, 1 - closed object", __FILE__, closed, g);
-  theCommands.Add ("meshshow",        "display MeshVS_Mesh object",                   __FILE__, mdisplay,        g );
-  theCommands.Add ("meshhide",        "erase MeshVS_Mesh object",                     __FILE__, merase,          g );
-  theCommands.Add ("meshhidesel",     "hide selected entities",                       __FILE__, hidesel,         g );
-  theCommands.Add ("meshshowsel",     "show only selected entities",                  __FILE__, showonly,        g );
-  theCommands.Add ("meshshowall",     "show all entities",                            __FILE__, showall,         g );
-  theCommands.Add ("meshcolors",      "display color presentation",                   __FILE__, meshcolors,      g );
-  theCommands.Add ("meshvectors",     "display sample vectors",                       __FILE__, meshvectors,     g );
-  theCommands.Add ("meshtext",        "display text labels",                          __FILE__, meshtext,        g );
-  theCommands.Add ("meshdeform",      "display deformed mesh",                        __FILE__, meshdeform,      g );
-  theCommands.Add ("mesh_edge_width", "set width of edges",                           __FILE__, mesh_edge_width, g );
-  theCommands.Add ("meshinfo",        "displays the number of nodes and triangles",   __FILE__, meshinfo,        g );
-  theCommands.Add ("WritePly", R"(
+  theCommands.Add("ReadGltf",
+                  "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]"
+                  "\n\t\t: Read glTF file into XDE document."
+                  "\n\t\t:   -listExternalFiles do not read mesh and only list external files"
+                  "\n\t\t:   -noCreateDoc read into existing XDE document"
+                  "\n\t\t:   -doublePrecision store triangulation with double or single floating point"
+                  "\n\t\t:                    precision (single by default)"
+                  "\n\t\t:   -skipLateLoading data loading is skipped and can be performed later"
+                  "\n\t\t:                    (false by default)"
+                  "\n\t\t:   -keepLate data is loaded into itself with preservation of information"
+                  "\n\t\t:             about deferred storage to load/unload this data later."
+                  "\n\t\t:   -allScenes load all scenes defined in the document instead of default one (false by default)"
+                  "\n\t\t:   -toPrintDebugInfo print additional debug information during data reading"
+                  "\n\t\t:   -assetInfo print asset information",
+                  __FILE__, ReadGltf, g);
+  theCommands.Add("readgltf",
+                  "readgltf shape file"
+                  "\n\t\t: Same as ReadGltf but reads glTF file into a shape instead of a document.",
+                  __FILE__, ReadGltf, g);
+  theCommands.Add("WriteGltf",
+                  "WriteGltf Doc file [-trsfFormat {compact|TRS|mat4}]=compact"
+                  "\n\t\t:            [-systemCoordSys {Zup|Yup}]=Zup"
+                  "\n\t\t:            [-comments Text] [-author Name]"
+                  "\n\t\t:            [-forceUVExport]=0 [-texturesSeparate]=0 [-mergeFaces]=0 [-splitIndices16]=0"
+                  "\n\t\t:            [-nodeNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=instOrProd"
+                  "\n\t\t:            [-meshNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=product"
+                  "\n\t\t:            [-draco]=0 [-compressionLevel {0-10}]=7 [-quantizePositionBits Value]=14 [-quantizeNormalBits Value]=10"
+                  "\n\t\t:            [-quantizeTexcoordBits Value]=12 [-quantizeColorBits Value]=8 [-quantizeGenericBits Value]=12"
+                  "\n\t\t:            [-unifiedQuantization]=0 [-parallel]=0"
+                  "\n\t\t: Write XDE document into glTF file."
+                  "\n\t\t:   -trsfFormat       preferred transformation format"
+                  "\n\t\t:   -systemCoordSys   system coordinate system; Zup when not specified"
+                  "\n\t\t:   -mergeFaces       merge Faces within the same Mesh"
+                  "\n\t\t:   -splitIndices16   split Faces to keep 16-bit indices when -mergeFaces is enabled"
+                  "\n\t\t:   -forceUVExport    always export UV coordinates"
+                  "\n\t\t:   -texturesSeparate write textures to separate files"
+                  "\n\t\t:   -nodeNameFormat   name format for Nodes"
+                  "\n\t\t:   -meshNameFormat   name format for Meshes"
+                  "\n\t\t:   -draco            use Draco compression 3D geometric meshes"
+                  "\n\t\t:   -compressionLevel draco compression level [0-10] (by default 7), a value of 0 will apply sequential encoding and preserve face order"
+                  "\n\t\t:   -quantizePositionBits quantization bits for position attribute when using Draco compression (by default 14)"
+                  "\n\t\t:   -quantizeNormalBits   quantization bits for normal attribute when using Draco compression (by default 10)"
+                  "\n\t\t:   -quantizeTexcoordBits quantization bits for texture coordinate attribute when using Draco compression (by default 12)"
+                  "\n\t\t:   -quantizeColorBits    quantization bits for color attribute when using Draco compression (by default 8)"
+                  "\n\t\t:   -quantizeGenericBits  quantization bits for skinning attribute (joint indices and joint weights)"
+                  "\n                        and custom attributes when using Draco compression (by default 12)"
+                  "\n\t\t:   -unifiedQuantization  quantization is applied on each primitive separately if this option is false"
+                  "\n\t\t:   -parallel             use multithreading for Draco compression",
+                  __FILE__, WriteGltf, g);
+  theCommands.Add("writegltf",
+                  "writegltf shape file",
+                  __FILE__, WriteGltf, g);
+  theCommands.Add("writevrml", "shape file [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 1 by default]", __FILE__, writevrml, g);
+  theCommands.Add("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]", __FILE__, writestl, g);
+  theCommands.Add("readstl",
+                  "readstl shape file [-brep] [-mergeAngle Angle] [-multi]"
+                  "\n\t\t: Reads STL file and creates a new shape with specified name."
+                  "\n\t\t: When -brep is specified, creates a Compound of per-triangle Faces."
+                  "\n\t\t: Single triangulation-only Face is created otherwise (default)."
+                  "\n\t\t: -mergeAngle specifies maximum angle in degrees between triangles to merge equal nodes; disabled by default."
+                  "\n\t\t: -multi creates a face per solid in multi-domain files; ignored when -brep is set.",
+                  __FILE__, readstl, g);
+  theCommands.Add("loadvrml", "shape file", __FILE__, loadvrml, g);
+  theCommands.Add("ReadObj",
+                  "ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
+                  "\n\t\t:                  [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
+                  "\n\t\t:                  [-listExternalFiles] [-noCreateDoc]"
+                  "\n\t\t: Read OBJ file into XDE document."
+                  "\n\t\t:   -fileUnit       length unit of OBJ file content;"
+                  "\n\t\t:   -fileCoordSys   coordinate system defined by OBJ file; Yup when not specified."
+                  "\n\t\t:   -resultCoordSys result coordinate system; Zup when not specified."
+                  "\n\t\t:   -singlePrecision truncate vertex data to single precision during read; FALSE by default."
+                  "\n\t\t:   -listExternalFiles do not read mesh and only list external files."
+                  "\n\t\t:   -noCreateDoc    read into existing XDE document.",
+                  __FILE__, ReadObj, g);
+  theCommands.Add("readobj",
+                  "readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
+                  "\n\t\t:                    [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
+                  "\n\t\t:                    [-singleFace]"
+                  "\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document."
+                  "\n\t\t:   -singleFace merge OBJ content into a single triangulation Face.",
+                  __FILE__, ReadObj, g);
+  theCommands.Add("WriteObj",
+                  "WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
+                  "\n\t\t:                   [-systemCoordSys {Zup|Yup}]"
+                  "\n\t\t:                   [-comments Text] [-author Name]"
+                  "\n\t\t: Write XDE document into OBJ file."
+                  "\n\t\t:   -fileUnit       length unit of OBJ file content;"
+                  "\n\t\t:   -fileCoordSys   coordinate system defined by OBJ file; Yup when not specified."
+                  "\n\t\t:   -systemCoordSys system coordinate system; Zup when not specified.",
+                  __FILE__, WriteObj, g);
+  theCommands.Add("writeobj",
+                  "writeobj shape file",
+                  __FILE__, WriteObj, g);
+
+  theCommands.Add("meshfromstl", "creates MeshVS_Mesh from STL file", __FILE__, createmesh, g);
+  theCommands.Add("mesh3delem", "creates 3d element mesh to test", __FILE__, create3d, g);
+  theCommands.Add("meshshadcolor", "change MeshVS_Mesh shading color", __FILE__, meshcolor, g);
+  theCommands.Add("meshlinkcolor", "change MeshVS_Mesh line color", __FILE__, linecolor, g);
+  theCommands.Add("meshmat", "change MeshVS_Mesh material and transparency", __FILE__, meshmat, g);
+  theCommands.Add("meshshrcoef", "change MeshVS_Mesh shrink coeff", __FILE__, shrink, g);
+  theCommands.Add("meshclosed", "meshclosed meshname (0/1) \nChange MeshVS_Mesh drawing mode. 0 - not closed object, 1 - closed object", __FILE__, closed, g);
+  theCommands.Add("meshshow", "display MeshVS_Mesh object", __FILE__, mdisplay, g);
+  theCommands.Add("meshhide", "erase MeshVS_Mesh object", __FILE__, merase, g);
+  theCommands.Add("meshhidesel", "hide selected entities", __FILE__, hidesel, g);
+  theCommands.Add("meshshowsel", "show only selected entities", __FILE__, showonly, g);
+  theCommands.Add("meshshowall", "show all entities", __FILE__, showall, g);
+  theCommands.Add("meshcolors", "display color presentation", __FILE__, meshcolors, g);
+  theCommands.Add("meshvectors", "display sample vectors", __FILE__, meshvectors, g);
+  theCommands.Add("meshtext", "display text labels", __FILE__, meshtext, g);
+  theCommands.Add("meshdeform", "display deformed mesh", __FILE__, meshdeform, g);
+  theCommands.Add("mesh_edge_width", "set width of edges", __FILE__, mesh_edge_width, g);
+  theCommands.Add("meshinfo", "displays the number of nodes and triangles", __FILE__, meshinfo, g);
+  theCommands.Add("WritePly", R"(
 WritePly Doc file [-normals {0|1}]=1 [-colors {0|1}]=1 [-uv {0|1}]=0 [-partId {0|1}]=1 [-faceId {0|1}]=0
                   [-pointCloud {0|1}]=0 [-distance Value]=0.0 [-density Value] [-tolerance Value]
 Write document or triangulated shape into PLY file.
@@ -2557,14 +2612,15 @@ Generate point cloud out of the shape and write it into PLY file.
  -density    sets density of points to generate randomly on surface;
  -tolerance  sets tolerance; default value is Precision::Confusion();
 )", __FILE__, WritePly, g);
-  theCommands.Add ("writeply",
-                   "writeply shape file",
-                   __FILE__, WritePly, g);
+  theCommands.Add("writeply",
+                  "writeply shape file",
+                  __FILE__, WritePly, g);
 }
 
-//==============================================================================
-// XSDRAWSTLVRML::Factory
-//==============================================================================
+//=======================================================================
+//function : Factory
+//purpose  :
+//=======================================================================
 void XSDRAWSTLVRML::Factory(Draw_Interpretor& theDI)
 {
   XSDRAWIGES::InitSelect();
@@ -2580,4 +2636,3 @@ void XSDRAWSTLVRML::Factory(Draw_Interpretor& theDI)
 
 // Declare entry point PLUGINFACTORY
 DPLUGIN(XSDRAWSTLVRML)
-