From: Paul RASCLE Date: Mon, 16 Nov 2020 15:46:39 +0000 (+0100) Subject: use hydroGeoMeshUtils in scripts: lot1, h009, h010, h011, h015, h020, h021 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=67ef35a7c261e6b9fb2866e89a9d8d2f5bf244b0;p=modules%2Fhydro.git use hydroGeoMeshUtils in scripts: lot1, h009, h010, h011, h015, h020, h021 --- diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index b07a6757..7b38f76f 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -63,6 +63,8 @@ SET(HYDRO_SAMPLES garonne_ign_02.png Cloud_02.xyz garonne_point_L93.xyz + axeDigue.shp + axeDigue.shx constraint1.shp constraint1.shx constraint2.shp diff --git a/doc/salome/examples/axeDigue.shp b/doc/salome/examples/axeDigue.shp new file mode 100644 index 00000000..39c61158 Binary files /dev/null and b/doc/salome/examples/axeDigue.shp differ diff --git a/doc/salome/examples/axeDigue.shx b/doc/salome/examples/axeDigue.shx new file mode 100644 index 00000000..87fd24f8 Binary files /dev/null and b/doc/salome/examples/axeDigue.shx differ diff --git a/doc/salome/examples/h009_normalCaseManual.py b/doc/salome/examples/h009_normalCaseManual.py index b0fd629c..14f3afe2 100644 --- a/doc/salome/examples/h009_normalCaseManual.py +++ b/doc/salome/examples/h009_normalCaseManual.py @@ -2,6 +2,13 @@ import os HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO") +HYDRO_TEST_RESOURCES = os.path.join(os.environ["HYDRO_DIR"], "bin", "salome", "test", "tmp_test") +if not os.path.isdir(HYDRO_TEST_RESOURCES): + os.mkdir(HYDRO_TEST_RESOURCES) + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) import sys import salome @@ -16,240 +23,35 @@ from HYDROPy import * from PyQt5.QtCore import * from PyQt5.QtGui import * -hydro_doc = HYDROData_Document.Document() - -hydro_doc.SetLocalCS( 430000, 6.35e+06 ) - -garonne_ign_01 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_01.SetName( "garonne_ign_01" ) - -garonne_ign_01.SetZLevel( 0 ) - - -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 ) ) - -garonne_ign_01.SetGlobalPoints( 1, - QPointF( 471562, 6.36775e+06 ), - QPointF( 489400, 6.37702e+06 ) ) - -garonne_ign_01.Update() - -garonne_ign_02 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_02.SetName( "garonne_ign_02" ) - -garonne_ign_02.SetZLevel( 1 ) - - -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 ) ) - -garonne_ign_02.SetGlobalPoints( 3, - QPointF( 631, 95 ), - QPointF( 26, 129 ) ) -garonne_ign_02.SetTrsfReferenceImage( garonne_ign_01 ) - -garonne_ign_02.Update() - -garonne = hydro_doc.CreateObject( KIND_POLYLINEXY ) -garonne.SetName( "garonne" ) - -garonne.SetZLevel( 2 ) - -garonne.AddSection( "Section_1", 1, 1 ) -garonne.AddPoint( 0, gp_XY( 38191.48, 33184.55 ) ) -garonne.AddPoint( 0, gp_XY( 38553.78, 33013.53 ) ) -garonne.AddPoint( 0, gp_XY( 38993.90, 32767.64 ) ) -garonne.AddPoint( 0, gp_XY( 39678.58, 32533.58 ) ) -garonne.AddPoint( 0, gp_XY( 40240.26, 32305.27 ) ) -garonne.AddPoint( 0, gp_XY( 40717.94, 32193.70 ) ) -garonne.AddPoint( 0, gp_XY( 41361.00, 32464.18 ) ) -garonne.AddPoint( 0, gp_XY( 41831.41, 32626.69 ) ) -garonne.AddPoint( 0, gp_XY( 41950.14, 32618.24 ) ) -garonne.AddPoint( 0, gp_XY( 42524.97, 32419.61 ) ) -garonne.AddPoint( 0, gp_XY( 42909.80, 32291.33 ) ) -garonne.AddPoint( 0, gp_XY( 43177.03, 32269.95 ) ) -garonne.AddPoint( 0, gp_XY( 43465.65, 32344.78 ) ) -garonne.AddPoint( 0, gp_XY( 43754.27, 32152.37 ) ) -garonne.AddPoint( 0, gp_XY( 44128.40, 31842.37 ) ) -garonne.AddPoint( 0, gp_XY( 44003.90, 31269.93 ) ) -garonne.AddPoint( 0, gp_XY( 44010.82, 30869.63 ) ) -garonne.AddPoint( 0, gp_XY( 44064.26, 30655.84 ) ) -garonne.AddPoint( 0, gp_XY( 44434.73, 30366.18 ) ) -garonne.AddPoint( 0, gp_XY( 45208.04, 30484.81 ) ) -garonne.AddPoint( 0, gp_XY( 45705.01, 30287.34 ) ) -garonne.AddPoint( 0, gp_XY( 45933.89, 30046.87 ) ) -garonne.AddPoint( 0, gp_XY( 46127.34, 29490.68 ) ) -garonne.AddPoint( 0, gp_XY( 46111.60, 29226.08 ) ) -garonne.AddPoint( 0, gp_XY( 46228.62, 28784.05 ) ) -garonne.AddPoint( 0, gp_XY( 46247.64, 28449.75 ) ) -garonne.AddPoint( 0, gp_XY( 46108.48, 28086.94 ) ) -garonne.AddPoint( 0, gp_XY( 45618.52, 27553.74 ) ) -garonne.AddPoint( 0, gp_XY( 45276.77, 27042.78 ) ) -garonne.AddPoint( 0, gp_XY( 45001.89, 26273.15 ) ) -garonne.AddPoint( 0, gp_XY( 45167.76, 25975.34 ) ) -garonne.AddPoint( 0, gp_XY( 46018.15, 25848.84 ) ) -garonne.AddPoint( 0, gp_XY( 46378.94, 25872.21 ) ) -garonne.AddPoint( 0, gp_XY( 46885.57, 25937.64 ) ) -garonne.AddPoint( 0, gp_XY( 47278.36, 25782.88 ) ) -garonne.AddPoint( 0, gp_XY( 47153.86, 25728.04 ) ) -garonne.AddPoint( 0, gp_XY( 46987.51, 25749.97 ) ) -garonne.AddPoint( 0, gp_XY( 46658.26, 25715.71 ) ) -garonne.AddPoint( 0, gp_XY( 45650.76, 25634.46 ) ) -garonne.AddPoint( 0, gp_XY( 45122.63, 25748.21 ) ) -garonne.AddPoint( 0, gp_XY( 44797.63, 26325.09 ) ) -garonne.AddPoint( 0, gp_XY( 45114.51, 27168.75 ) ) -garonne.AddPoint( 0, gp_XY( 45508.28, 27713.21 ) ) -garonne.AddPoint( 0, gp_XY( 45994.19, 28382.53 ) ) -garonne.AddPoint( 0, gp_XY( 45927.01, 29201.34 ) ) -garonne.AddPoint( 0, gp_XY( 45756.39, 29859.47 ) ) -garonne.AddPoint( 0, gp_XY( 45390.76, 30151.97 ) ) -garonne.AddPoint( 0, gp_XY( 45039.85, 30120.84 ) ) -garonne.AddPoint( 0, gp_XY( 44513.26, 30084.28 ) ) -garonne.AddPoint( 0, gp_XY( 43923.42, 30426.28 ) ) -garonne.AddPoint( 0, gp_XY( 43768.81, 30934.29 ) ) -garonne.AddPoint( 0, gp_XY( 43820.10, 31425.20 ) ) -garonne.AddPoint( 0, gp_XY( 43854.78, 31801.12 ) ) -garonne.AddPoint( 0, gp_XY( 43479.64, 32053.54 ) ) -garonne.AddPoint( 0, gp_XY( 42923.47, 32051.85 ) ) -garonne.AddPoint( 0, gp_XY( 42493.64, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 42074.27, 32302.91 ) ) -garonne.AddPoint( 0, gp_XY( 41624.75, 32330.93 ) ) -garonne.AddPoint( 0, gp_XY( 41325.93, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 40879.52, 31987.29 ) ) -garonne.AddPoint( 0, gp_XY( 40308.78, 32018.46 ) ) -garonne.AddPoint( 0, gp_XY( 39782.86, 32207.17 ) ) -garonne.AddPoint( 0, gp_XY( 38814.10, 32560.43 ) ) -garonne.AddPoint( 0, gp_XY( 38302.17, 32903.70 ) ) - -garonne.Update() - - -domaine = hydro_doc.CreateObject( KIND_POLYLINEXY ) -domaine.SetName( "domaine" ) - -domaine.SetZLevel( 3 ) - -domaine.AddSection( "Section_1", 0, 1 ) -domaine.AddPoint( 0, gp_XY( 39901.15, 34762.30 ) ); -domaine.AddPoint( 0, gp_XY( 38086.50, 29964.69 ) ); -domaine.AddPoint( 0, gp_XY( 44835.83, 24264.97 ) ); -domaine.AddPoint( 0, gp_XY( 46758.56, 25021.86 ) ); -domaine.AddPoint( 0, gp_XY( 46757.20, 26601.21 ) ); -domaine.AddPoint( 0, gp_XY( 48566.45, 30152.81 ) ); -domaine.AddPoint( 0, gp_XY( 45532.36, 33239.83 ) ); -domaine.AddPoint( 0, gp_XY( 43548.77, 34048.39 ) ); - -domaine.Update() - - -lit_majeur = hydro_doc.CreateObject( KIND_POLYLINEXY ) -lit_majeur.SetName( "lit_majeur" ) - -lit_majeur.SetZLevel( 7 ) - -lit_majeur.AddSection( "Section_1", 1, 1 ) -lit_majeur.AddPoint( 0, gp_XY( 41225.22, 34118.46 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41716.41, 33705.87 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42384.43, 33293.27 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42561.26, 32684.19 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42875.62, 32369.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43700.82, 32350.18 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44526.02, 31662.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45370.87, 31819.69 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46274.66, 31682.16 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46981.97, 31328.50 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47021.27, 30719.43 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47217.74, 30051.41 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47846.46, 29560.22 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48730.61, 28735.02 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48809.20, 27732.99 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49143.21, 27163.21 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49654.05, 26829.20 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49693.34, 25355.63 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48612.72, 23214.04 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47453.51, 23115.80 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46471.13, 24176.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45960.29, 25257.39 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44899.32, 25591.40 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44270.60, 26573.78 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43248.92, 27909.82 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42757.73, 28243.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42266.54, 28342.07 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41736.06, 28106.30 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41402.05, 28833.26 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40910.86, 28911.85 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40576.85, 29324.45 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40144.60, 29599.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 39024.69, 30130.00 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38612.09, 30365.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38828.21, 33391.50 ) ) - -lit_majeur.Update() - - -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() - - -litMajeur = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -litMajeur.SetName( "litMajeur" ) - -litMajeur.SetZLevel( 5 ) - -litMajeur.SetFillingColor( QColor( 0, 170, 127, 255 ) ) - -litMajeur.SetAltitudeObject( Cloud_02 ) -litMajeur.SetPolyline( lit_majeur ) - -litMajeur.Update() +from salome.hydrotools.hydroGeoMeshUtils import loadImage, GeolocaliseImageCoords, GeolocaliseImageReference +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy +hydro_doc = HYDROData_Document.Document() -domaineEtendu = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -domaineEtendu.SetName( "domaineEtendu" ) +offsetX = 430000. +offsetY = 6350000. +hydro_doc.SetLocalCS( offsetX, offsetY ) -domaineEtendu.SetZLevel( 4 ) +garonne_ign_01 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png"), "garonne_ign_01", 0) +GeolocaliseImageCoords(garonne_ign_01, + QPoint(40, 817), QPoint(1325, 85), + QPointF(471562, 6.36775e+06), QPointF(489400, 6.37702e+06)) -domaineEtendu.SetFillingColor( QColor( 201, 203, 55, 255 ) ) +garonne_ign_02 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png"), "garonne_ign_02", 1) +GeolocaliseImageReference(garonne_ign_02, garonne_ign_01, + QPoint(1389, 447), QPoint(784, 481), + QPoint(631, 95), QPoint(26, 129)) -domaineEtendu.SetAltitudeObject( Cloud_02 ) -domaineEtendu.SetPolyline( domaine ) +garonnes = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne.shp"), "garonne_PolyXY", True, 5) +limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6) +lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7) -domaineEtendu.Update() +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) +garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES) +domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2) +litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3) +litMineur = createImmersibleZone(hydro_doc, "litMineur", garonnes[0], garonne_point_L93, True, 4) # Calculation case garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) @@ -266,8 +68,7 @@ case_geom_group = litMineur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) case_geom_group = litMajeur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) -garonne_1.SetBoundaryPolyline( domaine ) -#garonne_1.SetStricklerTable( Strickler_table_1 ) +garonne_1.SetBoundaryPolyline( limites_domaine[0] ) # Start the algorithm of the partition and assignment garonne_1.Update() diff --git a/doc/salome/examples/h010_normalCaseManualMesh.py b/doc/salome/examples/h010_normalCaseManualMesh.py index afc98701..ecb4c2f9 100644 --- a/doc/salome/examples/h010_normalCaseManualMesh.py +++ b/doc/salome/examples/h010_normalCaseManualMesh.py @@ -2,6 +2,13 @@ import os HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO") +HYDRO_TEST_RESOURCES = os.path.join(os.environ["HYDRO_DIR"], "bin", "salome", "test", "tmp_test") +if not os.path.isdir(HYDRO_TEST_RESOURCES): + os.mkdir(HYDRO_TEST_RESOURCES) + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) import sys import salome @@ -16,240 +23,35 @@ from HYDROPy import * from PyQt5.QtCore import * from PyQt5.QtGui import * -hydro_doc = HYDROData_Document.Document() - -hydro_doc.SetLocalCS( 430000, 6.35e+06 ) - -garonne_ign_01 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_01.SetName( "garonne_ign_01" ) - -garonne_ign_01.SetZLevel( 0 ) - - -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 ) ) - -garonne_ign_01.SetGlobalPoints( 1, - QPointF( 471562, 6.36775e+06 ), - QPointF( 489400, 6.37702e+06 ) ) - -garonne_ign_01.Update() - -garonne_ign_02 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_02.SetName( "garonne_ign_02" ) - -garonne_ign_02.SetZLevel( 1 ) - - -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 ) ) - -garonne_ign_02.SetGlobalPoints( 3, - QPointF( 631, 95 ), - QPointF( 26, 129 ) ) -garonne_ign_02.SetTrsfReferenceImage( garonne_ign_01 ) - -garonne_ign_02.Update() - -garonne = hydro_doc.CreateObject( KIND_POLYLINEXY ) -garonne.SetName( "garonne" ) - -garonne.SetZLevel( 2 ) - -garonne.AddSection( "Section_1", 1, 1 ) -garonne.AddPoint( 0, gp_XY( 38191.48, 33184.55 ) ) -garonne.AddPoint( 0, gp_XY( 38553.78, 33013.53 ) ) -garonne.AddPoint( 0, gp_XY( 38993.90, 32767.64 ) ) -garonne.AddPoint( 0, gp_XY( 39678.58, 32533.58 ) ) -garonne.AddPoint( 0, gp_XY( 40240.26, 32305.27 ) ) -garonne.AddPoint( 0, gp_XY( 40717.94, 32193.70 ) ) -garonne.AddPoint( 0, gp_XY( 41361.00, 32464.18 ) ) -garonne.AddPoint( 0, gp_XY( 41831.41, 32626.69 ) ) -garonne.AddPoint( 0, gp_XY( 41950.14, 32618.24 ) ) -garonne.AddPoint( 0, gp_XY( 42524.97, 32419.61 ) ) -garonne.AddPoint( 0, gp_XY( 42909.80, 32291.33 ) ) -garonne.AddPoint( 0, gp_XY( 43177.03, 32269.95 ) ) -garonne.AddPoint( 0, gp_XY( 43465.65, 32344.78 ) ) -garonne.AddPoint( 0, gp_XY( 43754.27, 32152.37 ) ) -garonne.AddPoint( 0, gp_XY( 44128.40, 31842.37 ) ) -garonne.AddPoint( 0, gp_XY( 44003.90, 31269.93 ) ) -garonne.AddPoint( 0, gp_XY( 44010.82, 30869.63 ) ) -garonne.AddPoint( 0, gp_XY( 44064.26, 30655.84 ) ) -garonne.AddPoint( 0, gp_XY( 44434.73, 30366.18 ) ) -garonne.AddPoint( 0, gp_XY( 45208.04, 30484.81 ) ) -garonne.AddPoint( 0, gp_XY( 45705.01, 30287.34 ) ) -garonne.AddPoint( 0, gp_XY( 45933.89, 30046.87 ) ) -garonne.AddPoint( 0, gp_XY( 46127.34, 29490.68 ) ) -garonne.AddPoint( 0, gp_XY( 46111.60, 29226.08 ) ) -garonne.AddPoint( 0, gp_XY( 46228.62, 28784.05 ) ) -garonne.AddPoint( 0, gp_XY( 46247.64, 28449.75 ) ) -garonne.AddPoint( 0, gp_XY( 46108.48, 28086.94 ) ) -garonne.AddPoint( 0, gp_XY( 45618.52, 27553.74 ) ) -garonne.AddPoint( 0, gp_XY( 45276.77, 27042.78 ) ) -garonne.AddPoint( 0, gp_XY( 45001.89, 26273.15 ) ) -garonne.AddPoint( 0, gp_XY( 45167.76, 25975.34 ) ) -garonne.AddPoint( 0, gp_XY( 46018.15, 25848.84 ) ) -garonne.AddPoint( 0, gp_XY( 46378.94, 25872.21 ) ) -garonne.AddPoint( 0, gp_XY( 46885.57, 25937.64 ) ) -garonne.AddPoint( 0, gp_XY( 47278.36, 25782.88 ) ) -garonne.AddPoint( 0, gp_XY( 47153.86, 25728.04 ) ) -garonne.AddPoint( 0, gp_XY( 46987.51, 25749.97 ) ) -garonne.AddPoint( 0, gp_XY( 46658.26, 25715.71 ) ) -garonne.AddPoint( 0, gp_XY( 45650.76, 25634.46 ) ) -garonne.AddPoint( 0, gp_XY( 45122.63, 25748.21 ) ) -garonne.AddPoint( 0, gp_XY( 44797.63, 26325.09 ) ) -garonne.AddPoint( 0, gp_XY( 45114.51, 27168.75 ) ) -garonne.AddPoint( 0, gp_XY( 45508.28, 27713.21 ) ) -garonne.AddPoint( 0, gp_XY( 45994.19, 28382.53 ) ) -garonne.AddPoint( 0, gp_XY( 45927.01, 29201.34 ) ) -garonne.AddPoint( 0, gp_XY( 45756.39, 29859.47 ) ) -garonne.AddPoint( 0, gp_XY( 45390.76, 30151.97 ) ) -garonne.AddPoint( 0, gp_XY( 45039.85, 30120.84 ) ) -garonne.AddPoint( 0, gp_XY( 44513.26, 30084.28 ) ) -garonne.AddPoint( 0, gp_XY( 43923.42, 30426.28 ) ) -garonne.AddPoint( 0, gp_XY( 43768.81, 30934.29 ) ) -garonne.AddPoint( 0, gp_XY( 43820.10, 31425.20 ) ) -garonne.AddPoint( 0, gp_XY( 43854.78, 31801.12 ) ) -garonne.AddPoint( 0, gp_XY( 43479.64, 32053.54 ) ) -garonne.AddPoint( 0, gp_XY( 42923.47, 32051.85 ) ) -garonne.AddPoint( 0, gp_XY( 42493.64, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 42074.27, 32302.91 ) ) -garonne.AddPoint( 0, gp_XY( 41624.75, 32330.93 ) ) -garonne.AddPoint( 0, gp_XY( 41325.93, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 40879.52, 31987.29 ) ) -garonne.AddPoint( 0, gp_XY( 40308.78, 32018.46 ) ) -garonne.AddPoint( 0, gp_XY( 39782.86, 32207.17 ) ) -garonne.AddPoint( 0, gp_XY( 38814.10, 32560.43 ) ) -garonne.AddPoint( 0, gp_XY( 38302.17, 32903.70 ) ) - -garonne.Update() - - -domaine = hydro_doc.CreateObject( KIND_POLYLINEXY ) -domaine.SetName( "domaine" ) - -domaine.SetZLevel( 3 ) - -domaine.AddSection( "Section_1", 0, 1 ) -domaine.AddPoint( 0, gp_XY( 39901.15, 34762.30 ) ); -domaine.AddPoint( 0, gp_XY( 38086.50, 29964.69 ) ); -domaine.AddPoint( 0, gp_XY( 44835.83, 24264.97 ) ); -domaine.AddPoint( 0, gp_XY( 46758.56, 25021.86 ) ); -domaine.AddPoint( 0, gp_XY( 46757.20, 26601.21 ) ); -domaine.AddPoint( 0, gp_XY( 48566.45, 30152.81 ) ); -domaine.AddPoint( 0, gp_XY( 45532.36, 33239.83 ) ); -domaine.AddPoint( 0, gp_XY( 43548.77, 34048.39 ) ); - -domaine.Update() - - -lit_majeur = hydro_doc.CreateObject( KIND_POLYLINEXY ) -lit_majeur.SetName( "lit_majeur" ) - -lit_majeur.SetZLevel( 7 ) - -lit_majeur.AddSection( "Section_1", 1, 1 ) -lit_majeur.AddPoint( 0, gp_XY( 41225.22, 34118.46 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41716.41, 33705.87 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42384.43, 33293.27 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42561.26, 32684.19 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42875.62, 32369.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43700.82, 32350.18 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44526.02, 31662.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45370.87, 31819.69 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46274.66, 31682.16 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46981.97, 31328.50 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47021.27, 30719.43 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47217.74, 30051.41 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47846.46, 29560.22 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48730.61, 28735.02 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48809.20, 27732.99 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49143.21, 27163.21 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49654.05, 26829.20 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49693.34, 25355.63 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48612.72, 23214.04 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47453.51, 23115.80 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46471.13, 24176.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45960.29, 25257.39 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44899.32, 25591.40 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44270.60, 26573.78 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43248.92, 27909.82 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42757.73, 28243.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42266.54, 28342.07 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41736.06, 28106.30 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41402.05, 28833.26 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40910.86, 28911.85 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40576.85, 29324.45 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40144.60, 29599.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 39024.69, 30130.00 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38612.09, 30365.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38828.21, 33391.50 ) ) - -lit_majeur.Update() - - -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() - - -litMajeur = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -litMajeur.SetName( "litMajeur" ) - -litMajeur.SetZLevel( 5 ) - -litMajeur.SetFillingColor( QColor( 0, 170, 127, 255 ) ) - -litMajeur.SetAltitudeObject( Cloud_02 ) -litMajeur.SetPolyline( lit_majeur ) - -litMajeur.Update() +from salome.hydrotools.hydroGeoMeshUtils import loadImage, GeolocaliseImageCoords, GeolocaliseImageReference +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy +hydro_doc = HYDROData_Document.Document() -domaineEtendu = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -domaineEtendu.SetName( "domaineEtendu" ) +offsetX = 430000. +offsetY = 6350000. +hydro_doc.SetLocalCS( offsetX, offsetY ) -domaineEtendu.SetZLevel( 4 ) +garonne_ign_01 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png"), "garonne_ign_01", 0) +GeolocaliseImageCoords(garonne_ign_01, + QPoint(40, 817), QPoint(1325, 85), + QPointF(471562, 6.36775e+06), QPointF(489400, 6.37702e+06)) -domaineEtendu.SetFillingColor( QColor( 201, 203, 55, 255 ) ) +garonne_ign_02 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png"), "garonne_ign_02", 1) +GeolocaliseImageReference(garonne_ign_02, garonne_ign_01, + QPoint(1389, 447), QPoint(784, 481), + QPoint(631, 95), QPoint(26, 129)) -domaineEtendu.SetAltitudeObject( Cloud_02 ) -domaineEtendu.SetPolyline( domaine ) +garonnes = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne.shp"), "garonne_PolyXY", True, 5) +limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6) +lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7) -domaineEtendu.Update() +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) +garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES) +domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2) +litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3) +litMineur = createImmersibleZone(hydro_doc, "litMineur", garonnes[0], garonne_point_L93, True, 4) # Calculation case garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) @@ -266,7 +68,7 @@ case_geom_group = litMineur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) case_geom_group = litMajeur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) -garonne_1.SetBoundaryPolyline( domaine ) +garonne_1.SetBoundaryPolyline( limites_domaine[0] ) # Start the algorithm of the partition and assignment garonne_1.Update() @@ -300,9 +102,9 @@ 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") -garonne_1_riveDroite.SetName("garonne_1_riveDroite") -garonne_1_riveGauche.SetName("garonne_1_riveGauche") +garonne_1_litMineur.SetName( "garonne_1_litMineur" ) +garonne_1_riveDroite.SetName( "garonne_1_riveDroite" ) +garonne_1_riveGauche.SetName( "garonne_1_riveGauche" ) # Export of the calculation case garonne_1_entry = garonne_1.Export() diff --git a/doc/salome/examples/h011_normalCaseManualInterpolZ.py b/doc/salome/examples/h011_normalCaseManualInterpolZ.py index 9405ad06..c7a8043e 100644 --- a/doc/salome/examples/h011_normalCaseManualInterpolZ.py +++ b/doc/salome/examples/h011_normalCaseManualInterpolZ.py @@ -2,6 +2,13 @@ import os HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO") +HYDRO_TEST_RESOURCES = os.path.join(os.environ["HYDRO_DIR"], "bin", "salome", "test", "tmp_test") +if not os.path.isdir(HYDRO_TEST_RESOURCES): + os.mkdir(HYDRO_TEST_RESOURCES) + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) import sys import salome @@ -16,240 +23,35 @@ from HYDROPy import * from PyQt5.QtCore import * from PyQt5.QtGui import * -hydro_doc = HYDROData_Document.Document() - -hydro_doc.SetLocalCS( 430000, 6.35e+06 ) - -garonne_ign_01 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_01.SetName( "garonne_ign_01" ) - -garonne_ign_01.SetZLevel( 0 ) - - -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 ) ) - -garonne_ign_01.SetGlobalPoints( 1, - QPointF( 471562, 6.36775e+06 ), - QPointF( 489400, 6.37702e+06 ) ) - -garonne_ign_01.Update() - -garonne_ign_02 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_02.SetName( "garonne_ign_02" ) - -garonne_ign_02.SetZLevel( 1 ) - - -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 ) ) - -garonne_ign_02.SetGlobalPoints( 3, - QPointF( 631, 95 ), - QPointF( 26, 129 ) ) -garonne_ign_02.SetTrsfReferenceImage( garonne_ign_01 ) - -garonne_ign_02.Update() - -garonne = hydro_doc.CreateObject( KIND_POLYLINEXY ) -garonne.SetName( "garonne" ) - -garonne.SetZLevel( 2 ) - -garonne.AddSection( "Section_1", 1, 1 ) -garonne.AddPoint( 0, gp_XY( 38191.48, 33184.55 ) ) -garonne.AddPoint( 0, gp_XY( 38553.78, 33013.53 ) ) -garonne.AddPoint( 0, gp_XY( 38993.90, 32767.64 ) ) -garonne.AddPoint( 0, gp_XY( 39678.58, 32533.58 ) ) -garonne.AddPoint( 0, gp_XY( 40240.26, 32305.27 ) ) -garonne.AddPoint( 0, gp_XY( 40717.94, 32193.70 ) ) -garonne.AddPoint( 0, gp_XY( 41361.00, 32464.18 ) ) -garonne.AddPoint( 0, gp_XY( 41831.41, 32626.69 ) ) -garonne.AddPoint( 0, gp_XY( 41950.14, 32618.24 ) ) -garonne.AddPoint( 0, gp_XY( 42524.97, 32419.61 ) ) -garonne.AddPoint( 0, gp_XY( 42909.80, 32291.33 ) ) -garonne.AddPoint( 0, gp_XY( 43177.03, 32269.95 ) ) -garonne.AddPoint( 0, gp_XY( 43465.65, 32344.78 ) ) -garonne.AddPoint( 0, gp_XY( 43754.27, 32152.37 ) ) -garonne.AddPoint( 0, gp_XY( 44128.40, 31842.37 ) ) -garonne.AddPoint( 0, gp_XY( 44003.90, 31269.93 ) ) -garonne.AddPoint( 0, gp_XY( 44010.82, 30869.63 ) ) -garonne.AddPoint( 0, gp_XY( 44064.26, 30655.84 ) ) -garonne.AddPoint( 0, gp_XY( 44434.73, 30366.18 ) ) -garonne.AddPoint( 0, gp_XY( 45208.04, 30484.81 ) ) -garonne.AddPoint( 0, gp_XY( 45705.01, 30287.34 ) ) -garonne.AddPoint( 0, gp_XY( 45933.89, 30046.87 ) ) -garonne.AddPoint( 0, gp_XY( 46127.34, 29490.68 ) ) -garonne.AddPoint( 0, gp_XY( 46111.60, 29226.08 ) ) -garonne.AddPoint( 0, gp_XY( 46228.62, 28784.05 ) ) -garonne.AddPoint( 0, gp_XY( 46247.64, 28449.75 ) ) -garonne.AddPoint( 0, gp_XY( 46108.48, 28086.94 ) ) -garonne.AddPoint( 0, gp_XY( 45618.52, 27553.74 ) ) -garonne.AddPoint( 0, gp_XY( 45276.77, 27042.78 ) ) -garonne.AddPoint( 0, gp_XY( 45001.89, 26273.15 ) ) -garonne.AddPoint( 0, gp_XY( 45167.76, 25975.34 ) ) -garonne.AddPoint( 0, gp_XY( 46018.15, 25848.84 ) ) -garonne.AddPoint( 0, gp_XY( 46378.94, 25872.21 ) ) -garonne.AddPoint( 0, gp_XY( 46885.57, 25937.64 ) ) -garonne.AddPoint( 0, gp_XY( 47278.36, 25782.88 ) ) -garonne.AddPoint( 0, gp_XY( 47153.86, 25728.04 ) ) -garonne.AddPoint( 0, gp_XY( 46987.51, 25749.97 ) ) -garonne.AddPoint( 0, gp_XY( 46658.26, 25715.71 ) ) -garonne.AddPoint( 0, gp_XY( 45650.76, 25634.46 ) ) -garonne.AddPoint( 0, gp_XY( 45122.63, 25748.21 ) ) -garonne.AddPoint( 0, gp_XY( 44797.63, 26325.09 ) ) -garonne.AddPoint( 0, gp_XY( 45114.51, 27168.75 ) ) -garonne.AddPoint( 0, gp_XY( 45508.28, 27713.21 ) ) -garonne.AddPoint( 0, gp_XY( 45994.19, 28382.53 ) ) -garonne.AddPoint( 0, gp_XY( 45927.01, 29201.34 ) ) -garonne.AddPoint( 0, gp_XY( 45756.39, 29859.47 ) ) -garonne.AddPoint( 0, gp_XY( 45390.76, 30151.97 ) ) -garonne.AddPoint( 0, gp_XY( 45039.85, 30120.84 ) ) -garonne.AddPoint( 0, gp_XY( 44513.26, 30084.28 ) ) -garonne.AddPoint( 0, gp_XY( 43923.42, 30426.28 ) ) -garonne.AddPoint( 0, gp_XY( 43768.81, 30934.29 ) ) -garonne.AddPoint( 0, gp_XY( 43820.10, 31425.20 ) ) -garonne.AddPoint( 0, gp_XY( 43854.78, 31801.12 ) ) -garonne.AddPoint( 0, gp_XY( 43479.64, 32053.54 ) ) -garonne.AddPoint( 0, gp_XY( 42923.47, 32051.85 ) ) -garonne.AddPoint( 0, gp_XY( 42493.64, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 42074.27, 32302.91 ) ) -garonne.AddPoint( 0, gp_XY( 41624.75, 32330.93 ) ) -garonne.AddPoint( 0, gp_XY( 41325.93, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 40879.52, 31987.29 ) ) -garonne.AddPoint( 0, gp_XY( 40308.78, 32018.46 ) ) -garonne.AddPoint( 0, gp_XY( 39782.86, 32207.17 ) ) -garonne.AddPoint( 0, gp_XY( 38814.10, 32560.43 ) ) -garonne.AddPoint( 0, gp_XY( 38302.17, 32903.70 ) ) - -garonne.Update() - - -domaine = hydro_doc.CreateObject( KIND_POLYLINEXY ) -domaine.SetName( "domaine" ) - -domaine.SetZLevel( 3 ) - -domaine.AddSection( "Section_1", 0, 1 ) -domaine.AddPoint( 0, gp_XY( 39901.15, 34762.30 ) ); -domaine.AddPoint( 0, gp_XY( 38086.50, 29964.69 ) ); -domaine.AddPoint( 0, gp_XY( 44835.83, 24264.97 ) ); -domaine.AddPoint( 0, gp_XY( 46758.56, 25021.86 ) ); -domaine.AddPoint( 0, gp_XY( 46757.20, 26601.21 ) ); -domaine.AddPoint( 0, gp_XY( 48566.45, 30152.81 ) ); -domaine.AddPoint( 0, gp_XY( 45532.36, 33239.83 ) ); -domaine.AddPoint( 0, gp_XY( 43548.77, 34048.39 ) ); - -domaine.Update() - - -lit_majeur = hydro_doc.CreateObject( KIND_POLYLINEXY ) -lit_majeur.SetName( "lit_majeur" ) - -lit_majeur.SetZLevel( 7 ) - -lit_majeur.AddSection( "Section_1", 1, 1 ) -lit_majeur.AddPoint( 0, gp_XY( 41225.22, 34118.46 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41716.41, 33705.87 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42384.43, 33293.27 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42561.26, 32684.19 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42875.62, 32369.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43700.82, 32350.18 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44526.02, 31662.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45370.87, 31819.69 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46274.66, 31682.16 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46981.97, 31328.50 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47021.27, 30719.43 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47217.74, 30051.41 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47846.46, 29560.22 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48730.61, 28735.02 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48809.20, 27732.99 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49143.21, 27163.21 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49654.05, 26829.20 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49693.34, 25355.63 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48612.72, 23214.04 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47453.51, 23115.80 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46471.13, 24176.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45960.29, 25257.39 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44899.32, 25591.40 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44270.60, 26573.78 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43248.92, 27909.82 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42757.73, 28243.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42266.54, 28342.07 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41736.06, 28106.30 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41402.05, 28833.26 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40910.86, 28911.85 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40576.85, 29324.45 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40144.60, 29599.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 39024.69, 30130.00 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38612.09, 30365.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38828.21, 33391.50 ) ) - -lit_majeur.Update() - - -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() - - -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() +from salome.hydrotools.hydroGeoMeshUtils import loadImage, GeolocaliseImageCoords, GeolocaliseImageReference +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy +hydro_doc = HYDROData_Document.Document() -domaineEtendu = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -domaineEtendu.SetName( "domaineEtendu" ) +offsetX = 430000. +offsetY = 6350000. +hydro_doc.SetLocalCS( offsetX, offsetY ) -domaineEtendu.SetZLevel( 4 ) +garonne_ign_01 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png"), "garonne_ign_01", 0) +GeolocaliseImageCoords(garonne_ign_01, + QPoint(40, 817), QPoint(1325, 85), + QPointF(471562, 6.36775e+06), QPointF(489400, 6.37702e+06)) -domaineEtendu.SetFillingColor( QColor( 201, 203, 55, 255 ) ) +garonne_ign_02 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png"), "garonne_ign_02", 1) +GeolocaliseImageReference(garonne_ign_02, garonne_ign_01, + QPoint(1389, 447), QPoint(784, 481), + QPoint(631, 95), QPoint(26, 129)) -domaineEtendu.SetAltitudeObject( Cloud_02 ) -domaineEtendu.SetPolyline( domaine ) +garonnes = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne.shp"), "garonne_PolyXY", True, 5) +limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6) +lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7) -domaineEtendu.Update() +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) +garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES) +domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2) +litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3) +litMineur = createImmersibleZone(hydro_doc, "litMineur", garonnes[0], garonne_point_L93, True, 4) # Calculation case garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) @@ -266,7 +68,7 @@ case_geom_group = litMineur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) case_geom_group = litMajeur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) -garonne_1.SetBoundaryPolyline( domaine ) +garonne_1.SetBoundaryPolyline( limites_domaine[0] ) # Start the algorithm of the partition and assignment garonne_1.Update() @@ -300,9 +102,9 @@ 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") -garonne_1_riveDroite.SetName("garonne_1_riveDroite") -garonne_1_riveGauche.SetName("garonne_1_riveGauche") +garonne_1_litMineur.SetName( "garonne_1_litMineur" ) +garonne_1_riveDroite.SetName( "garonne_1_riveDroite" ) +garonne_1_riveGauche.SetName( "garonne_1_riveGauche" ) # Export of the calculation case garonne_1_entry = garonne_1.Export() diff --git a/doc/salome/examples/h015_normalCaseManualTelemac.py b/doc/salome/examples/h015_normalCaseManualTelemac.py index 23e8a42f..28ed6755 100644 --- a/doc/salome/examples/h015_normalCaseManualTelemac.py +++ b/doc/salome/examples/h015_normalCaseManualTelemac.py @@ -2,6 +2,13 @@ import os HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO") +HYDRO_TEST_RESOURCES = os.path.join(os.environ["HYDRO_DIR"], "bin", "salome", "test", "tmp_test") +if not os.path.isdir(HYDRO_TEST_RESOURCES): + os.mkdir(HYDRO_TEST_RESOURCES) + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) import sys import salome @@ -16,240 +23,35 @@ from HYDROPy import * from PyQt5.QtCore import * from PyQt5.QtGui import * -hydro_doc = HYDROData_Document.Document() - -hydro_doc.SetLocalCS( 430000, 6.35e+06 ) - -garonne_ign_01 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_01.SetName( "garonne_ign_01" ) - -garonne_ign_01.SetZLevel( 0 ) - - -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 ) ) - -garonne_ign_01.SetGlobalPoints( 1, - QPointF( 471562, 6.36775e+06 ), - QPointF( 489400, 6.37702e+06 ) ) - -garonne_ign_01.Update() - -garonne_ign_02 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_02.SetName( "garonne_ign_02" ) - -garonne_ign_02.SetZLevel( 1 ) - - -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 ) ) - -garonne_ign_02.SetGlobalPoints( 3, - QPointF( 631, 95 ), - QPointF( 26, 129 ) ) -garonne_ign_02.SetTrsfReferenceImage( garonne_ign_01 ) - -garonne_ign_02.Update() - -garonne = hydro_doc.CreateObject( KIND_POLYLINEXY ) -garonne.SetName( "garonne" ) - -garonne.SetZLevel( 2 ) - -garonne.AddSection( "Section_1", 1, 1 ) -garonne.AddPoint( 0, gp_XY( 38191.48, 33184.55 ) ) -garonne.AddPoint( 0, gp_XY( 38553.78, 33013.53 ) ) -garonne.AddPoint( 0, gp_XY( 38993.90, 32767.64 ) ) -garonne.AddPoint( 0, gp_XY( 39678.58, 32533.58 ) ) -garonne.AddPoint( 0, gp_XY( 40240.26, 32305.27 ) ) -garonne.AddPoint( 0, gp_XY( 40717.94, 32193.70 ) ) -garonne.AddPoint( 0, gp_XY( 41361.00, 32464.18 ) ) -garonne.AddPoint( 0, gp_XY( 41831.41, 32626.69 ) ) -garonne.AddPoint( 0, gp_XY( 41950.14, 32618.24 ) ) -garonne.AddPoint( 0, gp_XY( 42524.97, 32419.61 ) ) -garonne.AddPoint( 0, gp_XY( 42909.80, 32291.33 ) ) -garonne.AddPoint( 0, gp_XY( 43177.03, 32269.95 ) ) -garonne.AddPoint( 0, gp_XY( 43465.65, 32344.78 ) ) -garonne.AddPoint( 0, gp_XY( 43754.27, 32152.37 ) ) -garonne.AddPoint( 0, gp_XY( 44128.40, 31842.37 ) ) -garonne.AddPoint( 0, gp_XY( 44003.90, 31269.93 ) ) -garonne.AddPoint( 0, gp_XY( 44010.82, 30869.63 ) ) -garonne.AddPoint( 0, gp_XY( 44064.26, 30655.84 ) ) -garonne.AddPoint( 0, gp_XY( 44434.73, 30366.18 ) ) -garonne.AddPoint( 0, gp_XY( 45208.04, 30484.81 ) ) -garonne.AddPoint( 0, gp_XY( 45705.01, 30287.34 ) ) -garonne.AddPoint( 0, gp_XY( 45933.89, 30046.87 ) ) -garonne.AddPoint( 0, gp_XY( 46127.34, 29490.68 ) ) -garonne.AddPoint( 0, gp_XY( 46111.60, 29226.08 ) ) -garonne.AddPoint( 0, gp_XY( 46228.62, 28784.05 ) ) -garonne.AddPoint( 0, gp_XY( 46247.64, 28449.75 ) ) -garonne.AddPoint( 0, gp_XY( 46108.48, 28086.94 ) ) -garonne.AddPoint( 0, gp_XY( 45618.52, 27553.74 ) ) -garonne.AddPoint( 0, gp_XY( 45276.77, 27042.78 ) ) -garonne.AddPoint( 0, gp_XY( 45001.89, 26273.15 ) ) -garonne.AddPoint( 0, gp_XY( 45167.76, 25975.34 ) ) -garonne.AddPoint( 0, gp_XY( 46018.15, 25848.84 ) ) -garonne.AddPoint( 0, gp_XY( 46378.94, 25872.21 ) ) -garonne.AddPoint( 0, gp_XY( 46885.57, 25937.64 ) ) -garonne.AddPoint( 0, gp_XY( 47278.36, 25782.88 ) ) -garonne.AddPoint( 0, gp_XY( 47153.86, 25728.04 ) ) -garonne.AddPoint( 0, gp_XY( 46987.51, 25749.97 ) ) -garonne.AddPoint( 0, gp_XY( 46658.26, 25715.71 ) ) -garonne.AddPoint( 0, gp_XY( 45650.76, 25634.46 ) ) -garonne.AddPoint( 0, gp_XY( 45122.63, 25748.21 ) ) -garonne.AddPoint( 0, gp_XY( 44797.63, 26325.09 ) ) -garonne.AddPoint( 0, gp_XY( 45114.51, 27168.75 ) ) -garonne.AddPoint( 0, gp_XY( 45508.28, 27713.21 ) ) -garonne.AddPoint( 0, gp_XY( 45994.19, 28382.53 ) ) -garonne.AddPoint( 0, gp_XY( 45927.01, 29201.34 ) ) -garonne.AddPoint( 0, gp_XY( 45756.39, 29859.47 ) ) -garonne.AddPoint( 0, gp_XY( 45390.76, 30151.97 ) ) -garonne.AddPoint( 0, gp_XY( 45039.85, 30120.84 ) ) -garonne.AddPoint( 0, gp_XY( 44513.26, 30084.28 ) ) -garonne.AddPoint( 0, gp_XY( 43923.42, 30426.28 ) ) -garonne.AddPoint( 0, gp_XY( 43768.81, 30934.29 ) ) -garonne.AddPoint( 0, gp_XY( 43820.10, 31425.20 ) ) -garonne.AddPoint( 0, gp_XY( 43854.78, 31801.12 ) ) -garonne.AddPoint( 0, gp_XY( 43479.64, 32053.54 ) ) -garonne.AddPoint( 0, gp_XY( 42923.47, 32051.85 ) ) -garonne.AddPoint( 0, gp_XY( 42493.64, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 42074.27, 32302.91 ) ) -garonne.AddPoint( 0, gp_XY( 41624.75, 32330.93 ) ) -garonne.AddPoint( 0, gp_XY( 41325.93, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 40879.52, 31987.29 ) ) -garonne.AddPoint( 0, gp_XY( 40308.78, 32018.46 ) ) -garonne.AddPoint( 0, gp_XY( 39782.86, 32207.17 ) ) -garonne.AddPoint( 0, gp_XY( 38814.10, 32560.43 ) ) -garonne.AddPoint( 0, gp_XY( 38302.17, 32903.70 ) ) - -garonne.Update() - - -domaine = hydro_doc.CreateObject( KIND_POLYLINEXY ) -domaine.SetName( "domaine" ) - -domaine.SetZLevel( 3 ) - -domaine.AddSection( "Section_1", 0, 1 ) -domaine.AddPoint( 0, gp_XY( 39901.15, 34762.30 ) ); -domaine.AddPoint( 0, gp_XY( 38086.50, 29964.69 ) ); -domaine.AddPoint( 0, gp_XY( 44835.83, 24264.97 ) ); -domaine.AddPoint( 0, gp_XY( 46758.56, 25021.86 ) ); -domaine.AddPoint( 0, gp_XY( 46757.20, 26601.21 ) ); -domaine.AddPoint( 0, gp_XY( 48566.45, 30152.81 ) ); -domaine.AddPoint( 0, gp_XY( 45532.36, 33239.83 ) ); -domaine.AddPoint( 0, gp_XY( 43548.77, 34048.39 ) ); - -domaine.Update() - - -lit_majeur = hydro_doc.CreateObject( KIND_POLYLINEXY ) -lit_majeur.SetName( "lit_majeur" ) - -lit_majeur.SetZLevel( 7 ) - -lit_majeur.AddSection( "Section_1", 1, 1 ) -lit_majeur.AddPoint( 0, gp_XY( 41225.22, 34118.46 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41716.41, 33705.87 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42384.43, 33293.27 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42561.26, 32684.19 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42875.62, 32369.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43700.82, 32350.18 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44526.02, 31662.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45370.87, 31819.69 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46274.66, 31682.16 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46981.97, 31328.50 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47021.27, 30719.43 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47217.74, 30051.41 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47846.46, 29560.22 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48730.61, 28735.02 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48809.20, 27732.99 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49143.21, 27163.21 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49654.05, 26829.20 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49693.34, 25355.63 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48612.72, 23214.04 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47453.51, 23115.80 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46471.13, 24176.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45960.29, 25257.39 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44899.32, 25591.40 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44270.60, 26573.78 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43248.92, 27909.82 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42757.73, 28243.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42266.54, 28342.07 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41736.06, 28106.30 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41402.05, 28833.26 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40910.86, 28911.85 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40576.85, 29324.45 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40144.60, 29599.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 39024.69, 30130.00 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38612.09, 30365.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38828.21, 33391.50 ) ) - -lit_majeur.Update() - - -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() - - -litMajeur = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -litMajeur.SetName( "litMajeur" ) - -litMajeur.SetZLevel( 5 ) - -litMajeur.SetFillingColor( QColor( 0, 170, 127, 255 ) ) - -litMajeur.SetAltitudeObject( Cloud_02 ) -litMajeur.SetPolyline( lit_majeur ) - -litMajeur.Update() +from salome.hydrotools.hydroGeoMeshUtils import loadImage, GeolocaliseImageCoords, GeolocaliseImageReference +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy +hydro_doc = HYDROData_Document.Document() -domaineEtendu = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -domaineEtendu.SetName( "domaineEtendu" ) +offsetX = 430000. +offsetY = 6350000. +hydro_doc.SetLocalCS( offsetX, offsetY ) -domaineEtendu.SetZLevel( 4 ) +garonne_ign_01 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png"), "garonne_ign_01", 0) +GeolocaliseImageCoords(garonne_ign_01, + QPoint(40, 817), QPoint(1325, 85), + QPointF(471562, 6.36775e+06), QPointF(489400, 6.37702e+06)) -domaineEtendu.SetFillingColor( QColor( 201, 203, 55, 255 ) ) +garonne_ign_02 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png"), "garonne_ign_02", 1) +GeolocaliseImageReference(garonne_ign_02, garonne_ign_01, + QPoint(1389, 447), QPoint(784, 481), + QPoint(631, 95), QPoint(26, 129)) -domaineEtendu.SetAltitudeObject( Cloud_02 ) -domaineEtendu.SetPolyline( domaine ) +garonnes = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne.shp"), "garonne_PolyXY", True, 5) +limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6) +lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7) -domaineEtendu.Update() +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) +garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES) +domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2) +litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3) +litMineur = createImmersibleZone(hydro_doc, "litMineur", garonnes[0], garonne_point_L93, True, 4) # Calculation case garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) @@ -266,7 +68,7 @@ case_geom_group = litMineur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) case_geom_group = litMajeur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) -garonne_1.SetBoundaryPolyline( domaine ) +garonne_1.SetBoundaryPolyline( limites_domaine[0] ) # Start the algorithm of the partition and assignment garonne_1.Update() @@ -300,9 +102,9 @@ 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") -garonne_1_riveDroite.SetName("garonne_1_riveDroite") -garonne_1_riveGauche.SetName("garonne_1_riveGauche") +garonne_1_litMineur.SetName( "garonne_1_litMineur" ) +garonne_1_riveDroite.SetName( "garonne_1_riveDroite" ) +garonne_1_riveGauche.SetName( "garonne_1_riveGauche" ) # Export of the calculation case garonne_1_entry = garonne_1.Export() diff --git a/doc/salome/examples/h020_normalCaseChangeBathy.py b/doc/salome/examples/h020_normalCaseChangeBathy.py index bb71999a..3d33d9de 100644 --- a/doc/salome/examples/h020_normalCaseChangeBathy.py +++ b/doc/salome/examples/h020_normalCaseChangeBathy.py @@ -2,6 +2,13 @@ import os HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO") +HYDRO_TEST_RESOURCES = os.path.join(os.environ["HYDRO_DIR"], "bin", "salome", "test", "tmp_test") +if not os.path.isdir(HYDRO_TEST_RESOURCES): + os.mkdir(HYDRO_TEST_RESOURCES) + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) import sys import salome @@ -16,240 +23,35 @@ from HYDROPy import * from PyQt5.QtCore import * from PyQt5.QtGui import * -hydro_doc = HYDROData_Document.Document() - -hydro_doc.SetLocalCS( 430000, 6.35e+06 ) - -garonne_ign_01 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_01.SetName( "garonne_ign_01" ) - -garonne_ign_01.SetZLevel( 0 ) - - -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 ) ) - -garonne_ign_01.SetGlobalPoints( 1, - QPointF( 471562, 6.36775e+06 ), - QPointF( 489400, 6.37702e+06 ) ) - -garonne_ign_01.Update() - -garonne_ign_02 = hydro_doc.CreateObject( KIND_IMAGE ) -garonne_ign_02.SetName( "garonne_ign_02" ) - -garonne_ign_02.SetZLevel( 1 ) - - -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 ) ) - -garonne_ign_02.SetGlobalPoints( 3, - QPointF( 631, 95 ), - QPointF( 26, 129 ) ) -garonne_ign_02.SetTrsfReferenceImage( garonne_ign_01 ) - -garonne_ign_02.Update() - -garonne = hydro_doc.CreateObject( KIND_POLYLINEXY ) -garonne.SetName( "garonne" ) - -garonne.SetZLevel( 2 ) - -garonne.AddSection( "Section_1", 1, 1 ) -garonne.AddPoint( 0, gp_XY( 38191.48, 33184.55 ) ) -garonne.AddPoint( 0, gp_XY( 38553.78, 33013.53 ) ) -garonne.AddPoint( 0, gp_XY( 38993.90, 32767.64 ) ) -garonne.AddPoint( 0, gp_XY( 39678.58, 32533.58 ) ) -garonne.AddPoint( 0, gp_XY( 40240.26, 32305.27 ) ) -garonne.AddPoint( 0, gp_XY( 40717.94, 32193.70 ) ) -garonne.AddPoint( 0, gp_XY( 41361.00, 32464.18 ) ) -garonne.AddPoint( 0, gp_XY( 41831.41, 32626.69 ) ) -garonne.AddPoint( 0, gp_XY( 41950.14, 32618.24 ) ) -garonne.AddPoint( 0, gp_XY( 42524.97, 32419.61 ) ) -garonne.AddPoint( 0, gp_XY( 42909.80, 32291.33 ) ) -garonne.AddPoint( 0, gp_XY( 43177.03, 32269.95 ) ) -garonne.AddPoint( 0, gp_XY( 43465.65, 32344.78 ) ) -garonne.AddPoint( 0, gp_XY( 43754.27, 32152.37 ) ) -garonne.AddPoint( 0, gp_XY( 44128.40, 31842.37 ) ) -garonne.AddPoint( 0, gp_XY( 44003.90, 31269.93 ) ) -garonne.AddPoint( 0, gp_XY( 44010.82, 30869.63 ) ) -garonne.AddPoint( 0, gp_XY( 44064.26, 30655.84 ) ) -garonne.AddPoint( 0, gp_XY( 44434.73, 30366.18 ) ) -garonne.AddPoint( 0, gp_XY( 45208.04, 30484.81 ) ) -garonne.AddPoint( 0, gp_XY( 45705.01, 30287.34 ) ) -garonne.AddPoint( 0, gp_XY( 45933.89, 30046.87 ) ) -garonne.AddPoint( 0, gp_XY( 46127.34, 29490.68 ) ) -garonne.AddPoint( 0, gp_XY( 46111.60, 29226.08 ) ) -garonne.AddPoint( 0, gp_XY( 46228.62, 28784.05 ) ) -garonne.AddPoint( 0, gp_XY( 46247.64, 28449.75 ) ) -garonne.AddPoint( 0, gp_XY( 46108.48, 28086.94 ) ) -garonne.AddPoint( 0, gp_XY( 45618.52, 27553.74 ) ) -garonne.AddPoint( 0, gp_XY( 45276.77, 27042.78 ) ) -garonne.AddPoint( 0, gp_XY( 45001.89, 26273.15 ) ) -garonne.AddPoint( 0, gp_XY( 45167.76, 25975.34 ) ) -garonne.AddPoint( 0, gp_XY( 46018.15, 25848.84 ) ) -garonne.AddPoint( 0, gp_XY( 46378.94, 25872.21 ) ) -garonne.AddPoint( 0, gp_XY( 46885.57, 25937.64 ) ) -garonne.AddPoint( 0, gp_XY( 47278.36, 25782.88 ) ) -garonne.AddPoint( 0, gp_XY( 47153.86, 25728.04 ) ) -garonne.AddPoint( 0, gp_XY( 46987.51, 25749.97 ) ) -garonne.AddPoint( 0, gp_XY( 46658.26, 25715.71 ) ) -garonne.AddPoint( 0, gp_XY( 45650.76, 25634.46 ) ) -garonne.AddPoint( 0, gp_XY( 45122.63, 25748.21 ) ) -garonne.AddPoint( 0, gp_XY( 44797.63, 26325.09 ) ) -garonne.AddPoint( 0, gp_XY( 45114.51, 27168.75 ) ) -garonne.AddPoint( 0, gp_XY( 45508.28, 27713.21 ) ) -garonne.AddPoint( 0, gp_XY( 45994.19, 28382.53 ) ) -garonne.AddPoint( 0, gp_XY( 45927.01, 29201.34 ) ) -garonne.AddPoint( 0, gp_XY( 45756.39, 29859.47 ) ) -garonne.AddPoint( 0, gp_XY( 45390.76, 30151.97 ) ) -garonne.AddPoint( 0, gp_XY( 45039.85, 30120.84 ) ) -garonne.AddPoint( 0, gp_XY( 44513.26, 30084.28 ) ) -garonne.AddPoint( 0, gp_XY( 43923.42, 30426.28 ) ) -garonne.AddPoint( 0, gp_XY( 43768.81, 30934.29 ) ) -garonne.AddPoint( 0, gp_XY( 43820.10, 31425.20 ) ) -garonne.AddPoint( 0, gp_XY( 43854.78, 31801.12 ) ) -garonne.AddPoint( 0, gp_XY( 43479.64, 32053.54 ) ) -garonne.AddPoint( 0, gp_XY( 42923.47, 32051.85 ) ) -garonne.AddPoint( 0, gp_XY( 42493.64, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 42074.27, 32302.91 ) ) -garonne.AddPoint( 0, gp_XY( 41624.75, 32330.93 ) ) -garonne.AddPoint( 0, gp_XY( 41325.93, 32187.97 ) ) -garonne.AddPoint( 0, gp_XY( 40879.52, 31987.29 ) ) -garonne.AddPoint( 0, gp_XY( 40308.78, 32018.46 ) ) -garonne.AddPoint( 0, gp_XY( 39782.86, 32207.17 ) ) -garonne.AddPoint( 0, gp_XY( 38814.10, 32560.43 ) ) -garonne.AddPoint( 0, gp_XY( 38302.17, 32903.70 ) ) - -garonne.Update() - - -domaine = hydro_doc.CreateObject( KIND_POLYLINEXY ) -domaine.SetName( "domaine" ) - -domaine.SetZLevel( 3 ) - -domaine.AddSection( "Section_1", 0, 1 ) -domaine.AddPoint( 0, gp_XY( 39901.15, 34762.30 ) ); -domaine.AddPoint( 0, gp_XY( 38086.50, 29964.69 ) ); -domaine.AddPoint( 0, gp_XY( 44835.83, 24264.97 ) ); -domaine.AddPoint( 0, gp_XY( 46758.56, 25021.86 ) ); -domaine.AddPoint( 0, gp_XY( 46757.20, 26601.21 ) ); -domaine.AddPoint( 0, gp_XY( 48566.45, 30152.81 ) ); -domaine.AddPoint( 0, gp_XY( 45532.36, 33239.83 ) ); -domaine.AddPoint( 0, gp_XY( 43548.77, 34048.39 ) ); - -domaine.Update() - - -lit_majeur = hydro_doc.CreateObject( KIND_POLYLINEXY ) -lit_majeur.SetName( "lit_majeur" ) - -lit_majeur.SetZLevel( 7 ) - -lit_majeur.AddSection( "Section_1", 1, 1 ) -lit_majeur.AddPoint( 0, gp_XY( 41225.22, 34118.46 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41716.41, 33705.87 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42384.43, 33293.27 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42561.26, 32684.19 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42875.62, 32369.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43700.82, 32350.18 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44526.02, 31662.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45370.87, 31819.69 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46274.66, 31682.16 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46981.97, 31328.50 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47021.27, 30719.43 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47217.74, 30051.41 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47846.46, 29560.22 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48730.61, 28735.02 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48809.20, 27732.99 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49143.21, 27163.21 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49654.05, 26829.20 ) ) -lit_majeur.AddPoint( 0, gp_XY( 49693.34, 25355.63 ) ) -lit_majeur.AddPoint( 0, gp_XY( 48612.72, 23214.04 ) ) -lit_majeur.AddPoint( 0, gp_XY( 47453.51, 23115.80 ) ) -lit_majeur.AddPoint( 0, gp_XY( 46471.13, 24176.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 45960.29, 25257.39 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44899.32, 25591.40 ) ) -lit_majeur.AddPoint( 0, gp_XY( 44270.60, 26573.78 ) ) -lit_majeur.AddPoint( 0, gp_XY( 43248.92, 27909.82 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42757.73, 28243.83 ) ) -lit_majeur.AddPoint( 0, gp_XY( 42266.54, 28342.07 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41736.06, 28106.30 ) ) -lit_majeur.AddPoint( 0, gp_XY( 41402.05, 28833.26 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40910.86, 28911.85 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40576.85, 29324.45 ) ) -lit_majeur.AddPoint( 0, gp_XY( 40144.60, 29599.51 ) ) -lit_majeur.AddPoint( 0, gp_XY( 39024.69, 30130.00 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38612.09, 30365.77 ) ) -lit_majeur.AddPoint( 0, gp_XY( 38828.21, 33391.50 ) ) - -lit_majeur.Update() - - -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() - - -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() +from salome.hydrotools.hydroGeoMeshUtils import loadImage, GeolocaliseImageCoords, GeolocaliseImageReference +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy +hydro_doc = HYDROData_Document.Document() -domaineEtendu = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -domaineEtendu.SetName( "domaineEtendu" ) +offsetX = 430000. +offsetY = 6350000. +hydro_doc.SetLocalCS( offsetX, offsetY ) -domaineEtendu.SetZLevel( 4 ) +garonne_ign_01 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png"), "garonne_ign_01", 0) +GeolocaliseImageCoords(garonne_ign_01, + QPoint(40, 817), QPoint(1325, 85), + QPointF(471562, 6.36775e+06), QPointF(489400, 6.37702e+06)) -domaineEtendu.SetFillingColor( QColor( 201, 203, 55, 255 ) ) +garonne_ign_02 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png"), "garonne_ign_02", 1) +GeolocaliseImageReference(garonne_ign_02, garonne_ign_01, + QPoint(1389, 447), QPoint(784, 481), + QPoint(631, 95), QPoint(26, 129)) -domaineEtendu.SetAltitudeObject( Cloud_02 ) -domaineEtendu.SetPolyline( domaine ) +garonnes = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne.shp"), "garonne_PolyXY", True, 5) +limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6) +lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7) -domaineEtendu.Update() +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) +garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES) +domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2) +litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3) +litMineur = createImmersibleZone(hydro_doc, "litMineur", garonnes[0], garonne_point_L93, True, 4) # Calculation case garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) @@ -266,7 +68,7 @@ case_geom_group = litMineur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) case_geom_group = litMajeur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) -garonne_1.SetBoundaryPolyline( domaine ) +garonne_1.SetBoundaryPolyline( limites_domaine[0] ) # Start the algorithm of the partition and assignment garonne_1.Update() @@ -300,9 +102,9 @@ 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") -garonne_1_riveDroite.SetName("garonne_1_riveDroite") -garonne_1_riveGauche.SetName("garonne_1_riveGauche") +garonne_1_litMineur.SetName( "garonne_1_litMineur" ) +garonne_1_riveDroite.SetName( "garonne_1_riveDroite" ) +garonne_1_riveGauche.SetName( "garonne_1_riveGauche" ) # Export of the calculation case garonne_1_entry = garonne_1.Export() diff --git a/doc/salome/examples/h021_meshChangeBathy.py b/doc/salome/examples/h021_meshChangeBathy.py index 4ecc30e8..fcfe5ea3 100644 --- a/doc/salome/examples/h021_meshChangeBathy.py +++ b/doc/salome/examples/h021_meshChangeBathy.py @@ -2,6 +2,13 @@ import os HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO") +HYDRO_TEST_RESOURCES = os.path.join(os.environ["HYDRO_DIR"], "bin", "salome", "test", "tmp_test") +if not os.path.isdir(HYDRO_TEST_RESOURCES): + os.mkdir(HYDRO_TEST_RESOURCES) + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) import sys import salome @@ -16,93 +23,35 @@ from HYDROPy import * from PyQt5.QtCore import * from PyQt5.QtGui import * -hydro_doc = HYDROData_Document.Document() - -hydro_doc.SetLocalCS( 430000, 6.35e+06 ) - -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 = "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( 4 ) - -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() - - -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() +from salome.hydrotools.hydroGeoMeshUtils import loadImage, GeolocaliseImageCoords, GeolocaliseImageReference +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy +hydro_doc = HYDROData_Document.Document() -domaineEtendu = hydro_doc.CreateObject( KIND_IMMERSIBLE_ZONE ) -domaineEtendu.SetName( "domaineEtendu" ) +offsetX = 430000. +offsetY = 6350000. +hydro_doc.SetLocalCS( offsetX, offsetY ) -domaineEtendu.SetZLevel( 4 ) +garonne_ign_01 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png"), "garonne_ign_01", 0) +GeolocaliseImageCoords(garonne_ign_01, + QPoint(40, 817), QPoint(1325, 85), + QPointF(471562, 6.36775e+06), QPointF(489400, 6.37702e+06)) -domaineEtendu.SetFillingColor( QColor( 201, 203, 55, 255 ) ) +garonne_ign_02 = loadImage(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png"), "garonne_ign_02", 1) +GeolocaliseImageReference(garonne_ign_02, garonne_ign_01, + QPoint(1389, 447), QPoint(784, 481), + QPoint(631, 95), QPoint(26, 129)) -domaineEtendu.SetAltitudeObject( Cloud_02 ) -domaineEtendu.SetPolyline( domaine ) +garonnes = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonne.shp"), "garonne_PolyXY", True, 5) +limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaine.shp"), "domaine_PolyXY", False, 6) +lits_majeur = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "lit_majeur.shp"), "lit_majeur_PolyXY", True, 7) -domaineEtendu.Update() +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) +garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES) +domaineEtendu = createImmersibleZone(hydro_doc, "domaineEtendu", limites_domaine[0], Cloud_02, True, 2) +litMajeur = createImmersibleZone(hydro_doc, "litMajeur", lits_majeur[0], garonne_point_L93, True, 3) +litMineur = createImmersibleZone(hydro_doc, "litMineur", garonnes[0], garonne_point_L93, True, 4) # Calculation case garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) @@ -119,7 +68,7 @@ case_geom_group = litMineur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) case_geom_group = litMajeur.GetGroup( 0 ) garonne_1.AddGeometryGroup( case_geom_group ) -garonne_1.SetBoundaryPolyline( domaine ) +garonne_1.SetBoundaryPolyline( limites_domaine[0] ) # Start the algorithm of the partition and assignment garonne_1.Update() @@ -153,9 +102,9 @@ 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") -garonne_1_riveDroite.SetName("garonne_1_riveDroite") -garonne_1_riveGauche.SetName("garonne_1_riveGauche") +garonne_1_litMineur.SetName( "garonne_1_litMineur" ) +garonne_1_riveDroite.SetName( "garonne_1_riveDroite" ) +garonne_1_riveGauche.SetName( "garonne_1_riveGauche" ) # Export of the calculation case garonne_1_entry = garonne_1.Export() diff --git a/src/HYDROTools/hydroGeoMeshUtils.py b/src/HYDROTools/hydroGeoMeshUtils.py index e23d44c6..55d21a18 100644 --- a/src/HYDROTools/hydroGeoMeshUtils.py +++ b/src/HYDROTools/hydroGeoMeshUtils.py @@ -8,6 +8,8 @@ from HYDROPy import * from PyQt5.QtCore import * from PyQt5.QtGui import * +from random import randint + def getChildrenInStudy(obj): """ Given an object published in SALOME study (for instance a GEOM object), retreive its children. @@ -26,6 +28,32 @@ def getChildrenInStudy(obj): childIterator.Next() return children +def loadImage(document, imageFile, imageName, displayLevel): + """ + """ + image = document.CreateObject(KIND_IMAGE) + image.SetName(imageName) + image.SetZLevel(displayLevel) + if not(image.LoadImage(imageFile)): + raise ValueError('problem while loading image %s'%imageFile) + image.Update() + return image + +def GeolocaliseImageCoords(image, a, b, c ,d): + """ + """ + image.SetLocalPoints(a, b) + image.SetGlobalPoints(1, c, d) + image.Update() + +def GeolocaliseImageReference(image, imageRef, a, b, c ,d): + """ + """ + image.SetLocalPoints(a, b) + image.SetGlobalPoints(3, c, d) + image.SetTrsfReferenceImage(imageRef) + image.Update() + def importPolylines(document, shapeFile, shapeName, iSpline, displayLevel): """ """ @@ -79,6 +107,7 @@ def createImmersibleZone(document, imzName, polyLine, bathy, isImmersible, displ imz.SetAltitudeObject( bathy ) imz.SetPolyline( polyLine ) imz.SetIsSubmersible(isImmersible) + imz.SetFillingColor(QColor(randint(0,255), randint(0,255), randint(0,255), 255)) imz.Update() return imz