]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Integrate patches for win32 version
authorana <ana@opencascade.com>
Mon, 19 Sep 2011 07:08:59 +0000 (07:08 +0000)
committerana <ana@opencascade.com>
Mon, 19 Sep 2011 07:08:59 +0000 (07:08 +0000)
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx

index 60458d8307b1621f18264586e6c89c073308e13e..7d4bbfae42f2d01d7e44cc580d0fcc8caefe7569 100644 (file)
@@ -1144,6 +1144,44 @@ void SMESH_Mesh::ExportMED(const char *file,
   myWriter.Perform();
 }
 
+void SMESH_Mesh::ExportSAUV(const char *file, 
+                            const char* theMeshName, 
+                            bool theAutoGroups)
+  throw(SALOME_Exception)
+{
+  std::string medfilename(file);
+  medfilename += ".med";
+  std::string cmd;
+#ifdef WNT
+  cmd = "%PYTHONBIN% ";
+#else
+  cmd = "python ";
+#endif
+  cmd += "-c \"";
+  cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
+  cmd += "\"";
+  system(cmd.c_str());
+  ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, 1);
+#ifdef WNT
+  cmd = "%PYTHONBIN% ";
+#else
+  cmd = "python ";
+#endif
+  cmd += "-c \"";
+  cmd += "from medutilities import convert ; convert(r'" + medfilename + "', 'MED', 'GIBI', 1, r'" + file + "')";
+  cmd += "\"";
+  system(cmd.c_str());
+#ifdef WNT
+  cmd = "%PYTHONBIN% ";
+#else
+  cmd = "python ";
+#endif
+  cmd += "-c \"";
+  cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
+  cmd += "\"";
+  system(cmd.c_str());
+}
+
 void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
 {
   Unexpect aCatch(SalomeException);
index a77498ed5786a60a65b02ae8bc42a637751d5a48..58b85201cc754bc60c5de6b14a7db116eba2c2fb 100644 (file)
@@ -222,6 +222,11 @@ public:
                  int theVersion = 0) 
     throw(SALOME_Exception);
 
+  void ExportSAUV(const char *file, 
+                  const char* theMeshName = NULL, 
+                  bool theAutoGroups = true)
+    throw(SALOME_Exception);
+
   void ExportDAT(const char *file) throw(SALOME_Exception);
   void ExportUNV(const char *file) throw(SALOME_Exception);
   void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception);
index ba566cc24b74ec36fc25dfde9265037c1e181927..f607b1929e715f7fe55664f065cce571a508cf14 100644 (file)
     else if ( theCommandID == 111 ) {
       filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
     }
+    else if ( theCommandID == 115 ) {
+      filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
+      filter.append( QObject::tr( "All files (*)" ) );
+    }
     else if ( theCommandID == 140 ) {
       filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
     }
               }
               break;
             }
+          case 115:
+            {
+              // SAUV format
+              SMESH::DriverMED_ReadStatus res;
+              aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
+              if ( res != SMESH::DRS_OK ) {
+                errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
+                               arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
+              }
+              break;
+            }
           case 140:
             {
               // STL format
     switch ( theCommandID ) {
     case 125:
     case 122:
+    case 142:
+    case 143:
       {
         for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
           SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
               return;
           }
         }
-        // PAL18696
-        //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
-        QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
-        //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
-        aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
+       switch ( theCommandID ) {
+        case 125:
+        case 122:
+          {
+            // PAL18696
+            QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
+            QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
+            aFilterMap.insert( QString("MED ") +  v21 + " (*.med)", SMESH::MED_V2_1 );
+            aFilterMap.insert( QString("MED ") +  v22 + " (*.med)", SMESH::MED_V2_2 );
+          }
+          break;
+       case 142:
+       case 143:
+         {
+           aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
+           aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
+           aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
+         }
+         break;
+        }
       }
       break;
     case 124:
     if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
       anInitialPath = QDir::currentPath();
 
-    if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 141) {
+    if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 141 && theCommandID != 142 && theCommandID != 143) {
       if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
       aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), anInitialPath + QString("/") + aMeshName,
                                             aFilter, aTitle, false);
             }
           }
           break;
+        case 142:
+        case 143: {
+            for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
+              SMESH::SMESH_Mesh_var aMeshItem = (*aMeshIter).first;
+              if( !aMeshItem->_is_nil() )
+                aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
+            }
+          }
+          break;
         case 124:
         case 121:
           aMesh->ExportDAT( aFilename.toLatin1().data() );
