Salome HOME
Fix for issue 19964 EDF SMESH 803( Bad dump script of revolutionned mesh with groups).
[modules/smesh.git] / src / SMESH_I / SMESH_DumpPython.cxx
index d640a6489c3b6989abc49d93991b0017b0bd4595..1fee7112e64d408a5faeee03de017237a258f993 100644 (file)
@@ -15,7 +15,7 @@
 // License along with this library; if not, write to the Free Software 
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 // File    : SMESH_Gen_i_DumpPython.cxx
 // Created : Thu Mar 24 17:17:59 2005
@@ -231,6 +231,7 @@ namespace SMESH
       case FT_BelongToGeom:     myStream<< "aBelongToGeom";     break;
       case FT_BelongToPlane:    myStream<< "aBelongToPlane";    break;
       case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
+      case FT_BelongToGenSurface:myStream<<"aBelongToGenSurface";break;
       case FT_LyingOnGeom:      myStream<< "aLyingOnGeom";      break;
       case FT_RangeOfIds:       myStream<< "aRangeOfIds";       break;
       case FT_BadOrientedVolume:myStream<< "aBadOrientedVolume";break;
@@ -295,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" );
 
@@ -362,7 +381,7 @@ namespace SMESH
 
     // find where literal begins
     int literalBeg = theFrom + myLongStringStart.Length(); // = 26
-    char* typeLenStr = theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
+    char* typeLenStr = (char*) theText.ToCString() + literalBeg - 1; // = "7 Pattern!!! SALO...."
     int typeLen = atoi ( typeLenStr ); // = 7
     while ( *typeLenStr != ' ' ) { // look for ' ' after typeLen
       literalBeg++; // 26 -> 27
@@ -526,7 +545,7 @@ Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theStri
   Standard_Integer aLen = theString.Length();
   Standard_Boolean isFound = Standard_False;
 
-  char* arr = theString.ToCString();
+  char* arr = (char*) theString.ToCString();
   Standard_Integer i = 0, j;
 
   while(i < aLen) {
@@ -748,6 +767,53 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
   if (aSeq->Value(aLen) < aScriptLength)
     anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength);
 
+
+  SMESH_Gen_i* aSMESHGenI = SMESH_Gen_i::GetSMESHGen();
+  SALOMEDS::Study_ptr aStudy = aSMESHGenI->GetCurrentStudy();
+  if( !CORBA::is_nil(aStudy) )
+  {
+    SALOMEDS::SObject_var aComp = aStudy->FindComponent(ComponentDataType());
+    if( !CORBA::is_nil(aComp) )
+    {
+      SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aComp);
+      for( Itr->InitEx(true); Itr->More(); Itr->Next() )
+      {
+       SALOMEDS::SObject_var aSObj = Itr->Value();
+       CORBA::String_var aName = aSObj->GetName();
+
+       SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH_Gen_i::SObjectToObject( aSObj ) );
+       if( !CORBA::is_nil(aMesh) )
+       {
+         bool isAutoColor = aMesh->GetAutoColor();
+         if( isAutoColor )
+         {
+           anUpdatedScript += "\n\t";
+           anUpdatedScript += (char*)aName.in();
+           anUpdatedScript += ".SetAutoColor(1)";
+         }
+       }
+       SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH_Gen_i::SObjectToObject( aSObj ) );
+       if( !CORBA::is_nil(aGroup) )
+       {
+         SALOMEDS::Color aColor = aGroup->GetColor();
+         if ( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 )
+         {
+           anUpdatedScript += "\n\t";
+           anUpdatedScript += (char*)aName.in();
+           anUpdatedScript += ".SetColor(SALOMEDS.Color(";
+           anUpdatedScript += aColor.R;
+           anUpdatedScript += ",";
+           anUpdatedScript += aColor.G;
+           anUpdatedScript += ",";
+           anUpdatedScript += aColor.B;
+           anUpdatedScript += "))";
+         }
+       }
+      }
+    }
+  }
+
   // Remove removed objects
   if ( seqRemoved.Length() > 0 ) {
     anUpdatedScript += "\n\t## some objects were removed";
@@ -816,7 +882,7 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
     {
       // find the function name
       int functBeg = posAlready;
-      char* script = anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
+      char* script = (char*) anUpdatedScript.ToCString() + posAlready - 1; // look at ":" after "def fuction()"
       while ( *script != ' ' ) {
         script--;
         functBeg--;