Fix for issue 19964 EDF SMESH 803( Bad dump script of revolutionned mesh with groups).

This commit is contained in:
rnv 2008-09-17 10:31:27 +00:00
parent c243e78505
commit 6eb4c26173
6 changed files with 434 additions and 218 deletions

View File

@ -742,6 +742,7 @@ salome.sg.updateObjBrowser(1)
\code \code
import math import math
import SMESH
import SMESH_mechanic import SMESH_mechanic
@ -750,7 +751,7 @@ smesh = SMESH_mechanic.smesh
# create a group of faces to be revolved # create a group of faces to be revolved
FacesRotate = [492, 493, 502, 503] FacesRotate = [492, 493, 502, 503]
GroupRotate = mesh.CreateGroup(SMESH.FACE,"Group of faces (rotate)") GroupRotate = mesh.CreateEmptyGroup(SMESH.FACE,"Group of faces (rotate)")
GroupRotate.Add(FacesRotate) GroupRotate.Add(FacesRotate)
# define revolution angle and axis # define revolution angle and axis

View File

@ -893,6 +893,18 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
sameMethods.Insert( names ); sameMethods.Insert( names );
} }
// names of SMESH_MeshEditor methods which differ from methods of class Mesh
// only last two arguments
static TStringSet diffLastTwoArgsMethods;
if (diffLastTwoArgsMethods.empty() ){
const char * names[] = {
"MirrorMakeGroups","MirrorObjectMakeGroups",
"TranslateMakeGroups","TranslateObjectMakeGroups",
"RotateMakeGroups","RotateObjectMakeGroups",
""};// <- mark of the end
diffLastTwoArgsMethods.Insert( names );
}
if ( sameMethods.Contains( theCommand->GetMethod() )) { if ( sameMethods.Contains( theCommand->GetMethod() )) {
theCommand->SetObject( myMesh ); theCommand->SetObject( myMesh );
@ -902,11 +914,32 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
_pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod() _pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod()
} }
else { else {
// editor creation command is needed only if any editor function is called
theGen->AddMeshAccessorMethod( theCommand ); // for *Object() //Replace SMESH_MeshEditor "MakeGroups" functions on the Mesh
if ( !myCreationCmdStr.IsEmpty() ) { //functions with the flag "theMakeGroups = True" like:
GetCreationCmd()->GetString() = myCreationCmdStr; //SMESH_MeshEditor.CmdMakeGroups => Mesh.Cmd(...,True)
myCreationCmdStr.Clear(); int pos = theCommand->GetMethod().Search("MakeGroups");
if( pos != -1) {
// 1. Remove "MakeGroups" from the Command
TCollection_AsciiString aMethod = theCommand->GetMethod();
int nbArgsToAdd = diffLastTwoArgsMethods.Contains(aMethod) ? 2 : 1;
aMethod.Trunc(pos-1);
theCommand->SetMethod(aMethod);
// 2. Set Mesh object instead SMESH_MeshEditor
theCommand->SetObject( myMesh );
// 3. And add last "True" argument
while(nbArgsToAdd--)
theCommand->SetArg(theCommand->GetNbArgs()+1,"True ");
}
else {
// editor creation command is needed only if any editor function is called
theGen->AddMeshAccessorMethod( theCommand ); // for *Object()
if ( !myCreationCmdStr.IsEmpty() ) {
GetCreationCmd()->GetString() = myCreationCmdStr;
myCreationCmdStr.Clear();
}
} }
} }
} }

View File

@ -296,6 +296,24 @@ namespace SMESH
return *this; return *this;
} }
TPythonDump& TPythonDump::operator<<(const SMESH::ListOfGroups * theList){
if(theList && theList->length() > 0 ) {
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
myStream << "[";
int aListLen = theList->length();
for(int i = 0 ; i < aListLen; i++){
SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,(*theList)[i]);
if(!aSObject->_is_nil()) {
myStream << aSObject->GetID();
i < (aListLen - 1) ? myStream<<", " : myStream<<"]";
}
}
}
return *this;
}
TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" ); TCollection_AsciiString myLongStringStart( "TPythonDump::LongStringStart" );
TCollection_AsciiString myLongStringEnd ( "TPythonDump::LongStringEnd" ); TCollection_AsciiString myLongStringEnd ( "TPythonDump::LongStringEnd" );

