From 95dab66d27ba89f7ef91cf50e207367d2b48125a Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 15 Dec 2005 08:34:25 +0000 Subject: [PATCH] PAL10494 (SMESH python dump uses idl interface). Python dump converted to smesh.py API, usage of TPythonDump tool --- src/SMESH_I/SMESH_DumpPython.cxx | 394 ++++++++++----------- src/SMESH_I/SMESH_Gen_i.cxx | 69 ++-- src/SMESH_I/SMESH_Gen_i.hxx | 24 -- src/SMESH_I/SMESH_Group_i.cxx | 23 +- src/SMESH_I/SMESH_MeshEditor_i.cxx | 537 ++++++++++++----------------- src/SMESH_I/SMESH_Mesh_i.cxx | 174 +++------- src/SMESH_I/SMESH_Pattern_i.cxx | 67 ++-- src/SMESH_I/SMESH_PythonDump.hxx | 32 ++ 8 files changed, 550 insertions(+), 770 deletions(-) diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index d88f470d9..97e49b2a1 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -26,6 +26,7 @@ #include "SMESH_PythonDump.hxx" #include "SMESH_Gen_i.hxx" #include "SMESH_Filter_i.hxx" +#include "SMESH_2smeshpy.hxx" #include #include @@ -105,7 +106,8 @@ namespace SMESH TPythonDump& TPythonDump:: operator<<(const char* theArg){ - myStream< + void DumpArray(const TArray& theArray, std::ostringstream & theStream) + { + theStream << "[ "; + for (int i = 1; i <= theArray.length(); i++) { + theStream << theArray[i-1]; + if ( i < theArray.length() ) + theStream << ", "; + } + theStream << " ]"; + } TPythonDump& - TPythonDump:: - operator<<(const SMESH::long_array& theArg) + TPythonDump::operator<<(const SMESH::long_array& theArg) { - myStream<<"[ "; - CORBA::Long i = 1, iEnd = theArg.length(); - for(; i <= iEnd; i++) { - myStream<_is_nil() ) + myStream << aSObject->GetID(); + else + myStream << NotPublishedObjectName(); + return *this; + } TPythonDump& TPythonDump:: operator<<(CORBA::Object_ptr theArg) { - TCollection_AsciiString aString("None"); SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg); - if(!aSObject->_is_nil()){ - aString = aSObject->GetID(); - }else if(!CORBA::is_nil(theArg)){ - aString = "smeshObj_"; + if(!aSObject->_is_nil()) { + myStream << aSObject->GetID(); + } else if ( !CORBA::is_nil(theArg)) { if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object - aString += (int) theArg; + myStream << "smeshObj_" << (int) theArg; else - aString = NotPublishedObjectName(); + myStream << NotPublishedObjectName(); } - myStream<GetFunctorType(); - switch(aFunctorType){ - case FT_AspectRatio: - myStream<<"anAspectRatio"; - break; - case FT_AspectRatio3D: - myStream<<"anAspectRatio3D"; - break; - case FT_Warping: - myStream<<"aWarping"; - break; - case FT_MinimumAngle: - myStream<<"aMinimumAngle"; - break; - case FT_Taper: - myStream<<"aTaper"; - break; - case FT_Skew: - myStream<<"aSkew"; - break; - case FT_Area: - myStream<<"aArea"; - break; - case FT_FreeBorders: - myStream<<"aFreeBorders"; - break; - case FT_FreeEdges: - myStream<<"aFreeEdges"; - break; - case FT_MultiConnection: - myStream<<"aMultiConnection"; - break; - case FT_MultiConnection2D: - myStream<<"aMultiConnection2D"; - break; - case FT_Length: - myStream<<"aLength"; - break; - case FT_Length2D: - myStream<<"aLength"; - break; - case FT_BelongToGeom: - myStream<<"aBelongToGeom"; - break; - case FT_BelongToPlane: - myStream<<"aBelongToPlane"; - break; - case FT_BelongToCylinder: - myStream<<"aBelongToCylinder"; - break; - case FT_LyingOnGeom: - myStream<<"aLyingOnGeom"; - break; - case FT_RangeOfIds: - myStream<<"aRangeOfIds"; - break; - case FT_BadOrientedVolume: - myStream<<"aBadOrientedVolume"; - break; - case FT_LessThan: - myStream<<"aLessThan"; - break; - case FT_MoreThan: - myStream<<"aMoreThan"; - break; - case FT_EqualTo: - myStream<<"anEqualTo"; - break; - case FT_LogicalNOT: - myStream<<"aLogicalNOT"; - break; - case FT_LogicalAND: - myStream<<"aLogicalAND"; - break; - case FT_LogicalOR: - myStream<<"aLogicalOR"; - break; - case FT_Undefined: - myStream<<"anUndefined"; - break; + if ( theArg ) { + FunctorType aFunctorType = theArg->GetFunctorType(); + switch(aFunctorType){ + case FT_AspectRatio: myStream<< "anAspectRatio"; break; + case FT_AspectRatio3D: myStream<< "anAspectRatio3D"; break; + case FT_Warping: myStream<< "aWarping"; break; + case FT_MinimumAngle: myStream<< "aMinimumAngle"; break; + case FT_Taper: myStream<< "aTaper"; break; + case FT_Skew: myStream<< "aSkew"; break; + case FT_Area: myStream<< "aArea"; break; + case FT_FreeBorders: myStream<< "aFreeBorders"; break; + case FT_FreeEdges: myStream<< "aFreeEdges"; break; + case FT_MultiConnection: myStream<< "aMultiConnection"; break; + case FT_MultiConnection2D:myStream<< "aMultiConnection2D";break; + case FT_Length: myStream<< "aLength"; break; + case FT_Length2D: myStream<< "aLength"; break; + case FT_BelongToGeom: myStream<< "aBelongToGeom"; break; + case FT_BelongToPlane: myStream<< "aBelongToPlane"; break; + case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break; + case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break; + case FT_RangeOfIds: myStream<< "aRangeOfIds"; break; + case FT_BadOrientedVolume:myStream<< "aBadOrientedVolume";break; + case FT_LessThan: myStream<< "aLessThan"; break; + case FT_MoreThan: myStream<< "aMoreThan"; break; + case FT_EqualTo: myStream<< "anEqualTo"; break; + case FT_LogicalNOT: myStream<< "aLogicalNOT"; break; + case FT_LogicalAND: myStream<< "aLogicalAND"; break; + case FT_LogicalOR: myStream<< "aLogicalOR"; break; + case FT_Undefined: myStream<< "anUndefined"; break; + } + myStream<NewChildIterator(aSO); for (Itr->InitEx(true); Itr->More(); Itr->Next()) { @@ -330,9 +339,6 @@ Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy, TCollection_AsciiString aSavedTrace (oldValue); // Add trace of API methods calls and replace study entries by names - //TCollection_AsciiString aScript = - // SALOMEDSImpl_Study::GetDumpStudyComment("SMESH") + "\n\n" + - // DumpPython_impl(aStudy->StudyId(), aMap, aMapNames, isPublished, isValidScript, aSavedTrace); TCollection_AsciiString aScript = "### This file is generated by SALOME automatically by dump python functionality of SMESH component\n\n"; aScript += DumpPython_impl(aStudy->StudyId(), aMap, aMapNames, @@ -377,45 +383,6 @@ void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID) } } -//======================================================================= -//function : AddToCurrentPyScript -//purpose : -//======================================================================= - -void SMESH_Gen_i::AddToCurrentPyScript (const TCollection_AsciiString& theString) -{ - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); - if (aStudy->_is_nil()) return; - aSMESHGen->AddToPythonScript(aStudy->StudyId(), theString); -} - - -//======================================================================= -//function : AddObject -//purpose : add object to script string -//======================================================================= - -TCollection_AsciiString& SMESH_Gen_i::AddObject(TCollection_AsciiString& theStr, - CORBA::Object_ptr theObject) -{ - TCollection_AsciiString aString("None"); - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::SObject_var aSObject = - aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject); - if ( !aSObject->_is_nil() ) { - aString = aSObject->GetID(); - } else if ( !CORBA::is_nil( theObject )) { - aString = "smeshObj_"; - if ( aSMESHGen->CanPublishInStudy( theObject )) // not published SMESH object - aString += (int) theObject; - else - aString = NotPublishedObjectName(); - } - theStr += aString; - return theStr; -} - //======================================================================= //function : SavePython //purpose : @@ -470,19 +437,20 @@ Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theStri while(i < aLen) { int c = (int)arr[i]; j = i+1; - if(c >= 48 && c <= 57) { //Is digit? + if ( isdigit( c )) { //Is digit? isFound = Standard_False; - while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry + while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry c = (int)arr[j++]; - if(c == 58) isFound = Standard_True; + if(c == ':') isFound = Standard_True; } if (isFound) { int prev = (i < 1) ? 0 : (int)arr[i - 1]; - // last char should be a diggit, + // to distinguish from a sketcher command: + // last char should be a digit, not ":", // previous char should not be '"'. - if (arr[j-2] != 58 && prev != 34) { + if (arr[j-2] != ':' && prev != '"') { aSeq->Append(i+1); // +1 because AsciiString starts from 1 aSeq->Append(j-1); } @@ -508,28 +476,57 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl bool& aValidScript, const TCollection_AsciiString& theSavedTrace) { + TCollection_AsciiString helper; // to comfortably concatenate C strings + TCollection_AsciiString aSmeshpy( SMESH_2smeshpy::SmeshpyName() ); + TCollection_AsciiString aSMESHGen( SMESH_2smeshpy::GenName() ); + TCollection_AsciiString anOldGen( SMESH::TPythonDump::SMESHGenName() ); + TCollection_AsciiString aScript; - aScript = "def RebuildData(theStudy):"; - aScript += "\n\tsmesh = salome.lcc.FindOrLoadComponent(\"FactoryServer\", \"SMESH\")"; - aScript += "\n\taFilterManager = smesh.CreateFilterManager()"; + aScript = "def RebuildData(theStudy):\n\t"; + aScript += helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()\n\t"; if ( isPublished ) - aScript += "\n\tsmesh.SetCurrentStudy(theStudy)"; + aScript += aSMESHGen + ".SetCurrentStudy(theStudy)"; else - aScript += "\n\tsmesh.SetCurrentStudy(None)"; + aScript += aSMESHGen + ".SetCurrentStudy(None)"; // Dump trace of restored study if (theSavedTrace.Length() > 0) { - aScript += "\n"; - aScript += theSavedTrace; + // For the convertion of IDL API calls -> smesh.py API, "smesh" standing for SMESH_Gen + // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()). + // Change "smesh" -> "smeshgen" in the trace saved before passage to smesh.py API + bool isNewVersion = + theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() ); + if ( !isNewVersion ) { + TCollection_AsciiString aSavedTrace( theSavedTrace ); + TCollection_AsciiString aSmeshCall ( "smesh." ), gen( "gen" ); + int beg, end = aSavedTrace.Length(), from = 1; + while ( from < end && ( beg = aSavedTrace.Location( aSmeshCall, from, end ))) { + char charBefore = ( beg == 1 ) ? ' ' : aSavedTrace.Value( beg - 1 ); + if ( isspace( charBefore ) || charBefore == '=' ) { + aSavedTrace.Insert( beg + aSmeshCall.Length() - 1, gen ); + end += gen.Length(); + } + from = beg + aSmeshCall.Length(); + } + aScript += helper + "\n" + aSavedTrace; + } + else + // append a saved trace to the script + aScript += helper + "\n" + theSavedTrace; } // Dump trace of API methods calls TCollection_AsciiString aNewLines = GetNewPythonLines(theStudyID); if (aNewLines.Length() > 0) { - aScript += "\n"; - aScript += aNewLines; + aScript += helper + "\n" + aNewLines; } + // Convert IDL API calls into smesh.py API. + // Some objects are wrapped with python classes and + // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects + Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod; + aScript = SMESH_2smeshpy::ConvertScript( aScript, anEntry2AccessorMethod ); + // Find entries to be replaced by names Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript); Standard_Integer aLen = aSeq->Length(); @@ -566,14 +563,18 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl aName = theObjectNames.Find(anEntry); // check validity of aName bool isValidName = true; - if ( aName.IsIntegerValue() ) { // aName must not start with a digit - aName.Insert( 1, 'a' ); + int p=1; // replace not allowed chars with underscore + while (p <= aName.Length() && + (p = aName.FirstLocationNotInSet(allowedChars, p, aName.Length()))) + { + if ( p == 1 || p == aName.Length() || aName.Value(p-1) == '_') + aName.Remove( p, 1 ); // remove double _ and from the start and the end + else + aName.SetValue(p, '_'); isValidName = false; } - int p, p2=1; // replace not allowed chars - while ((p = aName.FirstLocationNotInSet(allowedChars, p2, aName.Length()))) { - aName.SetValue(p, '_'); - p2=p; + if ( aName.IsIntegerValue() ) { // aName must not start with a digit + aName.Insert( 1, 'a' ); isValidName = false; } if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) { @@ -592,7 +593,7 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl } else { // Removed Object do { - aName = aBaseName + TCollection_AsciiString(++objectCounter); + aName = aBaseName + (++objectCounter); } while (theObjectNames.IsBound(aName)); seqRemoved.Append(aName); mapRemoved.Bind(anEntry, "1"); @@ -609,10 +610,12 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl } // set initial part of aSript - TCollection_AsciiString initPart = "import salome, SMESH, StdMeshers\n\n"; + TCollection_AsciiString initPart = "import salome, SMESH\n"; + initPart += helper + "import " + aSmeshpy + "\n\n"; if ( importGeom ) { - initPart += ("import string, os, sys, re\n" + initPart += ("## import GEOM dump file ## \n" + "import string, os, sys, re\n" "sys.path.insert( 0, os.path.dirname(__file__) )\n" "exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",__name__)+\" import *\")\n\n"); } @@ -623,7 +626,10 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength); // Remove removed objects - anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()"; + if ( seqRemoved.Length() > 0 ) { + anUpdatedScript += "\n\t## some objects were removed"; + anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()"; + } for (int ir = 1; ir <= seqRemoved.Length(); ir++) { anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR("; anUpdatedScript += seqRemoved.Value(ir); @@ -631,27 +637,31 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl } // Set object names - anUpdatedScript += "\n\n\tisGUIMode = "; - anUpdatedScript += isPublished; - anUpdatedScript += "\n\tif isGUIMode:"; - anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")"; - anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())"; - anUpdatedScript += "\n"; + anUpdatedScript += "\n\t## set object names"; + anUpdatedScript += helper + " \n\tisGUIMode = " + isPublished; + anUpdatedScript += "\n\tif isGUIMode and salome.sg.hasDesktop():"; +// anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")"; +// anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())"; +// anUpdatedScript += "\n"; TCollection_AsciiString aGUIName; Resource_DataMapOfAsciiStringAsciiString mapEntries; - for (Standard_Integer i = 1; i <= aLen; i += 2) { + for (Standard_Integer i = 1; i <= aLen; i += 2) + { anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1)); aName = geom->GetDumpName( anEntry.ToCString() ); if (aName.IsEmpty() && // Not a GEOM object theNames.IsBound(anEntry) && !mapEntries.IsBound(anEntry) && // Not yet processed - !mapRemoved.IsBound(anEntry)) { // Was not removed + !mapRemoved.IsBound(anEntry)) // Was not removed + { aName = theObjectNames.Find(anEntry); aGUIName = theNames.Find(anEntry); mapEntries.Bind(anEntry, aName); - anUpdatedScript += "\n\t\tsmeshgui.SetName(salome.ObjectToID("; - anUpdatedScript += aName + "), \"" + aGUIName + "\")"; + anUpdatedScript += helper + "\n\t\t" + aSmeshpy + ".SetName(" + aName; + if ( anEntry2AccessorMethod.IsBound( anEntry ) ) + anUpdatedScript += helper + "." + anEntry2AccessorMethod( anEntry ); + anUpdatedScript += helper + ", '" + aGUIName + "')"; } } anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)"; diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 2806e40eb..f4999c97f 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -59,6 +59,7 @@ #include "SMESH_Hypothesis_i.hxx" #include "SMESH_Algo_i.hxx" #include "SMESH_Group_i.hxx" +#include "SMESH_PythonDump.hxx" #include "SMESHDS_Document.hxx" #include "SMESHDS_Group.hxx" @@ -89,6 +90,7 @@ #include using namespace std; +using SMESH::TPythonDump; #define NUM_TMP_FILES 2 @@ -411,7 +413,7 @@ GEOM_Client* SMESH_Gen_i::GetShapeReader() void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy ) { //if(MYDEBUG) - MESSAGE( "SMESH_Gen_i::SetCurrentStudy" ); + //MESSAGE( "SMESH_Gen_i::SetCurrentStudy" ); myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy ); // create study context, if it doesn't exist and set current study int studyId = GetCurrentStudyID(); @@ -480,14 +482,8 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam SALOMEDS::SObject_var aSO = PublishHypothesis( myCurrentStudy, hyp ); if ( !aSO->_is_nil() ) { // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = smesh.CreateHypothesis(\""; - aStr += Standard_CString(theHypName); - aStr += "\", \""; - aStr += Standard_CString(theLibName); - aStr += "\")"; - - AddToCurrentPyScript(aStr); + TPythonDump() << aSO << " = " << this << ".CreateHypothesis('" + << theHypName << "', '" << theLibName << "')"; } } @@ -522,11 +518,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj aStudyBuilder->CommitCommand(); if ( !aSO->_is_nil() ) { // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = smesh.CreateMesh("; - SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")"; - - AddToCurrentPyScript(aStr); + TPythonDump() << aSO << " = " << this << ".CreateMesh(" << theShapeObject << ")"; } } @@ -557,12 +549,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName aStudyBuilder->CommitCommand(); if ( !aSO->_is_nil() ) { // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = smesh.CreateMeshesFromUNV(\""; - aStr += Standard_CString(theFileName); - aStr += "\")"; - - AddToCurrentPyScript(aStr); + TPythonDump() << aSO << " = smeshgen.CreateMeshesFromUNV('" << theFileName << "')"; } } @@ -588,7 +575,9 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" ); // Python Dump - TCollection_AsciiString aStr ("(["); + TPythonDump aPythonDump; + aPythonDump << "(["; + //TCollection_AsciiString aStr ("(["); // Retrieve mesh names from the file DriverMED_R_SMESHDS_Mesh myReader; @@ -607,7 +596,8 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, // Iterate through all meshes and create mesh objects for ( list::iterator it = aNames.begin(); it != aNames.end(); it++ ) { // Python Dump - if (i > 0) aStr += ", "; + //if (i > 0) aStr += ", "; + if (i > 0) aPythonDump << ", "; // create mesh SMESH::SMESH_Mesh_var mesh = createMesh(); @@ -618,11 +608,13 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, aSO = PublishMesh( myCurrentStudy, mesh.in(), (*it).c_str() ); if ( !aSO->_is_nil() ) { // Python Dump - aStr += aSO->GetID(); + aPythonDump << aSO; + //aStr += aSO->GetID(); } else { // Python Dump - aStr += "mesh_"; - aStr += TCollection_AsciiString(i); + aPythonDump << "mesh_" << i; +// aStr += "mesh_"; +// aStr += TCollection_AsciiString(i); } // Read mesh data (groups are published automatically by ImportMEDFile()) @@ -639,11 +631,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, } // Update Python script - aStr += "], status) = smesh.CreateMeshesFromMED(\""; - aStr += Standard_CString(theFileName); - aStr += "\")"; - - AddToCurrentPyScript(aStr); + aPythonDump << "], status) = " << this << ".CreateMeshesFromMED('" << theFileName << "')"; return aResult._retn(); } @@ -672,13 +660,8 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() ); aStudyBuilder->CommitCommand(); if ( !aSO->_is_nil() ) { - // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = smesh.CreateMeshesFromSTL(\""; - aStr += Standard_CString(theFileName); - aStr += "\")"; - - AddToCurrentPyScript(aStr); + // Update Python script + TPythonDump() << aSO << " = " << this << ".CreateMeshesFromSTL('" << theFileName << "')"; } } @@ -922,15 +905,9 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, SALOME::BAD_PARAM ); // Update Python script - TCollection_AsciiString aStr ("isDone = smesh.Compute("); - SMESH_Gen_i::AddObject(aStr, theMesh) += ", "; - SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")"; - - AddToCurrentPyScript(aStr); - - aStr = "if isDone == 0: print \"Mesh "; - SMESH_Gen_i::AddObject(aStr, theMesh) += " computation failed\""; - AddToCurrentPyScript(aStr); + TPythonDump() << "isDone = " << this << ".Compute( " + << theMesh << ", " << theShapeObject << ")"; + TPythonDump() << "if not isDone: print 'Mesh " << theMesh << " : computation failed'"; try { // get mesh servant diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index 1ffe1993f..b2d6d882a 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -295,8 +295,6 @@ public: void RemoveLastFromPythonScript (int theStudyID); - static void AddToCurrentPyScript (const TCollection_AsciiString& theString); - void SavePython (SALOMEDS::Study_ptr theStudy); TCollection_AsciiString DumpPython_impl (int theStudyID, @@ -310,28 +308,6 @@ public: void CleanPythonTrace (int theStudyID); - // Dump python comfort methods - - static TCollection_AsciiString& AddObject(TCollection_AsciiString& theStr, - CORBA::Object_ptr theObject); - // add object to script string - - template - static TCollection_AsciiString& AddArray(TCollection_AsciiString& theStr, - const _array & array) - // put array contents into theStr like this: "[ 1, 2, 5 ]" - { - ostringstream sout; // can convert long int, and TCollection_AsciiString cant - sout << "[ "; - for (int i = 1; i <= array.length(); i++) { - sout << array[i-1]; - if ( i < array.length() ) - sout << ", "; - } - sout << " ]"; - theStr += (char*) sout.str().c_str(); - return theStr; - } // ***************************************** // Internal methods diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 47236abcc..2720a60f5 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -120,11 +120,7 @@ SMESHDS_GroupBase* SMESH_GroupBase_i::GetGroupDS() const void SMESH_GroupBase_i::SetName( const char* theName ) { // Update Python script - TCollection_AsciiString aStr, aStrName ((char*)theName); - SMESH_Gen_i::AddObject(aStr, _this()) += ".SetName(\""; - aStr += aStrName + "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".SetName( '" << theName << "' )"; // Perform renaming ::SMESH_Group* aGroup = GetSmeshGroup(); @@ -219,10 +215,7 @@ CORBA::Boolean SMESH_GroupBase_i::IsEmpty() void SMESH_Group_i::Clear() { // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, _this()) += ".Clear()"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".Clear()"; // Clear the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); @@ -257,11 +250,7 @@ CORBA::Boolean SMESH_GroupBase_i::Contains( CORBA::Long theID ) CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs ) { // Update Python script - TCollection_AsciiString aStr ("nbAdd = "); - SMESH_Gen_i::AddObject(aStr, _this()) += ".Add("; - SMESH_Gen_i::AddArray(aStr, theIDs) += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << "nbAdd = " << _this() << ".Add( " << theIDs << " )"; // Add elements to the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); @@ -287,11 +276,7 @@ CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs ) CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs ) { // Update Python script - TCollection_AsciiString aStr ("nbDel = "); - SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove("; - SMESH_Gen_i::AddArray(aStr, theIDs) += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << "nbDel = " << _this() << ".Remove( " << theIDs << " )"; // Remove elements from the group SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 76f79d76b..9aa35ea1e 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -36,6 +36,7 @@ #include "SMESH_Gen_i.hxx" #include "SMESH_Filter_i.hxx" +#include "SMESH_PythonDump.hxx" #include "utilities.h" @@ -49,24 +50,7 @@ typedef map > TElemOfElemListMap; using namespace std; - -//======================================================================= -//function : addAxis -//purpose : -//======================================================================= - -static TCollection_AsciiString& addAxis(TCollection_AsciiString& theStr, - const SMESH::AxisStruct & theAxis) -{ - theStr += "SMESH.AxisStruct( "; - theStr += TCollection_AsciiString( theAxis.x ) + ", "; - theStr += TCollection_AsciiString( theAxis.y ) + ", "; - theStr += TCollection_AsciiString( theAxis.z ) + ", "; - theStr += TCollection_AsciiString( theAxis.vx ) + ", "; - theStr += TCollection_AsciiString( theAxis.vy ) + ", "; - theStr += TCollection_AsciiString( theAxis.vz ) + " )"; - return theStr; -} +using SMESH::TPythonDump; //============================================================================= /*! @@ -95,11 +79,9 @@ CORBA::Boolean IdList.push_back( IDsOfElements[i] ); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.RemoveElements("); - SMESH_Gen_i::AddArray( str, IDsOfElements ) += ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"RemoveElements: \", isDone" ); + TPythonDump() << "print 'RemoveElements: ', isDone"; #endif // Remove Elements return anEditor.Remove( IdList, false ); @@ -111,8 +93,7 @@ CORBA::Boolean */ //============================================================================= -CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH:: - long_array & IDsOfNodes) +CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes) { ::SMESH_MeshEditor anEditor( _myMesh ); list< int > IdList; @@ -120,11 +101,9 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH:: IdList.push_back( IDsOfNodes[i] ); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.RemoveNodes("); - SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"RemoveNodes: \", isDone" ); + TPythonDump() << "print 'RemoveNodes: ', isDone"; #endif return anEditor.Remove( IdList, true ); @@ -146,10 +125,8 @@ CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes) GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2)); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.AddEdge(["); - str += TCollection_AsciiString((int) index1) + ", "; - str += TCollection_AsciiString((int) index2) + " ])"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".AddEdge([ " + << index1 << ", " << index2 <<" ])"; } return true; } @@ -166,11 +143,8 @@ CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x, GetMeshDS()->AddNode(x, y, z); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.AddNode("); - str += TCollection_AsciiString( x ) + ", "; - str += TCollection_AsciiString( y ) + ", "; - str += TCollection_AsciiString( z ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".AddNode( " + << x << ", " << y << ", " << z << " )"; return true; } @@ -207,11 +181,9 @@ CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes) } // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.AddFace("); - SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".AddFace( " << IDsOfNodes << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"AddFace: \", isDone" ); + TPythonDump() << "print 'AddFace: ', isDone"; #endif return true; @@ -223,8 +195,7 @@ CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes) */ //============================================================================= -CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH:: - long_array & IDsOfNodes) +CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes) { int NbNodes = IDsOfNodes.length(); vector< const SMDS_MeshNode*> n(NbNodes); @@ -239,11 +210,9 @@ CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH:: case 8:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break; } // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.AddVolume("); - SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".AddVolume( " << IDsOfNodes << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"AddVolume: \", isDone" ); + TPythonDump() << "print 'AddVolume: ', isDone"; #endif return true; @@ -271,12 +240,10 @@ CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolume GetMeshDS()->AddPolyhedralVolume(n, q); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.AddPolyhedralVolume("); - SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ", "; - SMESH_Gen_i::AddArray( str, Quantities ) += ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".AddPolyhedralVolume( " + << IDsOfNodes << ", " << Quantities << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"AddPolyhedralVolume: \", isDone" ); + TPythonDump() << "print 'AddPolyhedralVolume: ', isDone"; #endif return true; @@ -307,11 +274,10 @@ CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.AddPolyhedralVolumeByFaces("); - SMESH_Gen_i::AddArray( str, IdsOfFaces ) += ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".AddPolyhedralVolumeByFaces( " + << IdsOfFaces << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"AddPolyhedralVolume: \", isDone" ); + TPythonDump() << "print 'AddPolyhedralVolume: ', isDone"; #endif return true; @@ -335,12 +301,8 @@ CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID, GetMeshDS()->MoveNode(node, x, y, z); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.MoveNode("); - str += TCollection_AsciiString((Standard_Integer) NodeID) + ", "; - str += TCollection_AsciiString((Standard_Real) x) + ", "; - str += TCollection_AsciiString((Standard_Real) y) + ", "; - str += TCollection_AsciiString((Standard_Real) z) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".MoveNode( " + << NodeID << ", " << x << ", " << y << ", " << z << " )"; return true; } @@ -360,10 +322,8 @@ CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1, return false; // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.InverseDiag("); - str += TCollection_AsciiString((Standard_Integer) NodeID1) + ", "; - str += TCollection_AsciiString((Standard_Integer) NodeID2) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".InverseDiag( " + << NodeID1 << ", " << NodeID2 << " )"; ::SMESH_MeshEditor aMeshEditor( _myMesh ); return aMeshEditor.InverseDiag ( n1, n2 ); @@ -384,10 +344,8 @@ CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1, return false; // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.DeleteDiag("); - str += TCollection_AsciiString((Standard_Integer) NodeID1) + ", "; - str += TCollection_AsciiString((Standard_Integer) NodeID2) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".DeleteDiag( " + << NodeID1 << ", " << NodeID2 << " )"; ::SMESH_MeshEditor aMeshEditor( _myMesh ); return aMeshEditor.DeleteDiag ( n1, n2 ); @@ -410,9 +368,7 @@ CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfEleme anEditor.Reorient( elem ); } // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.Reorient("); - SMESH_Gen_i::AddArray( str, IDsOfElements ) += ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )"; return true; } @@ -434,9 +390,7 @@ CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theO aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.ReorientObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".ReorientObject( " << theObject << " )"; return isDone; } @@ -467,12 +421,10 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE aCrit = aNumericalFunctor->GetNumericalFunctor(); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.TriToQuad("); - SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None, "; - str += TCollection_AsciiString((Standard_Real) MaxAngle) + ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".TriToQuad( " + << IDsOfElements << ", None, " << MaxAngle << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuad: \", isDone" ); + TPythonDump() << "print 'TriToQuad: ', isDone"; #endif ::SMESH_MeshEditor anEditor( _myMesh ); @@ -499,12 +451,10 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr #endif // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.TriToQuadObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", None, "; - str += TCollection_AsciiString((Standard_Real) MaxAngle) + ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".TriToQuadObject(" + << theObject << ", None, " << MaxAngle << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuadObject: \", isDone" ); + TPythonDump() << "print 'TriToQuadObject: ', isDone"; #endif return isDone; @@ -536,11 +486,9 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfE // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.QuadToTri("); - SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", None )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTri: \", isDone" ); + TPythonDump() << "print 'QuadToTri: ', isDone"; #endif ::SMESH_MeshEditor anEditor( _myMesh ); @@ -566,11 +514,9 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr #endif // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.QuadToTriObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", None )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".QuadToTriObject(" << theObject << ", None )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTriObject: \", isDone" ); + TPythonDump() << "print 'QuadToTriObject: ', isDone"; #endif return isDone; @@ -594,12 +540,10 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle } // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.SplitQuad("); - SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", "; - str += TCollection_AsciiString( Diag13 ) + ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".SplitQuad( " + << IDsOfElements << ", " << Diag13 << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuad: \", isDone" ); + TPythonDump() << "print 'SplitQuad: ', isDone"; #endif ::SMESH_MeshEditor anEditor( _myMesh ); @@ -625,12 +569,10 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr th #endif // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor.SplitQuadObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", "; - str += TCollection_AsciiString( Diag13 ) + ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << ".SplitQuadObject( " + << theObject << ", " << Diag13 << " )"; #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuadObject: \", isDone" ); + TPythonDump() << "print 'SplitQuadObject: ', isDone"; #endif return isDone; @@ -767,22 +709,15 @@ CORBA::Boolean MaxNbOfIterations, MaxAspectRatio, IsParametric ); // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor."); - str += (char*) (IsParametric ? "SmoothParametric( " : "Smooth( "); - SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", "; - SMESH_Gen_i::AddArray( str, IDsOfFixedNodes ) += ", "; - str += (Standard_Integer) MaxNbOfIterations; - str += ", "; - str += (Standard_Real) MaxAspectRatio; - if ( method == ::SMESH_MeshEditor::CENTROIDAL ) - str += ", SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH, "; - else - str += ", SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH, "; - str += IsParametric; - str += " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << "." + << (IsParametric ? "SmoothParametric( " : "Smooth( ") + << IDsOfElements << ", " << IDsOfFixedNodes << ", " + << MaxNbOfIterations << ", " << MaxAspectRatio << ", " + << "SMESH.SMESH_MeshEditor." + << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ? + "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )"); #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"Smooth: \", isDone" ); + TPythonDump() << "print 'Smooth: ', isDone"; #endif return true; @@ -795,12 +730,12 @@ CORBA::Boolean //============================================================================= CORBA::Boolean - SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject, - const SMESH::long_array & IDsOfFixedNodes, - CORBA::Long MaxNbOfIterations, - CORBA::Double MaxAspectRatio, - SMESH::SMESH_MeshEditor::Smooth_Method Method, - bool IsParametric) +SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method, + bool IsParametric) { SMESH::long_array_var anElementsId = theObject->GetIDs(); CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations, @@ -814,22 +749,15 @@ CORBA::Boolean #endif // Update Python script - TCollection_AsciiString str ("isDone = mesh_editor."); - str += (char*) (IsParametric ? "SmoothParametricObject( " : "SmoothObject( "); - SMESH_Gen_i::AddObject( str, theObject ) += ", "; - SMESH_Gen_i::AddArray( str, IDsOfFixedNodes ) += ", "; - str += (Standard_Integer) MaxNbOfIterations; - str += ", "; - str += (Standard_Real) MaxAspectRatio; - if ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ) - str += ", SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH, "; - else - str += ", SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH, "; - str += IsParametric; - str += " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = " << this << "." + << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ") + << theObject << ", " << IDsOfFixedNodes << ", " + << MaxNbOfIterations << ", " << MaxAspectRatio << ", " + << "SMESH.SMESH_MeshEditor." + << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ? + "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )"); #ifdef _DEBUG_ - SMESH_Gen_i::AddToCurrentPyScript( "print \"SmoothObject: \", isDone" ); + TPythonDump() << "print 'SmoothObject: ', isDone"; #endif return isDone; @@ -844,7 +772,7 @@ CORBA::Boolean void SMESH_MeshEditor_i::RenumberNodes() { // Update Python script - SMESH_Gen_i::AddToCurrentPyScript( "mesh_editor.RenumberNodes()" ); + TPythonDump() << this << ".RenumberNodes()"; GetMeshDS()->Renumber( true ); } @@ -858,7 +786,7 @@ void SMESH_MeshEditor_i::RenumberNodes() void SMESH_MeshEditor_i::RenumberElements() { // Update Python script - SMESH_Gen_i::AddToCurrentPyScript( "mesh_editor.RenumberElements()" ); + TPythonDump() << this << ".RenumberElements()"; GetMeshDS()->Renumber( false ); } @@ -892,15 +820,13 @@ void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElement theNbOfSteps, theTolerance); // Update Python script - TCollection_AsciiString str = "axis = "; - addAxis( str, theAxis ); - SMESH_Gen_i::AddToCurrentPyScript( str ); - str = "mesh_editor.RotationSweep("; - SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", axis, "; - str += TCollection_AsciiString( theAngleInRadians ) + ", "; - str += TCollection_AsciiString( (int)theNbOfSteps ) + ", "; - str += TCollection_AsciiString( theTolerance ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".RotationSweep( " + << theIDsOfElements + << ", axis, " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; } //======================================================================= @@ -922,12 +848,12 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); // Update Python script - TCollection_AsciiString str ("mesh_editor.RotationSweepObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", axis, "; - str += TCollection_AsciiString( theAngleInRadians ) + ", "; - str += TCollection_AsciiString( (int)theNbOfSteps ) + ", "; - str += TCollection_AsciiString( theTolerance ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << this << ".RotationSweepObject( " + << theObject + << ", axis, " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; } //======================================================================= @@ -958,15 +884,9 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory); // Update Python script - TCollection_AsciiString str = "stepVector = SMESH.DirStruct( SMESH.PointStruct ( "; - str += (TCollection_AsciiString) stepVec.X() + ", "; - str += (TCollection_AsciiString) stepVec.Y() + ", "; - str += (TCollection_AsciiString) stepVec.Z() + " ))"; - SMESH_Gen_i::AddToCurrentPyScript( str ); - str = ("mesh_editor.ExtrusionSweep("); - SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", stepVector, "; - str += TCollection_AsciiString((int)theNbOfSteps) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweep( " + << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; } @@ -987,10 +907,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); // Update Python script - TCollection_AsciiString str ("mesh_editor.ExtrusionSweepObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", stepVector, "; - str += TCollection_AsciiString((int)theNbOfSteps) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << this << ".ExtrusionSweepObject( " + << theObject << ", stepVector, " << theNbOfSteps << " )"; } //======================================================================= @@ -1021,6 +939,11 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObj //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps); TElemOfElemListMap aHystory; anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory); + + // Update Python script + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweepObject1D( " + << theObject << ", stepVector, " << theNbOfSteps << " )"; } //======================================================================= @@ -1051,6 +974,11 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObj //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps); TElemOfElemListMap aHystory; anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory); + + // Update Python script + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".ExtrusionSweepObject2D( " + << theObject << ", stepVector, " << theNbOfSteps << " )"; } @@ -1084,17 +1012,13 @@ void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfEle theExtrFlags, theSewTolerance); // Update Python script - TCollection_AsciiString str = "stepVector = SMESH.DirStruct( SMESH.PointStruct ( "; - str += (TCollection_AsciiString) stepVec.X() + ", "; - str += (TCollection_AsciiString) stepVec.Y() + ", "; - str += (TCollection_AsciiString) stepVec.Z() + " ))"; - SMESH_Gen_i::AddToCurrentPyScript( str ); - str = ("mesh_editor.AdvancedExtrusion("); - SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", stepVector, "; - str += TCollection_AsciiString((int)theNbOfSteps) + ","; - str += TCollection_AsciiString((int)theExtrFlags) + ", "; - str += TCollection_AsciiString((double)theSewTolerance) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "stepVector = " << theStepVector; + TPythonDump() << this << ".AdvancedExtrusion(" + << theIDsOfElements + << ", stepVector, " + << theNbOfSteps << "," + << theExtrFlags << ", " + << theSewTolerance << " )"; } @@ -1163,23 +1087,23 @@ SMESH::SMESH_MeshEditor::Extrusion_Error gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z ); // Update Python script - TCollection_AsciiString str = "refPoint = SMESH.PointStruct( "; - str += (TCollection_AsciiString) refPnt.X() + ", "; - str += (TCollection_AsciiString) refPnt.Y() + ", "; - str += (TCollection_AsciiString) refPnt.Z() + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); - str = ("error = mesh_editor.ExtrusionAlongPath("); - SMESH_Gen_i::AddArray ( str, theIDsOfElements ) += ", "; - SMESH_Gen_i::AddObject( str, thePathMesh ) += ", "; - SMESH_Gen_i::AddObject( str, thePathShape ) += ", "; - str += TCollection_AsciiString( (int)theNodeStart ) + ", "; - str += TCollection_AsciiString( (int)theHasAngles ) + ", "; - SMESH_Gen_i::AddArray ( str, theAngles ) += ", "; - str += (TCollection_AsciiString) theHasRefPoint + ", refPoint )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "refPoint = SMESH.PointStruct( " + << refPnt.X() << ", " + << refPnt.Y() << ", " + << refPnt.Z() << " )"; + TPythonDump() << "error = " << this << ".ExtrusionAlongPath( " + << theIDsOfElements << ", " + << thePathMesh << ", " + << thePathShape << ", " + << theNodeStart << ", " + << theHasAngles << ", " + << theAngles << ", " + << theHasRefPoint << ", refPoint )"; ::SMESH_MeshEditor anEditor( _myMesh ); - return convExtrError( anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, theHasAngles, angles, theHasRefPoint, refPnt ) ); + return convExtrError( anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, + theHasAngles, angles, + theHasRefPoint, refPnt ) ); } //======================================================================= @@ -1188,14 +1112,14 @@ SMESH::SMESH_MeshEditor::Extrusion_Error //======================================================================= SMESH::SMESH_MeshEditor::Extrusion_Error - SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject, - SMESH::SMESH_Mesh_ptr thePathMesh, - GEOM::GEOM_Object_ptr thePathShape, - CORBA::Long theNodeStart, - CORBA::Boolean theHasAngles, - const SMESH::double_array & theAngles, - CORBA::Boolean theHasRefPoint, - const SMESH::PointStruct & theRefPoint) +SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject, + SMESH::SMESH_Mesh_ptr thePathMesh, + GEOM::GEOM_Object_ptr thePathShape, + CORBA::Long theNodeStart, + CORBA::Boolean theHasAngles, + const SMESH::double_array & theAngles, + CORBA::Boolean theHasRefPoint, + const SMESH::PointStruct & theRefPoint) { SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath @@ -1207,15 +1131,14 @@ SMESH::SMESH_MeshEditor::Extrusion_Error aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); // Update Python script - TCollection_AsciiString str ("error = mesh_editor.ExtrusionAlongPathObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", "; - SMESH_Gen_i::AddObject( str, thePathMesh ) += ", "; - SMESH_Gen_i::AddObject( str, thePathShape ) += ", "; - str += TCollection_AsciiString( (int)theNodeStart ) + ", "; - str += TCollection_AsciiString( theHasAngles ) + ", "; - SMESH_Gen_i::AddArray ( str, theAngles ) += ", "; - str += TCollection_AsciiString( theHasRefPoint ) + ", refPoint )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( " + << theObject << ", " + << thePathMesh << ", " + << thePathShape << ", " + << theNodeStart << ", " + << theHasAngles << ", " + << theAngles << ", " + << theHasRefPoint << ", refPoint )"; return error; } @@ -1244,7 +1167,7 @@ void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElem gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz ); gp_Trsf aTrsf; - TCollection_AsciiString typeStr, copyStr( theCopy ); + TCollection_AsciiString typeStr; switch ( theMirrorType ) { case SMESH::SMESH_MeshEditor::POINT: aTrsf.SetMirror( P ); @@ -1260,12 +1183,11 @@ void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElem } // Update Python script - TCollection_AsciiString str ("mesh_editor.Mirror("); - SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", "; - addAxis( str, theAxis ) += ", "; - str += typeStr + ", "; - str += copyStr + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << this << ".Mirror( " + << theIDsOfElements << ", " + << theAxis << ", " + << typeStr << ", " + << theCopy << " )"; ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.Transform (elements, aTrsf, theCopy); @@ -1289,7 +1211,7 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); // Update Python script - TCollection_AsciiString typeStr, copyStr( theCopy ); + TCollection_AsciiString typeStr; switch ( theMirrorType ) { case SMESH::SMESH_MeshEditor::POINT: typeStr = "SMESH.SMESH_MeshEditor.POINT"; @@ -1300,12 +1222,12 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj default: typeStr = "SMESH.SMESH_MeshEditor.PLANE"; } - - TCollection_AsciiString str ("mesh_editor.MirrorObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", "; - addAxis( str, theAxis ) += ", "; - str += typeStr + ", " + copyStr + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".MirrorObject( " + << theObject << ", " + << "axis, " + << typeStr << ", " + << theCopy << " )"; } //======================================================================= @@ -1335,15 +1257,11 @@ void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements, anEditor.Transform (elements, aTrsf, theCopy); // Update Python script - TCollection_AsciiString str = "vector = SMESH.DirStruct( SMESH.PointStruct ( "; - str += (TCollection_AsciiString) P->x + ", "; - str += (TCollection_AsciiString) P->y + ", "; - str += (TCollection_AsciiString) P->z + " ))"; - SMESH_Gen_i::AddToCurrentPyScript( str ); - str = ("mesh_editor.Translate("); - SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", vector, "; - str += (TCollection_AsciiString) theCopy + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "vector = " << theVector; + TPythonDump() << this << ".Translate( " + << theIDsOfElements + << ", vector, " + << theCopy << " )"; } //======================================================================= @@ -1363,10 +1281,10 @@ void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject, aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); // Update Python script - TCollection_AsciiString str ("mesh_editor.TranslateObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", vector, "; - str += TCollection_AsciiString( theCopy ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << this << ".TranslateObject( " + << theObject + << ", vector, " + << theCopy << " )"; } //======================================================================= @@ -1399,14 +1317,12 @@ void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, anEditor.Transform (elements, aTrsf, theCopy); // Update Python script - TCollection_AsciiString str ("axis = "); - addAxis( str, theAxis ); - SMESH_Gen_i::AddToCurrentPyScript( str ); - str = ("mesh_editor.Rotate("); - SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", axis, "; - str += (TCollection_AsciiString) theAngle + ", "; - str += (TCollection_AsciiString) theCopy + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "axis = " << theAxis; + TPythonDump() << this << ".Rotate( " + << theIDsOfElements + << ", axis, " + << theAngle << ", " + << theCopy << " )"; } //======================================================================= @@ -1427,11 +1343,11 @@ void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject, aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); // Update Python script - TCollection_AsciiString str ("mesh_editor.RotateObject("); - SMESH_Gen_i::AddObject( str, theObject ) += ", axis, "; - str += TCollection_AsciiString( theAngle ) + ", "; - str += TCollection_AsciiString( theCopy ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << this << ".RotateObject( " + << theObject + << ", axis, " + << theAngle << ", " + << theCopy << " )"; } //======================================================================= @@ -1459,6 +1375,9 @@ void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tol for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ ) aGroup[ j ] = (*lIt)->GetID(); } + // Update Python script + TPythonDump() << "coincident_nodes = " << this << ".FindCoincidentNodes( " + << Tolerance << " )"; } //======================================================================= @@ -1470,7 +1389,8 @@ void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfN { SMESHDS_Mesh* aMesh = GetMeshDS(); - TCollection_AsciiString str( "mesh_editor.MergeNodes([" ); + TPythonDump aTPythonDump; + aTPythonDump << this << ".MergeNodes(["; ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes; for (int i = 0; i < GroupsOfNodes.length(); i++) { @@ -1487,15 +1407,14 @@ void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfN if ( aListOfNodes.size() < 2 ) aListOfListOfNodes.pop_back(); - if ( i > 0 ) - str += ","; - SMESH_Gen_i::AddArray( str, aNodeGroup ); + if ( i > 0 ) aTPythonDump << ", "; + aTPythonDump << aNodeGroup; } ::SMESH_MeshEditor anEditor( _myMesh ); anEditor.MergeNodes( aListOfListOfNodes ); // Update Python script - SMESH_Gen_i::AddToCurrentPyScript( str + "])" ); + aTPythonDump << "])"; } //======================================================================= @@ -1509,7 +1428,7 @@ void SMESH_MeshEditor_i::MergeEqualElements() anEditor.MergeEqualElements(); // Update Python script - SMESH_Gen_i::AddToCurrentPyScript( "mesh_editor.MergeEqualElements()" ); + TPythonDump() << this << ".MergeEqualElements()"; } //======================================================================= @@ -1570,16 +1489,15 @@ SMESH::SMESH_MeshEditor::Sew_Error return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; // Update Python script - TCollection_AsciiString str ("error = mesh_editor.SewFreeBorders( "); - str += TCollection_AsciiString( (int) FirstNodeID1 ) + ", "; - str += TCollection_AsciiString( (int) SecondNodeID1 ) + ", "; - str += TCollection_AsciiString( (int) LastNodeID1 ) + ", "; - str += TCollection_AsciiString( (int) FirstNodeID2 ) + ", "; - str += TCollection_AsciiString( (int) SecondNodeID2 ) + ", "; - str += TCollection_AsciiString( (int) LastNodeID2 ) + ", "; - str += TCollection_AsciiString( CreatePolygons ) + ", "; - str += TCollection_AsciiString( CreatePolyedrs ) + ") "; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "error = " << this << ".SewFreeBorders( " + << FirstNodeID1 << ", " + << SecondNodeID1 << ", " + << LastNodeID1 << ", " + << FirstNodeID2 << ", " + << SecondNodeID2 << ", " + << LastNodeID2 << ", " + << CreatePolygons<< ", " + << CreatePolyedrs<< " )"; ::SMESH_MeshEditor anEditor( _myMesh ); return convError( anEditor.SewFreeBorder (aBorderFirstNode, @@ -1599,11 +1517,11 @@ SMESH::SMESH_MeshEditor::Sew_Error //======================================================================= SMESH::SMESH_MeshEditor::Sew_Error - SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, - CORBA::Long SecondNodeID1, - CORBA::Long LastNodeID1, - CORBA::Long FirstNodeID2, - CORBA::Long SecondNodeID2) +SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, + CORBA::Long SecondNodeID1, + CORBA::Long LastNodeID1, + CORBA::Long FirstNodeID2, + CORBA::Long SecondNodeID2) { SMESHDS_Mesh* aMesh = GetMeshDS(); @@ -1623,13 +1541,12 @@ SMESH::SMESH_MeshEditor::Sew_Error return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; // Update Python script - TCollection_AsciiString str ("error = mesh_editor.SewConformFreeBorders( "); - str += TCollection_AsciiString( (int) FirstNodeID1 ) + ", "; - str += TCollection_AsciiString( (int) SecondNodeID1 ) + ", "; - str += TCollection_AsciiString( (int) LastNodeID1 ) + ", "; - str += TCollection_AsciiString( (int) FirstNodeID2 ) + ", "; - str += TCollection_AsciiString( (int) SecondNodeID2 ) + ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "error = " << this << ".SewConformFreeBorders( " + << FirstNodeID1 << ", " + << SecondNodeID1 << ", " + << LastNodeID1 << ", " + << FirstNodeID2 << ", " + << SecondNodeID2 << " )"; ::SMESH_MeshEditor anEditor( _myMesh ); return convError( anEditor.SewFreeBorder (aBorderFirstNode, @@ -1648,13 +1565,13 @@ SMESH::SMESH_MeshEditor::Sew_Error //======================================================================= SMESH::SMESH_MeshEditor::Sew_Error - SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, - CORBA::Long SecondNodeIDOnFreeBorder, - CORBA::Long LastNodeIDOnFreeBorder, - CORBA::Long FirstNodeIDOnSide, - CORBA::Long LastNodeIDOnSide, - CORBA::Boolean CreatePolygons, - CORBA::Boolean CreatePolyedrs) +SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, + CORBA::Long SecondNodeIDOnFreeBorder, + CORBA::Long LastNodeIDOnFreeBorder, + CORBA::Long FirstNodeIDOnSide, + CORBA::Long LastNodeIDOnSide, + CORBA::Boolean CreatePolygons, + CORBA::Boolean CreatePolyedrs) { SMESHDS_Mesh* aMesh = GetMeshDS(); @@ -1674,15 +1591,14 @@ SMESH::SMESH_MeshEditor::Sew_Error return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES; // Update Python script - TCollection_AsciiString str ("error = mesh_editor.SewBorderToSide( "); - str += TCollection_AsciiString( (int) FirstNodeIDOnFreeBorder ) + ", "; - str += TCollection_AsciiString( (int) SecondNodeIDOnFreeBorder ) + ", "; - str += TCollection_AsciiString( (int) LastNodeIDOnFreeBorder ) + ", "; - str += TCollection_AsciiString( (int) FirstNodeIDOnSide ) + ", "; - str += TCollection_AsciiString( (int) LastNodeIDOnSide ) + ", "; - str += TCollection_AsciiString( CreatePolygons ) + ", "; - str += TCollection_AsciiString( CreatePolyedrs ) + ") "; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "error = " << this << ".SewBorderToSide( " + << FirstNodeIDOnFreeBorder << ", " + << SecondNodeIDOnFreeBorder << ", " + << LastNodeIDOnFreeBorder << ", " + << FirstNodeIDOnSide << ", " + << LastNodeIDOnSide << ", " + << CreatePolygons << ", " + << CreatePolyedrs << ") "; ::SMESH_MeshEditor anEditor( _myMesh ); return convError( anEditor.SewFreeBorder (aBorderFirstNode, @@ -1702,12 +1618,12 @@ SMESH::SMESH_MeshEditor::Sew_Error //======================================================================= SMESH::SMESH_MeshEditor::Sew_Error - SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements, - const SMESH::long_array& IDsOfSide2Elements, - CORBA::Long NodeID1OfSide1ToMerge, - CORBA::Long NodeID1OfSide2ToMerge, - CORBA::Long NodeID2OfSide1ToMerge, - CORBA::Long NodeID2OfSide2ToMerge) +SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements, + const SMESH::long_array& IDsOfSide2Elements, + CORBA::Long NodeID1OfSide1ToMerge, + CORBA::Long NodeID1OfSide2ToMerge, + CORBA::Long NodeID2OfSide1ToMerge, + CORBA::Long NodeID2OfSide2ToMerge) { SMESHDS_Mesh* aMesh = GetMeshDS(); @@ -1739,14 +1655,13 @@ SMESH::SMESH_MeshEditor::Sew_Error aSide2Elems.insert( elem ); } // Update Python script - TCollection_AsciiString str ("error = mesh_editor.SewSideElements( "); - SMESH_Gen_i::AddArray( str, IDsOfSide1Elements ) += ", "; - SMESH_Gen_i::AddArray( str, IDsOfSide2Elements ) += ", "; - str += TCollection_AsciiString( (int) NodeID1OfSide1ToMerge ) + ", "; - str += TCollection_AsciiString( (int) NodeID1OfSide2ToMerge ) + ", "; - str += TCollection_AsciiString( (int) NodeID2OfSide1ToMerge ) + ", "; - str += TCollection_AsciiString( (int) NodeID2OfSide2ToMerge ) + ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "error = " << this << ".SewSideElements( " + << IDsOfSide1Elements << ", " + << IDsOfSide2Elements << ", " + << NodeID1OfSide1ToMerge << ", " + << NodeID1OfSide2ToMerge << ", " + << NodeID2OfSide1ToMerge << ", " + << NodeID2OfSide2ToMerge << ")"; ::SMESH_MeshEditor anEditor( _myMesh ); return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems, diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 3fc5a38dd..d8445554f 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -31,6 +31,7 @@ #include "SMESH_MEDMesh_i.hxx" #include "SMESH_Group_i.hxx" #include "SMESH_Filter_i.hxx" +#include "SMESH_PythonDump.hxx" #include "Utils_CorbaException.hxx" #include "Utils_ExceptHandlers.hxx" @@ -68,6 +69,7 @@ static int MYDEBUG = 0; #endif using namespace std; +using SMESH::TPythonDump; int SMESH_Mesh_i::myIdGenerator = 0; @@ -344,12 +346,8 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubS if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); // Update Python script - TCollection_AsciiString aStr ("status = "); - SMESH_Gen_i::AddObject(aStr, _this()) += ".AddHypothesis("; - SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", "; - SMESH_Gen_i::AddObject(aStr, anHyp) += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << "status = " << _this() << ".AddHypothesis( " + << aSubShapeObject << ", " << anHyp << " )"; return ConvertHypothesisStatus(status); } @@ -416,12 +414,8 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aS aSubShapeObject, anHyp ); // Update Python script - TCollection_AsciiString aStr ("status = "); - SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveHypothesis("; - SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", "; - SMESH_Gen_i::AddObject(aStr, anHyp) += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << "status = " << _this() << ".RemoveHypothesis( " + << aSubShapeObject << ", " << anHyp << " )"; return ConvertHypothesisStatus(status); } @@ -537,14 +531,8 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap subMesh, aSubShapeObject, theName ); if ( !aSO->_is_nil()) { // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".GetSubMesh("; - SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", \""; - aStr += (char*)theName; - aStr += "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << aSO << " = " << _this() << ".GetSubMesh( " + << aSubShapeObject << ", '" << theName << "' )"; } } } @@ -581,12 +569,7 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh ) aStudy->NewBuilder()->RemoveObjectWithChildren( anSO ); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveSubMesh("; - aStr += anSO->GetID(); - aStr += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".RemoveSubMesh( " << anSO << " )"; } } @@ -598,29 +581,18 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh ) * ElementTypeString */ //============================================================================= +#define CASE2STRING(enum) case SMESH::enum: return "SMESH."#enum; inline TCollection_AsciiString ElementTypeString (SMESH::ElementType theElemType) { - TCollection_AsciiString aStr; switch (theElemType) { - case SMESH::ALL: - aStr = "SMESH.ALL"; - break; - case SMESH::NODE: - aStr = "SMESH.NODE"; - break; - case SMESH::EDGE: - aStr = "SMESH.EDGE"; - break; - case SMESH::FACE: - aStr = "SMESH.FACE"; - break; - case SMESH::VOLUME: - aStr = "SMESH.VOLUME"; - break; - default: - break; + CASE2STRING( ALL ); + CASE2STRING( NODE ); + CASE2STRING( EDGE ); + CASE2STRING( FACE ); + CASE2STRING( VOLUME ); + default:; } - return aStr; + return ""; } //============================================================================= @@ -643,15 +615,10 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType aNewGroup, GEOM::GEOM_Object::_nil(), theName); if ( !aSO->_is_nil()) { // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroup("; - aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << aSO << " = " << _this() << ".CreateGroup( " + << ElementTypeString(theElemType) << ", '" << theName << "' )"; } } - return aNewGroup._retn(); } @@ -679,13 +646,9 @@ SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementTy aNewGroup, theGeomObj, theName); if ( !aSO->_is_nil()) { // Update Python script - TCollection_AsciiString aStr (aSO->GetID()); - aStr += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroupFromGEOM("; - aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\", "; - SMESH_Gen_i::AddObject(aStr, theGeomObj) += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << aSO << " = " << _this() << ".CreateGroupFromGEOM(" + << ElementTypeString(theElemType) << ", '" << theName << "', " + << theGeomObj << " )"; } } } @@ -716,12 +679,7 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup ) if ( !aGroupSO->_is_nil() ) { // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveGroup("; - aStr += aGroupSO->GetID(); - aStr += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".RemoveGroup( " << aGroupSO << " )"; // Remove group's SObject aStudy->NewBuilder()->RemoveObject( aGroupSO ); @@ -752,11 +710,7 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor(); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveGroupWithContents("; - SMESH_Gen_i::AddObject(aStr, theGroup) += ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".RemoveGroupWithContents( " << theGroup << " )"; // Remove contents if ( aGroup->GetType() == SMESH::NODE ) @@ -821,14 +775,9 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".UnionGroups("; - SMESH_Gen_i::AddObject(aStr, theGroup1) += ", "; - SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \""; - aStr += TCollection_AsciiString((char*)theName) + "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << aResGrp << " = " << _this() << ".UnionGroups( " + << theGroup1 << ", " << theGroup2 << ", '" + << theName << "' )"; return aResGrp._retn(); } @@ -886,14 +835,8 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".IntersectGroups("; - SMESH_Gen_i::AddObject(aStr, theGroup1) += ", "; - SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \""; - aStr += TCollection_AsciiString((char*)theName) + "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << aResGrp << " = " << _this() << ".IntersectGroups( " + << theGroup1 << ", " << theGroup2 << ", '" << theName << "')"; return aResGrp._retn(); } @@ -946,14 +889,9 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr _gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; - SMESH_Gen_i::AddObject(aStr, _this()) += ".CutGroups("; - SMESH_Gen_i::AddObject(aStr, theGroup1) += ", "; - SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \""; - aStr += TCollection_AsciiString((char*)theName) + "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << aResGrp << " = " << _this() << ".CutGroups( " + << theGroup1 << ", " << theGroup2 << ", '" + << theName << "' )"; return aResGrp._retn(); } @@ -1213,15 +1151,13 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl) SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor() { - // Update Python script - TCollection_AsciiString aStr ("mesh_editor = "); - SMESH_Gen_i::AddObject(aStr, _this()) += ".GetMeshEditor()"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); - // Create MeshEditor SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl ); SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this(); + + // Update Python script + TPythonDump() << aMeshEditor << " = " << _this() << ".GetMeshEditor()"; + return aMesh._retn(); } @@ -1293,23 +1229,8 @@ void SMESH_Mesh_i::ExportToMED (const char* file, Unexpect aCatch(SALOME_SalomeException); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportToMED(\""; - aStr += TCollection_AsciiString((char*)file) + "\", "; - aStr += TCollection_AsciiString((int)auto_groups) + ", "; - switch (theVersion) { - case SMESH::MED_V2_1: - aStr += "SMESH.MED_V2_1)"; - break; - case SMESH::MED_V2_2: - aStr += "SMESH.MED_V2_2)"; - break; - default: - aStr += TCollection_AsciiString(theVersion) + ")"; - break; - } - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".ExportToMED( '" + << file << "', " << auto_groups << ", " << theVersion << " )"; // Perform Export PrepareForWriting(file); @@ -1357,11 +1278,7 @@ void SMESH_Mesh_i::ExportDAT (const char *file) Unexpect aCatch(SALOME_SalomeException); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportDAT(\""; - aStr += TCollection_AsciiString((char*)file) + "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".ExportDAT( '" << file << "' )"; // Perform Export PrepareForWriting(file); @@ -1374,11 +1291,7 @@ void SMESH_Mesh_i::ExportUNV (const char *file) Unexpect aCatch(SALOME_SalomeException); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportUNV(\""; - aStr += TCollection_AsciiString((char*)file) + "\")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".ExportUNV( '" << file << "' )"; // Perform Export PrepareForWriting(file); @@ -1391,12 +1304,7 @@ void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii) Unexpect aCatch(SALOME_SalomeException); // Update Python script - TCollection_AsciiString aStr; - SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportSTL(\""; - aStr += TCollection_AsciiString((char*)file) + "\", "; - aStr += TCollection_AsciiString((int)isascii) + ")"; - - SMESH_Gen_i::AddToCurrentPyScript(aStr); + TPythonDump() << _this() << ".ExportSTL( '" << file << "', " << isascii << " )"; // Perform Export PrepareForWriting(file); diff --git a/src/SMESH_I/SMESH_Pattern_i.cxx b/src/SMESH_I/SMESH_Pattern_i.cxx index 887dfe51f..f48a6fab3 100644 --- a/src/SMESH_I/SMESH_Pattern_i.cxx +++ b/src/SMESH_I/SMESH_Pattern_i.cxx @@ -32,6 +32,7 @@ #include "SMESH_Gen_i.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_Mesh_i.hxx" +#include "SMESH_PythonDump.hxx" #include "SMDS_MeshFace.hxx" #include "SMDS_MeshVolume.hxx" @@ -42,6 +43,8 @@ #include #include +using SMESH::TPythonDump; + //======================================================================= //function : dumpErrorCode //purpose : @@ -49,11 +52,8 @@ static void addErrorCode(const char* thePyCommand) { - SMESH_Gen_i::AddToCurrentPyScript("if (isDone != 1):"); - TCollection_AsciiString str ("\tprint \""); - str += (char*) thePyCommand; - str += ":\", pattern.GetErrorCode()"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "if (isDone != 1):"; + TPythonDump() << "\tprint '" << thePyCommand << " :', pattern.GetErrorCode()"; } //============================================================================= @@ -67,7 +67,7 @@ static void addErrorCode(const char* thePyCommand) SMESH::SMESH_Pattern_ptr SMESH_Gen_i::GetPattern() { // Update Python script - SMESH_Gen_i::AddToCurrentPyScript( "pattern = smesh.GetPattern()" ); + TPythonDump() << "pattern = " << this << ".GetPattern()"; SMESH_Pattern_i* i = new SMESH_Pattern_i( this ); SMESH::SMESH_Pattern_var anObj = i->_this(); @@ -107,9 +107,7 @@ SMESH_Pattern_i::SMESH_Pattern_i( SMESH_Gen_i* theGen_i ): CORBA::Boolean SMESH_Pattern_i::LoadFromFile(const char* theFileContents) { // Update Python script - TCollection_AsciiString str( "isDone = pattern.LoadFromFile(" ); - str += TCollection_AsciiString( (char*) theFileContents ) + ")"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = pattern.LoadFromFile(" << theFileContents << ")"; addErrorCode( "LoadFromFile" ); return myPattern.Load( theFileContents ); @@ -136,11 +134,8 @@ CORBA::Boolean SMESH_Pattern_i::LoadFromFace(SMESH::SMESH_Mesh_ptr theMesh, return false; // Update Python script - TCollection_AsciiString str( "isDone = pattern.LoadFromFace( " ); - SMESH_Gen_i::AddObject( str, theMesh ) += ", "; - SMESH_Gen_i::AddObject( str, theFace ) += ", "; - str += TCollection_AsciiString( theProject ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = pattern.LoadFromFace( " << theMesh << ", " + << theFace << ", " << theProject << " )"; addErrorCode( "LoadFromFace" ); return myPattern.Load( aMesh, TopoDS::Face( aFace ), theProject ); @@ -170,10 +165,7 @@ CORBA::Boolean SMESH_Pattern_i::LoadFrom3DBlock(SMESH::SMESH_Mesh_ptr theMesh, return false; // Update Python script - TCollection_AsciiString str( "isDone = pattern.LoadFrom3DBlock( " ); - SMESH_Gen_i::AddObject( str, theMesh ) += ", "; - SMESH_Gen_i::AddObject( str, theBlock ) += " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = pattern.LoadFrom3DBlock( " << theMesh << ", " << theBlock << " )"; addErrorCode( "LoadFrom3DBlock" ); return myPattern.Load( aMesh, TopoDS::Shell( exp.Current() )); @@ -209,11 +201,8 @@ SMESH::point_array* SMESH_Pattern_i::ApplyToFace(GEOM::GEOM_Object_ptr theFace, } // Update Python script - TCollection_AsciiString str( "pattern.ApplyToFace( " ); - SMESH_Gen_i::AddObject( str, theFace ) += ", "; - SMESH_Gen_i::AddObject( str, theVertexOnKeyPoint1 ) += ", "; - str += TCollection_AsciiString( theReverse ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "pattern.ApplyToFace( " << theFace << ", " + << theVertexOnKeyPoint1 << ", " << theReverse << " )"; return points._retn(); } @@ -252,11 +241,8 @@ SMESH::point_array* SMESH_Pattern_i::ApplyTo3DBlock(GEOM::GEOM_Object_ptr theBlo } // Update Python script - TCollection_AsciiString str( "pattern.ApplyTo3DBlock( " ); - SMESH_Gen_i::AddObject( str, theBlock ) += ", "; - SMESH_Gen_i::AddObject( str, theVertex000 ) += ", "; - SMESH_Gen_i::AddObject( str, theVertex001 ) += " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "pattern.ApplyTo3DBlock( " << theBlock << ", " + << theVertex000 << ", " << theVertex001 << " )"; return points._retn(); } @@ -299,12 +285,9 @@ SMESH::point_array* } // Update Python script - TCollection_AsciiString str( "pattern.ApplyToMeshFaces( " ); - SMESH_Gen_i::AddObject( str, theMesh ) += ", "; - SMESH_Gen_i::AddArray( str, theFacesIDs ) += ", "; - str += TCollection_AsciiString( (int)theNodeIndexOnKeyPoint1 ) + ", "; - str += TCollection_AsciiString( theReverse ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "pattern.ApplyToMeshFaces( " << theMesh << ", " + << theFacesIDs << ", " + << theNodeIndexOnKeyPoint1 << ", " << theReverse << " )"; return points._retn(); } @@ -347,12 +330,9 @@ SMESH::point_array* } // Update Python script - TCollection_AsciiString str( "pattern.ApplyToHexahedrons( " ); - SMESH_Gen_i::AddObject( str, theMesh ) += ", "; - SMESH_Gen_i::AddArray( str, theVolumesIDs ) += ", "; - str += TCollection_AsciiString( (int)theNode000Index ) + ", "; - str += TCollection_AsciiString( (int)theNode001Index ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "pattern.ApplyToHexahedrons( " << theMesh << ", " + << theVolumesIDs << ", " + << theNode000Index << ", " << theNode001Index << " )"; return points._retn(); } @@ -371,11 +351,8 @@ CORBA::Boolean SMESH_Pattern_i::MakeMesh (SMESH::SMESH_Mesh_ptr theMesh, return false; // Update Python script - TCollection_AsciiString str( "isDone = pattern.MakeMesh( " ); - SMESH_Gen_i::AddObject( str, theMesh ) += ", "; - str += TCollection_AsciiString( CreatePolygons ) + ", "; - str += TCollection_AsciiString( CreatePolyedrs ) + " )"; - SMESH_Gen_i::AddToCurrentPyScript( str ); + TPythonDump() << "isDone = pattern.MakeMesh( " << theMesh << ", " + << CreatePolygons << ", " << CreatePolyedrs << " )"; addErrorCode( "MakeMesh" ); return myPattern.MakeMesh( aMesh, CreatePolygons, CreatePolyedrs ); diff --git a/src/SMESH_I/SMESH_PythonDump.hxx b/src/SMESH_I/SMESH_PythonDump.hxx index 86133cf8a..f3a011335 100644 --- a/src/SMESH_I/SMESH_PythonDump.hxx +++ b/src/SMESH_I/SMESH_PythonDump.hxx @@ -22,9 +22,14 @@ #include #include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SALOMEDS) #include +class SMESH_Gen_i; +class SMESH_MeshEditor_i; +class TCollection_AsciiString; + namespace SMESH { class FilterLibrary_i; @@ -64,6 +69,12 @@ namespace SMESH TPythonDump& operator<<(const SMESH::long_array& theArg); + TPythonDump& + operator<<(const SMESH::double_array& theArg); + + TPythonDump& + operator<<(SALOMEDS::SObject_ptr theArg); + TPythonDump& operator<<(CORBA::Object_ptr theArg); @@ -78,6 +89,27 @@ namespace SMESH TPythonDump& operator<<(SMESH::Functor_i* theArg); + + TPythonDump& + operator<<(SMESH_Gen_i* theArg); + + TPythonDump& + operator<<(SMESH_MeshEditor_i* theArg); + + TPythonDump& + operator<<(SMESH::MED_VERSION theArg); + + TPythonDump& + operator<<(const SMESH::AxisStruct & theAxis); + + TPythonDump& + operator<<(const SMESH::DirStruct & theDir); + + TPythonDump& + operator<<(const TCollection_AsciiString & theArg); + + static char* SMESHGenName() { return "smeshgen"; } + static char* MeshEditorName() { return "mesh_editor"; } }; } -- 2.39.2