mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-08 10:37:28 +05:00
SALOME_TESTS/Grids/smesh/bugs_09/J9
In CreateMeshFrom*(), throw an exception if the file does not exist
This commit is contained in:
parent
896b180efc
commit
2107fb0fba
@ -105,6 +105,10 @@ bool SMESH_File::open()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( _error.empty() )
|
||||||
|
{
|
||||||
|
_error = "Can't open for reading an existing file " + _name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return _pos;
|
return _pos;
|
||||||
}
|
}
|
||||||
|
@ -953,6 +953,29 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateEmptyMesh()
|
|||||||
return mesh._retn();
|
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
|
* SMESH_Gen_i::CreateMeshFromUNV
|
||||||
@ -965,7 +988,8 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
|
|||||||
throw ( SALOME::SALOME_Exception )
|
throw ( SALOME::SALOME_Exception )
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshesFromUNV" );
|
|
||||||
|
checkFileReadable( theFileName );
|
||||||
|
|
||||||
SMESH::SMESH_Mesh_var aMesh = createMesh();
|
SMESH::SMESH_Mesh_var aMesh = createMesh();
|
||||||
string aFileName;
|
string aFileName;
|
||||||
@ -1082,10 +1106,11 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMEDorSAUV( const char* theFileNa
|
|||||||
|
|
||||||
SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
|
SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName,
|
||||||
SMESH::DriverMED_ReadStatus& theStatus)
|
SMESH::DriverMED_ReadStatus& theStatus)
|
||||||
throw ( SALOME::SALOME_Exception )
|
throw ( SALOME::SALOME_Exception )
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" );
|
checkFileReadable( theFileName );
|
||||||
|
|
||||||
SMESH::mesh_array* result = CreateMeshesFromMEDorSAUV(theFileName, theStatus, "CreateMeshesFromMED", theFileName);
|
SMESH::mesh_array* result = CreateMeshesFromMEDorSAUV(theFileName, theStatus, "CreateMeshesFromMED", theFileName);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1103,7 +1128,8 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromSAUV( const char* theFileName,
|
|||||||
throw ( SALOME::SALOME_Exception )
|
throw ( SALOME::SALOME_Exception )
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromSAUV" );
|
checkFileReadable( theFileName );
|
||||||
|
|
||||||
std::string sauvfilename(theFileName);
|
std::string sauvfilename(theFileName);
|
||||||
std::string medfilename(theFileName);
|
std::string medfilename(theFileName);
|
||||||
medfilename += ".med";
|
medfilename += ".med";
|
||||||
@ -1142,7 +1168,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName
|
|||||||
throw ( SALOME::SALOME_Exception )
|
throw ( SALOME::SALOME_Exception )
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshesFromSTL" );
|
checkFileReadable( theFileName );
|
||||||
|
|
||||||
SMESH::SMESH_Mesh_var aMesh = createMesh();
|
SMESH::SMESH_Mesh_var aMesh = createMesh();
|
||||||
//string aFileName;
|
//string aFileName;
|
||||||
@ -1184,6 +1210,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char* theFileName,
|
|||||||
throw ( SALOME::SALOME_Exception )
|
throw ( SALOME::SALOME_Exception )
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
|
checkFileReadable( theFileName );
|
||||||
|
|
||||||
SMESH::mesh_array_var aResult = new SMESH::mesh_array();
|
SMESH::mesh_array_var aResult = new SMESH::mesh_array();
|
||||||
|
|
||||||
@ -1271,6 +1298,7 @@ SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName,
|
|||||||
throw ( SALOME::SALOME_Exception )
|
throw ( SALOME::SALOME_Exception )
|
||||||
{
|
{
|
||||||
Unexpect aCatch(SALOME_SalomeException);
|
Unexpect aCatch(SALOME_SalomeException);
|
||||||
|
checkFileReadable( theFileName );
|
||||||
|
|
||||||
SMESH::SMESH_Mesh_var aMesh = createMesh();
|
SMESH::SMESH_Mesh_var aMesh = createMesh();
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user