mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 17:30:35 +05:00
Dump Python: dump groups operations; correct processing of removed objects.
This commit is contained in:
parent
8d1da03971
commit
304f30c5ca
@ -288,6 +288,8 @@ public:
|
||||
|
||||
void AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString);
|
||||
|
||||
void RemoveLastFromPythonScript (int theStudyID);
|
||||
|
||||
static void AddToCurrentPyScript (const TCollection_AsciiString& theString);
|
||||
|
||||
void SavePython (SALOMEDS::Study_ptr theStudy);
|
||||
|
@ -33,6 +33,7 @@ Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
|
||||
SALOMEDS::SObject_var aValue = Itr->Value();
|
||||
|
||||
TCollection_AsciiString aName (aValue->GetName());
|
||||
if (aName.Length() > 0) {
|
||||
int p, p2 = 1, e = aName.Length();
|
||||
while ((p = aName.FirstLocationNotInSet(s, p2, e))) {
|
||||
aName.SetValue(p, '_');
|
||||
@ -40,6 +41,7 @@ Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
|
||||
}
|
||||
aMap.Bind(TCollection_AsciiString(aValue->GetID()), aName);
|
||||
}
|
||||
}
|
||||
|
||||
// Get trace of restored study
|
||||
//SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
|
||||
@ -80,6 +82,19 @@ void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiStri
|
||||
myPythonScripts[theStudyID]->Append(theString);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* RemoveLastFromPythonScript
|
||||
*/
|
||||
//=============================================================================
|
||||
void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID)
|
||||
{
|
||||
if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
|
||||
int aLen = myPythonScripts[theStudyID]->Length();
|
||||
myPythonScripts[theStudyID]->Remove(aLen);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddToCurrentPyScript
|
||||
//purpose :
|
||||
@ -232,16 +247,6 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
||||
aScript += "\n";
|
||||
aScript += aNewLines;
|
||||
}
|
||||
// if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
|
||||
// aScript += "\n";
|
||||
// Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID];
|
||||
// Standard_Integer istr, aLen = aPythonScript->Length();
|
||||
// for (istr = 1; istr <= aLen; istr++) {
|
||||
// aScript += "\n\t";
|
||||
// aScript += aPythonScript->Value(istr);
|
||||
// }
|
||||
// aScript += "\n";
|
||||
// }
|
||||
|
||||
// Find entries to be replaced by names
|
||||
Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
|
||||
@ -251,9 +256,11 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
||||
return aScript;
|
||||
|
||||
// Replace entries by the names
|
||||
TColStd_SequenceOfAsciiString seqRemoved;
|
||||
Resource_DataMapOfAsciiStringAsciiString mapRemoved;
|
||||
Resource_DataMapOfAsciiStringAsciiString aNames;
|
||||
Standard_Integer objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
|
||||
TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("geomObj_");
|
||||
TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("smeshObj_");
|
||||
|
||||
for (Standard_Integer i = 1; i <= aLen; i += 2) {
|
||||
anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1);
|
||||
@ -271,10 +278,13 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
||||
theObjectNames(anEntry) = aName;
|
||||
}
|
||||
} else {
|
||||
// ? Removed Object ?
|
||||
do {
|
||||
aName = aBaseName + TCollection_AsciiString(++objectCounter);
|
||||
} while (theObjectNames.IsBound(aName));
|
||||
theObjectNames.Bind(anEntry, aName);
|
||||
seqRemoved.Append(aName);
|
||||
mapRemoved.Bind(anEntry, "1");
|
||||
}
|
||||
theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
|
||||
|
||||
@ -283,10 +293,19 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
||||
aStart = aSeq->Value(i + 1) + 1;
|
||||
}
|
||||
|
||||
// add final part of the script
|
||||
// add final part of aScript
|
||||
if (aSeq->Value(aLen) < aScriptLength)
|
||||
anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength);
|
||||
|
||||
// Remove removed objects
|
||||
anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()";
|
||||
for (int ir = 1; ir <= seqRemoved.Length(); ir++) {
|
||||
anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
|
||||
anUpdatedScript += seqRemoved.Value(ir);
|
||||
anUpdatedScript += "))\n\tif SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO)";
|
||||
}
|
||||
anUpdatedScript += "\n";
|
||||
|
||||
// Set object names
|
||||
anUpdatedScript += "\n\tisGUIMode = 1";
|
||||
anUpdatedScript += "\n\tif isGUIMode:";
|
||||
@ -297,13 +316,13 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
||||
Resource_DataMapOfAsciiStringAsciiString mapEntries;
|
||||
for (Standard_Integer i = 1; i <= aLen; i += 2) {
|
||||
anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
|
||||
if (theObjectNames.IsBound(anEntry) && !mapEntries.IsBound(anEntry)) {
|
||||
if (theObjectNames.IsBound(anEntry) &&
|
||||
!mapEntries.IsBound(anEntry) &&
|
||||
!mapRemoved.IsBound(anEntry)) {
|
||||
aName = theObjectNames.Find(anEntry);
|
||||
mapEntries.Bind(anEntry, aName);
|
||||
anUpdatedScript += "\n\t\tsmeshgui.SetName(salome.ObjectToID(";
|
||||
anUpdatedScript += aName + "), \"" + aName + "\")";
|
||||
//anUpdatedScript += "\n\t\tsmeshgui.SetName(\"";
|
||||
//anUpdatedScript += anEntry + "\", \"" + aName + "\")";
|
||||
}
|
||||
}
|
||||
anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)";
|
||||
|
@ -204,6 +204,13 @@ CORBA::Boolean SMESH_GroupBase_i::IsEmpty()
|
||||
|
||||
void SMESH_Group_i::Clear()
|
||||
{
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr;
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".Clear()";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
// Clear the group
|
||||
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
|
||||
if (aGroupDS) {
|
||||
aGroupDS->Clear();
|
||||
@ -235,6 +242,14 @@ CORBA::Boolean SMESH_GroupBase_i::Contains( CORBA::Long theID )
|
||||
|
||||
CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs )
|
||||
{
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr ("nbAdd = ");
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".Add(";
|
||||
SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
// Add elements to the group
|
||||
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
|
||||
if (aGroupDS) {
|
||||
int nbAdd = 0;
|
||||
@ -293,6 +308,14 @@ SMESH::long_array* SMESH_GroupBase_i::GetListOfID()
|
||||
|
||||
CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
|
||||
{
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr ("nbDel = ");
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove(";
|
||||
SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
// Remove elements from the group
|
||||
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
|
||||
if (aGroupDS) {
|
||||
int nbDel = 0;
|
||||
|
@ -337,21 +337,12 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubS
|
||||
if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status );
|
||||
|
||||
// Update Python script
|
||||
SALOMEDS::SObject_var aMeshSO = SMESH_Gen_i::ObjectToSObject(_gen_i->GetCurrentStudy(), _this());
|
||||
SALOMEDS::SObject_var aHypoSO = SMESH_Gen_i::ObjectToSObject(_gen_i->GetCurrentStudy(), anHyp);
|
||||
|
||||
TCollection_AsciiString aStr ("status = ");
|
||||
aStr += aMeshSO->GetID();
|
||||
aStr += ".AddHypothesis(salome.IDToObject(\"";
|
||||
aStr += aSubShapeObject->GetStudyEntry();
|
||||
aStr += "\"), ";
|
||||
aStr += aHypoSO->GetID();
|
||||
aStr += ")";
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".AddHypothesis(";
|
||||
SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", ";
|
||||
SMESH_Gen_i::AddObject(aStr, anHyp) += ")";
|
||||
|
||||
_gen_i->AddToPythonScript(_gen_i->GetCurrentStudy()->StudyId(), aStr);
|
||||
|
||||
aStr = "print \"AddHypothesis: \", status";
|
||||
_gen_i->AddToPythonScript(_gen_i->GetCurrentStudy()->StudyId(), aStr);
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
return ConvertHypothesisStatus(status);
|
||||
}
|
||||
@ -417,6 +408,14 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aS
|
||||
_gen_i->RemoveHypothesisFromShape(_gen_i->GetCurrentStudy(), _this(),
|
||||
aSubShapeObject, anHyp );
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr ("status = ");
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveHypothesis(";
|
||||
SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", ";
|
||||
SMESH_Gen_i::AddObject(aStr, anHyp) += ")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
return ConvertHypothesisStatus(status);
|
||||
}
|
||||
|
||||
@ -525,9 +524,21 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap
|
||||
if ( subMesh->_is_nil() )
|
||||
subMesh = createSubMesh( aSubShapeObject );
|
||||
|
||||
if ( _gen_i->CanPublishInStudy( subMesh ))
|
||||
_gen_i->PublishSubMesh (_gen_i->GetCurrentStudy(), aMesh,
|
||||
if ( _gen_i->CanPublishInStudy( subMesh )) {
|
||||
SALOMEDS::SObject_var aSO =
|
||||
_gen_i->PublishSubMesh(_gen_i->GetCurrentStudy(), aMesh,
|
||||
subMesh, aSubShapeObject, theName );
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr (aSO->GetID());
|
||||
aStr += " = ";
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".GetSubMesh(";
|
||||
SMESH_Gen_i::AddObject(aStr, aSubShapeObject) += ", \"";
|
||||
aStr += (char*)theName;
|
||||
aStr += "\")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
}
|
||||
}
|
||||
catch(SALOME_Exception & S_ex) {
|
||||
THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
|
||||
@ -560,12 +571,49 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
|
||||
aSubShapeObject = GEOM::GEOM_Object::_narrow( aRef->GetObject() );
|
||||
|
||||
aStudy->NewBuilder()->RemoveObjectWithChildren( anSO );
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr;
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveSubMesh(";
|
||||
aStr += anSO->GetID();
|
||||
aStr += ")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
}
|
||||
}
|
||||
|
||||
removeSubMesh( theSubMesh, aSubShapeObject.in() );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ElementTypeString
|
||||
*/
|
||||
//=============================================================================
|
||||
inline TCollection_AsciiString ElementTypeString (SMESH::ElementType theElemType)
|
||||
{
|
||||
TCollection_AsciiString aStr;
|
||||
switch (theElemType) {
|
||||
case SMESH::ALL:
|
||||
aStr = "SMESH.ALL";
|
||||
break;
|
||||
case SMESH::NODE:
|
||||
aStr = "SMESH.NODE";
|
||||
break;
|
||||
case SMESH::EDGE:
|
||||
aStr = "SMESH.EDGE";
|
||||
break;
|
||||
case SMESH::FACE:
|
||||
aStr = "SMESH.FACE";
|
||||
break;
|
||||
case SMESH::VOLUME:
|
||||
aStr = "SMESH.VOLUME";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return aStr;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
@ -581,9 +629,20 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType
|
||||
SMESH::SMESH_Group_var aNewGroup =
|
||||
SMESH::SMESH_Group::_narrow( createGroup( theElemType, theName ));
|
||||
|
||||
_gen_i->PublishGroup( _gen_i->GetCurrentStudy(), _this(),
|
||||
if ( _gen_i->CanPublishInStudy( aNewGroup ) ) {
|
||||
SALOMEDS::SObject_var aSO =
|
||||
_gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(),
|
||||
aNewGroup, GEOM::GEOM_Object::_nil(), theName);
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr (aSO->GetID());
|
||||
aStr += " = ";
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroup(";
|
||||
aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
}
|
||||
|
||||
return aNewGroup._retn();
|
||||
}
|
||||
|
||||
@ -593,7 +652,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM( SMESH::ElementType theElemType,
|
||||
SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM (SMESH::ElementType theElemType,
|
||||
const char* theName,
|
||||
GEOM::GEOM_Object_ptr theGeomObj)
|
||||
throw(SALOME::SALOME_Exception)
|
||||
@ -605,13 +664,25 @@ SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM( SMESH::ElementTy
|
||||
if ( !aShape.IsNull() ) {
|
||||
aNewGroup = SMESH::SMESH_GroupOnGeom::_narrow
|
||||
( createGroup( theElemType, theName, aShape ));
|
||||
if ( _gen_i->CanPublishInStudy( aNewGroup ) )
|
||||
_gen_i->PublishGroup( _gen_i->GetCurrentStudy(), _this(),
|
||||
aNewGroup, theGeomObj, theName );
|
||||
if ( _gen_i->CanPublishInStudy( aNewGroup ) ) {
|
||||
SALOMEDS::SObject_var aSO =
|
||||
_gen_i->PublishGroup(_gen_i->GetCurrentStudy(), _this(),
|
||||
aNewGroup, theGeomObj, theName);
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr (aSO->GetID());
|
||||
aStr += " = ";
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".CreateGroupFromGEOM(";
|
||||
aStr += ElementTypeString(theElemType) + ", \"" + (char*)theName + "\", ";
|
||||
SMESH_Gen_i::AddObject(aStr, theGeomObj) += ")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
}
|
||||
}
|
||||
|
||||
return aNewGroup._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
@ -631,11 +702,21 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
|
||||
|
||||
SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
|
||||
if ( !aStudy->_is_nil() ) {
|
||||
// Remove group's SObject
|
||||
SALOMEDS::SObject_var aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
|
||||
if ( !aGroupSO->_is_nil() )
|
||||
|
||||
if ( !aGroupSO->_is_nil() ) {
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr;
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveGroup(";
|
||||
aStr += aGroupSO->GetID();
|
||||
aStr += ")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
// Remove group's SObject
|
||||
aStudy->NewBuilder()->RemoveObject( aGroupSO );
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the group from SMESH data structures
|
||||
removeGroup( aGroup->GetLocalID() );
|
||||
@ -660,12 +741,25 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup
|
||||
SMESH::long_array_var anIds = aGroup->GetListOfID();
|
||||
SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr;
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".RemoveGroupWithContents(";
|
||||
SMESH_Gen_i::AddObject(aStr, theGroup) += ")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
// Remove contents
|
||||
if ( aGroup->GetType() == SMESH::NODE )
|
||||
aMeshEditor->RemoveNodes( anIds );
|
||||
else
|
||||
aMeshEditor->RemoveElements( anIds );
|
||||
|
||||
// Remove group
|
||||
RemoveGroup( theGroup );
|
||||
|
||||
// Clear python lines, created by RemoveNodes/Elements() and RemoveGroup()
|
||||
_gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId());
|
||||
_gen_i->RemoveLastFromPythonScript(_gen_i->GetCurrentStudy()->StudyId());
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -681,13 +775,12 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the
|
||||
{
|
||||
try
|
||||
{
|
||||
SMESH::SMESH_Group_var aResGrp;
|
||||
|
||||
if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
|
||||
theGroup1->GetType() != theGroup2->GetType() )
|
||||
return SMESH::SMESH_Group::_nil();
|
||||
|
||||
aResGrp = CreateGroup( theGroup1->GetType(), theName );
|
||||
// Create Union
|
||||
SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
|
||||
if ( aResGrp->_is_nil() )
|
||||
return SMESH::SMESH_Group::_nil();
|
||||
|
||||
@ -712,6 +805,21 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the
|
||||
|
||||
aResGrp->Add( aResIds );
|
||||
|
||||
// Clear python lines, created by CreateGroup() and Add()
|
||||
SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
|
||||
_gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
|
||||
_gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr;
|
||||
SMESH_Gen_i::AddObject(aStr, aResGrp) += " = ";
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".UnionGroups(";
|
||||
SMESH_Gen_i::AddObject(aStr, theGroup1) += ", ";
|
||||
SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \"";
|
||||
aStr += TCollection_AsciiString((char*)theName) + "\")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
return aResGrp._retn();
|
||||
}
|
||||
catch( ... )
|
||||
@ -731,13 +839,12 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr
|
||||
const char* theName )
|
||||
throw (SALOME::SALOME_Exception)
|
||||
{
|
||||
SMESH::SMESH_Group_var aResGrp;
|
||||
|
||||
if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
|
||||
theGroup1->GetType() != theGroup2->GetType() )
|
||||
return aResGrp;
|
||||
return SMESH::SMESH_Group::_nil();
|
||||
|
||||
aResGrp = CreateGroup( theGroup1->GetType(), theName );
|
||||
// Create Intersection
|
||||
SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
|
||||
if ( aResGrp->_is_nil() )
|
||||
return aResGrp;
|
||||
|
||||
@ -763,6 +870,21 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr
|
||||
|
||||
aResGrp->Add( aResIds );
|
||||
|
||||
// Clear python lines, created by CreateGroup() and Add()
|
||||
SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
|
||||
_gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
|
||||
_gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr;
|
||||
SMESH_Gen_i::AddObject(aStr, aResGrp) += " = ";
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".IntersectGroups(";
|
||||
SMESH_Gen_i::AddObject(aStr, theGroup1) += ", ";
|
||||
SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \"";
|
||||
aStr += TCollection_AsciiString((char*)theName) + "\")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
return aResGrp._retn();
|
||||
}
|
||||
|
||||
@ -777,13 +899,12 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr
|
||||
const char* theName )
|
||||
throw (SALOME::SALOME_Exception)
|
||||
{
|
||||
SMESH::SMESH_Group_var aResGrp;
|
||||
|
||||
if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
|
||||
theGroup1->GetType() != theGroup2->GetType() )
|
||||
return aResGrp;
|
||||
return SMESH::SMESH_Group::_nil();
|
||||
|
||||
aResGrp = CreateGroup( theGroup1->GetType(), theName );
|
||||
// Perform Cutting
|
||||
SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName );
|
||||
if ( aResGrp->_is_nil() )
|
||||
return aResGrp;
|
||||
|
||||
@ -809,6 +930,21 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr
|
||||
|
||||
aResGrp->Add( aResIds );
|
||||
|
||||
// Clear python lines, created by CreateGroup() and Add()
|
||||
SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
|
||||
_gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
|
||||
_gen_i->RemoveLastFromPythonScript(aStudy->StudyId());
|
||||
|
||||
// Update Python script
|
||||
TCollection_AsciiString aStr;
|
||||
SMESH_Gen_i::AddObject(aStr, aResGrp) += " = ";
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".CutGroups(";
|
||||
SMESH_Gen_i::AddObject(aStr, theGroup1) += ", ";
|
||||
SMESH_Gen_i::AddObject(aStr, theGroup2) += ", \"";
|
||||
aStr += TCollection_AsciiString((char*)theName) + "\")";
|
||||
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
return aResGrp._retn();
|
||||
}
|
||||
|
||||
@ -1068,13 +1204,10 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl)
|
||||
SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
|
||||
{
|
||||
// Update Python script
|
||||
SALOMEDS::SObject_var aSO =
|
||||
SMESH_Gen_i::ObjectToSObject(_gen_i->GetCurrentStudy(), _this());
|
||||
TCollection_AsciiString aStr ("mesh_editor = ");
|
||||
aStr += aSO->GetID();
|
||||
aStr += ".GetMeshEditor()";
|
||||
SMESH_Gen_i::AddObject(aStr, _this()) += ".GetMeshEditor()";
|
||||
|
||||
_gen_i->AddToPythonScript(_gen_i->GetCurrentStudy()->StudyId(), aStr);
|
||||
SMESH_Gen_i::AddToCurrentPyScript(aStr);
|
||||
|
||||
// Create MeshEditor
|
||||
SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl );
|
||||
|
Loading…
Reference in New Issue
Block a user