From 0496b1aabd8b1e305fcfb3e79923f61ec9679d2c Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Tue, 5 Jan 2016 14:22:31 +0100 Subject: [PATCH] =?utf8?q?d=C3=A9tection=20des=20probl=C3=A8mes=20de=20cha?= =?utf8?q?rgement=20de=20bathym=C3=A9trie?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- doc/salome/examples/h004_importBathyXYZ.py | 3 ++- doc/salome/examples/h006_importBathyXYZBad.py | 8 +++----- doc/salome/examples/h009_normalCaseManual.py | 6 ++++-- doc/salome/examples/h010_normalCaseManualMesh.py | 6 ++++-- doc/salome/examples/h011_normalCaseManualInterpolZ.py | 6 ++++-- doc/salome/examples/h012_caseDigueManual.py | 6 ++++-- doc/salome/examples/h013_caseDigueManualMesh.py | 6 ++++-- doc/salome/examples/h014_caseDigueManualInterpolZ.py | 6 ++++-- doc/salome/examples/h015_normalCaseManualTelemac.py | 6 ++++-- src/HYDROData/HYDROData_Bathymetry.cxx | 4 ++-- 10 files changed, 35 insertions(+), 22 deletions(-) diff --git a/doc/salome/examples/h004_importBathyXYZ.py b/doc/salome/examples/h004_importBathyXYZ.py index 6dc8d699..369a7e37 100644 --- a/doc/salome/examples/h004_importBathyXYZ.py +++ b/doc/salome/examples/h004_importBathyXYZ.py @@ -21,7 +21,8 @@ Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_02.SetName( "Cloud_02" ) Cloud_02.SetAltitudesInverted( 0 ); -Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" )) +if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))): + raise ValueError('problem while loading bathymetry') Cloud_02.Update() diff --git a/doc/salome/examples/h006_importBathyXYZBad.py b/doc/salome/examples/h006_importBathyXYZBad.py index 3a24a9f2..d41226e4 100644 --- a/doc/salome/examples/h006_importBathyXYZBad.py +++ b/doc/salome/examples/h006_importBathyXYZBad.py @@ -21,12 +21,10 @@ Cloud_inexistant = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_inexistant.SetName( "Cloud_inexistant" ) Cloud_inexistant.SetAltitudesInverted( 0 ); -Cloud_inexistant.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_inexistant.xyz" )) +ret = Cloud_inexistant.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_inexistant.xyz" )) -# TODO : ce chargement doit echouer avec un retour d'erreur à traiter -raise ValueError('file not found') - -Cloud_inexistant.Update() +if ret: + raise ValueError('loading problem not detected: return value should be null') if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h009_normalCaseManual.py b/doc/salome/examples/h009_normalCaseManual.py index cd407f19..f15bf500 100644 --- a/doc/salome/examples/h009_normalCaseManual.py +++ b/doc/salome/examples/h009_normalCaseManual.py @@ -199,7 +199,8 @@ Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_02.SetName( "Cloud_02" ) Cloud_02.SetAltitudesInverted( 0 ) -Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" )) +if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))): + raise ValueError('problem while loading bathymetry') Cloud_02.Update() @@ -208,7 +209,8 @@ garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY ) garonne_point_L93.SetName( "garonne_point_L93" ) garonne_point_L93.SetAltitudesInverted( 0 ) -garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" )) +if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))): + raise ValueError('problem while loading bathymetry') garonne_point_L93.Update() diff --git a/doc/salome/examples/h010_normalCaseManualMesh.py b/doc/salome/examples/h010_normalCaseManualMesh.py index 6c5272d0..d7f88d13 100644 --- a/doc/salome/examples/h010_normalCaseManualMesh.py +++ b/doc/salome/examples/h010_normalCaseManualMesh.py @@ -199,7 +199,8 @@ Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_02.SetName( "Cloud_02" ) Cloud_02.SetAltitudesInverted( 0 ) -Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" )) +if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))): + raise ValueError('problem while loading bathymetry') Cloud_02.Update() @@ -208,7 +209,8 @@ garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY ) garonne_point_L93.SetName( "garonne_point_L93" ) garonne_point_L93.SetAltitudesInverted( 0 ) -garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" )) +if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))): + raise ValueError('problem while loading bathymetry') garonne_point_L93.Update() diff --git a/doc/salome/examples/h011_normalCaseManualInterpolZ.py b/doc/salome/examples/h011_normalCaseManualInterpolZ.py index 49282307..cbd67350 100644 --- a/doc/salome/examples/h011_normalCaseManualInterpolZ.py +++ b/doc/salome/examples/h011_normalCaseManualInterpolZ.py @@ -199,7 +199,8 @@ Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_02.SetName( "Cloud_02" ) Cloud_02.SetAltitudesInverted( 0 ) -Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" )) +if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))): + raise ValueError('problem while loading bathymetry') Cloud_02.Update() @@ -208,7 +209,8 @@ garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY ) garonne_point_L93.SetName( "garonne_point_L93" ) garonne_point_L93.SetAltitudesInverted( 0 ) -garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" )) +if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))): + raise ValueError('problem while loading bathymetry') garonne_point_L93.Update() diff --git a/doc/salome/examples/h012_caseDigueManual.py b/doc/salome/examples/h012_caseDigueManual.py index 6b679b4b..311cbaf7 100644 --- a/doc/salome/examples/h012_caseDigueManual.py +++ b/doc/salome/examples/h012_caseDigueManual.py @@ -219,7 +219,8 @@ Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_02.SetName( "Cloud_02" ) Cloud_02.SetAltitudesInverted( 0 ) -Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" )) +if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))): + raise ValueError('problem while loading bathymetry') Cloud_02.Update() @@ -228,7 +229,8 @@ garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY ) garonne_point_L93.SetName( "garonne_point_L93" ) garonne_point_L93.SetAltitudesInverted( 0 ) -garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" )) +if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))): + raise ValueError('problem while loading bathymetry') garonne_point_L93.Update() diff --git a/doc/salome/examples/h013_caseDigueManualMesh.py b/doc/salome/examples/h013_caseDigueManualMesh.py index 6e013f8d..ab55e730 100644 --- a/doc/salome/examples/h013_caseDigueManualMesh.py +++ b/doc/salome/examples/h013_caseDigueManualMesh.py @@ -219,7 +219,8 @@ Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_02.SetName( "Cloud_02" ) Cloud_02.SetAltitudesInverted( 0 ) -Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" )) +if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))): + raise ValueError('problem while loading bathymetry') Cloud_02.Update() @@ -228,7 +229,8 @@ garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY ) garonne_point_L93.SetName( "garonne_point_L93" ) garonne_point_L93.SetAltitudesInverted( 0 ) -garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" )) +if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))): + raise ValueError('problem while loading bathymetry') garonne_point_L93.Update() diff --git a/doc/salome/examples/h014_caseDigueManualInterpolZ.py b/doc/salome/examples/h014_caseDigueManualInterpolZ.py index 174c6bee..501fd091 100644 --- a/doc/salome/examples/h014_caseDigueManualInterpolZ.py +++ b/doc/salome/examples/h014_caseDigueManualInterpolZ.py @@ -219,7 +219,8 @@ Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_02.SetName( "Cloud_02" ) Cloud_02.SetAltitudesInverted( 0 ) -Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" )) +if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))): + raise ValueError('problem while loading bathymetry') Cloud_02.Update() @@ -228,7 +229,8 @@ garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY ) garonne_point_L93.SetName( "garonne_point_L93" ) garonne_point_L93.SetAltitudesInverted( 0 ) -garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" )) +if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))): + raise ValueError('problem while loading bathymetry') garonne_point_L93.Update() diff --git a/doc/salome/examples/h015_normalCaseManualTelemac.py b/doc/salome/examples/h015_normalCaseManualTelemac.py index 5395883f..2d5db353 100644 --- a/doc/salome/examples/h015_normalCaseManualTelemac.py +++ b/doc/salome/examples/h015_normalCaseManualTelemac.py @@ -199,7 +199,8 @@ Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY ) Cloud_02.SetName( "Cloud_02" ) Cloud_02.SetAltitudesInverted( 0 ) -Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" )) +if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))): + raise ValueError('problem while loading bathymetry') Cloud_02.Update() @@ -208,7 +209,8 @@ garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY ) garonne_point_L93.SetName( "garonne_point_L93" ) garonne_point_L93.SetAltitudesInverted( 0 ) -garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" )) +if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))): + raise ValueError('problem while loading bathymetry') garonne_point_L93.Update() diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index baaf0cd3..bc7e75b4 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -81,9 +81,9 @@ QStringList HYDROData_Bathymetry::DumpToPython( const QString& thePyScriptPath, .arg( aBathymetryName ).arg( IsAltitudesInverted() ); TCollection_AsciiString aFilePath = GetFilePath(); - aResList << QString( "%1.ImportFromFile( \"%2\" )" ) + aResList << QString( "if not(%1.ImportFromFile( \"%2\" )):" ) .arg( aBathymetryName ).arg( aFilePath.ToCString() ); - + aResList << QString( " raise ValueError('problem while loading bathymetry')" ); aResList << QString( "" ); aResList << QString( "%1.Update()" ).arg( aBathymetryName ); aResList << QString( "" ); -- 2.39.2