Salome HOME
first fix of digue tests
[modules/hydro.git] / doc / salome / examples / h014_caseDigueManualInterpolZ.py
index bab32b468a56055d2070abba8d3c36ee67fb20c1..ce536cfee2380206bf3850f1fc1d82b16f2acd19 100644 (file)
@@ -8,9 +8,9 @@ import salome
 
 salome.salome_init()
 theStudy = salome.myStudy
-  
+
 #----------------------
-# --- HYDRO 
+# --- HYDRO
 #----------------------
 
 from HYDROPy import *
@@ -27,7 +27,8 @@ garonne_ign_01.SetName( "garonne_ign_01" )
 garonne_ign_01.SetZLevel( 0 )
 
 
-garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))
+if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))):
+  raise ValueError('problem while loading image')
 
 garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ),
                                QPoint( 1325, 85 ) )
@@ -44,7 +45,8 @@ garonne_ign_02.SetName( "garonne_ign_02" )
 garonne_ign_02.SetZLevel( 1 )
 
 
-garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))
+if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))):
+  raise ValueError('problem while loading image')
 
 garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ),
                                QPoint( 784, 481 ) )
@@ -217,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()
 
@@ -226,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()
 
@@ -368,7 +372,7 @@ garonne_2_digue.SetName("garonne_2_digue")
 garonne_2_entry = garonne_2.Export( theStudy._get_StudyId() )
 
 #----------------------
-# --- Geometry 
+# --- Geometry
 #----------------------
 
 # Get geometry shape and print debug information
@@ -396,10 +400,10 @@ geompy.UnionIDs(SectionsGaronne, [4, 11])
 geompy.addToStudyInFather( HYDRO_garonne_2, SectionsGaronne, 'SectionsGaronne' )
 
 SectionsDigue = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(SectionsDigue, [46, 50])
+geompy.UnionIDs(SectionsDigue, [43, 48])
 geompy.addToStudyInFather( HYDRO_garonne_2, SectionsDigue, 'SectionsDigue' )
 
-# --- recreate subshapes already exported from HYDRO to get access from Python 
+# --- recreate subshapes already exported from HYDRO to get access from Python
 #garonne_2_domaineEtendu_Outer = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
 #geompy.UnionIDs(garonne_2_domaineEtendu_Outer, [4, 11, 17, 24, 26, 28, 14, 19, 20, 22, 31, 39, 41, 33, 35, 37])
 #garonne_2_digue_Left_Bank = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
@@ -413,13 +417,13 @@ geompy.addToStudyInFather( HYDRO_garonne_2, SectionsDigue, 'SectionsDigue' )
 #garonne_2_digue_Right_Bank = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"])
 #geompy.UnionIDs(garonne_2_digue_Right_Bank, [48])
 
-controlGeomProps(geompy, riveGauche,  39493.270103, 35885901.558025)
-controlGeomProps(geompy, digue,       10343.900923,   103893.397004)
-controlGeomProps(geompy, litMineur,   30337.548492,  3646827.749809)
-controlGeomProps(geompy, riveDroite,  32012.343241, 26177085.460092)
+controlGeomProps(geompy, riveGauche,  39490.835288, 35845737.590926)
+controlGeomProps(geompy, digue,       10341.466108,   103090.760662)
+controlGeomProps(geompy, litMineur,   30337.548492,  3488480.304388)
+controlGeomProps(geompy, riveDroite,  32012.343241, 25998769.23615)
 
 #----------------------
-# --- Meshing 
+# --- Meshing
 #----------------------
 
 import  SMESH, SALOMEDS
@@ -471,6 +475,7 @@ isDone = garonne_2.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur
 # --- compute mesh
 isDone = garonne_2.Compute()
 isDone = garonne_2.SplitQuadObject( garonne_2, 1 )
+isDone = garonne_2.ReorientObject( garonne_2 )
 
 # --- geometrical groups of edges
 #garonne_2_litMineur_Outer_1 = garonne_2.GroupOnGeom(garonne_2_litMineur_Outer,'garonne_2_litMineur_Outer',SMESH.EDGE)
@@ -501,9 +506,23 @@ digue_2 = garonne_2.GroupOnGeom(digue,'digue',SMESH.NODE)
 #bordDroiteDomaine_2 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE)
 SectionsGaronne_3 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE)
 
+
+med_file = r'/tmp/garonne_2.med'
+
+try:
+  os.remove(med_file)
+except OSError:
+  pass
+
+
 garonne_2.SetAutoColor( 1 )
-garonne_2.ExportMED( r'/tmp/garonne_2.med', 0, SMESH.MED_V2_2, 1, None ,1)
+garonne_2.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1)
 
+#controlMeshStats(garonne_2, 5247, 717, 10075)
+#controlSubMeshStats(litMineur_2, 2384)
+#controlSubMeshStats(riveDroite_1, 2348)
+#controlSubMeshStats(riveGauche_1, 5343)
+#controlSubMeshStats(digue_1, 0)
 controlMeshStats(garonne_2, 6190, 691, 12201)
 controlSubMeshStats(litMineur_2, 2384)
 controlSubMeshStats(riveDroite_1, 2400)
@@ -514,7 +533,7 @@ if salome.sg.hasDesktop():
   salome.sg.updateObjBrowser(1)
 
 #----------------------
-# --- Z interpolation with HYDRO 
+# --- Z interpolation with HYDRO
 #----------------------
 
 from salome.hydrotools.interpolZ import interpolZ, createZfield2
@@ -524,7 +543,7 @@ from salome.hydrotools.controls import controlStatZ
 nomCas = 'garonne_2'
 
 # --- med file 2D(x,y) of the case produced by SMESH
-fichierMaillage = '/tmp/garonne_2.med'
+fichierMaillage = med_file
 
 # --- dictionary [med group name] = region name
 dicoGroupeRegion= dict(litMineur  = 'garonne_2_litMineur',
@@ -532,13 +551,13 @@ dicoGroupeRegion= dict(litMineur  = 'garonne_2_litMineur',
                        riveGauche = 'garonne_2_riveGauche',
                        digue      = 'garonne_2_digue',
                        )
-# --- value to use for Z when the node is not in a region (used to detect problems)                       
+# --- value to use for Z when the node is not in a region (used to detect problems)
 zUndef = 90
 
 # --- Z interpolation on the bathymety/altimetry on the mesh nodes
 statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef)
-#refstatz = {'riveDroite': (10.88, 32.47999954), 'riveGauche': (7.72, 71.38999939), 'litMineur': (2.06, 25.41)}
-#controlStatZ(statz, refstatz)
+refstatz = {'riveDroite': (10.88, 32.47999954), 'riveGauche': (7.72, 71.38999939), 'litMineur': (2.06, 25.41), 'digue': (14.10,27.09)}
+controlStatZ(statz, refstatz)
 
 # --- add a field on nodes of type double with z values, named "BOTTOM"
 createZfield2(fichierMaillage)