Salome HOME
Merge 'master' branch into 'V9_dev' branch. V9_dev V9_0_0
authorrnv <rnv@opencascade.com>
Wed, 17 Jan 2018 13:20:50 +0000 (16:20 +0300)
committerrnv <rnv@opencascade.com>
Thu, 18 Jan 2018 16:31:08 +0000 (19:31 +0300)
103 files changed:
1  2 
doc/salome/examples/creating_meshes_ex03.py
doc/salome/examples/filters_ex01.py
doc/salome/gui/SMESH/input/smesh_migration.doc
idl/SMESH_Gen.idl
src/DriverMED/DriverMED_W_Field.cxx
src/SMESH/SMESH_Algo.cxx
src/SMESH/SMESH_Algo.hxx
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_Gen.hxx
src/SMESH/SMESH_Hypothesis.cxx
src/SMESH/SMESH_Hypothesis.hxx
src/SMESH/SMESH_Mesh.cxx
src/SMESHGUI/SMESHGUI_DuplicateNodesDlg.cxx
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_Filter_i.cxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_PythonDump.cxx
src/SMESH_SWIG/SMESH_blocks.py
src/SMESH_SWIG/StdMeshersBuilder.py
src/SMESH_SWIG/smeshBuilder.py
src/SMESH_SWIG/smesh_algorithm.py
src/StdMeshers/StdMeshers_Arithmetic1D.cxx
src/StdMeshers/StdMeshers_Arithmetic1D.hxx
src/StdMeshers/StdMeshers_AutomaticLength.cxx
src/StdMeshers/StdMeshers_AutomaticLength.hxx
src/StdMeshers/StdMeshers_Cartesian_3D.cxx
src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx
src/StdMeshers/StdMeshers_CompositeHexa_3D.hxx
src/StdMeshers/StdMeshers_CompositeSegment_1D.cxx
src/StdMeshers/StdMeshers_CompositeSegment_1D.hxx
src/StdMeshers/StdMeshers_Deflection1D.cxx
src/StdMeshers/StdMeshers_Deflection1D.hxx
src/StdMeshers/StdMeshers_FixedPoints1D.cxx
src/StdMeshers/StdMeshers_FixedPoints1D.hxx
src/StdMeshers/StdMeshers_Geometric1D.cxx
src/StdMeshers/StdMeshers_Geometric1D.hxx
src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx
src/StdMeshers/StdMeshers_Hexa_3D.cxx
src/StdMeshers/StdMeshers_Hexa_3D.hxx
src/StdMeshers/StdMeshers_ImportSource.cxx
src/StdMeshers/StdMeshers_ImportSource.hxx
src/StdMeshers/StdMeshers_Import_1D.cxx
src/StdMeshers/StdMeshers_Import_1D.hxx
src/StdMeshers/StdMeshers_Import_1D2D.cxx
src/StdMeshers/StdMeshers_Import_1D2D.hxx
src/StdMeshers/StdMeshers_LengthFromEdges.cxx
src/StdMeshers/StdMeshers_LengthFromEdges.hxx
src/StdMeshers/StdMeshers_LocalLength.cxx
src/StdMeshers/StdMeshers_LocalLength.hxx
src/StdMeshers/StdMeshers_MEFISTO_2D.cxx
src/StdMeshers/StdMeshers_MEFISTO_2D.hxx
src/StdMeshers/StdMeshers_MaxElementArea.cxx
src/StdMeshers/StdMeshers_MaxElementArea.hxx
src/StdMeshers/StdMeshers_MaxElementVolume.cxx
src/StdMeshers/StdMeshers_MaxElementVolume.hxx
src/StdMeshers/StdMeshers_MaxLength.cxx
src/StdMeshers/StdMeshers_MaxLength.hxx
src/StdMeshers/StdMeshers_NotConformAllowed.cxx
src/StdMeshers/StdMeshers_NotConformAllowed.hxx
src/StdMeshers/StdMeshers_NumberOfSegments.cxx
src/StdMeshers/StdMeshers_NumberOfSegments.hxx
src/StdMeshers/StdMeshers_Prism_3D.cxx
src/StdMeshers/StdMeshers_Prism_3D.hxx
src/StdMeshers/StdMeshers_Projection_1D.cxx
src/StdMeshers/StdMeshers_Projection_1D.hxx
src/StdMeshers/StdMeshers_Projection_2D.cxx
src/StdMeshers/StdMeshers_Projection_2D.hxx
src/StdMeshers/StdMeshers_Projection_3D.cxx
src/StdMeshers/StdMeshers_Projection_3D.hxx
src/StdMeshers/StdMeshers_Propagation.cxx
src/StdMeshers/StdMeshers_Propagation.hxx
src/StdMeshers/StdMeshers_QuadFromMedialAxis_1D2D.cxx
src/StdMeshers/StdMeshers_QuadranglePreference.cxx
src/StdMeshers/StdMeshers_QuadranglePreference.hxx
src/StdMeshers/StdMeshers_Quadrangle_2D.cxx
src/StdMeshers/StdMeshers_QuadraticMesh.cxx
src/StdMeshers/StdMeshers_QuadraticMesh.hxx
src/StdMeshers/StdMeshers_RadialPrism_3D.cxx
src/StdMeshers/StdMeshers_RadialPrism_3D.hxx
src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.hxx
src/StdMeshers/StdMeshers_Regular_1D.hxx
src/StdMeshers/StdMeshers_Reversible1D.cxx
src/StdMeshers/StdMeshers_Reversible1D.hxx
src/StdMeshers/StdMeshers_SegmentAroundVertex_0D.cxx
src/StdMeshers/StdMeshers_SegmentAroundVertex_0D.hxx
src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.cxx
src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.hxx
src/StdMeshers/StdMeshers_StartEndLength.cxx
src/StdMeshers/StdMeshers_StartEndLength.hxx
src/StdMeshers/StdMeshers_UseExisting_1D2D.cxx
src/StdMeshers/StdMeshers_UseExisting_1D2D.hxx
src/StdMeshers/StdMeshers_ViscousLayers.cxx
src/StdMeshers/StdMeshers_ViscousLayers2D.cxx
src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx
src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx
src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx
src/StdMeshers_I/StdMeshers_i.cxx

index bb647c370fbd4e4980b65dab7d987227eadd4493,30d263caaa2ed7f6a65cd90980afcd508c426427..42bf8c91a40b10a63def6afdb76b89f9b6528c4e
@@@ -4,11 -4,11 +4,11 @@@ import salom
  salome.salome_init()
  import GEOM
  from salome.geom import geomBuilder
 -geompy = geomBuilder.New(salome.myStudy)
 +geompy = geomBuilder.New()
  
  import SMESH, SALOMEDS
  from salome.smesh import smeshBuilder
 -smesh =  smeshBuilder.New(salome.myStudy)
 +smesh =  smeshBuilder.New()
  
  Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
  [Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"])
@@@ -42,18 -42,18 +42,18 @@@ Nb_Segments_4 = Regular_1D_3.NumberOfSe
  MEFISTO_2D_3 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_3)
  SubMesh_3 = MEFISTO_2D_3.GetSubMesh()
  
- # check exisiting sub-mesh priority order
+ # check existing sub-mesh priority order
  [ [ SubMesh_1, SubMesh_3, SubMesh_2 ] ] = Mesh_1.GetMeshOrder()
  isDone = Mesh_1.Compute()
 -print "Nb elements at initial order of sub-meshes:", Mesh_1.NbElements()
 +print("Nb elements at initial order of sub-meshes:", Mesh_1.NbElements())
  
  # set new sub-mesh order
  isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_1, SubMesh_2, SubMesh_3 ] ])
  # compute mesh
  isDone = Mesh_1.Compute()
 -print "Nb elements at new order of sub-meshes:", Mesh_1.NbElements()
 +print("Nb elements at new order of sub-meshes:", Mesh_1.NbElements())
  
  # compute with other sub-mesh order
  isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_2, SubMesh_1, SubMesh_3 ] ])
  isDone = Mesh_1.Compute()
 -print "Nb elements at another order of sub-meshes:", Mesh_1.NbElements()
 +print("Nb elements at another order of sub-meshes:", Mesh_1.NbElements())
index 02f3588c8dd795fa70c50864c2ce7b153e2f1594,9ee7ce8521df9a58c1bc95032ece239dac750433..f323ecb768c0b8a9569c23eec250e77c95944c26
@@@ -7,38 -7,38 +7,38 @@@ from SMESH_mechanic import 
  # get faces with aspect ratio > 2.5
  filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5)
  ids = mesh.GetIdsFromFilter(filter)
 -print "Number of faces with aspect ratio > 2.5:", len(ids)
 +print("Number of faces with aspect ratio > 2.5:", len(ids))
  
  # get faces with aspect ratio > 1.5
  filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, '>', 1.5, mesh=mesh)
  ids = filter.GetIDs()
 -print "Number of faces with aspect ratio > 1.5:", len(ids)
 +print("Number of faces with aspect ratio > 1.5:", len(ids))
  
  # copy the faces with aspect ratio > 1.5 to another mesh;
- # this demostrates that a filter can be used where usually a group or sub-mesh is acceptable
+ # this demonstrates that a filter can be used where usually a group or sub-mesh is acceptable
  filter.SetMesh( mesh.GetMesh() ) # - actually non necessary as mesh is set at filter creation
  mesh2 = smesh.CopyMesh( filter, "AR > 1.5" )
 -print "Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces()
 +print("Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces())
  
  # create a group (Group on Filter) of faces with Aspect Ratio < 1.5
  group = mesh.MakeGroup("AR < 1.5", SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5)
 -print "Number of faces with aspect ratio < 1.5:", group.Size()
 +print("Number of faces with aspect ratio < 1.5:", group.Size())
  
  # combine several criteria to Create a Group of only Triangular faces with Aspect Ratio < 1.5;
  # note that contents of a GroupOnFilter is dynamically updated as the mesh changes
  crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ),
           smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ]
  triaGroup = mesh.MakeGroupByCriteria( "Tria AR < 1.5", crit )
 -print "Number of triangles with aspect ratio < 1.5:", triaGroup.Size()
 +print("Number of triangles with aspect ratio < 1.5:", triaGroup.Size())
  
  # get range of values of Aspect Ratio of all faces in the mesh
  aspects = mesh.GetMinMax( SMESH.FT_AspectRatio )
 -print "MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] )
 +print("MESH: Min aspect = %s, Max aspect = %s" % ( aspects[0], aspects[1] ))
  
  # get max value of Aspect Ratio of faces in triaGroup
  grAspects = mesh.GetMinMax( SMESH.FT_AspectRatio, triaGroup )
 -print "GROUP: Max aspect = %s" % grAspects[1]
 +print("GROUP: Max aspect = %s" % grAspects[1])
  
  # get Aspect Ratio of an element
  aspect = mesh.FunctorValue( SMESH.FT_AspectRatio, ids[0] )
 -print "Aspect ratio of the face %s = %s" % ( ids[0], aspect )
 +print("Aspect ratio of the face %s = %s" % ( ids[0], aspect ))
index 14b048f730f287ee5d41586441e1b8d2916d5b96,71c18b1e08ebc1f88c99b04179b782dadeaecacc..9c8af6c9d9ccb7937d89cb0a1415dee657a3cfea
@@@ -1,6 -1,6 +1,6 @@@
  /*!
  
- \page smesh_migration_page Modifing Mesh Python scripts from SALOME 6 and before
+ \page smesh_migration_page Modifying Mesh Python scripts from SALOME 6 and before
  
  \n In SALOME 7.2, the Python interface for %Mesh has been slightly modified to offer new functionality:
  
@@@ -20,13 -20,13 +20,13 @@@ salome.salome_init(
  \n the old mode (from dump):
  \code
  import smesh, SMESH, SALOMEDS
 -smesh.SetCurrentStudy(salome.myStudy)
 +smesh.UpdateStudy()
  \endcode
  \n the new mode:
  \code
  import SMESH, SALOMEDS
  from salome.smesh import smeshBuilder
 -smesh =  smeshBuilder.New(salome.myStudy)
 +smesh =  smeshBuilder.New()
  \endcode
  
  
diff --combined idl/SMESH_Gen.idl
index 878c3d6a7ff9ab2519970ee5ef7a1d312d800b2a,dd0866f8a240579c824e61ceea0755e75a0217b6..ec7b9ebba6250876b1eee7ca8e349bf89de83d02
@@@ -76,7 -76,7 +76,7 @@@ module SMES
    const long Tag_LastGroup              = 16;
  
    /*!
-    * Hypothesis definintion error
+    * Hypothesis definition error
     */
    struct AlgoStateError
    {
      boolean IsEmbeddedMode();
  
      /*!
 -      Set the current study
 +      Update the study
       */
 -    void SetCurrentStudy( in SALOMEDS::Study theStudy );
 -
 +    void UpdateStudy();
 +    
 +    /*!
 +      Set enable publishing in the study
 +     */
 +    void SetEnablePublish( in boolean theIsEnablePublish );
 +    
      /*!
 -      Get the current study
 +      Get enable publishing in the study
       */
 -    SALOMEDS::Study GetCurrentStudy();
 +    boolean IsEnablePublish();
  
      /*!
       * Create a hypothesis that can be shared by different parts of the mesh.
        raises ( SALOME::SALOME_Exception );
  
      /*!
-      * Return errors of hypotheses definintion
+      * Return errors of hypotheses definition
       * algo_error_array is empty if everything is OK
       */
      algo_error_array GetAlgoState( in SMESH_Mesh        theMesh,
       */
      long GetObjectId(in Object theObject);
  
 +    /*!
 +     * \brief Get version of MED format being used.
 +     */
 +    string GetMEDFileVersion();
 +
      /*!
       * \brief Get MED version of the file by its name.
       */
 -    boolean GetMEDVersion(in string theFileName, out MED_VERSION theVersion);
 +    string GetMEDVersion(in string theFileName);
 +
 +    /*!
 +     * \brief Check compatibility of file with MED format being used.
 +     */
 +    boolean CheckCompatibility(in string theFileName);
  
      /*!
       * \brief Get names of meshes defined in file with the specified name.
index 45bf8c3b91831a30e9d81d373a468ef86bd3f86c,57e8edf19482b6db36f39ebea2646fcad0a6d9e5..d0e89a2b9a1865cd8746f60b8d65c6bbac075a1a
@@@ -254,7 -254,7 +254,7 @@@ Driver_Mesh::Status DriverMED_W_Field::
    if ( !myMesh )
      return addMessage("Supporting mesh not set", /*isFatal=*/true );
  
 -  MED::PWrapper medFile = MED::CrWrapper( myFile, MED::eV2_2 );
 +  MED::PWrapper medFile = MED::CrWrapperW( myFile );
    MED::PMeshInfo meshInfo;
    if ( myMeshId > 0 )
    {
    return DRS_OK;
  }
  
- namespace DriverMED // Implemetation of fuctions declared in DriverMED.hxx
+ namespace DriverMED // Implementation of functions declared in DriverMED.hxx
  {
    //================================================================================
    /*!
diff --combined src/SMESH/SMESH_Algo.cxx
index 45c4a7f55f6bc129121c44f98a3d97ee3e526e34,561f64471f04bd14af51428a18bacd5de113570e..febb8e0406d718825c8cdb1b2620bcc9c54c0c17
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : SMESH_Algo.cxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -173,8 -173,8 +173,8 @@@ const SMESH_Algo::Features& SMESH_Algo:
   */
  //=============================================================================
  
 -SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen)
 -  : SMESH_Hypothesis(hypId, studyId, gen)
 +SMESH_Algo::SMESH_Algo (int hypId, SMESH_Gen * gen)
 +  : SMESH_Hypothesis(hypId, gen)
  {
    _compatibleAllHypFilter = _compatibleNoAuxHypFilter = NULL;
    _onlyUnaryInput = _requireDiscreteBoundary = _requireShape = true;
@@@ -202,26 -202,26 +202,26 @@@ SMESH_Algo::~SMESH_Algo(
   */
  //=============================================================================
  
 -SMESH_0D_Algo::SMESH_0D_Algo(int hypId, int studyId, SMESH_Gen* gen)
 -  : SMESH_Algo(hypId, studyId, gen)
 +SMESH_0D_Algo::SMESH_0D_Algo(int hypId, SMESH_Gen* gen)
 +  : SMESH_Algo(hypId, gen)
  {
    _shapeType = (1 << TopAbs_VERTEX);
    _type = ALGO_0D;
  }
 -SMESH_1D_Algo::SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen)
 -  : SMESH_Algo(hypId, studyId, gen)
 +SMESH_1D_Algo::SMESH_1D_Algo(int hypId, SMESH_Gen* gen)
 +  : SMESH_Algo(hypId, gen)
  {
    _shapeType = (1 << TopAbs_EDGE);
    _type = ALGO_1D;
  }
 -SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
 -  : SMESH_Algo(hypId, studyId, gen)
 +SMESH_2D_Algo::SMESH_2D_Algo(int hypId, SMESH_Gen* gen)
 +  : SMESH_Algo(hypId, gen)
  {
    _shapeType = (1 << TopAbs_FACE);
    _type = ALGO_2D;
  }
 -SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
 -  : SMESH_Algo(hypId, studyId, gen)
 +SMESH_3D_Algo::SMESH_3D_Algo(int hypId, SMESH_Gen* gen)
 +  : SMESH_Algo(hypId, gen)
  {
    _shapeType = (1 << TopAbs_SOLID);
    _type = ALGO_3D;
diff --combined src/SMESH/SMESH_Algo.hxx
index e35cf6284e37bc31e3c6b68c06666a8ad0c2fee8,81ff8eb3aabda71a1c9cd8e603110b2395afb9bb..03154a989fcee01691d6d04984c20881bcefef37
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : SMESH_Algo.hxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -69,7 -69,7 +69,7 @@@ typedef std::map< SMESH_subMesh*, std::
   *  Methods of the class are grouped into several parts:
   *  - main lifecycle methods, like Compute()
   *  - methods describing features of the algorithm, like NeedShape()
-  *  - methods related to dependencies between sub-meshes imposed by the algorith
+  *  - methods related to dependencies between sub-meshes imposed by the algorithm
   *  - static utilities, like EdgeLength()
   */
  // ==================================================================================
@@@ -102,9 -102,10 +102,9 @@@ class SMESH_EXPORT SMESH_Algo : public 
    /*!
     * \brief Creates algorithm
      * \param hypId - algorithm ID
 -    * \param studyId - study ID
      * \param gen - SMESH_Gen
     */
 -  SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
 +  SMESH_Algo(int hypId, SMESH_Gen * gen);
  
    /*!
     * \brief Destructor
@@@ -474,19 -475,19 +474,19 @@@ protected
  class SMESH_EXPORT SMESH_0D_Algo: public SMESH_Algo
  {
  public:
 -  SMESH_0D_Algo(int hypId, int studyId,  SMESH_Gen* gen);
 +  SMESH_0D_Algo(int hypId, SMESH_Gen* gen);
  };
  
  class SMESH_EXPORT SMESH_1D_Algo: public SMESH_Algo
  {
  public:
 -  SMESH_1D_Algo(int hypId, int studyId,  SMESH_Gen* gen);
 +  SMESH_1D_Algo(int hypId, SMESH_Gen* gen);
  };
  
  class SMESH_EXPORT SMESH_2D_Algo: public SMESH_Algo
  {
  public:
 -  SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen);
 +  SMESH_2D_Algo(int hypId, SMESH_Gen* gen);
    /*!
     * \brief Method in which an algorithm generating a structured mesh
     *        fixes positions of in-face nodes after there movement
  class SMESH_EXPORT SMESH_3D_Algo: public SMESH_Algo
  {
  public:
 -  SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen);
 +  SMESH_3D_Algo(int hypId, SMESH_Gen* gen);
  };
  
  #endif
diff --combined src/SMESH/SMESH_Gen.cxx
index 27881281ed5f593b839a0561cdea0d6f2b2e56d1,69e499dd5effcb8884fc45b732ea9091ac037258..36e454366a4165396b8da07ba93724a5e0eb7ee6
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : SMESH_Gen.cxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -65,8 -65,6 +65,8 @@@ using namespace std
  
  SMESH_Gen::SMESH_Gen()
  {
 +  _studyContext = new StudyContextStruct;
 +  _studyContext->myDocument = new SMESHDS_Document();
    _localId = 0;
    _hypId   = 0;
    _segmentation = _nbSegments = 10;
@@@ -96,14 -94,19 +96,14 @@@ namespac
  
  SMESH_Gen::~SMESH_Gen()
  {
 -  std::map < int, StudyContextStruct * >::iterator i_sc = _mapStudyContext.begin();
 -  for ( ; i_sc != _mapStudyContext.end(); ++i_sc )
 -  {
 -    StudyContextStruct* context = i_sc->second;
 -    std::map < int, SMESH_Hypothesis * >::iterator i_hyp = context->mapHypothesis.begin();
 -    for ( ; i_hyp != context->mapHypothesis.end(); ++i_hyp )
 +    std::map < int, SMESH_Hypothesis * >::iterator i_hyp = _studyContext->mapHypothesis.begin();
 +    for ( ; i_hyp != _studyContext->mapHypothesis.end(); ++i_hyp )
      {
        if ( _Hyp* h = static_cast< _Hyp*>( i_hyp->second ))
          h->NullifyGen();
      }
 -    delete context->myDocument;
 -    delete context;
 -  }
 +  delete _studyContext->myDocument;
 +  delete _studyContext;
  }
  
  //=============================================================================
   */
  //=============================================================================
  
 -SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
 +SMESH_Mesh* SMESH_Gen::CreateMesh(bool theIsEmbeddedMode)
    throw(SALOME_Exception)
  {
    Unexpect aCatch(SalomeException);
  
 -  // Get studyContext, create it if it doesn't exist, with a SMESHDS_Document
 -  StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
 -
    // create a new SMESH_mesh object
    SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
 -                                     theStudyId,
                                       this,
                                       theIsEmbeddedMode,
 -                                     aStudyContext->myDocument);
 -  aStudyContext->mapMesh[_localId-1] = aMesh;
 +                                     _studyContext->myDocument);
 +  _studyContext->mapMesh[_localId-1] = aMesh;
  
    return aMesh;
  }
@@@ -1142,9 -1149,17 +1142,9 @@@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_su
   */
  //=============================================================================
  
 -StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
 +StudyContextStruct *SMESH_Gen::GetStudyContext()
  {
 -  // Get studyContext, create it if it doesn't exist, with a SMESHDS_Document
 -
 -  if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
 -  {
 -    _mapStudyContext[studyId] = new StudyContextStruct;
 -    _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
 -  }
 -  StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
 -  return myStudyContext;
 +  return _studyContext;
  }
  
  //================================================================================
diff --combined src/SMESH/SMESH_Gen.hxx
index 1433a79fa0d5f0fcc2da7c7bbabca59702c6c3e8,64eb26a70a83a274f066faab99fcf7d338f88281..d4c70292274dc1ff6767a401cc08744492b05189
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : SMESH_Gen.hxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -66,7 -66,7 +66,7 @@@ public
    SMESH_Gen();
    ~SMESH_Gen();
  
 -  SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
 +  SMESH_Mesh* CreateMesh(bool theIsEmbeddedMode)
      throw(SALOME_Exception);
  
    enum ComputeFlags
    // if Compute() would fail because of some algo bad state
    // theErrors list contains problems description
  
 -  StudyContextStruct *GetStudyContext(int studyId);
 +  StudyContextStruct *GetStudyContext();
  
    static int GetShapeDim(const TopAbs_ShapeEnum & aShapeType);
    static int GetShapeDim(const TopoDS_Shape &     aShape)
  private:
  
    int _localId;                         // unique Id of created objects, within SMESH_Gen entity
 -  std::map < int, StudyContextStruct * >_mapStudyContext;
 +  StudyContextStruct* _studyContext;
  
    // hypotheses managing
    int _hypId;
index 991eb2e94b316490ea7c39c0fe6733b678b4b314,23c52bcc3200786b7c93c76b0e08c471693353c4..ce08b40570c998a6a77f6f35f498655f2bac2ef9
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : SMESH_Hypothesis.cxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -41,13 -41,15 +41,13 @@@ using namespace std
  //=============================================================================
  
  SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
 -                                   int studyId,
                                     SMESH_Gen* gen) : SMESHDS_Hypothesis(hypId)
  {
    _gen            = gen;
 -  _studyId        = studyId;
    _type           = PARAM_ALGO;
    _shapeType      = 0;  // to be set by algo with TopAbs_Enum
    _param_algo_dim = -1; // to be set by algo parameter
 -  StudyContextStruct* myStudyContext = gen->GetStudyContext(_studyId);
 +  StudyContextStruct* myStudyContext = gen->GetStudyContext();
    myStudyContext->mapHypothesis[hypId] = this;
  }
  
@@@ -61,7 -63,7 +61,7 @@@ SMESH_Hypothesis::~SMESH_Hypothesis(
  {
    if ( _gen )
    {
 -    StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
 +    StudyContextStruct* myStudyContext = _gen->GetStudyContext();
      myStudyContext->mapHypothesis[_hypId] = 0;
    }
  }
@@@ -104,11 -106,22 +104,11 @@@ int SMESH_Hypothesis::GetShapeType() co
   */
  //=============================================================================
  
 -int SMESH_Hypothesis::GetStudyId() const
 -{
 -  return _studyId;
 -}
 -
 -//=============================================================================
 -/*!
 - * 
 - */
 -//=============================================================================
 -
  void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
  {
    // for all meshes in study
  
 -  StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
 +  StudyContextStruct* myStudyContext = _gen->GetStudyContext();
    map<int, SMESH_Mesh*>::iterator itm;
    for (itm = myStudyContext->mapMesh.begin();
         itm != myStudyContext->mapMesh.end();
@@@ -148,7 -161,7 +148,7 @@@ void SMESH_Hypothesis::SetLibName(cons
  
  SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id)
  {
 -  StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
 +  StudyContextStruct* myStudyContext = _gen->GetStudyContext();
    map<int, SMESH_Mesh*>::iterator itm = myStudyContext->mapMesh.begin();
    for ( ; itm != myStudyContext->mapMesh.end(); itm++)
    {
index 60b74bfb4a80e1405d31d8be3f048fb7bd9a74a2,7973a26a140d97dd3d4d035183d745b3a498494a..9aef12133684fe6e27e10459cb5b33711c8a10c8
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : SMESH_Hypothesis.hxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -69,9 -69,10 +69,9 @@@ public
    static bool IsStatusFatal(Hypothesis_Status theStatus)
    { return theStatus >= HYP_UNKNOWN_FATAL; }
  
 -  SMESH_Hypothesis(int hypId, int studyId, SMESH_Gen* gen);
 +  SMESH_Hypothesis(int hypId, SMESH_Gen* gen);
    virtual ~SMESH_Hypothesis();
    virtual int GetDim() const;
 -  int         GetStudyId() const;
    SMESH_Gen*  GetGen() const { return (SMESH_Gen*) _gen; }
    virtual int GetShapeType() const;
    virtual const char* GetLibName() const;
  
  protected:
    SMESH_Gen* _gen;
 -  int        _studyId;
    int        _shapeType;
    int        _param_algo_dim; // to be set at descendant hypothesis constructor
  
diff --combined src/SMESH/SMESH_Mesh.cxx
index f830b4ad28730e224d5270dccf264e5657cf8bee,0e2b961ea89b5ee73dc2a7ee317a325e99f55595..9c9491da224806d2dfe5d3e9edd3d4e63f47098f
@@@ -106,6 -106,7 +106,6 @@@ class SMESH_Mesh::SubMeshHolder : publi
  //=============================================================================
  
  SMESH_Mesh::SMESH_Mesh(int               theLocalId, 
 -                       int               theStudyId, 
                         SMESH_Gen*        theGen,
                         bool              theIsEmbeddedMode,
                         SMESHDS_Document* theDocument):
  {
    if(MYDEBUG) MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
    _id            = theLocalId;
 -  _studyId       = theStudyId;
    _gen           = theGen;
    _myDocument    = theDocument;
    _myMeshDS      = theDocument->NewMesh(theIsEmbeddedMode,theLocalId);
  
  SMESH_Mesh::SMESH_Mesh():
    _id(-1),
 -  _studyId(-1),
    _groupId( 0 ),
    _nbSubShapes( 0 ),
    _isShapeToMesh( false ),
@@@ -205,7 -208,7 +205,7 @@@ SMESH_Mesh::~SMESH_Mesh(
    // remove self from studyContext
    if ( _gen )
    {
 -    StudyContextStruct * studyContext = _gen->GetStudyContext( _studyId );
 +    StudyContextStruct * studyContext = _gen->GetStudyContext();
      studyContext->mapMesh.erase( _id );
    }
    if ( _myDocument )
@@@ -245,7 -248,7 +245,7 @@@ SMESH_Mesh* SMESH_Mesh::FindMesh( int m
    if ( _id == meshId )
      return (SMESH_Mesh*) this;
  
 -  if ( StudyContextStruct *aStudyContext = _gen->GetStudyContext( _studyId ))
 +  if ( StudyContextStruct *aStudyContext = _gen->GetStudyContext())
    {
      std::map < int, SMESH_Mesh * >::iterator i_m = aStudyContext->mapMesh.find( meshId );
      if ( i_m != aStudyContext->mapMesh.end() )
@@@ -694,7 -697,7 +694,7 @@@ SMESH_Mesh::AddHypothesis(const TopoDS_
        }
      }
  
-     // check concurent hypotheses on ancestors
+     // check concurrent hypotheses on ancestors
      if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp )
      {
        SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
@@@ -731,7 -734,7 +731,7 @@@ SMESH_Mesh::RemoveHypothesis(const Topo
    Unexpect aCatch(SalomeException);
    if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
  
 -  StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
 +  StudyContextStruct *sc = _gen->GetStudyContext();
    if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
      throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
  
      if (ret2 > ret) // more severe
        ret = ret2;
  
-     // check concurent hypotheses on ancestors
+     // check concurrent hypotheses on ancestors
      if (ret < SMESH_Hypothesis::HYP_CONCURENT && !IsMainShape( aSubShape ) )
      {
        SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
@@@ -992,7 -995,7 +992,7 @@@ int SMESH_Mesh::GetHypotheses(const SME
  
  SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const int anHypId) const
  {
 -  StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
 +  StudyContextStruct *sc = _gen->GetStudyContext();
    if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
      return NULL;
  
@@@ -1376,6 -1379,7 +1376,6 @@@ bool SMESH_Mesh::HasDuplicatedGroupName
   *  \param [in] theAutoGroups - boolean parameter for creating/not creating
   *              the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
   *              the typical use is auto_groups=false.
 - *  \param [in] theVersion - defines the version of format of MED file, that will be created
   *  \param [in] meshPart - mesh data to export
   *  \param [in] theAutoDimension - if \c true, a space dimension of a MED mesh can be either
       *         - 1D if all mesh nodes lie on OX coordinate axis, or
  void SMESH_Mesh::ExportMED(const char *        file, 
                             const char*         theMeshName, 
                             bool                theAutoGroups,
 -                           int                 theVersion,
                             const SMESHDS_Mesh* meshPart,
                             bool                theAutoDimension,
                             bool                theAddODOnVertices,
    SMESH_TRY;
  
    DriverMED_W_SMESHDS_Mesh myWriter;
 -  myWriter.SetFile         ( file, MED::EVersion(theVersion) );
 +  myWriter.SetFile         ( file );
    myWriter.SetMesh         ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS   );
    myWriter.SetAutoDimension( theAutoDimension );
    myWriter.AddODOnVertices ( theAddODOnVertices );
@@@ -1471,19 -1476,19 +1471,19 @@@ void SMESH_Mesh::ExportSAUV(const char 
  #ifdef WIN32
    cmd = "%PYTHONBIN% ";
  #else
 -  cmd = "python ";
 +  cmd = "python3 ";
  #endif
    cmd += "-c \"";
    cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
    cmd += "\"";
    system(cmd.c_str());
 -  ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, /*theVersion=*/1,
 +  ExportMED(medfilename.c_str(), theMeshName, theAutoGroups,
              /*meshPart=*/NULL, /*theAutoDimension=*/false, /*theAddODOnVertices=*/false,
              /*theAllElemsToGroup=*/true ); // theAllElemsToGroup is for PAL0023413
  #ifdef WIN32
    cmd = "%PYTHONBIN% ";
  #else
 -  cmd = "python ";
 +  cmd = "python3 ";
  #endif
    cmd += "-c \"";
    cmd += "from medutilities import convert ; convert(r'" + medfilename + "', 'MED', 'GIBI', 1, r'" + file + "')";
  #ifdef WIN32
    cmd = "%PYTHONBIN% ";
  #else
 -  cmd = "python ";
 +  cmd = "python3 ";
  #endif
    cmd += "-c \"";
    cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
index 0eb48be8378e641ea1cc7d896db40f1befad5585,e9e235766fe5788e8e00ed4e7a7590e127e61e90..383c936857b0565912a7c94e6420ad71fe703751
@@@ -165,21 -165,23 +165,23 @@@ SMESHGUI_DuplicateNodesDlg::SMESHGUI_Du
    mySelectButton3->setIcon(iconSelect);
    myLineEdit3 = new QLineEdit(myGroupArguments);
    myLineEdit3->setReadOnly(true);
+   myGenerateButton3 = new QPushButton(tr("GENERATE_GROUPS"), myGroupArguments);
  
    myCheckBox1 = new QCheckBox(tr("CONSTRUCT_NEW_GROUP_ELEMENTS"), myGroupArguments);
    myCheckBox2 = new QCheckBox(tr("CONSTRUCT_NEW_GROUP_NODES"), myGroupArguments);
  
-   aGroupArgumentsLayout->addWidget(myTextLabel1,    0, 0);
-   aGroupArgumentsLayout->addWidget(mySelectButton1, 0, 1);
-   aGroupArgumentsLayout->addWidget(myLineEdit1,     0, 2);
-   aGroupArgumentsLayout->addWidget(myTextLabel2,    1, 0);
-   aGroupArgumentsLayout->addWidget(mySelectButton2, 1, 1);
-   aGroupArgumentsLayout->addWidget(myLineEdit2,     1, 2);
-   aGroupArgumentsLayout->addWidget(myTextLabel3,    2, 0);
-   aGroupArgumentsLayout->addWidget(mySelectButton3, 2, 1);
-   aGroupArgumentsLayout->addWidget(myLineEdit3,     2, 2);
-   aGroupArgumentsLayout->addWidget(myCheckBox1, 3, 0);
-   aGroupArgumentsLayout->addWidget(myCheckBox2, 4, 0);
+   aGroupArgumentsLayout->addWidget(myTextLabel1,     0, 0);
+   aGroupArgumentsLayout->addWidget(mySelectButton1,  0, 1);
+   aGroupArgumentsLayout->addWidget(myLineEdit1,      0, 2, 1, 2);
+   aGroupArgumentsLayout->addWidget(myTextLabel2,     1, 0);
+   aGroupArgumentsLayout->addWidget(mySelectButton2,  1, 1);
+   aGroupArgumentsLayout->addWidget(myLineEdit2,      1, 2, 1, 2);
+   aGroupArgumentsLayout->addWidget(myTextLabel3,     2, 0);
+   aGroupArgumentsLayout->addWidget(mySelectButton3,  2, 1);
+   aGroupArgumentsLayout->addWidget(myLineEdit3,      2, 2);
+   aGroupArgumentsLayout->addWidget(myGenerateButton3,2, 3);
+   aGroupArgumentsLayout->addWidget(myCheckBox1,      3, 0);
+   aGroupArgumentsLayout->addWidget(myCheckBox2,      4, 0);
    aGroupArgumentsLayout->setRowStretch(5, 1);
    
    // Buttons
    connect(mySelectButton1, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
    connect(mySelectButton2, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
    connect(mySelectButton3, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
+   connect(myGenerateButton3, SIGNAL (clicked()), this, SLOT(onGenerate()));
  
    connect(myCheckBox2,    SIGNAL(stateChanged(int)), SLOT(updateButtons()));
  
@@@ -302,20 -305,21 +305,21 @@@ void SMESHGUI_DuplicateNodesDlg::onCons
        // Set text to the group of arguments and to the first two labels
        myGroupArguments->setTitle(tr("DUPLICATION_WITHOUT_ELEMS"));
        myTextLabel1->setText(tr("GROUP_NODES_TO_DUPLICATE"));
-       myTextLabel2->setText(tr("GROUP_NODES_TO_REPLACE"));
+       myTextLabel3->setText(tr("GROUP_NODES_TO_REPLACE"));
  
        myCheckBox1->hide();
        myCheckBox2->show();
        myCheckBox2->setText( tr("CONSTRUCT_NEW_GROUP_NODES"));
        
-       // Hide the third field
-       myTextLabel2->show();
-       mySelectButton2->show();
-       myLineEdit2->show();
-       myTextLabel3->hide();
-       mySelectButton3->hide();
-       myLineEdit3->hide();
-       
+       // Hide the 2nd field
+       myTextLabel2     ->hide();
+       mySelectButton2  ->hide();
+       myLineEdit2      ->hide();
+       myTextLabel3     ->show();
+       mySelectButton3  ->show();
+       myLineEdit3      ->show();
+       myGenerateButton3->show();
        break;
      }
    case 1:
        myCheckBox1->setText( tr("CONSTRUCT_NEW_GROUP_ELEMENTS"));
        myCheckBox2->setText( tr("CONSTRUCT_NEW_GROUP_NODES"));
  
-       // Show the third field
-       myTextLabel2->show();
-       mySelectButton2->show();
-       myLineEdit2->show();
-       myTextLabel3->show();
-       mySelectButton3->show();
-       myLineEdit3->show();
+       // Show the 2nd field
+       myTextLabel2     ->show();
+       mySelectButton2  ->show();
+       myLineEdit2      ->show();
+       myTextLabel3     ->show();
+       mySelectButton3  ->show();
+       myLineEdit3      ->show();
+       myGenerateButton3->show();
  
        break;
      }
        myCheckBox2->hide();
  
        // Hide the second and the third field
-       myTextLabel2->hide();
-       mySelectButton2->hide();
-       myLineEdit2->hide();
-       myTextLabel3->hide();
-       mySelectButton3->hide();
-       myLineEdit3->hide();
+       myTextLabel2     ->hide();
+       mySelectButton2  ->hide();
+       myLineEdit2      ->hide();
+       myTextLabel3     ->hide();
+       mySelectButton3  ->hide();
+       myLineEdit3      ->hide();
+       myGenerateButton3->hide();
  
        break;
      }
        myCheckBox2->setText( tr("ON_ALL_BOUNDARIES"));
  
        // Hide the second and the third field
-       myTextLabel2->hide();
-       mySelectButton2->hide();
-       myLineEdit2->hide();
-       myTextLabel3->hide();
-       mySelectButton3->hide();
-       myLineEdit3->hide();
+       myTextLabel2     ->hide();
+       mySelectButton2  ->hide();
+       myLineEdit2      ->hide();
+       myTextLabel3     ->hide();
+       mySelectButton3  ->hide();
+       myLineEdit3      ->hide();
+       myGenerateButton3->hide();
  
        break;
      }
  */
  bool SMESHGUI_DuplicateNodesDlg::onApply()
  {
 -  if ( mySMESHGUI->isActiveStudyLocked() || !isValid() )
 +  if ( SMESHGUI::isStudyLocked() || !isValid() )
      return false;
  
    BusyLocker lock( myBusy );
    QStringList anEntryList;
  
    try {
-     SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
+     SMESH::SMESH_Mesh_var             aMesh = myGroups1[0]->GetMesh();
      SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
  
      switch ( operationMode ) {
        for ( int i = 0; i < myGroups1.count(); i++ )
          g1[i] = myGroups1[i];
        SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
-       g2->length( myGroups2.count() );
-       for ( int i = 0; i < myGroups2.count(); i++ )
-         g2[i] = myGroups2[i];
+       g2->length( myGroups3.count() );
+       for ( int i = 0; i < myGroups3.count(); i++ )
+         g2[i] = myGroups3[i];
  
        if ( toCreateNodeGroup ) {
          SMESH::SMESH_GroupBase_var aNewGroup = 
      SalomeApp_Tools::QtCatchCorbaException(S_ex);
    }
    catch ( const std::exception& exc ) {
-     INFOS( "Follow exception was cought:\n\t" << exc.what() );
+     INFOS( "Follow exception was caught:\n\t" << exc.what() );
    }
    catch (...) {
-     INFOS( "Unknown exception was cought !!!" );
+     INFOS( "Unknown exception was caught !!!" );
    }
  
    if (!result) {
@@@ -638,6 -645,9 +645,9 @@@ void SMESHGUI_DuplicateNodesDlg::update
    bool isDataValid = isValid();
    myButtonOk->setEnabled( isDataValid );
    myButtonApply->setEnabled( isDataValid );
+   int operationMode = myGroupConstructors->checkedId();
+   myGenerateButton3->setEnabled( operationMode <= 1 && !myGroups1.empty() );
  }
  
  /*!
@@@ -690,6 -700,59 +700,59 @@@ void SMESHGUI_DuplicateNodesDlg::onDeac
    }
  }
  
 -  if ( mySMESHGUI->isActiveStudyLocked() )
+ /*!
+   \brief SLOT called when Generate button is clicked
+ */
+ void SMESHGUI_DuplicateNodesDlg::onGenerate()
+ {
++  if ( SMESHGUI::isStudyLocked() )
+     return;
+   SUIT_OverrideCursor aWaitCursor;
+   BusyLocker lock( myBusy );
+   try {
+     SMESH::SMESH_Mesh_var             aMesh = myGroups1[0]->GetMesh();
+     SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
+     SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
+     g1->length( myGroups1.count() );
+     for ( int i = 0; i < myGroups1.count(); i++ )
+       g1[i] = myGroups1[i];
+     SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
+     g2->length( myGroups2.count() );
+     for ( int i = 0; i < myGroups2.count(); i++ )
+       g2[i] = myGroups2[i];
+     SMESH::ListOfGroups_var newGroups =
+       aMeshEditor->AffectedElemGroupsInRegion( g1, g2, GEOM::GEOM_Object::_nil() );
+     QString text;
+     switch ( newGroups->length() ) {
+     case 0:  break;
+     case 1:  text = SMESH::toQStr( newGroups[0]->GetName() ); break;
+     default: text = tr( "SMESH_OBJECTS_SELECTED" ).arg( newGroups->length() );
+     }
+     myLineEdit3->setText( text );
+     myGroups3.clear();
+     for ( CORBA::ULong i = 0; i < newGroups->length(); ++i )
+       myGroups3 << SMESH::SMESH_GroupBase::_duplicate( newGroups[i] );
+   }
+   catch (const SALOME::SALOME_Exception& S_ex) {
+     SalomeApp_Tools::QtCatchCorbaException(S_ex);
+   }
+   catch ( const std::exception& exc ) {
+     INFOS( "Follow exception was caught:\n\t" << exc.what() );
+   }
+   catch (...) {
+     INFOS( "Unknown exception was caught !!!" );
+   }
+   mySMESHGUI->updateObjBrowser(true);
+   updateButtons();
+ }
  /*!
    \brief Receive dialog enter events.
    Activates the dialog when the mouse cursor enters.
index 1d4ab3789c420647ae8351b7e94df3fc26bf440a,ef6213ce6bd44dbf90d693b37d5e89dfef7ba3ba..dba59dba77b8aa6c4b013400b0cff0b805bd4d80
          <source>MED_FILES_FILTER</source>
          <translation>MED files</translation>
      </message>
 +    <message>
 +        <source>SAUV_FILES_FILTER</source>
 +        <translation>SAUV files</translation>
 +    </message>
      <message>
          <source>IDEAS_FILES_FILTER</source>
          <translation>IDEAS files</translation>
          <source>TEXT_FILES_FILTER</source>
          <translation>TXT files</translation>
      </message>
 -    <message>
 -        <source>MED_VX_FILES_FILTER</source>
 -        <translation>MED %1 files</translation>
 -    </message>
      <message>
          <source>STL_FILES_FILTER</source>
          <translation>STL files</translation>
@@@ -1792,6 -1792,13 +1792,6 @@@ Do you want to continue?</translation
          <source>SMESH_EXPORT_ONLY_GPOUP</source>
          <translation>You are going to export the group without its mesh.
  Do you want to continue?</translation>
 -    </message>
 -    <message>
 -        <source>SMESH_EXPORT_MED_V2_1</source>
 -        <translation>During export mesh with name - &quot;%1&quot; to MED 2.1
 -polygons and polyhedrons elements will be missed
 -For correct export use MED 2.2
 -Are you sure want to export to MED 2.1?</translation>
      </message>
      <message>
          <source>SMESH_EXPORT_MED_VERSION_COLLISION</source>
@@@ -7233,6 -7240,10 +7233,10 @@@ It is impossible to read point coordina
          <source>ON_ALL_BOUNDARIES</source>
          <translation>On all boundaries</translation>
      </message>
+     <message>
+         <source>GENERATE_GROUPS</source>
+         <translation>Generate</translation>
+     </message>
  </context>
  <context>
      <name>SMESHGUI_Make2DFrom3DDlg</name>
index cbfe62c194c7556ce5c967e336cdb625db425e94,e7155c2157326b01eca798cf5cf649af80d2fbf4..aed61ba95ee2c267a97bd70cdadc7996e7f0d6bd
@@@ -185,7 -185,7 +185,7 @@@ namespace 
      _AString comment;
  
      _pyID obj = cmd->GetObject();
 -    if ( obj.Search( "print " ) == 1 )
 +    if ( obj.Search( "print(" ) == 1 )
        return; // print statement
  
      if ( !obj.IsEmpty() && obj.Value( obj.Length() ) == ')' )
        }
      }
    }
 +
 +  bool _FilterArg( const _AString& theArg  )
 +  {
 +    static std::list<_AString> filteredArgs;
 +    static bool initialized = false;
 +    if ( !initialized ) {
 +      initialized = true;
 +      filteredArgs.push_back( "SMESH.MED_V2_1" );
 +      filteredArgs.push_back( "SMESH.MED_V2_2" );
 +    }  
 +    return std::find( filteredArgs.begin(), filteredArgs.end(), theArg ) != filteredArgs.end();
 +  }
  }
  
  //================================================================================
@@@ -476,6 -464,7 +476,6 @@@ SMESH_2smeshpy::ConvertScript(std::list
                                Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
                                Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
                                std::set< TCollection_AsciiString >&      theRemovedObjIDs,
 -                              SALOMEDS::Study_ptr&                      theStudy,
                                const bool                                theToKeepAllCommands)
  {
    std::list< TCollection_AsciiString >::iterator lineIt;
    theGen = new _pyGen( theEntry2AccessorMethod,
                         theObjectNames,
                         theRemovedObjIDs,
 -                       theStudy,
                         theToKeepAllCommands );
  
    for ( lineIt = theScriptLines.begin(); lineIt != theScriptLines.end(); ++lineIt )
    MESSAGE_BEGIN ( std::endl << " ######## RESULT ######## " << std::endl<< std::endl );
  #endif
  
-   // clean commmands of removed objects depending on myIsPublished flag
+   // clean commands of removed objects depending on myIsPublished flag
    theGen->ClearCommands();
  
    // reorder commands after conversion
    set<_pyID> createdObjects;
    createdObjects.insert( "smeshBuilder" );
    createdObjects.insert( "smesh" );
 -  createdObjects.insert( "theStudy" );
    for ( cmd = theGen->GetCommands().begin(); cmd != theGen->GetCommands().end(); ++cmd )
    {
  #ifdef DUMP_CONVERSION
  _pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
                 Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
                 std::set< TCollection_AsciiString >&      theRemovedObjIDs,
 -               SALOMEDS::Study_ptr&                      theStudy,
                 const bool                                theToKeepAllCommands)
    : _pyObject( new _pyCommand( "", 0 )),
      myNbCommands( 0 ),
      myRemovedObjIDs( theRemovedObjIDs ),
      myNbFilters( 0 ),
      myToKeepAllCommands( theToKeepAllCommands ),
 -    myStudy( SALOMEDS::Study::_duplicate( theStudy )),
      myGeomIDNb(0), myGeomIDIndex(-1)
  {
    // make that GetID() to return TPythonDump::SMESHGenName()
    GetCreationCmd()->GetString() += "=";
  
    // Find 1st digit of study entry by which a GEOM object differs from a SMESH object
 -  if ( !theObjectNames.IsEmpty() && !CORBA::is_nil( theStudy ))
 +  if ( !theObjectNames.IsEmpty() )
    {
      // find a GEOM entry
      _pyID geomID;
 -    SALOMEDS::SComponent_wrap geomComp = theStudy->FindComponent("GEOM");
 +    SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::getStudyServant()->FindComponent("GEOM");
      if ( geomComp->_is_nil() ) return;
      CORBA::String_var entry = geomComp->GetID();
      geomID = entry.in();
@@@ -698,7 -691,7 +698,7 @@@ Handle(_pyCommand) _pyGen::AddCommand( 
        _AString newCmd = indent + tab + ( aCommand->GetString().ToCString() + indent.Length() );
        _AString pasCmd = indent + tab + "pass"; // to keep valid if newCmd is erased
        _AString excStr = indent + "except:";
 -      _AString msgStr = indent + "\tprint '"; msgStr += method + "() failed. Invalid file name?'";
 +      _AString msgStr = indent + "\tprint('"; msgStr += method + "() failed. Invalid file name?')";
  
        myCommands.insert( --myCommands.end(), new _pyCommand( tryStr, myNbCommands ));
        aCommand->Clear();
      else if ( method == "MakeBoundaryElements")
        meshID = aCommand->GetResultValue(2);
  
-     if ( method.Search("MakeGroups") != -1  ||
-          method == "ExtrusionAlongPathX"    ||
-          method == "ExtrusionAlongPathObjX" ||
-          method == "DoubleNodeGroupNew"     ||
-          method == "DoubleNodeGroupsNew"    ||
-          method == "DoubleNodeElemGroupNew" ||
-          method == "DoubleNodeElemGroupsNew"||
-          method == "DoubleNodeElemGroup2New"||
-          method == "DoubleNodeElemGroups2New"
+     if ( method.Search("MakeGroups") != -1      ||
+          method == "ExtrusionAlongPathX"        ||
+          method == "ExtrusionAlongPathObjX"     ||
+          method == "DoubleNodeGroupNew"         ||
+          method == "DoubleNodeGroupsNew"        ||
+          method == "DoubleNodeElemGroupNew"     ||
+          method == "DoubleNodeElemGroupsNew"    ||
+          method == "DoubleNodeElemGroup2New"    ||
+          method == "DoubleNodeElemGroups2New"   ||
+          method == "AffectedElemGroupsInRegion"
           )
        groups = aCommand->GetResultValue();
      else if ( method == "MakeBoundaryMesh" )
@@@ -1111,7 -1105,7 +1112,7 @@@ void _pyGen::Process( const Handle(_pyC
    static TStringSet smeshpyMethods;
    if ( smeshpyMethods.empty() ) {
      const char * names[] =
 -      { "SetEmbeddedMode","IsEmbeddedMode","SetCurrentStudy","GetCurrentStudy",
 +      { "SetEmbeddedMode","IsEmbeddedMode","UpdateStudy","GetStudy",
          "GetPattern","GetSubShapesId",
          "" }; // <- mark of array end
      smeshpyMethods.Insert( names );
@@@ -1222,7 -1216,7 +1223,7 @@@ void _pyGen::PlaceSubmeshAfterItsCreati
  
  //================================================================================
  /*!
-  * \brief Clean commmands of removed objects depending on myIsPublished flag
+  * \brief Clean commands of removed objects depending on myIsPublished flag
   */
  //================================================================================
  
@@@ -1683,7 -1677,7 +1684,7 @@@ bool _pyGen::IsNotPublished(const _pyID
    // either the SMESH object is not in study or it is a GEOM object
    if ( IsGeomObject( theObjID ))
    {
 -    SALOMEDS::SObject_wrap so = myStudy->FindObjectID( theObjID.ToCString() );
 +    SALOMEDS::SObject_wrap so = SMESH_Gen_i::getStudyServant()->FindObjectID( theObjID.ToCString() );
      if ( so->_is_nil() ) return true;
      CORBA::Object_var obj = so->GetObject();
      return CORBA::is_nil( obj );
@@@ -1986,26 -1980,16 +1987,26 @@@ void _pyMesh::Process( const Handle(_py
    // ----------------------------------------------------------------------
    else if ( theCommand->MethodStartsFrom( "Export" ))
    {
 -    if ( method == "ExportToMED" ||  // ExportToMED()  --> ExportMED()
 -         method == "ExportToMEDX" )  // ExportToMEDX() --> ExportMED()
 +    if ( method == "ExportToMED"  || // ExportToMED()  --> ExportMED()
 +         method == "ExportToMEDX" || // ExportToMEDX() --> ExportMED()
 +         method == "ExportMED" )
      {
        theCommand->SetMethod( "ExportMED" );
 -      if ( theCommand->GetNbArgs() == 5 )
 +      // filter out deprecated version parameter
 +      vector< _AString > args;
 +      for ( int i = 1; i <= theCommand->GetNbArgs(); i++ ) {
 +        if ( !_FilterArg( theCommand->GetArg( i ) ) )
 +          args.push_back( theCommand->GetArg( i ) );
 +      }
 +      theCommand->RemoveArgs();
 +      for ( uint i = 0; i < args.size(); i++ )
 +        theCommand->SetArg( i+1, args[i] );
 +      if ( theCommand->GetNbArgs() == 4 )
        {
          // ExportToMEDX(...,autoDimension) -> ExportToMEDX(...,meshPart=None,autoDimension)
 -        _AString autoDimension = theCommand->GetArg( 5 );
 -        theCommand->SetArg( 5, "None" );
 -        theCommand->SetArg( 6, autoDimension );
 +        _AString autoDimension = theCommand->GetArg( 4 );
 +        theCommand->SetArg( 4, "None" );
 +        theCommand->SetArg( 5, autoDimension );
        }
      }
      else if ( method == "ExportCGNS" )
        TCollection_AsciiString newMethod = method;
        newMethod.Remove( /*where=*/7, /*howmany=*/6 );
        theCommand->SetMethod( newMethod );
 +      // filter out deprecated version parameter
 +      vector< _AString > args;
 +      for ( int i = 1; i <= theCommand->GetNbArgs(); i++ ) {
 +        if ( !_FilterArg( theCommand->GetArg( i ) ) )
 +          args.push_back( theCommand->GetArg( i ) );
 +      }
 +      theCommand->RemoveArgs();
 +      for ( uint i = 0; i < args.size(); i++ )
 +        theCommand->SetArg( i+1, args[i] );
        // make the 1st arg be the last one (or last but three for ExportMED())
        _pyID partID = theCommand->GetArg( 1 );
        int nbArgs = theCommand->GetNbArgs() - 3 * (newMethod == "ExportMED");
@@@ -2151,7 -2126,7 +2152,7 @@@ bool _pyMesh::NeedMeshAccess( const Han
      const char * names[] =
        { "ExportDAT","ExportUNV","ExportSTL","ExportSAUV", "RemoveGroup","RemoveGroupWithContents",
          "GetGroups","UnionGroups","IntersectGroups","CutGroups","CreateDimGroup","GetLog","GetId",
 -        "ClearLog","GetStudyId","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
 +        "ClearLog","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
          "NbEdges","NbEdgesOfOrder","NbFaces","NbFacesOfOrder","NbTriangles",
          "NbTrianglesOfOrder","NbQuadrangles","NbQuadranglesOfOrder","NbPolygons","NbVolumes",
          "NbVolumesOfOrder","NbTetras","NbTetrasOfOrder","NbHexas","NbHexasOfOrder",
@@@ -2465,7 -2440,7 +2466,7 @@@ void _pyMeshEditor::Process( const Hand
        "Scale","ScaleMakeMesh","RotateMakeMesh","RotateObjectMakeMesh","MakeBoundaryMesh",
        "MakeBoundaryElements", "SplitVolumesIntoTetra","SplitHexahedraIntoPrisms",
        "DoubleElements","DoubleNodes","DoubleNode","DoubleNodeGroup","DoubleNodeGroups",
-       "DoubleNodeElem","DoubleNodeElemInRegion","DoubleNodeElemGroup",
+       "DoubleNodeElem","DoubleNodeElemInRegion","DoubleNodeElemGroup","AffectedElemGroupsInRegion",
        "DoubleNodeElemGroupInRegion","DoubleNodeElemGroups","DoubleNodeElemGroupsInRegion",
        "DoubleNodesOnGroupBoundaries","CreateFlatElementsOnFacesGroups","CreateHoleSkin"
        ,"" }; // <- mark of the end
@@@ -4112,7 -4087,7 +4113,7 @@@ void _pyCommand::SetPart(int thePartInd
  
  //================================================================================
  /*!
-  * \brief Set agrument
+  * \brief Set argument
   *  \param index - The argument index, it counts from 1
   *  \param theArg - The argument string
   */
index 6b64f7005a3da1e7cfcee91075bcb6b9eba9aedb,28e749b6e758b5a0650660c187f9d41428028b78..73217f272fb12c92da5d84599da5696d452d1eaa
@@@ -136,14 -136,18 +136,14 @@@ static TopoDS_Shape getShapeByName( con
    if ( theName != 0 )
    {
      SMESH_Gen_i* aSMESHGen     = SMESH_Gen_i::GetSMESHGen();
 -    SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
 -    if ( !aStudy->_is_nil() )
 +    SALOMEDS::Study::ListOfSObject_var aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "GEOM" );
 +    if ( aList->length() > 0 )
      {
 -      SALOMEDS::Study::ListOfSObject_var aList = aStudy->FindObjectByName( theName, "GEOM" );
 -      if ( aList->length() > 0 )
 -      {
 -        CORBA::Object_var        anObj = aList[ 0 ]->GetObject();
 -        GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( anObj );
 -        TopoDS_Shape             shape = aSMESHGen->GeomObjectToShape( aGeomObj );
 -        SALOME::UnRegister( aList ); // UnRegister() objects in aList
 -        return shape;
 -      }
 +      CORBA::Object_var        anObj = aList[ 0 ]->GetObject();
 +      GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( anObj );
 +      TopoDS_Shape             shape = aSMESHGen->GeomObjectToShape( aGeomObj );
 +      SALOME::UnRegister( aList ); // UnRegister() objects in aList
 +      return shape;
      }
    }
    return TopoDS_Shape();
@@@ -153,11 -157,14 +153,11 @@@ static TopoDS_Shape getShapeByID (cons
  {
    if ( theID && strlen( theID ) > 0 ) {
      SMESH_Gen_i*     aSMESHGen = SMESH_Gen_i::GetSMESHGen();
 -    SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
 -    if ( !aStudy->_is_nil() ) {
 -      SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
 -      if ( !aSObj->_is_nil() ) {
 -        CORBA::Object_var          obj = aSObj->GetObject();
 -        GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
 -        return aSMESHGen->GeomObjectToShape( aGeomObj );
 -      }
 +    SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID(theID);
 +    if ( !aSObj->_is_nil() ) {
 +      CORBA::Object_var          obj = aSObj->GetObject();
 +      GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
 +      return aSMESHGen->GeomObjectToShape( aGeomObj );
      }
    }
    return TopoDS_Shape();
  // static std::string getShapeNameByID (const char* theID)
  // {
  //   if ( theID && strlen( theID ) > 0 ) {
 -//     SMESH_Gen_i*     aSMESHGen = SMESH_Gen_i::GetSMESHGen();
 -//     SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
 -//     if ( !aStudy->_is_nil() ) {
 -//       SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID(theID);
 -//       if ( !aSObj->_is_nil() ) {
 -//         CORBA::String_var name = aSObj->GetName();
 -//         return name.in();
 -//       }
 +//     SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID(theID);
 +//     if ( !aSObj->_is_nil() ) {
 +//       CORBA::String_var name = aSObj->GetName();
 +//       return name.in();
  //     }
  //   }
  //   return "";
  
  /*
    Class       : Functor_i
-   Description : An abstact class for all functors
+   Description : An abstract class for all functors
  */
  Functor_i::Functor_i():
    SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
@@@ -781,10 -792,14 +781,10 @@@ void BelongToMeshGroup_i::SetGroupID( c
    }
    else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI
    {
 -    SMESH_Gen_i* aSMESHGen     = SMESH_Gen_i::GetSMESHGen();
 -    SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
 -    if ( !aStudy->_is_nil() ) {
 -      SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID( myID.c_str() );
 -      if ( !aSObj->_is_nil() ) {
 -        CORBA::Object_var obj = aSObj->GetObject();
 -        SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
 -      }
 +    SALOMEDS::SObject_wrap aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( myID.c_str() );
 +    if ( !aSObj->_is_nil() ) {
 +      CORBA::Object_var obj = aSObj->GetObject();
 +      SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
      }
    }
    else if ( !myID.empty() ) // persistent mode
@@@ -810,7 -825,7 +810,7 @@@ SMESH::SMESH_GroupBase_ptr BelongToMesh
    {
      // search for a group in a current study
      SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
 -    if ( StudyContext*  sc = aSMESHGen->GetCurrentStudyContext() )
 +    if ( StudyContext*  sc = aSMESHGen->GetStudyContext() )
      {
        int id = 1;
        std::string ior;
@@@ -1675,7 -1690,11 +1675,7 @@@ void ConnectedElements_i::SetThreshold 
      }
    case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry /////////////////
      {
 -      SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
 -      if ( study->_is_nil() )
 -        THROW_SALOME_CORBA_EXCEPTION
 -          ( "ConnectedElements_i::SetThreshold(): NULL current study", SALOME::BAD_PARAM );
 -      SALOMEDS::SObject_wrap sobj = study->FindObjectID( threshold );
 +      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( threshold );
        if ( sobj->_is_nil() )
          THROW_SALOME_CORBA_EXCEPTION
            ( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM );
index 9b3b5af56c88ce4d24fad6c4fd68109366b735a9,b29e9a90173dd725ca4534098dad708a9ba8f289..bdf44dc4908d288304aa161f28a143cf7f080d9c
  
  #include <map>
  #include <fstream>
 +#include <sstream>
  #include <cstdio>
  #include <cstdlib>
  
@@@ -299,10 -298,7 +299,10 @@@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_pt
    _thisObj = this ;
    _id = myPoa->activate_object( _thisObj );
  
 +  myStudyContext = new StudyContext;
 +
    myIsEmbeddedMode = false;
 +  myIsEnablePublish = true;
    myShapeReader = NULL;  // shape reader
    mySMESHGen = this;
    myIsHistoricalPythonDump = true;
@@@ -360,8 -356,11 +360,8 @@@ SMESH_Gen_i::~SMESH_Gen_i(
    myHypCreatorMap.clear();
  
    // Clear study contexts data
 -  map<int, StudyContext*>::iterator it;
 -  for ( it = myStudyContextMap.begin(); it != myStudyContextMap.end(); ++it ) {
 -    delete it->second;
 -  }
 -  myStudyContextMap.clear();
 +  delete myStudyContext;
 +
    // delete shape reader
    if ( myShapeReader )
      delete myShapeReader;
@@@ -379,7 -378,7 +379,7 @@@ GenericHypothesisCreator_i* SMESH_Gen_i
    throw (SALOME::SALOME_Exception)
  {
    std::string aPlatformLibName;
-   /* It's Need to tranlate lib name for WIN32 or X platform */
+   /* It's Need to translate lib name for WIN32 or X platform */
    if ( theLibName && theLibName[0] != '\0'  )
    {
      int libNameLen = strlen(theLibName);
@@@ -486,7 -485,7 +486,7 @@@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i
      getHypothesisCreator(theHypName, theLibName, aPlatformLibName);
  
    // create a new hypothesis object, store its ref. in studyContext
 -  myHypothesis_i = aCreator->Create(myPoa, GetCurrentStudyID(), &myGen);
 +  myHypothesis_i = aCreator->Create(myPoa, &myGen);
    if (myHypothesis_i)
    {
      myHypothesis_i->SetLibName( aPlatformLibName.c_str() ); // for persistency assurance
@@@ -518,10 -517,10 +518,10 @@@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::crea
    // Get or create the GEOM_Client instance
    try {
      // create a new mesh object servant, store it in a map in study context
 -    SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() );
 +    SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this );
      // create a new mesh object
      if(MYDEBUG) MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode);
 -    meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode ));
 +    meshServant->SetImpl( myGen.CreateMesh( myIsEmbeddedMode ));
  
      // activate the CORBA servant of Mesh
      SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() );
@@@ -615,74 -614,82 +615,74 @@@ CORBA::Boolean SMESH_Gen_i::IsEmbeddedM
  
  //=============================================================================
  /*!
 - *  SMESH_Gen_i::SetCurrentStudy
 + *  SMESH_Gen_i::SetEnablePublish
   *
 - *  Set current study
 + *  Set enable publishing in the study
   */
  //=============================================================================
 -
 -void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy )
 +void SMESH_Gen_i::SetEnablePublish( CORBA::Boolean theIsEnablePublish )
  {
 -  setCurrentStudy( theStudy );
 +  myIsEnablePublish = theIsEnablePublish;
  }
  
 -void SMESH_Gen_i::setCurrentStudy( SALOMEDS::Study_ptr theStudy,
 -                                   bool                theStudyIsBeingClosed)
 +//=============================================================================
 +/*!
 + *  SMESH_Gen_i::IsEnablePublish
 + *
 + *  Check enable publishing
 + */
 +//=============================================================================
 +
 +CORBA::Boolean SMESH_Gen_i::IsEnablePublish()
  {
 -  int curStudyId = GetCurrentStudyID();
 -  myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy );
 -  // create study context, if it doesn't exist and set current study
 -  int studyId = GetCurrentStudyID();
 -  if ( myStudyContextMap.find( studyId ) == myStudyContextMap.end() )
 -    myStudyContextMap[ studyId ] = new StudyContext;
 -
 -  // myCurrentStudy may be nil
 -  if ( !theStudyIsBeingClosed && !CORBA::is_nil( myCurrentStudy ) ) {
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
 -    SALOMEDS::SComponent_wrap GEOM_var = myCurrentStudy->FindComponent( "GEOM" );
 -    if( !GEOM_var->_is_nil() )
 -      aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine() );
 -    // NPAL16168, issue 0020210
 -    // Let meshes update their data depending on GEOM groups that could change
 -    if ( curStudyId != studyId )
 -    {
 -      CORBA::String_var compDataType = ComponentDataType();
 -      SALOMEDS::SComponent_wrap me = myCurrentStudy->FindComponent( compDataType.in() );
 -      if ( !me->_is_nil() ) {
 -        SALOMEDS::ChildIterator_wrap anIter = myCurrentStudy->NewChildIterator( me );
 -        for ( ; anIter->More(); anIter->Next() ) {
 -          SALOMEDS::SObject_wrap so = anIter->Value();
 -          CORBA::Object_var     ior = SObjectToObject( so );
 -          if ( SMESH_Mesh_i*   mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
 -            mesh->CheckGeomModif();
 -        }
 -      }
 -    }
 -  }
 +  return myIsEnablePublish;
  }
  
  //=============================================================================
  /*!
 - *  SMESH_Gen_i::GetCurrentStudy
 + *  SMESH_Gen_i::UpdateStudy
   *
 - *  Get current study
 + *  Update study (needed at switching GEOM->SMESH)
   */
  //=============================================================================
  
 -SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy()
 +void SMESH_Gen_i::UpdateStudy()
  {
 -  if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetCurrentStudy: study Id = " << GetCurrentStudyID() );
 -  if ( GetCurrentStudyID() < 0 )
 -    return SALOMEDS::Study::_nil();
 -  return SALOMEDS::Study::_duplicate( myCurrentStudy );
 +  if ( !myStudyContext )
 +    myStudyContext = new StudyContext;
 +
 +  SALOMEDS::Study_var aStudy = getStudyServant();
 +  if ( !CORBA::is_nil( aStudy ) ) {
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
 +    SALOMEDS::SComponent_wrap GEOM_var = aStudy->FindComponent( "GEOM" );
 +    if( !GEOM_var->_is_nil() )
 +      aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine() );
 +    // NPAL16168, issue 0020210
 +    // Let meshes update their data depending on GEOM groups that could change
 +    CORBA::String_var compDataType = ComponentDataType();
 +    SALOMEDS::SComponent_wrap me = aStudy->FindComponent( compDataType.in() );
 +    if ( !me->_is_nil() ) {
 +      SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( me );
 +      for ( ; anIter->More(); anIter->Next() ) {
 +        SALOMEDS::SObject_wrap so = anIter->Value();
 +        CORBA::Object_var     ior = SObjectToObject( so );
 +        if ( SMESH_Mesh_i*   mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
 +          mesh->CheckGeomModif();
 +      }
 +    }
 +  }
  }
  
  //=============================================================================
  /*!
 - *  SMESH_Gen_i::GetCurrentStudyContext
 + *  SMESH_Gen_i::GetStudyContext
   *
 - *  Get current study context
 + *  Get study context
   */
  //=============================================================================
 -StudyContext* SMESH_Gen_i::GetCurrentStudyContext()
 +StudyContext* SMESH_Gen_i::GetStudyContext()
  {
 -  if ( !CORBA::is_nil( myCurrentStudy ) &&
 -       myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() )
 -    return myStudyContextMap[ myCurrentStudy->StudyId() ];
 -  else
 -    return 0;
 +  return myStudyContext;
  }
  
  //=============================================================================
@@@ -703,7 -710,7 +703,7 @@@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i
  
    // Publish hypothesis/algorithm in the study
    if ( CanPublishInStudy( hyp ) ) {
 -    SALOMEDS::SObject_wrap aSO = PublishHypothesis( myCurrentStudy, hyp );
 +    SALOMEDS::SObject_wrap aSO = PublishHypothesis( hyp );
      if ( !aSO->_is_nil() ) {
        // Update Python script
        TPythonDump() << aSO << " = " << this << ".CreateHypothesis('"
@@@ -828,12 -835,12 +828,12 @@@ CORBA::Boolean SMESH_Gen_i::GetSoleSubM
                                                      SMESH::SMESH_Mesh_out       theMesh,
                                                      GEOM::GEOM_Object_out       theShape)
  {
 -  if ( GetCurrentStudyID() < 0 || CORBA::is_nil( theHyp ))
 +  if ( CORBA::is_nil( theHyp ))
      return false;
  
    // get Mesh component SO
    CORBA::String_var compDataType = ComponentDataType();
 -  SALOMEDS::SComponent_wrap comp = myCurrentStudy->FindComponent( compDataType.in() );
 +  SALOMEDS::SComponent_wrap comp = getStudyServant()->FindComponent( compDataType.in() );
    if ( CORBA::is_nil( comp ))
      return false;
  
    SMESH::SMESH_Mesh_var foundMesh;
    TopoDS_Shape          foundShape;
    bool                  isSole = true;
 -  SALOMEDS::ChildIterator_wrap meshIter = myCurrentStudy->NewChildIterator( comp );
 +  SALOMEDS::ChildIterator_wrap meshIter = getStudyServant()->NewChildIterator( comp );
    for ( ; meshIter->More() && isSole; meshIter->Next() )
    {
      SALOMEDS::SObject_wrap curSO = meshIter->Value();
@@@ -1047,9 -1054,9 +1047,9 @@@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Crea
  
    // publish mesh in the study
    if ( CanPublishInStudy( mesh ) ) {
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
      aStudyBuilder->NewCommand();  // There is a transaction
 -    SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, mesh.in() );
 +    SALOMEDS::SObject_wrap aSO = PublishMesh( mesh.in() );
      aStudyBuilder->CommitCommand();
      if ( !aSO->_is_nil() ) {
        // Update Python script
@@@ -1078,9 -1085,9 +1078,9 @@@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Crea
  
    // publish mesh in the study
    if ( CanPublishInStudy( mesh ) ) {
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
      aStudyBuilder->NewCommand();  // There is a transaction
 -    SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, mesh.in() );
 +    SALOMEDS::SObject_wrap aSO = PublishMesh( mesh.in() );
      aStudyBuilder->CommitCommand();
      if ( !aSO->_is_nil() ) {
        // Update Python script
@@@ -1133,9 -1140,9 +1133,9 @@@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Crea
    string aFileName;
    // publish mesh in the study
    if ( CanPublishInStudy( aMesh ) ) {
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
      aStudyBuilder->NewCommand();  // There is a transaction
 -    SALOMEDS::SObject_wrap aSO = PublishMesh( myCurrentStudy, aMesh.in(), aFileName.c_str() );
 +    SALOMEDS::SObject_wrap aSO = PublishMesh( aMesh.in(), aFileName.c_str() );
      aStudyBuilder->CommitCommand();
      if ( !aSO->_is_nil() ) {
        // Update Python script
@@@ -1191,9 -1198,11 +1191,9 @@@ SMESH::mesh_array* SMESH_Gen_i::CreateM
  
    if (theStatus == SMESH::DRS_OK) {
      SALOMEDS::StudyBuilder_var aStudyBuilder;
 -    if ( GetCurrentStudyID() > -1 )
 -    {
 -      aStudyBuilder = myCurrentStudy->NewBuilder();
 -      aStudyBuilder->NewCommand();  // There is a transaction
 -    }
 +    aStudyBuilder = getStudyServant()->NewBuilder();
 +    aStudyBuilder->NewCommand();  // There is a transaction
 +
      aResult->length( aNames.size() );
      int i = 0;
  
          // little trick: for MED file theFileName and theFileNameForPython are the same, but they are different for SAUV
          // - as names of meshes are stored in MED file, we use them for data publishing
          // - as mesh name is not stored in UNV file, we use file name as name of mesh when publishing data
 -        aSO = PublishMesh( myCurrentStudy, mesh.in(), ( theFileName == theFileNameForPython ) ? (*it).c_str() : aFileName.c_str() );
 +        aSO = PublishMesh( mesh.in(), ( theFileName == theFileNameForPython ) ? (*it).c_str() : aFileName.c_str() );
  
        // Python Dump
        if ( !aSO->_is_nil() ) {
@@@ -1279,7 -1288,7 +1279,7 @@@ SMESH::mesh_array* SMESH_Gen_i::CreateM
  #ifdef WIN32
    cmd = "%PYTHONBIN% ";
  #else
 -  cmd = "python ";
 +  cmd = "python3 ";
  #endif
    cmd += "-c \"";
    cmd += "from medutilities import convert ; convert(r'" + sauvfilename + "', 'GIBI', 'MED', 1, r'" + medfilename + "')";
  #ifdef WIN32
    cmd = "%PYTHONBIN% ";
  #else
 -  cmd = "python ";
 +  cmd = "python3 ";
  #endif
    cmd += "-c \"";
    cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
@@@ -1323,9 -1332,10 +1323,9 @@@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Crea
  #endif
    // publish mesh in the study
    if ( CanPublishInStudy( aMesh ) ) {
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
      aStudyBuilder->NewCommand();  // There is a transaction
 -    SALOMEDS::SObject_wrap aSO = PublishInStudy
 -      ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
 +    SALOMEDS::SObject_wrap aSO = PublishInStudy( SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
      aStudyBuilder->CommitCommand();
      if ( !aSO->_is_nil() ) {
        // Update Python script
@@@ -1373,7 -1383,7 +1373,7 @@@ SMESH::mesh_array* SMESH_Gen_i::CreateM
  
      if (theStatus == SMESH::DRS_OK)
      {
 -      SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
 +      SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
        aStudyBuilder->NewCommand();  // There is a transaction
  
        int i = 0;
          // publish mesh in the study
          SALOMEDS::SObject_wrap aSO;
          if ( CanPublishInStudy( mesh ) )
 -          aSO = PublishMesh( myCurrentStudy, mesh.in(), meshName.c_str() );
 +          aSO = PublishMesh( mesh.in(), meshName.c_str() );
  
          // Python Dump
          if ( !aSO->_is_nil() ) {
@@@ -1451,9 -1461,10 +1451,9 @@@ SMESH_Gen_i::CreateMeshesFromGMF( cons
  #endif
    // publish mesh in the study
    if ( CanPublishInStudy( aMesh ) ) {
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
      aStudyBuilder->NewCommand();  // There is a transaction
 -    SALOMEDS::SObject_wrap aSO = PublishInStudy
 -      ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
 +    SALOMEDS::SObject_wrap aSO = PublishInStudy( SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
      aStudyBuilder->CommitCommand();
      if ( !aSO->_is_nil() ) {
        // Update Python script
@@@ -1520,17 -1531,16 +1520,17 @@@ CORBA::Boolean SMESH_Gen_i::IsReadyToCo
  SALOMEDS::SObject_ptr SMESH_Gen_i::GetAlgoSO(const ::SMESH_Algo* algo)
  {
    if ( algo ) {
 -    if ( !myCurrentStudy->_is_nil() ) {
 +  SALOMEDS::Study_var aStudy = getStudyServant();
 +    if ( !aStudy->_is_nil() ) {
        // find algo in the study
        CORBA::String_var compDataType  = ComponentDataType();
 -      SALOMEDS::SComponent_wrap father = myCurrentStudy->FindComponent( compDataType.in() );
 +      SALOMEDS::SComponent_wrap father = aStudy->FindComponent( compDataType.in() );
        if ( !father->_is_nil() ) {
 -        SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( father );
 +        SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( father );
          for ( ; itBig->More(); itBig->Next() ) {
            SALOMEDS::SObject_wrap gotBranch = itBig->Value();
            if ( gotBranch->Tag() == GetAlgorithmsRootTag() ) {
 -            SALOMEDS::ChildIterator_wrap algoIt = myCurrentStudy->NewChildIterator( gotBranch );
 +            SALOMEDS::ChildIterator_wrap algoIt = aStudy->NewChildIterator( gotBranch );
              for ( ; algoIt->More(); algoIt->Next() ) {
                SALOMEDS::SObject_wrap algoSO = algoIt->Value();
                CORBA::Object_var     algoIOR = SObjectToObject( algoSO );
@@@ -1744,7 -1754,7 +1744,7 @@@ SMESH_Gen_i::MakeGroupsOfBadInputElemen
  
  //================================================================================
  /*!
-  * \brief Returns errors of hypotheses definintion
+  * \brief Returns errors of hypotheses definition
   * \param theMesh - the mesh
   * \param theSubObject - the main or sub- shape
   * \retval SMESH::algo_error_array* - sequence of errors
@@@ -2266,16 -2276,16 +2266,16 @@@ SMESH_Gen_i::GetGeometryByMeshElement( 
      GEOM::GEOM_Gen_ptr    geomGen   = GetGeomEngine();
  
      // try to find the corresponding SObject
 -    SALOMEDS::SObject_wrap SObj = ObjectToSObject( myCurrentStudy, geom.in() );
 +    SALOMEDS::SObject_wrap SObj = ObjectToSObject( geom.in() );
      if ( SObj->_is_nil() ) // submesh can be not found even if published
      {
        // try to find published submesh
        GEOM::ListOfLong_var list = geom->GetSubShapeIndices();
        if ( !geom->IsMainShape() && list->length() == 1 ) {
 -        SALOMEDS::SObject_wrap mainSO = ObjectToSObject( myCurrentStudy, mainShape );
 +        SALOMEDS::SObject_wrap mainSO = ObjectToSObject( mainShape );
          SALOMEDS::ChildIterator_wrap it;
          if ( !mainSO->_is_nil() ) {
 -          it = myCurrentStudy->NewChildIterator( mainSO );
 +          it = getStudyServant()->NewChildIterator( mainSO );
          }
          if ( !it->_is_nil() ) {
            for ( it->InitEx(true); it->More(); it->Next() ) {
        }
      }
      if ( SObj->_is_nil() ) // publish a new subshape
 -      SObj = geomGen->AddInStudy( myCurrentStudy, geom, theGeomName, mainShape );
 +      SObj = geomGen->AddInStudy( geom, theGeomName, mainShape );
  
      // return only published geometry
      if ( !SObj->_is_nil() ) {
@@@ -2343,10 -2353,10 +2343,10 @@@ SMESH_Gen_i::FindGeometryByMeshElement
          GEOM::GEOM_Object_var geom = ShapeToGeomObject( meshDS->IndexToShape( shapeID ));
          if ( geom->_is_nil() ) {
            // try to find a published sub-shape
 -          SALOMEDS::SObject_wrap mainSO = ObjectToSObject( myCurrentStudy, mainShape );
 +          SALOMEDS::SObject_wrap mainSO = ObjectToSObject( mainShape );
            SALOMEDS::ChildIterator_wrap it;
            if ( !mainSO->_is_nil() ) {
 -            it = myCurrentStudy->NewChildIterator( mainSO );
 +            it = getStudyServant()->NewChildIterator( mainSO );
            }
            if ( !it->_is_nil() ) {
              for ( it->InitEx(true); it->More(); it->Next() ) {
          }
          if ( geom->_is_nil() ) {
            // explode
 -          GEOM::GEOM_IShapesOperations_wrap op =
 -            geomGen->GetIShapesOperations( GetCurrentStudyID() );
 +          GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
            if ( !op->_is_nil() )
              geom = op->GetSubShape( mainShape, shapeID );
          }
@@@ -2557,7 -2568,7 +2557,7 @@@ SMESH_Gen_i::ConcatenateCommon(const SM
            int _assert[( nbNames == SMESH::NB_ELEMENT_TYPES ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
          }
          string groupName = "Gr";
 -        SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, theMeshesArray[i] );
 +        SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( theMeshesArray[i] );
          if ( aMeshSObj ) {
            CORBA::String_var name = aMeshSObj->GetName();
            groupName += name;
    }
  
    // IPAL21468 Change icon of compound because it need not be computed.
 -  SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( myCurrentStudy, aNewMesh );
 +  SALOMEDS::SObject_wrap aMeshSObj = ObjectToSObject( aNewMesh );
    SetPixMap( aMeshSObj, "ICON_SMESH_TREE_MESH" );
  
    if (aNewMeshDS)
@@@ -2758,7 -2769,7 +2758,7 @@@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Copy
    SMESH_Mesh_i*       newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
    if ( !newMesh_i )
      THROW_SALOME_CORBA_EXCEPTION( "can't create a mesh", SALOME::INTERNAL_ERROR );
 -  SALOMEDS::SObject_wrap meshSO = ObjectToSObject(myCurrentStudy, newMesh );
 +  SALOMEDS::SObject_wrap meshSO = ObjectToSObject( newMesh );
    if ( !meshSO->_is_nil() )
    {
      SetName( meshSO, meshName, "Mesh" );
    return newMesh._retn();
  }
  
 +//================================================================================
 +/*!
 + * \brief Get version of MED format being used.
 + */
 +//================================================================================
 +
 +char* SMESH_Gen_i::GetMEDFileVersion()
 +{
 +  MED::TInt majeur, mineur, release;
 +  majeur =  mineur = release = 0;
 +  MED::GetVersionRelease(majeur, mineur, release);
 +  std::ostringstream version;
 +  version << majeur << "." << mineur << "." << release;
 +  return CORBA::string_dup( version.str().c_str() );
 +}
 +
  //================================================================================
  /*!
   *  SMESH_Gen_i::GetMEDVersion
   *  Get MED version of the file by its name
   */
  //================================================================================
 -CORBA::Boolean SMESH_Gen_i::GetMEDVersion(const char* theFileName,
 -                                          SMESH::MED_VERSION& theVersion)
 +char* SMESH_Gen_i::GetMEDVersion(const char* theFileName)
  {
 -  theVersion = SMESH::MED_V2_1;
 -  MED::EVersion aVersion = MED::GetVersionId( theFileName );
 -  switch( aVersion ) {
 -    case MED::eV2_1     : theVersion = SMESH::MED_V2_1;    return true;
 -    case MED::eV2_2     : theVersion = SMESH::MED_V2_2;    return true;
 -    case MED::eLATEST   : theVersion = SMESH::MED_LATEST;  return true;
 -    case MED::eMINOR_0  : theVersion = SMESH::MED_MINOR_0; return true;
 -    case MED::eMINOR_1  : theVersion = SMESH::MED_MINOR_1; return true;
 -    case MED::eMINOR_2  : theVersion = SMESH::MED_MINOR_2; return true;
 -    case MED::eMINOR_3  : theVersion = SMESH::MED_MINOR_3; return true;
 -    case MED::eMINOR_4  : theVersion = SMESH::MED_MINOR_4; return true;
 -    case MED::eMINOR_5  : theVersion = SMESH::MED_MINOR_5; return true;
 -    case MED::eMINOR_6  : theVersion = SMESH::MED_MINOR_6; return true;
 -    case MED::eMINOR_7  : theVersion = SMESH::MED_MINOR_7; return true;
 -    case MED::eMINOR_8  : theVersion = SMESH::MED_MINOR_8; return true;
 -    case MED::eMINOR_9  : theVersion = SMESH::MED_MINOR_9; return true;
 -    case MED::eVUnknown : return false;
 -  }
 -  return false;
 +  std::string version = MED::GetMEDVersion( theFileName );
 +  return CORBA::string_dup( version.c_str() );
 +}
 +
 +//================================================================================
 +/*!
 + *  SMESH_Gen_i::CheckCompatibility
 + *
 + *  Check compatibility of file with MED format being used.
 + */
 +//================================================================================
 +CORBA::Boolean SMESH_Gen_i::CheckCompatibility(const char* theFileName)
 +{
 +  return MED::CheckCompatibility( theFileName );
  }
  
  //================================================================================
  SMESH::string_array* SMESH_Gen_i::GetMeshNames(const char* theFileName)
  {
    SMESH::string_array_var aResult = new SMESH::string_array();
 -  MED::PWrapper aMed = MED::CrWrapper( theFileName );
 +  MED::PWrapper aMed = MED::CrWrapperR( theFileName );
    MED::TErr anErr;
    MED::TInt aNbMeshes = aMed->GetNbMeshes( &anErr );
    if( anErr >= 0 ) {
@@@ -3024,13 -3025,16 +3024,13 @@@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( S
                                        const char*              theURL,
                                        bool                     isMultiFile )
  {
 -  //  ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() )
 -  // san -- in case <myCurrentStudy> differs from theComponent's study,
 -  // use that of the component
 -  if ( theComponent->GetStudy()->StudyId() != GetCurrentStudyID() )
 -    SetCurrentStudy( theComponent->GetStudy() );
 +  if (!myStudyContext)
 +    UpdateStudy();
  
    // Store study contents as a set of python commands
 -  SavePython(myCurrentStudy);
 +  SavePython();
  
 -  StudyContext* myStudyContext = GetCurrentStudyContext();
 +  SALOMEDS::Study_var aStudy = getStudyServant();
  
    // Declare a byte stream
    SALOMEDS::TMPFile_var aStreamFile;
      ( isMultiFile ) ? TCollection_AsciiString( ( char* )theURL ) : ( char* )SALOMEDS_Tool::GetTmpDir().c_str();
  
    // Create a sequence of files processed
 -  SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
 -  aFileSeq->length( NUM_TMP_FILES );
 +  SALOMEDS_Tool::ListOfFiles aFileSeq;
 +  aFileSeq.reserve( NUM_TMP_FILES );
  
    TCollection_AsciiString aStudyName( "" );
    if ( isMultiFile )
 -    aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ).c_str() );
 +    aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(aStudy->URL()) ).c_str() );
  
    // Set names of temporary files
    TCollection_AsciiString filename =
      aStudyName + TCollection_AsciiString( "_SMESH.hdf" );        // for SMESH data itself
    TCollection_AsciiString meshfile =
      aStudyName + TCollection_AsciiString( "_SMESH_Mesh.med" );   // for mesh data to be stored in MED file
 -  aFileSeq[ 0 ] = CORBA::string_dup( filename.ToCString() );
 -  aFileSeq[ 1 ] = CORBA::string_dup( meshfile.ToCString() );
 +  aFileSeq.push_back(CORBA::string_dup( filename.ToCString() ));
 +  aFileSeq.push_back(CORBA::string_dup( meshfile.ToCString() ));
    filename = tmpDir + filename;
    meshfile = tmpDir + meshfile;
  
    // SetStoreName() to groups before storing hypotheses to let them refer to
    // groups using "store name", which is "Group <group_persistent_id>"
    {
 -    SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( theComponent );
 +    SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( theComponent );
      for ( ; itBig->More(); itBig->Next() ) {
        SALOMEDS::SObject_wrap gotBranch = itBig->Value();
        if ( gotBranch->Tag() > GetAlgorithmsRootTag() ) {
    aFile->CreateOnDisk();
  
    // --> iterator for top-level objects
 -  SALOMEDS::ChildIterator_wrap itBig = myCurrentStudy->NewChildIterator( theComponent );
 +  SALOMEDS::ChildIterator_wrap itBig = aStudy->NewChildIterator( theComponent );
    for ( ; itBig->More(); itBig->Next() ) {
      SALOMEDS::SObject_wrap gotBranch = itBig->Value();
  
        aTopGroup->CreateOnDisk();
  
        // iterator for all hypotheses
 -      SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( gotBranch );
 +      SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( gotBranch );
        for ( ; it->More(); it->Next() ) {
          SALOMEDS::SObject_wrap mySObject = it->Value();
          CORBA::Object_var anObject = SObjectToObject( mySObject );
        aTopGroup->CreateOnDisk();
  
        // iterator for all algorithms
 -      SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( gotBranch );
 +      SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( gotBranch );
        for ( ; it->More(); it->Next() ) {
          SALOMEDS::SObject_wrap mySObject = it->Value();
          CORBA::Object_var anObject = SObjectToObject( mySObject );
              SALOMEDS::SObject_wrap myHypBranch;
              found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch.inout() );
              if ( found && !shapeRefFound && hasShape) { // remove applied hyps
 -              myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch );
 +              aStudy->NewBuilder()->RemoveObjectWithChildren( myHypBranch );
              }
              if ( found && (shapeRefFound || !hasShape) ) {
                aGroup = new HDFgroup( "Applied Hypotheses", aTopGroup );
                aGroup->CreateOnDisk();
  
 -              SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myHypBranch );
 +              SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myHypBranch );
                int hypNb = 0;
                for ( ; it->More(); it->Next() ) {
                  SALOMEDS::SObject_wrap mySObject = it->Value();
              found = gotBranch->FindSubObject( GetRefOnAppliedAlgorithmsTag(),
                                                myAlgoBranch.inout() );
              if ( found && !shapeRefFound && hasShape) { // remove applied algos
 -              myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch );
 +              aStudy->NewBuilder()->RemoveObjectWithChildren( myAlgoBranch );
              }
              if ( found && (shapeRefFound || !hasShape)) {
                aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
                aGroup->CreateOnDisk();
  
 -              SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myAlgoBranch );
 +              SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myAlgoBranch );
                int algoNb = 0;
                for ( ; it->More(); it->Next() ) {
                  SALOMEDS::SObject_wrap mySObject = it->Value();
                {
                  bool hasShapeRef = false;
                  SALOMEDS::ChildIterator_wrap itSM =
 -                  myCurrentStudy->NewChildIterator( mySubmeshBranch );
 +                  aStudy->NewChildIterator( mySubmeshBranch );
                  for ( ; itSM->More(); itSM->Next() ) {
                    SALOMEDS::SObject_wrap mySubRef, myShape, mySObject = itSM->Value();
                    if ( mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef.inout() ))
                          }
                        }
                      }
 -                    myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( mySObject );
 +                    aStudy->NewBuilder()->RemoveObjectWithChildren( mySObject );
                    }
                  } // loop on submeshes of a type
                  if ( !shapeRefFound || !hasShapeRef ) { // remove the whole submeshes branch
 -                  myCurrentStudy->NewBuilder()->RemoveObjectWithChildren( mySubmeshBranch );
 +                  aStudy->NewBuilder()->RemoveObjectWithChildren( mySubmeshBranch );
                    found = false;
                  }
                }  // end check if there is shape reference in submeshes
                  aGroup->CreateOnDisk();
  
                  // iterator for all submeshes of given type
 -                SALOMEDS::ChildIterator_wrap itSM = myCurrentStudy->NewChildIterator( mySubmeshBranch );
 +                SALOMEDS::ChildIterator_wrap itSM = aStudy->NewChildIterator( mySubmeshBranch );
                  for ( ; itSM->More(); itSM->Next() ) {
                    SALOMEDS::SObject_wrap mySObject = itSM->Value();
                    CORBA::Object_var anSubObject = SObjectToObject( mySObject );
                        aSubSubGroup = new HDFgroup( "Applied Hypotheses", aSubGroup );
                        aSubSubGroup->CreateOnDisk();
  
 -                      SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( mySubHypBranch );
 +                      SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( mySubHypBranch );
                        int hypNb = 0;
                        for ( ; it->More(); it->Next() ) {
                          SALOMEDS::SObject_wrap mySubSObject = it->Value();
                        aSubSubGroup->CreateOnDisk();
  
                        SALOMEDS::ChildIterator_wrap it =
 -                        myCurrentStudy->NewChildIterator( mySubAlgoBranch );
 +                        aStudy->NewChildIterator( mySubAlgoBranch );
                        int algoNb = 0;
                        for ( ; it->More(); it->Next() ) {
                          SALOMEDS::SObject_wrap mySubSObject = it->Value();
                  aGroup = new HDFgroup( name_group, aTopGroup );
                  aGroup->CreateOnDisk();
  
 -                SALOMEDS::ChildIterator_wrap it = myCurrentStudy->NewChildIterator( myGroupsBranch );
 +                SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( myGroupsBranch );
                  for ( ; it->More(); it->Next() ) {
                    SALOMEDS::SObject_wrap mySObject = it->Value();
                    CORBA::Object_var aSubObject = SObjectToObject( mySObject );
    delete aFile;
  
    // Convert temporary files to stream
 -  aStreamFile = SALOMEDS_Tool::PutFilesToStream( tmpDir.ToCString(), aFileSeq.in(), isMultiFile );
 +  aStreamFile = SALOMEDS_Tool::PutFilesToStream( tmpDir.ToCString(), aFileSeq, isMultiFile );
  
    // Remove temporary files and directory
    if ( !isMultiFile )
 -    SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq.in(), true );
 +    SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq, true );
  
    return aStreamFile._retn();
  }
@@@ -4007,7 -4011,11 +4007,7 @@@ void SMESH_Gen_i::loadGeomData( SALOMED
    if ( theCompRoot->_is_nil() )
      return;
  
 -  SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theCompRoot->GetStudy() );
 -  if ( aStudy->_is_nil() )
 -    return;
 -
 -  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
 +  SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
    aStudyBuilder->LoadWith( theCompRoot, GetGeomEngine() );
  }
  
@@@ -4024,27 -4032,30 +4024,27 @@@ bool SMESH_Gen_i::Load( SALOMEDS::SComp
                          const char*              theURL,
                          bool                     isMultiFile )
  {
 -  if ( theComponent->GetStudy()->StudyId() != GetCurrentStudyID() )
 -    SetCurrentStudy( theComponent->GetStudy() );
 -
 +  if (!myStudyContext)
 +    UpdateStudy();
 +  SALOMEDS::Study_var aStudy = getStudyServant();
    /*  if( !theComponent->_is_nil() )
        {
 -      //SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( theComponent->GetStudy() );
 -      if( !myCurrentStudy->FindComponent( "GEOM" )->_is_nil() )
 -      loadGeomData( myCurrentStudy->FindComponent( "GEOM" ) );
 +      if( !aStudy->FindComponent( "GEOM" )->_is_nil() )
 +      loadGeomData( aStudy->FindComponent( "GEOM" ) );
        }*/
  
 -  StudyContext* myStudyContext = GetCurrentStudyContext();
 -
    // Get temporary files location
    TCollection_AsciiString tmpDir =
      ( char* )( isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir().c_str() );
  
    // Convert the stream into sequence of files to process
 -  SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
 -                                                                            tmpDir.ToCString(),
 -                                                                            isMultiFile );
 +  SALOMEDS_Tool::ListOfFiles aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream,
 +                                                                         tmpDir.ToCString(),
 +                                                                         isMultiFile );
    TCollection_AsciiString aStudyName( "" );
    if ( isMultiFile ) {
 -    CORBA::String_var url = myCurrentStudy->URL();
 -    aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( url.in() ).c_str();
 +    CORBA::WString_var url = aStudy->URL();
 +    aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(url.in()) ).c_str();
    }
    // Set names of temporary files
    TCollection_AsciiString filename = tmpDir + aStudyName + "_SMESH.hdf";
              aDataset->ReadFromDisk( refFromFile );
              aDataset->CloseOnDisk();
              if ( strlen( refFromFile ) > 0 ) {
 -              SALOMEDS::SObject_wrap shapeSO = myCurrentStudy->FindObjectID( refFromFile );
 +              SALOMEDS::SObject_wrap shapeSO = aStudy->FindObjectID( refFromFile );
  
                // Make sure GEOM data are loaded first
                //loadGeomData( shapeSO->GetFatherComponent() );
              aDataset->ReadFromDisk( refFromFile );
              aDataset->CloseOnDisk();
              // san - it is impossible to recover applied algorithms using their entries within Load() method
 -            //SALOMEDS::SObject_wrap hypSO = myCurrentStudy->FindObjectID( refFromFile );
 +            //SALOMEDS::SObject_wrap hypSO = aStudy->FindObjectID( refFromFile );
              //CORBA::Object_var hypObject = SObjectToObject( hypSO );
              int id = atoi( refFromFile );
              delete [] refFromFile;
              aDataset->ReadFromDisk( refFromFile );
              aDataset->CloseOnDisk();
              // san - it is impossible to recover applied hypotheses using their entries within Load() method
 -            //SALOMEDS::SObject_wrap hypSO = myCurrentStudy->FindObjectID( refFromFile );
 +            //SALOMEDS::SObject_wrap hypSO = myStudy->FindObjectID( refFromFile );
              //CORBA::Object_var hypObject = SObjectToObject( hypSO );
              int id = atoi( refFromFile );
              delete [] refFromFile;
                  aDataset->ReadFromDisk( refFromFile );
                  aDataset->CloseOnDisk();
                  if ( strlen( refFromFile ) > 0 ) {
 -                  SALOMEDS::SObject_wrap subShapeSO = myCurrentStudy->FindObjectID( refFromFile );
 +                  SALOMEDS::SObject_wrap subShapeSO = aStudy->FindObjectID( refFromFile );
                    CORBA::Object_var subShapeObject = SObjectToObject( subShapeSO );
                    if ( !CORBA::is_nil( subShapeObject ) ) {
                      aSubShapeObject = GEOM::GEOM_Object::_narrow( subShapeObject );
                  aDataset->ReadFromDisk( refFromFile );
                  aDataset->CloseOnDisk();
                  if ( strlen( refFromFile ) > 0 ) {
 -                  SALOMEDS::SObject_wrap shapeSO = myCurrentStudy->FindObjectID( refFromFile );
 +                  SALOMEDS::SObject_wrap shapeSO = aStudy->FindObjectID( refFromFile );
                    CORBA::Object_var shapeObject = SObjectToObject( shapeSO );
                    if ( !CORBA::is_nil( shapeObject ) ) {
                      aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject );
      SMESH_File meshFile( meshfile.ToCString() );
      if ( !meshFile ) // no meshfile exists
      {
 -      SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq.in(), true );
 +      SALOMEDS_Tool::RemoveTemporaryFiles( tmpDir.ToCString(), aFileSeq, true );
      }
      else
      {
  
    // creation of tree nodes for all data objects in the study
    // to support tree representation customization and drag-n-drop:
 -  SALOMEDS::Study_var                    study = theComponent->GetStudy();
 -  SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = study->GetUseCaseBuilder();
 +  SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = aStudy->GetUseCaseBuilder();
    if ( !useCaseBuilder->IsUseCaseNode( theComponent ) ) {
      useCaseBuilder->SetRootCurrent();
      useCaseBuilder->Append( theComponent ); // component object is added as the top level item
 -    SALOMEDS::ChildIterator_wrap it = study->NewChildIterator( theComponent );
 +    SALOMEDS::ChildIterator_wrap it = aStudy->NewChildIterator( theComponent );
      for (it->InitEx(true); it->More(); it->Next()) {
        useCaseBuilder->AppendTo( it->Value()->GetFather(), it->Value() );
      }
@@@ -4942,13 -4954,22 +4942,13 @@@ void SMESH_Gen_i::Close( SALOMEDS::SCom
  {
    if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Close" );
  
 -  // set correct current study
 -  SALOMEDS::Study_var study = theComponent->GetStudy();
 -  if ( study->StudyId() != GetCurrentStudyID())
 -    setCurrentStudy( study, /*IsBeingClosed=*/true );
 -
    // Clear study contexts data
 -  int studyId = GetCurrentStudyID();
 -  if ( myStudyContextMap.find( studyId ) != myStudyContextMap.end() ) {
 -    delete myStudyContextMap[ studyId ];
 -    myStudyContextMap.erase( studyId );
 -  }
 +  delete myStudyContext;
 +  myStudyContext = 0;
  
    // remove the tmp files meshes are loaded from
    SMESH_PreMeshInfo::RemoveStudyFiles_TMP_METHOD( theComponent );
  
 -  myCurrentStudy = SALOMEDS::Study::_nil();
    return;
  }
  
@@@ -4981,6 -5002,7 +4981,6 @@@ char* SMESH_Gen_i::IORToLocalPersistent
                                             CORBA::Boolean        /*isASCII*/ )
  {
    if(MYDEBUG) MESSAGE( "SMESH_Gen_i::IORToLocalPersistentID" );
 -  StudyContext* myStudyContext = GetCurrentStudyContext();
  
    if ( myStudyContext && strcmp( IORString, "" ) != 0 ) {
      int anId = myStudyContext->findId( IORString );
@@@ -5008,6 -5030,7 +5008,6 @@@ char* SMESH_Gen_i::LocalPersistentIDToI
                                             CORBA::Boolean        /*isASCII*/ )
  {
    if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LocalPersistentIDToIOR(): id = " << aLocalPersistentID );
 -  StudyContext* myStudyContext = GetCurrentStudyContext();
  
    if ( myStudyContext && strcmp( aLocalPersistentID, "" ) != 0 ) {
      int anId = atoi( aLocalPersistentID );
  
  int SMESH_Gen_i::RegisterObject(CORBA::Object_ptr theObject)
  {
 -  StudyContext* myStudyContext = GetCurrentStudyContext();
    if ( myStudyContext && !CORBA::is_nil( theObject )) {
      CORBA::String_var iorString = GetORB()->object_to_string( theObject );
      return myStudyContext->addObject( string( iorString.in() ) );
  
  CORBA::Long SMESH_Gen_i::GetObjectId(CORBA::Object_ptr theObject)
  {
 -  StudyContext* myStudyContext = GetCurrentStudyContext();
    if ( myStudyContext && !CORBA::is_nil( theObject )) {
      string iorString = GetORB()->object_to_string( theObject );
      return myStudyContext->findId( iorString );
@@@ -5059,13 -5084,18 +5059,13 @@@ void SMESH_Gen_i::SetName(const char* t
  {
    if ( theIOR && strcmp( theIOR, "" ) ) {
      CORBA::Object_var anObject = GetORB()->string_to_object( theIOR );
 -    SALOMEDS::SObject_wrap aSO = ObjectToSObject( myCurrentStudy, anObject );
 +    SALOMEDS::SObject_wrap aSO = ObjectToSObject( anObject );
      if ( !aSO->_is_nil() ) {
        SetName( aSO, theName );
      }
    }
  }
  
 -int SMESH_Gen_i::GetCurrentStudyID()
 -{
 -  return myCurrentStudy->_is_nil() || myCurrentStudy->_non_existent() ? -1 : myCurrentStudy->StudyId();
 -}
 -
  // Version information
  char* SMESH_Gen_i::getVersion()
  {
@@@ -5087,8 -5117,9 +5087,8 @@@ void SMESH_Gen_i::Move( const SMESH::so
  {
    if ( CORBA::is_nil( where ) ) return;
  
 -  SALOMEDS::Study_var study = where->GetStudy();
 -  SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
 -  SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
 +  SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
 +  SALOMEDS::UseCaseBuilder_var useCaseBuilder = getStudyServant()->GetUseCaseBuilder();
    SALOMEDS::SComponent_var father = where->GetFatherComponent();
    std::string dataType = father->ComponentDataType();
    if ( dataType != "SMESH" ) return; // not a SMESH component
index abeb3777d4153fdcf4543be1cbcc834c84cf8960,e5bd4f95ddc4ebe46783068c5ce8b2e5f5b45112..a0667465611147aab0f9b9af9bea00c3f6201736
@@@ -152,12 -152,11 +152,12 @@@ public
    // Get CORBA object corresponding to the SALOMEDS::SObject
    static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject );
    // Get the SALOMEDS::SObject corresponding to a CORBA object
 -  static SALOMEDS::SObject_ptr ObjectToSObject(SALOMEDS::Study_ptr theStudy,
 -                                               CORBA::Object_ptr   theObject);
 +  static SALOMEDS::SObject_ptr ObjectToSObject(CORBA::Object_ptr theObject);
 +  // Get the SALOMEDS::Study from naming service
 +  static SALOMEDS::Study_ptr getStudyServant();
-   // Get GEOM Object correspoding to TopoDS_Shape
+   // Get GEOM Object corresponding to TopoDS_Shape
    GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape );
-   // Get TopoDS_Shape correspoding to GEOM_Object
+   // Get TopoDS_Shape corresponding to GEOM_Object
    TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject);
  
    // Default constructor
    //GEOM::GEOM_Gen_ptr SetGeomEngine( const char* containerLoc );
    void SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo );
  
 -  // Set current study
 +  // Set embedded mode
    void SetEmbeddedMode( CORBA::Boolean theMode );
 -  // Get current study
 +  // Check embedded mode
    CORBA::Boolean IsEmbeddedMode();
  
 -  // Set current study
 -  void SetCurrentStudy( SALOMEDS::Study_ptr theStudy );
 -  // Get current study
 -  SALOMEDS::Study_ptr GetCurrentStudy();
 +  // Set enable publishing in the study
 +  void SetEnablePublish( CORBA::Boolean theIsEnablePublish );
 +
 +  // Check enable publishing
 +  CORBA::Boolean IsEnablePublish();
 +
 +  // Update study
 +  void UpdateStudy();
  
    // Create hypothesis/algorothm of given type
    SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType,
                                          SMESH::long_array&    theShapesId )
      throw ( SALOME::SALOME_Exception );
  
-   // Returns errors of hypotheses definintion
+   // Returns errors of hypotheses definition
    SMESH::algo_error_array* GetAlgoState( SMESH::SMESH_Mesh_ptr theMesh,
                                           GEOM::GEOM_Object_ptr theSubObject )
        throw ( SALOME::SALOME_Exception );
                                                CORBA::Double                 mergeTolerance)
      throw ( SALOME::SALOME_Exception );
  
 +  // Get version of MED format being used.
 +  char* GetMEDFileVersion();
 +
    // Get MED version of the file by its name
 -  CORBA::Boolean GetMEDVersion(const char* theFileName,
 -                               SMESH::MED_VERSION& theVersion);
 +  char* GetMEDVersion(const char* theFileName);
 +
 +  // Check compatibility of file with MED format being used.
 +  CORBA::Boolean CheckCompatibility(const char* theFileName);
  
    // Get names of meshes defined in file with the specified name
    SMESH::string_array* GetMeshNames(const char* theFileName);
    // Returns true if object can be published in the study
    bool CanPublishInStudy( CORBA::Object_ptr theIOR );
    // Publish object in the study
 -  SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::Study_ptr   theStudy,
 -                                        SALOMEDS::SObject_ptr theSObject,
 +  SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::SObject_ptr theSObject,
                                          CORBA::Object_ptr     theObject,
                                          const char*           theName )
      throw ( SALOME::SALOME_Exception );
    // Dump python
    // ============
  
 -  virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
 -                                       CORBA::Boolean isPublished,
 +  virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
                                         CORBA::Boolean isMultiFile,
                                         CORBA::Boolean& isValidScript);
  
 -  void AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString);
 +  void AddToPythonScript (const TCollection_AsciiString& theString);
  
 -  void RemoveLastFromPythonScript (int theStudyID);
 +  void RemoveLastFromPythonScript();
  
 -  void SavePython (SALOMEDS::Study_ptr theStudy);
 +  void SavePython();
  
 -  TCollection_AsciiString DumpPython_impl (SALOMEDS::Study_ptr theStudy,
 -                                           Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
 +  TCollection_AsciiString DumpPython_impl (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
                                             Resource_DataMapOfAsciiStringAsciiString& theNames,
                                             bool isPublished,
                                             bool isMultiFile,
                                             bool& aValidScript,
                                             TCollection_AsciiString& theSavedTrace);
  
 -  TCollection_AsciiString GetNewPythonLines (int theStudyID);
 +  TCollection_AsciiString GetNewPythonLines();
  
 -  void CleanPythonTrace (int theStudyID);
 +  void CleanPythonTrace();
  
    // *****************************************
    // Internal methods
@@@ -524,26 -517,33 +524,26 @@@ public
    static long GetBallElementsGroupsTag();
  
    // publishing methods
 -  SALOMEDS::SComponent_ptr PublishComponent(SALOMEDS::Study_ptr theStudy);
 -  SALOMEDS::SObject_ptr PublishMesh (SALOMEDS::Study_ptr   theStudy,
 -                                     SMESH::SMESH_Mesh_ptr theMesh,
 +  SALOMEDS::SComponent_ptr PublishComponent();
 +  SALOMEDS::SObject_ptr PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
                                       const char*           theName = 0);
 -  SALOMEDS::SObject_ptr PublishHypothesis (SALOMEDS::Study_ptr         theStudy,
 -                                           SMESH::SMESH_Hypothesis_ptr theHyp,
 +  SALOMEDS::SObject_ptr PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
                                             const char*                 theName = 0);
 -  SALOMEDS::SObject_ptr PublishSubMesh (SALOMEDS::Study_ptr      theStudy,
 -                                        SMESH::SMESH_Mesh_ptr    theMesh,
 +  SALOMEDS::SObject_ptr PublishSubMesh (SMESH::SMESH_Mesh_ptr    theMesh,
                                          SMESH::SMESH_subMesh_ptr theSubMesh,
                                          GEOM::GEOM_Object_ptr    theShapeObject,
                                          const char*              theName = 0);
 -  SALOMEDS::SObject_ptr PublishGroup (SALOMEDS::Study_ptr    theStudy,
 -                                      SMESH::SMESH_Mesh_ptr  theMesh,
 +  SALOMEDS::SObject_ptr PublishGroup (SMESH::SMESH_Mesh_ptr  theMesh,
                                        SMESH::SMESH_GroupBase_ptr theGroup,
                                        GEOM::GEOM_Object_ptr  theShapeObject,
                                        const char*            theName = 0);
 -  bool AddHypothesisToShape(SALOMEDS::Study_ptr         theStudy,
 -                            SMESH::SMESH_Mesh_ptr       theMesh,
 +  bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr       theMesh,
                              GEOM::GEOM_Object_ptr       theShapeObject,
                              SMESH::SMESH_Hypothesis_ptr theHyp);
 -  bool RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy,
 -                                 SMESH::SMESH_Mesh_ptr       theMesh,
 +  bool RemoveHypothesisFromShape(SMESH::SMESH_Mesh_ptr       theMesh,
                                   GEOM::GEOM_Object_ptr       theShapeObject,
                                   SMESH::SMESH_Hypothesis_ptr theHyp);
 -  SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr   theStudy,
 -                                                 SMESH::SMESH_Mesh_ptr theMesh,
 +  SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
                                                   GEOM::GEOM_Object_ptr theShape);
    static void SetName(SALOMEDS::SObject_ptr theSObject,
                        const char*           theName,
                          const char*           thePixMap);
  
    //  Get study context
 -  StudyContext* GetCurrentStudyContext();
 +  StudyContext* GetStudyContext();
  
    // Register an object in a StudyContext; return object id
    int RegisterObject(CORBA::Object_ptr theObject);
    template<class TInterface>
      typename TInterface::_var_type GetObjectByOldId( const int oldID )
    {
 -    if ( StudyContext* myStudyContext = GetCurrentStudyContext() ) {
 +    if ( myStudyContext ) {
        std::string ior = myStudyContext->getIORbyOldId( oldID );
        if ( !ior.empty() )
          return TInterface::_narrow(GetORB()->string_to_object( ior.c_str() ));
      return TInterface::_nil();
    }
  
 -  // Get current study ID
 -  int GetCurrentStudyID();
 -
    /*!
     * \brief Find SObject for an algo
     */
@@@ -648,6 -651,9 +648,6 @@@ private
                                                  const char* theCommandNameForPython,
                                                  const char* theFileNameForPython);
  
 -  void setCurrentStudy( SALOMEDS::Study_ptr theStudy,
 -                        bool                theStudyIsBeingClosed=false);
 -
    std::vector<long> _GetInside(SMESH::SMESH_IDSource_ptr meshPart,
                                 SMESH::ElementType     theElemType,
                                 TopoDS_Shape& aShape,
@@@ -665,11 -671,11 +665,11 @@@ private
    // hypotheses managing
    std::map<std::string, GenericHypothesisCreator_i*> myHypCreatorMap;
  
 -  std::map<int, StudyContext*>   myStudyContextMap;  // Map of study context objects
 +  StudyContext*                  myStudyContext;  // study context
  
    GEOM_Client*                   myShapeReader;      // Shape reader
 -  SALOMEDS::Study_var            myCurrentStudy;     // Current study
    CORBA::Boolean                 myIsEmbeddedMode;   // Current mode
 +  CORBA::Boolean                 myIsEnablePublish;  // Enable publishing
  
    // Default color of groups
    std::string myDefaultGroupColor;
    bool myToForgetMeshDataOnHypModif;
  
    // Dump Python: trace of API methods calls
 -  std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts;
 -  bool                                                     myIsHistoricalPythonDump;
 -  std::vector< int >                                       myLastParamIndex;
 -  std::vector< std::string >                               myLastParameters;
 -  std::string                                              myLastObj;
 +  Handle(TColStd_HSequenceOfAsciiString) myPythonScript;
 +  bool                                   myIsHistoricalPythonDump;
 +  std::vector< int >                     myLastParamIndex;
 +  std::vector< std::string >             myLastParameters;
 +  std::string                            myLastObj;
  };
  
  
index c9b43633cbba20c5b671f4db37b25a167d3d1e78,e434840ddec0bf0ffc29c787052ecaab81033880..6b3da78a1efcc5e3c0909a379c9bd534f64de8b7
@@@ -40,7 -40,6 +40,7 @@@
  #include <Utils_ExceptHandlers.hxx>
  #include <SALOMEDS_wrap.hxx>
  #include <SALOMEDS_Attributes_wrap.hxx>
 +#include <SALOME_KernelServices.hxx>
  
  #include <TCollection_AsciiString.hxx>
  #include <TopoDS_Solid.hxx>
@@@ -163,11 -162,10 +163,11 @@@ long SMESH_Gen_i::GetBallElementsGroups
  
  bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
  {
 -  if(MYDEBUG) MESSAGE("CanPublishInStudy - "<<!CORBA::is_nil(myCurrentStudy));
 -  if( GetCurrentStudyID() < 0 )
 -    return false;
 +  if(MYDEBUG) MESSAGE("CanPublishInStudy - "<<!CORBA::is_nil(getStudyServant()));
    
 +  if( !myIsEnablePublish )
 +    return false;
 +
    SMESH::SMESH_Mesh_var aMesh       = SMESH::SMESH_Mesh::_narrow(theIOR);
    if( !aMesh->_is_nil() )
      return true;
  //purpose  : Put a result into a SALOMEDS::SObject_wrap or call UnRegister()!
  //=======================================================================
  
 -SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(SALOMEDS::Study_ptr theStudy,
 -                                                   CORBA::Object_ptr   theObject)
 +SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(CORBA::Object_ptr theObject)
  {
    SALOMEDS::SObject_wrap aSO;
 -  if ( !CORBA::is_nil( theStudy ) && !CORBA::is_nil( theObject ))
 +  if ( !CORBA::is_nil( theObject ))
    {
      CORBA::String_var objStr = SMESH_Gen_i::GetORB()->object_to_string( theObject );
 -    aSO = theStudy->FindObjectIOR( objStr.in() );
 +    aSO = getStudyServant()->FindObjectIOR( objStr.in() );
    }
    return aSO._retn();
  }
  
 +//=======================================================================
 +//function : GetStudyPtr
 +//purpose  : Get study from naming service
 +//=======================================================================
 +SALOMEDS::Study_ptr SMESH_Gen_i::getStudyServant()
 +{
 +  return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
 +}
 +
  //=======================================================================
  //function : objectToServant
  //purpose  : 
@@@ -265,14 -255,14 +265,14 @@@ TopoDS_Shape SMESH_Gen_i::GeomObjectToS
  //purpose  : 
  //=======================================================================
  
 -static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr   theStudy,
 -                                     CORBA::Object_ptr     theIOR,
 +static SALOMEDS::SObject_ptr publish(CORBA::Object_ptr     theIOR,
                                       SALOMEDS::SObject_ptr theFatherObject,
                                       const int             theTag = 0,
                                       const char*           thePixMap = 0,
                                       const bool            theSelectable = true)
  {
 -  SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theStudy, theIOR );
 +  SALOMEDS::Study_var theStudy = SMESH_Gen_i::getStudyServant();
 +  SALOMEDS::SObject_wrap SO = SMESH_Gen_i::ObjectToSObject( theIOR );
    SALOMEDS::StudyBuilder_var     aStudyBuilder = theStudy->NewBuilder();
    SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder();
    bool isNewSO = false, isInUseCaseTree = false;
@@@ -366,7 -356,8 +366,7 @@@ void SMESH_Gen_i::SetName(SALOMEDS::SOb
                            const char*           theDefaultName)
  {
    if ( !theSObject->_is_nil() ) {
 -    SALOMEDS::Study_var               aStudy = theSObject->GetStudy();
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
      SALOMEDS::GenericAttribute_wrap   anAttr =
        aStudyBuilder->FindOrCreateAttribute( theSObject, "AttributeName" );
      SALOMEDS::AttributeName_wrap aNameAttr = anAttr;
@@@ -398,7 -389,8 +398,7 @@@ void SMESH_Gen_i::SetPixMap(SALOMEDS::S
  {
    if ( !theSObject->_is_nil() && thePixMap && strlen( thePixMap ))
    {
 -    SALOMEDS::Study_var               aStudy = theSObject->GetStudy();
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
      SALOMEDS::GenericAttribute_wrap anAttr =
        aStudyBuilder->FindOrCreateAttribute( theSObject, "AttributePixMap" );
      SALOMEDS::AttributePixMap_wrap aPMAttr = anAttr;
  //purpose  : 
  //=======================================================================
  
 -static void addReference (SALOMEDS::Study_ptr   theStudy,
 -                          SALOMEDS::SObject_ptr theSObject,
 +static void addReference (SALOMEDS::SObject_ptr theSObject,
                            CORBA::Object_ptr     theToObject,
                            int                   theTag = 0)
  {
 -  SALOMEDS::SObject_wrap aToObjSO = SMESH_Gen_i::ObjectToSObject( theStudy, theToObject );
 +  SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
 +  SALOMEDS::SObject_wrap aToObjSO = SMESH_Gen_i::ObjectToSObject( theToObject );
    if ( !aToObjSO->_is_nil() && !theSObject->_is_nil() ) {
 -    SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
 +    SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
      SALOMEDS::SObject_wrap aReferenceSO;
      if ( !theTag ) {
        // check if the reference to theToObject already exists
        // and find a free label for the reference object
        bool isReferred = false;
        int tag = 1;
 -      SALOMEDS::ChildIterator_wrap anIter = theStudy->NewChildIterator( theSObject );
 +      SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( theSObject );
        for ( ; !isReferred && anIter->More(); anIter->Next(), ++tag ) {
          SALOMEDS::SObject_wrap curSO = anIter->Value();
          if ( curSO->ReferencedObject( aReferenceSO.inout() )) {
  
      // add reference to the use case tree
      // (to support tree representation customization and drag-n-drop)
 -    SALOMEDS::UseCaseBuilder_wrap  useCaseBuilder = theStudy->GetUseCaseBuilder();
 +    SALOMEDS::UseCaseBuilder_wrap  useCaseBuilder = aStudy->GetUseCaseBuilder();
      SALOMEDS::UseCaseIterator_wrap    useCaseIter = useCaseBuilder->GetUseCaseIterator(theSObject);
      for ( ; useCaseIter->More(); useCaseIter->Next() )
      {
   */
  //=============================================================================
  
 -SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::Study_ptr   theStudy,
 -                                                  SALOMEDS::SObject_ptr theSObject,
 +SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::SObject_ptr theSObject,
                                                    CORBA::Object_ptr     theIOR,
                                                    const char*           theName)
       throw (SALOME::SALOME_Exception)
  {
    Unexpect aCatch(SALOME_SalomeException);
    SALOMEDS::SObject_wrap aSO;
 -  if ( CORBA::is_nil( theStudy ) || CORBA::is_nil( theIOR ))
 +  if ( CORBA::is_nil( theIOR ))
      return aSO._retn();
    if(MYDEBUG) MESSAGE("PublishInStudy");
  
    // Publishing a mesh
    SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( theIOR );
    if( !aMesh->_is_nil() )
 -    aSO = PublishMesh( theStudy, aMesh, theName );
 +    aSO = PublishMesh( aMesh, theName );
  
    // Publishing a sub-mesh
    SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( theIOR );
    if( aSO->_is_nil() && !aSubMesh->_is_nil() ) {
      GEOM::GEOM_Object_var aShapeObject = aSubMesh->GetSubShape();
      aMesh = aSubMesh->GetFather();
 -    aSO = PublishSubMesh( theStudy, aMesh, aSubMesh, aShapeObject, theName );
 +    aSO = PublishSubMesh( aMesh, aSubMesh, aShapeObject, theName );
    }
  
    // Publishing a hypothesis or algorithm
    SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theIOR );
    if ( aSO->_is_nil() && !aHyp->_is_nil() )
 -    aSO = PublishHypothesis( theStudy, aHyp );
 +    aSO = PublishHypothesis( aHyp );
  
    // Publishing a group
    SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(theIOR);
    if ( aSO->_is_nil() && !aGroup->_is_nil() ) {
      GEOM::GEOM_Object_var aShapeObject;
      aMesh = aGroup->GetMesh();
 -    aSO = PublishGroup( theStudy, aMesh, aGroup, aShapeObject, theName );
 +    aSO = PublishGroup( aMesh, aGroup, aShapeObject, theName );
    }
    if(MYDEBUG) MESSAGE("PublishInStudy_END");
  
  //purpose  : 
  //=======================================================================
  
 -SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theStudy)
 +SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent()
  {
 -  if ( CORBA::is_nil( theStudy ))
 -    return SALOMEDS::SComponent::_nil();
    if(MYDEBUG) MESSAGE("PublishComponent");
  
 -  SALOMEDS::StudyBuilder_var    aStudyBuilder  = theStudy->NewBuilder(); 
 -  SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = theStudy->GetUseCaseBuilder();
 +  SALOMEDS::StudyBuilder_var    aStudyBuilder  = getStudyServant()->NewBuilder();
 +  SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = getStudyServant()->GetUseCaseBuilder();
  
    CORBA::String_var   compDataType = ComponentDataType();
 -  SALOMEDS::SComponent_wrap father = theStudy->FindComponent( compDataType.in() );
 +  SALOMEDS::SComponent_wrap father = getStudyServant()->FindComponent( compDataType.in() );
    if ( !CORBA::is_nil( father ) ) {
      // check that the component is added to the use case browser
      if ( !useCaseBuilder->IsUseCaseNode( father ) ) {
  //purpose  : 
  //=======================================================================
  
 -SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SALOMEDS::Study_ptr   theStudy,
 -                                                SMESH::SMESH_Mesh_ptr theMesh,
 +SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
                                                  const char*           theName)
  {
 -  if ( CORBA::is_nil( theStudy ) ||
 -       CORBA::is_nil( theMesh ))
 +  if ( CORBA::is_nil( theMesh ))
      return SALOMEDS::SComponent::_nil();
    if(MYDEBUG) MESSAGE("PublishMesh--IN");
  
    // find or publish a mesh
  
 -  SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theStudy, theMesh );
 +  SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theMesh );
    if ( aMeshSO->_is_nil() )
    {
 -    SALOMEDS::SComponent_wrap father = PublishComponent( theStudy );
 +    SALOMEDS::SComponent_wrap father = PublishComponent();
      if ( father->_is_nil() )
        return aMeshSO._retn();
  
      else
        aTag++;
  
 -    aMeshSO = publish (theStudy, theMesh, father, aTag, "ICON_SMESH_TREE_MESH_WARN" );
 +    aMeshSO = publish ( theMesh, father, aTag, "ICON_SMESH_TREE_MESH_WARN" );
      if ( aMeshSO->_is_nil() )
        return aMeshSO._retn();
    }
  
    GEOM::GEOM_Object_var aShapeObject = theMesh->GetShapeToMesh();
    if ( !CORBA::is_nil( aShapeObject )) {
 -    addReference( theStudy, aMeshSO, aShapeObject, GetRefOnShapeTag() );
 +    addReference( aMeshSO, aShapeObject, GetRefOnShapeTag() );
  
      // Publish global hypotheses
  
      for ( CORBA::ULong i = 0; i < hypList->length(); i++ )
      {
        SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]);
 -      SALOMEDS::SObject_wrap so = PublishHypothesis( theStudy, aHyp );
 -      AddHypothesisToShape( theStudy, theMesh, aShapeObject, aHyp );
 +      SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp );
 +      AddHypothesisToShape( theMesh, aShapeObject, aHyp );
      }
    }
  
      SMESH::SMESH_subMesh_ptr aSubMesh = (*subIt).second->_this();
      if ( !CORBA::is_nil( aSubMesh )) {
        aShapeObject = aSubMesh->GetSubShape();
 -      SALOMEDS::SObject_wrap( PublishSubMesh( theStudy, theMesh, aSubMesh, aShapeObject ));
 +      SALOMEDS::SObject_wrap( PublishSubMesh( theMesh, aSubMesh, aShapeObject ));
      }
    }
  
        SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup );
        if ( !aGeomGroup->_is_nil() )
          aShapeObj = aGeomGroup->GetShape();
 -      SALOMEDS::SObject_wrap( PublishGroup( theStudy, theMesh, aGroup, aShapeObj ));
 +      SALOMEDS::SObject_wrap( PublishGroup( theMesh, aGroup, aShapeObj ));
      }
    }
  
  //purpose  : 
  //=======================================================================
  
 -SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theStudy,
 -                                                   SMESH::SMESH_Mesh_ptr    theMesh,
 +SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SMESH::SMESH_Mesh_ptr    theMesh,
                                                     SMESH::SMESH_subMesh_ptr theSubMesh,
                                                     GEOM::GEOM_Object_ptr    theShapeObject,
                                                     const char*              theName)
  {
 -  if (theStudy->_is_nil() || theMesh->_is_nil() ||
 -      theSubMesh->_is_nil() || theShapeObject->_is_nil() )
 +  if ( theMesh->_is_nil() || theSubMesh->_is_nil() || theShapeObject->_is_nil() )
      return SALOMEDS::SObject::_nil();
  
 -  SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theStudy, theSubMesh );
 +  SALOMEDS::SObject_wrap aSubMeshSO = ObjectToSObject( theSubMesh );
    if ( aSubMeshSO->_is_nil() )
    {
 -    SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theStudy, theMesh );
 +    SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theMesh );
      if ( aMeshSO->_is_nil() ) {
 -      aMeshSO = PublishMesh( theStudy, theMesh );
 +      aMeshSO = PublishMesh( theMesh );
        if ( aMeshSO->_is_nil())
          return SALOMEDS::SObject::_nil();
      }
      }
  
      // Find or create submesh root
 -    SALOMEDS::SObject_wrap aRootSO = publish (theStudy, CORBA::Object::_nil(),
 -                                             aMeshSO, aRootTag, 0, false );
 +    SALOMEDS::SObject_wrap aRootSO = publish ( CORBA::Object::_nil(),
 +                                               aMeshSO, aRootTag, 0, false );
      if ( aRootSO->_is_nil() )
        return aSubMeshSO._retn();
  
      SMESH::array_of_ElementType_var elemTypes = theSubMesh->GetTypes();
      const int isEmpty = ( elemTypes->length() == 0 );
      const char* pm[2] = { "ICON_SMESH_TREE_MESH", "ICON_SMESH_TREE_MESH_WARN" };
 -    aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, pm[isEmpty] );
 +    aSubMeshSO = publish ( theSubMesh, aRootSO, 0, pm[isEmpty] );
      if ( aSubMeshSO->_is_nil() )
        return aSubMeshSO._retn();
    }
  
    // Add reference to theShapeObject
  
 -  addReference( theStudy, aSubMeshSO, theShapeObject, 1 );
 +  addReference( aSubMeshSO, theShapeObject, 1 );
  
    // Publish hypothesis
  
    SMESH::ListOfHypothesis_var hypList = theMesh->GetHypothesisList( theShapeObject );
    for ( CORBA::ULong i = 0; i < hypList->length(); i++ ) {
      SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]);
 -    SALOMEDS::SObject_wrap so = PublishHypothesis( theStudy, aHyp );
 -    AddHypothesisToShape( theStudy, theMesh, theShapeObject, aHyp );
 +    SALOMEDS::SObject_wrap so = PublishHypothesis( aHyp );
 +    AddHypothesisToShape( theMesh, theShapeObject, aHyp );
    }
  
    return aSubMeshSO._retn();
  //purpose  : 
  //=======================================================================
  
 -SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SALOMEDS::Study_ptr    theStudy,
 -                                                 SMESH::SMESH_Mesh_ptr  theMesh,
 +SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SMESH::SMESH_Mesh_ptr  theMesh,
                                                   SMESH::SMESH_GroupBase_ptr theGroup,
                                                   GEOM::GEOM_Object_ptr  theShapeObject,
                                                   const char*            theName)
  {
 -  if (theStudy->_is_nil() || theMesh->_is_nil() || theGroup->_is_nil() )
 +  if (theMesh->_is_nil() || theGroup->_is_nil() )
      return SALOMEDS::SObject::_nil();
  
 -  SALOMEDS::SObject_wrap aGroupSO = ObjectToSObject( theStudy, theGroup );
 +  SALOMEDS::SObject_wrap aGroupSO = ObjectToSObject( theGroup );
    if ( aGroupSO->_is_nil() )
    {
 -    SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theStudy, theMesh );
 +    SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theMesh );
      if ( aMeshSO->_is_nil() ) {
 -      aMeshSO = PublishInStudy( theStudy, SALOMEDS::SObject::_nil(), theMesh, "");
 +      aMeshSO = PublishInStudy( SALOMEDS::SObject::_nil(), theMesh, "");
        if ( aMeshSO->_is_nil())
          return SALOMEDS::SObject::_nil();
      }
        long aRootTag = GetNodeGroupsTag() + aType - 1;
  
        // Find or create groups root
 -      SALOMEDS::SObject_wrap aRootSO = publish (theStudy, CORBA::Object::_nil(),
 -                                               aMeshSO, aRootTag, 0, false );
 +      SALOMEDS::SObject_wrap aRootSO = publish ( CORBA::Object::_nil(),
 +                                                 aMeshSO, aRootTag, 0, false );
        if ( aRootSO->_is_nil() ) return SALOMEDS::SObject::_nil();
  
        if ( aType < sizeof(aRootNames)/sizeof(char*) )
              isEmpty = ( allElemTypes[i] != theGroup->GetType() );
          }
        }
 -      aGroupSO = publish (theStudy, theGroup, aRootSO, 0, pm[isEmpty].c_str() );
 +      aGroupSO = publish ( theGroup, aRootSO, 0, pm[isEmpty].c_str() );
      }
      if ( aGroupSO->_is_nil() )
        return aGroupSO._retn();
  
    //Add reference to geometry
    if ( !theShapeObject->_is_nil() )
 -    addReference( theStudy, aGroupSO, theShapeObject, 1 );
 +    addReference( aGroupSO, theShapeObject, 1 );
  
    return aGroupSO._retn();
  }
  //=======================================================================
  
  SALOMEDS::SObject_ptr
 -  SMESH_Gen_i::PublishHypothesis (SALOMEDS::Study_ptr         theStudy,
 -                                  SMESH::SMESH_Hypothesis_ptr theHyp,
 +  SMESH_Gen_i::PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
                                    const char*                 theName)
  {
    if(MYDEBUG) MESSAGE("PublishHypothesis")
 -  if (theStudy->_is_nil() || theHyp->_is_nil())
 +  if (theHyp->_is_nil())
      return SALOMEDS::SObject::_nil();
  
    CORBA::String_var hypType = theHyp->GetName();
  
 -  SALOMEDS::SObject_wrap aHypSO = ObjectToSObject( theStudy, theHyp );
 +  SALOMEDS::SObject_wrap aHypSO = ObjectToSObject( theHyp );
    if ( aHypSO->_is_nil() )
    {
 -    SALOMEDS::SComponent_wrap father = PublishComponent( theStudy );
 +    SALOMEDS::SComponent_wrap father = PublishComponent();
      if ( father->_is_nil() )
        return aHypSO._retn();
  
      bool isAlgo = ( !SMESH::SMESH_Algo::_narrow( theHyp )->_is_nil() );
      int aRootTag = isAlgo ? GetAlgorithmsRootTag() : GetHypothesisRootTag();
      SALOMEDS::SObject_wrap aRootSO =
 -      publish (theStudy, CORBA::Object::_nil(),father, aRootTag,
 +      publish (CORBA::Object::_nil(),father, aRootTag,
                 isAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO", false);
      SetName( aRootSO, isAlgo ?  "Algorithms" : "Hypotheses" );
  
      string pluginName = myHypCreatorMap[ hypType.in() ]->GetModuleName();
      if ( pluginName != "StdMeshers" )
        aPmName = pluginName + "::" + aPmName;
 -    aHypSO = publish( theStudy, theHyp, aRootSO, 0, aPmName.c_str() );
 +    aHypSO = publish( theHyp, aRootSO, 0, aPmName.c_str() );
    }
  
    SetName( aHypSO, theName, hypType.in() );
  //=======================================================================
  
  SALOMEDS::SObject_ptr
 -  SMESH_Gen_i::GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr   theStudy,
 -                                        SMESH::SMESH_Mesh_ptr theMesh,
 +  SMESH_Gen_i::GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
                                          GEOM::GEOM_Object_ptr theShape)
  {
    if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape")
    if ( !aShape.IsNull() && mesh_i && mesh_i->GetImpl().GetMeshDS() ) {
      SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS();
      if ( aShape.IsSame( meshDS->ShapeToMesh() ))
 -      aMeshOrSubMesh = ObjectToSObject( theStudy, theMesh );
 +      aMeshOrSubMesh = ObjectToSObject( theMesh );
      else {
        int shapeID = meshDS->ShapeToIndex( aShape );
        SMESH::SMESH_subMesh_var aSubMesh = mesh_i->getSubMesh(shapeID);
        if ( !aSubMesh->_is_nil() )
 -        aMeshOrSubMesh = ObjectToSObject( theStudy, aSubMesh );
 +        aMeshOrSubMesh = ObjectToSObject( aSubMesh );
      }
    }
    if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape--END")
  //purpose  : 
  //=======================================================================
  
 -bool SMESH_Gen_i::AddHypothesisToShape(SALOMEDS::Study_ptr         theStudy,
 -                                       SMESH::SMESH_Mesh_ptr       theMesh,
 +bool SMESH_Gen_i::AddHypothesisToShape(SMESH::SMESH_Mesh_ptr       theMesh,
                                         GEOM::GEOM_Object_ptr       theShape,
                                         SMESH::SMESH_Hypothesis_ptr theHyp)
  {
    if(MYDEBUG) MESSAGE("AddHypothesisToShape")
 -  if (theStudy->_is_nil() || theMesh->_is_nil() ||
 +  if (theMesh->_is_nil() ||
        theHyp->_is_nil() || (theShape->_is_nil()
                              && theMesh->HasShapeToMesh()) )
      return false;
  
 -  SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theStudy, theMesh );
 +  SALOMEDS::SObject_wrap aMeshSO = ObjectToSObject( theMesh );
    if ( aMeshSO->_is_nil() )
 -    aMeshSO = PublishMesh( theStudy, theMesh );
 -  SALOMEDS::SObject_wrap aHypSO = PublishHypothesis( theStudy, theHyp );
 +    aMeshSO = PublishMesh( theMesh );
 +  SALOMEDS::SObject_wrap aHypSO = PublishHypothesis( theHyp );
    if ( aMeshSO->_is_nil() || aHypSO->_is_nil())
      return false;
  
    // Find a mesh or submesh referring to theShape
    SALOMEDS::SObject_wrap aMeshOrSubMesh =
 -    GetMeshOrSubmeshByShape( theStudy, theMesh, theShape );
 +    GetMeshOrSubmeshByShape( theMesh, theShape );
    if ( aMeshOrSubMesh->_is_nil() )
    {
      // publish submesh
        SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS();
        int shapeID = meshDS->ShapeToIndex( aShape );
        SMESH::SMESH_subMesh_var aSubMesh = mesh_i->getSubMesh(shapeID);
 -      aMeshOrSubMesh = PublishSubMesh( theStudy, theMesh, aSubMesh, theShape );
 +      aMeshOrSubMesh = PublishSubMesh( theMesh, aSubMesh, theShape );
      }
      if ( aMeshOrSubMesh->_is_nil() )
        return false;
    //Find or Create Applied Hypothesis root
    bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( theHyp )->_is_nil();
    SALOMEDS::SObject_wrap AHR =
 -    publish (theStudy, CORBA::Object::_nil(), aMeshOrSubMesh,
 +    publish (CORBA::Object::_nil(), aMeshOrSubMesh,
               aIsAlgo ? GetRefOnAppliedAlgorithmsTag() : GetRefOnAppliedHypothesisTag(),
               aIsAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO", false);
    SetName( AHR, aIsAlgo ? "Applied algorithms" : "Applied hypotheses" );
  
 -  addReference( theStudy, AHR, theHyp );
 +  addReference( AHR, theHyp );
  
    if(MYDEBUG) MESSAGE("AddHypothesisToShape--END")
    return true;
  //purpose  : 
  //=======================================================================
  
 -bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy,
 -                                            SMESH::SMESH_Mesh_ptr       theMesh,
 +bool SMESH_Gen_i::RemoveHypothesisFromShape(SMESH::SMESH_Mesh_ptr       theMesh,
                                              GEOM::GEOM_Object_ptr       theShape,
                                              SMESH::SMESH_Hypothesis_ptr theHyp)
  {
 -  if (theStudy->_is_nil() || theMesh->_is_nil() ||
 +  if (theMesh->_is_nil() ||
        theHyp->_is_nil() || (theShape->_is_nil()
                              && theMesh->HasShapeToMesh()))
      return false;
  
 -  SALOMEDS::SObject_wrap aHypSO = ObjectToSObject( theStudy, theHyp );
 +  SALOMEDS::SObject_wrap aHypSO = ObjectToSObject( theHyp );
    if ( aHypSO->_is_nil() )
      return false;
  
  
    // Find a mesh or sub-mesh referring to theShape
    SALOMEDS::SObject_wrap aMeshOrSubMesh =
 -    GetMeshOrSubmeshByShape( theStudy, theMesh, theShape );
 +    GetMeshOrSubmeshByShape( theMesh, theShape );
    if ( aMeshOrSubMesh->_is_nil() )
      return false;
  
    // Find and remove a reference to aHypSO
    SALOMEDS::SObject_wrap aRef, anObj;
 -  SALOMEDS::ChildIterator_wrap it = theStudy->NewChildIterator( aMeshOrSubMesh );
 +  SALOMEDS::ChildIterator_wrap it = getStudyServant()->NewChildIterator( aMeshOrSubMesh );
    bool found = false;
    for ( it->InitEx( true ); ( it->More() && !found ); it->Next() ) {
      anObj = it->Value();
      }
      if ( found )
      {
 -      SALOMEDS::StudyBuilder_var builder = theStudy->NewBuilder();
 +      SALOMEDS::StudyBuilder_var builder = getStudyServant()->NewBuilder();
        builder->RemoveObject( anObj );
      }
    }
   * \brief Stores names of variables that WILL be passes as parameters when calling
   *        some method of a given object.
   *  \param [in] theObject - the object whose a method WILL be called with \a theParameters.
-  *  \param [in] theParameters - a string contating parameters separated by ':'.
+  *  \param [in] theParameters - a string containing parameters separated by ':'.
   */
  //================================================================================
  
  void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
  {
 -  SALOMEDS::Study_var aStudy = GetCurrentStudy();
 -  if ( aStudy->_is_nil() )
 -    return;
 -
    // find variable names within theParameters
  
    myLastObj.clear();
        if ( prevPos < pos )
        {
          string val( theParameters + prevPos, theParameters + pos );
 -        if ( !aStudy->IsVariable( val.c_str() ))
 +        if ( !getStudyServant()->IsVariable( val.c_str() ))
            val.clear();
          myLastParameters.push_back( val );
          nbVars += (! myLastParameters.back().empty() );
    // (2) indices of found variables in myLastParamIndex.
  
    // remember theObject
 -  SALOMEDS::SObject_wrap aSObj =  ObjectToSObject(aStudy,theObject);
 +  SALOMEDS::SObject_wrap aSObj =  ObjectToSObject(theObject);
    if ( aSObj->_is_nil() )
      return;
    CORBA::String_var anObjEntry = aSObj->GetID();
    myLastObj = anObjEntry.in();
  
    // get a string of variable names
 -  SALOMEDS::StudyBuilder_var   aStudyBuilder = aStudy->NewBuilder();
 +  SALOMEDS::StudyBuilder_var   aStudyBuilder = getStudyServant()->NewBuilder();
    SALOMEDS::GenericAttribute_wrap     anAttr =
      aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString" );
    SALOMEDS::AttributeString_wrap aStringAttr = anAttr;
  std::vector< std::string > SMESH_Gen_i::GetAllParameters(const std::string& theObjectEntry) const
  {
    std::vector< std::string > varNames;
 -  if ( myCurrentStudy->_is_nil() )
 -    return varNames;
  
 -  SALOMEDS::SObject_wrap aSObj = myCurrentStudy->FindObjectID( theObjectEntry.c_str() );
 -  if ( myCurrentStudy->_is_nil() )
 -    return varNames;
 +  SALOMEDS::SObject_wrap aSObj = getStudyServant()->FindObjectID( theObjectEntry.c_str() );
  
    // get a string of variable names
 -  SALOMEDS::StudyBuilder_var   aStudyBuilder = myCurrentStudy->NewBuilder();
 +  SALOMEDS::StudyBuilder_var   aStudyBuilder = getStudyServant()->NewBuilder();
    SALOMEDS::GenericAttribute_wrap     anAttr =
      aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString" );
    SALOMEDS::AttributeString_wrap aStringAttr = anAttr;
  //   //const char* aParameters = theParameters;
  // //   const char* aParameters = CORBA::string_dup(theParameters);
  //   TCollection_AsciiString anInputParams;
 -//   SALOMEDS::Study_var aStudy = GetCurrentStudy();
 +//   SALOMEDS::Study_var aStudy = getStudyServant();
  //   if( !aStudy->_is_nil() ) {
  // //     SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(theParameters);
  // //     for(int j=0;j<aSections->length();j++) {
@@@ -1220,7 -1232,7 +1220,7 @@@ char* SMESH_Gen_i::GetParameters(CORBA:
  {
    CORBA::String_var aResult("");
  
 -  SALOMEDS::SObject_wrap aSObj = ObjectToSObject( myCurrentStudy, theObject );
 +  SALOMEDS::SObject_wrap aSObj = ObjectToSObject( theObject );
    if ( !aSObj->_is_nil() )
    {
      SALOMEDS::GenericAttribute_wrap attr;
index c46ae7d0c66223bb715cd1ace6b370dad1802a71,6cad2a92eb6c6fed23f9df6f5a0e75e8eca01be2..4f8809f99951434c43091235847d92b1b40eabe4
@@@ -102,7 -102,7 +102,7 @@@ namespace MeshEditor_I 
      SMDSAbs_ElementType myPreviewType; // type to show
      //!< Constructor
      TPreviewMesh(SMDSAbs_ElementType previewElements = SMDSAbs_All) {
 -      _isShapeToMesh = (_id =_studyId = 0);
 +      _isShapeToMesh = (_id = 0);
        _myMeshDS  = new SMESHDS_Mesh( _id, true );
        myPreviewType = previewElements;
      }
@@@ -2013,7 -2013,7 +2013,7 @@@ CORBA::Boolean SMESH_MeshEditor_i::Spli
  //=============================================================================
  /*!
   * Find better splitting of the given quadrangle.
-  *  \param IDOfQuad  ID of the quadrangle to be splitted.
+  *  \param IDOfQuad  ID of the quadrangle to be split.
   *  \param Criterion A criterion to choose a diagonal for splitting.
   *  \return 1 if 1-3 diagonal is better, 2 if 2-4
   *          diagonal is better, 0 if error occurs.
@@@ -5395,7 -5395,8 +5395,7 @@@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_
  {
    SMESH_Gen_i*              gen = SMESH_Gen_i::GetSMESHGen();
    SMESH::SMESH_Mesh_var    mesh = gen->CreateEmptyMesh();
 -  SALOMEDS::Study_var     study = gen->GetCurrentStudy();
 -  SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( study, mesh );
 +  SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( mesh );
    gen->SetName( meshSO, theMeshName, "Mesh" );
    gen->SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED");
  
@@@ -5690,10 -5691,7 +5690,7 @@@ CORBA::Boolean SMESH_MeshEditor_i::Doub
    if ( !CORBA::is_nil( theModifiedElems ) )
      aModifiedElems = theModifiedElems->GetListOfID();
    else
-   {
      aModifiedElems = new SMESH::long_array;
-     aModifiedElems->length( 0 );
-   }
  
    TPythonDump pyDump; // suppress dump by the next line
  
@@@ -6406,12 -6404,9 +6403,9 @@@ SMESH_MeshEditor_i::AffectedElemGroupsI
  {
    SMESH_TRY;
    SMESH::ListOfGroups_var aListOfGroups = new SMESH::ListOfGroups();
-   bool isEdgeGroup = false;
-   bool isFaceGroup = false;
-   bool isVolumeGroup = false;
-   SMESH::SMESH_Group_var aNewEdgeGroup = myMesh_i->CreateGroup(SMESH::EDGE, "affectedEdges");
-   SMESH::SMESH_Group_var aNewFaceGroup = myMesh_i->CreateGroup(SMESH::FACE, "affectedFaces");
-   SMESH::SMESH_Group_var aNewVolumeGroup = myMesh_i->CreateGroup(SMESH::VOLUME, "affectedVolumes");
+   SMESH::SMESH_Group_var aNewEdgeGroup   = SMESH::SMESH_Group::_nil();
+   SMESH::SMESH_Group_var aNewFaceGroup   = SMESH::SMESH_Group::_nil();
+   SMESH::SMESH_Group_var aNewVolumeGroup = SMESH::SMESH_Group::_nil();
  
    initData();
  
  
    SMESHDS_Mesh* aMeshDS = getMeshDS();
    TIDSortedElemSet anElems, aNodes;
-   listOfGroupToSet(theElems, aMeshDS, anElems, false);
+   bool isNodeGrp = theElems.length() ? theElems[0]->GetType() == SMESH::NODE : false;
+   listOfGroupToSet(theElems, aMeshDS, anElems, isNodeGrp);
    listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true);
  
    TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape(theShape);
    TIDSortedElemSet anAffected;
    bool aResult = aMeshEditor.AffectedElemGroupsInRegion(anElems, aNodes, aShape, anAffected);
  
    declareMeshModified( /*isReComputeSafe=*/ !aResult );
  
    TPythonDump pyDump;
-   if (aResult)
+   if ( aResult && anAffected.size() > 0 )
    {
-     int lg = anAffected.size();
      SMESH::long_array_var volumeIds = new SMESH::long_array;
-     volumeIds->length(lg);
-     SMESH::long_array_var faceIds = new SMESH::long_array;
-     faceIds->length(lg);
-     SMESH::long_array_var edgeIds = new SMESH::long_array;
-     edgeIds->length(lg);
+     SMESH::long_array_var   faceIds = new SMESH::long_array;
+     SMESH::long_array_var   edgeIds = new SMESH::long_array;
+     volumeIds->length( anAffected.size() );
+     faceIds  ->length( anAffected.size() );
+     edgeIds  ->length( anAffected.size() );
      int ivol = 0;
      int iface = 0;
      int iedge = 0;
      TIDSortedElemSet::const_iterator eIt = anAffected.begin();
      for (; eIt != anAffected.end(); ++eIt)
      {
        const SMDS_MeshElement* anElem = *eIt;
-       if (!anElem)
-         continue;
        int elemId = anElem->GetID();
-       if (myMesh->GetElementType(elemId, true) == SMDSAbs_Volume)
-         volumeIds[ivol++] = elemId;
-       else if (myMesh->GetElementType(elemId, true) == SMDSAbs_Face)
-         faceIds[iface++] = elemId;
-       else if (myMesh->GetElementType(elemId, true) == SMDSAbs_Edge)
-         edgeIds[iedge++] = elemId;
+       switch ( anElem->GetType() ) {
+       case SMDSAbs_Volume: volumeIds[ivol++] = elemId; break;
+       case SMDSAbs_Face:    faceIds[iface++] = elemId; break;
+       case SMDSAbs_Edge:    edgeIds[iedge++] = elemId; break;
+       default:;
+       }
      }
      volumeIds->length(ivol);
      faceIds->length(iface);
      edgeIds->length(iedge);
  
-     aNewVolumeGroup->Add(volumeIds);
-     aNewFaceGroup->Add(faceIds);
-     aNewEdgeGroup->Add(edgeIds);
-     isVolumeGroup = (aNewVolumeGroup->Size() > 0);
-     isFaceGroup = (aNewFaceGroup->Size() > 0);
-     isEdgeGroup = (aNewEdgeGroup->Size() > 0);
+     int nbGroups = 0;
+     if ( ivol > 0 )
+     {
+       aNewVolumeGroup = myMesh_i->CreateGroup(SMESH::VOLUME,
+                                               generateGroupName("affectedVolumes").c_str());
+       aNewVolumeGroup->Add(volumeIds);
+       aListOfGroups->length( nbGroups+1 );
+       aListOfGroups[ nbGroups++ ] = aNewVolumeGroup._retn();
+     }
+     if ( iface > 0 )
+     {
+       aNewFaceGroup = myMesh_i->CreateGroup(SMESH::FACE,
+                                             generateGroupName("affectedFaces").c_str());
+       aNewFaceGroup->Add(faceIds);
+       aListOfGroups->length( nbGroups+1 );
+       aListOfGroups[ nbGroups++ ] = aNewFaceGroup._retn();
+     }
+     if ( iedge > 0 )
+     {
+       aNewEdgeGroup = myMesh_i->CreateGroup(SMESH::EDGE,
+                                             generateGroupName("affectedEdges").c_str());
+       aNewEdgeGroup->Add(edgeIds);
+       aListOfGroups->length( nbGroups+1 );
+       aListOfGroups[ nbGroups++ ] = aNewEdgeGroup._retn();
+     }
    }
  
-   int nbGroups = 0;
-   if (isEdgeGroup)   nbGroups++;
-   if (isFaceGroup)   nbGroups++;
-   if (isVolumeGroup) nbGroups++;
-   aListOfGroups->length(nbGroups);
-   int i = 0;
-   if (isEdgeGroup)   aListOfGroups[i++] = aNewEdgeGroup._retn();
-   if (isFaceGroup)   aListOfGroups[i++] = aNewFaceGroup._retn();
-   if (isVolumeGroup) aListOfGroups[i++] = aNewVolumeGroup._retn();
    // Update Python script
  
-   pyDump << "[ ";
-   if (isEdgeGroup)   pyDump << aNewEdgeGroup << ", ";
-   if (isFaceGroup)   pyDump << aNewFaceGroup << ", ";
-   if (isVolumeGroup) pyDump << aNewVolumeGroup << ", ";
-   pyDump << "] = ";
-   pyDump << this << ".AffectedElemGroupsInRegion( "
+   pyDump << aListOfGroups << " = " << this << ".AffectedElemGroupsInRegion( "
           << &theElems << ", " << &theNodesNot << ", " << theShape << " )";
  
    return aListOfGroups._retn();
  //================================================================================
  /*!
    \brief Generated skin mesh (containing 2D cells) from 3D mesh
-    The created 2D mesh elements based on nodes of free faces of boundary volumes
+   The created 2D mesh elements based on nodes of free faces of boundary volumes
    \return TRUE if operation has been completed successfully, FALSE otherwise
  */
  //================================================================================
index 0f56d30358be2e08f92c1d5f92179a9fc4a9e4ca,76fe5989c8a613e24bedbff5489702ad24851041..a38dd896f89afe2660bf15b49ef60e6f300c3472
@@@ -104,12 -104,14 +104,12 @@@ int SMESH_Mesh_i::_idGenerator = 0
  //=============================================================================
  
  SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
 -                            SMESH_Gen_i*            gen_i,
 -                            CORBA::Long             studyId )
 +                            SMESH_Gen_i*            gen_i )
  : SALOME::GenericObj_i( thePOA )
  {
    _impl          = NULL;
    _gen_i         = gen_i;
    _id            = _idGenerator++;
 -  _studyId       = studyId;
    _editor        = NULL;
    _previewEditor = NULL;
    _preMeshInfo   = NULL;
@@@ -237,7 -239,9 +237,7 @@@ GEOM::GEOM_Object_ptr SMESH_Mesh_i::Get
          for ( ; data != _geomGroupData.end(); ++data )
            if ( data->_smeshObject->_is_equivalent( _this() ))
            {
 -            SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -            if ( study->_is_nil() ) break;
 -            SALOMEDS::SObject_wrap so = study->FindObjectID( data->_groupEntry.c_str() );
 +            SALOMEDS::SObject_wrap so = SMESH_Gen_i::getStudyServant()->FindObjectID( data->_groupEntry.c_str() );
              CORBA::Object_var     obj = _gen_i->SObjectToObject( so );
              aShapeObj = GEOM::GEOM_Object::_narrow( obj );
              break;
@@@ -402,8 -406,8 +402,8 @@@ SMESH_Mesh_i::ImportMEDFile( const char
    CreateGroupServants();
  
    int major, minor, release;
 -  if( !MED::getMEDVersion( theFileName, major, minor, release ) )
 -    major = minor = release = -1;
 +  major = minor = release = 0;
 +  MED::GetMEDVersion(theFileName, major, minor, release);
    _medFileInfo           = new SMESH::MedFileInfo();
    _medFileInfo->fileName = theFileName;
    _medFileInfo->fileSize = 0;
@@@ -443,6 -447,19 +443,6 @@@ SMESH::DriverMED_ReadStatus SMESH_Mesh_
    return ConvertDriverMEDReadStatus(status);
  }
  
 -//================================================================================
 -/*!
 - * \brief Return string representation of a MED file version comprising nbDigits
 - */
 -//================================================================================
 -
 -char* SMESH_Mesh_i::GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits)
 -{
 -  string ver = DriverMED_W_SMESHDS_Mesh::GetVersionString(MED::EVersion(version),
 -                                                          nbDigits);
 -  return CORBA::string_dup( ver.c_str() );
 -}
 -
  //=============================================================================
  /*!
   *  ImportUNVFile
@@@ -482,7 -499,8 +482,7 @@@ int SMESH_Mesh_i::ImportSTLFile( const 
    std::string name = _impl->STLToMesh( theFileName );
    if ( !name.empty() )
    {
 -    SALOMEDS::Study_var     study = _gen_i->GetCurrentStudy();
 -    SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( study, _this() );
 +    SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( _this() );
      _gen_i->SetName( meshSO, name.c_str() );
    }
  
@@@ -591,7 -609,8 +591,7 @@@ SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_
    SMESH::SMESH_Mesh_var mesh( _this() );
    if ( !SMESH_Hypothesis::IsStatusFatal(status) )
    {
 -    SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -    _gen_i->AddHypothesisToShape( study, mesh, aSubShape, anHyp );
 +    _gen_i->AddHypothesisToShape( mesh, aSubShape, anHyp );
    }
    if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
  
@@@ -676,7 -695,8 +676,7 @@@ SMESH::Hypothesis_Status SMESH_Mesh_i::
  
    if ( !SMESH_Hypothesis::IsStatusFatal(status) )
    {
 -    SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -    _gen_i->RemoveHypothesisFromShape( study, mesh, aSubShape, anHyp );
 +    _gen_i->RemoveHypothesisFromShape( mesh, aSubShape, anHyp );
    }
    // Update Python script
    if(_impl->HasShapeToMesh())
@@@ -846,8 -866,9 +846,8 @@@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::
        subMesh = createSubMesh( aSubShape );
      if ( _gen_i->CanPublishInStudy( subMesh ))
      {
 -      SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
        SALOMEDS::SObject_wrap aSO =
 -        _gen_i->PublishSubMesh( study, aMesh, subMesh, aSubShape, theName );
 +        _gen_i->PublishSubMesh( aMesh, subMesh, aSubShape, theName );
        if ( !aSO->_is_nil()) {
          // Update Python script
          TPythonDump() << aSO << " = " << aMesh << ".GetSubMesh( "
@@@ -876,25 -897,28 +876,25 @@@ void SMESH_Mesh_i::RemoveSubMesh( SMESH
      return;
  
    GEOM::GEOM_Object_var aSubShape;
 -  SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
 -  if ( !aStudy->_is_nil() )  {
 -    // Remove submesh's SObject
 -    SALOMEDS::SObject_wrap anSO = _gen_i->ObjectToSObject( aStudy, theSubMesh );
 -    if ( !anSO->_is_nil() ) {
 -      long aTag = SMESH_Gen_i::GetRefOnShapeTag();
 -      SALOMEDS::SObject_wrap anObj, aRef;
 -      if ( anSO->FindSubObject( aTag, anObj.inout() ) &&
 -           anObj->ReferencedObject( aRef.inout() ))
 -      {
 -        CORBA::Object_var obj = aRef->GetObject();
 -        aSubShape = GEOM::GEOM_Object::_narrow( obj );
 -      }
 -      // if ( aSubShape->_is_nil() ) // not published shape (IPAL13617)
 -      //   aSubShape = theSubMesh->GetSubShape();
 +  // Remove submesh's SObject
 +  SALOMEDS::SObject_wrap anSO = _gen_i->ObjectToSObject( theSubMesh );
 +  if ( !anSO->_is_nil() ) {
 +    long aTag = SMESH_Gen_i::GetRefOnShapeTag();
 +    SALOMEDS::SObject_wrap anObj, aRef;
 +    if ( anSO->FindSubObject( aTag, anObj.inout() ) &&
 +         anObj->ReferencedObject( aRef.inout() ))
 +    {
 +      CORBA::Object_var obj = aRef->GetObject();
 +      aSubShape = GEOM::GEOM_Object::_narrow( obj );
 +    }
 +    // if ( aSubShape->_is_nil() ) // not published shape (IPAL13617)
 +    //   aSubShape = theSubMesh->GetSubShape();
  
 -      SALOMEDS::StudyBuilder_var builder = aStudy->NewBuilder();
 -      builder->RemoveObjectWithChildren( anSO );
 +    SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
 +    builder->RemoveObjectWithChildren( anSO );
  
 -      // Update Python script
 -      TPythonDump() << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )";
 -    }
 +    // Update Python script
 +    TPythonDump() << SMESH::SMESH_Mesh_var( _this() ) << ".RemoveSubMesh( " << anSO << " )";
    }
  
    if ( removeSubMesh( theSubMesh, aSubShape.in() ))
@@@ -924,8 -948,9 +924,8 @@@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::Cr
    if ( _gen_i->CanPublishInStudy( aNewGroup ) )
    {
      SMESH::SMESH_Mesh_var mesh = _this();
 -    SALOMEDS::Study_var  study = _gen_i->GetCurrentStudy();
      SALOMEDS::SObject_wrap aSO =
 -      _gen_i->PublishGroup( study, mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName);
 +      _gen_i->PublishGroup( mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName);
      if ( !aSO->_is_nil())
        // Update Python script
        TPythonDump() << aSO << " = " << mesh << ".CreateGroup( "
@@@ -960,8 -985,9 +960,8 @@@ SMESH_Mesh_i::CreateGroupFromGEOM (SMES
      if ( _gen_i->CanPublishInStudy( aNewGroup ) )
      {
        SMESH::SMESH_Mesh_var mesh = _this();
 -      SALOMEDS::Study_var  study = _gen_i->GetCurrentStudy();
        SALOMEDS::SObject_wrap aSO =
 -        _gen_i->PublishGroup( study, mesh, aNewGroup, theGeomObj, theName );
 +        _gen_i->PublishGroup( mesh, aNewGroup, theGeomObj, theName );
        if ( !aSO->_is_nil())
          TPythonDump() << aSO << " = " << mesh << ".CreateGroupFromGEOM( "
                        << theElemType << ", '" << theName << "', " << theGeomObj << " )";
@@@ -1008,8 -1034,9 +1008,8 @@@ SMESH_Mesh_i::CreateGroupFromFilter(SME
    if ( _gen_i->CanPublishInStudy( aNewGroup ) )
    {
      SMESH::SMESH_Mesh_var mesh = _this();
 -    SALOMEDS::Study_var  study = _gen_i->GetCurrentStudy();
      SALOMEDS::SObject_wrap aSO =
 -      _gen_i->PublishGroup( study, mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName );
 +      _gen_i->PublishGroup( mesh, aNewGroup, GEOM::GEOM_Object::_nil(), theName );
  
      if ( !aSO->_is_nil())
        pd << aSO << " = " << mesh << ".CreateGroupFromFilter( "
@@@ -1036,15 -1063,19 +1036,15 @@@ void SMESH_Mesh_i::RemoveGroup( SMESH::
    if ( !aGroup )
      return;
  
 -  SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
 -  if ( !aStudy->_is_nil() )
 +  SALOMEDS::SObject_wrap aGroupSO = _gen_i->ObjectToSObject( theGroup );
 +  if ( !aGroupSO->_is_nil() )
    {
 -    SALOMEDS::SObject_wrap aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
 -    if ( !aGroupSO->_is_nil() )
 -    {
 -      // Update Python script
 -      TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
 +    // Update Python script
 +    TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".RemoveGroup( " << aGroupSO << " )";
  
 -      // Remove group's SObject
 -      SALOMEDS::StudyBuilder_var builder = aStudy->NewBuilder();
 -      builder->RemoveObjectWithChildren( aGroupSO );
 -    }
 +    // Remove group's SObject
 +    SALOMEDS::StudyBuilder_var builder = SMESH_Gen_i::getStudyServant()->NewBuilder();
 +    builder->RemoveObjectWithChildren( aGroupSO );
    }
    aGroup->Modified(/*removed=*/true); // notify dependent Filter with FT_BelongToMeshGroup criterion
  
@@@ -1805,13 -1836,14 +1805,13 @@@ void SMESH_Mesh_i::addGeomGroupData(GEO
    if ( CORBA::is_nil( theGeomObj ) || theGeomObj->GetType() != GEOM_GROUP )
      return;
    // group SO
 -  SALOMEDS::Study_var    study   = _gen_i->GetCurrentStudy();
 -  SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( study, theGeomObj );
 +  SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( theGeomObj );
    if ( groupSO->_is_nil() )
      return;
    // group indices
    GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine();
    GEOM::GEOM_IGroupOperations_wrap groupOp =
 -    geomGen->GetIGroupOperations( _gen_i->GetCurrentStudyID() );
 +    geomGen->GetIGroupOperations();
    GEOM::ListOfLong_var ids = groupOp->GetObjects( theGeomObj );
  
    // store data
@@@ -1859,7 -1891,9 +1859,7 @@@ TopoDS_Shape SMESH_Mesh_i::newGroupShap
    TopoDS_Shape newShape;
  
    // get geom group
 -  SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -  if ( study->_is_nil() ) return newShape; // means "not changed"
 -  SALOMEDS::SObject_wrap groupSO = study->FindObjectID( groupData._groupEntry.c_str() );
 +  SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( groupData._groupEntry.c_str() );
    if ( !groupSO->_is_nil() )
    {
      CORBA::Object_var groupObj = _gen_i->SObjectToObject( groupSO );
      set<int> curIndices;
      GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine();
      GEOM::GEOM_IGroupOperations_wrap groupOp =
 -      geomGen->GetIGroupOperations( _gen_i->GetCurrentStudyID() );
 +      geomGen->GetIGroupOperations();
      GEOM::ListOfLong_var   ids = groupOp->GetObjects( geomGroup );
      for ( CORBA::ULong i = 0; i < ids->length(); ++i )
        curIndices.insert( ids[i] );
@@@ -1935,6 -1969,9 +1935,6 @@@ void SMESH_Mesh_i::CheckGeomModif(
  {
    if ( !_impl->HasShapeToMesh() ) return;
  
 -  SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -  if ( study->_is_nil() ) return;
 -
    GEOM::GEOM_Object_var mainGO = _gen_i->ShapeToGeomObject( _impl->GetShapeToMesh() );
    //if ( mainGO->_is_nil() ) return;
  
@@@ -2081,6 -2118,9 +2081,6 @@@ void SMESH_Mesh_i::CheckGeomGroupModif(
  {
    if ( !_impl->HasShapeToMesh() ) return;
  
 -  SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -  if ( study->_is_nil() ) return;
 -
    CORBA::Long nbEntities = NbNodes() + NbElements();
  
    // Check if group contents changed
          if ( _mapGroups.find( oldID ) == _mapGroups.end() )
            continue;
          // get group name
 -        SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( study,_mapGroups[oldID] );
 +        SALOMEDS::SObject_wrap groupSO = _gen_i->ObjectToSObject( _mapGroups[oldID] );
          CORBA::String_var      name    = groupSO->GetName();
          // update
          SMESH_GroupBase_i*  group_i    = SMESH::DownCast<SMESH_GroupBase_i*>(_mapGroups[oldID] );
    if ( newNbEntities != nbEntities )
    {
      // Add all SObjects with icons to soToUpdateIcons
 -    soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, _this() )); // mesh
 +    soToUpdateIcons.push_back( _gen_i->ObjectToSObject( _this() )); // mesh
  
      for (map<int, SMESH::SMESH_subMesh_ptr>::iterator i_sm = _mapSubMeshIor.begin();
           i_sm != _mapSubMeshIor.end(); ++i_sm ) // submeshes
 -      soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, i_sm->second ));
 +      soToUpdateIcons.push_back( _gen_i->ObjectToSObject( i_sm->second ));
  
      for ( map<int, SMESH::SMESH_GroupBase_ptr>::iterator i_gr = _mapGroups.begin();
            i_gr != _mapGroups.end(); ++i_gr ) // groups
 -      soToUpdateIcons.push_back( _gen_i->ObjectToSObject( study, i_gr->second ));
 +      soToUpdateIcons.push_back( _gen_i->ObjectToSObject( i_gr->second ));
    }
  
    list< SALOMEDS::SObject_wrap >::iterator so = soToUpdateIcons.begin();
@@@ -2342,10 -2382,10 +2342,10 @@@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::Co
  
    SALOMEDS::StudyBuilder_var builder;
    SALOMEDS::SObject_wrap     aGroupSO;
 -  SALOMEDS::Study_var        aStudy = _gen_i->GetCurrentStudy();
 +  SALOMEDS::Study_var        aStudy = SMESH_Gen_i::getStudyServant();
    if ( !aStudy->_is_nil() ) {
      builder  = aStudy->NewBuilder();
 -    aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
 +    aGroupSO = _gen_i->ObjectToSObject( theGroup );
      if ( !aGroupSO->_is_nil() )
      {
        // remove reference to geometry
@@@ -2666,6 -2706,17 +2666,6 @@@ CORBA::Long SMESH_Mesh_i::GetId()throw(
    return _id;
  }
  
 -//=============================================================================
 -/*!
 - *
 - */
 -//=============================================================================
 -
 -CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception)
 -{
 -  return _studyId;
 -}
 -
  //=============================================================================
  namespace
  {
@@@ -2925,9 -2976,9 +2925,9 @@@ string SMESH_Mesh_i::prepareMeshNameAnd
    // Perform Export
    PrepareForWriting(file, overwrite);
    string aMeshName = "Mesh";
 -  SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
 +  SALOMEDS::Study_var aStudy = SMESH_Gen_i::getStudyServant();
    if ( !aStudy->_is_nil() ) {
 -    SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject( aStudy, _this() );
 +    SALOMEDS::SObject_wrap aMeshSO = _gen_i->ObjectToSObject(  _this() );
      if ( !aMeshSO->_is_nil() ) {
        CORBA::String_var name = aMeshSO->GetName();
        aMeshName = name;
  
  //================================================================================
  /*!
 - * \brief Export to med file
 + * \brief Export to MED file
   */
  //================================================================================
  
 -void SMESH_Mesh_i::ExportToMEDX (const char*        file,
 -                                 CORBA::Boolean     auto_groups,
 -                                 SMESH::MED_VERSION theVersion,
 -                                 CORBA::Boolean     overwrite,
 -                                 CORBA::Boolean     autoDimension)
 +void SMESH_Mesh_i::ExportMED(const char*        file,
 +                             CORBA::Boolean     auto_groups,
 +                             CORBA::Boolean     overwrite,
 +                             CORBA::Boolean     autoDimension)
    throw(SALOME::SALOME_Exception)
  {
    //MESSAGE("SMESH::MED_VERSION:"<< theVersion);
      _preMeshInfo->FullLoadFromFile();
  
    string aMeshName = prepareMeshNameAndGroups(file, overwrite);
 -  _impl->ExportMED( file, aMeshName.c_str(), auto_groups, theVersion, 0, autoDimension );
 +  _impl->ExportMED( file, aMeshName.c_str(), auto_groups, 0, autoDimension );
  
 -  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportToMEDX( r'"
 +  TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
                  << file << "', " << auto_groups << ", "
 -                << theVersion << ", " << overwrite << ", "
 +                << overwrite << ", "
                  << autoDimension << " )";
  
    SMESH_CATCH( SMESH::throwCorbaException );
  }
  
 -//================================================================================
 -/*!
 - * \brief Export a mesh to a med file
 - */
 -//================================================================================
 -
 -void SMESH_Mesh_i::ExportToMED (const char*        file,
 -                                CORBA::Boolean     auto_groups,
 -                                SMESH::MED_VERSION theVersion)
 -  throw(SALOME::SALOME_Exception)
 -{
 -  //MESSAGE("SMESH::MED_VERSION:"<< theVersion);
 -  ExportToMEDX(file,auto_groups,theVersion,true);
 -}
 -
 -//================================================================================
 -/*!
 - * \brief Export a mesh to a med file
 - */
 -//================================================================================
 -
 -void SMESH_Mesh_i::ExportMED (const char* file,
 -                              CORBA::Boolean auto_groups)
 -  throw(SALOME::SALOME_Exception)
 -{
 -  //MESSAGE("SMESH::MED_VERSION:"<< SMESH::MED_LATEST);
 -  ExportToMEDX(file,auto_groups,SMESH::MED_LATEST,true);
 -}
 -
  //================================================================================
  /*!
   * \brief Export a mesh to a SAUV file
@@@ -3073,7 -3154,8 +3073,7 @@@ void SMESH_Mesh_i::ExportSTL (const cha
                  << ".ExportSTL( r'" << file << "', " << isascii << " )";
  
    CORBA::String_var name;
 -  SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -  SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, _this() );
 +  SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( _this() );
    if ( !so->_is_nil() )
      name = so->GetName();
  
  void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
                                     const char*               file,
                                     CORBA::Boolean            auto_groups,
 -                                   SMESH::MED_VERSION        version,
                                     CORBA::Boolean            overwrite,
                                     CORBA::Boolean            autoDimension,
                                     const GEOM::ListOfFields& fields,
    {
      aMeshName = prepareMeshNameAndGroups(file, overwrite);
      _impl->ExportMED( file, aMeshName.c_str(), auto_groups,
 -                      version, 0, autoDimension, /*addODOnVertices=*/have0dField);
 +                      0, autoDimension, /*addODOnVertices=*/have0dField);
      meshDS = _impl->GetMeshDS();
    }
    else
  
      PrepareForWriting(file, overwrite);
  
 -    SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
 -    if ( !aStudy->_is_nil() ) {
 -      SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( aStudy, meshPart );
 -      if ( !SO->_is_nil() ) {
 -        CORBA::String_var name = SO->GetName();
 -        aMeshName = name;
 -      }
 +    SALOMEDS::SObject_wrap SO = _gen_i->ObjectToSObject( meshPart );
 +    if ( !SO->_is_nil() ) {
 +      CORBA::String_var name = SO->GetName();
 +      aMeshName = name;
      }
 +
      SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart );
      _impl->ExportMED( file, aMeshName.c_str(), auto_groups,
 -                      version, partDS, autoDimension, /*addODOnVertices=*/have0dField);
 +                      partDS, autoDimension, /*addODOnVertices=*/have0dField);
      meshDS = tmpDSDeleter._obj = partDS;
    }
  
    }
    TPythonDump() << _this() << ".ExportPartToMED( "
                  << meshPart << ", r'" << file << "', "
 -                << auto_groups << ", " << version << ", " << overwrite << ", "
 +                << auto_groups << ", " << overwrite << ", "
                  << autoDimension << ", " << goList
                  << ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
  
@@@ -3526,7 -3611,8 +3526,7 @@@ void SMESH_Mesh_i::ExportPartToSTL(::SM
    PrepareForWriting(file);
  
    CORBA::String_var name;
 -  SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -  SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, meshPart );
 +  SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( meshPart );
    if ( !so->_is_nil() )
      name = so->GetName();
  
@@@ -3557,7 -3643,8 +3557,7 @@@ void SMESH_Mesh_i::ExportCGNS(::SMESH::
    PrepareForWriting(file,overwrite);
  
    std::string meshName("");
 -  SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
 -  SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( study, meshPart );
 +  SALOMEDS::SObject_wrap so = _gen_i->ObjectToSObject( meshPart );
    if ( !so->_is_nil() )
    {
      CORBA::String_var name = so->GetName();
@@@ -4899,9 -4986,10 +4899,9 @@@ SMESH_Mesh_i::MakeGroupsOfBadInputEleme
          groups[ ++iG ] = createGroup( SMESH::ElementType(i), theGroupName );
          if ( _gen_i->CanPublishInStudy( groups[ iG ] ))
          {
 -          SALOMEDS::Study_var  study = _gen_i->GetCurrentStudy();
            SMESH::SMESH_Mesh_var mesh = _this();
            SALOMEDS::SObject_wrap aSO =
 -            _gen_i->PublishGroup( study, mesh, groups[ iG ],
 +            _gen_i->PublishGroup( mesh, groups[ iG ],
                                   GEOM::GEOM_Object::_nil(), theGroupName);
          }
          SMESH_GroupBase_i* grp_i = SMESH::DownCast< SMESH_GroupBase_i* >( groups[ iG ]);
  
  void SMESH_Mesh_i::CreateGroupServants()
  {
 -  SALOMEDS::Study_var  aStudy = _gen_i->GetCurrentStudy();
    SMESH::SMESH_Mesh_var aMesh = _this();
  
    set<int> addedIDs;
      else        { nextId = 0; } // avoid "unused variable" warning in release mode
  
      // publishing the groups in the study
 -    if ( !aStudy->_is_nil() ) {
 -      GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape );
 -      _gen_i->PublishGroup( aStudy, aMesh, groupVar, shapeVar, group->GetName());
 -    }
 +    GEOM::GEOM_Object_var shapeVar = _gen_i->ShapeToGeomObject( shape );
 +    _gen_i->PublishGroup( aMesh, groupVar, shapeVar, group->GetName());
    }
    if ( !addedIDs.empty() )
    {
@@@ -5028,6 -5119,10 +5028,6 @@@ void SMESH_Mesh_i::checkGroupNames(
    int nbGrp = NbGroups();
    if ( !nbGrp )
      return;
 -
 -  SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy();
 -  if ( aStudy->_is_nil() )
 -    return; // nothing to do
    
    SMESH::ListOfGroups* grpList = 0;
    // avoid dump of "GetGroups"
      SMESH::SMESH_GroupBase_ptr aGrp = (*grpList)[ gIndx ];
      if ( !aGrp )
        continue;
 -    SALOMEDS::SObject_wrap aGrpSO = _gen_i->ObjectToSObject( aStudy, aGrp );
 +    SALOMEDS::SObject_wrap aGrpSO = _gen_i->ObjectToSObject( aGrp );
      if ( aGrpSO->_is_nil() )
        continue;
      // correct name of the mesh group if necessary
@@@ -5084,12 -5179,15 +5084,12 @@@ SMESH::string_array* SMESH_Mesh_i::GetL
    SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
    if(gen) {
      CORBA::String_var aParameters = GetParameters();
 -    SALOMEDS::Study_var    aStudy = gen->GetCurrentStudy();
 -    if ( !aStudy->_is_nil()) {
 -      SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); 
 -      if ( aSections->length() > 0 ) {
 -        SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
 -        aResult->length( aVars.length() );
 -        for ( CORBA::ULong i = 0;i < aVars.length(); i++ )
 -          aResult[i] = CORBA::string_dup( aVars[i] );
 -      }
 +    SALOMEDS::ListOfListOfStrings_var aSections = SMESH_Gen_i::getStudyServant()->ParseVariables(aParameters);
 +    if ( aSections->length() > 0 ) {
 +      SALOMEDS::ListOfStrings aVars = aSections[ aSections->length() - 1 ];
 +      aResult->length( aVars.length() );
 +      for ( CORBA::ULong i = 0;i < aVars.length(); i++ )
 +        aResult[i] = CORBA::string_dup( aVars[i] );
      }
    }
    return aResult._retn();
@@@ -5490,10 -5588,10 +5490,10 @@@ TopAbs_ShapeEnum shapeTypeByDim(const i
  
  //-----------------------------------------------------------------------------
  /*!
-  * \brief Internal structure used to find concurent submeshes
+  * \brief Internal structure used to find concurrent submeshes
   *
-  * It represents a pair < submesh, concurent dimension >, where
-  * 'concurrent dimension' is dimension of shape where the submesh can concurent
+  * It represents a pair < submesh, concurrent dimension >, where
+  * 'concurrent dimension' is dimension of shape where the submesh can concurrent
   *  with another submesh. In other words, it is dimension of a hypothesis assigned
   *  to submesh.
   */
@@@ -5885,7 -5983,7 +5885,7 @@@ TListOfListOfInt SMESH_Mesh_i::findConc
      
      removeDimHyps(dimHypListArr);
      
-     // now, minimise the number of concurrent groups
+     // now, minimize the number of concurrent groups
      // Here we assume that lists of submeshes can have same submesh
      // in case of multi-dimension algorithms, as result
      //  list with common submesh has to be united into one list
@@@ -5982,7 -6080,7 +5982,7 @@@ void SMESH_Mesh_i::convertMeshOrder (co
        continue;
      if ( theIsDump )
        aPythonDump << "[ ";
-     // convert shape indeces into interfaces
+     // convert shape indices into interfaces
      SMESH::submesh_array_var aResSubSet = new SMESH::submesh_array();
      aResSubSet->length(aSubOrder.size());
      TListOfInt::const_iterator subIt = aSubOrder.begin();
index 0052d85e26edb48ec58b1fb78253ed7dbd730e79,0000000000000000000000000000000000000000..0828fc5e4c3f0df88770c7575551f0faae0b9c17
mode 100644,000000..100644
--- /dev/null
@@@ -1,1384 -1,0 +1,1384 @@@
-       char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
 +// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 +//
 +// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 +//
 +// This library is free software; you can redistribute it and/or
 +// modify it under the terms of the GNU Lesser General Public
 +// License as published by the Free Software Foundation; either
 +// version 2.1 of the License, or (at your option) any later version.
 +//
 +// This library is distributed in the hope that it will be useful,
 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 +// Lesser General Public License for more details.
 +//
 +// You should have received a copy of the GNU Lesser General Public
 +// License along with this library; if not, write to the Free Software
 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 +//
 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 +//
 +//  File    : SMESH_DumpPython.cxx
 +//  Created : Thu Mar 24 17:17:59 2005
 +//  Author  : Julia DOROVSKIKH
 +//  Module  : SMESH
 +
 +#include "SMESH_PythonDump.hxx"
 +
 +#include "SMESH_2smeshpy.hxx"
 +#include "SMESH_Comment.hxx"
 +#include "SMESH_Filter_i.hxx"
 +#include "SMESH_Gen_i.hxx"
 +#include "SMESH_MeshEditor_i.hxx"
 +
 +#include <SALOMEDS_wrap.hxx>
 +
 +#include <LDOMParser.hxx>
 +#include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
 +#include <TColStd_HSequenceOfInteger.hxx>
 +#include <TCollection_AsciiString.hxx>
 +
 +#ifdef _DEBUG_
 +static int MYDEBUG = 0;
 +#else
 +static int MYDEBUG = 0;
 +#endif
 +
 +#include "SMESH_TryCatch.hxx"
 +
 +namespace SMESH
 +{
 +
 +  size_t TPythonDump::myCounter = 0;
 +  const char theNotPublishedObjectName[] = "__NOT__Published__Object__";
 +
 +  TVar::TVar(CORBA::Double value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
 +  TVar::TVar(CORBA::Long   value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
 +  TVar::TVar(CORBA::Short  value):myVals(1), myIsList(false) { myVals[0] = SMESH_Comment(value); }
 +  TVar::TVar(const SMESH::double_array& value):myVals(value.length()), myIsList(true)
 +  {
 +    for ( size_t i = 0; i < value.length(); i++)
 +      myVals[i] = SMESH_Comment(value[i]);
 +  }
 +
 +  TPythonDump::
 +  TPythonDump():myVarsCounter(0)
 +  {
 +    ++myCounter;
 +  }
 +  TPythonDump::
 +  ~TPythonDump()
 +  {
 +    if(--myCounter == 0){
 +      SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
 +      std::string aString = myStream.str();
 +      TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
 +      if(!aCollection.IsEmpty())
 +      {
 +        const std::string & objEntry = SMESH_Gen_i::GetSMESHGen()->GetLastObjEntry();
 +        if ( !objEntry.empty() )
 +          aCollection += (TVar::ObjPrefix() + objEntry ).c_str();
 +        aSMESHGen->AddToPythonScript(aCollection);
 +        if(MYDEBUG) MESSAGE(aString);
 +        // prevent misuse of already treated variables
 +        aSMESHGen->UpdateParameters(CORBA::Object_var().in(),"");
 +      }
 +    }
 +  }
 +
 +  TPythonDump& //!< store a variable value. Write either a value or '$varID$'
 +  TPythonDump::
 +  operator<<(const TVar& theVarValue)
 +  {
 +    const std::vector< int >& varIDs = SMESH_Gen_i::GetSMESHGen()->GetLastParamIndices();
 +    if ( theVarValue.myIsList )
 +    {
 +      myStream << "[ ";
 +      for ( size_t i = 1; i <= theVarValue.myVals.size(); ++i )
 +      {
 +        if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
 +          myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
 +        else
 +          myStream << theVarValue.myVals[i-1];
 +        if ( i < theVarValue.myVals.size() )
 +          myStream << ", ";
 +        ++myVarsCounter;
 +      }
 +      myStream << " ]";
 +    }
 +    else
 +    {
 +      if ( myVarsCounter < (int)varIDs.size() && varIDs[ myVarsCounter ] >= 0 )
 +        myStream << TVar::Quote() << varIDs[ myVarsCounter ] << TVar::Quote();
 +      else
 +        myStream << theVarValue.myVals[0];
 +      ++myVarsCounter;
 +    }
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(long int theArg){
 +    myStream<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(int theArg){
 +    myStream<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(double theArg){
 +    myStream<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(float theArg){
 +    myStream<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(const void* theArg){
 +    myStream<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(const char* theArg){
 +    if ( theArg )
 +      myStream<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(const std::string& theArg){
 +    myStream<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(const SMESH::ElementType& theArg)
 +  {
 +    myStream<<"SMESH.";
 +    switch(theArg){
 +    case ALL:    myStream<<"ALL";    break;
 +    case NODE:   myStream<<"NODE";   break;
 +    case EDGE:   myStream<<"EDGE";   break;
 +    case FACE:   myStream<<"FACE";   break;
 +    case VOLUME: myStream<<"VOLUME"; break;
 +    case ELEM0D: myStream<<"ELEM0D"; break;
 +    case BALL:   myStream<<"BALL";   break;
 +    default:     myStream<<"__UNKNOWN__ElementType: " << theArg;
 +    }
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(const SMESH::GeometryType& theArg)
 +  {
 +    myStream<<"SMESH.";
 +    switch(theArg){
 +    case Geom_POINT:      myStream<<"Geom_POINT";      break;
 +    case Geom_EDGE:       myStream<<"Geom_EDGE";       break;
 +    case Geom_TRIANGLE:   myStream<<"Geom_TRIANGLE";   break;
 +    case Geom_QUADRANGLE: myStream<<"Geom_QUADRANGLE"; break;
 +    case Geom_POLYGON:    myStream<<"Geom_POLYGON";    break;
 +    case Geom_TETRA:      myStream<<"Geom_TETRA";      break;
 +    case Geom_PYRAMID:    myStream<<"Geom_PYRAMID";    break;
 +    case Geom_HEXA:       myStream<<"Geom_HEXA";       break;
 +    case Geom_PENTA:      myStream<<"Geom_PENTA";      break;
 +    case Geom_POLYHEDRA:  myStream<<"Geom_POLYHEDRA";  break;
 +    case Geom_BALL:       myStream<<"Geom_BALL";       break;
 +    default:    myStream<<"__UNKNOWN__GeometryType: " << theArg;
 +    }
 +    return *this;
 +  }
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(const SMESH::EntityType& theArg)
 +  {
 +    myStream<<"SMESH.";
 +    switch(theArg){
 +    case Entity_0D:                myStream<<"Entity_0D";                break;
 +    case Entity_Edge:              myStream<<"Entity_Edge";              break;
 +    case Entity_Quad_Edge:         myStream<<"Entity_Quad_Edge";         break;
 +    case Entity_Triangle:          myStream<<"Entity_Triangle";          break;
 +    case Entity_Quad_Triangle:     myStream<<"Entity_Quad_Triangle";     break;
 +    case Entity_BiQuad_Triangle:   myStream<<"Entity_BiQuad_Triangle";   break;
 +    case Entity_Quadrangle:        myStream<<"Entity_Quadrangle";        break;
 +    case Entity_Quad_Quadrangle:   myStream<<"Entity_Quad_Quadrangle";   break;
 +    case Entity_BiQuad_Quadrangle: myStream<<"Entity_BiQuad_Quadrangle"; break;
 +    case Entity_Polygon:           myStream<<"Entity_Polygon";           break;
 +    case Entity_Quad_Polygon:      myStream<<"Entity_Quad_Polygon";      break;
 +    case Entity_Tetra:             myStream<<"Entity_Tetra";             break;
 +    case Entity_Quad_Tetra:        myStream<<"Entity_Quad_Tetra";        break;
 +    case Entity_Pyramid:           myStream<<"Entity_Pyramid";           break;
 +    case Entity_Quad_Pyramid:      myStream<<"Entity_Quad_Pyramid";      break;
 +    case Entity_Hexa:              myStream<<"Entity_Hexa";              break;
 +    case Entity_Quad_Hexa:         myStream<<"Entity_Quad_Hexa";         break;
 +    case Entity_TriQuad_Hexa:      myStream<<"Entity_TriQuad_Hexa";      break;
 +    case Entity_Penta:             myStream<<"Entity_Penta";             break;
 +    case Entity_Quad_Penta:        myStream<<"Entity_Quad_Penta";        break;
 +    case Entity_BiQuad_Penta:      myStream<<"Entity_BiQuad_Penta";      break;
 +    case Entity_Hexagonal_Prism:   myStream<<"Entity_Hexagonal_Prism";   break;
 +    case Entity_Polyhedra:         myStream<<"Entity_Polyhedra";         break;
 +    case Entity_Quad_Polyhedra:    myStream<<"Entity_Quad_Polyhedra";    break;
 +    case Entity_Ball:              myStream<<"Entity_Ball";              break;
 +    case Entity_Last:              myStream<<"Entity_Last";              break;
 +    default:    myStream<<"__UNKNOWN__EntityType: " << theArg;
 +    }
 +    return *this;
 +  }
 +
 +  template<class TArray>
 +  void DumpArray(const TArray& theArray, TPythonDump & theStream)
 +  {
 +    if ( theArray.length() == 0 )
 +    {
 +      theStream << "[]";
 +    }
 +    else
 +    {
 +      theStream << "[ ";
 +      for (CORBA::ULong i = 1; i <= theArray.length(); i++) {
 +        theStream << theArray[i-1];
 +        if ( i < theArray.length() )
 +          theStream << ", ";
 +      }
 +      theStream << " ]";
 +    }
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::operator<<(const SMESH::long_array& theArg)
 +  {
 +    DumpArray( theArg, *this );
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::operator<<(const SMESH::double_array& theArg)
 +  {
 +    DumpArray( theArg, *this );
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::operator<<(const SMESH::nodes_array& theArg)
 +  {
 +    DumpArray( theArg, *this );
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::operator<<(const SMESH::string_array& theArray)
 +  {
 +    myStream << "[ ";
 +    for ( CORBA::ULong i = 1; i <= theArray.length(); i++ ) {
 +      myStream << "'" << theArray[i-1] << "'";
 +      if ( i < theArray.length() )
 +        myStream << ", ";
 +    }
 +    myStream << " ]";
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(SALOMEDS::SObject_ptr aSObject)
 +  {
 +    if ( !aSObject->_is_nil() ) {
 +      CORBA::String_var entry = aSObject->GetID();
 +      myStream << entry.in();
 +    }
 +    else {
 +      myStream << theNotPublishedObjectName;
 +    }
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(CORBA::Object_ptr theArg)
 +  {
 +    SMESH_Gen_i*          aSMESHGen = SMESH_Gen_i::GetSMESHGen();
 +    SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
 +    if(!aSObject->_is_nil()) {
 +      CORBA::String_var id = aSObject->GetID();
 +      myStream << id;
 +    } else if ( !CORBA::is_nil(theArg)) {
 +      if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object
 +        myStream << "smeshObj_" << size_t(theArg);
 +      else
 +        myStream << theNotPublishedObjectName;
 +    }
 +    else
 +      myStream << "None";
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
 +  {
 +    SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
 +    if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
 +      myStream << "hyp_" << theArg->GetId();
 +    else
 +      *this << aSObject;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(SMESH::SMESH_IDSource_ptr theArg)
 +  {
 +    if ( CORBA::is_nil( theArg ) )
 +      return *this << "None";
 +    SMESH_Gen_i*          aSMESHGen = SMESH_Gen_i::GetSMESHGen();
 +    SALOMEDS::SObject_wrap aSObject = SMESH_Gen_i::ObjectToSObject(theArg);
 +    if(!aSObject->_is_nil())
 +    {
 +      return *this << aSObject;
 +    }
 +    if ( SMESH::Filter_i* filter = SMESH::DownCast<SMESH::Filter_i*>( theArg ))
 +    {
 +      return *this << filter;
 +    }
 +    if ( SMESH_MeshEditor_i::IsTemporaryIDSource( theArg ))
 +    {
 +      SMESH::SMESH_Mesh_var            mesh = theArg->GetMesh();
 +      SMESH::long_array_var    anElementsId = theArg->GetIDs();
 +      SMESH::array_of_ElementType_var types = theArg->GetTypes();
 +      SMESH::ElementType               type = types->length() ? types[0] : SMESH::ALL;
 +      SALOMEDS::SObject_wrap         meshSO = SMESH_Gen_i::ObjectToSObject(mesh);
 +      if ( meshSO->_is_nil() ) // don't waste memory for dumping not published objects
 +        return *this << mesh << ".GetIDSource([], " << type << ")";
 +      else
 +        return *this << mesh << ".GetIDSource(" << anElementsId << ", " << type << ")";
 +    }
 +    return *this << theNotPublishedObjectName;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(SMESH::FilterLibrary_i* theArg)
 +  {
 +    myStream<<"aFilterLibrary"<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(SMESH::FilterManager_i* theArg)
 +  {
 +    myStream<<"aFilterManager";
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(SMESH::Filter_i* theArg)
 +  {
 +    myStream<<"aFilter"<<theArg;
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(SMESH::Functor_i* theArg)
 +  {
 +    if ( theArg ) {
 +      FunctorType aFunctorType = theArg->GetFunctorType();
 +      switch(aFunctorType) {
 +      case FT_AspectRatio:           myStream<< "aAspectRatio";           break;
 +      case FT_AspectRatio3D:         myStream<< "aAspectRatio3D";         break;
 +      case FT_Warping:               myStream<< "aWarping";               break;
 +      case FT_MinimumAngle:          myStream<< "aMinimumAngle";          break;
 +      case FT_Taper:                 myStream<< "aTaper";                 break;
 +      case FT_Skew:                  myStream<< "aSkew";                  break;
 +      case FT_Area:                  myStream<< "aArea";                  break;
 +      case FT_Volume3D:              myStream<< "aVolume3D";              break;
 +      case FT_MaxElementLength2D:    myStream<< "aMaxElementLength2D";    break;
 +      case FT_MaxElementLength3D:    myStream<< "aMaxElementLength3D";    break;
 +      case FT_FreeBorders:           myStream<< "aFreeBorders";           break;
 +      case FT_FreeEdges:             myStream<< "aFreeEdges";             break;
 +      case FT_FreeNodes:             myStream<< "aFreeNodes";             break;
 +      case FT_FreeFaces:             myStream<< "aFreeFaces";             break;
 +      case FT_EqualNodes:            myStream<< "aEqualNodes";            break;
 +      case FT_EqualEdges:            myStream<< "aEqualEdges";            break;
 +      case FT_EqualFaces:            myStream<< "aEqualFaces";            break;
 +      case FT_EqualVolumes:          myStream<< "aEqualVolumes";          break;
 +      case FT_MultiConnection:       myStream<< "aMultiConnection";       break;
 +      case FT_MultiConnection2D:     myStream<< "aMultiConnection2D";     break;
 +      case FT_Length:                myStream<< "aLength";                break;
 +      case FT_Length2D:              myStream<< "aLength2D";              break;
 +      case FT_Deflection2D:          myStream<< "aDeflection2D";          break;
 +      case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break;
 +      case FT_BelongToMeshGroup:     myStream<< "aBelongToMeshGroup";     break;
 +      case FT_BelongToGeom:          myStream<< "aBelongToGeom";          break;
 +      case FT_BelongToPlane:         myStream<< "aBelongToPlane";         break;
 +      case FT_BelongToCylinder:      myStream<< "aBelongToCylinder";      break;
 +      case FT_BelongToGenSurface:    myStream<< "aBelongToGenSurface";    break;
 +      case FT_LyingOnGeom:           myStream<< "aLyingOnGeom";           break;
 +      case FT_RangeOfIds:            myStream<< "aRangeOfIds";            break;
 +      case FT_BadOrientedVolume:     myStream<< "aBadOrientedVolume";     break;
 +      case FT_BareBorderVolume:      myStream<< "aBareBorderVolume";      break;
 +      case FT_BareBorderFace:        myStream<< "aBareBorderFace";        break;
 +      case FT_OverConstrainedVolume: myStream<< "aOverConstrainedVolume"; break;
 +      case FT_OverConstrainedFace:   myStream<< "aOverConstrainedFace";   break;
 +      case FT_LinearOrQuadratic:     myStream<< "aLinearOrQuadratic";     break;
 +      case FT_GroupColor:            myStream<< "aGroupColor";            break;
 +      case FT_ElemGeomType:          myStream<< "aElemGeomType";          break;
 +      case FT_EntityType:            myStream<< "aEntityType";            break;
 +      case FT_CoplanarFaces:         myStream<< "aCoplanarFaces";         break;
 +      case FT_BallDiameter:          myStream<< "aBallDiameter";          break;
 +      case FT_ConnectedElements:     myStream<< "aConnectedElements";     break;
 +      case FT_LessThan:              myStream<< "aLessThan";              break;
 +      case FT_MoreThan:              myStream<< "aMoreThan";              break;
 +      case FT_EqualTo:               myStream<< "aEqualTo";               break;
 +      case FT_LogicalNOT:            myStream<< "aLogicalNOT";            break;
 +      case FT_LogicalAND:            myStream<< "aLogicalAND";            break;
 +      case FT_LogicalOR:             myStream<< "aLogicalOR";             break;
 +      case FT_Undefined:             myStream<< "anUndefined";            break;
 +        //default: -- commented to have a compilation warning
 +      }
 +      myStream<<theArg;
 +    }
 +    return *this;
 +  }
 +
 +  TPythonDump&
 +  TPythonDump::
 +  operator<<(SMESH::Measurements_i* theArg)
 +  {
 +    myStream<<"aMeasurements";
 +    return *this;
 +  }
 +
 +  TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
 +  {
 +    myStream << SMESHGenName(); return *this;
 +  }
 +
 +  TPythonDump& TPythonDump::operator<<(SMESH_MeshEditor_i* theArg)
 +  {
 +    myStream << MeshEditorName() << "_" << ( theArg ? theArg->GetMeshId() : -1 ); return *this;
 +  }
 +
 +  TPythonDump& TPythonDump::operator<<(const TCollection_AsciiString & theStr)
 +  {
 +    myStream << theStr; return *this;
 +  }
 +
 +  TPythonDump& TPythonDump::operator<<(const SMESH::AxisStruct & theAxis)
 +  {
 +    *this << "SMESH.AxisStruct( "
 +          << TVar( theAxis.x  ) << ", "
 +          << TVar( theAxis.y  ) << ", "
 +          << TVar( theAxis.z  ) << ", "
 +          << TVar( theAxis.vx ) << ", "
 +          << TVar( theAxis.vy ) << ", "
 +          << TVar( theAxis.vz ) << " )";
 +    return *this;
 +  }
 +
 +  TPythonDump& TPythonDump::operator<<(const SMESH::DirStruct & theDir)
 +  {
 +    const SMESH::PointStruct & P = theDir.PS;
 +    *this << "SMESH.DirStruct( SMESH.PointStruct ( "
 +          << TVar( P.x ) << ", "
 +          << TVar( P.y ) << ", "
 +          << TVar( P.z ) << " ))";
 +    return *this;
 +  }
 +
 +  TPythonDump& TPythonDump::operator<<(const SMESH::PointStruct & P)
 +  {
 +    *this << "SMESH.PointStruct ( "
 +          << TVar( P.x ) << ", "
 +          << TVar( P.y ) << ", "
 +          << TVar( P.z ) << " )";
 +    return *this;
 +  }
 +
 +  TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups& theList)
 +  {
 +    DumpArray( theList, *this );
 +    return *this;
 +  }
 +  TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups * theList)
 +  {
 +    DumpArray( *theList, *this );
 +    return *this;
 +  }
 +  TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGO& theList)
 +  {
 +    DumpArray( theList, *this );
 +    return *this;
 +  }
 +  TPythonDump& TPythonDump::operator<<(const GEOM::ListOfGBO& theList)
 +  {
 +    DumpArray( theList, *this );
 +    return *this;
 +  }
 +  TPythonDump& TPythonDump::operator<<(const SMESH::ListOfIDSources& theList)
 +  {
 +    DumpArray( theList, *this );
 +    return *this;
 +  }
 +  TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB)
 +  {
 +    // dump CoincidentFreeBorders as a list of lists, each enclosed list
 +    // contains node IDs of a group of coincident free borders where
 +    // each consequent triple of IDs describe a free border: (n1, n2, nLast)
 +    // For example [[1, 2, 10, 20, 21, 40], [11, 12, 15, 55, 54, 41]] describes
 +    // two groups of coincident free borders, each group including two borders
 +
 +    myStream << "[";
 +    for ( CORBA::ULong i = 0; i < theCFB.coincidentGroups.length(); ++i )
 +    {
 +      const SMESH::FreeBordersGroup& aGRP = theCFB.coincidentGroups[ i ];
 +      if ( i ) myStream << ",";
 +      myStream << "[";
 +      for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
 +      {
 +        const SMESH::FreeBorderPart& aPART = aGRP[ iP ];
 +        if ( 0 <= aPART.border && aPART.border < (CORBA::Long)theCFB.borders.length() )
 +        {
 +          if ( iP ) myStream << ", ";
 +          const SMESH::FreeBorder& aBRD = theCFB.borders[ aPART.border ];
 +          myStream << aBRD.nodeIDs[ aPART.node1    ] << ",";
 +          myStream << aBRD.nodeIDs[ aPART.node2    ] << ",";
 +          myStream << aBRD.nodeIDs[ aPART.nodeLast ];
 +        }
 +      }
 +      myStream << "]";
 +    }
 +    myStream << "]";
 +
 +    return *this;
 +  }
 +
 +  const char* TPythonDump::NotPublishedObjectName()
 +  {
 +    return theNotPublishedObjectName;
 +  }
 +
 +  TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
 +  TCollection_AsciiString myLongStringEnd  ( "TPythonDump::LongStringEnd" );
 +
 +  //================================================================================
 +  /*!
 +   * \brief Return marker of long string literal beginning
 +   * \param type - a name of functionality producing the string literal
 +   * \retval TCollection_AsciiString - the marker string to be written into
 +   * a raw python script
 +   */
 +  //================================================================================
 +
 +  TCollection_AsciiString TPythonDump::LongStringStart(const char* type)
 +  {
 +    return
 +      myLongStringStart +
 +      (Standard_Integer) strlen(type) +
 +      " " +
 +      (char*) type;
 +  }
 +
 +  //================================================================================
 +  /*!
 +     * \brief Return marker of long string literal end
 +      * \retval TCollection_AsciiString - the marker string to be written into
 +      * a raw python script
 +   */
 +  //================================================================================
 +
 +  TCollection_AsciiString TPythonDump::LongStringEnd()
 +  {
 +    return myLongStringEnd;
 +  }
 +
 +  //================================================================================
 +  /*!
 +     * \brief Cut out a long string literal from a string
 +      * \param theText - text possibly containing string literals
 +      * \param theFrom - position in the text to search from
 +      * \param theLongString - the retrieved literal
 +      * \param theStringType - a name of functionality produced the literal
 +      * \retval bool - true if a string literal found
 +     *
 +     * The literal is removed from theText; theFrom points position right after
 +     * the removed literal
 +   */
 +  //================================================================================
 +
 +  bool  TPythonDump::CutoutLongString( TCollection_AsciiString & theText,
 +                                       int                     & theFrom,
 +                                       TCollection_AsciiString & theLongString,
 +                                       TCollection_AsciiString & theStringType)
 +  {
 +    if ( theFrom < 1 || theFrom > theText.Length() )
 +      return false;
 +
 +    // ...script \  beg marker    \ \ type \       literal              \  end marker  \ script...
 +    //  "theText myLongStringStart7 Pattern!!! SALOME Mesh Pattern file myLongStringEndtextEnd"
 +    //  012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
 +    //  0         1         2         3         4         5         6         7         8
 +
 +    theFrom = theText.Location( myLongStringStart, theFrom, theText.Length() ); // = 09
 +    if ( !theFrom )
 +      return false;
 +
 +    // find where literal begins
 +    int literalBeg = theFrom + myLongStringStart.Length(); // = 26
 +    char* typeLenStr = (char*) theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
 +    int typeLen = atoi ( typeLenStr ); // = 7
 +    while ( *typeLenStr != ' ' ) { // look for ' ' after typeLen
 +      literalBeg++; // 26 -> 27
 +      typeLenStr++;
 +    }
 +    literalBeg += typeLen + 1; // = 35
 +    if ( literalBeg > theText.Length() )
 +      return false;
 +
 +    // where literal ends (i.e. end marker begins)
 +    int literalEnd = theText.Location( myLongStringEnd, literalBeg, theText.Length() ); // = 64
 +    if ( !literalEnd )
 +      literalEnd = theText.Length();
 +
 +    // literal
 +    theLongString = theText.SubString( literalBeg, literalEnd - 1); // "!!! SALOME Mesh Pattern file "
 +    // type
 +    theStringType = theText.SubString( literalBeg - typeLen, literalBeg - 1 ); // "Pattern"
 +    // cut off literal
 +    literalEnd += myLongStringEnd.Length(); // = 79
 +    TCollection_AsciiString textEnd = theText.SubString( literalEnd, theText.Length() ); // "textE..."
 +    theText = theText.SubString( 1, theFrom - 1 ) + textEnd;
 +
 +    return true;
 +  }
 +
 +  void printException( const char* text )
 +  {
 +#ifdef _DEBUG_
 +    cout << "Exception in SMESH_Gen_i::DumpPython(): " << text << endl;
 +#endif
 +  }
 +}
 +
 +//=======================================================================
 +//function : RemoveTabulation
 +//purpose  : 
 +//=======================================================================
 +void RemoveTabulation( TCollection_AsciiString& theScript )
 +{
 +  std::string aString( theScript.ToCString() );
 +  std::string::size_type aPos = 0;
 +  while( aPos < aString.length() )
 +  {
 +    aPos = aString.find( "\n\t", aPos );
 +    if( aPos == std::string::npos )
 +      break;
 +    aString.replace( aPos, 2, "\n" );
 +    aPos++;
 +  }
 +  theScript = aString.c_str();
 +}
 +
 +//=======================================================================
 +//function : DumpPython
 +//purpose  :
 +//=======================================================================
 +Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished,
 +                                           CORBA::Boolean isMultiFile,
 +                                           CORBA::Boolean& isValidScript)
 +{
 +  SALOMEDS::Study_var aStudy = getStudyServant();
 +  if (CORBA::is_nil(aStudy))
 +    return new Engines::TMPFile(0);
 +
 +  CORBA::String_var compDataType = ComponentDataType();
 +  SALOMEDS::SObject_wrap aSO = aStudy->FindComponent( compDataType.in() );
 +  if (CORBA::is_nil(aSO))
 +    return new Engines::TMPFile(0);
 +
 +  // Map study entries to object names
 +  Resource_DataMapOfAsciiStringAsciiString aMap;
 +  Resource_DataMapOfAsciiStringAsciiString aMapNames;
 +
 +  SALOMEDS::ChildIterator_wrap Itr = aStudy->NewChildIterator(aSO);
 +  for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
 +    SALOMEDS::SObject_wrap aValue = Itr->Value();
 +    CORBA::String_var anID = aValue->GetID();
 +    CORBA::String_var aName = aValue->GetName();
 +    TCollection_AsciiString aGUIName ( (char*) aName.in() );
 +    TCollection_AsciiString anEntry ( (char*) anID.in() );
 +    if (aGUIName.Length() > 0) {
 +      aMapNames.Bind( anEntry, aGUIName );
 +      aMap.Bind( anEntry, aGUIName );
 +    }
 +  }
 +
 +  // Get trace of restored study
 +  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
 +  SALOMEDS::GenericAttribute_wrap anAttr =
 +    aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
 +
 +  SALOMEDS::AttributePythonObject_var pyAttr =
 +    SALOMEDS::AttributePythonObject::_narrow(anAttr);
 +  CORBA::String_var oldValue = pyAttr->GetObject();
 +  TCollection_AsciiString aSavedTrace (oldValue.in());
 +
 +  // Add trace of API methods calls and replace study entries by names
 +  TCollection_AsciiString aScript;
 +  aScript += DumpPython_impl(aMap, aMapNames, isPublished, isMultiFile,
 +                             myIsHistoricalPythonDump, isValidScript, aSavedTrace);
 +
 +  int aLen = aScript.Length();
 +  unsigned char* aBuffer = new unsigned char[aLen+1];
 +  strcpy((char*)aBuffer, aScript.ToCString());
 +
 +  CORBA::Octet* anOctetBuf =  (CORBA::Octet*)aBuffer;
 +  Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
 +
 +  bool hasNotPublishedObjects = aScript.Location( SMESH::theNotPublishedObjectName, 1, aLen);
 +  isValidScript = isValidScript && !hasNotPublishedObjects;
 +
 +  return aStreamFile._retn();
 +}
 +
 +//=============================================================================
 +/*!
 + *  AddToPythonScript
 + */
 +//=============================================================================
 +void SMESH_Gen_i::AddToPythonScript (const TCollection_AsciiString& theString)
 +{
 +  if (myPythonScript.IsNull()) {
 +    myPythonScript = new TColStd_HSequenceOfAsciiString;
 +  }
 +  myPythonScript->Append(theString);
 +}
 +
 +//=============================================================================
 +/*!
 + *  RemoveLastFromPythonScript
 + */
 +//=============================================================================
 +void SMESH_Gen_i::RemoveLastFromPythonScript()
 +{
 +  if (!myPythonScript.IsNull()) {
 +    int aLen = myPythonScript->Length();
 +    myPythonScript->Remove(aLen);
 +  }
 +}
 +
 +//=======================================================================
 +//function : SavePython
 +//purpose  :
 +//=======================================================================
 +void SMESH_Gen_i::SavePython()
 +{
 +  // Dump trace of API methods calls
 +  TCollection_AsciiString aScript = GetNewPythonLines();
 +
 +  // Check contents of PythonObject attribute
 +  CORBA::String_var compDataType = ComponentDataType();
 +  SALOMEDS::SObject_wrap aSO = getStudyServant()->FindComponent( compDataType.in() );
 +  SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
 +  SALOMEDS::GenericAttribute_wrap anAttr =
 +    aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
 +
 +  SALOMEDS::AttributePythonObject_var pyAttr =
 +    SALOMEDS::AttributePythonObject::_narrow(anAttr);
 +  CORBA::String_var oldValue = pyAttr->GetObject();
 +  TCollection_AsciiString oldScript (oldValue.in());
 +
 +  if (oldScript.Length() > 0) {
 +    oldScript += "\n";
 +    oldScript += aScript;
 +  } else {
 +    oldScript = aScript;
 +  }
 +
 +  // Store in PythonObject attribute
 +  pyAttr->SetObject(oldScript.ToCString(), 1);
 +
 +  // Clean trace of API methods calls
 +  CleanPythonTrace();
 +}
 +
 +
 +// impl
 +
 +
 +//=============================================================================
 +/*!
 + *  FindEntries: Returns a sequence of start/end positions of entries in the string
 + */
 +//=============================================================================
 +Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
 +{
 +  Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
 +  Standard_Integer aLen = theString.Length();
 +  Standard_Boolean isFound = Standard_False;
 +
 +  char* arr = (char*) theString.ToCString();
 +  Standard_Integer i = 0, j;
 +
 +  while(i < aLen) {
 +    int c = (int)arr[i];
 +    j = i+1;
 +    if ( isdigit( c )) { //Is digit?
 +
 +      isFound = Standard_False;
 +      while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry
 +        c = (int)arr[j++];
 +        if(c == ':') isFound = Standard_True;
 +      }
 +
 +      if (isFound) {
 +        int prev = (i < 1) ? 0 : (int)arr[i - 1];
 +        // to distinguish from a sketcher command:
 +        // last char should be a digit, not ":",
 +        // previous char should not be '"'.
 +        if (arr[j-2] != ':' && prev != '"') {
 +          aSeq->Append(i+1); // +1 because AsciiString starts from 1
 +          aSeq->Append(j-1);
 +        }
 +      }
 +    }
 +
 +    i = j;
 +  }
 +
 +  return aSeq;
 +}
 +
 +namespace {
 +
 +  //================================================================================
 +  /*!
 +   * \brief Make a string be a valid python name
 +    * \param aName - a string to fix
 +    * \retval bool - true if aName was not modified
 +   */
 +  //================================================================================
 +
 +  bool fixPythonName(TCollection_AsciiString & aName)
 +  {
 +    bool isValidName = true;
 +    int nbUnderscore = 0;
 +    int p;
 +    // replace not allowed chars by underscore
 +    const char* name = aName.ToCString();
 +    for ( p = 0; name[p]; ++p ) {
 +      if ( !isalnum( name[p] ) && name[p] != '_' )
 +      {
 +        if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_')
 +        {
 +          aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end
 +          --p;
 +          name = aName.ToCString();
 +        }
 +        else
 +        {
 +          aName.SetValue( p+1, '_');
 +          nbUnderscore++;
 +        }
 +        isValidName = false;
 +      }
 +    }
 +    // aName must not start with a digit
 +    if ( aName.IsIntegerValue() ) {
 +      aName.Insert( 1, 'a' );
 +      isValidName = false;
 +    }
 +    // shorten names like CartesianParameters3D_400_400_400_1000000_1
 +    const int nbAllowedUnderscore = 3; /* changed from 2 to 3 by an user request
 +                                          posted to SALOME Forum */
 +    if ( aName.Length() > 20 && nbUnderscore > nbAllowedUnderscore )
 +    {
 +      p = aName.Location( "_", 20, aName.Length());
 +      if ( p > 1 )
 +        aName.Trunc( p-1 );
 +    }
 +    return isValidName;
 +  }
 +
 +  //================================================================================
 +  /*!
 +   * \brief Return Python module names of available plug-ins.
 +   */
 +  //================================================================================
 +
 +  std::vector<std::string> getPluginNames()
 +  {
 +    std::vector<std::string> pluginNames;
 +    std::vector< std::string > xmlPaths = SMESH_Gen::GetPluginXMLPaths();
 +    LDOMParser xmlParser;
 +    for ( size_t i = 0; i < xmlPaths.size(); ++i )
 +    {
 +      bool error = xmlParser.parse( xmlPaths[i].c_str() );
 +      if ( error )
 +      {
 +        TCollection_AsciiString data;
 +        INFOS( xmlParser.GetError(data) );
 +        continue;
 +      }
 +      // <meshers-group name="Standard Meshers"
 +      //                resources="StdMeshers"
 +      //                idl-module="StdMeshers"
 +      //                server-lib="StdMeshersEngine"
 +      //                gui-lib="StdMeshersGUI">
 +      LDOM_Document xmlDoc   = xmlParser.getDocument();
 +      LDOM_NodeList nodeList = xmlDoc.getElementsByTagName( "meshers-group" );
 +      for ( int i = 0; i < nodeList.getLength(); ++i )
 +      {
 +        LDOM_Node       node = nodeList.item( i );
 +        LDOM_Element&   elem = (LDOM_Element&) node;
 +        LDOMString idlModule = elem.getAttribute( "idl-module" );
 +        if ( strlen( idlModule.GetString() ) > 0 )
 +          pluginNames.push_back( idlModule.GetString() );
 +      }
 +    }
 +    return pluginNames;
 +  }
 +}
 +
 +//================================================================================
 +/*!
 + * \brief Createa a Dump Python script
 + *  \param [in,out] theObjectNames - map of an entry to a study and python name
 + *  \param [in] theNames -  - map of an entry to a study name
 + *  \param [in] isPublished - \c true if dump of object publication in study is needed
 + *  \param [in] isMultiFile - \c true if dump of each module goes to a separate file
 + *  \param [in] isHistoricalDump - \c true if removed object should be dumped
 + *  \param [out] aValidScript - returns \c true if the returned script seems valid
 + *  \param [in,out] theSavedTrace - the dump stored in the study. It's cleared to
 + *         decrease memory usage.
 + *  \return TCollection_AsciiString - the result dump script.
 + */
 +//================================================================================
 +
 +TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
 +                        (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
 +                         Resource_DataMapOfAsciiStringAsciiString& theNames,
 +                         bool                                      isPublished,
 +                         bool                                      isMultiFile,
 +                         bool                                      isHistoricalDump,
 +                         bool&                                     aValidScript,
 +                         TCollection_AsciiString&                  theSavedTrace)
 +{
 +  SMESH_TRY;
 +
 +  const TCollection_AsciiString aSmeshpy ( SMESH_2smeshpy::SmeshpyName() );
 +  const TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() );
 +  const TCollection_AsciiString anOldGen ( SMESH::TPythonDump::SMESHGenName() );
 +  const TCollection_AsciiString helper; // to comfortably append C strings to TCollection_AsciiString
 +  const TCollection_AsciiString tab( isMultiFile ? "\t" : "" ), nt = helper + "\n" + tab;
 +
 +  std::list< TCollection_AsciiString > lines; // lines of a script
 +  std::list< TCollection_AsciiString >::iterator linesIt;
 +  
 +  if ( isPublished )
 +    lines.push_back(  aSMESHGen + " = smeshBuilder.New()" );
 +   else
 +    lines.push_back(  aSMESHGen + " = smeshBuilder.New(False)" );
 +  lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" );
 +  lines.push_back( helper + "aMeasurements = "  + aSMESHGen + ".CreateMeasurements()" );
 +
 +  // Treat dump trace of restored study
 +  if (theSavedTrace.Length() > 0)
 +  {
 +    linesIt = --lines.end();
 +    // Split theSavedTrace into lines
 +    int from = 1, end = theSavedTrace.Length(), to;
 +    while ( from < end && ( to = theSavedTrace.Location( "\n", from, end )))
 +    {
 +      if ( theSavedTrace.ToCString()[from-1] == '\t' )
 +        ++from;
 +      if ( to != from )
 +        lines.push_back( theSavedTrace.SubString( from, to - 1 ));
 +      from = to + 1;
 +    }
 +    // For the conversion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen
 +    // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()).
 +    // Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API
 +    bool isNewVersion =
 +      theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() );
 +    theSavedTrace.Clear();
 +    if ( !isNewVersion )
 +    {
 +      const TCollection_AsciiString aSmeshCall ( "smesh." ), gen( "gen" );
 +      int beg, end, from;
 +      for ( ++linesIt; linesIt != lines.end(); ++linesIt )
 +      {
 +        TCollection_AsciiString& aSavedLine = *linesIt;
 +        end = aSavedLine.Length(), from = 1;
 +        while ( from < end && ( beg = aSavedLine.Location( aSmeshCall, from, end )))
 +        {
 +          char charBefore = ( beg == 1 ) ? ' ' : aSavedLine.Value( beg - 1 );
 +          if ( isspace( charBefore ) || charBefore == '=' ) { // "smesh." is not a part of a long word
 +            aSavedLine.Insert( beg + aSmeshCall.Length() - 1, gen );// "smesh" -> "smeshgen"
 +            end += gen.Length();
 +          }
 +          from = beg + aSmeshCall.Length();
 +        }
 +      }
 +    }
 +  }
 +
 +  // Add new dump trace of API methods calls to script lines
 +  if (!myPythonScript.IsNull())
 +  {
 +    Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
 +    Standard_Integer istr, aLen = aPythonScript->Length();
 +    for (istr = 1; istr <= aLen; istr++)
 +      lines.push_back( aPythonScript->Value( istr ));
 +  }
 +
 +  // Convert IDL API calls into smeshBuilder.py API.
 +  // Some objects are wrapped with python classes and
 +  // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects
 +  Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
 +  std::set< TCollection_AsciiString >      aRemovedObjIDs;
 +  if ( !getenv("NO_2smeshpy_conversion"))
 +    SMESH_2smeshpy::ConvertScript( lines, anEntry2AccessorMethod,
 +                                   theObjectNames, aRemovedObjIDs,
 +                                   isHistoricalDump );
 +
 +  bool importGeom = false;
 +  GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
 +  {
 +    // Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects
 +    GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
 +    int ign = 0, nbgn = aGeomNames->length();
 +    for (; ign < nbgn; ign++) {
 +      TCollection_AsciiString aName = aGeomNames[ign].in();
 +      theObjectNames.Bind(aName, "1");
 +    }
 +  }
 +
 +  TCollection_AsciiString anUpdatedScript;
 +
 +  Resource_DataMapOfAsciiStringAsciiString mapRemoved;
 +  Resource_DataMapOfAsciiStringAsciiString mapEntries; // names and entries present in anUpdatedScript
 +  Standard_Integer objectCounter = 0;
 +  TCollection_AsciiString anEntry, aName, aGUIName, aBaseName("smeshObj_");
 +
 +  // Treat every script line and add it to anUpdatedScript
 +  for ( linesIt = lines.begin(); linesIt != lines.end(); ++linesIt )
 +  {
 +    TCollection_AsciiString& aLine = *linesIt;
 +    anUpdatedScript += tab;
 +    {
 +      //Replace characters used instead of quote marks to quote notebook variables
 +      int pos = 1;
 +      while (( pos = aLine.Location( 1, SMESH::TVar::Quote(), pos, aLine.Length() )))
 +        aLine.SetValue( pos, '"' );
 +    }
 +    // Find entries to be replaced by names
 +    Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aLine);
 +    const Standard_Integer aSeqLen = aSeq->Length();
 +    Standard_Integer aStart = 1;
 +    for (Standard_Integer i = 1; i <= aSeqLen; i += 2)
 +    {
 +      if ( aStart < aSeq->Value(i) )
 +        anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
 +      anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
 +      // is a GEOM object?
 +      CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() );
 +      if ( !geomName.in() || !geomName.in()[0] ) {
 +        // is a SMESH object
 +        if ( theObjectNames.IsBound( anEntry )) {
 +          // The Object is in Study
 +          aName = theObjectNames.Find( anEntry );
 +          // check validity of aName
 +          bool isValidName = fixPythonName( aName );
 +          if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
 +            // diff objects have same name - make a new name by appending a digit
 +            TCollection_AsciiString aName2;
 +            Standard_Integer i = 0;
 +            do {
 +              aName2 = aName + "_" + ++i;
 +            } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
 +            aName = aName2;
 +            isValidName = false;
 +          }
 +          if ( !isValidName )
 +            theObjectNames(anEntry) = aName;
 +
 +          if ( aLine.Value(1) != '#' )
 +            mapEntries.Bind(anEntry, aName);
 +        }
 +        else
 +        {
 +          // Removed Object
 +          do {
 +            aName = aBaseName + (++objectCounter);
 +          } while (theObjectNames.IsBound(aName));
 +
 +          if ( !aRemovedObjIDs.count( anEntry ) && aLine.Value(1) != '#')
 +            mapRemoved.Bind(anEntry, aName);
 +
 +          theObjectNames.Bind(anEntry, aName);
 +        }
 +        theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
 +      }
 +      else
 +      {
 +        aName = geomName.in();
 +        importGeom = true;
 +      }
 +      anUpdatedScript += aName;
 +      aStart = aSeq->Value(i + 1) + 1;
 +
 +    } // loop on entries within aLine
 +
 +    if ( aSeqLen == 0 )
 +      anUpdatedScript += aLine;
 +    else if ( aSeq->Value( aSeqLen ) < aLine.Length() )
 +      anUpdatedScript += aLine.SubString( aSeq->Value(aSeqLen) + 1, aLine.Length() );
 +
 +    anUpdatedScript += '\n';
 +  }
 +
 +  // Make an initial part of aSript
 +
 +  TCollection_AsciiString initPart = "import ";
 +  if ( isMultiFile )
 +    initPart += "salome, ";
 +  initPart += " SMESH, SALOMEDS\n";
 +  initPart += "from salome.smesh import smeshBuilder\n";
 +  if ( importGeom && isMultiFile )
 +  {
 +    initPart += ("\n## import GEOM dump file ## \n"
 +                 "import string, os, sys, re, inspect\n"
 +                 "thisFile   = inspect.getfile( inspect.currentframe() )\n"
 +                 "thisModule = os.path.splitext( os.path.basename( thisFile ))[0]\n"
 +                 "sys.path.insert( 0, os.path.dirname( thisFile ))\n"
 +                 "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",thisModule)+\" import *\")\n\n");
 +  }
 +  // import python files corresponding to plugins if they are used in anUpdatedScript
 +  {
 +    TCollection_AsciiString importStr;
 +    std::vector<std::string> pluginNames = getPluginNames();
 +    for ( size_t i = 0; i < pluginNames.size(); ++i )
 +    {
 +      // Convert access to plugin members:
 +      // e.g. StdMeshers.QUAD_REDUCED -> StdMeshersBuilder.QUAD_REDUCED
 +      TCollection_AsciiString pluginAccess = (pluginNames[i] + ".").c_str() ;
 +      int iFrom = 1, iPos;
 +      while (( iPos = anUpdatedScript.Location( pluginAccess, iFrom, anUpdatedScript.Length() )))
 +      {
 +        anUpdatedScript.Insert( iPos + pluginNames[i].size(), "Builder" );
 +        iFrom = iPos + pluginNames[i].size() + 8;
 +      }
 +      // if any plugin member is used, import the plugin
 +      if ( iFrom > 1 )
 +        importStr += ( helper + "\n" "from salome." + pluginNames[i].c_str() +
 +                       " import " + pluginNames[i].c_str() +"Builder" );
 +    }
 +    if ( !importStr.IsEmpty() )
 +      initPart += importStr + "\n";
 +  }
 +
 +  if ( isMultiFile )
 +    initPart += "def RebuildData():";
 +  initPart += "\n";
 +
 +  anUpdatedScript.Prepend( initPart );
 +
 +  // Make a final part of aScript
 +
 +  // Dump object removal
 +  TCollection_AsciiString removeObjPart;
 +  if ( !mapRemoved.IsEmpty() ) {
 +    removeObjPart += nt + "## some objects were removed";
 +    removeObjPart += nt + "aStudyBuilder = salome.myStudy.NewBuilder()";
 +    Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapRemovedIt;
 +    for ( mapRemovedIt.Initialize( mapRemoved ); mapRemovedIt.More(); mapRemovedIt.Next() ) {
 +      aName   = mapRemovedIt.Value(); // python name
 +      anEntry = mapRemovedIt.Key();
 +      removeObjPart += nt + "SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(";
 +      removeObjPart += aName;
 +      // for object wrapped by class of smeshBuilder.py
 +      if ( anEntry2AccessorMethod.IsBound( anEntry ) )
 +        removeObjPart += helper + "." + anEntry2AccessorMethod( anEntry );
 +      removeObjPart += helper + "))" + nt + "if SO: aStudyBuilder.RemoveObjectWithChildren(SO)";
 +    }
 +  }
 +
 +  // Set object names
 +  TCollection_AsciiString setNamePart;
 +  Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString mapEntriesIt;
 +  for ( mapEntriesIt.Initialize( mapEntries ); mapEntriesIt.More(); mapEntriesIt.Next() )
 +  {
 +    anEntry = mapEntriesIt.Key();
 +    aName   = mapEntriesIt.Value(); // python name
 +    if ( theNames.IsBound( anEntry ))
 +    {
 +      aGUIName = theNames.Find(anEntry);
 +      aGUIName.RemoveAll('\''); // remove a quote from a name (issue 22360)
 +      setNamePart += nt + aSMESHGen + ".SetName(" + aName;
 +      if ( anEntry2AccessorMethod.IsBound( anEntry ) )
 +        setNamePart += helper + "." + anEntry2AccessorMethod( anEntry );
 +      setNamePart += helper + ", '" + aGUIName + "')";
 +    }
 +  }
 +  if ( !setNamePart.IsEmpty() )
 +  {
 +    setNamePart.Insert( 1, nt + "## Set names of Mesh objects" );
 +  }
 +
 +  // Store visual properties of displayed objects
 +
 +  TCollection_AsciiString visualPropertiesPart;
 +  if (isPublished)
 +  {
 +    //Output the script that sets up the visual parameters.
 +    CORBA::String_var compDataType = ComponentDataType();
 +    CORBA::String_var script = getStudyServant()->GetDefaultScript( compDataType.in(), tab.ToCString() );
 +    if ( script.in() && script.in()[0] ) {
 +      visualPropertiesPart += nt + "### Store presentation parameters of displayed objects\n";
 +      visualPropertiesPart += script.in();
 +    }
 +  }
 +
 +  anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart;
 +
 +  if ( isMultiFile )
 +  {
 +    anUpdatedScript +=
 +      "\n\tpass"
 +      "\n"
 +      "\nif __name__ == '__main__':"
 +      "\n\tSMESH_RebuildData = RebuildData"
 +      "\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
 +      "\n\tGEOM_dump.RebuildData()"
 +      "\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
 +      "\n\tSMESH_RebuildData()";
 +  }
 +  anUpdatedScript += "\n";
 +
 +  // no need now as we use 'tab' and 'nt' variables depending on isMultiFile
 +  // if( !isMultiFile ) // remove unnecessary tabulation
 +  //   RemoveTabulation( anUpdatedScript );
 +
 +  // -----------------------------------------------------------------
 +  // put string literals describing patterns into separate functions
 +  // -----------------------------------------------------------------
 +
 +  TCollection_AsciiString aLongString, aFunctionType;
 +  int where = 1;
 +  std::set< std::string > functionNameSet;
 +  while ( SMESH::TPythonDump::CutoutLongString( anUpdatedScript, where, aLongString, aFunctionType ))
 +  {
 +    // make a python string literal
 +    aLongString.Prepend(":\n\treturn '''\n");
 +    aLongString += "\n\t'''\n\tpass\n";
 +
 +    TCollection_AsciiString functionName;
 +
 +    // check if the function returning this literal is already defined
 +    int posAlready = anUpdatedScript.Location( aLongString, where, anUpdatedScript.Length() );
 +    if ( posAlready ) // already defined
 +    {
 +      // find the function name
 +      int functBeg = posAlready;
++      char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def function()"
 +      while ( *script != ' ' ) {
 +        script--;
 +        functBeg--;
 +      }
 +      functBeg++; // do not take ' '
 +      posAlready--; // do not take ':'
 +      functionName = anUpdatedScript.SubString( functBeg, posAlready );
 +    }
 +    else // not defined yet
 +    {
 +      // find a unique function name
 +      fixPythonName( aFunctionType );
 +      Standard_Integer nb = 0;
 +      do functionName = aFunctionType + "_" + ( nb++ ) + "()";
 +      while ( !functionNameSet.insert( functionName.ToCString() ).second );
 +
 +      // define function
 +      TCollection_AsciiString funDef = helper + "def " + functionName + aLongString;
 +      if ( isMultiFile )
 +      {
 +        anUpdatedScript += helper + "\n\n" + funDef;
 +      }
 +      else
 +      {
 +        funDef += "\n\n";
 +        anUpdatedScript.Insert( 1, funDef);
 +        where += funDef.Length();
 +      }
 +    }
 +    anUpdatedScript.InsertBefore( where, functionName ); // call function
 +  }
 +
 +  aValidScript = true;
 +
 +  return anUpdatedScript;
 +
 +  SMESH_CATCH( SMESH::printException );
 +
 +  aValidScript = false;
 +  return "";
 +}
 +
 +//=============================================================================
 +/*!
 + *  GetNewPythonLines
 + */
 +//=============================================================================
 +TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines()
 +{
 +  TCollection_AsciiString aScript;
 +
 +  // Dump trace of API methods calls
 +  if (!myPythonScript.IsNull()) {
 +    Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScript;
 +    Standard_Integer istr, aLen = aPythonScript->Length();
 +    for (istr = 1; istr <= aLen; istr++) {
 +      aScript += "\n";
 +      aScript += aPythonScript->Value(istr);
 +    }
 +    aScript += "\n";
 +  }
 +
 +  return aScript;
 +}
 +
 +//=============================================================================
 +/*!
 + *  CleanPythonTrace
 + */
 +//=============================================================================
 +void SMESH_Gen_i::CleanPythonTrace()
 +{
 +  TCollection_AsciiString aScript;
 +
 +  // Clean trace of API methods calls
 +  if (!myPythonScript.IsNull()) {
 +    myPythonScript->Clear();
 +  }
 +}
index 4d25b4a968c5f50fcbd3aab255de69bd149b2509,65a12f5c3c8c141017538c6f2d88cba7fff63ce4..3d6d664f89438dd10942760c84886e7ca9740e7c
@@@ -21,7 -21,7 +21,7 @@@
  # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  #
  
- #  SMESH SMESH_SWIG : binding of C++ implementaion with Python
+ #  SMESH SMESH_SWIG : binding of C++ implementation with Python
  #  File   : SMESH_blocks.py
  #  Author : Julia DOROVSKIKH
  #  Module : SMESH
@@@ -31,11 -31,11 +31,11 @@@ import salom
  salome.salome_init()
  import GEOM
  from salome.geom import geomBuilder
 -geompy = geomBuilder.New(salome.myStudy)
 +geompy = geomBuilder.New()
  
  import SMESH, SALOMEDS
  from salome.smesh import smeshBuilder
 -smesh =  smeshBuilder.New(salome.myStudy)
 +smesh =  smeshBuilder.New()
  
  import math
  
@@@ -46,4 -46,4 +46,4 @@@ isMeshTest   = 1 # Tru
  
  GEOM_Spanner.MakeSpanner(geompy, math, isBlocksTest, isMeshTest, smesh)
  
 -salome.sg.updateObjBrowser(True)
 +salome.sg.updateObjBrowser()
index a81853eb31dd328c8f35d298be7f1ab91e6b390b,29e0fccf368299dc8a0e38b5d606eef99f5e317f..1d3d393d7aed30ef3c3affa262bcb665bcc6854d
@@@ -369,7 -369,7 +369,7 @@@ class StdMeshersBuilder_Segment(Mesh_Al
      def LengthNearVertex(self, length, vertex=0, UseExisting=0):
          import types
          store_geom = self.geom
 -        if type(vertex) is types.IntType:
 +        if isinstance(vertex, int):
              if vertex == 0 or vertex == 1:
                  from salome.geom import geomBuilder
                  vertex = self.mesh.geompyD.ExtractShapes(self.geom, geomBuilder.geomBuilder.ShapeType["VERTEX"],True)[vertex]
          # 0D algorithm
          if self.geom is None:
              self.geom = store_geom
 -            raise RuntimeError, "Attempt to create SegmentAroundVertex_0D algorithm on None shape"
 +            raise RuntimeError("Attempt to create SegmentAroundVertex_0D algorithm on None shape")
          from salome.smesh.smeshBuilder import AssureGeomPublished, GetName, TreatHypoStatus
          AssureGeomPublished( self.mesh, self.geom )
          name = GetName(self.geom)
@@@ -983,7 -983,7 +983,7 @@@ class StdMeshersBuilder_Prism3D(Mesh_Al
      ## Return 3D hypothesis holding the 1D one
      def Get3DHypothesis(self):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          return self.distribHyp
  
      #  hypothesis. Returns the created hypothesis
      def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          if not self.nbLayers is None:
              self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
              self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
 -        study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
 -        self.mesh.smeshpyD.SetCurrentStudy( None )
 +        self.mesh.smeshpyD.SetEnablePublish( False ) # prevents publishing own 1D hypothesis
          hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
 -        self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
 +        self.mesh.smeshpyD.SetEnablePublish( True ) # enables publishing
          if not self.distribHyp:
              self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
          self.distribHyp.SetLayerDistribution( hyp )
      #                     the same parameters, else (default) - creates a new one
      def NumberOfLayers(self, n, UseExisting=0):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
          from salome.smesh.smeshBuilder import IsEqual
      #  @param p the precision of rounding
      def LocalLength(self, l, p=1e-07):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          hyp = self.OwnHypothesis("LocalLength", [l,p])
          hyp.SetLength(l)
      #  @param s the scale factor (optional)
      def NumberOfSegments(self, n, s=[]):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          if not s:
              hyp = self.OwnHypothesis("NumberOfSegments", [n])
      #  @param end    the length of the last  segment
      def Arithmetic1D(self, start, end ):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
          hyp.SetLength(start, 1)
      #  @param ratio  the common ratio of the geometric progression
      def GeometricProgression(self, start, ratio ):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
          hyp.SetStartLength( start )
      #  @param end   for the length of the last  segment
      def StartEndLength(self, start, end):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          hyp = self.OwnHypothesis("StartEndLength", [start, end])
          hyp.SetLength(start, 1)
      #  @param fineness defines the quality of the mesh within the range [0-1]
      def AutomaticLength(self, fineness=0):
          if self.algoType != "RadialPrism_3D":
-             print("Prism_3D algorith doesn't support any hyposesis")
 -            print "Prism_3D algorithm doesn't support any hypothesis"
++            print("Prism_3D algorithm doesn't support any hypothesis")
              return None
          hyp = self.OwnHypothesis("AutomaticLength")
          hyp.SetFineness( fineness )
@@@ -1162,9 -1163,10 +1162,9 @@@ class StdMeshersBuilder_RadialAlgorithm
              self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
          else:
              self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
 -        study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
 -        self.mesh.smeshpyD.SetCurrentStudy( None )
 +        self.mesh.smeshpyD.SetEnablePublish( False )
          hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
 -        self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
 +        self.mesh.smeshpyD.SetEnablePublish( True )
          self.distribHyp.SetLayerDistribution( hyp )
          return hyp
  
@@@ -1491,7 -1493,7 +1491,7 @@@ class StdMeshersBuilder_Cartesian_3D(Me
              self.mesh.AddHypothesis( self.hyp, self.geom )
  
          for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef] ):
 -            if not gridDef: raise ValueError, "Empty grid definition"
 +            if not gridDef: raise ValueError("Empty grid definition")
              if isinstance( gridDef, str ):
                  self.hyp.SetGridSpacing( [gridDef], [], axis )
              elif isinstance( gridDef[0], str ):
index dc7f7de3531284f4a56c6c0fbb13d80719d0f1b6,270d5946bf631382e392f4febd7163d812c59347..d1e2f3bb23584320f531ab0386672fb146f5d52f
@@@ -84,91 -84,12 +84,91 @@@ import salom
  from salome.geom import geomBuilder
  
  import SMESH # This is necessary for back compatibility
 +import omniORB                                   # back compatibility
 +SMESH.MED_V2_1 = omniORB.EnumItem("MED_V2_1", 0) # back compatibility
 +SMESH.MED_V2_2 = omniORB.EnumItem("MED_V2_2", 1) # back compatibility
 +
  from   SMESH import *
  from   salome.smesh.smesh_algorithm import Mesh_Algorithm
  
  import SALOME
  import SALOMEDS
  import os
 +import inspect
 +
 +# In case the omniORBpy EnumItem class does not fully support Python 3
 +# (for instance in version 4.2.1-2), the comparison ordering methods must be
 +# defined
 +#
 +try:
 +    SMESH.Entity_Triangle < SMESH.Entity_Quadrangle
 +except TypeError:
 +    def enumitem_eq(self, other):
 +        try:
 +            if isinstance(other, omniORB.EnumItem):
 +                if other._parent_id == self._parent_id:
 +                    return self._v == other._v
 +                else:
 +                    return self._parent_id == other._parent_id
 +            else:
 +                return id(self) == id(other)
 +        except:
 +            return id(self) == id(other)
 +
 +    def enumitem_lt(self, other):
 +        try:
 +            if isinstance(other, omniORB.EnumItem):
 +                if other._parent_id == self._parent_id:
 +                    return self._v < other._v
 +                else:
 +                    return self._parent_id < other._parent_id
 +            else:
 +                return id(self) < id(other)
 +        except:
 +            return id(self) < id(other)
 +
 +    def enumitem_le(self, other):
 +        try:
 +            if isinstance(other, omniORB.EnumItem):
 +                if other._parent_id == self._parent_id:
 +                    return self._v <= other._v
 +                else:
 +                    return self._parent_id <= other._parent_id
 +            else:
 +                return id(self) <= id(other)
 +        except:
 +            return id(self) <= id(other)
 +
 +    def enumitem_gt(self, other):
 +        try:
 +            if isinstance(other, omniORB.EnumItem):
 +                if other._parent_id == self._parent_id:
 +                    return self._v > other._v
 +                else:
 +                    return self._parent_id > other._parent_id
 +            else:
 +                return id(self) > id(other)
 +        except:
 +            return id(self) > id(other)
 +
 +    def enumitem_ge(self, other):
 +        try:
 +            if isinstance(other, omniORB.EnumItem):
 +                if other._parent_id == self._parent_id:
 +                    return self._v >= other._v
 +                else:
 +                    return self._parent_id >= other._parent_id
 +            else:
 +                return id(self) >= id(other)
 +        except:
 +            return id(self) >= id(other)
 +
 +    omniORB.EnumItem.__eq__ = enumitem_eq
 +    omniORB.EnumItem.__lt__ = enumitem_lt
 +    omniORB.EnumItem.__le__ = enumitem_le
 +    omniORB.EnumItem.__gt__ = enumitem_gt
 +    omniORB.EnumItem.__ge__ = enumitem_ge
 +
  
  ## Private class used to workaround a problem that sometimes isinstance(m, Mesh) returns False
  #
@@@ -202,7 -123,7 +202,7 @@@ def ParseParameters(*args)
      Parameters = ""
      hasVariables = False
      varModifFun=None
 -    if args and callable( args[-1] ):
 +    if args and callable(args[-1]):
          args, varModifFun = args[:-1], args[-1]
      for parameter in args:
  
          if isinstance(parameter,str):
              # check if there is an inexistent variable name
              if not notebook.isVariable(parameter):
 -                raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
 +                raise ValueError("Variable with name '" + parameter + "' doesn't exist!!!")
              parameter = notebook.get(parameter)
              hasVariables = True
              if varModifFun:
@@@ -241,7 -162,8 +241,7 @@@ SMESH.PointStruct.__init__ = __initPoin
  #  Parameters are stored in AxisStruct.parameters attribute
  def __initAxisStruct(ax,*args):
      if len( args ) != 6:
 -        raise RuntimeError,\
 -              "Bad nb args (%s) passed in SMESH.AxisStruct(x,y,z,dx,dy,dz)"%(len( args ))
 +        raise RuntimeError("Bad nb args (%s) passed in SMESH.AxisStruct(x,y,z,dx,dy,dz)"%(len( args )))
      ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
      pass
  SMESH.AxisStruct.__init__ = __initAxisStruct
@@@ -267,8 -189,13 +267,8 @@@ def GetName(obj)
          except:
              ior = None
          if ior:
 -            # CORBA object
 -            studies = salome.myStudyManager.GetOpenStudies()
 -            for sname in studies:
 -                s = salome.myStudyManager.GetStudyByName(sname)
 -                if not s: continue
 -                sobj = s.FindObjectIOR(ior)
 -                if not sobj: continue
 +            sobj = salome.myStudy.FindObjectIOR(ior)
 +            if sobj:
                  return sobj.GetName()
              if hasattr(obj, "GetName"):
                  # unknown CORBA object, having GetName() method
              # unknown non-CORBA object, having GetName() method
              return obj.GetName()
          pass
 -    raise RuntimeError, "Null or invalid object"
 +    raise RuntimeError("Null or invalid object")
  
  ## Print error message if a hypothesis was not assigned.
  def TreatHypoStatus(status, hypName, geomName, isAlgo, mesh):
          pass
      reason = ""
      if hasattr( status, "__getitem__" ):
 -        status,reason = status[0],status[1]
 -    if status == HYP_UNKNOWN_FATAL :
 +        status, reason = status[0], status[1]
 +    if status == HYP_UNKNOWN_FATAL:
          reason = "for unknown reason"
 -    elif status == HYP_INCOMPATIBLE :
 +    elif status == HYP_INCOMPATIBLE:
          reason = "this hypothesis mismatches the algorithm"
 -    elif status == HYP_NOTCONFORM :
 +    elif status == HYP_NOTCONFORM:
          reason = "a non-conform mesh would be built"
 -    elif status == HYP_ALREADY_EXIST :
 +    elif status == HYP_ALREADY_EXIST:
          if isAlgo: return # it does not influence anything
          reason = hypType + " of the same dimension is already assigned to this shape"
 -    elif status == HYP_BAD_DIM :
 +    elif status == HYP_BAD_DIM:
          reason = hypType + " mismatches the shape"
 -    elif status == HYP_CONCURENT :
 +    elif status == HYP_CONCURENT:
          reason = "there are concurrent hypotheses on sub-shapes"
 -    elif status == HYP_BAD_SUBSHAPE :
 +    elif status == HYP_BAD_SUBSHAPE:
          reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
      elif status == HYP_BAD_GEOMETRY:
          reason = "the algorithm is not applicable to this geometry"
              if meshName and meshName != NO_NAME:
                  where = '"%s" shape in "%s" mesh ' % ( geomName, meshName )
      if status < HYP_UNKNOWN_FATAL and where:
 -        print '"%s" was assigned to %s but %s' %( hypName, where, reason )
 +        print('"%s" was assigned to %s but %s' %( hypName, where, reason ))
      elif where:
 -        print '"%s" was not assigned to %s : %s' %( hypName, where, reason )
 +        print('"%s" was not assigned to %s : %s' %( hypName, where, reason ))
      else:
 -        print '"%s" was not assigned : %s' %( hypName, reason )
 +        print('"%s" was not assigned : %s' %( hypName, reason ))
          pass
  
  ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
  def AssureGeomPublished(mesh, geom, name=''):
      if not isinstance( geom, geomBuilder.GEOM._objref_GEOM_Object ):
          return
 -    if not geom.GetStudyEntry() and \
 -           mesh.smeshpyD.GetCurrentStudy():
 -        ## set the study
 -        studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
 -        if studyID != mesh.geompyD.myStudyId:
 -            mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
 +    if not geom.GetStudyEntry():
          ## get a name
          if not name and geom.GetShapeType() != geomBuilder.GEOM.COMPOUND:
              # for all groups SubShapeName() return "Compound_-1"
  def FirstVertexOnCurve(mesh, edge):
      vv = mesh.geompyD.SubShapeAll( edge, geomBuilder.geomBuilder.ShapeType["VERTEX"])
      if not vv:
 -        raise TypeError, "Given object has no vertices"
 +        raise TypeError("Given object has no vertices")
      if len( vv ) == 1: return vv[0]
      v0   = mesh.geompyD.MakeVertexOnCurve(edge,0.)
      xyz  = mesh.geompyD.PointCoordinates( v0 ) # coords of the first vertex
      else:
          return vv[1]
  
 +## Return a long value from enumeration
 +def EnumToLong(theItem):
 +    return theItem._v
 +
  # end of l1_auxiliary
  ## @}
  
@@@ -386,7 -314,7 +386,7 @@@ created = Fals
  ## This class allows to create, load or manipulate meshes.
  #  It has a set of methods to create, load or copy meshes, to combine several meshes, etc.
  #  It also has methods to get infos and measure meshes.
 -class smeshBuilder(object, SMESH._objref_SMESH_Gen):
 +class smeshBuilder(SMESH._objref_SMESH_Gen):
  
      # MirrorType enumeration
      POINT = SMESH_MeshEditor.POINT
      PrecisionConfusion = smeshPrecisionConfusion
  
      # TopAbs_State enumeration
 -    [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
 +    [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = list(range(4))
  
      # Methods of splitting a hexahedron into tetrahedra
      Hex_5Tet, Hex_6Tet, Hex_24Tet, Hex_2Prisms, Hex_4Prisms = 1, 2, 3, 1, 2
  
 -    def __new__(cls):
 +    def __new__(cls, *args):
          global engine
          global smeshInst
          global doLcc
          #print "====2 ", smeshInst
          return smeshInst
  
 -    def __init__(self):
 +    def __init__(self, *args):
          global created
          #print "--------------- smeshbuilder __init__ ---", created
          if not created:
 -          created = True
 -          SMESH._objref_SMESH_Gen.__init__(self)
 +            created = True
 +            SMESH._objref_SMESH_Gen.__init__(self, *args)
  
      ## Dump component to the Python script
      #  This method overrides IDL function to allow default values for the parameters.
      #  @ingroup l1_auxiliary
 -    def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
 -        return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
 +    def DumpPython(self, theIsPublished=True, theIsMultiFile=True):
 +        return SMESH._objref_SMESH_Gen.DumpPython(self, theIsPublished, theIsMultiFile)
  
      ## Set mode of DumpPython(), \a historical or \a snapshot.
      #  In the \a historical mode, the Python Dump script includes all commands
          else:            val = "false"
          SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
  
 -    ## Set the current study and Geometry component
 +    ## Set Geometry component
      #  @ingroup l1_auxiliary
 -    def init_smesh(self,theStudy,geompyD = None):
 +    def init_smesh(self,isPublished = True,geompyD = None):
          #print "init_smesh"
 -        self.SetCurrentStudy(theStudy,geompyD)
 -        if theStudy:
 +        self.UpdateStudy(geompyD)
 +        if isPublished:
              global notebook
 -            notebook.myStudy = theStudy
 +            notebook.myStudy = salome.myStudy
  
      ## Create a mesh. This can be either an empty mesh, possibly having an underlying geometry,
      #  or a mesh wrapping a CORBA mesh given as a parameter.
              obj,name = name,obj
          return Mesh(self,self.geompyD,obj,name)
  
 -    ## Return a long value from enumeration
 -    #  @ingroup l1_auxiliary
 -    def EnumToLong(self,theItem):
 -        return theItem._v
 -
      ## Return a string representation of the color.
      #  To be used with filters.
      #  @param c color value (SALOMEDS.Color)
          elif isinstance(c, str):
              val = c
          else:
 -            raise ValueError, "Color value should be of string or SALOMEDS.Color type"
 +            raise ValueError("Color value should be of string or SALOMEDS.Color type")
          return val
  
      ## Get PointStruct from vertex
      def GetDirStruct(self,theVector):
          vertices = self.geompyD.SubShapeAll( theVector, geomBuilder.geomBuilder.ShapeType["VERTEX"] )
          if(len(vertices) != 2):
 -            print "Error: vector object is incorrect."
 +            print("Error: vector object is incorrect.")
              return None
          p1 = self.geompyD.PointCoordinates(vertices[0])
          p2 = self.geompyD.PointCoordinates(vertices[1])
      #  @ingroup l1_auxiliary
      def IsEmbeddedMode(self):
          return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
 -
 -    ## Set the current study. Calling SetCurrentStudy( None ) allows to
 -    #  switch OFF automatic pubilishing in the Study of mesh objects.
 +    
 +    ## Update the current study. Calling UpdateStudy() allows to 
 +    #  update meshes at switching GEOM->SMESH
      #  @ingroup l1_auxiliary
 -    def SetCurrentStudy( self, theStudy, geompyD = None ):
 +    def UpdateStudy( self, geompyD = None  ):
 +        #self.UpdateStudy()
          if not geompyD:
              from salome.geom import geomBuilder
              geompyD = geomBuilder.geom
              pass
          self.geompyD=geompyD
          self.SetGeomEngine(geompyD)
 -        SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
 -        global notebook
 -        if theStudy:
 -            notebook = salome_notebook.NoteBook( theStudy )
 -        else:
 -            notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() )
 -        if theStudy:
 -            sb = theStudy.NewBuilder()
 -            sc = theStudy.FindComponent("SMESH")
 -            if sc: sb.LoadWith(sc, self)
 -            pass
 +        SMESH._objref_SMESH_Gen.UpdateStudy(self)
 +        sb = salome.myStudy.NewBuilder()
 +        sc = salome.myStudy.FindComponent("SMESH")
 +        if sc: sb.LoadWith(sc, self)
          pass
 -
 -    ## Get the current study
 +        
 +    ## Sets enable publishing in the study. Calling SetEnablePublish( false ) allows to
 +    #  switch OFF publishing in the Study of mesh objects.
      #  @ingroup l1_auxiliary
 -    def GetCurrentStudy(self):
 -        return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
 +    def SetEnablePublish( self, theIsEnablePublish ):
 +        #self.SetEnablePublish(theIsEnablePublish)
 +        SMESH._objref_SMESH_Gen.SetEnablePublish(self,theIsEnablePublish)
 +        global notebook
 +        notebook = salome_notebook.NoteBook( theIsEnablePublish )
  
      ## Create a Mesh object importing data from the given UNV file
      #  @return an instance of Mesh class
          aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self,
                                                                          theFileName,
                                                                          True)
 -        if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment
 +        if error.comment: print("*** CreateMeshesFromGMF() errors:\n", error.comment)
          return Mesh(self, self.geompyD, aSmeshMesh), error
  
      ## Concatenate the given meshes into one mesh. All groups of input meshes will be
      def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
          return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
  
 -    ## Create a pattern mapper. 
 +    ## Create a pattern mapper.
      #  @return an instance of SMESH_Pattern
      #
      #  <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
      #  @return SMESH.Filter.Criterion
      #  @ingroup l1_controls
      def GetEmptyCriterion(self):
 -        Type = self.EnumToLong(FT_Undefined)
 -        Compare = self.EnumToLong(FT_Undefined)
 +        Type = EnumToLong(FT_Undefined)
 +        Compare = EnumToLong(FT_Undefined)
          Threshold = 0
          ThresholdStr = ""
          ThresholdID = ""
 -        UnaryOp = self.EnumToLong(FT_Undefined)
 -        BinaryOp = self.EnumToLong(FT_Undefined)
 +        UnaryOp = EnumToLong(FT_Undefined)
 +        BinaryOp = EnumToLong(FT_Undefined)
          Tolerance = 1e-07
          TypeOfElement = ALL
          Precision = -1 ##@1e-07
                       BinaryOp=FT_Undefined,
                       Tolerance=1e-07):
          if not CritType in SMESH.FunctorType._items:
 -            raise TypeError, "CritType should be of SMESH.FunctorType"
 +            raise TypeError("CritType should be of SMESH.FunctorType")
          aCriterion               = self.GetEmptyCriterion()
          aCriterion.TypeOfElement = elementType
 -        aCriterion.Type          = self.EnumToLong(CritType)
 +        aCriterion.Type          = EnumToLong(CritType)
          aCriterion.Tolerance     = Tolerance
  
          aThreshold = Threshold
  
          if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
 -            aCriterion.Compare = self.EnumToLong(Compare)
 +            aCriterion.Compare = EnumToLong(Compare)
          elif Compare == "=" or Compare == "==":
 -            aCriterion.Compare = self.EnumToLong(FT_EqualTo)
 +            aCriterion.Compare = EnumToLong(FT_EqualTo)
          elif Compare == "<":
 -            aCriterion.Compare = self.EnumToLong(FT_LessThan)
 +            aCriterion.Compare = EnumToLong(FT_LessThan)
          elif Compare == ">":
 -            aCriterion.Compare = self.EnumToLong(FT_MoreThan)
 +            aCriterion.Compare = EnumToLong(FT_MoreThan)
          elif Compare != FT_Undefined:
 -            aCriterion.Compare = self.EnumToLong(FT_EqualTo)
 +            aCriterion.Compare = EnumToLong(FT_EqualTo)
              aThreshold = Compare
  
          if CritType in [FT_BelongToGeom,     FT_BelongToPlane, FT_BelongToGenSurface,
              elif isinstance( aThreshold, str ):
                  aCriterion.ThresholdStr = aThreshold
              else:
 -                raise TypeError, "The Threshold should be a shape."
 +                raise TypeError("The Threshold should be a shape.")
              if isinstance(UnaryOp,float):
                  aCriterion.Tolerance = UnaryOp
                  UnaryOp = FT_Undefined
              # Check that Threshold is a group
              if isinstance(aThreshold, SMESH._objref_SMESH_GroupBase):
                  if aThreshold.GetType() != elementType:
 -                    raise ValueError, "Group type mismatches Element type"
 +                    raise ValueError("Group type mismatches Element type")
                  aCriterion.ThresholdStr = aThreshold.GetName()
                  aCriterion.ThresholdID  = salome.orb.object_to_string( aThreshold )
 -                study = self.GetCurrentStudy()
 +                study = salome.myStudy
                  if study:
                      so = study.FindObjectIOR( aCriterion.ThresholdID )
                      if so:
                          if entry:
                              aCriterion.ThresholdID = entry
              else:
 -                raise TypeError, "The Threshold should be a Mesh Group"
 +                raise TypeError("The Threshold should be a Mesh Group")
          elif CritType == FT_RangeOfIds:
              # Check that Threshold is string
              if isinstance(aThreshold, str):
                  aCriterion.ThresholdStr = aThreshold
              else:
 -                raise TypeError, "The Threshold should be a string."
 +                raise TypeError("The Threshold should be a string.")
          elif CritType == FT_CoplanarFaces:
              # Check the Threshold
              if isinstance(aThreshold, int):
              elif isinstance(aThreshold, str):
                  ID = int(aThreshold)
                  if ID < 1:
 -                    raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
 +                    raise ValueError("Invalid ID of mesh face: '%s'"%aThreshold)
                  aCriterion.ThresholdID = aThreshold
              else:
 -                raise TypeError,\
 -                      "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
 +                raise TypeError("The Threshold should be an ID of mesh face and not '%s'"%aThreshold)
          elif CritType == FT_ConnectedElements:
              # Check the Threshold
              if isinstance(aThreshold, geomBuilder.GEOM._objref_GEOM_Object): # shape
                  aCriterion.Threshold = aThreshold
              elif isinstance(aThreshold, list): # 3 point coordinates
                  if len( aThreshold ) < 3:
 -                    raise ValueError, "too few point coordinates, must be 3"
 +                    raise ValueError("too few point coordinates, must be 3")
                  aCriterion.ThresholdStr = " ".join( [str(c) for c in aThreshold[:3]] )
              elif isinstance(aThreshold, str):
                  if aThreshold.isdigit():
                  else:
                      aCriterion.ThresholdStr = aThreshold # hope that it's point coordinates
              else:
 -                raise TypeError,\
 -                      "The Threshold should either a VERTEX, or a node ID, "\
 -                      "or a list of point coordinates and not '%s'"%aThreshold
 +                raise TypeError("The Threshold should either a VERTEX, or a node ID, "\
 +                      "or a list of point coordinates and not '%s'"%aThreshold)
          elif CritType == FT_ElemGeomType:
              # Check the Threshold
              try:
 -                aCriterion.Threshold = self.EnumToLong(aThreshold)
 +                aCriterion.Threshold = EnumToLong(aThreshold)
                  assert( aThreshold in SMESH.GeometryType._items )
              except:
                  if isinstance(aThreshold, int):
                      aCriterion.Threshold = aThreshold
                  else:
 -                    raise TypeError, "The Threshold should be an integer or SMESH.GeometryType."
 +                    raise TypeError("The Threshold should be an integer or SMESH.GeometryType.")
                  pass
              pass
          elif CritType == FT_EntityType:
              # Check the Threshold
              try:
 -                aCriterion.Threshold = self.EnumToLong(aThreshold)
 +                aCriterion.Threshold = EnumToLong(aThreshold)
                  assert( aThreshold in SMESH.EntityType._items )
              except:
                  if isinstance(aThreshold, int):
                      aCriterion.Threshold = aThreshold
                  else:
 -                    raise TypeError, "The Threshold should be an integer or SMESH.EntityType."
 +                    raise TypeError("The Threshold should be an integer or SMESH.EntityType.")
                  pass
              pass
 -        
 +
          elif CritType == FT_GroupColor:
              # Check the Threshold
              try:
                  aCriterion.ThresholdStr = self.ColorToString(aThreshold)
              except:
 -                raise TypeError, "The threshold value should be of SALOMEDS.Color type"
 +                raise TypeError("The threshold value should be of SALOMEDS.Color type")
              pass
          elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
                            FT_LinearOrQuadratic, FT_BadOrientedVolume,
                            FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
              # At this point the Threshold is unnecessary
              if aThreshold ==  FT_LogicalNOT:
 -                aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
 +                aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
              elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
                  aCriterion.BinaryOp = aThreshold
          else:
                  aThreshold = float(aThreshold)
                  aCriterion.Threshold = aThreshold
              except:
 -                raise TypeError, "The Threshold should be a number."
 +                raise TypeError("The Threshold should be a number.")
                  return None
  
          if Threshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
 -            aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
 +            aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
  
          if Threshold in [FT_LogicalAND, FT_LogicalOR]:
 -            aCriterion.BinaryOp = self.EnumToLong(Threshold)
 +            aCriterion.BinaryOp = EnumToLong(Threshold)
  
          if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
 -            aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
 +            aCriterion.BinaryOp = EnumToLong(UnaryOp)
  
          if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
 -            aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
 +            aCriterion.BinaryOp = EnumToLong(BinaryOp)
  
          return aCriterion
  
      #  @ingroup l1_controls
      def GetFilterFromCriteria(self,criteria, binOp=SMESH.FT_LogicalAND):
          for i in range( len( criteria ) - 1 ):
 -            if criteria[i].BinaryOp == self.EnumToLong( SMESH.FT_Undefined ):
 -                criteria[i].BinaryOp = self.EnumToLong( binOp )
 +            if criteria[i].BinaryOp == EnumToLong( SMESH.FT_Undefined ):
 +                criteria[i].BinaryOp = EnumToLong( binOp )
          aFilterMgr = self.CreateFilterManager()
          aFilter = aFilterMgr.CreateFilter()
          aFilter.SetCriteria(criteria)
          elif theCriterion == FT_BallDiameter:
              functor = aFilterMgr.CreateBallDiameter()
          else:
 -            print "Error: given parameter is not numerical functor type."
 +            print("Error: given parameter is not numerical functor type.")
          aFilterMgr.UnRegister()
          return functor
  
          d = {}
          if hasattr(obj, "GetMeshInfo"):
              values = obj.GetMeshInfo()
 -            for i in range(SMESH.Entity_Last._v):
 +            for i in range(EnumToLong(SMESH.Entity_Last)):
                  if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
              pass
          return d
          aMeasurements.UnRegister()
          return value
  
+     ## Get gravity center of all nodes of the mesh object.
+     #  @param obj mesh, submesh or group
+     #  @return three components of the gravity center: x,y,z
+     #  @ingroup l1_measurements
+     def GetGravityCenter(self, obj):
+         if isinstance(obj, Mesh): obj = obj.mesh
+         if isinstance(obj, Mesh_Algorithm): obj = obj.GetSubMesh()
+         aMeasurements = self.CreateMeasurements()
+         pointStruct = aMeasurements.GravityCenter(obj)
+         aMeasurements.UnRegister()
+         return pointStruct.x, pointStruct.y, pointStruct.z
      pass # end of class smeshBuilder
  
  import omniORB
@@@ -1232,13 -1181,13 +1244,13 @@@ omniORB.registerObjref(SMESH._objref_SM
  #    import salome
  #    salome.salome_init()
  #    from salome.smesh import smeshBuilder
 -#    smesh = smeshBuilder.New(salome.myStudy)
 +#    smesh = smeshBuilder.New()
  #  \endcode
 -#  @param  study     SALOME study, generally obtained by salome.myStudy.
 +#  @param  isPublished If False, the notebool will not be used.
  #  @param  instance  CORBA proxy of SMESH Engine. If None, the default Engine is used.
  #  @return smeshBuilder instance
  
 -def New( study, instance=None):
 +def New( isPublished = True, instance=None):
      """
      Create a new smeshBuilder instance.The smeshBuilder class provides the Python
      interface to create or load meshes.
          import salome
          salome.salome_init()
          from salome.smesh import smeshBuilder
 -        smesh = smeshBuilder.New(salome.myStudy)
 +        smesh = smeshBuilder.New()
  
      Parameters:
 -        study     SALOME study, generally obtained by salome.myStudy.
 +        isPublished If False, the notebool will not be used.
          instance  CORBA proxy of SMESH Engine. If None, the default Engine is used.
      Returns:
          smeshBuilder instance
      global doLcc
      engine = instance
      if engine is None:
 -      doLcc = True
 +        doLcc = True
      smeshInst = smeshBuilder()
      assert isinstance(smeshInst,smeshBuilder), "Smesh engine class is %s but should be smeshBuilder.smeshBuilder. Import salome.smesh.smeshBuilder before creating the instance."%smeshInst.__class__
 -    smeshInst.init_smesh(study)
 +    smeshInst.init_smesh(isPublished)
      return smeshInst
  
  
  #  It also has methods to define groups of mesh elements, to modify a mesh (by addition of
  #  new nodes and elements and by changing the existing entities), to get information
  #  about a mesh and to export a mesh in different formats.
 -class Mesh:
 -    __metaclass__ = MeshMeta
 -
 +class Mesh(metaclass=MeshMeta):
      geom = 0
      mesh = 0
      editor = 0
      #  @param name Study name of the mesh
      #  @ingroup l2_construct
      def __init__(self, smeshpyD, geompyD, obj=0, name=0):
 -        self.smeshpyD=smeshpyD
 -        self.geompyD=geompyD
 +        self.smeshpyD = smeshpyD
 +        self.geompyD = geompyD
          if obj is None:
              obj = 0
          objHasName = False
                  self.geom = obj
                  objHasName = True
                  # publish geom of mesh (issue 0021122)
 -                if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
 +                if not self.geom.GetStudyEntry():
                      objHasName = False
 -                    studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
 -                    if studyID != geompyD.myStudyId:
 -                        geompyD.init_geom( smeshpyD.GetCurrentStudy())
 -                        pass
 +                    geompyD.init_geom()
                      if name:
                          geo_name = name + " shape"
                      else:
              self.geom = self.mesh.GetShapeToMesh()
  
          self.editor   = self.mesh.GetMeshEditor()
 -        self.functors = [None] * SMESH.FT_Undefined._v
 +        self.functors = [None] * EnumToLong(SMESH.FT_Undefined)
  
          # set self to algoCreator's
          for attrName in dir(self):
              #self.mesh.UnRegister()
              pass
          pass
 -        
 +
      ## Initialize the Mesh object from an instance of SMESH_Mesh interface
      #  @param theMesh a SMESH_Mesh object
      #  @ingroup l2_construct
              if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
                  self.mesh.Clear()
              ok = self.smeshpyD.Compute(self.mesh, geom)
 -        except SALOME.SALOME_Exception, ex:
 -            print "Mesh computation failed, exception caught:"
 -            print "    ", ex.details.text
 +        except SALOME.SALOME_Exception as ex:
 +            print("Mesh computation failed, exception caught:")
 +            print("    ", ex.details.text)
          except:
              import traceback
 -            print "Mesh computation failed, exception caught:"
 +            print("Mesh computation failed, exception caught:")
              traceback.print_exc()
          if True:#not ok:
              allReasons = ""
                  else:  msg += " has not been computed"
                  if allReasons != "": msg += ":"
                  else:                msg += "."
 -                print msg
 -                print allReasons
 +                print(msg)
 +                print(allReasons)
              pass
 -        if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
 +        if salome.sg.hasDesktop():
              if not isinstance( refresh, list): # not a call from subMesh.Compute()
                  smeshgui = salome.ImportComponentGUI("SMESH")
 -                smeshgui.Init(self.mesh.GetStudyId())
 +                smeshgui.Init()
                  smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
 -                if refresh: salome.sg.updateObjBrowser(True)
 +                if refresh: salome.sg.updateObjBrowser()
  
          return ok
  
          try:
              shapeText = ""
              mainIOR  = salome.orb.object_to_string( self.GetShape() )
 -            for sname in salome.myStudyManager.GetOpenStudies():
 -                s = salome.myStudyManager.GetStudyByName(sname)
 -                if not s: continue
 -                mainSO = s.FindObjectIOR(mainIOR)
 -                if not mainSO: continue
 +            s = salome.myStudy
 +            mainSO = s.FindObjectIOR(mainIOR)
 +            if mainSO:
                  if subShapeID == 1:
                      shapeText = '"%s"' % mainSO.GetName()
                  subIt = s.NewChildIterator(mainSO)
                          continue
                      if ids == subShapeID:
                          shapeText = '"%s"' % subSO.GetName()
 -                        break
              if not shapeText:
                  shape = self.geompyD.GetSubShape( self.GetShape(), [subShapeID])
                  if shape:
              pass
  
          groups = []
 -        for algoName, shapes in algo2shapes.items():
 +        for algoName, shapes in list(algo2shapes.items()):
              while shapes:
 -                groupType = self.smeshpyD.EnumToLong( shapes[0].GetShapeType() )
 +                groupType = EnumToLong( shapes[0].GetShapeType() )
                  otherTypeShapes = []
                  sameTypeShapes  = []
                  group = self.geompyD.CreateGroup( self.geom, groupType )
      #  @ingroup l2_construct
      def Clear(self, refresh=False):
          self.mesh.Clear()
 -        if ( salome.sg.hasDesktop() and 
 -             salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() ) ):
 +        if ( salome.sg.hasDesktop() ):
              smeshgui = salome.ImportComponentGUI("SMESH")
 -            smeshgui.Init(self.mesh.GetStudyId())
 +            smeshgui.Init()
              smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
 -            if refresh: salome.sg.updateObjBrowser(True)
 +            if refresh: salome.sg.updateObjBrowser()
  
      ## Remove all nodes and elements of indicated shape
      #  @param refresh if @c True, Object browser is automatically updated (when running in GUI)
          self.mesh.ClearSubMesh(geomId)
          if salome.sg.hasDesktop():
              smeshgui = salome.ImportComponentGUI("SMESH")
 -            smeshgui.Init(self.mesh.GetStudyId())
 +            smeshgui.Init()
              smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
 -            if refresh: salome.sg.updateObjBrowser(True)
 +            if refresh: salome.sg.updateObjBrowser()
  
      ## Compute a tetrahedral mesh using AutomaticLength + MEFISTO + Tetrahedron
      #  @param fineness [0.0,1.0] defines mesh fineness
              AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
              status = self.mesh.AddHypothesis(geom, hyp)
          else:
 -            status = HYP_BAD_GEOMETRY,""
 +            status = HYP_BAD_GEOMETRY, ""
          hyp_name = GetName( hyp )
          geom_name = ""
          if geom:
              return self.mesh.RemoveHypothesis( shape, hyp )
          hypName = GetName( hyp )
          geoName = GetName( shape )
 -        print "WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName )
 +        print("WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName ))
          return None
  
      ## Get the list of hypotheses added on a geometry
  
      ## Export the mesh in a file in MED format
      ## allowing to overwrite the file if it exists or add the exported data to its contents
 -    #  @param f is the file name
 +    #  @param fileName is the file name
      #  @param auto_groups boolean parameter for creating/not creating
      #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
      #  the typical use is auto_groups=False.
 -    #  @param version MED format version
 -    #         - MED_V2_1 is obsolete.
 -    #         - MED_V2_2 means current version (kept for compatibility reasons)
 -    #         - MED_LATEST means current version.
 -    #         - MED_MINOR_x where x from 0 to 9 indicates the minor version of MED
 -    #           to use for writing MED files, for backward compatibility :
 -    #           for instance, with SALOME 8.4 use MED 3.2 (minor=2) instead of 3.3,
 -    #           to allow the file to be read with SALOME 8.3.
      #  @param overwrite boolean parameter for overwriting/not overwriting the file
      #  @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
      #  @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
      #         - 3D in the rest cases.<br>
      #         If @a autoDimension is @c False, the space dimension is always 3.
      #  @param fields list of GEOM fields defined on the shape to mesh.
 -    #  @param geomAssocFields each character of this string means a need to export a 
 +    #  @param geomAssocFields each character of this string means a need to export a
      #         corresponding field; correspondence between fields and characters is following:
      #         - 'v' stands for "_vertices _" field;
      #         - 'e' stands for "_edges _" field;
      #         - 'f' stands for "_faces _" field;
      #         - 's' stands for "_solids _" field.
      #  @ingroup l2_impexp
 -    def ExportMED(self, f, auto_groups=0, version=MED_LATEST,
 -                  overwrite=1, meshPart=None, autoDimension=True, fields=[], geomAssocFields=''):
 +    def ExportMED(self, *args, **kwargs):
 +        # process positional arguments
 +        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
 +        fileName        = args[0]
 +        auto_groups     = args[1] if len(args) > 1 else False
 +        overwrite       = args[2] if len(args) > 2 else True
 +        meshPart        = args[3] if len(args) > 3 else None
 +        autoDimension   = args[4] if len(args) > 4 else True
 +        fields          = args[5] if len(args) > 5 else []
 +        geomAssocFields = args[6] if len(args) > 6 else ''
 +        # process keywords arguments
 +        auto_groups     = kwargs.get("auto_groups", auto_groups)
 +        overwrite       = kwargs.get("overwrite", overwrite)
 +        meshPart        = kwargs.get("meshPart", meshPart)
 +        autoDimension   = kwargs.get("autoDimension", autoDimension)
 +        fields          = kwargs.get("fields", fields)
 +        geomAssocFields = kwargs.get("geomAssocFields", geomAssocFields)
 +        # invoke engine's function
          if meshPart or fields or geomAssocFields:
              unRegister = genObjUnRegister()
              if isinstance( meshPart, list ):
                  meshPart = self.GetIDSource( meshPart, SMESH.ALL )
                  unRegister.set( meshPart )
 -            self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite, autoDimension,
 +            self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, overwrite, autoDimension,
                                         fields, geomAssocFields)
          else:
 -            self.mesh.ExportToMEDX(f, auto_groups, version, overwrite, autoDimension)
 +            self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
  
      ## Export the mesh in a file in SAUV format
      #  @param f is the file name
      ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
      #  Export the mesh in a file in MED format
      #  allowing to overwrite the file if it exists or add the exported data to its contents
 -    #  @param f the file name
 -    #  @param version MED format version:
 -    #         - MED_V2_1 is obsolete.
 -    #         - MED_V2_2 means current version (kept for compatibility reasons)
 -    #         - MED_LATEST means current version.
 -    #         - MED_MINOR_x where x from 0 to 9 indicates the minor version of MED
 -    #           to use for writing MED files, for backward compatibility :
 -    #           for instance, with SALOME 8.4 use MED 3.2 (minor=2) instead of 3.3,
 -    #           to allow the file to be read with SALOME 8.3.
 +    #  @param fileName the file name
 +    #  @param opt boolean parameter for creating/not creating
 +    #         the groups Group_On_All_Nodes, Group_On_All_Faces, ...
 +    #  @param overwrite boolean parameter for overwriting/not overwriting the file
 +    #  @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
 +    #         - 1D if all mesh nodes lie on OX coordinate axis, or
 +    #         - 2D if all mesh nodes lie on XOY coordinate plane, or
 +    #         - 3D in the rest cases.<br>
 +    #         If @a autoDimension is @c False, the space dimension is always 3.
 +    #  @ingroup l2_impexp
 +    def ExportToMED(self, *args, **kwargs):
 +        print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
 +        # process positional arguments
 +        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
 +        fileName      = args[0]
 +        auto_groups   = args[1] if len(args) > 1 else False
 +        overwrite     = args[2] if len(args) > 2 else True
 +        autoDimension = args[3] if len(args) > 3 else True
 +        # process keywords arguments
 +        auto_groups   = kwargs.get("opt", auto_groups)         # old keyword name
 +        auto_groups   = kwargs.get("auto_groups", auto_groups) # new keyword name
 +        overwrite     = kwargs.get("overwrite", overwrite)
 +        autoDimension = kwargs.get("autoDimension", autoDimension)
 +        # invoke engine's function
 +        self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
 +
 +    ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
 +    #  Export the mesh in a file in MED format
 +    #  allowing to overwrite the file if it exists or add the exported data to its contents
 +    #  @param fileName the file name
      #  @param opt boolean parameter for creating/not creating
      #         the groups Group_On_All_Nodes, Group_On_All_Faces, ...
      #  @param overwrite boolean parameter for overwriting/not overwriting the file
      #         - 3D in the rest cases.<br>
      #         If @a autoDimension is @c False, the space dimension is always 3.
      #  @ingroup l2_impexp
 -    def ExportToMED(self, f, version=MED_LATEST, opt=0, overwrite=1, autoDimension=True):
 -        self.mesh.ExportToMEDX(f, opt, version, overwrite, autoDimension)
 +    def ExportToMEDX(self, *args, **kwargs):
 +        print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
 +        # process positional arguments
 +        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
 +        fileName      = args[0]
 +        auto_groups   = args[1] if len(args) > 1 else False
 +        overwrite     = args[2] if len(args) > 2 else True
 +        autoDimension = args[3] if len(args) > 3 else True
 +        # process keywords arguments
 +        auto_groups   = kwargs.get("auto_groups", auto_groups)
 +        overwrite     = kwargs.get("overwrite", overwrite)
 +        autoDimension = kwargs.get("autoDimension", autoDimension)
 +        # invoke engine's function
 +        self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
  
      # Operations with groups:
      # ----------------------
  
      ## Create an empty mesh group
 -    #  @param elementType the type of elements in the group; either of 
 +    #  @param elementType the type of elements in the group; either of
      #         (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME)
      #  @param name the name of the mesh group
      #  @return SMESH_Group
      #  the name is the same as the geometrical group name
      #  @param grp  a geometrical group, a vertex, an edge, a face or a solid
      #  @param name the name of the mesh group
 -    #  @param typ  the type of elements in the group; either of 
 +    #  @param typ  the type of elements in the group; either of
      #         (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME). If not set, it is
      #         automatically detected by the type of the geometry
      #  @return SMESH_GroupOnGeom
          elif tgeo == "COMPOUND":
              sub = self.geompyD.SubShapeAll( shape, self.geompyD.ShapeType["SHAPE"])
              if not sub:
 -                raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
 +                raise ValueError("_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape))
              return self._groupTypeFromShape( sub[0] )
          else:
 -            raise ValueError, \
 -                  "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
 +            raise ValueError("_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape))
          return typ
  
      ## Create a mesh group with given \a name based on the \a filter which
      ## is a special type of group dynamically updating it's contents during
      ## mesh modification
 -    #  @param typ  the type of elements in the group; either of 
 +    #  @param typ  the type of elements in the group; either of
      #         (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
      #  @param name the name of the mesh group
      #  @param filter the filter defining group contents
  
      ## Create a mesh group by the given ids of elements
      #  @param groupName the name of the mesh group
 -    #  @param elementType the type of elements in the group; either of 
 +    #  @param elementType the type of elements in the group; either of
      #         (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
      #  @param elemIDs either the list of ids, group, sub-mesh, or filter
      #  @return SMESH_Group
  
      ## Get the list of groups existing in the mesh in the order
      #  of creation (starting from the oldest one)
 -    #  @param elemType type of elements the groups contain; either of 
 +    #  @param elemType type of elements the groups contain; either of
      #         (SMESH.ALL, SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME);
      #         by default groups of elements of all types are returned
      #  @return a sequence of SMESH_GroupBase
  
      ## Find groups by name and type
      #  @param name name of the group of interest
 -    #  @param elemType type of elements the groups contain; either of 
 +    #  @param elemType type of elements the groups contain; either of
      #         (SMESH.ALL, SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME);
      #         by default one group of any type of elements is returned
      #         if elemType == SMESH.ALL then all groups of any type are returned
              if group.GetName() == name:
                  if elemType is None:
                      return [group]
 -                if ( elemType == SMESH.ALL or 
 +                if ( elemType == SMESH.ALL or
                       group.GetType() == elemType ):
                      groups.append( group )
          return groups
      #  @return an instance of SMESH_Group
      #  @ingroup l2_grps_operon
      def UnionListOfGroups(self, groups, name):
 -      return self.mesh.UnionListOfGroups(groups, name)
 +        return self.mesh.UnionListOfGroups(groups, name)
  
      ## Prodice an intersection of two groups.
      #  A new group is created. All mesh elements that are common
      #  @return an instance of SMESH_Group
      #  @ingroup l2_grps_operon
      def IntersectListOfGroups(self, groups, name):
 -      return self.mesh.IntersectListOfGroups(groups, name)
 +        return self.mesh.IntersectListOfGroups(groups, name)
  
      ## Produce a cut of two groups.
      #  A new group is created. All mesh elements that are present in
      ##
      #  Create a standalone group of entities basing on nodes of other groups.
      #  \param groups - list of reference groups, sub-meshes or filters, of any type.
 -    #  \param elemType - a type of elements to include to the new group; either of 
 +    #  \param elemType - a type of elements to include to the new group; either of
      #         (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME).
      #  \param name - a name of the new group.
      #  \param nbCommonNodes - a criterion of inclusion of an element to the new group
      def GetId(self):
          return self.mesh.GetId()
  
 -    ## Get the study Id
 -    #  @return integer value, which is the study Id of the mesh
 -    #  @ingroup l1_auxiliary
 -    def GetStudyId(self):
 -        return self.mesh.GetStudyId()
 -
      ## Check the group names for duplications.
      #  Consider the maximum group name length stored in MED file.
      #  @return True or False
      def Add0DElement( self, IDOfNode, DuplicateElements=True ):
          return self.editor.Add0DElement( IDOfNode, DuplicateElements )
  
 -    ## Create 0D elements on all nodes of the given elements except those 
 +    ## Create 0D elements on all nodes of the given elements except those
      #  nodes on which a 0D element already exists.
      #  @param theObject an object on whose nodes 0D elements will be created.
      #         It can be mesh, sub-mesh, group, list of element IDs or a holder
      #         and/or found on nodes of \a theObject.
      #  @param DuplicateElements to add one more 0D element to a node or not
      #  @return an object (a new group or a temporary SMESH_IDSource) holding
 -    #          IDs of new and/or found 0D elements. IDs of 0D elements 
 +    #          IDs of new and/or found 0D elements. IDs of 0D elements
      #          can be retrieved from the returned object by calling GetIDs()
      #  @ingroup l2_modif_add
      def Add0DElementsToAllNodes(self, theObject, theGroupName="", DuplicateElements=False):
              VertexID = Vertex
          try:
              self.editor.SetNodeOnVertex(NodeID, VertexID)
 -        except SALOME.SALOME_Exception, inst:
 -            raise ValueError, inst.details.text
 +        except SALOME.SALOME_Exception as inst:
 +            raise ValueError(inst.details.text)
          return True
  
  
              EdgeID = Edge
          try:
              self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
 -        except SALOME.SALOME_Exception, inst:
 -            raise ValueError, inst.details.text
 +        except SALOME.SALOME_Exception as inst:
 +            raise ValueError(inst.details.text)
          return True
  
      ## @brief Stores node position on a face
              FaceID = Face
          try:
              self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
 -        except SALOME.SALOME_Exception, inst:
 -            raise ValueError, inst.details.text
 +        except SALOME.SALOME_Exception as inst:
 +            raise ValueError(inst.details.text)
          return True
  
      ## @brief Binds a node to a solid
              SolidID = Solid
          try:
              self.editor.SetNodeInVolume(NodeID, SolidID)
 -        except SALOME.SALOME_Exception, inst:
 -            raise ValueError, inst.details.text
 +        except SALOME.SALOME_Exception as inst:
 +            raise ValueError(inst.details.text)
          return True
  
      ## @brief Bind an element to a shape
              ShapeID = Shape
          try:
              self.editor.SetMeshElementOnShape(ElementID, ShapeID)
 -        except SALOME.SALOME_Exception, inst:
 -            raise ValueError, inst.details.text
 +        except SALOME.SALOME_Exception as inst:
 +            raise ValueError(inst.details.text)
          return True
  
  
      #  @param x  the X coordinate of a point
      #  @param y  the Y coordinate of a point
      #  @param z  the Z coordinate of a point
 -    #  @param elementType type of elements to find; either of 
 +    #  @param elementType type of elements to find; either of
      #         (SMESH.NODE, SMESH.EDGE, SMESH.FACE, SMESH.VOLUME); SMESH.ALL type
      #         means elements of any type excluding nodes, discrete and 0D elements.
      #  @param meshPart a part of mesh (group, sub-mesh) to search within
          return self.editor.TriToQuadObject(theObject, Functor, MaxAngle)
  
      ## Split quadrangles into triangles.
-     #  @param IDsOfElements the faces to be splitted.
+     #  @param IDsOfElements the faces to be split.
      #  @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to
      #         choose a diagonal for splitting. If @a theCriterion is None, which is a default
      #         value, then quadrangles will be split by the smallest diagonal.
  
      ## Split each of given quadrangles into 4 triangles. A node is added at the center of
      #  a quadrangle.
-     #  @param theElements the faces to be splitted. This can be either mesh, sub-mesh,
+     #  @param theElements the faces to be split. This can be either mesh, sub-mesh,
      #         group or a list of face IDs. By default all quadrangles are split
      #  @ingroup l2_modif_cutquadr
      def QuadTo4Tri (self, theElements=[]):
          return self.editor.QuadTo4Tri( theElements )
  
      ## Split quadrangles into triangles.
-     #  @param IDsOfElements the faces to be splitted
+     #  @param IDsOfElements the faces to be split
      #  @param Diag13        is used to choose a diagonal for splitting.
      #  @return TRUE in case of success, FALSE otherwise.
      #  @ingroup l2_modif_cutquadr
          return self.editor.SplitQuadObject(theObject, Diag13)
  
      ## Find a better splitting of the given quadrangle.
-     #  @param IDOfQuad   the ID of the quadrangle to be splitted.
+     #  @param IDOfQuad   the ID of the quadrangle to be split.
      #  @param theCriterion  is a numerical functor, in terms of enum SMESH.FunctorType, used to
      #         choose a diagonal for splitting.
      #         Type SMESH.FunctorType._items in the Python Console to see all items.
          pattern = self.smeshpyD.GetPattern()
          isDone  = pattern.LoadFromFile(pattern_tetra)
          if not isDone:
 -            print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
 +            print('Pattern.LoadFromFile :', pattern.GetErrorCode())
              return isDone
  
          pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
          isDone = pattern.MakeMesh(self.mesh, False, False)
 -        if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
 +        if not isDone: print('Pattern.MakeMesh :', pattern.GetErrorCode())
  
          # split quafrangle faces near triangular facets of volumes
          self.SplitQuadsNearTriangularFacets()
          pattern = self.smeshpyD.GetPattern()
          isDone  = pattern.LoadFromFile(pattern_prism)
          if not isDone:
 -            print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
 +            print('Pattern.LoadFromFile :', pattern.GetErrorCode())
              return isDone
  
          pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
          isDone = pattern.MakeMesh(self.mesh, False, False)
 -        if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
 +        if not isDone: print('Pattern.MakeMesh :', pattern.GetErrorCode())
  
          # Split quafrangle faces near triangular facets of volumes
          self.SplitQuadsNearTriangularFacets()
                  self.editor.ConvertToQuadratic(theForce3d)
          error = self.editor.GetLastError()
          if error and error.comment:
 -            print error.comment
 +            print(error.comment)
          return error
 -            
 +
      ## Convert the mesh from quadratic to ordinary,
      #  deletes old quadratic elements, \n replacing
      #  them with ordinary mesh elements with the same id.
          return mesh, group
  
      ##
 -    # @brief Create missing boundary elements around either the whole mesh or 
 +    # @brief Create missing boundary elements around either the whole mesh or
      #    groups of elements
      #  @param dimension - defines type of boundary elements to create, either of
      #                     { SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D }
      #  @param groupName - a name of group to store all boundary elements in,
      #    "" means not to create the group
 -    #  @param meshName - a name of a new mesh, which is a copy of the initial 
 +    #  @param meshName - a name of a new mesh, which is a copy of the initial
      #    mesh + created boundary elements; "" means not to create the new mesh
      #  @param toCopyAll - if true, the whole initial mesh will be copied into
      #    the new mesh else only boundary elements will be copied into the new mesh
          if isinstance( basePoint, int):
              xyz = self.GetNodeXYZ( basePoint )
              if not xyz:
 -                raise RuntimeError, "Invalid node ID: %s" % basePoint
 +                raise RuntimeError("Invalid node ID: %s" % basePoint)
              basePoint = xyz
          if isinstance( basePoint, geomBuilder.GEOM._objref_GEOM_Object ):
              basePoint = self.geompyD.PointCoordinates( basePoint )
              Elements = [ Elements.GetMesh() ]
          if isinstance( Elements, list ):
              if not Elements:
 -                raise RuntimeError, "Elements empty!"
 +                raise RuntimeError("Elements empty!")
              if isinstance( Elements[0], int ):
                  Elements = self.GetIDSource( Elements, SMESH.ALL )
                  unRegister.set( Elements )
          if ( isinstance( thePoint, list )):
              thePoint = PointStruct( thePoint[0], thePoint[1], thePoint[2] )
          if ( isinstance( theScaleFact, float )):
 -             theScaleFact = [theScaleFact]
 +            theScaleFact = [theScaleFact]
          if ( isinstance( theScaleFact, int )):
 -             theScaleFact = [ float(theScaleFact)]
 +            theScaleFact = [ float(theScaleFact)]
  
          self.mesh.SetParameters(thePoint.parameters)
  
          if ( isinstance( thePoint, list )):
              thePoint = PointStruct( thePoint[0], thePoint[1], thePoint[2] )
          if ( isinstance( theScaleFact, float )):
 -             theScaleFact = [theScaleFact]
 +            theScaleFact = [theScaleFact]
          if ( isinstance( theScaleFact, int )):
 -             theScaleFact = [ float(theScaleFact)]
 +            theScaleFact = [ float(theScaleFact)]
  
          self.mesh.SetParameters(thePoint.parameters)
          mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
          if holeNodes and isinstance( holeNodes, list ) and isinstance( holeNodes[0], int ):
              holeNodes = SMESH.FreeBorder(nodeIDs=holeNodes)
          if not isinstance( holeNodes, SMESH.FreeBorder ):
 -            raise TypeError, "holeNodes must be either SMESH.FreeBorder or list of integer and not %s" % holeNodes
 +            raise TypeError("holeNodes must be either SMESH.FreeBorder or list of integer and not %s" % holeNodes)
          self.editor.FillHole( holeNodes )
  
      ## Return groups of FreeBorder's coincident within the given tolerance.
      #  @ingroup l2_modif_trsf
      def FindCoincidentFreeBorders (self, tolerance=0.):
          return self.editor.FindCoincidentFreeBorders( tolerance )
 -        
 +
      ## Sew FreeBorder's of each group
      #  @param freeBorders either a SMESH.CoincidentFreeBorders structure or a list of lists
      #         where each enclosed list contains node IDs of a group of coincident free
              coincidentGroups = []
              for nodeList in freeBorders:
                  if not nodeList or len( nodeList ) % 3:
 -                    raise ValueError, "Wrong number of nodes in this group: %s" % nodeList
 +                    raise ValueError("Wrong number of nodes in this group: %s" % nodeList)
                  group = []
                  while nodeList:
                      group.append  ( SMESH.FreeBorderPart( len(borders), 0, 1, 2 ))
      def ClearLastCreated(self):
          self.editor.ClearLastCreated()
  
 -    ## Create duplicates of given elements, i.e. create new elements based on the 
 +    ## Create duplicates of given elements, i.e. create new elements based on the
      #  same nodes as the given ones.
      #  @param theElements - container of elements to duplicate. It can be a Mesh,
      #         sub-mesh, group, filter or a list of element IDs. If \a theElements is
      #  @param theGroupName - a name of group to contain the generated elements.
      #                    If a group with such a name already exists, the new elements
      #                    are added to the existng group, else a new group is created.
 -    #                    If \a theGroupName is empty, new elements are not added 
 +    #                    If \a theGroupName is empty, new elements are not added
      #                    in any group.
      # @return a group where the new elements are added. None if theGroupName == "".
      #  @ingroup l2_modif_duplicat
      #  @return TRUE if operation has been completed successfully, FALSE otherwise
      #  @ingroup l2_modif_duplicat
      def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems, onAllBoundaries=False ):
 -       return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems, onAllBoundaries )
 +        return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems, onAllBoundaries )
  
      ## Double nodes on some external faces and create flat elements.
      #  Flat elements are mainly used by some types of mechanic calculations.
 -    #  
 +    #
      #  Each group of the list must be constituted of faces.
      #  Triangles are transformed in prisms, and quadrangles in hexahedrons.
      #  @param theGroupsOfFaces - list of groups of faces
      #  @ingroup l2_modif_duplicat
      def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
          return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
 -    
 +
      ## identify all the elements around a geom shape, get the faces delimiting the hole
      #
      def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords):
          if not fn:
              fn = self.smeshpyD.GetFunctor(funcType)
              fn.SetMesh(self.mesh)
 -            self.functors[ funcType._v ] = fn
 +            self.functors[ EnumToLong(funcType) ] = fn
          return fn
  
      ## Return value of a functor for a given element
  #  with old dump scripts which call SMESH_Mesh directly and not via smeshBuilder.Mesh
  #
  class meshProxy(SMESH._objref_SMESH_Mesh):
 -    def __init__(self):
 -        SMESH._objref_SMESH_Mesh.__init__(self)
 +    def __init__(self, *args):
 +        SMESH._objref_SMESH_Mesh.__init__(self, *args)
      def __deepcopy__(self, memo=None):
 -        new = self.__class__()
 +        new = self.__class__(self)
          return new
      def CreateDimGroup(self,*args): # 2 args added: nbCommonNodes, underlyingOnly
          if len( args ) == 3:
              args += SMESH.ALL_NODES, True
 -        return SMESH._objref_SMESH_Mesh.CreateDimGroup( self, *args )
 +        return SMESH._objref_SMESH_Mesh.CreateDimGroup(self, *args)
 +    def ExportToMEDX(self, *args): # function removed
 +        print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
 +        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
 +        SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
 +    def ExportToMED(self, *args): # function removed
 +        print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
 +        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
 +        while len(args) < 4:  # !!!! nb of parameters for ExportToMED IDL's method
 +            args.append(True)
 +        SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
 +    def ExportPartToMED(self, *args): # 'version' parameter removed
 +        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
 +        SMESH._objref_SMESH_Mesh.ExportPartToMED(self, *args)
 +    def ExportMED(self, *args): # signature of method changed
 +        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
 +        while len(args) < 4:  # !!!! nb of parameters for ExportToMED IDL's method
 +            args.append(True)
 +        SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
      pass
  omniORB.registerObjref(SMESH._objref_SMESH_Mesh._NP_RepositoryId, meshProxy)
  
  ## Private class wrapping SMESH.SMESH_SubMesh in order to add Compute()
  #
  class submeshProxy(SMESH._objref_SMESH_subMesh):
 -    def __init__(self):
 -        SMESH._objref_SMESH_subMesh.__init__(self)
 +    def __init__(self, *args):
 +        SMESH._objref_SMESH_subMesh.__init__(self, *args)
          self.mesh = None
      def __deepcopy__(self, memo=None):
 -        new = self.__class__()
 +        new = self.__class__(self)
          return new
  
      ## Compute the sub-mesh and return the status of the computation
  
          ok = self.mesh.Compute( self.GetSubShape(),refresh=[] )
  
 -        if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
 +        if salome.sg.hasDesktop():
              smeshgui = salome.ImportComponentGUI("SMESH")
 -            smeshgui.Init(self.mesh.GetStudyId())
 +            smeshgui.Init()
              smeshgui.SetMeshIcon( salome.ObjectToID( self ), ok, (self.GetNumberOfElements()==0) )
 -            if refresh: salome.sg.updateObjBrowser(True)
 +            if refresh: salome.sg.updateObjBrowser()
              pass
  
          return ok
@@@ -5307,8 -5213,8 +5319,8 @@@ omniORB.registerObjref(SMESH._objref_SM
  #  smeshBuilder.Mesh
  #
  class meshEditor(SMESH._objref_SMESH_MeshEditor):
 -    def __init__(self):
 -        SMESH._objref_SMESH_MeshEditor.__init__(self)
 +    def __init__(self, *args):
 +        SMESH._objref_SMESH_MeshEditor.__init__(self, *args)
          self.mesh = None
      def __getattr__(self, name ): # method called if an attribute not found
          if not self.mesh:         # look for name() method in Mesh class
              return getattr( self.mesh, name )
          if name == "ExtrusionAlongPathObjX":
              return getattr( self.mesh, "ExtrusionAlongPathX" ) # other method name
 -        print "meshEditor: attribute '%s' NOT FOUND" % name
 +        print("meshEditor: attribute '%s' NOT FOUND" % name)
          return None
      def __deepcopy__(self, memo=None):
 -        new = self.__class__()
 +        new = self.__class__(self)
          return new
      def FindCoincidentNodes(self,*args): # a 2nd arg added (SeparateCornerAndMediumNodes)
          if len( args ) == 1: args += False,
@@@ -5386,8 -5292,8 +5398,8 @@@ class algoCreator
  
      # Store a python class of algorithm
      def add(self, algoClass):
 -        if type( algoClass ).__name__ == 'classobj' and \
 -           hasattr( algoClass, "algoType"):
 +        if inspect.isclass(algoClass) and \
 +           hasattr(algoClass, "algoType"):
              self.algoTypeToClass[ algoClass.algoType ] = algoClass
              if not self.defaultAlgoType and \
                 hasattr( algoClass, "isDefault") and algoClass.isDefault:
              algoType = self.defaultAlgoType
          if not algoType and self.algoTypeToClass:
              algoType = sorted( self.algoTypeToClass.keys() )[0]
 -        if self.algoTypeToClass.has_key( algoType ):
 +        if algoType in self.algoTypeToClass:
              #print "Create algo",algoType
 +
              return self.algoTypeToClass[ algoType ]( self.mesh, shape )
 -        raise RuntimeError, "No class found for algo type %s" % algoType
 +        raise RuntimeError( "No class found for algo type %s" % algoType)
          return None
  
  ## Private class used to substitute and store variable parameters of hypotheses.
@@@ -5464,11 -5369,11 +5476,11 @@@ class hypMethodWrapper
          except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
              # maybe there is a replaced string arg which is not variable
              result = self.method( self.hyp, *args )
 -        except ValueError, detail: # raised by ParseParameters()
 +        except ValueError as detail: # raised by ParseParameters()
              try:
                  result = self.method( self.hyp, *args )
              except omniORB.CORBA.BAD_PARAM:
 -                raise ValueError, detail # wrong variable name
 +                raise ValueError(detail) # wrong variable name
  
          return result
      pass
@@@ -5504,9 -5409,9 +5516,9 @@@ for pluginName in os.environ[ "SMESH_Me
      pluginBuilderName = pluginName + "Builder"
      try:
          exec( "from salome.%s.%s import *" % (pluginName, pluginBuilderName))
 -    except Exception, e:
 -      from salome_utils import verbose
 -      if verbose(): print "Exception while loading %s: %s" % ( pluginBuilderName, e )
 +    except Exception as e:
 +        from salome_utils import verbose
 +        if verbose(): print("Exception while loading %s: %s" % ( pluginBuilderName, e ))
          continue
      exec( "from salome.%s import %s" % (pluginName, pluginBuilderName))
      plugin = eval( pluginBuilderName )
          if k[0] == '_': continue
          algo = getattr( plugin, k )
          #print "             algo:", str(algo)
 -        if type( algo ).__name__ == 'classobj' and hasattr( algo, "meshMethod" ):
 +        if inspect.isclass(algo) and hasattr(algo, "meshMethod"):
              #print "                     meshMethod:" , str(algo.meshMethod)
              if not hasattr( Mesh, algo.meshMethod ):
                  setattr( Mesh, algo.meshMethod, algoCreator( algo.meshMethod ))
index d30f7f21af0e92b661f6c982bec900d888cf4d05,e5b5a3d6a3ee529fa2a4b0c3c8ab1025f137fcb1..92999bf2e2c5a8c861352cf1f177a79c5b45185d
@@@ -58,7 -58,7 +58,7 @@@ import SMESH, StdMesher
  #  @ingroup l2_algorithms
  class Mesh_Algorithm:
      
-     ## Private constuctor
+     ## Private constructor
      def __init__(self):
          self.mesh = None
          self.geom = None
@@@ -70,7 -70,7 +70,7 @@@
      #  Finds only the hypotheses created in smeshpyD engine.
      #  @return SMESH.SMESH_Hypothesis
      def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
 -        study = smeshpyD.GetCurrentStudy()
 +        study = salome.myStudy
          if not study: return None
          #to do: find component by smeshpyD object, not by its data type
          scomp = study.FindComponent(smeshpyD.ComponentDataType())
      #  Finds only the algorithms, which have been created in smeshpyD engine.
      #  @return SMESH.SMESH_Algo
      def FindAlgorithm (self, algoname, smeshpyD):
 -        study = smeshpyD.GetCurrentStudy()
 +        study = salome.myStudy
          if not study: return None
          #to do: find component by smeshpyD object, not by its data type
          scomp = study.FindComponent(smeshpyD.ComponentDataType())
      ## Private method.
      def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
          if geom is None and mesh.mesh.HasShapeToMesh():
 -            raise RuntimeError, "Attempt to create " + hypo + " algorithm on None shape"
 +            raise RuntimeError("Attempt to create " + hypo + " algorithm on None shape")
          algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
          if algo is None:
              algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
      def Assign(self, algo, mesh, geom):
          from salome.smesh.smeshBuilder import AssureGeomPublished, TreatHypoStatus, GetName
          if geom is None and mesh.mesh.HasShapeToMesh():
 -            raise RuntimeError, "Attempt to create " + algo + " algorithm on None shape"
 +            raise RuntimeError("Attempt to create " + algo + " algorithm on None shape")
          self.mesh = mesh
          if not geom or geom.IsSame( mesh.geom ):
              self.geom = mesh.geom
          return
  
      def CompareHyp (self, hyp, args):
 -        print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
 +        print("CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName())
          return False
  
      def CompareEqualHyp (self, hyp, args):
      def ViscousLayers(self, thickness, numberOfLayers, stretchFactor,
                        faces=[], isFacesToIgnore=True, extrMethod=StdMeshers.SURF_OFFSET_SMOOTH ):
          if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
 -            raise TypeError, "ViscousLayers are supported by 3D algorithms only"
 +            raise TypeError("ViscousLayers are supported by 3D algorithms only")
          if not "ViscousLayers" in self.GetCompatibleHypothesis():
 -            raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
 +            raise TypeError("ViscousLayers are not supported by %s"%self.algo.GetName())
          if faces and isinstance( faces, geomBuilder.GEOM._objref_GEOM_Object ):
              faces = [ faces ]
          if faces and isinstance( faces[0], geomBuilder.GEOM._objref_GEOM_Object ):
      def ViscousLayers2D(self, thickness, numberOfLayers, stretchFactor,
                          edges=[], isEdgesToIgnore=True ):
          if not isinstance(self.algo, SMESH._objref_SMESH_2D_Algo):
 -            raise TypeError, "ViscousLayers2D are supported by 2D algorithms only"
 +            raise TypeError("ViscousLayers2D are supported by 2D algorithms only")
          if not "ViscousLayers2D" in self.GetCompatibleHypothesis():
 -            raise TypeError, "ViscousLayers2D are not supported by %s"%self.algo.GetName()
 +            raise TypeError("ViscousLayers2D are not supported by %s"%self.algo.GetName())
          if edges and not isinstance( edges, list ) and not isinstance( edges, tuple ):
              edges = [edges]
          if edges and isinstance( edges[0], geomBuilder.GEOM._objref_GEOM_Object ):
              if isinstance( i, int ):
                  s = geompy.SubShapes(self.mesh.geom, [i])[0]
                  if s.GetShapeType() != geomBuilder.GEOM.EDGE:
 -                    raise TypeError, "Not EDGE index given"
 +                    raise TypeError("Not EDGE index given")
                  resList.append( i )
              elif isinstance( i, geomBuilder.GEOM._objref_GEOM_Object ):
                  if i.GetShapeType() != geomBuilder.GEOM.EDGE:
 -                    raise TypeError, "Not an EDGE given"
 +                    raise TypeError("Not an EDGE given")
                  resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
              elif len( i ) > 1:
                  e = i[0]
                  v = i[1]
                  if not isinstance( e, geomBuilder.GEOM._objref_GEOM_Object ) or \
                     not isinstance( v, geomBuilder.GEOM._objref_GEOM_Object ):
 -                    raise TypeError, "A list item must be a tuple (edge, 1st_vertex_of_edge)"
 +                    raise TypeError("A list item must be a tuple (edge, 1st_vertex_of_edge)")
                  if v.GetShapeType() == geomBuilder.GEOM.EDGE and \
                     e.GetShapeType() == geomBuilder.GEOM.VERTEX:
                      v,e = e,v
                  if e.GetShapeType() != geomBuilder.GEOM.EDGE or \
                     v.GetShapeType() != geomBuilder.GEOM.VERTEX:
 -                    raise TypeError, "A list item must be a tuple (edge, 1st_vertex_of_edge)"
 +                    raise TypeError("A list item must be a tuple (edge, 1st_vertex_of_edge)")
                  vFirst = FirstVertexOnCurve( self.mesh, e )
                  tol    = geompy.Tolerance( vFirst )[-1]
                  if geompy.MinDistance( v, vFirst ) > 1.5*tol:
                      resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
              else:
 -                raise TypeError, "Item must be either an edge or tuple (edge, 1st_vertex_of_edge)"
 +                raise TypeError("Item must be either an edge or tuple (edge, 1st_vertex_of_edge)")
          return resList
  
index 629ade75fa65025f4555b14a9941a2594e882d97,1dff2051523f9b99505cac09045bc8c84c922410..89cea269a479528f6a5ee04bb96db512cb966b3c
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Arithmetic1D.cxx
  //  Author : Damien COQUERET, OCC
  //  Module : SMESH
@@@ -48,8 -48,8 +48,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, SMESH_Gen * gen)
 +  :SMESH_Hypothesis(hypId, gen)
  {
    _begLength = 1.;
    _endLength = 10.;
index 7dd89459be51a82dbc8a2f63047af03e44e8f2b6,a95940dc4915e2479c0cc838565a7f8d88d482ac..e0b9cd9b76bd79889062e82ecfb10a077730370e
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Arithmetic1D.hxx
  //  Author : Damien COQUERET, OCC
  //  Module : SMESH
@@@ -41,7 -41,7 +41,7 @@@ class STDMESHERS_EXPORT StdMeshers_Arit
    public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Arithmetic1D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_Arithmetic1D();
  
    void SetLength(double length, bool isStartLength) throw(SALOME_Exception);
index 9e2ce9748eb132b1c2f7216f1fb7b1ffb3548d40,4e49040c1f0787dd0dbe7787c10db7da03d1b5f6..1041134d00bb98ee487bc4ec298cc2353b9f5419
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_AutomaticLength.cxx
  //  Author : Edward AGAPOV, OCC
  //  Module : SMESH
@@@ -47,8 -47,8 +47,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, SMESH_Gen * gen)
 +  :SMESH_Hypothesis(hypId, gen)
  {
    _name = "AutomaticLength";
    _param_algo_dim = 1; // is used by SMESH_Regular_1D
index f9188e374c07865f96bcfcd1f091fdd3f211f90c,d3da396c270b1880d20de641f2eedfae08bd2bbb..eb5b1cfb870ecb764c6a97b4ba8357bfd32402cd
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_AutomaticLength.hxx
  //  Author : Edward AGAPOV, OCC
  //  Module : SMESH
@@@ -49,7 -49,7 +49,7 @@@ class TopoDS_TShape
  class STDMESHERS_EXPORT StdMeshers_AutomaticLength:public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_AutomaticLength(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_AutomaticLength(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_AutomaticLength();
  
    /*!
index fd0cc16663b571544aae340622f05894d9e5d345,62e590b62e4293f6ba6a621be5db9fb3a33b2b05..1a0b026ecc74d0cc7d402dd1d687fe1df9be56b3
@@@ -107,8 -107,8 +107,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_Cartesian_3D::StdMeshers_Cartesian_3D(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_3D_Algo(hypId, studyId, gen)
 +StdMeshers_Cartesian_3D::StdMeshers_Cartesian_3D(int hypId, SMESH_Gen * gen)
 +  :SMESH_3D_Algo(hypId, gen)
  {
    _name = "Cartesian_3D";
    _shapeType = (1 << TopAbs_SOLID);       // 1 bit /shape type
@@@ -2460,7 -2460,7 +2460,7 @@@ namespac
        ip._faceIDs = e2fIt->second;
        ip._shapeID = edgeID;
  
-       // discretize the EGDE
+       // discretize the EDGE
        GCPnts_UniformDeflection discret( curve, deflection, true );
        if ( !discret.IsDone() || discret.NbPoints() < 2 )
          continue;
    }
    //================================================================================
    /*!
-    * \brief Classify a point by grid paremeters
+    * \brief Classify a point by grid parameters
     */
    bool Hexahedron::isOutParam(const double uvw[3]) const
    {
@@@ -3588,7 -3588,7 +3588,7 @@@ bool StdMeshers_Cartesian_3D::Compute(S
        facesItersectors[i].Intersect();
  #endif
  
-     // put interesection points onto the GridLine's; this is done after intersection
+     // put intersection points onto the GridLine's; this is done after intersection
      // to avoid contention of facesItersectors for writing into the same GridLine
      // in case of parallel work of facesItersectors
      for ( size_t i = 0; i < facesItersectors.size(); ++i )
index 431de7ef9cc0bc1cf66e6e043eda2a246b5bf5cb,ebdbd9ee47e0603cc27b89b7f55d12677945b6bd..7dff14e7e0097f688496c13288a7fd5ce4d7b3af
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_CompositeHexa_3D.cxx
  // Module    : SMESH
  // Created   : Tue Nov 25 11:04:59 2008
@@@ -85,7 -85,7 +85,7 @@@ enum EAxes{ COO_X=1, COO_Y, COO_Z }
  
  //================================================================================
  /*!
-  * \brief Convertor of a pair of integers to a sole index
+  * \brief Converter of a pair of integers to a sole index
   */
  struct _Indexer
  {
@@@ -267,8 -267,8 +267,8 @@@ private
   */
  //================================================================================
  
 -StdMeshers_CompositeHexa_3D::StdMeshers_CompositeHexa_3D(int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_3D_Algo(hypId, studyId, gen)
 +StdMeshers_CompositeHexa_3D::StdMeshers_CompositeHexa_3D(int hypId, SMESH_Gen* gen)
 +  :SMESH_3D_Algo(hypId, gen)
  {
    _name = "CompositeHexa_3D";
    _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);       // 1 bit /shape type
@@@ -564,7 -564,7 +564,7 @@@ bool StdMeshers_CompositeHexa_3D::findB
    if ( !fTop )
      return error(COMPERR_BAD_SHAPE);
  
-   // orient bottom egde of faces along axes of the unit box
+   // orient bottom edge of faces along axes of the unit box
    fBottom->ReverseEdges();
    fBack  ->ReverseEdges();
    fLeft  ->ReverseEdges();
   * \brief Computes hexahedral mesh on a box with composite sides
   *  \param aMesh - mesh to compute
   *  \param aShape - shape to mesh
-  *  \retval bool - succes sign
+  *  \retval bool - success sign
   */
  //================================================================================
  
@@@ -1158,7 -1158,7 +1158,7 @@@ bool _QuadFaceGrid::LoadGrid( SMESH_Mes
  
    myGrid.resize( myIndexer.size() );
  
-   // strore nodes bound to the bottom edge
+   // store nodes bound to the bottom edge
    mySides.GetSide( Q_BOTTOM )->StoreNodes( mesh, myGrid, myReverse );
  
    // store the rest nodes row by row
index 0b8e8f80d0a6e8a38325bfde41e609a175c27776,85cc6f2ec6c89f13064b897cff66f7fe5e0cb450..4987b2598df3b352f4d6a8d49f962928b03cb493
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_CompositeBlock_3D.hxx
  //  Module : SMESH
  //
@@@ -42,7 -42,7 +42,7 @@@ struct _QuadFaceGrid
  class STDMESHERS_EXPORT StdMeshers_CompositeHexa_3D: public SMESH_3D_Algo
  {
  public:
 -  StdMeshers_CompositeHexa_3D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_CompositeHexa_3D(int hypId, SMESH_Gen* gen);
    //virtual ~StdMeshers_CompositeHexa_3D();
  
    virtual bool Compute(SMESH_Mesh&         aMesh,
index 3992bc81add4db55f2f1c76d67818ecdc66049dc,ee3858c26b53472351d82a11e8dde106ab5b870a..aa3f460a4ce0d4a4ada50855217f3f906b7e5fbc
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_CompositeSegment_1D.cxx
  //  Module : SMESH
  //
@@@ -243,8 -243,9 +243,8 @@@ namespace 
  //=============================================================================
  
  StdMeshers_CompositeSegment_1D::StdMeshers_CompositeSegment_1D(int         hypId,
 -                                                               int         studyId,
                                                                 SMESH_Gen * gen)
 -  :StdMeshers_Regular_1D(hypId, studyId, gen)
 +  :StdMeshers_Regular_1D(hypId, gen)
  {
    _name = AlgoName();
  }
index 86436bd1839f727ca631f73ac23504b81d98de43,1a0129813037a17b80e60f8d22258d0f3061487a..7c2d2c046c8750bc2724f4c4084f65cf7b063dd7
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_CompositeSegment_1D.hxx
  //  Module : SMESH
  //
@@@ -39,7 -39,7 +39,7 @@@ class TopoDS_Face
  class STDMESHERS_EXPORT StdMeshers_CompositeSegment_1D: public StdMeshers_Regular_1D
  {
  public:
 -  StdMeshers_CompositeSegment_1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_CompositeSegment_1D(int hypId, SMESH_Gen* gen);
  
    virtual bool Compute(SMESH_Mesh&         aMesh,
                         const TopoDS_Shape& aShape);
index 2db55f223e851bd1e93d654b06e7fd762b79d8d8,fa0fcb264a1a47fa4c732cb67a9d9508e48f2edc..1e9227d9d3aa5c02f7ef35eaeb115e75e77c7aef
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers_Deflection1D : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers_Deflection1D : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Deflection1D.cxx
  //  Module : SMESH
  //
@@@ -50,8 -50,9 +50,8 @@@ using namespace std
  //=============================================================================
  
  StdMeshers_Deflection1D::StdMeshers_Deflection1D(int         hypId,
 -                                                 int         studyId,
                                                   SMESH_Gen * gen)
 -     :SMESH_Hypothesis(hypId, studyId, gen)
 +     :SMESH_Hypothesis(hypId, gen)
  {
    _value = 1.;
    _name = "Deflection1D";
index 34a2d34ee65c110b8fca2dc58ea4f87725b181a3,c1d2d741d7966689b96a3be4e3330ebc0420915b..466aa20cff43f24a4a90eb83ac1735a734a5ea68
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Deflection1D.hxx
  //  Module : SMESH
  //
@@@ -35,7 -35,7 +35,7 @@@
  class STDMESHERS_EXPORT StdMeshers_Deflection1D:public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_Deflection1D(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_Deflection1D(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_Deflection1D();
  
    void SetDeflection(double value) throw(SALOME_Exception);
index 9f32b2d862f8196203af2e5d7e31644fb313448d,254df4e1c2063d538d047ed2a4094d914ba0c542..b5934045b4fa19d3558f49faca6e0ac3453548dd
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_FixedPoints1D.cxx
  //  Author : Damien COQUERET, OCC
  //  Module : SMESH
@@@ -35,9 -35,9 +35,9 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId, int studyId,
 +StdMeshers_FixedPoints1D::StdMeshers_FixedPoints1D(int hypId,
                                                     SMESH_Gen * gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen)
 +  :SMESH_Hypothesis(hypId, gen)
  {
    _name = "FixedPoints1D";
    _param_algo_dim = 1;
index f8d8f6a755962e37aa44bf311a0b8730db669b56,342b5c9d5316d4486763c3b856eea534c6a62ff8..05f9030135a5c0abf7b5595a2351fb6e97844299
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_FixedPoints1D.hxx
  //  Author : Damien COQUERET, OCC
  //  Module : SMESH
@@@ -38,7 -38,7 +38,7 @@@ class STDMESHERS_EXPORT StdMeshers_Fixe
    public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_FixedPoints1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_FixedPoints1D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_FixedPoints1D();
  
    void SetPoints(std::vector<double>& listParams)
index b7eafade5dd0f93c4e122ff3f09810cd17180009,87514e2c9aea69233a7ce1d742aa6fb9e7930a2f..1d111112cb09d7a93e2e12068edcafcccc153922
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Geometric1D.cxx
  //  Module : SMESH
  //
@@@ -42,8 -42,8 +42,8 @@@
   */
  //=============================================================================
  
 -StdMeshers_Geometric1D::StdMeshers_Geometric1D(int hypId, int studyId, SMESH_Gen * gen)
 -  :StdMeshers_Reversible1D(hypId, studyId, gen)
 +StdMeshers_Geometric1D::StdMeshers_Geometric1D(int hypId, SMESH_Gen * gen)
 +  :StdMeshers_Reversible1D(hypId, gen)
  {
    _begLength = 1.;
    _ratio = 1.;
index 8810ad9855ffa7c9c629ca1a34a5e1f61ad964ca,4efc66101a7379bcfc60822a952c00a2756594ff..9e11b259a8b8addeeab6d0369907b6172ad67dd4
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Geometric1D.hxx
  //  Module : SMESH
  //
@@@ -35,7 -35,7 +35,7 @@@
  class STDMESHERS_EXPORT StdMeshers_Geometric1D: public StdMeshers_Reversible1D
  {
  public:
 -  StdMeshers_Geometric1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Geometric1D(int hypId, SMESH_Gen* gen);
  
    void SetStartLength(double length) throw(SALOME_Exception);
    void SetCommonRatio(double factor) throw(SALOME_Exception);
index 32edace13ca867aa0d45a1a189cdb83005bc2eba,a32b65891b4552a5a867931658beefe3b322a184..0cd90264c4dcd0a2d5592caa0ba1934693775a13
@@@ -145,7 -145,7 +145,7 @@@ namespac
  
    //================================================================================
    /*!
-    * \brief Convertor of a pair of integers to a sole index
+    * \brief Converter of a pair of integers to a sole index
     */
    struct _Indexer
    {
    };
    //================================================================================
    /*!
-    * \brief Oriented convertor of a pair of integers to a sole index 
+    * \brief Oriented converter of a pair of integers to a sole index 
     */
    class _OrientedIndexer : public _Indexer
    {
  //purpose  : 
  //=======================================================================
  
 -StdMeshers_HexaFromSkin_3D::StdMeshers_HexaFromSkin_3D(int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_3D_Algo(hypId, studyId, gen)
 +StdMeshers_HexaFromSkin_3D::StdMeshers_HexaFromSkin_3D(int hypId, SMESH_Gen* gen)
 +  :SMESH_3D_Algo(hypId, gen)
  {
    _name = "HexaFromSkin_3D";
  }
index a968121c58e6fda028db3d8c65cee8487daacbef,aa7b1c043afe64095f87a79f4e7b62d09b1b1815..72087519b3dcbe8cdeb0b37e21a9627166ef87c8
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Hexa_3D.cxx
  //           Moved here from SMESH_Hexa_3D.cxx
  //  Author : Paul RASCLE, EDF
@@@ -70,8 -70,8 +70,8 @@@ static bool EvaluatePentahedralMesh(SME
   */
  //=============================================================================
  
 -StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_3D_Algo(hypId, studyId, gen)
 +StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, SMESH_Gen * gen)
 +  :SMESH_3D_Algo(hypId, gen)
  {
    _name = "Hexa_3D";
    _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);       // 1 bit /shape type
@@@ -189,7 -189,7 +189,7 @@@ namespac
  
    //================================================================================
    /*!
-    * \brief Convertor of a pair of integers to a sole index
+    * \brief Converter of a pair of integers to a sole index
     */
    struct _Indexer
    {
@@@ -367,7 -367,7 +367,7 @@@ bool StdMeshers_Hexa_3D::Compute(SMESH_
    TopExp::MapShapes( aShape, TopAbs_FACE, FF);
    if ( FF.Extent() != 6)
    {
 -    static StdMeshers_CompositeHexa_3D compositeHexa(_gen->GetANewId(), 0, _gen);
 +    static StdMeshers_CompositeHexa_3D compositeHexa(_gen->GetANewId(), _gen);
      if ( !compositeHexa.Compute( aMesh, aShape ))
        return error( compositeHexa.GetComputeError() );
      return true;
    // ---------------------
    
    FaceQuadStructPtr quad[ 6 ];
 -  StdMeshers_Quadrangle_2D quadAlgo( _gen->GetANewId(), GetStudyId(), _gen);
 +  StdMeshers_Quadrangle_2D quadAlgo( _gen->GetANewId(), _gen);
    for ( int i = 0; i < 6; ++i )
    {
      if ( !( quad[i] = FaceQuadStructPtr( quadAlgo.CheckNbEdges( aMesh, FF( i+1 ),
@@@ -699,7 -699,7 +699,7 @@@ bool StdMeshers_Hexa_3D::Evaluate(SMESH
    }
    if (meshFaces.size() != 6) {
      //return error(COMPERR_BAD_SHAPE, TComm(meshFaces.size())<<" instead of 6 faces in a block");
 -    static StdMeshers_CompositeHexa_3D compositeHexa(-10, 0, aMesh.GetGen());
 +    static StdMeshers_CompositeHexa_3D compositeHexa(-10, aMesh.GetGen());
      return compositeHexa.Evaluate(aMesh, aShape, aResMap);
    }
    
@@@ -809,7 -809,7 +809,7 @@@ bool StdMeshers_Hexa_3D::Compute(SMESH_
    static StdMeshers_HexaFromSkin_3D * algo = 0;
    if ( !algo ) {
      SMESH_Gen* gen = aMesh.GetGen();
 -    algo = new StdMeshers_HexaFromSkin_3D( gen->GetANewId(), 0, gen );
 +    algo = new StdMeshers_HexaFromSkin_3D( gen->GetANewId(), gen );
    }
    algo->InitComputeError();
    algo->Compute( aMesh, aHelper );
@@@ -877,7 -877,7 +877,7 @@@ SMESH_ComputeErrorPtr ComputePentahedra
      static StdMeshers_Prism_3D * aPrism3D = 0;
      if ( !aPrism3D ) {
        SMESH_Gen* gen = aMesh.GetGen();
 -      aPrism3D = new StdMeshers_Prism_3D( gen->GetANewId(), 0, gen );
 +      aPrism3D = new StdMeshers_Prism_3D( gen->GetANewId(), gen );
      }
      SMESH_Hypothesis::Hypothesis_Status aStatus;
      if ( aPrism3D->CheckHypothesis( aMesh, aShape, aStatus ) ) {
@@@ -908,7 -908,7 +908,7 @@@ bool EvaluatePentahedralMesh(SMESH_Mes
      static StdMeshers_Prism_3D * aPrism3D = 0;
      if ( !aPrism3D ) {
        SMESH_Gen* gen = aMesh.GetGen();
 -      aPrism3D = new StdMeshers_Prism_3D( gen->GetANewId(), 0, gen );
 +      aPrism3D = new StdMeshers_Prism_3D( gen->GetANewId(), gen );
      }
      SMESH_Hypothesis::Hypothesis_Status aStatus;
      if ( aPrism3D->CheckHypothesis( aMesh, aShape, aStatus ) ) {
index 2f50e330f7eba7f3ed0246cd679e3faa2f2c2c15,0548c3ff46c154219820ee40d5375aa9f0fb6d54..6c0b04dbdb4076218852df4c8a63cd339a85b006
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Hexa_3D.hxx
  //           Moved here from SMESH_Hexa_3D.hxx
  //  Author : Paul RASCLE, EDF
@@@ -40,7 -40,7 +40,7 @@@ class SMESH_MesherHelper
  class STDMESHERS_EXPORT StdMeshers_Hexa_3D : public SMESH_3D_Algo
  {
  public:
 -  StdMeshers_Hexa_3D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Hexa_3D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_Hexa_3D();
  
    virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
index b737c57563a678fa75902b47adb47b337181e2e6,bf5128733638d46de93b96d07121fe3eb92f7ff6..c3860b26b6e05da7ffb97bf414b6fa4b3f0a6ecb
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers_ImportSource1D : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers_ImportSource1D : implementation of SMESH idl descriptions
  //  File   : StdMeshers_ImportSource1D.cxx
  //  Module : SMESH
  //
@@@ -49,8 -49,9 +49,8 @@@ using namespace std
  //=============================================================================
  
  StdMeshers_ImportSource1D::StdMeshers_ImportSource1D(int         hypId,
 -                                                     int         studyId,
                                                       SMESH_Gen * gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen),
 +  :SMESH_Hypothesis(hypId, gen),
     _toCopyMesh(false),
     _toCopyGroups(false)
  {
@@@ -65,8 -66,9 +65,8 @@@
  //=============================================================================
  
  StdMeshers_ImportSource2D::StdMeshers_ImportSource2D(int         hypId,
 -                                                     int         studyId,
                                                       SMESH_Gen * gen)
 -  :StdMeshers_ImportSource1D(hypId, studyId, gen)
 +  :StdMeshers_ImportSource1D(hypId, gen)
  {
    _name = "ImportSource2D";
    _param_algo_dim = 2; // is used by StdMeshers_Import_2D;
@@@ -204,7 -206,7 +204,7 @@@ const std::vector<SMESH_Group*>&  StdMe
  {
    // filter off deleted groups
    vector<SMESH_Group*> okGroups = getValidGroups( _groups,
 -                                                  _gen->GetStudyContext(_studyId),
 +                                                  _gen->GetStudyContext(),
                                                    loaded);
    if ( okGroups.size() != _groups.size() )
      ((StdMeshers_ImportSource1D*)this)->_groups = okGroups;
@@@ -245,7 -247,7 +245,7 @@@ std::vector<SMESH_Mesh*> StdMeshers_Imp
    vector<SMESH_Mesh*> meshes;
    if ( !meshIDs.empty() )
    {
 -    StudyContextStruct* studyContext = _gen->GetStudyContext(_studyId);
 +    StudyContextStruct* studyContext = _gen->GetStudyContext();
      for ( set<int>::iterator id = meshIDs.begin(); id != meshIDs.end(); ++id )
      {
        map<int, SMESH_Mesh*>::iterator itm = studyContext->mapMesh.begin();
@@@ -398,7 -400,7 +398,7 @@@ void StdMeshers_ImportSource1D::Restore
      int key1 = _resultGroupsStorage[i++];
      int key2 = _resultGroupsStorage[i++];
      pair<int, int> resMapKey( key1, key2 );
 -    SMESH_Mesh* mesh = getTgtMeshByKey( resMapKey, _gen->GetStudyContext(_studyId));
 +    SMESH_Mesh* mesh = getTgtMeshByKey( resMapKey, _gen->GetStudyContext());
      // restore mesh ids at least
      _resultGroups.insert( make_pair (resMapKey,vector<SMESH_Group*>() )); 
  
@@@ -461,7 -463,7 +461,7 @@@ StdMeshers_ImportSource1D::GetResultGro
    if ( key2groups == _resultGroups.end() )
      return 0;
    vector<SMESH_Group*> vec = getValidGroups((*key2groups).second,
 -                                            _gen->GetStudyContext(_studyId) );
 +                                            _gen->GetStudyContext() );
    if ( vec.size() != key2groups->second.size())
      key2groups->second = vec;
  
index cb2febf3b8524c74423f439c61bb044f8ed7447a,52329e514dd3b1d7f72e022300efc8c55ca89076..44077fd6fbc2565714d777dc78da91469ec49811
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers : implementation of SMESH idl descriptions
  //  File   : StdMeshers_ImportSource1D.hxx
  //  Module : SMESH
  //
@@@ -48,7 -48,7 +48,7 @@@ class SMESH_subMesh
  class STDMESHERS_EXPORT StdMeshers_ImportSource1D : public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_ImportSource1D(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_ImportSource1D(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_ImportSource1D();
  
    void SetGroups(const std::vector<SMESH_Group*>& groups);
@@@ -95,6 -95,6 +95,6 @@@ private
  class STDMESHERS_EXPORT StdMeshers_ImportSource2D : public StdMeshers_ImportSource1D
  {
   public:
 -  StdMeshers_ImportSource2D(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_ImportSource2D(int hypId, SMESH_Gen * gen);
  };
  #endif
index 61b6cf65b7bca7c20f4ce2b8ec81256b86d86387,aeb105383cecebebb26ccae74670cf2a2a632df8..20020982aeece4b3c8a32d4ce481ad864cd347a6
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Import_1D.cxx
  //  Module : SMESH
  //
@@@ -60,8 -60,8 +60,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_Import_1D::StdMeshers_Import_1D(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_1D_Algo(hypId, studyId, gen), _sourceHyp(0)
 +StdMeshers_Import_1D::StdMeshers_Import_1D(int hypId, SMESH_Gen * gen)
 +  :SMESH_1D_Algo(hypId, gen), _sourceHyp(0)
  {
    _name = "Import_1D";
    _shapeType = (1 << TopAbs_EDGE);
@@@ -211,7 -211,7 +211,7 @@@ namespace // INTERNAL STUF
                                             "StdMeshers_Import_1D::_Listener") {}
  
    public:
-     // return poiter to a static listener
+     // return pointer to a static listener
      static _Listener* get() { static _Listener theListener; return &theListener; }
  
      static _ImportData* getImportData(const SMESH_Mesh* srcMesh, SMESH_Mesh* tgtMesh);
index bbd752247c0624b7ac082e73e494cb325d355c3e,ffee0fe4c4f336b492f543b62b74065c07169b45..5d9e5997ad9e076d2c61195b50f688e16f451ed0
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  Module : SMESH
  //
  #ifndef _SMESH_Import_1D_HXX_
@@@ -39,7 -39,7 +39,7 @@@ class StdMeshers_ImportSource1D
  class STDMESHERS_EXPORT StdMeshers_Import_1D: public SMESH_1D_Algo
  {
  public:
 -  StdMeshers_Import_1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Import_1D(int hypId, SMESH_Gen* gen);
  
    virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
                                 const TopoDS_Shape& aShape,
index 85ec4cba52a40d4638c59ddabd724ee7b18c0949,949bd3a9073214bc786d6affa7d1840c79e433c3..ef13ad41877bb0ec7d704278cc71b4cbeaed40c1
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Import_1D2D.cxx
  //  Module : SMESH
  //
@@@ -96,8 -96,8 +96,8 @@@ namespac
   */
  //=============================================================================
  
 -StdMeshers_Import_1D2D::StdMeshers_Import_1D2D(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_2D_Algo(hypId, studyId, gen), _sourceHyp(0)
 +StdMeshers_Import_1D2D::StdMeshers_Import_1D2D(int hypId, SMESH_Gen * gen)
 +  :SMESH_2D_Algo(hypId, gen), _sourceHyp(0)
  {
    _name = "Import_1D2D";
    _shapeType = (1 << TopAbs_FACE);
index 8dc16d87e10e9e289767acab00e42bad821bbea9,15d1adf67011e1433f28ad53890d809f0b5c397f..5758d671ad1ae163f80b8aa56977c439d20bca19
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  Module : SMESH
  //
  #ifndef _SMESH_Import_2D_HXX_
@@@ -39,7 -39,7 +39,7 @@@ class StdMeshers_ImportSource1D
  class STDMESHERS_EXPORT StdMeshers_Import_1D2D: public SMESH_2D_Algo
  {
  public:
 -  StdMeshers_Import_1D2D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Import_1D2D(int hypId, SMESH_Gen* gen);
  
    virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
                                 const TopoDS_Shape& aShape,
index 3bcb1f6e5ed69f5ef28c549d765b95ab1238cb7f,ce35e21b918b80aac7f4281a39eb95029665514c..950dee5df6092a7309aec518bc25bbcc09918601
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_LengthFromEdges.cxx
  //           Moved here from SMESH_LengthFromEdges.cxx
  //  Author : Paul RASCLE, EDF
@@@ -38,8 -38,8 +38,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_LengthFromEdges::StdMeshers_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen)
 -  : SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_LengthFromEdges::StdMeshers_LengthFromEdges(int hypId, SMESH_Gen* gen)
 +  : SMESH_Hypothesis(hypId, gen)
  {
    _mode =1;
    _name = "LengthFromEdges";
index 7b7cd162dda6b77657616a1b32205549849e6e20,14494eec282e502282c80b9263af3bd166037299..01023caf068be2a5cf1419a550da8974009641a7
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_LengthFromEdges.hxx
  //           Moved here from SMESH_LengthFromEdges.hxx
  //  Author : Paul RASCLE, EDF
@@@ -38,7 -38,7 +38,7 @@@ class STDMESHERS_EXPORT StdMeshers_Leng
    public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_LengthFromEdges(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_LengthFromEdges();
  
    void SetMode(int mode)
index 898d940f4ed19d14b6dfa7559b0aaa52112b755b,e5c09bd04026f68b3926abfc71abf1c46f8a5b32..72b1543e6c74957ea47cd1e1a4eccbec6cf4d613
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_LocalLength.cxx
  //           Moved here from SMESH_LocalLength.cxx
  //  Author : Paul RASCLE, EDF
@@@ -52,8 -52,8 +52,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, SMESH_Gen * gen)
 +  :SMESH_Hypothesis(hypId, gen)
  {
    _length = 1.;
    _precision = Precision::Confusion();
index 29f6b166dd2fd873e2efa8fd4363c91de9b68965,76815141bd8bae5ec997561954e0adaca9d8db5b..5ac6e8e3ffbbbc58503e9f9b8aaf5d05d5429c09
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_LocalLength.hxx
  //           Moved here from SMESH_LocalLength.hxx
  //  Author : Paul RASCLE, EDF
@@@ -37,7 -37,7 +37,7 @@@
  class STDMESHERS_EXPORT StdMeshers_LocalLength: public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_LocalLength(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_LocalLength();
  
    void SetLength(double length) throw(SALOME_Exception);
index 50b79a6cc568381eb920532ff618b3eac746d316,196dbe7daf0fe38a41e2c5fcb0ae0619158e8163..bbc594b163c9e2a3de4670ff8c6e8aabd4783a9d
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_MEFISTO_2D.cxx
  //           Moved here from SMESH_MEFISTO_2D.cxx
  //  Author : Paul RASCLE, EDF
@@@ -79,8 -79,8 +79,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, int studyId, SMESH_Gen * gen):
 -  SMESH_2D_Algo(hypId, studyId, gen)
 +StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, SMESH_Gen * gen):
 +  SMESH_2D_Algo(hypId, gen)
  {
    _name = "MEFISTO_2D";
    _shapeType = (1 << TopAbs_FACE);
index bcf22d59e3dff5a6eecff7fa8a1b285cf77dc1ad,ba272fd3148d064233cf2afee882e6abed8ee778..ee89f144049eeab9d4e5bea9aa780a8de6fa3c9d
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_MEFISTO_2D.hxx
  //           Moved here from SMESH_MEFISTO_2D.hxx
  //  Author : Paul RASCLE, EDF
@@@ -47,7 -47,7 +47,7 @@@ class StdMeshers_FaceSide
  class STDMESHERS_EXPORT StdMeshers_MEFISTO_2D: public SMESH_2D_Algo
  {
  public:
 -  StdMeshers_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_MEFISTO_2D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_MEFISTO_2D();
  
    virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
index 77cefa46e9e5b34b38af6d445ea800f8767e8847,5e423c4b5f5ee463b9b6fbbc69af074b9b9a1dcb..fb51d05ba5c1079edacc01b3720f425122bc1dfa
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_MaxElementArea.cxx
  //           Moved here from SMESH_MaxElementArea.cxx
  //  Author : Paul RASCLE, EDF
@@@ -48,8 -48,8 +48,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_MaxElementArea::StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen)
 -  : SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_MaxElementArea::StdMeshers_MaxElementArea(int hypId, SMESH_Gen* gen)
 +  : SMESH_Hypothesis(hypId, gen)
  {
    _maxArea =1.;
    _name = "MaxElementArea";
index 10de97599f8ba65105cd46c36d0837b0846747ee,66139b17ce5c421a3561e90d94f6870c91a4f397..edc8142214a7d22af816cf2c2ff6bada0427ab4d
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_MaxElementArea.hxx
  //           Moved here from SMESH_MaxElementArea.hxx
  //  Author : Paul RASCLE, EDF
@@@ -37,7 -37,7 +37,7 @@@
  class STDMESHERS_EXPORT StdMeshers_MaxElementArea:public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_MaxElementArea(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_MaxElementArea();
  
    void SetMaxArea(double maxArea) throw(SALOME_Exception);
index 86c4f2aa4e5dbe2fa40f7c306e2c1f7683c3cb1c,2ded219bbdcca3c44b874eaa1d51b46248699a9d..e8096a51d32f157f9d38d84389e19e56788efcbe
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_MaxElementVolume.cxx
  //           Moved here from SMESH_MaxElementVolume.cxx
  //  Author : Paul RASCLE, EDF
@@@ -48,8 -48,8 +48,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen)
 -  : SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, SMESH_Gen* gen)
 +  : SMESH_Hypothesis(hypId, gen)
  {
    _maxVolume = 1.;
    _name = "MaxElementVolume";
index 3ad0e6175200924262c29ce408ab2cf7df4f9f00,291385f4d23e8ec19c27f701c6903da7a5106437..f790000fd8314a167024a1b56058113048a9cbe7
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_MaxElementVolume.hxx
  //           Moved here from SMESH_MaxElementVolume.hxx
  //  Author : Paul RASCLE, EDF
@@@ -38,7 -38,7 +38,7 @@@ class STDMESHERS_EXPORT StdMeshers_MaxE
    public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_MaxElementVolume(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_MaxElementVolume();
  
    void SetMaxVolume(double maxVolume)
index 7b0d7fbb6cae218dddf16434464583a46b5f936a,b8ca75232a2b732f12a47ceb4b43bb3cf4f734c0..1051fce5a1ed6c43e8cc8c52b672b76155b3cf9f
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_MaxLength.cxx
  //  Module : SMESH
  //
@@@ -47,8 -47,8 +47,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_MaxLength::StdMeshers_MaxLength(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_MaxLength::StdMeshers_MaxLength(int hypId, SMESH_Gen * gen)
 +  :SMESH_Hypothesis(hypId, gen)
  {
    _length = 1.;
    _preestimated = 0.;
index 575bbaafd0a365924c8f6d530062a00da1fb0a87,f9a6ab2ad55b2e451b6751b0d96d37d9cf273e54..ef31f125158262e99845afc3c0fd838e0d033709
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_MaxLength.hxx
  //  Module : SMESH
  //
@@@ -32,7 -32,7 +32,7 @@@
  class STDMESHERS_EXPORT StdMeshers_MaxLength: public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_MaxLength(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_MaxLength(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_MaxLength();
  
    void SetLength(double length) throw(SALOME_Exception);
index ca597ee523cea3a1577edaa3a0adac32c06914f9,301fd8ba3a41d8e7d2712286d686e633862a3332..c5bb45d6ad69f8ce1735117832517b78ae207361
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers : implementation of SMESH idl descriptions
  //  File   : StdMeshers_NotConformAllowed.cxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -36,8 -36,8 +36,8 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_NotConformAllowed::StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen)
 -  : SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_NotConformAllowed::StdMeshers_NotConformAllowed(int hypId, SMESH_Gen* gen)
 +  : SMESH_Hypothesis(hypId, gen)
  {
    _name = "NotConformAllowed";
    _param_algo_dim = -1; 
index 2f80da9a5bafde0f35daac85ce766801e15366d9,012eccfbada05c66b3e41d81f9af420c29bd3cc0..40b8db83d9b4401385c514873eb09e612ae255be
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers : implementation of SMESH idl descriptions
  //  File   : StdMeshers_NotConformAllowed.hxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -37,7 -37,7 +37,7 @@@ class STDMESHERS_EXPORT StdMeshers_NotC
    public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_NotConformAllowed(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_NotConformAllowed();
  
    virtual std::ostream & SaveTo(std::ostream & save);
index 41ba3495e30f17c3ecc781b061512f91dfdcdca6,fc8da4162a1618b2844191f981091f90394ce84c..b6785f2edbce312b241ecdd9536b7fa48b26705c
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_NumberOfSegments.cxx
  //           Moved here from SMESH_NumberOfSegments.cxx
  //  Author : Paul RASCLE, EDF
@@@ -59,8 -59,9 +59,8 @@@ const double PRECISION = 1e-7
  //=============================================================================
  
  StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int         hypId,
 -                                                         int         studyId,
                                                           SMESH_Gen * gen)
 -  : SMESH_Hypothesis(hypId, studyId, gen),
 +  : SMESH_Hypothesis(hypId, gen),
      _numberOfSegments(15),//issue 19923
      _distrType(DT_Regular),
      _scaleFactor(1.),
index 95273c5fa981c499b7421b77eca8a6773449e3dc,a85308bbfae94d1708e586547b46992cfd458263..6e9e59e3eaefc37347ee35baec1a18a9a6529ff0
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_NumberOfSegments.hxx
  //           Moved here from SMESH_NumberOfSegments.hxx
  //  Author : Paul RASCLE, EDF
@@@ -45,7 -45,7 +45,7 @@@ class STDMESHERS_EXPORT StdMeshers_Numb
    public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_NumberOfSegments(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_NumberOfSegments();
  
    // Builds point distribution according to passed function
index 894b5c2efca92ea0dec6916e71f13eab547e82f3,9dde41365e3a12a664c5409d757d41c01b39da36..68535a2192dcf80b7858c11bfca16228962c354b
@@@ -96,14 -96,15 +96,14 @@@ namespace 
     */
    struct TQuadrangleAlgo : public StdMeshers_Quadrangle_2D
    {
 -    TQuadrangleAlgo(int studyId, SMESH_Gen* gen)
 -      : StdMeshers_Quadrangle_2D( gen->GetANewId(), studyId, gen)
 +    TQuadrangleAlgo(SMESH_Gen* gen)
 +      : StdMeshers_Quadrangle_2D( gen->GetANewId(), gen)
      {
      }
      static StdMeshers_Quadrangle_2D* instance( SMESH_Algo*         fatherAlgo,
                                                 SMESH_MesherHelper* helper=0)
      {
 -      static TQuadrangleAlgo* algo = new TQuadrangleAlgo( fatherAlgo->GetStudyId(),
 -                                                          fatherAlgo->GetGen() );
 +      static TQuadrangleAlgo* algo = new TQuadrangleAlgo( fatherAlgo->GetGen() );
        if ( helper &&
             algo->myProxyMesh &&
             algo->myProxyMesh->GetMesh() != helper->GetMesh() )
    {
      StdMeshers_ProjectionSource1D myHyp;
  
 -    TProjction1dAlgo(int studyId, SMESH_Gen* gen)
 -      : StdMeshers_Projection_1D( gen->GetANewId(), studyId, gen),
 -        myHyp( gen->GetANewId(), studyId, gen)
 +    TProjction1dAlgo(SMESH_Gen* gen)
 +      : StdMeshers_Projection_1D( gen->GetANewId(), gen),
 +        myHyp( gen->GetANewId(), gen)
      {
        StdMeshers_Projection_1D::_sourceHypo = & myHyp;
      }
      static TProjction1dAlgo* instance( SMESH_Algo* fatherAlgo )
      {
 -      static TProjction1dAlgo* algo = new TProjction1dAlgo( fatherAlgo->GetStudyId(),
 -                                                            fatherAlgo->GetGen() );
 +      static TProjction1dAlgo* algo = new TProjction1dAlgo( fatherAlgo->GetGen() );
        return algo;
      }
    };
    {
      StdMeshers_ProjectionSource2D myHyp;
  
 -    TProjction2dAlgo(int studyId, SMESH_Gen* gen)
 -      : StdMeshers_Projection_1D2D( gen->GetANewId(), studyId, gen),
 -        myHyp( gen->GetANewId(), studyId, gen)
 +    TProjction2dAlgo(SMESH_Gen* gen)
 +      : StdMeshers_Projection_1D2D( gen->GetANewId(), gen),
 +        myHyp( gen->GetANewId(), gen)
      {
        StdMeshers_Projection_2D::_sourceHypo = & myHyp;
      }
      static TProjction2dAlgo* instance( SMESH_Algo* fatherAlgo )
      {
 -      static TProjction2dAlgo* algo = new TProjction2dAlgo( fatherAlgo->GetStudyId(),
 -                                                            fatherAlgo->GetGen() );
 +      static TProjction2dAlgo* algo = new TProjction2dAlgo( fatherAlgo->GetGen() );
        return algo;
      }
      const NSProjUtils::TNodeNodeMap& GetNodesMap()
  //purpose  : 
  //=======================================================================
  
 -StdMeshers_Prism_3D::StdMeshers_Prism_3D(int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_3D_Algo(hypId, studyId, gen)
 +StdMeshers_Prism_3D::StdMeshers_Prism_3D(int hypId, SMESH_Gen* gen)
 +  :SMESH_3D_Algo(hypId, gen)
  {
    _name                    = "Prism_3D";
    _shapeType               = (1 << TopAbs_SOLID); // 1 bit per shape type
@@@ -3060,7 -3063,7 +3060,7 @@@ bool StdMeshers_Prism_3D::IsApplicable(
  
            if ( side._topEdge.IsNull() )
            {
-             // find vertical EDGEs --- EGDEs shared with neighbor side FACEs
+             // find vertical EDGEs --- EDGEs shared with neighbor side FACEs
              for ( int is2nd = 0; is2nd < 2 && isOK; ++is2nd ) // 2 adjacent neighbors
              {
                int di = is2nd ? 1 : -1;
@@@ -3421,7 -3424,7 +3421,7 @@@ bool StdMeshers_Prism_3D::initPrism(Pri
    if ( !botSM ) // find a proper bottom
    {
      bool savedSetErrorToSM = mySetErrorToSM;
-     mySetErrorToSM = false; // ingore errors in initPrism()
+     mySetErrorToSM = false; // ignore errors in initPrism()
  
      // search among meshed FACEs
      list< SMESH_subMesh* >::iterator sm = meshedSubMesh.begin();
@@@ -4956,7 -4959,7 +4956,7 @@@ bool StdMeshers_Sweeper::ComputeNodesBy
    const size_t zSrc = 0, zTgt = zSize-1;
    if ( zSize < 3 ) return true;
  
-   vector< vector< gp_XYZ > > intPntsOfLayer( zSize ); // node coodinates to compute
+   vector< vector< gp_XYZ > > intPntsOfLayer( zSize ); // node coordinates to compute
    // set coordinates of src and tgt nodes
    for ( size_t z = 0; z < intPntsOfLayer.size(); ++z )
      intPntsOfLayer[ z ].resize( myIntColumns.size() );
    prepareTopBotDelaunay();
    bool isErrorCorrectable = findDelaunayTriangles();
  
-   // compute coordinates of internal nodes by projecting (transfroming) src and tgt
+   // compute coordinates of internal nodes by projecting (transforming) src and tgt
    // nodes towards the central layer
  
    vector< NSProjUtils::TrsfFinder3D > trsfOfLayer( zSize );
index d9103b72b62a999486a72826f0fd14741b86be36,129a6e3e3d202d06c360084352d1a65baebc5544..b216d2029a50b9c6d139f40c05e966e8013947e8
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Prism_3D.hxx
  //  Module : SMESH
  //
@@@ -479,7 -479,7 +479,7 @@@ private
  class STDMESHERS_EXPORT StdMeshers_Prism_3D: public SMESH_3D_Algo
  {
  public:
 -  StdMeshers_Prism_3D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Prism_3D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_Prism_3D();
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
index 029719f1b5ace280039965843168f099319f3d0c,cf41af1960ad16421791d1a45aa3f275c18eec03..991541f36b056fa466e1755340a96ca9c0ce87af
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_Projection_1D.cxx
  // Module    : SMESH
  // Created   : Fri Oct 20 11:37:07 2006
@@@ -65,8 -65,8 +65,8 @@@ namespace TAssocTool = StdMeshers_Proje
  //purpose  : 
  //=======================================================================
  
 -StdMeshers_Projection_1D::StdMeshers_Projection_1D(int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_1D_Algo(hypId, studyId, gen)
 +StdMeshers_Projection_1D::StdMeshers_Projection_1D(int hypId, SMESH_Gen* gen)
 +  :SMESH_1D_Algo(hypId, gen)
  {
    _name = "Projection_1D";
    _shapeType = (1 << TopAbs_EDGE);      // 1 bit per shape type
index a0cef0d648dcb81e2fba6d5775a5d5c59aa565a0,2fbd2742045df5fa91700b01b8aa4628cdea3458..aa0cfe10ce62c44e1bf19ab32b414af0cdd9e045
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Projection_1D.hxx
  //  Module : SMESH
  //
@@@ -38,7 -38,7 +38,7 @@@ class StdMeshers_ProjectionSource1D
  class STDMESHERS_EXPORT StdMeshers_Projection_1D: public SMESH_1D_Algo
  {
  public:
 -  StdMeshers_Projection_1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Projection_1D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_Projection_1D();
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
index 03819912493e05f2437f3b1ba925bf543d84dd78,0686b165a77c6301498028dd42455674b24afa52..a41c5ac6d2f77d9d3ba3ecac675b1d91beef9bab
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_Projection_2D.cxx
  // Module    : SMESH
  // Created   : Fri Oct 20 11:37:07 2006
@@@ -85,8 -85,8 +85,8 @@@ namespace TAssocTool = StdMeshers_Proje
  //purpose  : 
  //=======================================================================
  
 -StdMeshers_Projection_2D::StdMeshers_Projection_2D(int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_2D_Algo(hypId, studyId, gen)
 +StdMeshers_Projection_2D::StdMeshers_Projection_2D(int hypId, SMESH_Gen* gen)
 +  :SMESH_2D_Algo(hypId, gen)
  {
    _name = "Projection_2D";
    _compatibleHypothesis.push_back("ProjectionSource2D");
index 98864c3faec2f06e141188024cac60ec4f0fa781,0fbe35cc0cf7295d3430292e6b9fb42ab6d327d7..44ce8719c1e97d66aa3c51496d8382657841c8e1
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Projection_2D.hxx
  //  Module : SMESH
  //
@@@ -37,7 -37,7 +37,7 @@@ class StdMeshers_ProjectionSource2D
  class STDMESHERS_EXPORT StdMeshers_Projection_2D: public SMESH_2D_Algo
  {
  public:
 -  StdMeshers_Projection_2D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Projection_2D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_Projection_2D();
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
index 95bc469136c4636c7d6682bdaf90d31b1a170b8c,43a6c4c093ac3d5c7e201dda3f2633dcdde651a9..ea0fbfccd3ae9282e4a01fda25037304c80e3eb7
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_Projection_3D.cxx
  // Module    : SMESH
  // Created   : Fri Oct 20 11:37:07 2006
@@@ -65,8 -65,8 +65,8 @@@ using namespace std
  //purpose  : 
  //=======================================================================
  
 -StdMeshers_Projection_3D::StdMeshers_Projection_3D(int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_3D_Algo(hypId, studyId, gen)
 +StdMeshers_Projection_3D::StdMeshers_Projection_3D(int hypId, SMESH_Gen* gen)
 +  :SMESH_3D_Algo(hypId, gen)
  {
    _name = "Projection_3D";
    _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);  // 1 bit per shape type
index e09f007accd44103f1bb234cbe5b77c0cc5aacf4,78db64c6b11567d8d5aa0bab9e27c4ab1210d725..e61552ec6e8e6320a7b7787c4912383e8b03bf16
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Projection_3D.hxx
  //  Module : SMESH
  //
@@@ -36,7 -36,7 +36,7 @@@ class StdMeshers_ProjectionSource3D
  class STDMESHERS_EXPORT StdMeshers_Projection_3D: public SMESH_3D_Algo
  {
  public:
 -  StdMeshers_Projection_3D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Projection_3D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_Projection_3D();
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
index 3d82126adf50eeba19d875054d7669f3b9da6a72,750d1abd2fe1caa3f5a9fb788b6e395448e4e204..f0e53c203e991efbff95a4fcfc905ecaf2d43d36
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Propagation.cxx
  //  Module : SMESH
  //
@@@ -85,15 -85,16 +85,15 @@@ namespace 
   */
  //=============================================================================
  
 -StdMeshers_Propagation::StdMeshers_Propagation (int hypId, int studyId, SMESH_Gen * gen)
 -  : SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_Propagation::StdMeshers_Propagation (int hypId, SMESH_Gen * gen)
 +  : SMESH_Hypothesis(hypId, gen)
  {
    _name = GetName();
    _param_algo_dim = -1; // 1D auxiliary
  }
  StdMeshers_PropagOfDistribution::StdMeshers_PropagOfDistribution (int hypId,
 -                                                                  int studyId,
                                                                    SMESH_Gen * gen)
 -  : StdMeshers_Propagation(hypId, studyId, gen)                        { _name = GetName(); }
 +  : StdMeshers_Propagation(hypId, gen)                                 { _name = GetName(); }
  StdMeshers_Propagation::~StdMeshers_Propagation()                      {}
  string StdMeshers_Propagation::GetName ()                              { return "Propagation"; }
  string StdMeshers_PropagOfDistribution::GetName ()                     { return "PropagOfDistribution"; }
index 7f76acf0fd6a1a473217fcb6aba312ce7bd41169,17b09eefce3e4bf9732ab735821a485c5420c4df..bc68acc9df3c7afbbce1611b6694bf8027158da3
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Propagation.hxx
  //  Module : SMESH
  //
@@@ -46,7 -46,7 +46,7 @@@ class SMESH_HypoFilter
  class STDMESHERS_EXPORT StdMeshers_Propagation : public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_Propagation(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_Propagation(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_Propagation();
  
    virtual std::ostream & SaveTo(std::ostream & save);
  class STDMESHERS_EXPORT StdMeshers_PropagOfDistribution: public StdMeshers_Propagation
  {
   public:
 -  StdMeshers_PropagOfDistribution(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_PropagOfDistribution(int hypId, SMESH_Gen * gen);
  
    static std::string GetName();
  };
index 7b53e6a6d6d9cb0a6ba29001efb95df5d7918c02,094784908ecec53c054022ea8ff4d7dd3db383ef..2043f1ea7df1e96c198611b04af88afa1392d201
@@@ -71,8 -71,8 +71,8 @@@ using namespace std
  class StdMeshers_QuadFromMedialAxis_1D2D::Algo1D : public StdMeshers_Regular_1D
  {
  public:
 -  Algo1D(int studyId, SMESH_Gen* gen):
 -    StdMeshers_Regular_1D( gen->GetANewId(), studyId, gen )
 +  Algo1D(SMESH_Gen* gen):
 +    StdMeshers_Regular_1D( gen->GetANewId(), gen )
    {
    }
    void SetSegmentLength( double len )
  //================================================================================
  
  StdMeshers_QuadFromMedialAxis_1D2D::StdMeshers_QuadFromMedialAxis_1D2D(int        hypId,
 -                                                                       int        studyId,
                                                                         SMESH_Gen* gen)
 -  : StdMeshers_Quadrangle_2D(hypId, studyId, gen),
 +  : StdMeshers_Quadrangle_2D(hypId, gen),
      _regular1D( 0 )
  {
    _name = "QuadFromMedialAxis_1D2D";
@@@ -740,7 -741,7 +740,7 @@@ namespac
      }
  
      // cout << "from salome.geom import geomBuilder" << endl;
 -    // cout << "geompy = geomBuilder.New(salome.myStudy)" << endl;
 +    // cout << "geompy = geomBuilder.New()" << endl;
      Handle(TColgp_HArray1OfPnt) points = new TColgp_HArray1OfPnt(1, pnt.size());
      for ( size_t i = 0; i < pnt.size(); ++i )
      {
     *  \param [in] theDivPoints - projections of VERTEXes to MA
     *  \param [in] theSinuEdges - the sinuous EDGEs
     *  \param [in] theSideEdgeIDs - indices of sinuous EDGEs per side
-    *  \param [in] theIsEdgeComputed - is sinuous EGDE is meshed
+    *  \param [in] theIsEdgeComputed - is sinuous EDGE is meshed
     *  \param [in,out] thePointsOnE - the map to fill
     *  \param [out] theNodes2Merge - the map of nodes to merge
     */
    //================================================================================
    /*!
     * \brief Divide the sinuous EDGEs by projecting the division point of Medial
-    *        Axis to the EGDEs
+    *        Axis to the EDGEs
     *  \param [in] theHelper - the helper
     *  \param [in] theMinSegLen - minimal segment length
     *  \param [in] theMA - the Medial Axis
@@@ -2165,7 -2166,7 +2165,7 @@@ bool StdMeshers_QuadFromMedialAxis_1D2D
      SMESH_MAT2d::MedialAxis ma( F, sinuFace._sinuEdges, minSegLen, /*ignoreCorners=*/true );
  
      if ( !_regular1D )
 -      _regular1D = new Algo1D( _studyId, _gen );
 +      _regular1D = new Algo1D( _gen );
      _regular1D->SetSegmentLength( minSegLen );
  
      vector<double> maParams;
index 453b1fd6c7f71b9ecde332e0e25ee33d2d15e0d3,8b6ccfa3c85dddd5aebb768598841815a60a7043..5c81cfaef1acca42affb9c93eb88b4ec306c89ac
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers_QuadranglePreference : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers_QuadranglePreference : implementation of SMESH idl descriptions
  //  File   : StdMeshers_QuadranglePreference.cxx
  //  Module : SMESH
  //
@@@ -36,8 -36,9 +36,8 @@@ using namespace std
  //=============================================================================
  
  StdMeshers_QuadranglePreference::StdMeshers_QuadranglePreference(int         hypId,
 -                                                                 int         studyId,
                                                                   SMESH_Gen * gen)
 -     :SMESH_Hypothesis(hypId, studyId, gen)
 +     :SMESH_Hypothesis(hypId, gen)
  {
    _name = "QuadranglePreference";
    _param_algo_dim = -2; // auxiliary used by NETGEN 2D
index 747ed7e5f45a4addc2eb65ef3e21233b92186bad,9bc482e1aa0dd3dd6225eaddddeb307f7b793081..090f75bd68046bd38c3a5260445c3e8d777f1515
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers : implementation of SMESH idl descriptions
  //  File   : StdMeshers_QuadranglePreference.hxx
  //  Module : SMESH
  //
@@@ -41,7 -41,7 +41,7 @@@
  class STDMESHERS_EXPORT StdMeshers_QuadranglePreference:public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_QuadranglePreference(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_QuadranglePreference(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_QuadranglePreference();
    
    virtual std::ostream & SaveTo(std::ostream & save);
index c3c6d3e96d2153069433ba2666fd1b90f55f9818,679769a8f8e0b7c5296de4fdec4a9911df41c665..b8a2ee5a81a172497b45ce48c15aac96f156bc3f
@@@ -79,9 -79,9 +79,9 @@@ using namespace std
   */
  //=============================================================================
  
 -StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId,
 +StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId,
                                                      SMESH_Gen* gen)
 -  : SMESH_2D_Algo(hypId, studyId, gen),
 +  : SMESH_2D_Algo(hypId, gen),
      myQuadranglePreference(false),
      myTrianglePreference(false),
      myTriaVertexID(-1),
@@@ -1761,7 -1761,7 +1761,7 @@@ bool StdMeshers_Quadrangle_2D::computeQ
    //       |   |  |   |
    //       |   |C |   |
    //       | L |  | R |
-   //  left |   |__|   | rigth
+   //  left |   |__|   | right
    //       |  /    \  |
    //       | /  C   \ |
    //       |/        \|
    //       |   |__|   |
    //       |  /    \  |
    //       | /  C   \ |
-   //  left |/________\| rigth
+   //  left |/________\| right
    //       |          |
    //       |    C     |
    //       |          |
@@@ -2997,7 -2997,7 +2997,7 @@@ bool StdMeshers_Quadrangle_2D::computeR
      //       |   |  |   |
      //       |   |  |   |
      //       | L |  | R |
-     //  left |   |  |   | rigth
+     //  left |   |  |   | right
      //       |  /    \  |
      //       | /  C   \ |
      //       |/        \|
index 0203e322b9fb2559a3ec334db6435f4b2d638259,81270bfab6efaf5ae36e2d566762f6b62c87f2a6..2c9839b7e90720630648cef333049bb5a54fdee9
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers_QuadraticMesh : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers_QuadraticMesh : implementation of SMESH idl descriptions
  //  File   : StdMeshers_QuadraticMesh.cxx
  //  Module : SMESH
  //
@@@ -36,8 -36,9 +36,8 @@@ using namespace std
  //=============================================================================
  
  StdMeshers_QuadraticMesh::StdMeshers_QuadraticMesh(int         hypId,
 -                                                   int         studyId,
                                                     SMESH_Gen * gen)
 -     :SMESH_Hypothesis(hypId, studyId, gen)
 +     :SMESH_Hypothesis(hypId, gen)
  {
    _name = "QuadraticMesh";
    _param_algo_dim = -1; // it means auxiliary, dim = 1
index 5073faa5e6bfeb8a82becd1d4616f42b4e98ef4d,6fd428754655cf2cd42acdac780dd7dfed8d1c82..1f9f3927eb50aa789dd61ef90aa0e2aa9ff55ea1
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers : implementation of SMESH idl descriptions
  //  File   : StdMeshers_QuadraticMesh.hxx
  //  Module : SMESH
  //
@@@ -43,7 -43,7 +43,7 @@@
  class STDMESHERS_EXPORT StdMeshers_QuadraticMesh:public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_QuadraticMesh(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_QuadraticMesh(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_QuadraticMesh();
    
    virtual std::ostream & SaveTo(std::ostream & save);
index 2c4fe52ae331f456afd917c17bc7cf97effa690a,c5af23f3dd008138ee4142ac9b5854dd045bbc53..3ed74b3dabd57da54fb5c0e294e8a9bd8a9e51a9
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_RadialPrism_3D.cxx
  // Module    : SMESH
  // Created   : Fri Oct 20 11:37:07 2006
@@@ -69,8 -69,8 +69,8 @@@ namespace ProjectionUtils = StdMeshers_
  //purpose  : 
  //=======================================================================
  
 -StdMeshers_RadialPrism_3D::StdMeshers_RadialPrism_3D(int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_3D_Algo(hypId, studyId, gen)
 +StdMeshers_RadialPrism_3D::StdMeshers_RadialPrism_3D(int hypId, SMESH_Gen* gen)
 +  :SMESH_3D_Algo(hypId, gen)
  {
    _name = "RadialPrism_3D";
    _shapeType = (1 << TopAbs_SOLID);     // 1 bit per shape type
@@@ -336,7 -336,7 +336,7 @@@ public
      const int myID = -1000;
      TNodeDistributor* myHyp = dynamic_cast<TNodeDistributor*>( aMesh.GetHypothesis( myID ));
      if ( !myHyp )
 -      myHyp = new TNodeDistributor( myID, 0, aMesh.GetGen() );
 +      myHyp = new TNodeDistributor( myID, aMesh.GetGen() );
      return myHyp;
    }
    // -----------------------------------------------------------------------------
    }
  protected:
    // -----------------------------------------------------------------------------
 -  TNodeDistributor( int hypId, int studyId, SMESH_Gen* gen)
 -    : StdMeshers_Regular_1D( hypId, studyId, gen)
 +  TNodeDistributor( int hypId, SMESH_Gen* gen)
 +    : StdMeshers_Regular_1D( hypId, gen)
    {
    }
    // -----------------------------------------------------------------------------
index 34561414f2064db67a7b20eb31cfb52611d8d7fe,71d4d2238bb7cf3ac41f6f60853b38bdc75324d6..e8300084b1b35373b6d1f97e0db19a30e19958c9
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_RadialPrism_3D.hxx
  //  Module : SMESH
  //
@@@ -43,7 -43,7 +43,7 @@@ class gp_Pnt
  class STDMESHERS_EXPORT StdMeshers_RadialPrism_3D: public SMESH_3D_Algo
  {
  public:
 -  StdMeshers_RadialPrism_3D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_RadialPrism_3D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_RadialPrism_3D();
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
index a53b0285971bfbcc78ca3adbdb0bdc92a53f0cc7,0b0803b9d350b23a3698aed45e1727aec46627b4..50ca16eb92efa4a17e2f26459e3250f6fdc8db59
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_RadialQuadrangle_1D2D.hxx
  //  Module : SMESH
  //
@@@ -39,7 -39,7 +39,7 @@@ class StdMeshers_LayerDistribution
  class STDMESHERS_EXPORT StdMeshers_RadialQuadrangle_1D2D: public StdMeshers_Quadrangle_2D
  {
  public:
 -  StdMeshers_RadialQuadrangle_1D2D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_RadialQuadrangle_1D2D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_RadialQuadrangle_1D2D();
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
index bc17cf4f87e8231b168168d7c906cdf8a9db9f90,90dba12ad16366aa7b6ea8fe1b2eb0af6d420bd4..2845e55a29662feb834e4a744bdc22451f2cbda2
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Regular_1D.hxx
  //           Moved here from SMESH_Regular_1D.hxx
  //  Author : Paul RASCLE, EDF
@@@ -44,7 -44,7 +44,7 @@@ class TopoDS_Vertex
  class STDMESHERS_EXPORT StdMeshers_Regular_1D: public SMESH_1D_Algo
  {
  public:
 -  StdMeshers_Regular_1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Regular_1D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_Regular_1D();
  
    virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
index 72c435d904a800673c323524925cc5b6d22e1ba1,9562e9da185fa065fce7f9298ca40b370bf928d8..59284819337c5ccbe3e0db177a8c6feef374f5c9
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Reversible1D.cxx
  //  Module : SMESH
  //
@@@ -33,8 -33,8 +33,8 @@@
   */
  //=============================================================================
  
 -StdMeshers_Reversible1D::StdMeshers_Reversible1D(int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen)
 +StdMeshers_Reversible1D::StdMeshers_Reversible1D(int hypId, SMESH_Gen * gen)
 +  :SMESH_Hypothesis(hypId, gen)
  {
    _param_algo_dim = 1; 
  }
index a8d62257c46479b6bf19231476fe8329483723af,a856eddfad1e94e1199d72224f2e247514aaff5f..00d61a1dae6ea95b0497dc929d73f87a89e1ec29
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_Reversible1D.hxx
  //  Module : SMESH
  //
@@@ -38,7 -38,7 +38,7 @@@
  class STDMESHERS_EXPORT StdMeshers_Reversible1D : public SMESH_Hypothesis
  {
  public:
 -  StdMeshers_Reversible1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_Reversible1D(int hypId, SMESH_Gen* gen);
  
    void SetReversedEdges( const std::vector<int>& ids);
  
index c5bb4fd0dca29db095bef6ccd271015a3aad4f42,b109328a58cbc6517d98c161f0a8a7e91b79732c..ae37844d71657730a4332a31dd759d303f3aabaf
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_SegmentAroundVertex_0D.cxx
  // Module    : SMESH
  // Created   : Fri Oct 20 11:37:07 2006
@@@ -36,8 -36,8 +36,8 @@@
  //=======================================================================
  
  StdMeshers_SegmentAroundVertex_0D::StdMeshers_SegmentAroundVertex_0D
 -                                   (int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_0D_Algo(hypId, studyId, gen)
 +                                   (int hypId, SMESH_Gen* gen)
 +  :SMESH_0D_Algo(hypId, gen)
  {
    _name = "SegmentAroundVertex_0D";
    // it is assigned to vertices but influence a state of EDGE submeshes
index c8fbe88c1622bb004a4a3481b605ba3e19e3e2ec,4b0e53968be642e481c3726fc719e2232fe36095..3e886a1aec46da333012a8d14669a775e4c1cd4a
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_SegmentAroundVertex_0D.hxx
  //  Module : SMESH
  //
@@@ -38,7 -38,7 +38,7 @@@
  class STDMESHERS_EXPORT StdMeshers_SegmentAroundVertex_0D: public SMESH_0D_Algo
  {
  public:
 -  StdMeshers_SegmentAroundVertex_0D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_SegmentAroundVertex_0D(int hypId, SMESH_Gen* gen);
    virtual ~StdMeshers_SegmentAroundVertex_0D();
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
index 1b0dd37cea53e1cb51e079da8022603b43c84d2d,46baaadc2a292e2c9f0a1479c9455ebd38e4086b..e221883ec35d3a09e8a17c909049eca7958f151a
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_SegmentLengthAroundVertex.cxx
  //  Module : SMESH
  //
@@@ -50,8 -50,8 +50,8 @@@ using namespace std
  //=============================================================================
  
  StdMeshers_SegmentLengthAroundVertex::StdMeshers_SegmentLengthAroundVertex
 -                                       (int hypId, int studyId, SMESH_Gen * gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen)
 +                                       (int hypId, SMESH_Gen * gen)
 +  :SMESH_Hypothesis(hypId, gen)
  {
    _length = 1.;
    _name = "SegmentLengthAroundVertex";
index 198ba34c6c792d3cd980793ccf375b5d706fb96d,355bee46c5dbca13c2efa98271ce3debcdf59a02..acf96e04d8fa7794892479f5d493586c2f753a2f
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_SegmentLengthAroundVertex.hxx
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
@@@ -40,7 -40,7 +40,7 @@@
  class STDMESHERS_EXPORT StdMeshers_SegmentLengthAroundVertex:public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_SegmentLengthAroundVertex(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_SegmentLengthAroundVertex(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_SegmentLengthAroundVertex();
  
    void SetLength(double length) throw(SALOME_Exception);
index a78244733fb87c430df2db85e380ce693b71718e,51bb2cf92e91f443425f7c0d6b24ff547d3b4294..a2bf0f7e116cf39607ee72234659af1c60773e4d
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers_StartEndLength : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers_StartEndLength : implementation of SMESH idl descriptions
  //  File   : StdMeshers_StartEndLength.cxx
  //  Module : SMESH
  //
@@@ -48,8 -48,9 +48,8 @@@ using namespace std
  //=============================================================================
  
  StdMeshers_StartEndLength::StdMeshers_StartEndLength(int         hypId,
 -                                                     int         studyId,
                                                       SMESH_Gen * gen)
 -     :SMESH_Hypothesis(hypId, studyId, gen)
 +     :SMESH_Hypothesis(hypId, gen)
  {
    _begLength = 1.;
    _endLength = 10.;
index fed02351aa363a9348c154278c0d5d7f127af0bc,12f5f3c9573124f62ed4a769286e047cc12fe278..576d8e1992ee3ef041386b4392352a03953d4f28
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers : implementation of SMESH idl descriptions
  //  File   : StdMeshers_StartEndLength.hxx
  //  Module : SMESH
  //
@@@ -37,7 -37,7 +37,7 @@@
  class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis
  {
   public:
 -  StdMeshers_StartEndLength(int hypId, int studyId, SMESH_Gen * gen);
 +  StdMeshers_StartEndLength(int hypId, SMESH_Gen * gen);
    virtual ~ StdMeshers_StartEndLength();
  
    void SetLength(double length, bool isStartLength) throw(SALOME_Exception);
index 1f8a5b03b21ca5ec4c9f878b3397807b6b571635,2999915f4e5382b1e1162e8f1546f27874fb4374..eccadb802bd4e21370f12b1dd3cd73df1f694ef9
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_UseExisting_1D2D.cxx
  // Module    : SMESH
  // Created   : Fri Oct 20 11:37:07 2006
@@@ -34,8 -34,8 +34,8 @@@
  //=======================================================================
  
  StdMeshers_UseExisting_1D::StdMeshers_UseExisting_1D
 -                                   (int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_1D_Algo(hypId, studyId, gen)
 +                                   (int hypId, SMESH_Gen* gen)
 +  :SMESH_1D_Algo(hypId, gen)
  {
    _name = "UseExisting_1D";
    _shapeType = (1 << TopAbs_EDGE); // 1 bit per shape type
@@@ -89,8 -89,8 +89,8 @@@ bool StdMeshers_UseExisting_1D::Evaluat
  //=======================================================================
  
  StdMeshers_UseExisting_2D::StdMeshers_UseExisting_2D
 -                                   (int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_2D_Algo(hypId, studyId, gen)
 +                                   (int hypId, SMESH_Gen* gen)
 +  :SMESH_2D_Algo(hypId, gen)
  {
    _name = "UseExisting_2D";
    _shapeType = (1 << TopAbs_FACE); // 1 bit per shape type
index 307693819f6a433c3d436865a7c34d8ce12749db,89b3bf06f24c20f888c9a4d6328ac7220635c9f5..58d55e20b8bd1997d2fdcc5ae391e256c7c085f4
@@@ -17,7 -17,7 +17,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  //  File   : StdMeshers_UseExisting_1D2D.hxx
  //  Module : SMESH
  //
@@@ -35,7 -35,7 +35,7 @@@
  class STDMESHERS_EXPORT StdMeshers_UseExisting_2D: public SMESH_2D_Algo
  {
  public:
 -  StdMeshers_UseExisting_2D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_UseExisting_2D(int hypId, SMESH_Gen* gen);
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
                                 const TopoDS_Shape&                  aShape,
@@@ -50,7 -50,7 +50,7 @@@
  class STDMESHERS_EXPORT StdMeshers_UseExisting_1D: public SMESH_1D_Algo
  {
  public:
 -  StdMeshers_UseExisting_1D(int hypId, int studyId, SMESH_Gen* gen);
 +  StdMeshers_UseExisting_1D(int hypId, SMESH_Gen* gen);
  
    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
                                 const TopoDS_Shape&                  aShape,
index 7b5cbba4128d26e3d019b88e266ad560bac33378,34f3f07a5f18d87d3bb0466ebf30badb98574ede..475a7cef1d7f469029920d90fde530ecf9bbce53
@@@ -764,7 -764,7 +764,7 @@@ namespace VISCOUS_3
      // Convex FACEs whose radius of curvature is less than the thickness of layers
      map< TGeomID, _ConvexFace >      _convexFaces;
  
-     // shapes (EDGEs and VERTEXes) srink from which is forbidden due to collisions with
+     // shapes (EDGEs and VERTEXes) shrink from which is forbidden due to collisions with
      // the adjacent SOLID
      set< TGeomID >                   _noShrinkShapes;
  
  //================================================================================
  // StdMeshers_ViscousLayers hypothesis
  //
 -StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, int studyId, SMESH_Gen* gen)
 -  :SMESH_Hypothesis(hypId, studyId, gen),
 +StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, SMESH_Gen* gen)
 +  :SMESH_Hypothesis(hypId, gen),
     _isToIgnoreShapes(1), _nbLayers(1), _thickness(1), _stretchFactor(1),
     _method( SURF_OFFSET_SMOOTH )
  {
@@@ -1688,8 -1688,8 +1688,8 @@@ namespace VISCOUS_3
        py = _pyStream = new ofstream(fname);
        *py << "import SMESH" << endl
            << "from salome.smesh import smeshBuilder" << endl
 -          << "smesh  = smeshBuilder.New(salome.myStudy)" << endl
 -          << "meshSO = smesh.GetCurrentStudy().FindObjectID('0:1:2:" << tag <<"')" << endl
 +          << "smesh  = smeshBuilder.New()" << endl
 +          << "meshSO = salome.myStudy.FindObjectID('0:1:2:" << tag <<"')" << endl
            << "mesh   = smesh.Mesh( meshSO.GetObject() )"<<endl;
        theNbPyFunc = 0;
      }
@@@ -3082,7 -3082,7 +3082,7 @@@ bool _ViscousBuilder::findShapesToSmoot
    }
  
  
-   // Fill _eosC1 to make that C1 FACEs and EGDEs between them to be smoothed as a whole
+   // Fill _eosC1 to make that C1 FACEs and EDGEs between them to be smoothed as a whole
  
    TopTools_MapOfShape c1VV;
  
@@@ -4309,7 -4309,7 +4309,7 @@@ void _Simplex::SortSimplices(vector<_Si
  
  //================================================================================
  /*!
-  * \brief DEBUG. Create groups contating temorary data of _LayerEdge's
+  * \brief DEBUG. Create groups containing temporary data of _LayerEdge's
   */
  //================================================================================
  
@@@ -6722,7 -6722,7 +6722,7 @@@ void _ViscousBuilder::findCollisionEdge
               src2->GetID() < edge->_nodes[0]->GetID() )
            continue; // avoid using same segment twice
  
-         // a _LayerEdge containg tgt2
+         // a _LayerEdge containing tgt2
          _LayerEdge* neiborEdge = edge->_2neibors->_edges[j];
  
          _TmpMeshFaceOnEdge* f = new _TmpMeshFaceOnEdge( edge, neiborEdge, --_tmpFaceID );
@@@ -10331,7 -10331,7 +10331,7 @@@ bool _ViscousBuilder::shrink(_SolidData
    vector< _EdgesOnShape* > subEOS;
    vector< _LayerEdge* > lEdges;
  
-   // loop on FACEs to srink mesh on
+   // loop on FACEs to shrink mesh on
    map< TGeomID, list< _SolidData* > >::iterator f2sd = f2sdMap.begin();
    for ( ; f2sd != f2sdMap.end(); ++f2sd )
    {
          if ( eos.SWOLType() == TopAbs_EDGE )
          {
            SMESH_subMesh* edgeSM = _mesh->GetSubMesh( eos._sWOL );
-           _Shrinker1D& srinker  = e2shrMap[ edgeSM->GetId() ];
-           eShri1D.insert( & srinker );
-           srinker.AddEdge( eos._edges[0], eos, helper );
+           _Shrinker1D& shrinker  = e2shrMap[ edgeSM->GetId() ];
+           eShri1D.insert( & shrinker );
+           shrinker.AddEdge( eos._edges[0], eos, helper );
            VISCOUS_3D::ToClearSubWithMain( edgeSM, data._solid );
-           // restore params of nodes on EGDE if the EDGE has been already
-           // srinked while srinking other FACE
-           srinker.RestoreParams();
+           // restore params of nodes on EDGE if the EDGE has been already
+           // shrinked while shrinking other FACE
+           shrinker.RestoreParams();
          }
          for ( size_t i = 0; i < eos._edges.size(); ++i )
          {
      if ( data2 )
        VISCOUS_3D::ToClearSubWithMain( sm, data2->_solid );
  
-   } // loop on FACES to srink mesh on
+   } // loop on FACES to shrink mesh on
  
  
    // Replace source nodes by target nodes in shrinked mesh edges
@@@ -10981,7 -10981,7 +10981,7 @@@ void _ViscousBuilder::restoreNoShrink( 
  
  //================================================================================
  /*!
-  * \brief Try to fix triangles with high aspect ratio by swaping diagonals
+  * \brief Try to fix triangles with high aspect ratio by swapping diagonals
   */
  //================================================================================
  
index 23d18d35db0c9aa2d06edecc8ce57e039d828552,6cb97c538332e2cbdd489f8bcbff599781373c14..7c8ebe7767b2d1ab32201f942d59331424984392
@@@ -176,7 -176,7 +176,7 @@@ namespace VISCOUS_2
     */
    struct _Segment
    {
-     const gp_XY* _uv[2];       // poiter to _LayerEdge::_uvIn
+     const gp_XY* _uv[2];       // pointer to _LayerEdge::_uvIn
      int          _indexInLine; // position in _PolyLine
  
      _Segment() {}
  //================================================================================
  // StdMeshers_ViscousLayers hypothesis
  //
 -StdMeshers_ViscousLayers2D::StdMeshers_ViscousLayers2D(int hypId, int studyId, SMESH_Gen* gen)
 -  :StdMeshers_ViscousLayers(hypId, studyId, gen)
 +StdMeshers_ViscousLayers2D::StdMeshers_ViscousLayers2D(int hypId, SMESH_Gen* gen)
 +  :StdMeshers_ViscousLayers(hypId, gen)
  {
    _name = StdMeshers_ViscousLayers2D::GetHypType();
    _param_algo_dim = -2; // auxiliary hyp used by 2D algos
@@@ -600,7 -600,7 +600,7 @@@ StdMeshers_ViscousLayers2D::CheckHypoth
  // --------------------------------------------------------------------------------
  void StdMeshers_ViscousLayers2D::RestoreListeners() const
  {
 -  StudyContextStruct* sc = _gen->GetStudyContext( _studyId );
 +  StudyContextStruct* sc = _gen->GetStudyContext();
    std::map < int, SMESH_Mesh * >::iterator i_smesh = sc->mapMesh.begin();
    for ( ; i_smesh != sc->mapMesh.end(); ++i_smesh )
    {
index 5b6b5451246f76bd2a9b1d8f857db7cf4caf157d,8ce79e2f83da5269f7367ad914bef2f8afec8c2a..74f99aa000f522c0535d1a62c132808634cc2499
@@@ -36,7 -36,7 +36,7 @@@
  #include <SVTK_ViewWindow.h>
  #include <SALOME_ListIO.hxx>
  
- // SALOME KERNEL incldues
+ // SALOME KERNEL includes
  #include <SALOMEDSClient_SObject.hxx>
  #include <SALOMEDSClient_Study.hxx>
  
@@@ -227,9 -227,9 +227,9 @@@ void StdMeshersGUI_ObjectReferenceParam
    
    for ( unsigned i = 0; i < objects->length(); ++i )
    {
 -    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
 +    _PTR(Study) aStudy = SMESH::getStudy();
      _PTR(SObject) aSObj = aStudy->FindObjectID(objects[i].in());
 -    CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
 +    CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
      if ( !CORBA::is_nil( anObj )) {
        std::string name = aSObj->GetName();
        QString text = myObjNameLineEdit->text();
index 8c49daa2a72e0c917b05f6a4a3af2ed8866a92b1,bc551c68bfd1f2b1df132b4411eb286b4561f1f2..72ed9ba54443a83faeed6edb920295ec07794292
@@@ -126,7 -126,7 +126,7 @@@ QWidget* StdMeshersGUI_StdHypothesisCre
  
  //================================================================================
  /*!
-  * \brief Allow modifing myCustomWidgets in const methods
+  * \brief Allow modifying myCustomWidgets in const methods
    * \retval ListOfWidgets* - non-const pointer to myCustomWidgets
   */
  //================================================================================
@@@ -423,10 -423,10 +423,10 @@@ bool StdMeshersGUI_StdHypothesisCreator
        GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
  
        GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
 -      _PTR(Study)         aStudy = SMESH::GetActiveStudyDocument();
 +      _PTR(Study)         aStudy = SMESH::getStudy();
        GEOM::GEOM_IShapesOperations_wrap shapeOp;
        if ( !geomGen->_is_nil() && aStudy )
 -        shapeOp = geomGen->GetIShapesOperations( aStudy->StudyId() );
 +        shapeOp = geomGen->GetIShapesOperations();
        if ( !shapeOp->_is_nil() )
        {
          GEOM::ListOfLong_var vertices =
@@@ -1433,7 -1433,7 +1433,7 @@@ QString StdMeshersGUI_StdHypothesisCrea
  //================================================================================
  /*!
   * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name
-  * from message resouce file
+  * from message resource file
    * \param t - hypothesis type
    * \retval QString - result string
   */
index 60b0772ab5987c485ebd0c2cecad52da75a0400d,7ad64cee20dd2cf27951e8106619a2d25be2023b..c7e3988b845e69486f2f04bd30f532d488c27a38
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_ObjRefUlils.cxx
  // Created   : Wed Oct 18 15:38:22 2006
  // Author    : Edward AGAPOV (eap)
@@@ -59,8 -59,9 +59,8 @@@ StdMeshers_ObjRefUlils::EntryOrShapeToG
  
    // try by entry
    if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
 -    SALOMEDS::Study_var study = gen->GetCurrentStudy();
 -    if ( ! theEntry.empty() && ! study->_is_nil() ) {
 -      SALOMEDS::SObject_wrap sobj = study->FindObjectID( theEntry.c_str() );
 +    if ( ! theEntry.empty() ) {
 +      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( theEntry.c_str() );
        CORBA::Object_var       obj = gen->SObjectToObject( sobj );
        geom = GEOM::GEOM_Object::_narrow( obj );
      }
@@@ -87,7 -88,7 +87,7 @@@ void StdMeshers_ObjRefUlils::SaveToStre
      if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
        GEOM::GEOM_Object_var geom = gen->ShapeToGeomObject( theShape );
        if ( ! geom->_is_nil() ) {
 -        SALOMEDS::SObject_wrap sobj = gen->ObjectToSObject( gen->GetCurrentStudy(), geom );
 +        SALOMEDS::SObject_wrap sobj = gen->ObjectToSObject( geom );
          if ( !sobj->_is_nil() ) {
            CORBA::String_var entry = sobj->GetID();
            stream << " " << entry.in();
@@@ -116,10 -117,13 +116,10 @@@ TopoDS_Shape StdMeshers_ObjRefUlils::Lo
      if ( entry )
        * entry = str;
      if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
 -      SALOMEDS::Study_var study = gen->GetCurrentStudy();
 -      if ( ! study->_is_nil() ) {
 -        SALOMEDS::SObject_wrap sobj = study->FindObjectID( str.c_str() );
 -        CORBA::Object_var       obj = gen->SObjectToObject( sobj );
 -        GEOM::GEOM_Object_var  geom = GEOM::GEOM_Object::_narrow( obj );
 -        return gen->GeomObjectToShape( geom.in() );
 -      }
 +      SALOMEDS::SObject_wrap sobj = SMESH_Gen_i::getStudyServant()->FindObjectID( str.c_str() );
 +      CORBA::Object_var       obj = gen->SObjectToObject( sobj );
 +      GEOM::GEOM_Object_var  geom = GEOM::GEOM_Object::_narrow( obj );
 +      return gen->GeomObjectToShape( geom.in() );
      }
    }
    if ( entry )
index c095f95b3c5c8bc95be5e0af5ece0152f8c3c58f,ca30fd3d242e259d4289c750db4328036d7cc07a..fb2540c65c5331cfdda55ecb49db63e92a9e49f8
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH SMESH : implementaion of SMESH idl descriptions
+ //  SMESH SMESH : implementation of SMESH idl descriptions
  // File      : StdMeshers_ObjRefUlils.hxx
  // Created   : Wed Oct 18 15:15:27 2006
  // Author    : Edward AGAPOV (eap)
@@@ -42,7 -42,7 +42,7 @@@ class StdMeshers_ObjRefUlil
  {
  public:
    /*!
-    * \brief Return GEOM Object correspoding to TopoDS_Shape
+    * \brief Return GEOM Object corresponding to TopoDS_Shape
      * \param theShape - input TopoDS_Shape
      * \retval GEOM::GEOM_Object_ptr - result object
     */
@@@ -54,7 -54,7 +54,7 @@@
     }
  
    /*!
-    * \brief Return TopoDS_Shape correspoding to GEOM_Object
+    * \brief Return TopoDS_Shape corresponding to GEOM_Object
      * \param theGeomObject - input object
      * \retval TopoDS_Shape - result TopoDS_Shape
     */
      if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
        std::string str;
        if (stream >> str) {
 -        if ( StudyContext* myStudyContext = gen->GetCurrentStudyContext() ) {
 +        if ( StudyContext* myStudyContext = gen->GetStudyContext() ) {
            std::string ior = myStudyContext->getIORbyOldId( atoi( str.c_str() ));
            if ( !ior.empty() )
               return TInterface::_narrow(gen->GetORB()->string_to_object( ior.c_str() ));
index b2f2382201e09a290addb13416f7dd6473750656,97b28afcfc23d2f14d26aa19f5f07ab741628ef5..34c5db54123f9fc00aad9fafbccd049d4e794cbc
@@@ -20,7 -20,7 +20,7 @@@
  // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  //
  
- //  SMESH StdMeshers : implementaion of SMESH idl descriptions
+ //  SMESH StdMeshers : implementation of SMESH idl descriptions
  //  File   : StdMeshers_i.cxx
  //  Author : Julia DOROVSKIKH
  //  Module : SMESH
@@@ -113,10 -113,11 +113,10 @@@ class QuadrangleParamsCreator : public 
  {
  public:
    virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
 -                                      int                     theStudyId,
                                        ::SMESH_Gen*            theGenImpl)
    {
      StdMeshers_QuadrangleParams_i* h =
 -      new StdMeshers_QuadrangleParams_i( thePOA, theStudyId, theGenImpl);
 +      new StdMeshers_QuadrangleParams_i( thePOA, theGenImpl);
      h->SetQuadType( TYPE );
      return h;
    }