]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0020511: EDF 1101 SMESH : Add CGNS to Mesh Format Supported
authoreap <eap@opencascade.com>
Thu, 11 Aug 2011 11:38:37 +0000 (11:38 +0000)
committereap <eap@opencascade.com>
Thu, 11 Aug 2011 11:38:37 +0000 (11:38 +0000)
  make CGNS library an optional prerequisite

adm_local/unix/config_files/check_cgns.m4
src/Makefile.am
src/SMESH/Makefile.am
src/SMESH/SMESH_Mesh.cxx
src/SMESHGUI/SMESHGUI.cxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Mesh_i.cxx

index 75f85221ea04c452ce89f99fca186c7afdedadad..3fb01001c0a4712e2767c0d7ef3d94059cb71033 100644 (file)
@@ -44,32 +44,37 @@ cgns_ok=no
 LOCAL_INCLUDES=""
 LOCAL_LIBS="-lcgns $HDF5_LIBS"
 
-if test -z $CGNSHOME
-then
-   AC_MSG_WARN(undefined CGNSHOME variable which specify CGNS library installation directory)
-   AC_PATH_PROG(BINDIR, cgnsversion)
-   if test "x$BINDIR" != "x" ; then
-      CGNSHOME=$BINDIR
-      CGNSHOME=`echo ${CGNSHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
-      CGNSHOME=`echo ${CGNSHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
-   fi
-fi
-if test ! -z $CGNSHOME
-then
-   LOCAL_INCLUDES="-I$CGNSHOME/include"
-   if test "x$CGNSHOME" != "x/usr"; then
-     LOCAL_LIBS="-L$CGNSHOME/lib $LOCAL_LIBS"
-   fi
-fi
+if test "x$CGNSHOME" != "xno"; then
+    if test "x$CGNSHOME" == "xyes"; then
+        CGNSHOME=""
+    fi
+    if test -z $CGNSHOME
+    then
+        AC_MSG_WARN(undefined CGNSHOME variable which specify CGNS library installation directory)
+        AC_PATH_PROG(BINDIR, cgnsversion)
+        if test "x$BINDIR" != "x" ; then
+            CGNSHOME=$BINDIR
+            CGNSHOME=`echo ${CGNSHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
+            CGNSHOME=`echo ${CGNSHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
+        fi
+    fi
+    if test ! -z $CGNSHOME
+    then
+        LOCAL_INCLUDES="-I$CGNSHOME/include"
+        if test "x$CGNSHOME" != "x/usr"; then
+            LOCAL_LIBS="-L$CGNSHOME/lib $LOCAL_LIBS"
+        fi
+    fi
 
 dnl check cgnslib header
 
-CPPFLAGS_old=$CPPFLAGS
-CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
+    CPPFLAGS_old=$CPPFLAGS
+    CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES"
 
-AC_CHECK_HEADER(cgnslib.h,cgns_ok=yes ,cgns_ok=no)
+    AC_CHECK_HEADER(cgnslib.h,cgns_ok=yes ,cgns_ok=no)
 
-CPPFLAGS=$CPPFLAGS_old
+    CPPFLAGS=$CPPFLAGS_old
+fi
 
 if  test "x$cgns_ok" = "xyes"
 then
@@ -88,11 +93,11 @@ if  test "x$cgns_ok" = "xyes"
 then
   CGNS_LIBS="$LOCAL_LIBS"
   CGNS_INCLUDES="$LOCAL_INCLUDES"
-  #CPPFLAGS="-DWITH_CGNS $CPPFLAGS"
+  CPPFLAGS="-DWITH_CGNS $CPPFLAGS"
 fi
 
 AC_MSG_RESULT(for CGNS: $cgns_ok)
 
-#AM_CONDITIONAL(WITH_CGNS, [test x"$cgns_ok" = xyes])
+AM_CONDITIONAL(WITH_CGNS, [test x"$cgns_ok" = xyes])
 
 ])dnl
index 81302eaf5b57a00524dae77634c7cd1a2f6388a7..0e5088436c15dcb647bd8c95f21929114341fc74 100644 (file)
 #
 include $(top_srcdir)/adm_local/unix/make_common_starter.am
 
+if WITH_CGNS
+  DriverCGNS_SUDIR = DriverCGNS
+endif
+
 SUBDIRS = \
        SMDS \
        SMESHDS \
