]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Fix for issue 19964 EDF SMESH 803( Bad dump script of revolutionned mesh with groups).
authorrnv <rnv@opencascade.com>
Tue, 16 Sep 2008 12:11:37 +0000 (12:11 +0000)
committerrnv <rnv@opencascade.com>
Tue, 16 Sep 2008 12:11:37 +0000 (12:11 +0000)
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_DumpPython.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx
src/SMESH_I/SMESH_PythonDump.hxx

index 96724a917b5d5d8b070906f614fefe60cf3399b8..cfa660a2c3f7882da212debfd7ff21b5f7a0176b 100644 (file)
@@ -893,6 +893,18 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
     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() )) {
     theCommand->SetObject( myMesh );
 
@@ -902,11 +914,32 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
       _pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod()
   }
   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();
+    
+    //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 {
+      // 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();
+      }
     }
   }
 }
index 5741b8dec9eafdcd1a622e120f53addc00bcb31a..1fee7112e64d408a5faeee03de017237a258f993 100644 (file)
@@ -296,6 +296,24 @@ namespace SMESH
     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 myLongStringEnd  ( "TPythonDump::LongStringEnd" );
 
index 064955be5a1403232b09bfa674e4f1d6c48b89d4..8e3093c91a3ce82025a08acb50b8d092af43b6a9 100644 (file)
@@ -1429,21 +1429,24 @@ SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfEle
                                             CORBA::Long              theNbOfSteps,
                                             CORBA::Double            theTolerance)
 {
+  SMESH::ListOfGroups *aGroups = rotationSweep(theIDsOfElements,
+                                               theAxis,
+                                               theAngleInRadians,
+                                               theNbOfSteps,
+                                               theTolerance,
+                                               true);
   if ( !myPreviewMode ) {
-    TPythonDump() << "axis = " << theAxis;
-    TPythonDump() << this << ".RotationSweepMakeGroups( "
-                  << theIDsOfElements
-                  << ", axis, "
-                  << theAngleInRadians << ", "
-                  << theNbOfSteps << ", "
-                  << theTolerance << " )";
+    TPythonDump()<< "axis = " << theAxis;
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump<< this << ".RotationSweepMakeGroups( "
+               << theIDsOfElements
+               << ", axis, "
+               << theAngleInRadians << ", "
+               << theNbOfSteps << ", "
+               << theTolerance << " )";
   }
-  return rotationSweep(theIDsOfElements,
-                       theAxis,
-                       theAngleInRadians,
-                       theNbOfSteps,
-                       theTolerance,
-                       true);
+  return aGroups;
 }
 
 //=======================================================================
@@ -1487,22 +1490,25 @@ SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theO
                                                   CORBA::Long               theNbOfSteps,
                                                   CORBA::Double             theTolerance)
 {
+  SMESH::long_array_var anElementsId = theObject->GetIDs();
+  SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
+                                               theAxis,
+                                               theAngleInRadians,
+                                               theNbOfSteps,
+                                               theTolerance,
+                                               true);
   if ( !myPreviewMode ) {
     TPythonDump() << "axis = " << theAxis;
-    TPythonDump() << this << ".RotationSweepObjectMakeGroups( "
-                  << theObject
-                  << ", axis, "
-                  << theAngleInRadians << ", "
-                  << theNbOfSteps << ", "
-                  << theTolerance << " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump<< this << ".RotationSweepObjectMakeGroups( "
+               << theObject
+               << ", axis, "
+               << theAngleInRadians << ", "
+               << theNbOfSteps << ", "
+               << theTolerance << " )";
   }
-  SMESH::long_array_var anElementsId = theObject->GetIDs();
-  return rotationSweep(anElementsId,
-                       theAxis,
-                       theAngleInRadians,
-                       theNbOfSteps,
-                       theTolerance,
-                       true);
+  return aGroups;
 }
 
 
@@ -1628,12 +1634,16 @@ SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfEl
                                              const SMESH::DirStruct&  theStepVector,
                                              CORBA::Long              theNbOfSteps)
 {
+  SMESH::ListOfGroups* aGroups = extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true );
+    
   if ( !myPreviewMode ) {
     TPythonDump() << "stepVector = " << theStepVector;
-    TPythonDump() << this << ".ExtrusionSweepMakeGroups( "
-                  << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump  << this << ".ExtrusionSweepMakeGroups( "
+                 << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
   }
