X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Mesh_i.cxx;h=721476f831d6885c5f88a1913dd897958c9966d9;hb=252161f517834e1f54ac1c589928e101e0e61c22;hp=73d8014929fbc456d783ec704fb2d4314b11045a;hpb=c6513651400e7648d3b1454b4ecbf1e1d64af0bc;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 73d801492..721476f83 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -63,15 +63,16 @@ #include #include #include +#include #include #include #include #include #include #include -#include -#include #include +#include +#include // STL Includes #include @@ -305,7 +306,7 @@ void SMESH_Mesh_i::ClearSubMesh(CORBA::Long ShapeID) //============================================================================= /*! - * + * Convert enum Driver_Mesh::Status to SMESH::DriverMED_ReadStatus */ //============================================================================= @@ -329,6 +330,30 @@ static SMESH::DriverMED_ReadStatus ConvertDriverMEDReadStatus (int theStatus) return res; } +//============================================================================= +/*! + * Convert ::SMESH_ComputeError to SMESH::ComputeError + */ +//============================================================================= + +static SMESH::ComputeError* ConvertComputeError( SMESH_ComputeErrorPtr errorPtr ) +{ + SMESH::ComputeError_var errVar = new SMESH::ComputeError(); + errVar->subShapeID = -1; + errVar->hasBadMesh = false; + + if ( !errorPtr || errorPtr->IsOK() ) + { + errVar->code = SMESH::COMPERR_OK; + } + else + { + errVar->code = ConvertDriverMEDReadStatus( errorPtr->myName ); + errVar->comment = errorPtr->myComment.c_str(); + } + return errVar._retn(); +} + //============================================================================= /*! * ImportMEDFile @@ -452,6 +477,45 @@ int SMESH_Mesh_i::ImportSTLFile( const char* theFileName ) return 1; } +//================================================================================ +/*! + * \brief Imports data from a GMF file and returns an error description + */ +//================================================================================ + +SMESH::ComputeError* SMESH_Mesh_i::ImportGMFFile( const char* theFileName ) + throw (SALOME::SALOME_Exception) +{ + SMESH_ComputeErrorPtr error; + try { + error = _impl->GMFToMesh( theFileName ); + } + catch ( std::bad_alloc& exc ) { + error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "std::bad_alloc raised" ); + } + catch ( Standard_OutOfMemory& exc ) { + error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "Standard_OutOfMemory raised" ); + } + catch (Standard_Failure& ex) { + error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, ex.DynamicType()->Name() ); + if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) + error->myComment += string(": ") + ex.GetMessageString(); + } + catch ( SALOME_Exception& S_ex ) { + error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, S_ex.what() ); + } + catch ( std::exception& exc ) { + error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, exc.what() ); + } + catch (...) { + error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "Unknown exception" ); + } + + CreateGroupServants(); + + return ConvertComputeError( error ); +} + //============================================================================= /*! * @@ -2968,6 +3032,28 @@ void SMESH_Mesh_i::ExportCGNS(::SMESH::SMESH_IDSource_ptr meshPart, #endif } +//================================================================================ +/*! + * \brief Export a part of mesh to a GMF file + */ +//================================================================================ + +void SMESH_Mesh_i::ExportGMF(::SMESH::SMESH_IDSource_ptr meshPart, + const char* file) + throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + if ( _preMeshInfo ) + _preMeshInfo->FullLoadFromFile(); + + PrepareForWriting(file,/*overwrite=*/true); + + SMESH_MeshPartDS partDS( meshPart ); + _impl->ExportGMF(file, &partDS); + + TPythonDump() << _this() << ".ExportGMF( " << meshPart<< ", r'" << file << "')"; +} + //============================================================================= /*! * Return implementation of SALOME_MED::MESH interfaces @@ -4053,7 +4139,7 @@ SMESH::double_array* SMESH_Mesh_i::BaryCenter(const CORBA::Long id) */ //============================================================================= -void SMESH_Mesh_i::CreateGroupServants() +void SMESH_Mesh_i::CreateGroupServants() { SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); @@ -4964,3 +5050,5 @@ _GET_ITER_DEFINE( SMDS_VolumeIteratorPtr, volumesIterator, SMDS_MeshVolume, SMDS // END Implementation of SMESH_MeshPartDS // //================================================================================ + +