@@ -35,7 +39,7 @@ SUBDIRS = \
        DriverDAT \
        DriverUNV \
        DriverSTL \
-       DriverCGNS \
+       $(DriverCGNS_SUDIR) \
        SMESH \
        SMESH_I \
        SMESHClient \
@@ -56,6 +60,6 @@ if SMESH_ENABLE_GUI
        StdMeshersGUI
 endif
 
-DIST_SUBDIRS =         SMDS SMESHDS Controls Driver DriverMED DriverDAT DriverUNV DriverSTL SMESH      \
-               SMESH_I SMESHClient SMESH_SWIG MEFISTO2 StdMeshers StdMeshers_I OBJECT          \
+DIST_SUBDIRS =         SMDS SMESHDS Controls Driver DriverMED DriverDAT DriverUNV DriverSTL DriverCGNS \
+               SMESH SMESH_I SMESHClient SMESH_SWIG MEFISTO2 StdMeshers StdMeshers_I OBJECT    \
                SMESHFiltersSelection SMESHGUI PluginUtils SMESH_SWIG_WITHIHM StdMeshersGUI SMESH_PY Tools
index 040c9849f6490f4c534f84a4884f61e858e2575b..461b4dc00f2535dee75460bece1497acb2dc35a4 100644 (file)
@@ -87,6 +87,10 @@ libSMESHimpl_la_CPPFLAGS = \
        -I$(srcdir)/../SMESHDS \
        -I$(srcdir)/../SMESHUtils
 
+if WITH_CGNS
+  DriverCGNS_LIB = ../DriverCGNS/libMeshDriverCGNS.la
+endif
+
 libSMESHimpl_la_LDFLAGS = \
        ../SMESHDS/libSMESHDS.la \
        ../Controls/libSMESHControls.la \
@@ -94,7 +98,7 @@ libSMESHimpl_la_LDFLAGS = \
        ../DriverSTL/libMeshDriverSTL.la \
        ../DriverMED/libMeshDriverMED.la \
        ../DriverUNV/libMeshDriverUNV.la \
-       ../DriverCGNS/libMeshDriverCGNS.la \
+       $(DriverCGNS_LIB) \
        ../SMESHUtils/libSMESHUtils.la \
        $(GEOM_LDFLAGS) -lNMTTools \
        $(CAS_LDPATH) -lTKShHealing -lTKPrim -lTKG2d
index 7bc5b7ceb790197abb5578a0cc4fabf338713a33..4e61d614ca0fbbe584a8b39aa51af6b8259f0566 100644 (file)
 #include "DriverMED_R_SMESHDS_Mesh.h"
 #include "DriverUNV_R_SMDS_Mesh.h"
 #include "DriverSTL_R_SMDS_Mesh.h"
+#ifdef WITH_CGNS
 #include "DriverCGNS_Read.hxx"
 #include "DriverCGNS_Write.hxx"
+#endif
 
 #undef _Precision_HeaderFile
 #include <BRepBndLib.hxx>
@@ -455,16 +457,20 @@ int SMESH_Mesh::CGNSToMesh(const char*  theFileName,
                            const int    theMeshIndex,
                            std::string& theMeshName)
 {
+  int res = Driver_Mesh::DRS_FAIL;
+#ifdef WITH_CGNS
+
   DriverCGNS_Read myReader;
   myReader.SetMesh(_myMeshDS);
   myReader.SetFile(theFileName);
   myReader.SetMeshId(theMeshIndex);
-  int res = myReader.Perform();
+  res = myReader.Perform();
   theMeshName = myReader.GetMeshName();
 
   // create groups
   SynchronizeGroups();
 
+#endif
   return res;
 }
 
