Salome HOME
NPAL16198: EDF462: Submeshes creation duplicate algorithms and hypotheses. Refix.
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.cxx
index 7e04c6408009acf8f636aeffbf665c497612e942..4b0f6971d6f26b22770c276ae54138b2093cfb08 100644 (file)
@@ -327,41 +327,41 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName
   {
     int libNameLen = strlen(theLibName);
     //check for old format "libXXXXXXX.so"
-    if( libNameLen > 7 && !strncmp( theLibName, "lib", 3 ) && !strcmp( theLibName+libNameLen-3, ".so" ) )
-      {
-       //the old format
+    if (libNameLen > 7 &&
+        !strncmp( theLibName, "lib", 3 ) &&
+        !strcmp( theLibName+libNameLen-3, ".so" ))
+    {
+      //the old format
 #ifdef WNT
-       aPlatformLibName = new char[libNameLen - 1];
-       aPlatformLibName[0] = '\0';
-       aPlatformLibName = strncat( aPlatformLibName, theLibName+3, libNameLen-6  );
-       aPlatformLibName = strcat( aPlatformLibName, ".dll" );
-  aPlatformLibName[libNameLen - 2] = '\0';
+      aPlatformLibName = new char[libNameLen - 1];
+      aPlatformLibName[0] = '\0';
+      aPlatformLibName = strncat( aPlatformLibName, theLibName+3, libNameLen-6  );
+      aPlatformLibName = strcat( aPlatformLibName, ".dll" );
+      aPlatformLibName[libNameLen - 2] = '\0';
 #else
-       aPlatformLibName = new char[ libNameLen + 1];
-       aPlatformLibName[0] = '\0';
-       aPlatformLibName = strcat( aPlatformLibName, theLibName );
-  aPlatformLibName[libNameLen] = '\0';
+      aPlatformLibName = new char[ libNameLen + 1];
+      aPlatformLibName[0] = '\0';
+      aPlatformLibName = strcat( aPlatformLibName, theLibName );
+      aPlatformLibName[libNameLen] = '\0';
 #endif
-
-      }
+    }
     else
-      {
-       //try to use new format 
+    {
+      //try to use new format 
 #ifdef WNT
-       aPlatformLibName = new char[ libNameLen + 5 ];
-       aPlatformLibName[0] = '\0';
-       aPlatformLibName = strcat( aPlatformLibName, theLibName );
-       aPlatformLibName = strcat( aPlatformLibName, ".dll" );
+      aPlatformLibName = new char[ libNameLen + 5 ];
+      aPlatformLibName[0] = '\0';
+      aPlatformLibName = strcat( aPlatformLibName, theLibName );
+      aPlatformLibName = strcat( aPlatformLibName, ".dll" );
 #else
-       aPlatformLibName = new char[ libNameLen + 7 ];
-       aPlatformLibName[0] = '\0';
-       aPlatformLibName = strcat( aPlatformLibName, "lib" );
-       aPlatformLibName = strcat( aPlatformLibName, theLibName );
-       aPlatformLibName = strcat( aPlatformLibName, ".so" );
+      aPlatformLibName = new char[ libNameLen + 7 ];
+      aPlatformLibName[0] = '\0';
+      aPlatformLibName = strcat( aPlatformLibName, "lib" );
+      aPlatformLibName = strcat( aPlatformLibName, theLibName );
+      aPlatformLibName = strcat( aPlatformLibName, ".so" );
 #endif
-      }
+    }
   }
-  
 
 
   Unexpect aCatch(SALOME_SalomeException);
@@ -416,7 +416,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName
     // create a new hypothesis object, store its ref. in studyContext
     if(MYDEBUG) MESSAGE("Create Hypothesis " << theHypName);
     myHypothesis_i =
-      myHypCreatorMap[string(theHypName)]->Create (myPoa, GetCurrentStudyID(), &myGen);
+      myHypCreatorMap[string(theHypName)]->Create(myPoa, GetCurrentStudyID(), &myGen);
     myHypothesis_i->SetLibName(aPlatformLibName/*theLibName*/); // for persistency assurance
   }
   catch (SALOME_Exception& S_ex)
@@ -437,7 +437,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName
 
   return hypothesis_i._retn();
 }
-  
+
 //=============================================================================
 /*!
  *  SMESH_Gen_i::createMesh
@@ -1705,8 +1705,12 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
               if( libname_len > 4 )
                 libname.resize( libname_len - 4 );
 #else
-              if( libname_len > 3 )
-                libname.resize( libname_len - 3 );
+              // PAL17753 (Regresion: missing hypothesis in restored study)
+              // "lib" also should be removed from the beginning
+              //if( libname_len > 3 )
+                //libname.resize( libname_len - 3 );
+              if( libname_len > 6 )
+                libname = libname.substr( 3, libname_len - 3 - 3 );
 #endif
               CORBA::String_var objStr = GetORB()->object_to_string( anObject );
               int    id      = myStudyContext->findId( string( objStr.in() ) );
@@ -1770,8 +1774,12 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
               if( libname_len > 4 )
                 libname.resize( libname_len - 4 );
 #else
-              if( libname_len > 3 )
-                libname.resize( libname_len - 3 );
+              // PAL17753 (Regresion: missing hypothesis in restored study)
+              // "lib" also should be removed from the beginning
+              //if( libname_len > 3 )
+                //libname.resize( libname_len - 3 );
+              if( libname_len > 6 )
+                libname = libname.substr( 3, libname_len - 3 - 3 );
 #endif
               CORBA::String_var objStr = GetORB()->object_to_string( anObject );
               int    id      = myStudyContext->findId( string( objStr.in() ) );
@@ -3502,10 +3510,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
                double* anRGB = new double[ size ];
                aDataset->ReadFromDisk( anRGB );
                aDataset->CloseOnDisk();
-               SALOMEDS::Color aColor;
-               aColor.R = anRGB[0];
-               aColor.G = anRGB[1];
-               aColor.B = anRGB[2];
+               Quantity_Color aColor( anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB );
                aGroupBaseDS->SetColor( aColor );
              }
 
@@ -3586,6 +3591,10 @@ void SMESH_Gen_i::Close( SALOMEDS::SComponent_ptr theComponent )
 {
   if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Close" );
 
+  // set correct current study
+  if (theComponent->GetStudy()->StudyId() != GetCurrentStudyID())
+    SetCurrentStudy(theComponent->GetStudy());
+
   // Clear study contexts data
   int studyId = GetCurrentStudyID();
   if ( myStudyContextMap.find( studyId ) != myStudyContextMap.end() ) {
@@ -3697,7 +3706,7 @@ int SMESH_Gen_i::RegisterObject(CORBA::Object_ptr theObject)
  */
 //================================================================================
 
-int SMESH_Gen_i::GetObjectId(CORBA::Object_ptr theObject)
+CORBA::Long SMESH_Gen_i::GetObjectId(CORBA::Object_ptr theObject)
 {
   StudyContext* myStudyContext = GetCurrentStudyContext();
   if ( myStudyContext && !CORBA::is_nil( theObject )) {