PAL10494 (SMESH python dump uses idl interface). Python dump converted to smesh.py API, usage of TPythonDump tool

This commit is contained in:
eap 2005-12-15 08:34:25 +00:00
parent 5a76185f82
commit 95dab66d27
8 changed files with 550 additions and 770 deletions

View File

@ -26,6 +26,7 @@
#include "SMESH_PythonDump.hxx" #include "SMESH_PythonDump.hxx"
#include "SMESH_Gen_i.hxx" #include "SMESH_Gen_i.hxx"
#include "SMESH_Filter_i.hxx" #include "SMESH_Filter_i.hxx"
#include "SMESH_2smeshpy.hxx"
#include <TColStd_HSequenceOfInteger.hxx> #include <TColStd_HSequenceOfInteger.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
@ -105,7 +106,8 @@ namespace SMESH
TPythonDump& TPythonDump&
TPythonDump:: TPythonDump::
operator<<(const char* theArg){ operator<<(const char* theArg){
myStream<<theArg; if ( theArg )
myStream<<theArg;
return *this; return *this;
} }
@ -115,60 +117,69 @@ namespace SMESH
{ {
myStream<<"SMESH."; myStream<<"SMESH.";
switch(theArg){ switch(theArg){
case ALL: case ALL: myStream<<"ALL";break;
myStream<<"ALL"; case NODE: myStream<<"NODE";break;
break; case EDGE: myStream<<"EDGE";break;
case NODE: case FACE: myStream<<"FACE";break;
myStream<<"NODE"; case VOLUME:myStream<<"VOLUME";break;
break;
case EDGE:
myStream<<"EDGE";
break;
case FACE:
myStream<<"FACE";
break;
case VOLUME:
myStream<<"VOLUME";
break;
} }
return *this; return *this;
} }
template<class TArray>
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)
{
DumpArray( theArg, myStream );
return *this;
}
TPythonDump&
TPythonDump::operator<<(const SMESH::double_array& theArg)
{
DumpArray( theArg, myStream );
return *this;
}
TPythonDump& TPythonDump&
TPythonDump:: TPythonDump::
operator<<(const SMESH::long_array& theArg) operator<<(SALOMEDS::SObject_ptr aSObject)
{ {
myStream<<"[ "; if ( !aSObject->_is_nil() )
CORBA::Long i = 1, iEnd = theArg.length(); myStream << aSObject->GetID();
for(; i <= iEnd; i++) { else
myStream<<theArg[i-1]; myStream << NotPublishedObjectName();
if(i < iEnd)
myStream<< ", ";
}
myStream<<" ]";
return *this; return *this;
} }
TPythonDump& TPythonDump&
TPythonDump:: TPythonDump::
operator<<(CORBA::Object_ptr theArg) operator<<(CORBA::Object_ptr theArg)
{ {
TCollection_AsciiString aString("None");
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg); SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
if(!aSObject->_is_nil()){ if(!aSObject->_is_nil()) {
aString = aSObject->GetID(); myStream << aSObject->GetID();
}else if(!CORBA::is_nil(theArg)){ } else if ( !CORBA::is_nil(theArg)) {
aString = "smeshObj_";
if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object if ( aSMESHGen->CanPublishInStudy( theArg )) // not published SMESH object
aString += (int) theArg; myStream << "smeshObj_" << (int) theArg;
else else
aString = NotPublishedObjectName(); myStream << NotPublishedObjectName();
} }
myStream<<aString.ToCString(); else
myStream << "None";
return *this; return *this;
} }
@ -200,88 +211,86 @@ namespace SMESH
TPythonDump:: TPythonDump::
operator<<(SMESH::Functor_i* theArg) operator<<(SMESH::Functor_i* theArg)
{ {
FunctorType aFunctorType = theArg->GetFunctorType(); if ( theArg ) {
switch(aFunctorType){ FunctorType aFunctorType = theArg->GetFunctorType();
case FT_AspectRatio: switch(aFunctorType){
myStream<<"anAspectRatio"; case FT_AspectRatio: myStream<< "anAspectRatio"; break;
break; case FT_AspectRatio3D: myStream<< "anAspectRatio3D"; break;
case FT_AspectRatio3D: case FT_Warping: myStream<< "aWarping"; break;
myStream<<"anAspectRatio3D"; case FT_MinimumAngle: myStream<< "aMinimumAngle"; break;
break; case FT_Taper: myStream<< "aTaper"; break;
case FT_Warping: case FT_Skew: myStream<< "aSkew"; break;
myStream<<"aWarping"; case FT_Area: myStream<< "aArea"; break;
break; case FT_FreeBorders: myStream<< "aFreeBorders"; break;
case FT_MinimumAngle: case FT_FreeEdges: myStream<< "aFreeEdges"; break;
myStream<<"aMinimumAngle"; case FT_MultiConnection: myStream<< "aMultiConnection"; break;
break; case FT_MultiConnection2D:myStream<< "aMultiConnection2D";break;
case FT_Taper: case FT_Length: myStream<< "aLength"; break;
myStream<<"aTaper"; case FT_Length2D: myStream<< "aLength"; break;
break; case FT_BelongToGeom: myStream<< "aBelongToGeom"; break;
case FT_Skew: case FT_BelongToPlane: myStream<< "aBelongToPlane"; break;
myStream<<"aSkew"; case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
break; case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break;
case FT_Area: case FT_RangeOfIds: myStream<< "aRangeOfIds"; break;
myStream<<"aArea"; case FT_BadOrientedVolume:myStream<< "aBadOrientedVolume";break;
break; case FT_LessThan: myStream<< "aLessThan"; break;
case FT_FreeBorders: case FT_MoreThan: myStream<< "aMoreThan"; break;
myStream<<"aFreeBorders"; case FT_EqualTo: myStream<< "anEqualTo"; break;
break; case FT_LogicalNOT: myStream<< "aLogicalNOT"; break;
case FT_FreeEdges: case FT_LogicalAND: myStream<< "aLogicalAND"; break;
myStream<<"aFreeEdges"; case FT_LogicalOR: myStream<< "aLogicalOR"; break;
break; case FT_Undefined: myStream<< "anUndefined"; break;
case FT_MultiConnection: }
myStream<<"aMultiConnection"; myStream<<theArg;
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<<theArg; return *this;
}
TPythonDump& TPythonDump:: operator<<(SMESH_Gen_i* theArg)
{
myStream << SMESHGenName(); return *this;
}
TPythonDump& TPythonDump::operator<<(SMESH_MeshEditor_i* theArg)
{
myStream << MeshEditorName(); return *this;
}
TPythonDump& TPythonDump::operator<<(const TCollection_AsciiString & theStr)
{
myStream << theStr; return *this;
}
TPythonDump& TPythonDump::operator<<(SMESH::MED_VERSION theVersion)
{
switch (theVersion) {
case SMESH::MED_V2_1: myStream << "SMESH.MED_V2_1"; break;
case SMESH::MED_V2_2: myStream << "SMESH.MED_V2_2"; break;
default: myStream << theVersion;
}
return *this;
}
TPythonDump& TPythonDump::operator<<(const SMESH::AxisStruct & theAxis)
{
myStream << "SMESH.AxisStruct( "
<< theAxis.x << ", "
<< theAxis.y << ", "
<< theAxis.z << ", "
<< theAxis.vx << ", "
<< theAxis.vy << ", "
<< theAxis.vz << " )";
return *this;
}
TPythonDump& TPythonDump::operator<<(const SMESH::DirStruct & theDir)
{
const SMESH::PointStruct & P = theDir.PS;
myStream << "SMESH.DirStruct( SMESH.PointStruct ( "
<< P.x << ", "
<< P.y << ", "
<< P.z << " ))";
return *this; return *this;
} }
} }
@ -305,7 +314,7 @@ Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
// Map study entries to object names // Map study entries to object names
Resource_DataMapOfAsciiStringAsciiString aMap; Resource_DataMapOfAsciiStringAsciiString aMap;
Resource_DataMapOfAsciiStringAsciiString aMapNames; Resource_DataMapOfAsciiStringAsciiString aMapNames;
TCollection_AsciiString s ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_"); //TCollection_AsciiString s ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_");
SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO); SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
for (Itr->InitEx(true); Itr->More(); Itr->Next()) { 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); TCollection_AsciiString aSavedTrace (oldValue);
// Add trace of API methods calls and replace study entries by names // 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 = TCollection_AsciiString aScript =
"### This file is generated by SALOME automatically by dump python functionality of SMESH component\n\n"; "### This file is generated by SALOME automatically by dump python functionality of SMESH component\n\n";
aScript += DumpPython_impl(aStudy->StudyId(), aMap, aMapNames, 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 //function : SavePython
//purpose : //purpose :
@ -470,19 +437,20 @@ Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theStri
while(i < aLen) { while(i < aLen) {
int c = (int)arr[i]; int c = (int)arr[i];
j = i+1; j = i+1;
if(c >= 48 && c <= 57) { //Is digit? if ( isdigit( c )) { //Is digit?
isFound = Standard_False; 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++]; c = (int)arr[j++];
if(c == 58) isFound = Standard_True; if(c == ':') isFound = Standard_True;
} }
if (isFound) { if (isFound) {
int prev = (i < 1) ? 0 : (int)arr[i - 1]; 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 '"'. // 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(i+1); // +1 because AsciiString starts from 1
aSeq->Append(j-1); aSeq->Append(j-1);
} }
@ -508,28 +476,57 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
bool& aValidScript, bool& aValidScript,
const TCollection_AsciiString& theSavedTrace) 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; TCollection_AsciiString aScript;
aScript = "def RebuildData(theStudy):"; aScript = "def RebuildData(theStudy):\n\t";
aScript += "\n\tsmesh = salome.lcc.FindOrLoadComponent(\"FactoryServer\", \"SMESH\")"; aScript += helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()\n\t";
aScript += "\n\taFilterManager = smesh.CreateFilterManager()";
if ( isPublished ) if ( isPublished )
aScript += "\n\tsmesh.SetCurrentStudy(theStudy)"; aScript += aSMESHGen + ".SetCurrentStudy(theStudy)";
else else
aScript += "\n\tsmesh.SetCurrentStudy(None)"; aScript += aSMESHGen + ".SetCurrentStudy(None)";
// Dump trace of restored study // Dump trace of restored study
if (theSavedTrace.Length() > 0) { if (theSavedTrace.Length() > 0) {
aScript += "\n"; // For the convertion of IDL API calls -> smesh.py API, "smesh" standing for SMESH_Gen
aScript += theSavedTrace; // 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 // Dump trace of API methods calls
TCollection_AsciiString aNewLines = GetNewPythonLines(theStudyID); TCollection_AsciiString aNewLines = GetNewPythonLines(theStudyID);
if (aNewLines.Length() > 0) { if (aNewLines.Length() > 0) {
aScript += "\n"; aScript += helper + "\n" + aNewLines;
aScript += 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 // Find entries to be replaced by names
Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript); Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
Standard_Integer aLen = aSeq->Length(); Standard_Integer aLen = aSeq->Length();
@ -566,14 +563,18 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
aName = theObjectNames.Find(anEntry); aName = theObjectNames.Find(anEntry);
// check validity of aName // check validity of aName
bool isValidName = true; bool isValidName = true;
if ( aName.IsIntegerValue() ) { // aName must not start with a digit int p=1; // replace not allowed chars with underscore
aName.Insert( 1, 'a' ); 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; isValidName = false;
} }
int p, p2=1; // replace not allowed chars if ( aName.IsIntegerValue() ) { // aName must not start with a digit
while ((p = aName.FirstLocationNotInSet(allowedChars, p2, aName.Length()))) { aName.Insert( 1, 'a' );
aName.SetValue(p, '_');
p2=p;
isValidName = false; isValidName = false;
} }
if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) { if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
@ -592,7 +593,7 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
} else { } else {
// Removed Object // Removed Object
do { do {
aName = aBaseName + TCollection_AsciiString(++objectCounter); aName = aBaseName + (++objectCounter);
} while (theObjectNames.IsBound(aName)); } while (theObjectNames.IsBound(aName));
seqRemoved.Append(aName); seqRemoved.Append(aName);
mapRemoved.Bind(anEntry, "1"); mapRemoved.Bind(anEntry, "1");
@ -609,10 +610,12 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
} }
// set initial part of aSript // 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 ) 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" "sys.path.insert( 0, os.path.dirname(__file__) )\n"
"exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",__name__)+\" import *\")\n\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); anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength);
// Remove removed objects // 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++) { for (int ir = 1; ir <= seqRemoved.Length(); ir++) {
anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR("; anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
anUpdatedScript += seqRemoved.Value(ir); anUpdatedScript += seqRemoved.Value(ir);
@ -631,27 +637,31 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
} }
// Set object names // Set object names
anUpdatedScript += "\n\n\tisGUIMode = "; anUpdatedScript += "\n\t## set object names";
anUpdatedScript += isPublished; anUpdatedScript += helper + " \n\tisGUIMode = " + isPublished;
anUpdatedScript += "\n\tif isGUIMode:"; anUpdatedScript += "\n\tif isGUIMode and salome.sg.hasDesktop():";
anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")"; // anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")";
anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())"; // anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())";
anUpdatedScript += "\n"; // anUpdatedScript += "\n";
TCollection_AsciiString aGUIName; TCollection_AsciiString aGUIName;
Resource_DataMapOfAsciiStringAsciiString mapEntries; 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)); anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
aName = geom->GetDumpName( anEntry.ToCString() ); aName = geom->GetDumpName( anEntry.ToCString() );
if (aName.IsEmpty() && // Not a GEOM object if (aName.IsEmpty() && // Not a GEOM object
theNames.IsBound(anEntry) && theNames.IsBound(anEntry) &&
!mapEntries.IsBound(anEntry) && // Not yet processed !mapEntries.IsBound(anEntry) && // Not yet processed
!mapRemoved.IsBound(anEntry)) { // Was not removed !mapRemoved.IsBound(anEntry)) // Was not removed
{
aName = theObjectNames.Find(anEntry); aName = theObjectNames.Find(anEntry);
aGUIName = theNames.Find(anEntry); aGUIName = theNames.Find(anEntry);
mapEntries.Bind(anEntry, aName); mapEntries.Bind(anEntry, aName);
anUpdatedScript += "\n\t\tsmeshgui.SetName(salome.ObjectToID("; anUpdatedScript += helper + "\n\t\t" + aSmeshpy + ".SetName(" + aName;
anUpdatedScript += aName + "), \"" + aGUIName + "\")"; if ( anEntry2AccessorMethod.IsBound( anEntry ) )
anUpdatedScript += helper + "." + anEntry2AccessorMethod( anEntry );
anUpdatedScript += helper + ", '" + aGUIName + "')";
} }
} }
anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)"; anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)";

