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

This commit is contained in:
rnv 2008-09-16 12:11:37 +00:00
parent 8bfa9cdd5d
commit 9fe8334ee2
5 changed files with 432 additions and 217 deletions

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 );
@ -901,6 +913,26 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
if ( theCommand->GetMethod().Search("MakeMesh") != -1 ) if ( theCommand->GetMethod().Search("MakeMesh") != -1 )
_pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod() _pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod()
} }
else {
//Replace SMESH_MeshEditor "MakeGroups" functions on the Mesh
//functions with the flag "theMakeGroups = True" like:
//SMESH_MeshEditor.CmdMakeGroups => Mesh.Cmd(...,True)
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 { else {
// editor creation command is needed only if any editor function is called // editor creation command is needed only if any editor function is called
theGen->AddMeshAccessorMethod( theCommand ); // for *Object() theGen->AddMeshAccessorMethod( theCommand ); // for *Object()
@ -909,6 +941,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
myCreationCmdStr.Clear(); 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump<< this << ".RotationSweepMakeGroups( "
<< theIDsOfElements << theIDsOfElements
<< ", axis, " << ", axis, "
<< theAngleInRadians << ", " << theAngleInRadians << ", "
<< theNbOfSteps << ", " << theNbOfSteps << ", "
<< theTolerance << " )"; << 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump<< this << ".RotationSweepObjectMakeGroups( "
<< theObject << theObject
<< ", axis, " << ", axis, "
<< theAngleInRadians << ", " << theAngleInRadians << ", "
<< theNbOfSteps << ", " << theNbOfSteps << ", "
<< theTolerance << " )"; << 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepMakeGroups( "
<< theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; << 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( "
<< theObject << ", stepVector, " << theNbOfSteps << " )"; << 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( "
<< theObject << ", stepVector, " << theNbOfSteps << " )"; << 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( "
<< theObject << ", stepVector, " << theNbOfSteps << " )"; << 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".AdvancedExtrusionMakeGroups("
<< theIDsOfElements << theIDsOfElements
<< ", stepVector, " << ", stepVector, "
<< theNbOfSteps << "," << theNbOfSteps << ","
<< theExtrFlags << ", " << theExtrFlags << ", "
<< theSewTolerance << " )"; << 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,7 +2035,17 @@ 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;
TPythonDump aPythonDump;
if(isDumpGroups) {
aPythonDump << "("<<aGroups;
}
if(isDumpGroups)
aPythonDump << ", error)";
else
aPythonDump <<"error";
aPythonDump<<" = "<< this << ".ExtrusionAlongPathMakeGroups( "
<< theIDsOfElements << ", " << theIDsOfElements << ", "
<< thePathMesh << ", " << thePathMesh << ", "
<< thePathShape << ", " << thePathShape << ", "
@ -2010,16 +2054,7 @@ SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theI
<< "rotAngles" << ", " << "rotAngles" << ", "
<< theHasRefPoint << ", refPoint )"; << 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;
@ -2049,7 +2096,17 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
else else
TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )"; TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
TPythonDump() << "groups = " << this << ".ExtrusionAlongPathObjectMakeGroups( " bool isDumpGroups = aGroups && aGroups->length() > 0;
TPythonDump aPythonDump;
if(isDumpGroups) {
aPythonDump << "("<<aGroups;
}
if(isDumpGroups)
aPythonDump << ", error)";
else
aPythonDump <<"error";
aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
<< theObject << ", " << theObject << ", "
<< thePathMesh << ", " << thePathMesh << ", "
<< thePathShape << ", " << thePathShape << ", "
@ -2058,17 +2115,7 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
<< "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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".MirrorMakeGroups( "
<< theIDsOfElements << ", " << theIDsOfElements << ", "
<< theMirror << ", " << theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )"; << 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)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << this << ".MirrorObjectMakeGroups( " TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".MirrorObjectMakeGroups( "
<< theObject << ", " << theObject << ", "
<< theMirror << ", " << theMirror << ", "
<< mirrorTypeName(theMirrorType) << " )"; << mirrorTypeName(theMirrorType) << " )";
} }
SMESH::long_array_var anElementsId = theObject->GetIDs(); return aGroups;
return mirror(anElementsId, theMirror, theMirrorType, true, true);
} }
//======================================================================= //=======================================================================
@ -2279,11 +2332,16 @@ SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfE
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
const char* theMeshName) const char* theMeshName)
{ {
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 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();
@ -2297,6 +2355,12 @@ SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array& theIDsOfE
<< theCopyGroups << ", '" << theCopyGroups << ", '"
<< theMeshName << "' )"; << theMeshName << "' )";
} }
}
//dump "GetGroups"
if(!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn(); return mesh._retn();
} }
@ -2312,16 +2376,22 @@ SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr the
CORBA::Boolean theCopyGroups, CORBA::Boolean theCopyGroups,
const char* theMeshName) const char* theMeshName)
{ {
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 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 ) { if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( " pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
<< theObject << ", " << theObject << ", "
@ -2330,6 +2400,12 @@ SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr the
<< theCopyGroups << ", '" << theCopyGroups << ", '"
<< theMeshName << "' )"; << 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".TranslateMakeGroups( "
<< theIDsOfElements << theIDsOfElements
<< ", vector )"; << ", 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)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = translate(anElementsId, theVector, true, true);
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
TPythonDump() << "vector = " << theVector; TPythonDump() << "vector = " << theVector;
TPythonDump() << this << ".TranslateObjectMakeGroups( " TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".TranslateObjectMakeGroups( "
<< theObject << theObject
<< ", vector )"; << ", vector )";
} }
SMESH::long_array_var anElementsId = theObject->GetIDs(); return aGroups;
return translate(anElementsId, theVector, true, true);
} }
//======================================================================= //=======================================================================
@ -2456,14 +2540,23 @@ 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;
if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) { { // open new scope to dump "MakeMesh" command
// and then "GetGroups" using SMESH_Mesh::GetGroups()
TPythonDump pydump; // to prevent dump at mesh creation
mesh = makeMesh( theMeshName );
mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
if ( mesh_i ) {
translate(theIDsOfElements, theVector, translate(theIDsOfElements, theVector,
false, theCopyGroups, & mesh_i->GetImpl()); false, theCopyGroups, & mesh_i->GetImpl());
mesh_i->CreateGroupServants(); mesh_i->CreateGroupServants();
} }
if ( !myPreviewMode ) { if ( !myPreviewMode ) {
pydump << mesh << " = " << this << ".TranslateMakeMesh( " pydump << mesh << " = " << this << ".TranslateMakeMesh( "
<< theIDsOfElements << ", " << theIDsOfElements << ", "
@ -2471,6 +2564,12 @@ SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
<< theCopyGroups << ", '" << theCopyGroups << ", '"
<< theMeshName << "' )"; << theMeshName << "' )";
} }
}
//dump "GetGroups"
if(!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn(); return mesh._retn();
} }
@ -2485,10 +2584,16 @@ 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
// 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
mesh = makeMesh( theMeshName );
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();
translate(anElementsId, theVector, translate(anElementsId, theVector,
false, theCopyGroups, & mesh_i->GetImpl()); false, theCopyGroups, & mesh_i->GetImpl());
@ -2501,6 +2606,12 @@ SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
<< theCopyGroups << ", '" << theCopyGroups << ", '"
<< theMeshName << "' )"; << 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;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".RotateMakeGroups( "
<< theIDsOfElements << theIDsOfElements
<< ", axis, " << ", axis, "
<< theAngle << " )"; << 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,10 +2760,18 @@ 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
// and then "GetGroups" using SMESH_Mesh::GetGroups()
TPythonDump pydump; // to prevent dump at mesh creation
mesh = makeMesh( theMeshName );
mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
if ( mesh_i ) {
rotate(theIDsOfElements, theAxis, theAngleInRadians, rotate(theIDsOfElements, theAxis, theAngleInRadians,
false, theCopyGroups, & mesh_i->GetImpl()); false, theCopyGroups, & mesh_i->GetImpl());
mesh_i->CreateGroupServants(); mesh_i->CreateGroupServants();
@ -2658,6 +2784,12 @@ SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
<< theCopyGroups << ", '" << theCopyGroups << ", '"
<< theMeshName << "' )"; << theMeshName << "' )";
} }
}
//dump "GetGroups"
if(!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn(); return mesh._retn();
} }
@ -2673,10 +2805,17 @@ 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
// and then "GetGroups" using SMESH_Mesh::GetGroups()
TPythonDump pydump; // to prevent dump at mesh creation
mesh = makeMesh( theMeshName );
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();
rotate(anElementsId, theAxis, theAngleInRadians, rotate(anElementsId, theAxis, theAngleInRadians,
false, theCopyGroups, & mesh_i->GetImpl()); false, theCopyGroups, & mesh_i->GetImpl());
@ -2690,6 +2829,12 @@ SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
<< theCopyGroups << ", '" << theCopyGroups << ", '"
<< theMeshName << "' )"; << 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;
@ -487,6 +487,9 @@ private: //!< private methods
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
SMESH_Mesh_i* myMesh_i; SMESH_Mesh_i* myMesh_i;

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"; }