X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_PythonDump.cxx;h=7ffedf1d4eeed4e0b958bf6f8a7778027a3e1779;hp=0204a498a17234c4d6373470aa5e4cf3016ff869;hb=35012b0a3d7a04ff4af9f1622340a814b3f1300b;hpb=50b5fac2a8a05b472f332ac1f84ec38c7f305cb5 diff --git a/src/SMESH_I/SMESH_PythonDump.cxx b/src/SMESH_I/SMESH_PythonDump.cxx index 0204a498a..7ffedf1d4 100644 --- a/src/SMESH_I/SMESH_PythonDump.cxx +++ b/src/SMESH_I/SMESH_PythonDump.cxx @@ -678,33 +678,33 @@ namespace SMESH 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() ) + void RemoveTabulation( TCollection_AsciiString& theScript ) { - aPos = aString.find( "\n\t", aPos ); - if( aPos == std::string::npos ) - break; - aString.replace( aPos, 2, "\n" ); - aPos++; + 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(); } - theScript = aString.c_str(); } //======================================================================= //function : DumpPython //purpose : //======================================================================= -Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished, - CORBA::Boolean isMultiFile, +Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Boolean isPublished, + CORBA::Boolean isMultiFile, CORBA::Boolean& isValidScript) { SALOMEDS::Study_var aStudy = getStudyServant(); @@ -884,25 +884,25 @@ namespace { 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; -// } -// } + // 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' ); @@ -995,10 +995,9 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl 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( aSMESHGen + " = smeshBuilder.New()" ); + if ( !isPublished ) + lines.push_back( aSMESHGen + ".SetEnablePublish( False )" ); lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" ); lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" );