View File

@ -1429,21 +1429,24 @@ SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfEle
CORBA::Long theNbOfSteps, CORBA::Long theNbOfSteps,
CORBA::Double theTolerance) CORBA::Double theTolerance)
{ {
SMESH::ListOfGroups *aGroups = rotationSweep(theIDsOfElements,
theAxis,
theAngleInRadians,
theNbOfSteps,
theTolerance,
true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "axis = " << theAxis; TPythonDump()<< "axis = " << theAxis;
TPythonDump() << this << ".RotationSweepMakeGroups( " TPythonDump aPythonDump;
<< theIDsOfElements DumpGroupsList(aPythonDump,aGroups);
<< ", axis, " aPythonDump<< this << ".RotationSweepMakeGroups( "
<< theAngleInRadians << ", " << theIDsOfElements
<< theNbOfSteps << ", " << ", axis, "
<< theTolerance << " )"; << theAngleInRadians << ", "
<< theNbOfSteps << ", "
<< theTolerance << " )";
} }
return rotationSweep(theIDsOfElements, return aGroups;
theAxis,
theAngleInRadians,
theNbOfSteps,
theTolerance,
true);
} }
//======================================================================= //=======================================================================
@ -1487,22 +1490,25 @@ SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theO
CORBA::Long theNbOfSteps, CORBA::Long theNbOfSteps,
CORBA::Double theTolerance) CORBA::Double theTolerance)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
theAxis,
theAngleInRadians,
theNbOfSteps,
theTolerance,
true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "axis = " << theAxis; TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".RotationSweepObjectMakeGroups( " TPythonDump aPythonDump;
<< theObject DumpGroupsList(aPythonDump,aGroups);
<< ", axis, " aPythonDump<< this << ".RotationSweepObjectMakeGroups( "
<< theAngleInRadians << ", " << theObject
<< theNbOfSteps << ", " << ", axis, "
<< theTolerance << " )"; << theAngleInRadians << ", "
<< theNbOfSteps << ", "
<< theTolerance << " )";
} }
SMESH::long_array_var anElementsId = theObject->GetIDs(); return aGroups;
return rotationSweep(anElementsId,
theAxis,
theAngleInRadians,
theNbOfSteps,
theTolerance,
true);
} }
@ -1628,12 +1634,16 @@ SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfEl
const SMESH::DirStruct& theStepVector, const SMESH::DirStruct& theStepVector,
CORBA::Long theNbOfSteps) CORBA::Long theNbOfSteps)
{ {
SMESH::ListOfGroups* aGroups = extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true );
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweepMakeGroups( " TPythonDump aPythonDump;
<< theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepMakeGroups( "
<< theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
} }
return extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true ); return aGroups;
} }
//======================================================================= //=======================================================================
//function : ExtrusionSweepObjectMakeGroups //function : ExtrusionSweepObjectMakeGroups
@ -1645,13 +1655,17 @@ SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr the
const SMESH::DirStruct& theStepVector, const SMESH::DirStruct& theStepVector,
CORBA::Long theNbOfSteps) CORBA::Long theNbOfSteps)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true );
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweepObjectMakeGroups( " TPythonDump aPythonDump;
<< theObject << ", stepVector, " << theNbOfSteps << " )"; DumpGroupsList(aPythonDump,aGroups);
aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( "
<< theObject << ", stepVector, " << theNbOfSteps << " )";
} }
SMESH::long_array_var anElementsId = theObject->GetIDs(); return aGroups;
return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true );
} }
//======================================================================= //=======================================================================
@ -1664,13 +1678,16 @@ SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr t
const SMESH::DirStruct& theStepVector, const SMESH::DirStruct& theStepVector,
CORBA::Long theNbOfSteps) CORBA::Long theNbOfSteps)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge );
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweepObject1DMakeGroups( " TPythonDump aPythonDump;
<< theObject << ", stepVector, " << theNbOfSteps << " )"; DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( "
<< theObject << ", stepVector, " << theNbOfSteps << " )";
} }
SMESH::long_array_var anElementsId = theObject->GetIDs(); return aGroups;
return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge );
} }
//======================================================================= //=======================================================================
@ -1683,13 +1700,16 @@ SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr t
const SMESH::DirStruct& theStepVector, const SMESH::DirStruct& theStepVector,
CORBA::Long theNbOfSteps) CORBA::Long theNbOfSteps)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face );
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweepObject2DMakeGroups( " TPythonDump aPythonDump;
<< theObject << ", stepVector, " << theNbOfSteps << " )"; DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( "
<< theObject << ", stepVector, " << theNbOfSteps << " )";
} }
SMESH::long_array_var anElementsId = theObject->GetIDs(); return aGroups;
return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face );
} }
@ -1764,21 +1784,25 @@ SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsO
CORBA::Long theExtrFlags, CORBA::Long theExtrFlags,
CORBA::Double theSewTolerance) CORBA::Double theSewTolerance)
{ {
SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
theStepVector,
theNbOfSteps,
theExtrFlags,
theSewTolerance,
true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".AdvancedExtrusionMakeGroups(" TPythonDump aPythonDump;
<< theIDsOfElements DumpGroupsList(aPythonDump,aGroups);
<< ", stepVector, " aPythonDump << this << ".AdvancedExtrusionMakeGroups("
<< theNbOfSteps << "," << theIDsOfElements
<< theExtrFlags << ", " << ", stepVector, "
<< theSewTolerance << " )"; << theNbOfSteps << ","
<< theExtrFlags << ", "
<< theSewTolerance << " )";
} }
return advancedExtrusion( theIDsOfElements, return aGroups;
theStepVector,
theNbOfSteps,
theExtrFlags,
theSewTolerance,
true);
} }
@ -1990,6 +2014,16 @@ SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theI
const SMESH::PointStruct& theRefPoint, const SMESH::PointStruct& theRefPoint,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error) SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
{ {
SMESH::ListOfGroups * aGroups = extrusionAlongPath( theIDsOfElements,
thePathMesh,
thePathShape,
theNodeStart,
theHasAngles,
theAngles,
theHasRefPoint,
theRefPoint,
true,
Error);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "rotAngles = " << theAngles; TPythonDump() << "rotAngles = " << theAngles;
@ -2001,25 +2035,26 @@ SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theI
else else
TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )"; TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
TPythonDump() << "groups = " << this << ".ExtrusionAlongPathMakeGroups( " bool isDumpGroups = aGroups && aGroups->length() > 0;
<< theIDsOfElements << ", " TPythonDump aPythonDump;
<< thePathMesh << ", " if(isDumpGroups) {
<< thePathShape << ", " aPythonDump << "("<<aGroups;
<< theNodeStart << ", " }
<< theHasAngles << ", " if(isDumpGroups)
<< "rotAngles" << ", " aPythonDump << ", error)";
<< theHasRefPoint << ", refPoint )"; else
aPythonDump <<"error";
aPythonDump<<" = "<< this << ".ExtrusionAlongPathMakeGroups( "
<< theIDsOfElements << ", "
<< thePathMesh << ", "
<< thePathShape << ", "
<< theNodeStart << ", "
<< theHasAngles << ", "
<< "rotAngles" << ", "
<< theHasRefPoint << ", refPoint )";
} }
return extrusionAlongPath( theIDsOfElements, return aGroups;
thePathMesh,
thePathShape,
theNodeStart,
theHasAngles,
theAngles,
theHasRefPoint,
theRefPoint,
true,
Error);
} }
//======================================================================= //=======================================================================
@ -2038,6 +2073,18 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
const SMESH::PointStruct& theRefPoint, const SMESH::PointStruct& theRefPoint,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error) SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
thePathMesh,
thePathShape,
theNodeStart,
theHasAngles,
theAngles,
theHasRefPoint,
theRefPoint,
true,
Error);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "rotAngles = " << theAngles; TPythonDump() << "rotAngles = " << theAngles;
@ -2048,27 +2095,27 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
<< theRefPoint.z << " )"; << theRefPoint.z << " )";
else else
TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )"; TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
bool isDumpGroups = aGroups && aGroups->length() > 0;
TPythonDump aPythonDump;
if(isDumpGroups) {
aPythonDump << "("<<aGroups;
}
if(isDumpGroups)
aPythonDump << ", error)";
else
aPythonDump <<"error";
TPythonDump() << "groups = " << this << ".ExtrusionAlongPathObjectMakeGroups( " aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
<< theObject << ", " << theObject << ", "
<< thePathMesh << ", " << thePathMesh << ", "
<< thePathShape << ", " << thePathShape << ", "
<< theNodeStart << ", " << theNodeStart << ", "
<< theHasAngles << ", " << theHasAngles << ", "
<< "rotAngles" << ", " << "rotAngles" << ", "
<< theHasRefPoint << ", refPoint )"; << theHasRefPoint << ", refPoint )";
} }
SMESH::long_array_var anElementsId = theObject->GetIDs(); return aGroups;
return extrusionAlongPath( anElementsId,
thePathMesh,
thePathShape,
theNodeStart,
theHasAngles,
theAngles,
theHasRefPoint,
theRefPoint,
true,
Error);
} }
//================================================================================ //================================================================================
@ -2238,13 +2285,16 @@ SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsO
const SMESH::AxisStruct& theMirror, const SMESH::AxisStruct& theMirror,
SMESH::SMESH_MeshEditor::MirrorType theMirrorType) SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
{ {
SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << this << ".MirrorMakeGroups( " TPythonDump aPythonDump;
<< theIDsOfElements << ", " DumpGroupsList(aPythonDump,aGroups);
<< theMirror << ", " aPythonDump << this << ".MirrorMakeGroups( "
<< mirrorTypeName(theMirrorType) << " )"; << theIDsOfElements << ", "
<< theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )";
} }
return mirror(theIDsOfElements, theMirror, theMirrorType, true, true); return aGroups;
} }
//======================================================================= //=======================================================================
@ -2257,14 +2307,17 @@ SMESH_MeshEditor_i::MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr t
const SMESH::AxisStruct& theMirror, const SMESH::AxisStruct& theMirror,
SMESH::SMESH_MeshEditor::MirrorType theMirrorType) SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
{ {
if ( !myPreviewMode ) {
TPythonDump() << this << ".MirrorObjectMakeGroups( "
<< theObject << ", "
<< theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )";
}
SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::long_array_var anElementsId = theObject->GetIDs();
return mirror(anElementsId, theMirror, theMirrorType, true, true); SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true);
if ( !myPreviewMode ) {
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".MirrorObjectMakeGroups( "
<< theObject << ", "
<< theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )";
}
return aGroups;
} }
//======================================================================= //=======================================================================
@ -2279,24 +2332,35 @@ SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfE
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
const char* theMeshName) const char* theMeshName)
{ {
TPythonDump pydump; // to prevent dump at mesh creation SMESH_Mesh_i* mesh_i;
SMESH::SMESH_Mesh_var mesh;
{ // open new scope to dump "MakeMesh" command
// and then "GetGroups" using SMESH_Mesh::GetGroups()
TPythonDump pydump; // to prevent dump at mesh creation
SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName ); mesh = makeMesh( theMeshName );
if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
{ if (mesh_i) {
mirror(theIDsOfElements, theMirror, theMirrorType, mirror(theIDsOfElements, theMirror, theMirrorType,
false, theCopyGroups, & mesh_i->GetImpl()); false, theCopyGroups, & mesh_i->GetImpl());
mesh_i->CreateGroupServants(); mesh_i->CreateGroupServants();
}
if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".MirrorMakeMesh( "
<< theIDsOfElements << ", "
<< theMirror << ", "
<< mirrorTypeName(theMirrorType) << ", "
<< theCopyGroups << ", '"
<< theMeshName << "' )";
}
} }
if ( !myPreviewMode ) { //dump "GetGroups"
pydump << mesh << " = " << this << ".MirrorMakeMesh( " if(!myPreviewMode && mesh_i)
<< theIDsOfElements << ", " mesh_i->GetGroups();
<< theMirror << ", "
<< mirrorTypeName(theMirrorType) << ", "
<< theCopyGroups << ", '"
<< theMeshName << "' )";
}
return mesh._retn(); return mesh._retn();
} }
@ -2312,24 +2376,36 @@ SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr the
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
const char* theMeshName) const char* theMeshName)
{ {
TPythonDump pydump; // to prevent dump at mesh creation SMESH_Mesh_i* mesh_i;
SMESH::SMESH_Mesh_var mesh;
{ // open new scope to dump "MakeMesh" command
// and then "GetGroups" using SMESH_Mesh::GetGroups()
TPythonDump pydump; // to prevent dump at mesh creation
SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName ); mesh = makeMesh( theMeshName );
if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
{ if ( mesh_i ) {
SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::long_array_var anElementsId = theObject->GetIDs();
mirror(anElementsId, theMirror, theMirrorType, mirror(anElementsId, theMirror, theMirrorType,
false, theCopyGroups, & mesh_i->GetImpl()); false, theCopyGroups, & mesh_i->GetImpl());
mesh_i->CreateGroupServants(); mesh_i->CreateGroupServants();
} }
if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( " if ( !myPreviewMode ) {
<< theObject << ", " pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
<< theMirror << ", " << theObject << ", "
<< mirrorTypeName(theMirrorType) << ", " << theMirror << ", "
<< theCopyGroups << ", '" << mirrorTypeName(theMirrorType) << ", "
<< theMeshName << "' )"; << theCopyGroups << ", '"
} << theMeshName << "' )";
}
}
//dump "GetGroups"
if(!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn(); return mesh._retn();
} }
@ -2417,13 +2493,16 @@ SMESH::ListOfGroups*
SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements, SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
const SMESH::DirStruct& theVector) const SMESH::DirStruct& theVector)
{ {
SMESH::ListOfGroups * aGroups = translate(theIDsOfElements,theVector,true,true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "vector = " << theVector; TPythonDump() << "vector = " << theVector;
TPythonDump() << this << ".TranslateMakeGroups( " TPythonDump aPythonDump;
<< theIDsOfElements DumpGroupsList(aPythonDump,aGroups);
<< ", vector )"; aPythonDump << this << ".TranslateMakeGroups( "
<< theIDsOfElements
<< ", vector )";
} }
return translate(theIDsOfElements,theVector,true,true); return aGroups;
} }
//======================================================================= //=======================================================================
@ -2435,14 +2514,19 @@ SMESH::ListOfGroups*
SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
const SMESH::DirStruct& theVector) const SMESH::DirStruct& theVector)
{ {
if ( !myPreviewMode ) {
TPythonDump() << "vector = " << theVector;
TPythonDump() << this << ".TranslateObjectMakeGroups( "
<< theObject
<< ", vector )";
}
SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::long_array_var anElementsId = theObject->GetIDs();
return translate(anElementsId, theVector, true, true); SMESH::ListOfGroups * aGroups = translate(anElementsId, theVector, true, true);
if ( !myPreviewMode ) {
TPythonDump() << "vector = " << theVector;
TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".TranslateObjectMakeGroups( "
<< theObject
<< ", vector )";
}
return aGroups;
} }
//======================================================================= //=======================================================================
@ -2456,21 +2540,36 @@ SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
const char* theMeshName) const char* theMeshName)
{ {
TPythonDump pydump; // to prevent dump at mesh creation SMESH_Mesh_i* mesh_i;
SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName ); SMESH::SMESH_Mesh_var mesh;
{ // open new scope to dump "MakeMesh" command
// and then "GetGroups" using SMESH_Mesh::GetGroups()
if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) { TPythonDump pydump; // to prevent dump at mesh creation
translate(theIDsOfElements, theVector,
false, theCopyGroups, & mesh_i->GetImpl()); mesh = makeMesh( theMeshName );
mesh_i->CreateGroupServants(); mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
}
if ( !myPreviewMode ) { if ( mesh_i ) {
pydump << mesh << " = " << this << ".TranslateMakeMesh( " translate(theIDsOfElements, theVector,
<< theIDsOfElements << ", " false, theCopyGroups, & mesh_i->GetImpl());
<< theVector << ", " mesh_i->CreateGroupServants();
<< theCopyGroups << ", '" }
<< theMeshName << "' )";
if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".TranslateMakeMesh( "
<< theIDsOfElements << ", "
<< theVector << ", "
<< theCopyGroups << ", '"
<< theMeshName << "' )";
}
} }
//dump "GetGroups"
if(!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn(); return mesh._retn();
} }
@ -2485,22 +2584,34 @@ SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
const char* theMeshName) const char* theMeshName)
{ {
TPythonDump pydump; // to prevent dump at mesh creation SMESH_Mesh_i* mesh_i;
SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName ); SMESH::SMESH_Mesh_var mesh;
{ // open new scope to dump "MakeMesh" command
if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) { // and then "GetGroups" using SMESH_Mesh::GetGroups()
SMESH::long_array_var anElementsId = theObject->GetIDs();
translate(anElementsId, theVector, TPythonDump pydump; // to prevent dump at mesh creation
false, theCopyGroups, & mesh_i->GetImpl()); mesh = makeMesh( theMeshName );
mesh_i->CreateGroupServants(); mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
}
if ( !myPreviewMode ) { if ( mesh_i ) {
pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( " SMESH::long_array_var anElementsId = theObject->GetIDs();
<< theObject << ", " translate(anElementsId, theVector,
<< theVector << ", " false, theCopyGroups, & mesh_i->GetImpl());
<< theCopyGroups << ", '" mesh_i->CreateGroupServants();
<< theMeshName << "' )"; }
if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
<< theObject << ", "
<< theVector << ", "
<< theCopyGroups << ", '"
<< theMeshName << "' )";
}
} }
//dump "GetGroups"
if(!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn(); return mesh._retn();
} }
@ -2599,14 +2710,17 @@ SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
const SMESH::AxisStruct& theAxis, const SMESH::AxisStruct& theAxis,
CORBA::Double theAngle) CORBA::Double theAngle)
{ {
SMESH::ListOfGroups * aGroups = rotate(theIDsOfElements,theAxis,theAngle,true,true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "axis = " << theAxis; TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".RotateMakeGroups( " TPythonDump aPythonDump;
<< theIDsOfElements DumpGroupsList(aPythonDump,aGroups);
<< ", axis, " aPythonDump << this << ".RotateMakeGroups( "
<< theAngle << " )"; << theIDsOfElements
<< ", axis, "
<< theAngle << " )";
} }
return rotate(theIDsOfElements,theAxis,theAngle,true,true); return aGroups;
} }
//======================================================================= //=======================================================================
@ -2619,15 +2733,19 @@ SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
const SMESH::AxisStruct& theAxis, const SMESH::AxisStruct& theAxis,
CORBA::Double theAngle) CORBA::Double theAngle)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = rotate(anElementsId,theAxis,theAngle,true,true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "axis = " << theAxis; TPythonDump() << "axis = " << theAxis;
TPythonDump() << this << ".RotateObjectMakeGroups( " TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".RotateObjectMakeGroups( "
<< theObject << theObject
<< ", axis, " << ", axis, "
<< theAngle << " )"; << theAngle << " )";
} }
SMESH::long_array_var anElementsId = theObject->GetIDs(); return aGroups;
return rotate(anElementsId,theAxis,theAngle,true,true);
} }
//======================================================================= //=======================================================================
@ -2642,22 +2760,36 @@ SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
const char* theMeshName) const char* theMeshName)
{ {
TPythonDump pydump; // to prevent dump at mesh creation SMESH::SMESH_Mesh_var mesh;
SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName ); SMESH_Mesh_i* mesh_i;
if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) { { // open new scope to dump "MakeMesh" command
rotate(theIDsOfElements, theAxis, theAngleInRadians, // and then "GetGroups" using SMESH_Mesh::GetGroups()
false, theCopyGroups, & mesh_i->GetImpl());
mesh_i->CreateGroupServants(); TPythonDump pydump; // to prevent dump at mesh creation
}
if ( !myPreviewMode ) { mesh = makeMesh( theMeshName );
pydump << mesh << " = " << this << ".RotateMakeMesh( " mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
<< theIDsOfElements << ", "
<< theAxis << ", " if ( mesh_i ) {
<< theAngleInRadians << ", " rotate(theIDsOfElements, theAxis, theAngleInRadians,
<< theCopyGroups << ", '" false, theCopyGroups, & mesh_i->GetImpl());
<< theMeshName << "' )"; mesh_i->CreateGroupServants();
}
if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".RotateMakeMesh( "
<< theIDsOfElements << ", "
<< theAxis << ", "
<< theAngleInRadians << ", "
<< theCopyGroups << ", '"
<< theMeshName << "' )";
}
} }
//dump "GetGroups"
if(!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn(); return mesh._retn();
} }
@ -2673,23 +2805,36 @@ SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
const char* theMeshName) const char* theMeshName)
{ {
TPythonDump pydump; // to prevent dump at mesh creation SMESH::SMESH_Mesh_var mesh;
SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName ); SMESH_Mesh_i* mesh_i;
if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) { {// open new scope to dump "MakeMesh" command
SMESH::long_array_var anElementsId = theObject->GetIDs(); // and then "GetGroups" using SMESH_Mesh::GetGroups()
rotate(anElementsId, theAxis, theAngleInRadians,
false, theCopyGroups, & mesh_i->GetImpl()); TPythonDump pydump; // to prevent dump at mesh creation
mesh_i->CreateGroupServants(); mesh = makeMesh( theMeshName );
} mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".RotateObjectMakeMesh( " if (mesh_i ) {
<< theObject << ", " SMESH::long_array_var anElementsId = theObject->GetIDs();
<< theAxis << ", " rotate(anElementsId, theAxis, theAngleInRadians,
<< theAngleInRadians << ", " false, theCopyGroups, & mesh_i->GetImpl());
<< theCopyGroups << ", '" mesh_i->CreateGroupServants();
<< theMeshName << "' )"; }
if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
<< theObject << ", "
<< theAxis << ", "
<< theAngleInRadians << ", "
<< theCopyGroups << ", '"
<< theMeshName << "' )";
}
} }
//dump "GetGroups"
if(!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn(); return mesh._retn();
} }
@ -3454,3 +3599,16 @@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::makeMesh(const char* theMeshName)
return mesh._retn(); return mesh._retn();
} }
//=======================================================================
//function : DumpGroupsList
//purpose :
//=======================================================================
void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
const SMESH::ListOfGroups * theGroupList)
{
bool isDumpGroupList = theGroupList && theGroupList->length() > 0;
if(isDumpGroupList) {
theDumpPython << theGroupList << " = ";
}
}

