_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();
+ }
}
//================================================================================
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();
_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" )
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 );
//================================================================================
/*!
- * \brief Clean commmands of removed objects depending on myIsPublished flag
+ * \brief Clean commands of removed objects depending on myIsPublished flag
*/
//================================================================================
// 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 );
// ----------------------------------------------------------------------
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");
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",
"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
//================================================================================
/*!
- * \brief Set agrument
+ * \brief Set argument
* \param index - The argument index, it counts from 1
* \param theArg - The argument string
*/