-  return extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true );
+  return aGroups;
 }
 //=======================================================================
 //function : ExtrusionSweepObjectMakeGroups
@@ -1645,13 +1655,17 @@ SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr the
                                                    const SMESH::DirStruct&   theStepVector,
                                                    CORBA::Long               theNbOfSteps)
 {
+  SMESH::long_array_var anElementsId = theObject->GetIDs();
+  SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true );
+  
   if ( !myPreviewMode ) {
     TPythonDump() << "stepVector = " << theStepVector;
-    TPythonDump() << this << ".ExtrusionSweepObjectMakeGroups( "
-                  << theObject << ", stepVector, " << theNbOfSteps << " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( "
+               << theObject << ", stepVector, " << theNbOfSteps << " )";
   }
-  SMESH::long_array_var anElementsId = theObject->GetIDs();
-  return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true );
+  return aGroups;
 }
 
 //=======================================================================
@@ -1664,13 +1678,16 @@ SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr t
                                                      const SMESH::DirStruct&   theStepVector,
                                                      CORBA::Long               theNbOfSteps)
 {
+  SMESH::long_array_var anElementsId = theObject->GetIDs();
+  SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge );
   if ( !myPreviewMode ) {
     TPythonDump() << "stepVector = " << theStepVector;
-    TPythonDump() << this << ".ExtrusionSweepObject1DMakeGroups( "
-                  << theObject << ", stepVector, " << theNbOfSteps << " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( "
+                << theObject << ", stepVector, " << theNbOfSteps << " )";
   }
-  SMESH::long_array_var anElementsId = theObject->GetIDs();
-  return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge );
+  return aGroups;
 }
 
 //=======================================================================
@@ -1683,13 +1700,16 @@ SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr t
                                                      const SMESH::DirStruct&   theStepVector,
                                                      CORBA::Long               theNbOfSteps)
 {
+  SMESH::long_array_var anElementsId = theObject->GetIDs();
+  SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face );
   if ( !myPreviewMode ) {
     TPythonDump() << "stepVector = " << theStepVector;
-    TPythonDump() << this << ".ExtrusionSweepObject2DMakeGroups( "
-                  << theObject << ", stepVector, " << theNbOfSteps << " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( "
+                << theObject << ", stepVector, " << theNbOfSteps << " )";
   }
-  SMESH::long_array_var anElementsId = theObject->GetIDs();
-  return extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face );
+  return aGroups;
 }
 
 
@@ -1764,21 +1784,25 @@ SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsO
                                                 CORBA::Long              theExtrFlags,
                                                 CORBA::Double            theSewTolerance)
 {
+  SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
+                                                    theStepVector,
+                                                    theNbOfSteps,
+                                                    theExtrFlags,
+                                                    theSewTolerance,
+                                                    true);
+  
   if ( !myPreviewMode ) {
     TPythonDump() << "stepVector = " << theStepVector;
-    TPythonDump() << this << ".AdvancedExtrusionMakeGroups("
-                  << theIDsOfElements
-                  << ", stepVector, "
-                  << theNbOfSteps << ","
-                  << theExtrFlags << ", "
-                  << theSewTolerance <<  " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump << this << ".AdvancedExtrusionMakeGroups("
+                << theIDsOfElements
+                << ", stepVector, "
+                << theNbOfSteps << ","
+                << theExtrFlags << ", "
+                << theSewTolerance <<  " )";
   }
-  return advancedExtrusion( theIDsOfElements,
-                            theStepVector,
-                            theNbOfSteps,
-                            theExtrFlags,
-                            theSewTolerance,
-                            true);
+  return aGroups;
 }
 
 