View File

@ -59,6 +59,7 @@
#include "SMESH_Hypothesis_i.hxx" #include "SMESH_Hypothesis_i.hxx"
#include "SMESH_Algo_i.hxx" #include "SMESH_Algo_i.hxx"
#include "SMESH_Group_i.hxx" #include "SMESH_Group_i.hxx"
#include "SMESH_PythonDump.hxx"
#include "SMESHDS_Document.hxx" #include "SMESHDS_Document.hxx"
#include "SMESHDS_Group.hxx" #include "SMESHDS_Group.hxx"
@ -89,6 +90,7 @@
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
using namespace std; using namespace std;
using SMESH::TPythonDump;
#define NUM_TMP_FILES 2 #define NUM_TMP_FILES 2
@ -411,7 +413,7 @@ GEOM_Client* SMESH_Gen_i::GetShapeReader()
void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy ) void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy )
{ {
//if(MYDEBUG) //if(MYDEBUG)
MESSAGE( "SMESH_Gen_i::SetCurrentStudy" ); //MESSAGE( "SMESH_Gen_i::SetCurrentStudy" );
myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy ); myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy );
// create study context, if it doesn't exist and set current study // create study context, if it doesn't exist and set current study
int studyId = GetCurrentStudyID(); 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 ); SALOMEDS::SObject_var aSO = PublishHypothesis( myCurrentStudy, hyp );
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TCollection_AsciiString aStr (aSO->GetID()); TPythonDump() << aSO << " = " << this << ".CreateHypothesis('"
aStr += " = smesh.CreateHypothesis(\""; << theHypName << "', '" << theLibName << "')";
aStr += Standard_CString(theHypName);
aStr += "\", \"";
aStr += Standard_CString(theLibName);
aStr += "\")";
AddToCurrentPyScript(aStr);
} }
} }
@ -522,11 +518,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TCollection_AsciiString aStr (aSO->GetID()); TPythonDump() << aSO << " = " << this << ".CreateMesh(" << theShapeObject << ")";
aStr += " = smesh.CreateMesh(";
SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")";
AddToCurrentPyScript(aStr);
} }
} }
@ -557,12 +549,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TCollection_AsciiString aStr (aSO->GetID()); TPythonDump() << aSO << " = smeshgen.CreateMeshesFromUNV('" << theFileName << "')";
aStr += " = smesh.CreateMeshesFromUNV(\"";
aStr += Standard_CString(theFileName);
aStr += "\")";
AddToCurrentPyScript(aStr);
} }
} }
@ -588,7 +575,9 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" ); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
// Python Dump // Python Dump
TCollection_AsciiString aStr ("(["); TPythonDump aPythonDump;
aPythonDump << "([";
//TCollection_AsciiString aStr ("([");
// Retrieve mesh names from the file // Retrieve mesh names from the file
DriverMED_R_SMESHDS_Mesh myReader; 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 // Iterate through all meshes and create mesh objects
for ( list<string>::iterator it = aNames.begin(); it != aNames.end(); it++ ) { for ( list<string>::iterator it = aNames.begin(); it != aNames.end(); it++ ) {
// Python Dump // Python Dump
if (i > 0) aStr += ", "; //if (i > 0) aStr += ", ";
if (i > 0) aPythonDump << ", ";
// create mesh // create mesh
SMESH::SMESH_Mesh_var mesh = createMesh(); 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() ); aSO = PublishMesh( myCurrentStudy, mesh.in(), (*it).c_str() );
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Python Dump // Python Dump
aStr += aSO->GetID(); aPythonDump << aSO;
//aStr += aSO->GetID();
} else { } else {
// Python Dump // Python Dump
aStr += "mesh_"; aPythonDump << "mesh_" << i;
aStr += TCollection_AsciiString(i); // aStr += "mesh_";
// aStr += TCollection_AsciiString(i);
} }
// Read mesh data (groups are published automatically by ImportMEDFile()) // 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 // Update Python script
aStr += "], status) = smesh.CreateMeshesFromMED(\""; aPythonDump << "], status) = " << this << ".CreateMeshesFromMED('" << theFileName << "')";
aStr += Standard_CString(theFileName);
aStr += "\")";
AddToCurrentPyScript(aStr);
return aResult._retn(); 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() ); ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
TCollection_AsciiString aStr (aSO->GetID()); TPythonDump() << aSO << " = " << this << ".CreateMeshesFromSTL('" << theFileName << "')";
aStr += " = smesh.CreateMeshesFromSTL(\"";
aStr += Standard_CString(theFileName);
aStr += "\")";
AddToCurrentPyScript(aStr);
} }
} }
@ -922,15 +905,9 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
SALOME::BAD_PARAM ); SALOME::BAD_PARAM );
// Update Python script // Update Python script
TCollection_AsciiString aStr ("isDone = smesh.Compute("); TPythonDump() << "isDone = " << this << ".Compute( "
SMESH_Gen_i::AddObject(aStr, theMesh) += ", "; << theMesh << ", " << theShapeObject << ")";
SMESH_Gen_i::AddObject(aStr, theShapeObject) += ")"; TPythonDump() << "if not isDone: print 'Mesh " << theMesh << " : computation failed'";
AddToCurrentPyScript(aStr);
aStr = "if isDone == 0: print \"Mesh ";
SMESH_Gen_i::AddObject(aStr, theMesh) += " computation failed\"";
AddToCurrentPyScript(aStr);
try { try {
// get mesh servant // get mesh servant

View File

@ -295,8 +295,6 @@ public:
void RemoveLastFromPythonScript (int theStudyID); void RemoveLastFromPythonScript (int theStudyID);
static void AddToCurrentPyScript (const TCollection_AsciiString& theString);
void SavePython (SALOMEDS::Study_ptr theStudy); void SavePython (SALOMEDS::Study_ptr theStudy);
TCollection_AsciiString DumpPython_impl (int theStudyID, TCollection_AsciiString DumpPython_impl (int theStudyID,
@ -310,28 +308,6 @@ public:
void CleanPythonTrace (int theStudyID); 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 <class _array>
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 // Internal methods

View File

@ -120,11 +120,7 @@ SMESHDS_GroupBase* SMESH_GroupBase_i::GetGroupDS() const
void SMESH_GroupBase_i::SetName( const char* theName ) void SMESH_GroupBase_i::SetName( const char* theName )
{ {
// Update Python script // Update Python script
TCollection_AsciiString aStr, aStrName ((char*)theName); TPythonDump() << _this() << ".SetName( '" << theName << "' )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".SetName(\"";
aStr += aStrName + "\")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Perform renaming // Perform renaming
::SMESH_Group* aGroup = GetSmeshGroup(); ::SMESH_Group* aGroup = GetSmeshGroup();
@ -219,10 +215,7 @@ CORBA::Boolean SMESH_GroupBase_i::IsEmpty()
void SMESH_Group_i::Clear() void SMESH_Group_i::Clear()
{ {
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << _this() << ".Clear()";
SMESH_Gen_i::AddObject(aStr, _this()) += ".Clear()";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Clear the group // Clear the group
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() ); SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( 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 ) CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs )
{ {
// Update Python script // Update Python script
TCollection_AsciiString aStr ("nbAdd = "); TPythonDump() << "nbAdd = " << _this() << ".Add( " << theIDs << " )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".Add(";
SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Add elements to the group // Add elements to the group
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() ); SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( 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 ) CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
{ {
// Update Python script // Update Python script
TCollection_AsciiString aStr ("nbDel = "); TPythonDump() << "nbDel = " << _this() << ".Remove( " << theIDs << " )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove(";
SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Remove elements from the group // Remove elements from the group
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() ); SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );

View File

@ -36,6 +36,7 @@
#include "SMESH_Gen_i.hxx" #include "SMESH_Gen_i.hxx"
#include "SMESH_Filter_i.hxx" #include "SMESH_Filter_i.hxx"
#include "SMESH_PythonDump.hxx"
#include "utilities.h" #include "utilities.h"
@ -49,24 +50,7 @@ typedef map<const SMDS_MeshElement*,
list<const SMDS_MeshElement*> > TElemOfElemListMap; list<const SMDS_MeshElement*> > TElemOfElemListMap;
using namespace std; using namespace std;
using SMESH::TPythonDump;
//=======================================================================
//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;
}
//============================================================================= //=============================================================================
/*! /*!
@ -95,11 +79,9 @@ CORBA::Boolean
IdList.push_back( IDsOfElements[i] ); IdList.push_back( IDsOfElements[i] );
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.RemoveElements("); TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )";
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"RemoveElements: \", isDone" ); TPythonDump() << "print 'RemoveElements: ', isDone";
#endif #endif
// Remove Elements // Remove Elements
return anEditor.Remove( IdList, false ); return anEditor.Remove( IdList, false );
@ -111,8 +93,7 @@ CORBA::Boolean
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH:: CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNodes)
long_array & IDsOfNodes)
{ {
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
list< int > IdList; list< int > IdList;
@ -120,11 +101,9 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::
IdList.push_back( IDsOfNodes[i] ); IdList.push_back( IDsOfNodes[i] );
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.RemoveNodes("); TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )";
SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"RemoveNodes: \", isDone" ); TPythonDump() << "print 'RemoveNodes: ', isDone";
#endif #endif
return anEditor.Remove( IdList, true ); 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)); GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2));
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.AddEdge(["); TPythonDump() << "isDone = " << this << ".AddEdge([ "
str += TCollection_AsciiString((int) index1) + ", "; << index1 << ", " << index2 <<" ])";
str += TCollection_AsciiString((int) index2) + " ])";
SMESH_Gen_i::AddToCurrentPyScript( str );
} }
return true; return true;
} }
@ -166,11 +143,8 @@ CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
GetMeshDS()->AddNode(x, y, z); GetMeshDS()->AddNode(x, y, z);
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.AddNode("); TPythonDump() << "isDone = " << this << ".AddNode( "
str += TCollection_AsciiString( x ) + ", "; << x << ", " << y << ", " << z << " )";
str += TCollection_AsciiString( y ) + ", ";
str += TCollection_AsciiString( z ) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
return true; return true;
} }
@ -207,11 +181,9 @@ CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
} }
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.AddFace("); TPythonDump() << "isDone = " << this << ".AddFace( " << IDsOfNodes << " )";
SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"AddFace: \", isDone" ); TPythonDump() << "print 'AddFace: ', isDone";
#endif #endif
return true; 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:: CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes)
long_array & IDsOfNodes)
{ {
int NbNodes = IDsOfNodes.length(); int NbNodes = IDsOfNodes.length();
vector< const SMDS_MeshNode*> n(NbNodes); 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; case 8:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
} }
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.AddVolume("); TPythonDump() << "isDone = " << this << ".AddVolume( " << IDsOfNodes << " )";
SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"AddVolume: \", isDone" ); TPythonDump() << "print 'AddVolume: ', isDone";
#endif #endif
return true; return true;
@ -271,12 +240,10 @@ CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolume
GetMeshDS()->AddPolyhedralVolume(n, q); GetMeshDS()->AddPolyhedralVolume(n, q);
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.AddPolyhedralVolume("); TPythonDump() << "isDone = " << this << ".AddPolyhedralVolume( "
SMESH_Gen_i::AddArray( str, IDsOfNodes ) += ", "; << IDsOfNodes << ", " << Quantities << " )";
SMESH_Gen_i::AddArray( str, Quantities ) += ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"AddPolyhedralVolume: \", isDone" ); TPythonDump() << "print 'AddPolyhedralVolume: ', isDone";
#endif #endif
return true; return true;
@ -307,11 +274,10 @@ CORBA::Boolean SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces
GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities); GetMeshDS()->AddPolyhedralVolume(poly_nodes, quantities);
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.AddPolyhedralVolumeByFaces("); TPythonDump() << "isDone = " << this << ".AddPolyhedralVolumeByFaces( "
SMESH_Gen_i::AddArray( str, IdsOfFaces ) += ")"; << IdsOfFaces << " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"AddPolyhedralVolume: \", isDone" ); TPythonDump() << "print 'AddPolyhedralVolume: ', isDone";
#endif #endif
return true; return true;
@ -335,12 +301,8 @@ CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID,
GetMeshDS()->MoveNode(node, x, y, z); GetMeshDS()->MoveNode(node, x, y, z);
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.MoveNode("); TPythonDump() << "isDone = " << this << ".MoveNode( "
str += TCollection_AsciiString((Standard_Integer) NodeID) + ", "; << NodeID << ", " << x << ", " << y << ", " << z << " )";
str += TCollection_AsciiString((Standard_Real) x) + ", ";
str += TCollection_AsciiString((Standard_Real) y) + ", ";
str += TCollection_AsciiString((Standard_Real) z) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
return true; return true;
} }
@ -360,10 +322,8 @@ CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1,
return false; return false;
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.InverseDiag("); TPythonDump() << "isDone = " << this << ".InverseDiag( "
str += TCollection_AsciiString((Standard_Integer) NodeID1) + ", "; << NodeID1 << ", " << NodeID2 << " )";
str += TCollection_AsciiString((Standard_Integer) NodeID2) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
::SMESH_MeshEditor aMeshEditor( _myMesh ); ::SMESH_MeshEditor aMeshEditor( _myMesh );
return aMeshEditor.InverseDiag ( n1, n2 ); return aMeshEditor.InverseDiag ( n1, n2 );
@ -384,10 +344,8 @@ CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1,
return false; return false;
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.DeleteDiag("); TPythonDump() << "isDone = " << this << ".DeleteDiag( "
str += TCollection_AsciiString((Standard_Integer) NodeID1) + ", "; << NodeID1 << ", " << NodeID2 << " )";
str += TCollection_AsciiString((Standard_Integer) NodeID2) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
::SMESH_MeshEditor aMeshEditor( _myMesh ); ::SMESH_MeshEditor aMeshEditor( _myMesh );
return aMeshEditor.DeleteDiag ( n1, n2 ); return aMeshEditor.DeleteDiag ( n1, n2 );
@ -410,9 +368,7 @@ CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfEleme
anEditor.Reorient( elem ); anEditor.Reorient( elem );
} }
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.Reorient("); TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )";
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
return true; return true;
} }
@ -434,9 +390,7 @@ CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theO
aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.ReorientObject("); TPythonDump() << "isDone = " << this << ".ReorientObject( " << theObject << " )";
SMESH_Gen_i::AddObject( str, theObject ) += ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
return isDone; return isDone;
} }
@ -467,12 +421,10 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE
aCrit = aNumericalFunctor->GetNumericalFunctor(); aCrit = aNumericalFunctor->GetNumericalFunctor();
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.TriToQuad("); TPythonDump() << "isDone = " << this << ".TriToQuad( "
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None, "; << IDsOfElements << ", None, " << MaxAngle << " )";
str += TCollection_AsciiString((Standard_Real) MaxAngle) + ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuad: \", isDone" ); TPythonDump() << "print 'TriToQuad: ', isDone";
#endif #endif
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
@ -499,12 +451,10 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr
#endif #endif
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.TriToQuadObject("); TPythonDump() << "isDone = " << this << ".TriToQuadObject("
SMESH_Gen_i::AddObject( str, theObject ) += ", None, "; << theObject << ", None, " << MaxAngle << " )";
str += TCollection_AsciiString((Standard_Real) MaxAngle) + ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuadObject: \", isDone" ); TPythonDump() << "print 'TriToQuadObject: ', isDone";
#endif #endif
return isDone; return isDone;
@ -536,11 +486,9 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfE
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.QuadToTri("); TPythonDump() << "isDone = " << this << ".QuadToTri( " << IDsOfElements << ", None )";
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None )";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTri: \", isDone" ); TPythonDump() << "print 'QuadToTri: ', isDone";
#endif #endif
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
@ -566,11 +514,9 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr
#endif #endif
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.QuadToTriObject("); TPythonDump() << "isDone = " << this << ".QuadToTriObject(" << theObject << ", None )";
SMESH_Gen_i::AddObject( str, theObject ) += ", None )";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTriObject: \", isDone" ); TPythonDump() << "print 'QuadToTriObject: ', isDone";
#endif #endif
return isDone; return isDone;
@ -594,12 +540,10 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle
} }
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.SplitQuad("); TPythonDump() << "isDone = " << this << ".SplitQuad( "
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", "; << IDsOfElements << ", " << Diag13 << " )";
str += TCollection_AsciiString( Diag13 ) + ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuad: \", isDone" ); TPythonDump() << "print 'SplitQuad: ', isDone";
#endif #endif
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
@ -625,12 +569,10 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr th
#endif #endif
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.SplitQuadObject("); TPythonDump() << "isDone = " << this << ".SplitQuadObject( "
SMESH_Gen_i::AddObject( str, theObject ) += ", "; << theObject << ", " << Diag13 << " )";
str += TCollection_AsciiString( Diag13 ) + ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuadObject: \", isDone" ); TPythonDump() << "print 'SplitQuadObject: ', isDone";
#endif #endif
return isDone; return isDone;
@ -767,22 +709,15 @@ CORBA::Boolean
MaxNbOfIterations, MaxAspectRatio, IsParametric ); MaxNbOfIterations, MaxAspectRatio, IsParametric );
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor."); TPythonDump() << "isDone = " << this << "."
str += (char*) (IsParametric ? "SmoothParametric( " : "Smooth( "); << (IsParametric ? "SmoothParametric( " : "Smooth( ")
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", "; << IDsOfElements << ", " << IDsOfFixedNodes << ", "
SMESH_Gen_i::AddArray( str, IDsOfFixedNodes ) += ", "; << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
str += (Standard_Integer) MaxNbOfIterations; << "SMESH.SMESH_MeshEditor."
str += ", "; << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
str += (Standard_Real) MaxAspectRatio; "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
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 );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"Smooth: \", isDone" ); TPythonDump() << "print 'Smooth: ', isDone";
#endif #endif
return true; return true;
@ -795,12 +730,12 @@ CORBA::Boolean
//============================================================================= //=============================================================================
CORBA::Boolean CORBA::Boolean
SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject, SMESH_MeshEditor_i::smoothObject(SMESH::SMESH_IDSource_ptr theObject,
const SMESH::long_array & IDsOfFixedNodes, const SMESH::long_array & IDsOfFixedNodes,
CORBA::Long MaxNbOfIterations, CORBA::Long MaxNbOfIterations,
CORBA::Double MaxAspectRatio, CORBA::Double MaxAspectRatio,
SMESH::SMESH_MeshEditor::Smooth_Method Method, SMESH::SMESH_MeshEditor::Smooth_Method Method,
bool IsParametric) bool IsParametric)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations, CORBA::Boolean isDone = smooth (anElementsId, IDsOfFixedNodes, MaxNbOfIterations,
@ -814,22 +749,15 @@ CORBA::Boolean
#endif #endif
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor."); TPythonDump() << "isDone = " << this << "."
str += (char*) (IsParametric ? "SmoothParametricObject( " : "SmoothObject( "); << (IsParametric ? "SmoothParametricObject( " : "SmoothObject( ")
SMESH_Gen_i::AddObject( str, theObject ) += ", "; << theObject << ", " << IDsOfFixedNodes << ", "
SMESH_Gen_i::AddArray( str, IDsOfFixedNodes ) += ", "; << MaxNbOfIterations << ", " << MaxAspectRatio << ", "
str += (Standard_Integer) MaxNbOfIterations; << "SMESH.SMESH_MeshEditor."
str += ", "; << ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH ?
str += (Standard_Real) MaxAspectRatio; "CENTROIDAL_SMOOTH )" : "LAPLACIAN_SMOOTH )");
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 );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"SmoothObject: \", isDone" ); TPythonDump() << "print 'SmoothObject: ', isDone";
#endif #endif
return isDone; return isDone;
@ -844,7 +772,7 @@ CORBA::Boolean
void SMESH_MeshEditor_i::RenumberNodes() void SMESH_MeshEditor_i::RenumberNodes()
{ {
// Update Python script // Update Python script
SMESH_Gen_i::AddToCurrentPyScript( "mesh_editor.RenumberNodes()" ); TPythonDump() << this << ".RenumberNodes()";
GetMeshDS()->Renumber( true ); GetMeshDS()->Renumber( true );
} }
@ -858,7 +786,7 @@ void SMESH_MeshEditor_i::RenumberNodes()
void SMESH_MeshEditor_i::RenumberElements() void SMESH_MeshEditor_i::RenumberElements()
{ {
// Update Python script // Update Python script
SMESH_Gen_i::AddToCurrentPyScript( "mesh_editor.RenumberElements()" ); TPythonDump() << this << ".RenumberElements()";
GetMeshDS()->Renumber( false ); GetMeshDS()->Renumber( false );
} }
@ -892,15 +820,13 @@ void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElement
theNbOfSteps, theTolerance); theNbOfSteps, theTolerance);
// Update Python script // Update Python script
TCollection_AsciiString str = "axis = "; TPythonDump() << "axis = " << theAxis;
addAxis( str, theAxis ); TPythonDump() << this << ".RotationSweep( "
SMESH_Gen_i::AddToCurrentPyScript( str ); << theIDsOfElements
str = "mesh_editor.RotationSweep("; << ", axis, "
SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", axis, "; << theAngleInRadians << ", "
str += TCollection_AsciiString( theAngleInRadians ) + ", "; << theNbOfSteps << ", "
str += TCollection_AsciiString( (int)theNbOfSteps ) + ", "; << theTolerance << " )";
str += TCollection_AsciiString( theTolerance ) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
} }
//======================================================================= //=======================================================================
@ -922,12 +848,12 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject
aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
// Update Python script // Update Python script
TCollection_AsciiString str ("mesh_editor.RotationSweepObject("); TPythonDump() << this << ".RotationSweepObject( "
SMESH_Gen_i::AddObject( str, theObject ) += ", axis, "; << theObject
str += TCollection_AsciiString( theAngleInRadians ) + ", "; << ", axis, "
str += TCollection_AsciiString( (int)theNbOfSteps ) + ", "; << theAngleInRadians << ", "
str += TCollection_AsciiString( theTolerance ) + " )"; << theNbOfSteps << ", "
SMESH_Gen_i::AddToCurrentPyScript( str ); << theTolerance << " )";
} }
//======================================================================= //=======================================================================
@ -958,15 +884,9 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen
anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory); anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
// Update Python script // Update Python script
TCollection_AsciiString str = "stepVector = SMESH.DirStruct( SMESH.PointStruct ( "; TPythonDump() << "stepVector = " << theStepVector;
str += (TCollection_AsciiString) stepVec.X() + ", "; TPythonDump() << this << ".ExtrusionSweep( "
str += (TCollection_AsciiString) stepVec.Y() + ", "; << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
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 );
} }
@ -987,10 +907,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec
aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
// Update Python script // Update Python script
TCollection_AsciiString str ("mesh_editor.ExtrusionSweepObject("); TPythonDump() << this << ".ExtrusionSweepObject( "
SMESH_Gen_i::AddObject( str, theObject ) += ", stepVector, "; << theObject << ", stepVector, " << theNbOfSteps << " )";
str += TCollection_AsciiString((int)theNbOfSteps) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
} }
//======================================================================= //=======================================================================
@ -1021,6 +939,11 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObj
//anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps); //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
TElemOfElemListMap aHystory; TElemOfElemListMap aHystory;
anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, 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); //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
TElemOfElemListMap aHystory; TElemOfElemListMap aHystory;
anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, 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); theExtrFlags, theSewTolerance);
// Update Python script // Update Python script
TCollection_AsciiString str = "stepVector = SMESH.DirStruct( SMESH.PointStruct ( "; TPythonDump() << "stepVector = " << theStepVector;
str += (TCollection_AsciiString) stepVec.X() + ", "; TPythonDump() << this << ".AdvancedExtrusion("
str += (TCollection_AsciiString) stepVec.Y() + ", "; << theIDsOfElements
str += (TCollection_AsciiString) stepVec.Z() + " ))"; << ", stepVector, "
SMESH_Gen_i::AddToCurrentPyScript( str ); << theNbOfSteps << ","
str = ("mesh_editor.AdvancedExtrusion("); << theExtrFlags << ", "
SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", stepVector, "; << theSewTolerance << " )";
str += TCollection_AsciiString((int)theNbOfSteps) + ",";
str += TCollection_AsciiString((int)theExtrFlags) + ", ";
str += TCollection_AsciiString((double)theSewTolerance) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
} }
@ -1163,23 +1087,23 @@ SMESH::SMESH_MeshEditor::Extrusion_Error
gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z ); gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
// Update Python script // Update Python script
TCollection_AsciiString str = "refPoint = SMESH.PointStruct( "; TPythonDump() << "refPoint = SMESH.PointStruct( "
str += (TCollection_AsciiString) refPnt.X() + ", "; << refPnt.X() << ", "
str += (TCollection_AsciiString) refPnt.Y() + ", "; << refPnt.Y() << ", "
str += (TCollection_AsciiString) refPnt.Z() + " )"; << refPnt.Z() << " )";
SMESH_Gen_i::AddToCurrentPyScript( str ); TPythonDump() << "error = " << this << ".ExtrusionAlongPath( "
str = ("error = mesh_editor.ExtrusionAlongPath("); << theIDsOfElements << ", "
SMESH_Gen_i::AddArray ( str, theIDsOfElements ) += ", "; << thePathMesh << ", "
SMESH_Gen_i::AddObject( str, thePathMesh ) += ", "; << thePathShape << ", "
SMESH_Gen_i::AddObject( str, thePathShape ) += ", "; << theNodeStart << ", "
str += TCollection_AsciiString( (int)theNodeStart ) + ", "; << theHasAngles << ", "
str += TCollection_AsciiString( (int)theHasAngles ) + ", "; << theAngles << ", "
SMESH_Gen_i::AddArray ( str, theAngles ) += ", "; << theHasRefPoint << ", refPoint )";
str += (TCollection_AsciiString) theHasRefPoint + ", refPoint )";
SMESH_Gen_i::AddToCurrentPyScript( str );
::SMESH_MeshEditor anEditor( _myMesh ); ::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::SMESH_MeshEditor::Extrusion_Error
SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject, SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
SMESH::SMESH_Mesh_ptr thePathMesh, SMESH::SMESH_Mesh_ptr thePathMesh,
GEOM::GEOM_Object_ptr thePathShape, GEOM::GEOM_Object_ptr thePathShape,
CORBA::Long theNodeStart, CORBA::Long theNodeStart,
CORBA::Boolean theHasAngles, CORBA::Boolean theHasAngles,
const SMESH::double_array & theAngles, const SMESH::double_array & theAngles,
CORBA::Boolean theHasRefPoint, CORBA::Boolean theHasRefPoint,
const SMESH::PointStruct & theRefPoint) const SMESH::PointStruct & theRefPoint)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath SMESH::SMESH_MeshEditor::Extrusion_Error error = ExtrusionAlongPath
@ -1207,15 +1131,14 @@ SMESH::SMESH_MeshEditor::Extrusion_Error
aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
// Update Python script // Update Python script
TCollection_AsciiString str ("error = mesh_editor.ExtrusionAlongPathObject("); TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( "
SMESH_Gen_i::AddObject( str, theObject ) += ", "; << theObject << ", "
SMESH_Gen_i::AddObject( str, thePathMesh ) += ", "; << thePathMesh << ", "
SMESH_Gen_i::AddObject( str, thePathShape ) += ", "; << thePathShape << ", "
str += TCollection_AsciiString( (int)theNodeStart ) + ", "; << theNodeStart << ", "
str += TCollection_AsciiString( theHasAngles ) + ", "; << theHasAngles << ", "
SMESH_Gen_i::AddArray ( str, theAngles ) += ", "; << theAngles << ", "
str += TCollection_AsciiString( theHasRefPoint ) + ", refPoint )"; << theHasRefPoint << ", refPoint )";
SMESH_Gen_i::AddToCurrentPyScript( str );
return error; 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_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz );
gp_Trsf aTrsf; gp_Trsf aTrsf;
TCollection_AsciiString typeStr, copyStr( theCopy ); TCollection_AsciiString typeStr;
switch ( theMirrorType ) { switch ( theMirrorType ) {
case SMESH::SMESH_MeshEditor::POINT: case SMESH::SMESH_MeshEditor::POINT:
aTrsf.SetMirror( P ); aTrsf.SetMirror( P );
@ -1260,12 +1183,11 @@ void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElem
} }
// Update Python script // Update Python script
TCollection_AsciiString str ("mesh_editor.Mirror("); TPythonDump() << this << ".Mirror( "
SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", "; << theIDsOfElements << ", "
addAxis( str, theAxis ) += ", "; << theAxis << ", "
str += typeStr + ", "; << typeStr << ", "
str += copyStr + " )"; << theCopy << " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
anEditor.Transform (elements, aTrsf, theCopy); anEditor.Transform (elements, aTrsf, theCopy);
@ -1289,7 +1211,7 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj
aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
// Update Python script // Update Python script
TCollection_AsciiString typeStr, copyStr( theCopy ); TCollection_AsciiString typeStr;
switch ( theMirrorType ) { switch ( theMirrorType ) {
case SMESH::SMESH_MeshEditor::POINT: case SMESH::SMESH_MeshEditor::POINT:
typeStr = "SMESH.SMESH_MeshEditor.POINT"; typeStr = "SMESH.SMESH_MeshEditor.POINT";
@ -1300,12 +1222,12 @@ void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObj
default: default:
typeStr = "SMESH.SMESH_MeshEditor.PLANE"; typeStr = "SMESH.SMESH_MeshEditor.PLANE";
} }
TPythonDump() << "axis = " << theAxis;
TCollection_AsciiString str ("mesh_editor.MirrorObject("); TPythonDump() << this << ".MirrorObject( "
SMESH_Gen_i::AddObject( str, theObject ) += ", "; << theObject << ", "
addAxis( str, theAxis ) += ", "; << "axis, "
str += typeStr + ", " + copyStr + " )"; << typeStr << ", "
SMESH_Gen_i::AddToCurrentPyScript( str ); << theCopy << " )";
} }
//======================================================================= //=======================================================================
@ -1335,15 +1257,11 @@ void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
anEditor.Transform (elements, aTrsf, theCopy); anEditor.Transform (elements, aTrsf, theCopy);
// Update Python script // Update Python script
TCollection_AsciiString str = "vector = SMESH.DirStruct( SMESH.PointStruct ( "; TPythonDump() << "vector = " << theVector;
str += (TCollection_AsciiString) P->x + ", "; TPythonDump() << this << ".Translate( "
str += (TCollection_AsciiString) P->y + ", "; << theIDsOfElements
str += (TCollection_AsciiString) P->z + " ))"; << ", vector, "
SMESH_Gen_i::AddToCurrentPyScript( str ); << theCopy << " )";
str = ("mesh_editor.Translate(");
SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", vector, ";
str += (TCollection_AsciiString) theCopy + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
} }
//======================================================================= //=======================================================================
@ -1363,10 +1281,10 @@ void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
// Update Python script // Update Python script
TCollection_AsciiString str ("mesh_editor.TranslateObject("); TPythonDump() << this << ".TranslateObject( "
SMESH_Gen_i::AddObject( str, theObject ) += ", vector, "; << theObject
str += TCollection_AsciiString( theCopy ) + " )"; << ", vector, "
SMESH_Gen_i::AddToCurrentPyScript( str ); << theCopy << " )";
} }
//======================================================================= //=======================================================================
@ -1399,14 +1317,12 @@ void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
anEditor.Transform (elements, aTrsf, theCopy); anEditor.Transform (elements, aTrsf, theCopy);
// Update Python script // Update Python script
TCollection_AsciiString str ("axis = "); TPythonDump() << "axis = " << theAxis;
addAxis( str, theAxis ); TPythonDump() << this << ".Rotate( "
SMESH_Gen_i::AddToCurrentPyScript( str ); << theIDsOfElements
str = ("mesh_editor.Rotate("); << ", axis, "
SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", axis, "; << theAngle << ", "
str += (TCollection_AsciiString) theAngle + ", "; << theCopy << " )";
str += (TCollection_AsciiString) theCopy + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
} }
//======================================================================= //=======================================================================
@ -1427,11 +1343,11 @@ void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID()); aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
// Update Python script // Update Python script
TCollection_AsciiString str ("mesh_editor.RotateObject("); TPythonDump() << this << ".RotateObject( "
SMESH_Gen_i::AddObject( str, theObject ) += ", axis, "; << theObject
str += TCollection_AsciiString( theAngle ) + ", "; << ", axis, "
str += TCollection_AsciiString( theCopy ) + " )"; << theAngle << ", "
SMESH_Gen_i::AddToCurrentPyScript( str ); << theCopy << " )";
} }
//======================================================================= //=======================================================================
@ -1459,6 +1375,9 @@ void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tol
for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ ) for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ )
aGroup[ j ] = (*lIt)->GetID(); 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(); SMESHDS_Mesh* aMesh = GetMeshDS();
TCollection_AsciiString str( "mesh_editor.MergeNodes([" ); TPythonDump aTPythonDump;
aTPythonDump << this << ".MergeNodes([";
::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes; ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
for (int i = 0; i < GroupsOfNodes.length(); i++) 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 ) if ( aListOfNodes.size() < 2 )
aListOfListOfNodes.pop_back(); aListOfListOfNodes.pop_back();
if ( i > 0 ) if ( i > 0 ) aTPythonDump << ", ";
str += ","; aTPythonDump << aNodeGroup;
SMESH_Gen_i::AddArray( str, aNodeGroup );
} }
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
anEditor.MergeNodes( aListOfListOfNodes ); anEditor.MergeNodes( aListOfListOfNodes );
// Update Python script // Update Python script
SMESH_Gen_i::AddToCurrentPyScript( str + "])" ); aTPythonDump << "])";
} }
//======================================================================= //=======================================================================
@ -1509,7 +1428,7 @@ void SMESH_MeshEditor_i::MergeEqualElements()
anEditor.MergeEqualElements(); anEditor.MergeEqualElements();
// Update Python script // 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; return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
// Update Python script // Update Python script
TCollection_AsciiString str ("error = mesh_editor.SewFreeBorders( "); TPythonDump() << "error = " << this << ".SewFreeBorders( "
str += TCollection_AsciiString( (int) FirstNodeID1 ) + ", "; << FirstNodeID1 << ", "
str += TCollection_AsciiString( (int) SecondNodeID1 ) + ", "; << SecondNodeID1 << ", "
str += TCollection_AsciiString( (int) LastNodeID1 ) + ", "; << LastNodeID1 << ", "
str += TCollection_AsciiString( (int) FirstNodeID2 ) + ", "; << FirstNodeID2 << ", "
str += TCollection_AsciiString( (int) SecondNodeID2 ) + ", "; << SecondNodeID2 << ", "
str += TCollection_AsciiString( (int) LastNodeID2 ) + ", "; << LastNodeID2 << ", "
str += TCollection_AsciiString( CreatePolygons ) + ", "; << CreatePolygons<< ", "
str += TCollection_AsciiString( CreatePolyedrs ) + ") "; << CreatePolyedrs<< " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
return convError( anEditor.SewFreeBorder (aBorderFirstNode, return convError( anEditor.SewFreeBorder (aBorderFirstNode,
@ -1599,11 +1517,11 @@ SMESH::SMESH_MeshEditor::Sew_Error
//======================================================================= //=======================================================================
SMESH::SMESH_MeshEditor::Sew_Error SMESH::SMESH_MeshEditor::Sew_Error
SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1,
CORBA::Long SecondNodeID1, CORBA::Long SecondNodeID1,
CORBA::Long LastNodeID1, CORBA::Long LastNodeID1,
CORBA::Long FirstNodeID2, CORBA::Long FirstNodeID2,
CORBA::Long SecondNodeID2) CORBA::Long SecondNodeID2)
{ {
SMESHDS_Mesh* aMesh = GetMeshDS(); SMESHDS_Mesh* aMesh = GetMeshDS();
@ -1623,13 +1541,12 @@ SMESH::SMESH_MeshEditor::Sew_Error
return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND;
// Update Python script // Update Python script
TCollection_AsciiString str ("error = mesh_editor.SewConformFreeBorders( "); TPythonDump() << "error = " << this << ".SewConformFreeBorders( "
str += TCollection_AsciiString( (int) FirstNodeID1 ) + ", "; << FirstNodeID1 << ", "
str += TCollection_AsciiString( (int) SecondNodeID1 ) + ", "; << SecondNodeID1 << ", "
str += TCollection_AsciiString( (int) LastNodeID1 ) + ", "; << LastNodeID1 << ", "
str += TCollection_AsciiString( (int) FirstNodeID2 ) + ", "; << FirstNodeID2 << ", "
str += TCollection_AsciiString( (int) SecondNodeID2 ) + ")"; << SecondNodeID2 << " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
return convError( anEditor.SewFreeBorder (aBorderFirstNode, return convError( anEditor.SewFreeBorder (aBorderFirstNode,
@ -1648,13 +1565,13 @@ SMESH::SMESH_MeshEditor::Sew_Error
//======================================================================= //=======================================================================
SMESH::SMESH_MeshEditor::Sew_Error SMESH::SMESH_MeshEditor::Sew_Error
SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
CORBA::Long SecondNodeIDOnFreeBorder, CORBA::Long SecondNodeIDOnFreeBorder,
CORBA::Long LastNodeIDOnFreeBorder, CORBA::Long LastNodeIDOnFreeBorder,
CORBA::Long FirstNodeIDOnSide, CORBA::Long FirstNodeIDOnSide,
CORBA::Long LastNodeIDOnSide, CORBA::Long LastNodeIDOnSide,
CORBA::Boolean CreatePolygons, CORBA::Boolean CreatePolygons,
CORBA::Boolean CreatePolyedrs) CORBA::Boolean CreatePolyedrs)
{ {
SMESHDS_Mesh* aMesh = GetMeshDS(); SMESHDS_Mesh* aMesh = GetMeshDS();
@ -1674,15 +1591,14 @@ SMESH::SMESH_MeshEditor::Sew_Error
return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES; return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES;
// Update Python script // Update Python script
TCollection_AsciiString str ("error = mesh_editor.SewBorderToSide( "); TPythonDump() << "error = " << this << ".SewBorderToSide( "
str += TCollection_AsciiString( (int) FirstNodeIDOnFreeBorder ) + ", "; << FirstNodeIDOnFreeBorder << ", "
str += TCollection_AsciiString( (int) SecondNodeIDOnFreeBorder ) + ", "; << SecondNodeIDOnFreeBorder << ", "
str += TCollection_AsciiString( (int) LastNodeIDOnFreeBorder ) + ", "; << LastNodeIDOnFreeBorder << ", "
str += TCollection_AsciiString( (int) FirstNodeIDOnSide ) + ", "; << FirstNodeIDOnSide << ", "
str += TCollection_AsciiString( (int) LastNodeIDOnSide ) + ", "; << LastNodeIDOnSide << ", "
str += TCollection_AsciiString( CreatePolygons ) + ", "; << CreatePolygons << ", "
str += TCollection_AsciiString( CreatePolyedrs ) + ") "; << CreatePolyedrs << ") ";
SMESH_Gen_i::AddToCurrentPyScript( str );
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
return convError( anEditor.SewFreeBorder (aBorderFirstNode, return convError( anEditor.SewFreeBorder (aBorderFirstNode,
@ -1702,12 +1618,12 @@ SMESH::SMESH_MeshEditor::Sew_Error
//======================================================================= //=======================================================================
SMESH::SMESH_MeshEditor::Sew_Error SMESH::SMESH_MeshEditor::Sew_Error
SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements, SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
const SMESH::long_array& IDsOfSide2Elements, const SMESH::long_array& IDsOfSide2Elements,
CORBA::Long NodeID1OfSide1ToMerge, CORBA::Long NodeID1OfSide1ToMerge,
CORBA::Long NodeID1OfSide2ToMerge, CORBA::Long NodeID1OfSide2ToMerge,
CORBA::Long NodeID2OfSide1ToMerge, CORBA::Long NodeID2OfSide1ToMerge,
CORBA::Long NodeID2OfSide2ToMerge) CORBA::Long NodeID2OfSide2ToMerge)
{ {
SMESHDS_Mesh* aMesh = GetMeshDS(); SMESHDS_Mesh* aMesh = GetMeshDS();
@ -1739,14 +1655,13 @@ SMESH::SMESH_MeshEditor::Sew_Error
aSide2Elems.insert( elem ); aSide2Elems.insert( elem );
} }
// Update Python script // Update Python script
TCollection_AsciiString str ("error = mesh_editor.SewSideElements( "); TPythonDump() << "error = " << this << ".SewSideElements( "
SMESH_Gen_i::AddArray( str, IDsOfSide1Elements ) += ", "; << IDsOfSide1Elements << ", "
SMESH_Gen_i::AddArray( str, IDsOfSide2Elements ) += ", "; << IDsOfSide2Elements << ", "
str += TCollection_AsciiString( (int) NodeID1OfSide1ToMerge ) + ", "; << NodeID1OfSide1ToMerge << ", "
str += TCollection_AsciiString( (int) NodeID1OfSide2ToMerge ) + ", "; << NodeID1OfSide2ToMerge << ", "
str += TCollection_AsciiString( (int) NodeID2OfSide1ToMerge ) + ", "; << NodeID2OfSide1ToMerge << ", "
str += TCollection_AsciiString( (int) NodeID2OfSide2ToMerge ) + ")"; << NodeID2OfSide2ToMerge << ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems, return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems,

View File

@ -31,6 +31,7 @@
#include "SMESH_MEDMesh_i.hxx" #include "SMESH_MEDMesh_i.hxx"
#include "SMESH_Group_i.hxx" #include "SMESH_Group_i.hxx"
#include "SMESH_Filter_i.hxx" #include "SMESH_Filter_i.hxx"
#include "SMESH_PythonDump.hxx"
#include "Utils_CorbaException.hxx" #include "Utils_CorbaException.hxx"
#include "Utils_ExceptHandlers.hxx" #include "Utils_ExceptHandlers.hxx"
@ -68,6 +69,7 @@ static int MYDEBUG = 0;
#endif #endif
using namespace std; using namespace std;
using SMESH::TPythonDump;
int SMESH_Mesh_i::myIdGenerator = 0; 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 ); if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
// Update Python script // Update Python script
TCollection_AsciiString aStr ("status = "); TPythonDump() << "status = " << _this() << ".AddHypothesis( "
SMESH_Gen_i::AddObject(aStr, _this()) += ".AddHypothesis("; << aSubShapeObject << ", " << anHyp << " )";
SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", ";
SMESH_Gen_i::AddObject(aStr, anHyp) += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
return ConvertHypothesisStatus(status); return ConvertHypothesisStatus(status);
} }
@ -416,12 +414,8 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aS
aSubShapeObject, anHyp ); aSubShapeObject, anHyp );
// Update Python script // Update Python script
TCollection_AsciiString aStr ("status = "); TPythonDump() << "status = " << _this() << ".RemoveHypothesis( "
SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveHypothesis("; << aSubShapeObject << ", " << anHyp << " )";
SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", ";
SMESH_Gen_i::AddObject(aStr, anHyp) += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
return ConvertHypothesisStatus(status); return ConvertHypothesisStatus(status);
} }
@ -537,14 +531,8 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap
subMesh, aSubShapeObject, theName ); subMesh, aSubShapeObject, theName );
if ( !aSO->_is_nil()) { if ( !aSO->_is_nil()) {
// Update Python script // Update Python script
TCollection_AsciiString aStr (aSO->GetID()); TPythonDump() << aSO << " = " << _this() << ".GetSubMesh( "
aStr += " = "; << aSubShapeObject << ", '" << theName << "' )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".GetSubMesh(";
SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", \"";
aStr += (char*)theName;
aStr += "\")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
} }
} }
} }
@ -581,12 +569,7 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
aStudy->NewBuilder()->RemoveObjectWithChildren( anSO ); aStudy->NewBuilder()->RemoveObjectWithChildren( anSO );
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << _this() << ".RemoveSubMesh( " << anSO << " )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveSubMesh(";
aStr += anSO->GetID();
aStr += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
} }
} }
@ -598,29 +581,18 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
* ElementTypeString * ElementTypeString
*/ */
//============================================================================= //=============================================================================
#define CASE2STRING(enum) case SMESH::enum: return "SMESH."#enum;
inline TCollection_AsciiString ElementTypeString (SMESH::ElementType theElemType) inline TCollection_AsciiString ElementTypeString (SMESH::ElementType theElemType)
{ {
TCollection_AsciiString aStr;
switch (theElemType) { switch (theElemType) {
case SMESH::ALL: CASE2STRING( ALL );
aStr = "SMESH.ALL"; CASE2STRING( NODE );
break; CASE2STRING( EDGE );
case SMESH::NODE: CASE2STRING( FACE );
aStr = "SMESH.NODE"; CASE2STRING( VOLUME );
break; default:;
case SMESH::EDGE:
aStr = "SMESH.EDGE";
break;
case SMESH::FACE:
aStr = "SMESH.FACE";
break;
case SMESH::VOLUME:
aStr = "SMESH.VOLUME";
break;
default:
break;
} }
return aStr; return "";
} }
//============================================================================= //=============================================================================
@ -643,15 +615,10 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType
aNewGroup, GEOM::GEOM_Object::_nil(), theName); aNewGroup, GEOM::GEOM_Object::_nil(), theName);
if ( !aSO->_is_nil()) { if ( !aSO->_is_nil()) {
// Update Python script // Update Python script
TCollection_AsciiString aStr (aSO->GetID()); TPythonDump() << aSO << " = " << _this() << ".CreateGroup( "
aStr += " = "; << ElementTypeString(theElemType) << ", '" << theName << "' )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroup(";
aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
} }
} }
return aNewGroup._retn(); return aNewGroup._retn();
} }
@ -679,13 +646,9 @@ SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementTy
aNewGroup, theGeomObj, theName); aNewGroup, theGeomObj, theName);
if ( !aSO->_is_nil()) { if ( !aSO->_is_nil()) {
// Update Python script // Update Python script
TCollection_AsciiString aStr (aSO->GetID()); TPythonDump() << aSO << " = " << _this() << ".CreateGroupFromGEOM("
aStr += " = "; << ElementTypeString(theElemType) << ", '" << theName << "', "
SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroupFromGEOM("; << theGeomObj << " )";
aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\", ";
SMESH_Gen_i::AddObject(aStr, theGeomObj) += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
} }
} }
} }
@ -716,12 +679,7 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
if ( !aGroupSO->_is_nil() ) { if ( !aGroupSO->_is_nil() ) {
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << _this() << ".RemoveGroup( " << aGroupSO << " )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveGroup(";
aStr += aGroupSO->GetID();
aStr += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Remove group's SObject // Remove group's SObject
aStudy->NewBuilder()->RemoveObject( aGroupSO ); 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(); SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << _this() << ".RemoveGroupWithContents( " << theGroup << " )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveGroupWithContents(";
SMESH_Gen_i::AddObject(aStr, theGroup) += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Remove contents // Remove contents
if ( aGroup->GetType() == SMESH::NODE ) 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()); _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << aResGrp << " = " << _this() << ".UnionGroups( "
SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; << theGroup1 << ", " << theGroup2 << ", '"
SMESH_Gen_i::AddObject(aStr, _this()) += ".UnionGroups("; << theName << "' )";
SMESH_Gen_i::AddObject(aStr, theGroup1) += ", ";
SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \"";
aStr += TCollection_AsciiString((char*)theName) + "\")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
return aResGrp._retn(); return aResGrp._retn();
} }
@ -886,14 +835,8 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr
_gen_i->RemoveLastFromPythonScript(aStudy->StudyId()); _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << aResGrp << " = " << _this() << ".IntersectGroups( "
SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; << theGroup1 << ", " << theGroup2 << ", '" << theName << "')";
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);
return aResGrp._retn(); 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()); _gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << aResGrp << " = " << _this() << ".CutGroups( "
SMESH_Gen_i::AddObject(aStr, aResGrp) += " = "; << theGroup1 << ", " << theGroup2 << ", '"
SMESH_Gen_i::AddObject(aStr, _this()) += ".CutGroups("; << theName << "' )";
SMESH_Gen_i::AddObject(aStr, theGroup1) += ", ";
SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \"";
aStr += TCollection_AsciiString((char*)theName) + "\")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
return aResGrp._retn(); return aResGrp._retn();
} }
@ -1213,15 +1151,13 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl)
SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor() 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 // Create MeshEditor
SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl ); SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl );
SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this(); SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this();
// Update Python script
TPythonDump() << aMeshEditor << " = " << _this() << ".GetMeshEditor()";
return aMesh._retn(); return aMesh._retn();
} }
@ -1293,23 +1229,8 @@ void SMESH_Mesh_i::ExportToMED (const char* file,
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << _this() << ".ExportToMED( '"
SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportToMED(\""; << file << "', " << auto_groups << ", " << theVersion << " )";
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);
// Perform Export // Perform Export
PrepareForWriting(file); PrepareForWriting(file);
@ -1357,11 +1278,7 @@ void SMESH_Mesh_i::ExportDAT (const char *file)
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << _this() << ".ExportDAT( '" << file << "' )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportDAT(\"";
aStr += TCollection_AsciiString((char*)file) + "\")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Perform Export // Perform Export
PrepareForWriting(file); PrepareForWriting(file);
@ -1374,11 +1291,7 @@ void SMESH_Mesh_i::ExportUNV (const char *file)
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << _this() << ".ExportUNV( '" << file << "' )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportUNV(\"";
aStr += TCollection_AsciiString((char*)file) + "\")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Perform Export // Perform Export
PrepareForWriting(file); PrepareForWriting(file);
@ -1391,12 +1304,7 @@ void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii)
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
// Update Python script // Update Python script
TCollection_AsciiString aStr; TPythonDump() << _this() << ".ExportSTL( '" << file << "', " << isascii << " )";
SMESH_Gen_i::AddObject(aStr, _this()) += ".ExportSTL(\"";
aStr += TCollection_AsciiString((char*)file) + "\", ";
aStr += TCollection_AsciiString((int)isascii) + ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Perform Export // Perform Export
PrepareForWriting(file); PrepareForWriting(file);

