Salome HOME
Initial merge of branch 'BR_HYDRO_IMPS_2016' into BR_PORTING_OCCT_7
[modules/hydro.git] / doc / salome / examples / h010_normalCaseManualMesh.py
index 42ce8c920f7f2c76f41b22d0fedbc109d59c57b5..db0e6ff5897960a510d9fcf5597515cdd0578c78 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 ) )
@@ -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()
 
@@ -253,7 +257,6 @@ garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION )
 garonne_1.SetName( "garonne_1" )
 
 garonne_1.SetAssignmentMode( HYDROData_CalculationCase.MANUAL )
-garonne_1.SetAssignmentLandCoverMode( HYDROData_CalculationCase.AUTOMATIC )
 garonne_1.AddGeometryObject( litMineur )
 garonne_1.AddGeometryObject( domaineEtendu )
 garonne_1.AddGeometryObject( litMajeur )
@@ -291,7 +294,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
@@ -308,7 +311,7 @@ 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
@@ -339,14 +342,23 @@ 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.5484919,  3263628.55399)
+#controlGeomProps(geompy, riveDroite,  32012.3432411, 26177085.4601)
+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
@@ -384,6 +396,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)
@@ -412,8 +425,12 @@ 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, 1763, 180, 3360)
+#controlSubMeshStats(litMineur_2, 48)
+#controlSubMeshStats(riveDroite_1, 1360)
+#controlSubMeshStats(riveGauche_1, 1952)
 controlMeshStats(garonne_1, 3888, 475, 7597)
 controlSubMeshStats(litMineur_2, 2384)
 controlSubMeshStats(riveDroite_1, 2342)