@@ -1990,6 +2014,16 @@ SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array&   theI
                                                  const SMESH::PointStruct&  theRefPoint,
                                                  SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
 {
+    SMESH::ListOfGroups * aGroups =  extrusionAlongPath( theIDsOfElements,
+                                                         thePathMesh,
+                                                         thePathShape,
+                                                         theNodeStart,
+                                                         theHasAngles,
+                                                         theAngles,
+                                                         theHasRefPoint,
+                                                         theRefPoint,
+                                                         true,
+                                                         Error);
   if ( !myPreviewMode ) {
     TPythonDump() << "rotAngles = " << theAngles;
 
@@ -2001,25 +2035,26 @@ SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array&   theI
     else
       TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )";
 
-    TPythonDump() << "groups = " << this << ".ExtrusionAlongPathMakeGroups( "
-                  << theIDsOfElements << ", "
-                  << thePathMesh      << ", "
-                  << thePathShape     << ", "
-                  << theNodeStart     << ", "
-                  << theHasAngles     << ", "
-                  << "rotAngles"      << ", "
-                  << theHasRefPoint   << ", refPoint )";
+    bool isDumpGroups = aGroups && aGroups->length() > 0;
+    TPythonDump aPythonDump;
+    if(isDumpGroups) {
+      aPythonDump << "("<<aGroups;
+    }
+    if(isDumpGroups)
+      aPythonDump << ", error)";
+    else
+      aPythonDump <<"error";
+    
+    aPythonDump<<" = "<< this << ".ExtrusionAlongPathMakeGroups( "
+               << theIDsOfElements << ", "
+               << thePathMesh      << ", "
+               << thePathShape     << ", "
+               << theNodeStart     << ", "
+               << theHasAngles     << ", "
+               << "rotAngles"      << ", "
+               << theHasRefPoint   << ", refPoint )";
   }
-  return extrusionAlongPath( theIDsOfElements,
-                             thePathMesh,
-                             thePathShape,
-                             theNodeStart,
-                             theHasAngles,
-                             theAngles,
-                             theHasRefPoint,
-                             theRefPoint,
-                             true,
-                             Error);
+  return aGroups;
 }
 
 //=======================================================================
@@ -2038,6 +2073,18 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr  theObject,
                                    const SMESH::PointStruct&  theRefPoint,
                                    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 ) {
     TPythonDump() << "rotAngles = " << theAngles;
 
@@ -2048,27 +2095,27 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr  theObject,
                     << theRefPoint.z << " )";
     else
       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( "
-                  << theObject << ", "
-                  << thePathMesh      << ", "
-                  << thePathShape     << ", "
-                  << theNodeStart     << ", "
-                  << theHasAngles     << ", "
-                  << "rotAngles"      << ", "
-                  << theHasRefPoint   << ", refPoint )";
+    aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( "
+                << theObject << ", "
+                << thePathMesh      << ", "
+                << thePathShape     << ", "
+                << theNodeStart     << ", "
+                << theHasAngles     << ", "
+                << "rotAngles"      << ", "
+                << theHasRefPoint   << ", refPoint )";
   }
-  SMESH::long_array_var anElementsId = theObject->GetIDs();
-  return extrusionAlongPath( anElementsId,
-                             thePathMesh,
-                             thePathShape,
-                             theNodeStart,
-                             theHasAngles,
-                             theAngles,
-                             theHasRefPoint,
-                             theRefPoint,
-                             true,
-                             Error);
+  return aGroups;
 }
 
 //================================================================================
@@ -2238,13 +2285,16 @@ SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array&            theIDsO
                                      const SMESH::AxisStruct&            theMirror,
                                      SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
 {
+  SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true);
   if ( !myPreviewMode ) {
-    TPythonDump() << this << ".MirrorMakeGroups( "
-                  << theIDsOfElements << ", "
-                  << theMirror          << ", "
-                  << mirrorTypeName(theMirrorType) << " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump << this << ".MirrorMakeGroups( "
+                << 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,
                                            SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
 {
+  SMESH::long_array_var anElementsId = theObject->GetIDs();
+  SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true);
   if ( !myPreviewMode ) {
-    TPythonDump() << this << ".MirrorObjectMakeGroups( "
-                  << theObject << ", "
-                  << theMirror   << ", "
-                  << mirrorTypeName(theMirrorType) << " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump << this << ".MirrorObjectMakeGroups( "
+                << theObject << ", "
+                << theMirror   << ", "
+                << mirrorTypeName(theMirrorType) << " )";
   }
-  SMESH::long_array_var anElementsId = theObject->GetIDs();
-  return mirror(anElementsId, theMirror, theMirrorType, true, true);
+  return aGroups;
 }
 
 //=======================================================================
@@ -2279,24 +2332,35 @@ SMESH_MeshEditor_i::MirrorMakeMesh(const SMESH::long_array&            theIDsOfE
                                    CORBA::Boolean                      theCopyGroups,
                                    const char*                         theMeshName)
 {
-  TPythonDump pydump; // to prevent dump at mesh creation
-
-  SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName );
-  if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh ))
-  {
-    mirror(theIDsOfElements, theMirror, theMirrorType,
-           false, theCopyGroups, & mesh_i->GetImpl());
-    mesh_i->CreateGroupServants();
+  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
+
+    mesh = makeMesh( theMeshName );
+    mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+    if (mesh_i) {
+      mirror(theIDsOfElements, theMirror, theMirrorType,
+             false, theCopyGroups, & mesh_i->GetImpl());
+      mesh_i->CreateGroupServants();
+    }
+    
+    if ( !myPreviewMode ) {
+      pydump << mesh << " = " << this << ".MirrorMakeMesh( "
+             << theIDsOfElements << ", "
+             << theMirror   << ", "
+             << mirrorTypeName(theMirrorType) << ", "
+             << theCopyGroups << ", '"
+             << theMeshName << "' )";
+    }
   }
 
-  if ( !myPreviewMode ) {
-    pydump << mesh << " = " << this << ".MirrorMakeMesh( "
-           << theIDsOfElements << ", "
-           << theMirror   << ", "
-           << mirrorTypeName(theMirrorType) << ", "
-           << theCopyGroups << ", '"
-           << theMeshName << "' )";
-  }
+  //dump "GetGroups"
+  if(!myPreviewMode && mesh_i)
+    mesh_i->GetGroups();
+  
   return mesh._retn();
 }
 