View File

@ -35,7 +35,7 @@
#include CORBA_SERVER_HEADER(SMESH_MeshEditor) #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
#include "SMESH_Mesh.hxx" #include "SMESH_Mesh.hxx"
#include "SMESH_PythonDump.hxx"
#include <list> #include <list>
class SMESH_MeshEditor; class SMESH_MeshEditor;
@ -486,6 +486,9 @@ private: //!< private methods
::SMESH_Mesh* TargetMesh=0); ::SMESH_Mesh* TargetMesh=0);
SMESH::SMESH_Mesh_ptr makeMesh(const char* theMeshName); SMESH::SMESH_Mesh_ptr makeMesh(const char* theMeshName);
void DumpGroupsList(SMESH::TPythonDump & theDumpPython,
const SMESH::ListOfGroups * theGroupList);
private: //!< fields private: //!< fields

View File

@ -147,6 +147,9 @@ namespace SMESH
TPythonDump& TPythonDump&
operator<<(const TCollection_AsciiString & theArg); operator<<(const TCollection_AsciiString & theArg);
TPythonDump&
operator<<(const SMESH::ListOfGroups * theList);
static char* SMESHGenName() { return "smeshgen"; } static char* SMESHGenName() { return "smeshgen"; }
static char* MeshEditorName() { return "mesh_editor"; } static char* MeshEditorName() { return "mesh_editor"; }