Salome HOME
Fix to avoid dependence of mesh on itself (it leaded to cycle in 'SetRemovedFromStudy').
[modules/smesh.git] / src / SMESH_I / SMESH_2smeshpy.cxx
index b8f6840b73b9b8c44713b7d366125472dc9e41a8..20cc26043e36127d0f88380b1313a36392ec0def 100644 (file)
@@ -345,7 +345,7 @@ namespace {
 
 //================================================================================
 /*!
- * \brief Convert a python script using commands of smesh.py
+ * \brief Convert a python script using commands of smeshBuilder.py
  *  \param theScript - Input script
  *  \param theEntry2AccessorMethod - returns method names to access to
  *         objects wrapped with python class
@@ -498,7 +498,7 @@ _pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod
 
 //================================================================================
 /*!
- * \brief name of SMESH_Gen in smesh.py
+ * \brief name of SMESH_Gen in smeshBuilder.py
  */
 //================================================================================
 
@@ -916,7 +916,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
 
   // Replace name of SMESH_Gen
 
-  // names of SMESH_Gen methods fully equal to methods defined in smesh.py
+  // names of SMESH_Gen methods fully equal to methods defined in smeshBuilder.py
   static TStringSet smeshpyMethods;
   if ( smeshpyMethods.empty() ) {
     const char * names[] =
@@ -929,7 +929,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
     // smeshgen.Method() --> smesh.Method()
     theCommand->SetObject( SMESH_2smeshpy::SmeshpyName() );
   else
-    // smeshgen.Method() --> smesh.smesh.Method()
+    // smeshgen.Method() --> smesh.Method()
     theCommand->SetObject( SMESH_2smeshpy::GenName() );
 }
 
@@ -982,7 +982,7 @@ void _pyGen::Flush()
   for ( hyp = myHypos.begin(); hyp != myHypos.end(); ++hyp )
     if ( !hyp->IsNull() ) {
       (*hyp)->Flush();
-      // smeshgen.CreateHypothesis() --> smesh.smesh.CreateHypothesis()
+      // smeshgen.CreateHypothesis() --> smesh.CreateHypothesis()
       if ( !(*hyp)->IsWrapped() )
         (*hyp)->GetCreationCmd()->SetObject( SMESH_2smeshpy::GenName() );
     }
@@ -2011,7 +2011,7 @@ void _pyMesh::ClearCommands()
 
 void _pyMesh::addFatherMesh( const _pyID& meshID )
 {
-  if ( !meshID.IsEmpty() )
+  if ( !meshID.IsEmpty() && meshID != GetID() )
     addFatherMesh( Handle(_pyMesh)::DownCast( theGen->FindObject( meshID )));
 }
 
@@ -2023,7 +2023,7 @@ void _pyMesh::addFatherMesh( const _pyID& meshID )
 
 void _pyMesh::addFatherMesh( const Handle(_pyMesh)& mesh )
 {
-  if ( !mesh.IsNull() )
+  if ( !mesh.IsNull() && mesh->GetID() != GetID() )
   {
     //myFatherMeshes.push_back( mesh );
     mesh->myChildMeshes.push_back( this );
@@ -3316,7 +3316,7 @@ const TCollection_AsciiString & _pyCommand::GetObject()
     }
     myObj = GetWord( myString, begPos, true );
     // check if object is complex,
-    // so far consider case like "smesh.smesh.Method()"
+    // so far consider case like "smesh.Method()"
     if ( int bracketPos = myString.Location( "(", begPos, Length() )) {
       //if ( bracketPos==0 ) bracketPos = Length();
       int dotPos = begPos+myObj.Length();
@@ -3715,9 +3715,9 @@ void _pyCommand::Comment()
     myString.Insert( i, "#" );
     for ( int iPart = 0; iPart < myBegPos.Length(); ++iPart )
     {
-      int begPos = GetBegPos( iPart );
+      int begPos = GetBegPos( iPart + 1 );
       if ( begPos != UNKNOWN )
-        SetBegPos( iPart, begPos + 1 );
+        SetBegPos( iPart + 1, begPos + 1 );
     }
   }
 }