@@ -2312,24 +2376,36 @@ SMESH_MeshEditor_i::MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr           the
                                          CORBA::Boolean                      theCopyGroups,
                                          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
+
+    mesh = makeMesh( theMeshName );
+    mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+    if ( mesh_i ) {
+      SMESH::long_array_var anElementsId = theObject->GetIDs();
+      mirror(anElementsId, theMirror, theMirrorType,
+             false, theCopyGroups, & mesh_i->GetImpl());
+      mesh_i->CreateGroupServants();
+    }
 
-  SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName );
-  if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh ))
-  {
-    SMESH::long_array_var anElementsId = theObject->GetIDs();
-    mirror(anElementsId, theMirror, theMirrorType,
-           false, theCopyGroups, & mesh_i->GetImpl());
-    mesh_i->CreateGroupServants();
-  }
-  if ( !myPreviewMode ) {
-    pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
-           << theObject << ", "
-           << theMirror   << ", "
-           << mirrorTypeName(theMirrorType) << ", "
-           << theCopyGroups << ", '"
-           << theMeshName << "' )";
-  }
+    if ( !myPreviewMode ) {
+      pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
+             << theObject << ", "
+             << theMirror   << ", "
+             << mirrorTypeName(theMirrorType) << ", "
+             << theCopyGroups << ", '"
+             << theMeshName << "' )";
+    }
+  } 
+
+  //dump "GetGroups"
+  if(!myPreviewMode && mesh_i)
+    mesh_i->GetGroups();
+  
   return mesh._retn();
 }
 
