X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_PythonDump.cxx;h=5c9163bf42e3d55b2439accd1f2d58e33f2f5636;hb=17fe9ed25bf8040b93634b492ded417954f295a1;hp=0828fc5e4c3f0df88770c7575551f0faae0b9c17;hpb=7a3ecab720cc517ace17c5c4677fd3c20c0051ee;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_PythonDump.cxx b/src/SMESH_I/SMESH_PythonDump.cxx index 0828fc5e4..5c9163bf4 100644 --- a/src/SMESH_I/SMESH_PythonDump.cxx +++ b/src/SMESH_I/SMESH_PythonDump.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2019 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 @@ -349,7 +349,6 @@ namespace SMESH { 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()) { @@ -427,6 +426,7 @@ namespace SMESH case FT_MultiConnection2D: myStream<< "aMultiConnection2D"; break; case FT_Length: myStream<< "aLength"; break; case FT_Length2D: myStream<< "aLength2D"; break; + case FT_Length3D: myStream<< "aLength3D"; break; case FT_Deflection2D: myStream<< "aDeflection2D"; break; case FT_NodeConnectivityNumber:myStream<< "aNodeConnectivityNumber";break; case FT_BelongToMeshGroup: myStream<< "aBelongToMeshGroup"; break; @@ -541,6 +541,16 @@ namespace SMESH DumpArray( theList, *this ); return *this; } + TPythonDump& TPythonDump::operator<<(const SMESH::submesh_array& theList) + { + DumpArray( theList, *this ); + return *this; + } + TPythonDump& TPythonDump::operator<<(const SMESH::ListOfHypothesis& theList) + { + DumpArray( theList, *this ); + return *this; + } TPythonDump& TPythonDump::operator<<(const SMESH::CoincidentFreeBorders& theCFB) { // dump CoincidentFreeBorders as a list of lists, each enclosed list @@ -679,33 +689,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(); @@ -992,14 +1002,16 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl 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; - + TCollection_AsciiString optionalComment; + std::list< TCollection_AsciiString > lines; // lines of a script std::list< TCollection_AsciiString >::iterator linesIt; + lines.push_back( aSMESHGen + " = smeshBuilder.New()" ); if ( isPublished ) - lines.push_back( aSMESHGen + " = smeshBuilder.New()" ); - else - lines.push_back( aSMESHGen + " = smeshBuilder.New(False)" ); + optionalComment = "#"; + lines.push_back( optionalComment + aSMESHGen + ".SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations:" ); + lines.push_back( " # multiples meshes built in parallel, complex and numerous mesh edition (performance)\n" ); lines.push_back( helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()" ); lines.push_back( helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()" ); @@ -1177,26 +1189,28 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl } // import python files corresponding to plugins if they are used in anUpdatedScript { - TCollection_AsciiString importStr; + //TCollection_AsciiString importStr; std::vector pluginNames = getPluginNames(); for ( size_t i = 0; i < pluginNames.size(); ++i ) { // Convert access to plugin members: - // e.g. StdMeshers.QUAD_REDUCED -> StdMeshersBuilder.QUAD_REDUCED + // e.g. StdMeshers.QUAD_REDUCED -> smeshBuilder.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; + //anUpdatedScript.Insert( iPos + pluginNames[i].size(), "Builder" ); + anUpdatedScript.Remove( iPos, pluginNames[i].size() ); + anUpdatedScript.Insert( iPos, "smeshBuilder" ); + iFrom = iPos - pluginNames[i].size() + 12; } // 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 ( iFrom > 1 ) + // importStr += ( helper + "\n" "from salome." + pluginNames[i].c_str() + + // " import " + pluginNames[i].c_str() +"Builder" ); } - if ( !importStr.IsEmpty() ) - initPart += importStr + "\n"; + // if ( !importStr.IsEmpty() ) + // initPart += importStr + "\n"; } if ( isMultiFile )