@@ -1256,11 +1262,15 @@ void SMESH_Mesh::ExportSTL(const char *        file,
 void SMESH_Mesh::ExportCGNS(const char *        file,
                             const SMESHDS_Mesh* meshDS)
 {
+  int res = Driver_Mesh::DRS_FAIL;
+#ifdef WITH_CGNS
   DriverCGNS_Write myWriter;
   myWriter.SetFile( file );
   myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
   myWriter.SetMeshName( SMESH_Comment("Mesh_") << meshDS->GetPersistentId());
-  if ( myWriter.Perform() != Driver_Mesh::DRS_OK )
+  res = myWriter.Perform();
+#endif
+  if ( res != Driver_Mesh::DRS_OK )
     throw SALOME_Exception("Export failed");
 }
 
index 32576d43787df491dcb2d61bc32288b74ef7cfb8..bfb3d2d30ace96fa05a7daf498a25ee15988e9f3 100644 (file)
@@ -3502,14 +3502,16 @@ void SMESHGUI::initialize( CAM_Application* app )
   createMenu( 112, importId, -1 );
   createMenu( 113, importId, -1 );
   createMenu( 115, importId, -1 );
+#ifdef WITH_CGNS
   createMenu( 116, importId, -1 );
-
+#endif
   createMenu( 121, exportId, -1 );
   createMenu( 122, exportId, -1 );
   createMenu( 123, exportId, -1 );
   createMenu( 140, exportId, -1 ); // export to STL
+#ifdef WITH_CGNS
   createMenu( 142, exportId, -1 ); // export to CGNS
-
+#endif
   createMenu( separator(), fileId, 10 );
 
   createMenu( 33, editId, -1 );
@@ -3810,7 +3812,9 @@ void SMESHGUI::initialize( CAM_Application* app )
   createPopupItem( 125, OB, mesh_group, multiple_non_empty );   // EXPORT_MED
   createPopupItem( 126, OB, mesh_group, only_one_non_empty );   // EXPORT_UNV
   createPopupItem( 141, OB, mesh_group, only_one_2D );          // EXPORT_STL
+#ifdef WITH_CGNS
   createPopupItem( 143, OB, mesh_group, multiple_non_empty );   // EXPORT_CGNS
+#endif
   createPopupItem(  33, OB, mesh_part + " " + hyp_alg );        // DELETE
   popupMgr()->insert( separator(), -1, 0 );
 
index 3197d7204d42b4542e0fcafa7390cdd9fee9f5b6..887aeacc0bf56404f6b0733a1e9fdc000d56d473 100644 (file)
 
 #include "DriverMED_W_SMESHDS_Mesh.h"
 #include "DriverMED_R_SMESHDS_Mesh.h"
+#ifdef WITH_CGNS
 #include "DriverCGNS_Read.hxx"
+#endif
 
 #include "SALOMEDS_Tool.hxx"
 #include "SALOME_NamingService.hxx"
@@ -1036,6 +1038,9 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char* theFileName,
 {
   Unexpect aCatch(SALOME_SalomeException);
 
+  SMESH::mesh_array_var aResult = new SMESH::mesh_array();
+
+#ifdef WITH_CGNS
   // Retrieve nb meshes from the file
   DriverCGNS_Read myReader;
   myReader.SetFile( theFileName );
@@ -1043,7 +1048,6 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char* theFileName,
   int nbMeshes = myReader.GetNbMeshes(aStatus);
   theStatus = (SMESH::DriverMED_ReadStatus)aStatus;
 
-  SMESH::mesh_array_var aResult = new SMESH::mesh_array();
   aResult->length( nbMeshes );
 
   { // open a new scope to make aPythonDump die before PythonDump in SMESH_Mesh::GetGroups()
@@ -1098,6 +1102,9 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char* theFileName,
   // Dump creation of groups
   for ( int i = 0; i < aResult->length(); ++i )
     SMESH::ListOfGroups_var groups = aResult[ i ]->GetGroups();
+#else
+  THROW_SALOME_CORBA_EXCEPTION("CGNS library is unavailable", SALOME::INTERNAL_ERROR);
+#endif
 
   return aResult._retn();
 }
index 36604c7f8509de6d8e9f0bf73a73a4f91ed26f32..17b974e3cccc83da5ea05dd2e6cc19c9008327e4 100644 (file)
@@ -2784,6 +2784,7 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
                               CORBA::Boolean              overwrite)
   throw (SALOME::SALOME_Exception)
 {
+#ifdef WITH_CGNS
   Unexpect aCatch(SALOME_SalomeException);
 
   PrepareForWriting(file,overwrite);
@@ -2793,6 +2794,9 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart,
 
   TPythonDump() << _this() << ".ExportCGNS( "
                 << meshPart<< ", r'" << file << "', " << overwrite << ")";
+#else
+  THROW_SALOME_CORBA_EXCEPTION("CGNS library is unavailable", SALOME::INTERNAL_ERROR);
+#endif
 }
 
 //=============================================================================