@@ -2417,13 +2493,16 @@ SMESH::ListOfGroups*
 SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
                                         const SMESH::DirStruct&  theVector)
 {
+  SMESH::ListOfGroups * aGroups = translate(theIDsOfElements,theVector,true,true);
   if ( !myPreviewMode ) {
     TPythonDump() << "vector = " << theVector;
-    TPythonDump() << this << ".TranslateMakeGroups( "
-                  << theIDsOfElements
-                  << ", vector )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    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,
                                               const SMESH::DirStruct&   theVector)
 {
+  SMESH::long_array_var anElementsId = theObject->GetIDs();
+  SMESH::ListOfGroups * aGroups = translate(anElementsId, theVector, true, true);
+  
   if ( !myPreviewMode ) {
+
     TPythonDump() << "vector = " << theVector;
-    TPythonDump() << this << ".TranslateObjectMakeGroups( "
-                  << theObject
-                  << ", vector )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump << this << ".TranslateObjectMakeGroups( "
+                << theObject
+                << ", vector )";
   }
-  SMESH::long_array_var anElementsId = theObject->GetIDs();
-  return translate(anElementsId, theVector, true, true);
+  return aGroups;
 }
 
 //=======================================================================
@@ -2456,21 +2540,36 @@ SMESH_MeshEditor_i::TranslateMakeMesh(const SMESH::long_array& theIDsOfElements,
                                       CORBA::Boolean           theCopyGroups,
                                       const char*              theMeshName)
 {
-  TPythonDump pydump; // to prevent dump at mesh creation
-  SMESH::SMESH_Mesh_var mesh = makeMesh( 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()
 
-  if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) {
-    translate(theIDsOfElements, theVector,
-              false, theCopyGroups, & mesh_i->GetImpl());
-    mesh_i->CreateGroupServants();
-  }
-  if ( !myPreviewMode ) {
-    pydump << mesh << " = " << this << ".TranslateMakeMesh( "
-           << theIDsOfElements << ", "
-           << theVector   << ", "
-           << theCopyGroups << ", '"
-           << theMeshName << "' )";
+    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,
+                false, theCopyGroups, & mesh_i->GetImpl());
+      mesh_i->CreateGroupServants();
+    }
+    
+    if ( !myPreviewMode ) {
+      pydump << mesh << " = " << this << ".TranslateMakeMesh( "
+             << theIDsOfElements << ", "
+             << theVector   << ", "
+             << theCopyGroups << ", '"
+             << theMeshName << "' )";
+    }
   }
+  
+  //dump "GetGroups"
+  if(!myPreviewMode && mesh_i)
+    mesh_i->GetGroups();
+  
   return mesh._retn();
 }
 
@@ -2485,22 +2584,34 @@ SMESH_MeshEditor_i::TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
                                             CORBA::Boolean            theCopyGroups,
                                             const char*               theMeshName)
 {
-  TPythonDump pydump; // to prevent dump at mesh creation
-  SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName );
-
-  if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) {
-    SMESH::long_array_var anElementsId = theObject->GetIDs();
-    translate(anElementsId, theVector,
-              false, theCopyGroups, & mesh_i->GetImpl());
-    mesh_i->CreateGroupServants();
-  }
-  if ( !myPreviewMode ) {
-    pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
-           << theObject << ", "
-           << theVector   << ", "
-           << theCopyGroups << ", '"
-           << 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
+    mesh = makeMesh( theMeshName );
+    mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
+    
+    if ( mesh_i ) {
+      SMESH::long_array_var anElementsId = theObject->GetIDs();
+      translate(anElementsId, theVector,
+                false, theCopyGroups, & mesh_i->GetImpl());
+      mesh_i->CreateGroupServants();
+    }
+    if ( !myPreviewMode ) {
+      pydump << mesh << " = " << this << ".TranslateObjectMakeMesh( "
+             << theObject << ", "
+             << theVector   << ", "
+             << theCopyGroups << ", '"
+             << theMeshName << "' )";
+    }
   }
+  
+  //dump "GetGroups"
+  if(!myPreviewMode && mesh_i)
+    mesh_i->GetGroups();
+  
   return mesh._retn();
 }
 
@@ -2599,14 +2710,17 @@ SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements,
                                      const SMESH::AxisStruct& theAxis,
                                      CORBA::Double            theAngle)
 {
+  SMESH::ListOfGroups * aGroups =  rotate(theIDsOfElements,theAxis,theAngle,true,true);
   if ( !myPreviewMode ) {
     TPythonDump() << "axis = " << theAxis;
-    TPythonDump() << this << ".RotateMakeGroups( "
-                  << theIDsOfElements
-                  << ", axis, "
-                  << theAngle << " )";
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump << this << ".RotateMakeGroups( "
+                << 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,
                                            CORBA::Double             theAngle)
 {
+  SMESH::long_array_var anElementsId = theObject->GetIDs();
+  SMESH::ListOfGroups * aGroups =  rotate(anElementsId,theAxis,theAngle,true,true);
   if ( !myPreviewMode ) {
     TPythonDump() << "axis = " << theAxis;
-    TPythonDump() << this << ".RotateObjectMakeGroups( "
+    TPythonDump aPythonDump;
+    DumpGroupsList(aPythonDump,aGroups);
+    aPythonDump << this << ".RotateObjectMakeGroups( "
                   << theObject
                   << ", axis, "
                   << theAngle << " )";
   }
-  SMESH::long_array_var anElementsId = theObject->GetIDs();
-  return rotate(anElementsId,theAxis,theAngle,true,true);
+  return aGroups;
 }
 
 //=======================================================================
@@ -2642,22 +2760,36 @@ SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
                                    CORBA::Boolean           theCopyGroups,
                                    const char*              theMeshName)
 {
-  TPythonDump pydump; // to prevent dump at mesh creation
-  SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName );
+  SMESH::SMESH_Mesh_var mesh;
+  SMESH_Mesh_i* mesh_i;
 
