0020511: EDF 1101 SMESH : Add CGNS to Mesh Format Supported

make CGNS library an optional prerequisite
This commit is contained in:
eap 2011-08-11 11:38:37 +00:00
parent 54d766ea04
commit 39841ffadd
7 changed files with 70 additions and 32 deletions

View 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

View File

@ -25,6 +25,10 @@
#
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

View 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

View File

@ -48,8 +48,10 @@
#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");
}

View 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 );

View File

@ -100,7 +100,9 @@
#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();
}

View 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
}
//=============================================================================