@@ -1880,6 +1921,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 113:                                     // IMPORT
   case 112:
   case 111:
+  case 115:
   case 140:
     {
       if(checkLock(aStudy)) break;
@@ -1913,6 +1955,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
   case 125:
   case 126:
   case 141:
+  case 142:
+  case 143:
     {
       ::ExportMeshToFile(theCommandID);
       break;
@@ -3260,14 +3304,17 @@ void SMESHGUI::initialize( CAM_Application* app )
   createSMESHAction(  112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
   createSMESHAction(  113, "MED", "", (Qt::CTRL+Qt::Key_M) );
   createSMESHAction(  114, "NUM" );
+  createSMESHAction(  115, "SAUV" );
   createSMESHAction(  121, "DAT" );
   createSMESHAction(  122, "MED" );
   createSMESHAction(  123, "UNV" );
   createSMESHAction(  140, "STL" );
+  createSMESHAction(  142, "SAUV" );
   createSMESHAction(  124, "EXPORT_DAT" );
   createSMESHAction(  125, "EXPORT_MED" );
   createSMESHAction(  126, "EXPORT_UNV" );
   createSMESHAction(  141, "EXPORT_STL" );
+  createSMESHAction(  143, "EXPORT_SAUV" );
   createSMESHAction(  150, "FILE_INFO" );
   createSMESHAction(   33, "DELETE",          "ICON_DELETE", Qt::Key_Delete );
   createSMESHAction( 5105, "SEL_FILTER_LIB" );
@@ -3430,12 +3477,14 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 111, importId, -1 );
   createMenu( 112, importId, -1 );
   createMenu( 113, importId, -1 );
+  createMenu( 115, importId, -1 );
   createMenu( 140, importId, -1 );
 
   createMenu( 121, exportId, -1 );
   createMenu( 122, exportId, -1 );
   createMenu( 123, exportId, -1 );
   createMenu( 141, exportId, -1 ); // export to stl STL
+  createMenu( 142, exportId, -1 );
 
   createMenu( separator(), fileId, 10 );
 
@@ -3738,6 +3787,7 @@ void SMESHGUI::initialize( CAM_Application* app )
   createPopupItem( 125, OB, mesh, multiple_non_empty );   // EXPORT_MED
   createPopupItem( 126, OB, mesh, only_one_non_empty );   // EXPORT_UNV
   createPopupItem( 141, OB, mesh, only_one_non_empty );   // EXPORT_STL
+  createPopupItem( 143, OB, mesh, only_one_non_empty );   // EXPORT_SAUV
   //createPopupItem( 33, OB, subMesh + " " + group );       // DELETE
   createPopupItem(  33, OB, mesh_group + " " + hyp_alg ); // DELETE
   popupMgr()->insert( separator(), -1, 0 );
index 0da96ccdde4925d3c36a811cd3a221656cc1fa33..fd10b87747b285f4c76052590fe7e8b4cabb04c4 100644 (file)
     </message>
     <message>
         <source>MEN_EXPORT_SAUV</source>
-        <translation>Export to SAUV (ASCII) file</translation>
+        <translation>Export to SAUV file</translation>
     </message>
     <message>
         <source>MEN_EXPORT_STL</source>
     </message>
     <message>
         <source>MEN_SAUV</source>
-        <translation>SAUV (ASCII) file</translation>
+        <translation>SAUV file</translation>
     </message>
     <message>
         <source>MEN_MERGE</source>
@@ -2457,7 +2457,7 @@ Please check preferences of Mesh module.
     </message>
     <message>
         <source>STB_EXPORT_SAUV</source>
-        <translation>Export to SAUV (ASCII) file</translation>
+        <translation>Export to SAUV file</translation>
     </message>
     <message>
         <source>STB_EXPORT_STL</source>
@@ -2557,7 +2557,7 @@ Please check preferences of Mesh module.
     </message>
     <message>
         <source>STB_SAUV</source>
-        <translation>Import SAUV (ASCII) file</translation>
+        <translation>Import SAUV file</translation>
     </message>
     <message>
         <source>STB_MERGE</source>
@@ -3013,7 +3013,7 @@ Please check preferences of Mesh module.
     </message>
     <message>
         <source>TOP_EXPORT_SAUV</source>
-        <translation>Export to SAUV (ASCII) file</translation>
+        <translation>Export to SAUV file</translation>
     </message>
     <message>
         <source>TOP_EXPORT_STL</source>
@@ -3113,7 +3113,7 @@ Please check preferences of Mesh module.
     </message>
     <message>
         <source>TOP_SAUV</source>
-        <translation>Import SAUV (ASCII) file</translation>
+        <translation>Import SAUV file</translation>
     </message>
     <message>
         <source>TOP_MERGE</source>
index 767c325827692f09fccd4edfb3a7491a78a45a6c..90609acf2c9a9033b57ebe79889ec1093d93f125 100644 (file)
@@ -369,7 +369,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
     myMeshes.insert( make_pair( mesh->GetID(), mesh ));
     return;
   }
-  if( method == "CreateMeshesFromMED")
+  if( method == "CreateMeshesFromMED" || method == "CreateMeshesFromSAUV")
   {
     for(int ind = 0;ind<theCommand->GetNbResultValues();ind++)
     {
@@ -965,7 +965,7 @@ bool _pyMesh::NeedMeshAccess( const Handle(_pyCommand)& theCommand )
   static TStringSet sameMethods;
   if ( sameMethods.empty() ) {
     const char * names[] =
-      { "ExportDAT","ExportUNV","ExportSTL", "RemoveGroup","RemoveGroupWithContents",
+      { "ExportDAT","ExportUNV","ExportSTL","ExportSAUV", "RemoveGroup","RemoveGroupWithContents",
         "GetGroups","UnionGroups","IntersectGroups","CutGroups","GetLog","GetId","ClearLog",
         "GetStudyId","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
         "NbEdges","NbEdgesOfOrder","NbFaces","NbFacesOfOrder","NbTriangles",
index 76143cec042a92fed511903d75c13974efc22b08..32e1cdbefad45713bbd4ae76356c119b359c2a35 100644 (file)
@@ -914,13 +914,11 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
  */
 //=============================================================================
 
-SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
-                                                     SMESH::DriverMED_ReadStatus& theStatus)
-     throw ( SALOME::SALOME_Exception )
+SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileName,
+                                                           SMESH::DriverMED_ReadStatus& theStatus,
+                                                           const char* theCommandNameForPython,
+                                                           const char* theFileNameForPython)
 {
-  Unexpect aCatch(SALOME_SalomeException);
-  if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
-
   // Retrieve mesh names from the file
   DriverMED_R_SMESHDS_Mesh myReader;
   myReader.SetFile( theFileName );
@@ -977,7 +975,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
   }
 
   // Update Python script
-  aPythonDump << "], status) = " << this << ".CreateMeshesFromMED(r'" << theFileName << "')";
+  aPythonDump << "], status) = " << this << "." << theCommandNameForPython << "(r'" << theFileNameForPython << "')";
   }
   // Dump creation of groups
   for ( int i = 0; i < aResult->length(); ++i )
@@ -986,6 +984,56 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
   return aResult._retn();
 }
 
+SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
+                                                     SMESH::DriverMED_ReadStatus& theStatus)
+     throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
+  SMESH::mesh_array* result = CreateMeshesFromMEDorSAUV(theFileName, theStatus, "CreateMeshesFromMED", theFileName);
+  return result;
+}
+
+//=============================================================================
+/*!
+ *  SMESH_Gen_i::CreateMeshFromSAUV
+ *
+ *  Create mesh and import data from SAUV file
+ */
+//=============================================================================
+
+SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromSAUV( const char* theFileName,
+                                                      SMESH::DriverMED_ReadStatus& theStatus)
+     throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromSAUV" );
+  std::string sauvfilename(theFileName);
+  std::string medfilename(theFileName);
+  medfilename += ".med";
+  std::string cmd;
+#ifdef WNT
+  cmd = "%PYTHONBIN% ";
+#else
+  cmd = "python ";
+#endif
+  cmd += "-c \"";
+  cmd += "from medutilities import convert ; convert(r'" + sauvfilename + "', 'GIBI', 'MED', 1, r'" + medfilename + "')";
+  cmd += "\"";
+  system(cmd.c_str());
+  SMESH::mesh_array* result = CreateMeshesFromMEDorSAUV(medfilename.c_str(), theStatus, "CreateMeshesFromSAUV", sauvfilename.c_str());
+#ifdef WNT
+  cmd = "%PYTHONBIN% ";
+#else
+  cmd = "python ";
+#endif
+  cmd += "-c \"";
+  cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
+  cmd += "\"";
+  system(cmd.c_str());
+  return result;
+}
+
 //=============================================================================
 /*!
  *  SMESH_Gen_i::CreateMeshFromSTL
index 1087dc02368690e409fe8c594afce12cfdda37bb..4143a6f7e5dfd5b7ea7bda19dbecbac8c855344b 100644 (file)
@@ -230,6 +230,11 @@ public:
                                           SMESH::DriverMED_ReadStatus& theStatus )
     throw ( SALOME::SALOME_Exception );
 
+  //  Create mesh(es) and import data from MED file
+  SMESH::mesh_array* CreateMeshesFromSAUV( const char* theFileName,
+                                           SMESH::DriverMED_ReadStatus& theStatus )
+    throw ( SALOME::SALOME_Exception );
+
   //  Create mesh(es) and import data from STL file
   SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName )
     throw ( SALOME::SALOME_Exception );
@@ -545,6 +550,11 @@ private:
 
   static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
 
+  SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,
+                                                SMESH::DriverMED_ReadStatus& theStatus,
+                                                const char* theCommandNameForPython,
+                                                const char* theFileNameForPython);
+
 private:
   static GEOM::GEOM_Gen_var      myGeomGen;
   static CORBA::ORB_var          myOrb;         // ORB reference
index 7352426c687fa98ed820a4c0b58c32122e15d928..f2ef32302a1a5494a0051838ecde2ce57e1c2e86 100644 (file)
@@ -2436,14 +2436,9 @@ void SMESH_Mesh_i::PrepareForWriting (const char* file, bool overwrite)
   }
 }
 
-void SMESH_Mesh_i::ExportToMEDX (const char* file,
-                                 CORBA::Boolean auto_groups,
-                                 SMESH::MED_VERSION theVersion,
-                                 CORBA::Boolean overwrite)
-  throw(SALOME::SALOME_Exception)
+const char* SMESH_Mesh_i::PrepareMeshNameAndGroups(const char* file,
+                                                   CORBA::Boolean overwrite)
 {
-  Unexpect aCatch(SALOME_SalomeException);
-
   // Perform Export
   PrepareForWriting(file, overwrite);
   const char* aMeshName = "Mesh";
@@ -2477,6 +2472,17 @@ void SMESH_Mesh_i::ExportToMEDX (const char* file,
   // check names of groups
   checkGroupNames();
 
+  return aMeshName;
+}
+
+void SMESH_Mesh_i::ExportToMEDX (const char* file,
+                                 CORBA::Boolean auto_groups,
+                                 SMESH::MED_VERSION theVersion,
+                                 CORBA::Boolean overwrite)
+  throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  const char* aMeshName = PrepareMeshNameAndGroups(file, overwrite);
   TPythonDump() << _this() << ".ExportToMEDX( r'"
                 << file << "', " << auto_groups << ", " << theVersion << ", " << overwrite << " )";
 
@@ -2498,6 +2504,16 @@ void SMESH_Mesh_i::ExportMED (const char* file,
   ExportToMEDX(file,auto_groups,SMESH::MED_V2_2,true);
 }
 
+void SMESH_Mesh_i::ExportSAUV (const char* file,
+                               CORBA::Boolean auto_groups)
+  throw(SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  const char* aMeshName = PrepareMeshNameAndGroups(file, true);
+  TPythonDump() << _this() << ".ExportSAUV( r'" << file << "', " << auto_groups << " )";
+  _impl->ExportSAUV(file, aMeshName, auto_groups);
+}
+
 void SMESH_Mesh_i::ExportDAT (const char *file)
   throw(SALOME::SALOME_Exception)
 {
index 7ebc76ba398df49f2ccf2749e87651798915ea56..08afb022f62bf08cc143f1bc9eb0b6ea3b8f7932 100644 (file)
@@ -207,6 +207,8 @@ public:
    */
   char* GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits);
 
+  const char* PrepareMeshNameAndGroups( const char* file, CORBA::Boolean overwrite );
+
   void ExportToMEDX( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion, CORBA::Boolean overwrite )
     throw (SALOME::SALOME_Exception);
   void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
@@ -214,6 +216,9 @@ public:
   void ExportMED( const char* file, CORBA::Boolean auto_groups )
     throw (SALOME::SALOME_Exception);
 
+  void ExportSAUV( const char* file, CORBA::Boolean auto_groups )
+    throw (SALOME::SALOME_Exception);
+
   void ExportDAT( const char* file )
     throw (SALOME::SALOME_Exception);
   void ExportUNV( const char* file )