X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=doc%2Fsalome%2Fexamples%2Fh011_normalCaseManualInterpolZ.py;h=74231688224682f8d1b05557eaa82fbd8e71fe8e;hb=ccf1fc3746f78940dffc56d4958695c39a2a3088;hp=cf9560070583e16643fb11285333b4eec3baf2ad;hpb=4d422c4f2dc05c85f0924db65ab87a8d5deacea8;p=modules%2Fhydro.git diff --git a/doc/salome/examples/h011_normalCaseManualInterpolZ.py b/doc/salome/examples/h011_normalCaseManualInterpolZ.py index cf956007..74231688 100644 --- a/doc/salome/examples/h011_normalCaseManualInterpolZ.py +++ b/doc/salome/examples/h011_normalCaseManualInterpolZ.py @@ -8,14 +8,14 @@ import salome salome.salome_init() theStudy = salome.myStudy - + #---------------------- -# --- HYDRO +# --- HYDRO #---------------------- from HYDROPy import * -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() ) @@ -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 ) ) @@ -197,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() @@ -206,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() @@ -270,16 +274,31 @@ garonne_1.Update() garonne_1_litMineur = hydro_doc.FindObjectByName( "garonne_1_Reg_1" ) garonne_1_Zone_1 = hydro_doc.FindObjectByName( "garonne_1_Zone_1" ) garonne_1_Zone_1.SetMergeType( HYDROData_Zone.Merge_ZMIN ) +garonne_1_Zone_1.SetColor( QColor( 192, 113, 64 )) garonne_1_litMineur.AddZone( garonne_1_Zone_1 ) + garonne_1_riveDroite = hydro_doc.FindObjectByName( "garonne_1_Reg_2" ) garonne_1_Zone_2 = hydro_doc.FindObjectByName( "garonne_1_Zone_2" ) +garonne_1_Zone_2.SetColor( QColor( 141, 192, 64 )) garonne_1_riveDroite.AddZone( garonne_1_Zone_2 ) + garonne_1_Zone_3 = hydro_doc.FindObjectByName( "garonne_1_Zone_3" ) +garonne_1_Zone_3.SetMergeType( HYDROData_Zone.Merge_Object ) +Cloud_02 = hydro_doc.FindObjectByName( "Cloud_02" ) +garonne_1_Zone_3.SetMergeObject( Cloud_02 ) +garonne_1_Zone_3.SetColor( QColor( 64, 192, 77 )) garonne_1_riveDroite.AddZone( garonne_1_Zone_3 ) + garonne_1_riveGauche = hydro_doc.FindObjectByName( "garonne_1_Reg_3" ) garonne_1_Zone_4 = hydro_doc.FindObjectByName( "garonne_1_Zone_4" ) +garonne_1_Zone_4.SetMergeType( HYDROData_Zone.Merge_Object ) +Cloud_02 = hydro_doc.FindObjectByName( "Cloud_02" ) +garonne_1_Zone_4.SetMergeObject( Cloud_02 ) +garonne_1_Zone_4.SetColor( QColor( 64, 75, 192 )) garonne_1_riveGauche.AddZone( garonne_1_Zone_4 ) + garonne_1_Zone_5 = hydro_doc.FindObjectByName( "garonne_1_Zone_5" ) +garonne_1_Zone_5.SetColor( QColor( 64, 192, 77 )) garonne_1_riveGauche.AddZone( garonne_1_Zone_5 ) garonne_1_litMineur.SetName("garonne_1_litMineur") @@ -290,7 +309,7 @@ garonne_1_riveGauche.SetName("garonne_1_riveGauche") garonne_1_entry = garonne_1.Export( theStudy._get_StudyId() ) #---------------------- -# --- Geometry +# --- Geometry #---------------------- # Get geometry shape and print debug information @@ -307,14 +326,14 @@ HYDRO_garonne_1 = salome.IDToObject( str( garonne_1_entry ) ) print "Geom shape:", HYDRO_garonne_1 print "Geom shape name:", HYDRO_garonne_1.GetName() -# --- manual definition: geometrical faces +# --- manual definition: geometrical faces [riveGauche,litMineur,riveDroite] = geompy.ExtractShapes(HYDRO_garonne_1, geompy.ShapeType["FACE"], True) # --- manual definition: useful groups of edges garonne_1_litMineur_Outer = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(garonne_1_litMineur_Outer, [7, 9]) garonne_1_domaineEtendu_Outer = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) -geompy.UnionIDs(garonne_1_domaineEtendu_Outer, [4, 11, 17, 24, 26, 28, 14, 19, 20, 22, 31, 39, 41, 33, 35, 37]) +geompy.UnionIDs(garonne_1_domaineEtendu_Outer, [4, 11, 14, 16, 18, 20, 22, 24, 27, 29, 31, 33]) aval = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(aval, [4]) @@ -323,9 +342,9 @@ geompy.UnionIDs(amont, [11]) SectionsGaronne = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(SectionsGaronne, [4, 11]) bordGaucheDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) -geompy.UnionIDs(bordGaucheDomaine, [14, 28, 20, 24, 19, 17, 26, 22]) +geompy.UnionIDs(bordGaucheDomaine, [127, 30, 31, 33]) bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) -geompy.UnionIDs(bordDroiteDomaine, [41, 35, 31, 33, 39, 37]) +geompy.UnionIDs(bordDroiteDomaine, [14, 16, 18, 20, 22, 24]) # --- publications dans l'étude geompy.addToStudyInFather( HYDRO_garonne_1, riveGauche, 'riveGauche' ) @@ -338,14 +357,22 @@ geompy.addToStudyInFather( HYDRO_garonne_1, bordGaucheDomaine, 'bordGaucheDomain geompy.addToStudyInFather( HYDRO_garonne_1, bordDroiteDomaine, 'bordDroiteDomaine' ) # --- basic properties control: edges length, surfaces -controlGeomProps(geompy, riveGauche, 29149.36918, 35992556.454929) -controlGeomProps(geompy, litMineur, 30337.548492, 3646827.749809) -controlGeomProps(geompy, riveDroite, 32012.343241, 26177085.460092) + +controlGeomProps(geompy, riveGauche, 29149.36918, 35948828.352061) +controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) +controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) #---------------------- -# --- Meshing +# --- Meshing #---------------------- +med_file = r'/tmp/garonne_1.med' +try: + os.remove(med_file) +except OSError: + pass + + import SMESH, SALOMEDS from salome.smesh import smeshBuilder from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats @@ -383,6 +410,7 @@ isDone = garonne_1.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur # --- compute mesh isDone = garonne_1.Compute() isDone = garonne_1.SplitQuadObject( garonne_1, 1 ) +isDone = garonne_1.ReorientObject( garonne_1 ) # --- geometrical groups of edges garonne_1_litMineur_Outer_1 = garonne_1.GroupOnGeom(garonne_1_litMineur_Outer,'garonne_1_litMineur_Outer',SMESH.EDGE) @@ -411,7 +439,7 @@ bordDroiteDomaine_2 = garonne_1.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine SectionsGaronne_3 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) garonne_1.SetAutoColor( 1 ) -garonne_1.ExportMED( r'/tmp/garonne_1.med', 0, SMESH.MED_V2_2, 1, None ,1) +garonne_1.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) controlMeshStats(garonne_1, 3888, 475, 7597) controlSubMeshStats(litMineur_2, 2384) @@ -422,7 +450,7 @@ if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) #---------------------- -# --- Z interpolation with HYDRO +# --- Z interpolation with HYDRO #---------------------- from salome.hydrotools.interpolZ import interpolZ, createZfield2 @@ -432,19 +460,22 @@ from salome.hydrotools.controls import controlStatZ nomCas = 'garonne_1' # --- med file 2D(x,y) of the case produced by SMESH -fichierMaillage = '/tmp/garonne_1.med' +fichierMaillage = med_file # --- dictionary [med group name] = region name dicoGroupeRegion= dict(litMineur = 'garonne_1_litMineur', riveDroite = 'garonne_1_riveDroite', riveGauche = 'garonne_1_riveGauche', ) -# --- 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)} +#print statz +refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.2), + 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.2), + 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)} controlStatZ(statz, refstatz) # --- add a field on nodes of type double with z values, named "BOTTOM"