Salome HOME
0021375: EDF 1671 SMESH: Dump study of current state
[modules/smesh.git] / src / SMESH_I / SMESH_2smeshpy.cxx
index ea012abc4192b61600fb051aa6ec5d36b6788d43..c8fe9b6abea9ba8dbc92ee6e5c43778a3611ac2a 100644 (file)
@@ -1808,19 +1808,36 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
     if( pos != -1)
     {
       isPyMeshMethod = true;
+      bool is0DmethId  = ( method == "ExtrusionSweepMakeGroups0D" );
+      bool is0DmethObj = ( method == "ExtrusionSweepObject0DMakeGroups");
 
       // 1. Remove "MakeGroups" from the Command
       TCollection_AsciiString aMethod = theCommand->GetMethod();
       int nbArgsToAdd = diffLastTwoArgsMethods.Contains(aMethod) ? 2 : 1;
+      
+      if(is0DmethObj)
+        pos = pos-2;  //Remove "0D" from the Command too
       aMethod.Trunc(pos-1);
       theCommand->SetMethod(aMethod);
 
       // 2. And add last "True" argument(s)
       while(nbArgsToAdd--)
         theCommand->SetArg(theCommand->GetNbArgs()+1,"True");
+      if( is0DmethId || is0DmethObj )
+        theCommand->SetArg(theCommand->GetNbArgs()+1,"True");
     }
   }
 