-  if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) {
-    rotate(theIDsOfElements, theAxis, theAngleInRadians,
-           false, theCopyGroups, & mesh_i->GetImpl());
-    mesh_i->CreateGroupServants();
-  }
-  if ( !myPreviewMode ) {
-    pydump << mesh << " = " << this << ".RotateMakeMesh( "
-           << theIDsOfElements << ", "
-           << theAxis << ", "
-           << theAngleInRadians   << ", "
-           << theCopyGroups << ", '"
-           << theMeshName << "' )";
+  { // 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,
+             false, theCopyGroups, & mesh_i->GetImpl());
+      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();
 }
 
@@ -2673,23 +2805,36 @@ SMESH_MeshEditor_i::RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr theObject,
                                          CORBA::Boolean            theCopyGroups,
                                          const char*               theMeshName)
 {
-  TPythonDump pydump; // to prevent dump at mesh creation
-  SMESH::SMESH_Mesh_var mesh = makeMesh( theMeshName );
-
-  if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh )) {
-    SMESH::long_array_var anElementsId = theObject->GetIDs();
-    rotate(anElementsId, theAxis, theAngleInRadians,
-           false, theCopyGroups, & mesh_i->GetImpl());
-    mesh_i->CreateGroupServants();
-  }
-  if ( !myPreviewMode ) {
-    pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
-           << theObject << ", "
-           << theAxis << ", "
-           << theAngleInRadians   << ", "
-           << theCopyGroups << ", '"
-           << theMeshName << "' )";
+  SMESH::SMESH_Mesh_var mesh;
+  SMESH_Mesh_i* mesh_i;
+  
+  {// 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();
+      rotate(anElementsId, theAxis, theAngleInRadians,
+             false, theCopyGroups, & mesh_i->GetImpl());
+      mesh_i->CreateGroupServants();
+    }
+    if ( !myPreviewMode ) {
+      pydump << mesh << " = " << this << ".RotateObjectMakeMesh( "
+             << theObject << ", "
+             << theAxis << ", "
+             << theAngleInRadians   << ", "
+             << theCopyGroups << ", '"
+             << theMeshName << "' )";
+    }
   }
+  
+  //dump "GetGroups"
+  if(!myPreviewMode && mesh_i)
+    mesh_i->GetGroups();
+  
   return mesh._retn();
 }
 
@@ -3454,3 +3599,16 @@ SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::makeMesh(const char* theMeshName)
 
   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 << " = ";
+  }
+}
index 85d7b6cfdf6d2de7182ffc550aa5327dfc01c062..f2e6201cdd9a9a511c878dfe897d4ce8f0e207b7 100644 (file)
@@ -35,7 +35,7 @@
 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
 
 #include "SMESH_Mesh.hxx"
-
+#include "SMESH_PythonDump.hxx"
 #include <list>
 
 class SMESH_MeshEditor;
@@ -486,6 +486,9 @@ private: //!< private methods
                               ::SMESH_Mesh*             TargetMesh=0);
 
   SMESH::SMESH_Mesh_ptr makeMesh(const char* theMeshName);
+  
+  void DumpGroupsList(SMESH::TPythonDump & theDumpPython, 
+                      const SMESH::ListOfGroups * theGroupList);
 
 private: //!< fields
 
index 518e1be9220ca88703e8707d5aea712a20ac264f..e801d44affd4a5e0bc8b786eae41f93ebf9b34ab 100644 (file)
@@ -147,6 +147,9 @@ namespace SMESH
     TPythonDump&
     operator<<(const TCollection_AsciiString & theArg);
 
+    TPythonDump&
+    operator<<(const SMESH::ListOfGroups * theList);
+
     static char* SMESHGenName() { return "smeshgen"; }
     static char* MeshEditorName() { return "mesh_editor"; }