View File

@ -32,6 +32,7 @@
#include "SMESH_Gen_i.hxx" #include "SMESH_Gen_i.hxx"
#include "SMESH_Mesh.hxx" #include "SMESH_Mesh.hxx"
#include "SMESH_Mesh_i.hxx" #include "SMESH_Mesh_i.hxx"
#include "SMESH_PythonDump.hxx"
#include "SMDS_MeshFace.hxx" #include "SMDS_MeshFace.hxx"
#include "SMDS_MeshVolume.hxx" #include "SMDS_MeshVolume.hxx"
@ -42,6 +43,8 @@
#include <sstream> #include <sstream>
#include <set> #include <set>
using SMESH::TPythonDump;
//======================================================================= //=======================================================================
//function : dumpErrorCode //function : dumpErrorCode
//purpose : //purpose :
@ -49,11 +52,8 @@
static void addErrorCode(const char* thePyCommand) static void addErrorCode(const char* thePyCommand)
{ {
SMESH_Gen_i::AddToCurrentPyScript("if (isDone != 1):"); TPythonDump() << "if (isDone != 1):";
TCollection_AsciiString str ("\tprint \""); TPythonDump() << "\tprint '" << thePyCommand << " :', pattern.GetErrorCode()";
str += (char*) thePyCommand;
str += ":\", pattern.GetErrorCode()";
SMESH_Gen_i::AddToCurrentPyScript( str );
} }
//============================================================================= //=============================================================================
@ -67,7 +67,7 @@ static void addErrorCode(const char* thePyCommand)
SMESH::SMESH_Pattern_ptr SMESH_Gen_i::GetPattern() SMESH::SMESH_Pattern_ptr SMESH_Gen_i::GetPattern()
{ {
// Update Python script // Update Python script
SMESH_Gen_i::AddToCurrentPyScript( "pattern = smesh.GetPattern()" ); TPythonDump() << "pattern = " << this << ".GetPattern()";
SMESH_Pattern_i* i = new SMESH_Pattern_i( this ); SMESH_Pattern_i* i = new SMESH_Pattern_i( this );
SMESH::SMESH_Pattern_var anObj = 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) CORBA::Boolean SMESH_Pattern_i::LoadFromFile(const char* theFileContents)
{ {
// Update Python script // Update Python script
TCollection_AsciiString str( "isDone = pattern.LoadFromFile(" ); TPythonDump() << "isDone = pattern.LoadFromFile(" << theFileContents << ")";
str += TCollection_AsciiString( (char*) theFileContents ) + ")";
SMESH_Gen_i::AddToCurrentPyScript( str );
addErrorCode( "LoadFromFile" ); addErrorCode( "LoadFromFile" );
return myPattern.Load( theFileContents ); return myPattern.Load( theFileContents );
@ -136,11 +134,8 @@ CORBA::Boolean SMESH_Pattern_i::LoadFromFace(SMESH::SMESH_Mesh_ptr theMesh,
return false; return false;
// Update Python script // Update Python script
TCollection_AsciiString str( "isDone = pattern.LoadFromFace( " ); TPythonDump() << "isDone = pattern.LoadFromFace( " << theMesh << ", "
SMESH_Gen_i::AddObject( str, theMesh ) += ", "; << theFace << ", " << theProject << " )";
SMESH_Gen_i::AddObject( str, theFace ) += ", ";
str += TCollection_AsciiString( theProject ) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
addErrorCode( "LoadFromFace" ); addErrorCode( "LoadFromFace" );
return myPattern.Load( aMesh, TopoDS::Face( aFace ), theProject ); 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; return false;
// Update Python script // Update Python script
TCollection_AsciiString str( "isDone = pattern.LoadFrom3DBlock( " ); TPythonDump() << "isDone = pattern.LoadFrom3DBlock( " << theMesh << ", " << theBlock << " )";
SMESH_Gen_i::AddObject( str, theMesh ) += ", ";
SMESH_Gen_i::AddObject( str, theBlock ) += " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
addErrorCode( "LoadFrom3DBlock" ); addErrorCode( "LoadFrom3DBlock" );
return myPattern.Load( aMesh, TopoDS::Shell( exp.Current() )); 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 // Update Python script
TCollection_AsciiString str( "pattern.ApplyToFace( " ); TPythonDump() << "pattern.ApplyToFace( " << theFace << ", "
SMESH_Gen_i::AddObject( str, theFace ) += ", "; << theVertexOnKeyPoint1 << ", " << theReverse << " )";
SMESH_Gen_i::AddObject( str, theVertexOnKeyPoint1 ) += ", ";
str += TCollection_AsciiString( theReverse ) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
return points._retn(); return points._retn();
} }
@ -252,11 +241,8 @@ SMESH::point_array* SMESH_Pattern_i::ApplyTo3DBlock(GEOM::GEOM_Object_ptr theBlo
} }
// Update Python script // Update Python script
TCollection_AsciiString str( "pattern.ApplyTo3DBlock( " ); TPythonDump() << "pattern.ApplyTo3DBlock( " << theBlock << ", "
SMESH_Gen_i::AddObject( str, theBlock ) += ", "; << theVertex000 << ", " << theVertex001 << " )";
SMESH_Gen_i::AddObject( str, theVertex000 ) += ", ";
SMESH_Gen_i::AddObject( str, theVertex001 ) += " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
return points._retn(); return points._retn();
} }
@ -299,12 +285,9 @@ SMESH::point_array*
} }
// Update Python script // Update Python script
TCollection_AsciiString str( "pattern.ApplyToMeshFaces( " ); TPythonDump() << "pattern.ApplyToMeshFaces( " << theMesh << ", "
SMESH_Gen_i::AddObject( str, theMesh ) += ", "; << theFacesIDs << ", "
SMESH_Gen_i::AddArray( str, theFacesIDs ) += ", "; << theNodeIndexOnKeyPoint1 << ", " << theReverse << " )";
str += TCollection_AsciiString( (int)theNodeIndexOnKeyPoint1 ) + ", ";
str += TCollection_AsciiString( theReverse ) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
return points._retn(); return points._retn();
} }
@ -347,12 +330,9 @@ SMESH::point_array*
} }
// Update Python script // Update Python script
TCollection_AsciiString str( "pattern.ApplyToHexahedrons( " ); TPythonDump() << "pattern.ApplyToHexahedrons( " << theMesh << ", "
SMESH_Gen_i::AddObject( str, theMesh ) += ", "; << theVolumesIDs << ", "
SMESH_Gen_i::AddArray( str, theVolumesIDs ) += ", "; << theNode000Index << ", " << theNode001Index << " )";
str += TCollection_AsciiString( (int)theNode000Index ) + ", ";
str += TCollection_AsciiString( (int)theNode001Index ) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
return points._retn(); return points._retn();
} }
@ -371,11 +351,8 @@ CORBA::Boolean SMESH_Pattern_i::MakeMesh (SMESH::SMESH_Mesh_ptr theMesh,
return false; return false;
// Update Python script // Update Python script
TCollection_AsciiString str( "isDone = pattern.MakeMesh( " ); TPythonDump() << "isDone = pattern.MakeMesh( " << theMesh << ", "
SMESH_Gen_i::AddObject( str, theMesh ) += ", "; << CreatePolygons << ", " << CreatePolyedrs << " )";
str += TCollection_AsciiString( CreatePolygons ) + ", ";
str += TCollection_AsciiString( CreatePolyedrs ) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
addErrorCode( "MakeMesh" ); addErrorCode( "MakeMesh" );
return myPattern.MakeMesh( aMesh, CreatePolygons, CreatePolyedrs ); return myPattern.MakeMesh( aMesh, CreatePolygons, CreatePolyedrs );

View File

@ -22,9 +22,14 @@
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SALOMEDS)
#include <sstream> #include <sstream>
class SMESH_Gen_i;
class SMESH_MeshEditor_i;
class TCollection_AsciiString;
namespace SMESH namespace SMESH
{ {
class FilterLibrary_i; class FilterLibrary_i;
@ -64,6 +69,12 @@ namespace SMESH
TPythonDump& TPythonDump&
operator<<(const SMESH::long_array& theArg); operator<<(const SMESH::long_array& theArg);
TPythonDump&
operator<<(const SMESH::double_array& theArg);
TPythonDump&
operator<<(SALOMEDS::SObject_ptr theArg);
TPythonDump& TPythonDump&
operator<<(CORBA::Object_ptr theArg); operator<<(CORBA::Object_ptr theArg);
@ -78,6 +89,27 @@ namespace SMESH
TPythonDump& TPythonDump&
operator<<(SMESH::Functor_i* theArg); 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"; }
}; };
} }