+  // ExtrusionSweep0D() -> ExtrusionSweep()
+  // ExtrusionSweepObject0D() -> ExtrusionSweepObject()
+  if ( !isPyMeshMethod && ( method == "ExtrusionSweep0D"  ||
+                            method == "ExtrusionSweepObject0D" ))
+  {
+    isPyMeshMethod=true;
+    theCommand->SetMethod( method.SubString( 1, method.Length()-2));
+    theCommand->SetArg(theCommand->GetNbArgs()+1,"False");  //sets flag "MakeGroups = False"
+    theCommand->SetArg(theCommand->GetNbArgs()+1,"True");  //sets flag "IsNode = True"
+  }
   // set "ExtrusionAlongPathX()" instead of "ExtrusionAlongPathObjX()"
   if ( !isPyMeshMethod && method == "ExtrusionAlongPathObjX")
   {
@@ -2271,7 +2288,8 @@ bool _pyHypothesis::Addition2Creation( const Handle(_pyCommand)& theCmd,
 void _pyHypothesis::Process( const Handle(_pyCommand)& theCommand)
 {
   ASSERT( !myIsAlgo );
-  rememberCmdOfParameter( theCommand );
+  if ( !theGen->IsToKeepAllCommands() )
+    rememberCmdOfParameter( theCommand );
   // set args
   int nbArgs = 0;
   for ( int i = 1; i <= myArgMethods.Length(); ++i ) {
@@ -2296,9 +2314,8 @@ void _pyHypothesis::Process( const Handle(_pyCommand)& theCommand)
 
 void _pyHypothesis::Flush()
 {
-  if ( IsWrapped() ) {
-  }
-  else {
+  if ( !IsAlgo() )
+  {
     list < Handle(_pyCommand) >::iterator cmd = myArgCommands.begin();
     for ( ; cmd != myArgCommands.end(); ++cmd ) {
       // Add access to a wrapped mesh
@@ -2387,34 +2404,34 @@ bool _pyHypothesis::CanClear()
 
 void _pyHypothesis::ClearCommands()
 {
-  if ( !theGen->IsToKeepAllCommands() )
-  {
-    bool isUsed = false;
-    int lastComputeOrder = 0;
-    list<Handle(_pyCommand) >::iterator cmd = myComputeCmds.begin();
-    for ( ; cmd != myComputeCmds.end(); ++cmd )
-      if ( ! (*cmd)->IsEmpty() )
-      {
-        isUsed = true;
-        if ( (*cmd)->GetOrderNb() > lastComputeOrder )
-          lastComputeOrder = (*cmd)->GetOrderNb();
-      }
-    if ( !isUsed )
-    {
-      SetRemovedFromStudy( true );
-    }
-    else
-    {
-      // clear my commands invoked after lastComputeOrder
-      map<TCollection_AsciiString, list< Handle(_pyCommand) > >::iterator m2c;
-      for ( m2c = myMeth2Commands.begin(); m2c != myMeth2Commands.end(); ++m2c )
-      {
-        list< Handle(_pyCommand)> & cmds = m2c->second;
-        if ( !cmds.empty() && cmds.back()->GetOrderNb() > lastComputeOrder )
-          cmds.back()->Clear();
-      }
-    }
-  }
+  // if ( !theGen->IsToKeepAllCommands() )
+  // {
+  //   bool isUsed = false;
+  //   int lastComputeOrder = 0;
+  //   list<Handle(_pyCommand) >::iterator cmd = myComputeCmds.begin();
+  //   for ( ; cmd != myComputeCmds.end(); ++cmd )
+  //     if ( ! (*cmd)->IsEmpty() )
+  //     {
+  //       isUsed = true;
+  //       if ( (*cmd)->GetOrderNb() > lastComputeOrder )
+  //         lastComputeOrder = (*cmd)->GetOrderNb();
+  //     }
+  //   if ( !isUsed )
+  //   {
+  //     SetRemovedFromStudy( true );
+  //   }
+  //   else
+  //   {
+  //     // clear my commands invoked after lastComputeOrder
+  //     // map<TCollection_AsciiString, list< Handle(_pyCommand) > >::iterator m2c;
+  //     // for ( m2c = myMeth2Commands.begin(); m2c != myMeth2Commands.end(); ++m2c )
+  //     // {
+  //     //   list< Handle(_pyCommand)> & cmds = m2c->second;
+  //     //   if ( !cmds.empty() && cmds.back()->GetOrderNb() > lastComputeOrder )
+  //     //     cmds.back()->Clear();
+  //     // }
+  //   }
+  // }
   _pyObject::ClearCommands();
 }
 
@@ -2471,23 +2488,35 @@ bool _pyHypothesis::GetReferredMeshesAndGeom( list< Handle(_pyMesh) >& meshes )
 
 void _pyHypothesis::rememberCmdOfParameter( const Handle(_pyCommand) & theCommand )
 {
-  // not to clear commands setting different parameters via one method
+  // parameters are discriminated by method name
+  TCollection_AsciiString method = theCommand->GetMethod();
+
+  // discriminate commands setting different parameters via one method
   // by passing parameter names like e.g. SetOption("size", "0.2")
-  int quotePos = theCommand->GetString().FirstLocationInSet( "'\"", 1, theCommand->Length() );
-  if ( !quotePos )
+  if ( theCommand->GetString().FirstLocationInSet( "'\"", 1, theCommand->Length() ) &&
+       theCommand->GetNbArgs() > 1 )
   {
-    // parameters are discriminated by method name
-    list< Handle(_pyCommand)>& cmds = myMeth2Commands[ theCommand->GetMethod() ];
-    if ( !cmds.empty() && !isCmdUsedForCompute( cmds.back() ))
-    {
-      cmds.back()->Clear(); // previous parameter value has not been used
-      cmds.back() = theCommand;
-    }
-    else
+    // mangle method by appending a 1st textual arg (what if it's a variable name?!!!)
+    for ( int iArg = 1; iArg <= theCommand->GetNbArgs(); ++iArg )
     {
-      cmds.push_back( theCommand );
+      const TCollection_AsciiString& arg = theCommand->GetArg( iArg );
+      if ( arg.Value(1) != '\"' && arg.Value(1) != '\'' ) continue;
+      if ( !isalpha( arg.Value(2))) continue;
+      method += arg;
+      break;
     }
   }
+  // parameters are discriminated by method name
+  list< Handle(_pyCommand)>& cmds = myMeth2Commands[ theCommand->GetMethod() ];
+  if ( !cmds.empty() && !isCmdUsedForCompute( cmds.back() ))
+  {
+    cmds.back()->Clear(); // previous parameter value has not been used
+    cmds.back() = theCommand;
+  }
+  else
+  {
+    cmds.push_back( theCommand );
+  }
 }
 
 //================================================================================
@@ -2974,12 +3003,12 @@ const TCollection_AsciiString & _pyCommand::GetResultValue()
     if ( endPos )
     {
       begPos = 1;
-      while ( begPos < endPos && isblank( myString.Value( begPos ))) ++begPos;
+      while ( begPos < endPos && isspace( myString.Value( begPos ))) ++begPos;
       if ( begPos < endPos )
       {
         SetBegPos( RESULT_IND, begPos );
         --endPos;
-        while ( begPos < endPos && isblank( myString.Value( endPos ))) --endPos;
+        while ( begPos < endPos && isspace( myString.Value( endPos ))) --endPos;
         myRes = myString.SubString( begPos, endPos );
       }
     }
@@ -3451,7 +3480,7 @@ void _pyCommand::Comment()
   if ( IsEmpty() ) return;
 
   int i = 1;
-  while ( i <= Length() && isblank( myString.Value(i) )) ++i;
+  while ( i <= Length() && isspace( myString.Value(i) )) ++i;
   if ( i <= Length() )
   {
     myString.Insert( i, "#" );