return mesh._retn();
}
+namespace
+{
+ //================================================================================
+ /*!
+ * \brief Throws an exception in case if the file can't be read
+ */
+ //================================================================================
+
+ void checkFileReadable( const char* theFileName ) throw ( SALOME::SALOME_Exception )
+ {
+ SMESH_File f ( theFileName );
+ if ( !f )
+ {
+ if ( !f.error().empty() )
+ THROW_SALOME_CORBA_EXCEPTION( f.error().c_str(), SALOME::BAD_PARAM);
+
+ THROW_SALOME_CORBA_EXCEPTION
+ (( SMESH_Comment("Can't open for reading the file ") << theFileName ).c_str(),
+ SALOME::BAD_PARAM );
+ }
+ }
+}
+
//=============================================================================
/*!
* SMESH_Gen_i::CreateMeshFromUNV
throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
- if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshesFromUNV" );
+
+ checkFileReadable( theFileName );
SMESH::SMESH_Mesh_var aMesh = createMesh();
string aFileName;
SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
SMESH::DriverMED_ReadStatus& theStatus)
- throw ( SALOME::SALOME_Exception )
+ throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
- if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
+ checkFileReadable( theFileName );
+
SMESH::mesh_array* result = CreateMeshesFromMEDorSAUV(theFileName, theStatus, "CreateMeshesFromMED", theFileName);
return result;
}
throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
- if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromSAUV" );
+ checkFileReadable( theFileName );
+
std::string sauvfilename(theFileName);
std::string medfilename(theFileName);
medfilename += ".med";
throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
- if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshesFromSTL" );
+ checkFileReadable( theFileName );
SMESH::SMESH_Mesh_var aMesh = createMesh();
//string aFileName;
throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
+ checkFileReadable( theFileName );
SMESH::mesh_array_var aResult = new SMESH::mesh_array();
throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
+ checkFileReadable( theFileName );
SMESH::SMESH_Mesh_var aMesh = createMesh();
#ifdef WIN32