from PyQt5.QtCore import *
from PyQt5.QtGui import *
+from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy
+
hydro_doc = HYDROData_Document.Document()
offsetX = 430000.
offsetY = 6350000.
hydro_doc.SetLocalCS( offsetX, offsetY )
-name = "garonne"
-shape = os.path.join(HYDRO_SAMPLES, name+".shp" )
-HYDROData_PolylineXY.ImportShapesFromFile(shape)
-garonne = hydro_doc.FindObjectByName(name + '_PolyXY_0')
-for i in range(garonne.NbSections()):
- garonne.SetSectionType(i, 1) # spline
- garonne.Update()
-garonne.SetZLevel( 2 )
-
-name = "lit_majeur"
-shape = os.path.join(HYDRO_SAMPLES, name+".shp" )
-HYDROData_PolylineXY.ImportShapesFromFile(shape)
-lit_majeur = hydro_doc.FindObjectByName(name + '_PolyXY_0')
-for i in range(lit_majeur.NbSections()):
- lit_majeur.SetSectionType(i, 1) # spline
- lit_majeur.Update()
-lit_majeur.SetZLevel( 3 )
-
-name = "ile"
-shape = os.path.join(HYDRO_SAMPLES, name+".shp" )
-HYDROData_PolylineXY.ImportShapesFromFile(shape)
-ile = hydro_doc.FindObjectByName(name + '_PolyXY_0')
-for i in range(ile.NbSections()):
- ile.SetSectionType(i, 1) # spline
- ile.Update()
-ile.SetZLevel( 4 )
-
-name = "domaine"
-shape = os.path.join(HYDRO_SAMPLES, name+".shp" )
-HYDROData_PolylineXY.ImportShapesFromFile(shape)
-domaine = hydro_doc.FindObjectByName(name + '_PolyXY_0')
-for i in range(domaine.NbSections()):
- domaine.SetSectionType(i, 0) # polyline
- domaine.Update()
-domaine.SetZLevel( 5 )
-
-Cloud_02 = hydro_doc.CreateObject( KIND_BATHYMETRY )
-Cloud_02.SetName( "Cloud_02" )
-
-Cloud_02.SetAltitudesInverted( 0 )
-if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))):
- raise ValueError('problem while loading bathymetry')
-
-Cloud_02.Update()
-
-
-garonne_point_L93 = hydro_doc.CreateObject( KIND_BATHYMETRY )
-garonne_point_L93.SetName( "garonne_point_L93" )
-
-garonne_point_L93.SetAltitudesInverted( 0 )
-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()
-
-
-litMineur = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
-litMineur.SetName( "litMineur" )
-
-litMineur.SetZLevel( 6 )
-
-litMineur.SetAltitudeObject( garonne_point_L93 )
-litMineur.SetPolyline( garonne )
-
-litMineur.Update()
+limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 7)
+garonnes = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne.shp"), "garonne_PolyXY", True, 6)
+lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 5)
+iles = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "ile.shp"), "ile_PolyXY", True, 4)
+Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES)
+garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES)
-litMajeur = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
-litMajeur.SetName( "litMajeur" )
-
-litMajeur.SetZLevel( 5 )
-
-litMajeur.SetFillingColor( QColor( 0, 170, 127, 255 ) )
-
-litMajeur.SetAltitudeObject( garonne_point_L93 )
-litMajeur.SetPolyline( lit_majeur )
-
-litMajeur.Update()
-
-ilot = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
-ilot.SetName( "ilot" )
-
-ilot.SetZLevel( 9 )
-
-ilot.SetPolyline( ile )
-ilot.SetIsSubmersible(False)
-
-ilot.Update()
-
-domaineEtendu = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE )
-domaineEtendu.SetName( "domaineEtendu" )
-
-domaineEtendu.SetZLevel( 4 )
-
-domaineEtendu.SetFillingColor( QColor( 201, 203, 55, 255 ) )
-
-domaineEtendu.SetAltitudeObject( Cloud_02 )
-domaineEtendu.SetPolyline( domaine )
-
-domaineEtendu.Update()
-
+domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 0)
+litMineur = createImmersibleZone(hydro_doc, "litMineur", garonnes[0], garonne_point_L93, True, 2)
+litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 1)
+ilot = createImmersibleZone(hydro_doc, "ilot", iles[0], garonne_point_L93, False, 3)
# Calculation case
garonne_2 = hydro_doc.CreateObject( KIND_CALCULATION )
garonne_2.AddGeometryGroup( case_geom_group )
case_geom_group = litMajeur.GetGroup( 0 )
garonne_2.AddGeometryGroup( case_geom_group )
-garonne_2.SetBoundaryPolyline( domaine )
+
+garonne_2.SetBoundaryPolyline( limites_domaine[0] )
# Start the algorithm of the partition and assignment
garonne_2.Update()