From c88090c5f8063ac7b55ddc7ddbbeba836cdaf1e0 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Thu, 27 Aug 2020 10:46:17 +0200 Subject: [PATCH] improvements on importPolylines Python function --- .../examples/g022_extensionSimpleComplete.py | 224 +++++++++--------- .../examples/h022_extensionSimpleComplete.py | 16 +- src/HYDROTools/hydroGeoMeshUtils.py | 27 ++- 3 files changed, 139 insertions(+), 128 deletions(-) diff --git a/doc/salome/examples/g022_extensionSimpleComplete.py b/doc/salome/examples/g022_extensionSimpleComplete.py index 6598ee50..6b163c6a 100644 --- a/doc/salome/examples/g022_extensionSimpleComplete.py +++ b/doc/salome/examples/g022_extensionSimpleComplete.py @@ -132,68 +132,68 @@ domaineEtendu.Update() # Calculation case -garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) -garonne_1.SetName( "garonne_1" ) +garonne_2 = hydro_doc.CreateObject( KIND_CALCULATION ) +garonne_2.SetName( "garonne_2" ) -garonne_1.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) -garonne_1.AddGeometryObject( litMineur ) -garonne_1.AddGeometryObject( domaineEtendu ) -garonne_1.AddGeometryObject( litMajeur ) -garonne_1.AddGeometryObject( ilot ) +garonne_2.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +garonne_2.AddGeometryObject( litMineur ) +garonne_2.AddGeometryObject( domaineEtendu ) +garonne_2.AddGeometryObject( litMajeur ) +garonne_2.AddGeometryObject( ilot ) case_geom_group = domaineEtendu.GetGroup( 0 ) -garonne_1.AddGeometryGroup( case_geom_group ) +garonne_2.AddGeometryGroup( case_geom_group ) case_geom_group = litMineur.GetGroup( 0 ) -garonne_1.AddGeometryGroup( case_geom_group ) +garonne_2.AddGeometryGroup( case_geom_group ) case_geom_group = litMajeur.GetGroup( 0 ) -garonne_1.AddGeometryGroup( case_geom_group ) -garonne_1.SetBoundaryPolyline( domaine ) +garonne_2.AddGeometryGroup( case_geom_group ) +garonne_2.SetBoundaryPolyline( domaine ) # Start the algorithm of the partition and assignment -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 ) +garonne_2.Update() +garonne_2_litMineur = hydro_doc.FindObjectByName( "garonne_2_Reg_1" ) +garonne_2_Zone_1 = hydro_doc.FindObjectByName( "garonne_2_Zone_1" ) +garonne_2_Zone_1.SetMergeType( HYDROData_Zone.Merge_ZMIN ) +garonne_2_Zone_1.SetColor( QColor( 192, 113, 64 )) +garonne_2_litMineur.AddZone( garonne_2_Zone_1 ) + +garonne_2_riveDroite = hydro_doc.FindObjectByName( "garonne_2_Reg_2" ) +garonne_2_Zone_2 = hydro_doc.FindObjectByName( "garonne_2_Zone_2" ) +garonne_2_Zone_2.SetColor( QColor( 141, 192, 64 )) +garonne_2_riveDroite.AddZone( garonne_2_Zone_2 ) + +garonne_2_Zone_3 = hydro_doc.FindObjectByName( "garonne_2_Zone_3" ) +garonne_2_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_2_Zone_3.SetMergeObject( Cloud_02 ) +garonne_2_Zone_3.SetColor( QColor( 64, 192, 77 )) +garonne_2_riveDroite.AddZone( garonne_2_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 ) +garonne_2_riveGauche = hydro_doc.FindObjectByName( "garonne_2_Reg_3" ) +garonne_2_Zone_4 = hydro_doc.FindObjectByName( "garonne_2_Zone_4" ) +garonne_2_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_2_Zone_4.SetMergeObject( Cloud_02 ) +garonne_2_Zone_4.SetColor( QColor( 64, 75, 192 )) +garonne_2_riveGauche.AddZone( garonne_2_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_2_Zone_5 = hydro_doc.FindObjectByName( "garonne_2_Zone_5" ) +garonne_2_Zone_5.SetColor( QColor( 64, 192, 77 )) +garonne_2_riveGauche.AddZone( garonne_2_Zone_5 ) -garonne_1_ile = hydro_doc.FindObjectByName( "garonne_1_Reg_4" ) -garonne_1_Zone_6 = hydro_doc.FindObjectByName( "garonne_1_Zone_6" ) -garonne_1_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX ) -garonne_1_Zone_6.SetColor( QColor( 228, 145, 28 )) -garonne_1_ile.AddZone( garonne_1_Zone_6 ) +garonne_2_ile = hydro_doc.FindObjectByName( "garonne_2_Reg_4" ) +garonne_2_Zone_6 = hydro_doc.FindObjectByName( "garonne_2_Zone_6" ) +garonne_2_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX ) +garonne_2_Zone_6.SetColor( QColor( 228, 145, 28 )) +garonne_2_ile.AddZone( garonne_2_Zone_6 ) -garonne_1_litMineur.SetName("garonne_1_litMineur") -garonne_1_riveDroite.SetName("garonne_1_riveDroite") -garonne_1_riveGauche.SetName("garonne_1_riveGauche") -garonne_1_ile.SetName( "garonne_1_ile" ) +garonne_2_litMineur.SetName("garonne_2_litMineur") +garonne_2_riveDroite.SetName("garonne_2_riveDroite") +garonne_2_riveGauche.SetName("garonne_2_riveGauche") +garonne_2_ile.SetName( "garonne_2_ile" ) # Export of the calculation case -garonne_1_entry = garonne_1.Export() +garonne_2_entry = garonne_2.Export() # --- add a new bathymetry for the test changeBathy @@ -225,14 +225,14 @@ from salome.hydrotools.controls import controlGeomProps geompy = geomBuilder.New() -print("Entry:", garonne_1_entry) -HYDRO_garonne_1 = salome.IDToObject( str( garonne_1_entry ) ) -print("Geom shape:", HYDRO_garonne_1) -print("Geom shape name:", HYDRO_garonne_1.GetName()) +print("Entry:", garonne_2_entry) +HYDRO_garonne_2 = salome.IDToObject( str( garonne_2_entry ) ) +print("Geom shape:", HYDRO_garonne_2) +print("Geom shape name:", HYDRO_garonne_2.GetName()) # --- manual definition: geometrical faces -[garonne_litMineur,garonne_riveDroite,garonne_riveGauche] = geompy.SubShapeAll(HYDRO_garonne_1, geompy.ShapeType["FACE"]) +[garonne_litMineur,garonne_riveDroite,garonne_riveGauche] = geompy.SubShapeAll(HYDRO_garonne_2, geompy.ShapeType["FACE"]) controlGeomProps(geompy, garonne_riveGauche, 33378.8047, 34595667.2876) controlGeomProps(geompy, garonne_litMineur, 30337.548492, 3488480.304388) @@ -240,30 +240,30 @@ controlGeomProps(geompy, garonne_riveDroite, 32012.343241, 25998769.23615) # --- manual identification of all useful edge groups (boundary conditions) -allEdgesIds = geompy.SubShapeAllIDs(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +allEdgesIds = geompy.SubShapeAllIDs(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) print("allEdgesIds", allEdgesIds) -(isDone, ClosedFreeBoundary, OpenFreeBoundary) = geompy.GetFreeBoundary(HYDRO_garonne_1) -geompy.addToStudyInFather(HYDRO_garonne_1, ClosedFreeBoundary[0], "ClosedFreeBoundary") +(isDone, ClosedFreeBoundary, OpenFreeBoundary) = geompy.GetFreeBoundary(HYDRO_garonne_2) +geompy.addToStudyInFather(HYDRO_garonne_2, ClosedFreeBoundary[0], "ClosedFreeBoundary") freeBoundary = geompy.ExtractShapes(ClosedFreeBoundary[0], geompy.ShapeType["EDGE"], True) -freeBoundaryIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, freeBoundary[i]) for i in range(len(freeBoundary)) ] +freeBoundaryIds = [ geompy.GetSubShapeID(HYDRO_garonne_2, freeBoundary[i]) for i in range(len(freeBoundary)) ] print("freeBoundaryIds", freeBoundaryIds) [litMineur_droite] = geompy.GetSharedShapesMulti([garonne_riveDroite, garonne_litMineur], geompy.ShapeType["EDGE"], True) [litMineur_gauche] = geompy.GetSharedShapesMulti([garonne_riveGauche, garonne_litMineur], geompy.ShapeType["EDGE"], True) -geompy.addToStudyInFather(HYDRO_garonne_1, litMineur_droite, "litMineur_droite") -geompy.addToStudyInFather(HYDRO_garonne_1, litMineur_gauche, "litMineur_gauche") +geompy.addToStudyInFather(HYDRO_garonne_2, litMineur_droite, "litMineur_droite") +geompy.addToStudyInFather(HYDRO_garonne_2, litMineur_gauche, "litMineur_gauche") rives = [litMineur_droite, litMineur_gauche] -rivesIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, rives[i]) for i in range(len(rives)) ] +rivesIds = [ geompy.GetSubShapeID(HYDRO_garonne_2, rives[i]) for i in range(len(rives)) ] print("rivesIds", rivesIds) -edges_litMineur = geompy.GetSharedShapesMulti([HYDRO_garonne_1, garonne_litMineur], geompy.ShapeType["EDGE"], True) -edges_riveGauche = geompy.GetSharedShapesMulti([HYDRO_garonne_1, garonne_riveGauche], geompy.ShapeType["EDGE"], True) -edges_riveDroite = geompy.GetSharedShapesMulti([HYDRO_garonne_1, garonne_riveDroite], geompy.ShapeType["EDGE"], True) -edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_litMineur[i]) for i in range(len(edges_litMineur)) ] -edges_riveGaucheIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveGauche[i]) for i in range(len(edges_riveGauche)) ] -edges_riveDroiteIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveDroite[i]) for i in range(len(edges_riveDroite)) ] +edges_litMineur = geompy.GetSharedShapesMulti([HYDRO_garonne_2, garonne_litMineur], geompy.ShapeType["EDGE"], True) +edges_riveGauche = geompy.GetSharedShapesMulti([HYDRO_garonne_2, garonne_riveGauche], geompy.ShapeType["EDGE"], True) +edges_riveDroite = geompy.GetSharedShapesMulti([HYDRO_garonne_2, garonne_riveDroite], geompy.ShapeType["EDGE"], True) +edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_garonne_2, edges_litMineur[i]) for i in range(len(edges_litMineur)) ] +edges_riveGaucheIds = [ geompy.GetSubShapeID(HYDRO_garonne_2, edges_riveGauche[i]) for i in range(len(edges_riveGauche)) ] +edges_riveDroiteIds = [ geompy.GetSubShapeID(HYDRO_garonne_2, edges_riveDroite[i]) for i in range(len(edges_riveDroite)) ] print("edges_litMineurIds", edges_litMineurIds) print("edges_riveGaucheIds", edges_riveGaucheIds) @@ -271,25 +271,25 @@ print("edges_riveDroiteIds", edges_riveDroiteIds) sectionsIds = [Id for Id in edges_litMineurIds if Id not in rivesIds] print("sectionsIds", sectionsIds) -SectionsGaronne = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +SectionsGaronne = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) geompy.UnionIDs(SectionsGaronne, sectionsIds) -geompy.addToStudyInFather(HYDRO_garonne_1, SectionsGaronne, "SectionsGaronne") +geompy.addToStudyInFather(HYDRO_garonne_2, SectionsGaronne, "SectionsGaronne") bordGaucheDomaineIds = [Id for Id in freeBoundaryIds if Id in edges_riveGaucheIds] bordDroiteDomaineIds = [Id for Id in freeBoundaryIds if Id in edges_riveDroiteIds] print("bordGaucheDomaineIds", bordGaucheDomaineIds) print("bordDroiteDomaineIds", bordDroiteDomaineIds) -bordGaucheDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +bordGaucheDomaine = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) geompy.UnionIDs(bordGaucheDomaine, bordGaucheDomaineIds) -geompy.addToStudyInFather(HYDRO_garonne_1, bordGaucheDomaine, "bordGaucheDomaine") -bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +geompy.addToStudyInFather(HYDRO_garonne_2, bordGaucheDomaine, "bordGaucheDomaine") +bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) -geompy.addToStudyInFather(HYDRO_garonne_1, bordDroiteDomaine, "bordDroiteDomaine") +geompy.addToStudyInFather(HYDRO_garonne_2, bordDroiteDomaine, "bordDroiteDomaine") -amont = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(46757.861314, 25833.234752, 0)) -aval = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(39078.979127, 32588.627279, 0)) -geompy.addToStudyInFather(HYDRO_garonne_1, amont, "amont") -geompy.addToStudyInFather(HYDRO_garonne_1, aval, "aval") +amont = geompy.GetEdgeNearPoint(HYDRO_garonne_2, geompy.MakeVertex(46757.861314, 25833.234752, 0)) +aval = geompy.GetEdgeNearPoint(HYDRO_garonne_2, geompy.MakeVertex(39078.979127, 32588.627279, 0)) +geompy.addToStudyInFather(HYDRO_garonne_2, amont, "amont") +geompy.addToStudyInFather(HYDRO_garonne_2, aval, "aval") #---------------------- # --- Meshing @@ -303,9 +303,9 @@ import tempfile smesh = smeshBuilder.New() # --- algorithms and hypothesis -garonne_1 = smesh.Mesh(HYDRO_garonne_1) +garonne_2 = smesh.Mesh(HYDRO_garonne_2) -NETGEN_2D = garonne_1.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D = garonne_2.Triangle(algo=smeshBuilder.NETGEN_1D2D) NETGEN_2D_Parameters = NETGEN_2D.Parameters() NETGEN_2D_Parameters.SetMaxSize( 200 ) NETGEN_2D_Parameters.SetSecondOrder( 0 ) @@ -316,60 +316,60 @@ NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) NETGEN_2D_Parameters.SetFuseEdges( 1 ) NETGEN_2D_Parameters.SetQuadAllowed( 0 ) -algo2D_litMineur = garonne_1.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=garonne_litMineur) -algo1D_litMineur = garonne_1.Segment(geom=garonne_litMineur) +algo2D_litMineur = garonne_2.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=garonne_litMineur) +algo1D_litMineur = garonne_2.Segment(geom=garonne_litMineur) hypo1D_litMineur = algo1D_litMineur.LocalLength(100,None,1e-07) subMesh_litMineur = algo1D_litMineur.GetSubMesh() smesh.SetName(subMesh_litMineur, "litMineur") -algo1D_SectionsGaronne = garonne_1.Segment(geom=SectionsGaronne) +algo1D_SectionsGaronne = garonne_2.Segment(geom=SectionsGaronne) hypo1D_SectionsGaronne = algo1D_SectionsGaronne.NumberOfSegments(8) hypo1D_SectionsGaronne.SetDistrType( 0 ) subMesh_SectionsGaronne = algo1D_SectionsGaronne.GetSubMesh() smesh.SetName(subMesh_SectionsGaronne, "SectionsGaronne") -isDone = garonne_1.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur ] ]) +isDone = garonne_2.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur ] ]) # --- compute mesh -isDone = garonne_1.Compute() -isDone = garonne_1.SplitQuadObject( garonne_1, 1 ) -isDone = garonne_1.ReorientObject( garonne_1 ) +isDone = garonne_2.Compute() +isDone = garonne_2.SplitQuadObject( garonne_2, 1 ) +isDone = garonne_2.ReorientObject( garonne_2 ) # --- geometrical groups of faces -riveGauche_1 = garonne_1.GroupOnGeom(garonne_riveGauche,'riveGauche',SMESH.FACE) -litMineur_1 = garonne_1.GroupOnGeom(garonne_litMineur,'litMineur',SMESH.FACE) -riveDroite_1 = garonne_1.GroupOnGeom(garonne_riveDroite,'riveDroite',SMESH.FACE) +riveGauche_1 = garonne_2.GroupOnGeom(garonne_riveGauche,'riveGauche',SMESH.FACE) +litMineur_1 = garonne_2.GroupOnGeom(garonne_litMineur,'litMineur',SMESH.FACE) +riveDroite_1 = garonne_2.GroupOnGeom(garonne_riveDroite,'riveDroite',SMESH.FACE) # --- geometrical groups of edges -ClosedFreeBoundary_1 = garonne_1.GroupOnGeom(ClosedFreeBoundary[0],'ClosedFreeBoundary',SMESH.EDGE) -litMineur_droite_1 = garonne_1.GroupOnGeom(litMineur_droite,'litMineur_droite',SMESH.EDGE) -litMineur_gauche_1 = garonne_1.GroupOnGeom(litMineur_gauche,'litMineur_gauche',SMESH.EDGE) -SectionsGaronne_1 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE) -bordGaucheDomaine_1 = garonne_1.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.EDGE) -bordDroiteDomaine_1 = garonne_1.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.EDGE) -amont_1 = garonne_1.GroupOnGeom(amont,'amont',SMESH.EDGE) -aval_1 = garonne_1.GroupOnGeom(aval,'aval',SMESH.EDGE) +ClosedFreeBoundary_1 = garonne_2.GroupOnGeom(ClosedFreeBoundary[0],'ClosedFreeBoundary',SMESH.EDGE) +litMineur_droite_1 = garonne_2.GroupOnGeom(litMineur_droite,'litMineur_droite',SMESH.EDGE) +litMineur_gauche_1 = garonne_2.GroupOnGeom(litMineur_gauche,'litMineur_gauche',SMESH.EDGE) +Sectionsgaronne_2 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE) +bordGaucheDomaine_1 = garonne_2.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.EDGE) +bordDroiteDomaine_1 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.EDGE) +amont_1 = garonne_2.GroupOnGeom(amont,'amont',SMESH.EDGE) +aval_1 = garonne_2.GroupOnGeom(aval,'aval',SMESH.EDGE) # --- geometrical groups of nodes -garonne_1_litMineur_2 = garonne_1.GroupOnGeom(garonne_litMineur,'garonne_1_litMineur',SMESH.NODE) -garonne_1_riveDroite_2 = garonne_1.GroupOnGeom(garonne_riveDroite,'garonne_1_riveDroite',SMESH.NODE) -garonne_1_riveGauche_2 = garonne_1.GroupOnGeom(garonne_riveGauche,'garonne_1_riveGauche',SMESH.NODE) -ClosedFreeBoundary_2 = garonne_1.GroupOnGeom(ClosedFreeBoundary[0],'ClosedFreeBoundary',SMESH.NODE) -litMineur_droite_2 = garonne_1.GroupOnGeom(litMineur_droite,'litMineur_droite',SMESH.NODE) -litMineur_gauche_2 = garonne_1.GroupOnGeom(litMineur_gauche,'litMineur_gauche',SMESH.NODE) -SectionsGaronne_2 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) -bordGaucheDomaine_2 = garonne_1.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.NODE) -bordDroiteDomaine_2 = garonne_1.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE) -amont_2 = garonne_1.GroupOnGeom(amont,'amont',SMESH.NODE) -aval_2 = garonne_1.GroupOnGeom(aval,'aval',SMESH.NODE) - -garonne_1.SetAutoColor( 1 ) -fichierMaillage = os.path.join(HYDRO_TEST_RESOURCES, 'garonne_1.med') -garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) - -controlMeshStats(garonne_1, 3952, 512, 7690) +garonne_2_litMineur_2 = garonne_2.GroupOnGeom(garonne_litMineur,'garonne_2_litMineur',SMESH.NODE) +garonne_2_riveDroite_2 = garonne_2.GroupOnGeom(garonne_riveDroite,'garonne_2_riveDroite',SMESH.NODE) +garonne_2_riveGauche_2 = garonne_2.GroupOnGeom(garonne_riveGauche,'garonne_2_riveGauche',SMESH.NODE) +ClosedFreeBoundary_2 = garonne_2.GroupOnGeom(ClosedFreeBoundary[0],'ClosedFreeBoundary',SMESH.NODE) +litMineur_droite_2 = garonne_2.GroupOnGeom(litMineur_droite,'litMineur_droite',SMESH.NODE) +litMineur_gauche_2 = garonne_2.GroupOnGeom(litMineur_gauche,'litMineur_gauche',SMESH.NODE) +SectionsGaronne_2 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) +bordGaucheDomaine_2 = garonne_2.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.NODE) +bordDroiteDomaine_2 = garonne_2.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE) +amont_2 = garonne_2.GroupOnGeom(amont,'amont',SMESH.NODE) +aval_2 = garonne_2.GroupOnGeom(aval,'aval',SMESH.NODE) + +garonne_2.SetAutoColor( 1 ) +fichierMaillage = os.path.join(HYDRO_TEST_RESOURCES, 'garonne_2.med') +garonne_2.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) + +controlMeshStats(garonne_2, 3952, 512, 7690) controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2321) controlSubMeshStats(riveGauche_1, 2985) diff --git a/doc/salome/examples/h022_extensionSimpleComplete.py b/doc/salome/examples/h022_extensionSimpleComplete.py index 142faef6..2fecd70b 100644 --- a/doc/salome/examples/h022_extensionSimpleComplete.py +++ b/doc/salome/examples/h022_extensionSimpleComplete.py @@ -10,7 +10,7 @@ print("tmpdir=",tmpdir) # --- generated resources -origFileMesh = os.path.join(HYDRO_TEST_RESOURCES, 'garonne_1.med') +origFileMesh = os.path.join(HYDRO_TEST_RESOURCES, 'garonne_2.med') # ---------------------------------------------------------------------------------- # --- domain extension @@ -25,7 +25,7 @@ from salome.hydrotools.shapesGroups import freeBordersGroup, exploreEdgeGroups, offsetX = 430000. offsetY = 6350000. -ficMeshOut = os.path.join(tmpdir, "garonne_1_brd.med") +ficMeshOut = os.path.join(tmpdir, "garonne_2_brd.med") fileMeshBrd = freeBordersGroup(origFileMesh, ficMeshOut) exploreEdgeGroups(fileMeshBrd, "", offsetX, offsetY) @@ -37,18 +37,18 @@ from HYDROPy import * from PyQt5.QtCore import * from PyQt5.QtGui import * -from salome.hydrotools.hydroGeoMeshUtils import importPolyline, importBathymetry, createImmersibleZone +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone hydro_doc = HYDROData_Document.Document() hydro_doc.SetLocalCS( offsetX, offsetY ) -limite_original = importPolyline(hydro_doc, "garonne_1_brd_FreeBorders", tmpdir, '_0', True, 4) -limite_domaine = importPolyline(hydro_doc, "extension_1_1", HYDRO_SAMPLES, '_PolyXY_0', False, 2) +limites_original = importPolylines(hydro_doc, os.path.join(tmpdir, "garonne_2_brd_FreeBorders.shp"), 'garonne_2_brd_FreeBorders', True, 4) +limites_domaine = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "extension_1_1.shp"), 'extension_1_1_PolyXY', False, 2) Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) -domaine_original = createImmersibleZone(hydro_doc, "domaine_original", limite_original, Cloud_02, False, 1) -domaine_englobant = createImmersibleZone(hydro_doc, "domaine_englobant", limite_domaine, Cloud_02, True, 0) +domaine_original = createImmersibleZone(hydro_doc, "domaine_original", limites_original[0], Cloud_02, False, 1) +domaine_englobant = createImmersibleZone(hydro_doc, "domaine_englobant", limites_domaine[0], Cloud_02, True, 0) # Calculation case extension = hydro_doc.CreateObject( KIND_CALCULATION ) @@ -63,7 +63,7 @@ extension.AddGeometryGroup( case_geom_group ) case_geom_group = domaine_original.GetGroup( 0 ) extension.AddGeometryGroup( case_geom_group ) -extension.SetBoundaryPolyline( limite_domaine ) +extension.SetBoundaryPolyline( limites_domaine[0] ) # Start the algorithm of the partition and assignment extension.Update() diff --git a/src/HYDROTools/hydroGeoMeshUtils.py b/src/HYDROTools/hydroGeoMeshUtils.py index 04b31cf7..18df35eb 100644 --- a/src/HYDROTools/hydroGeoMeshUtils.py +++ b/src/HYDROTools/hydroGeoMeshUtils.py @@ -26,20 +26,31 @@ def getChildrenInStudy(obj): childIterator.Next() return children -def importPolyline(document, shapeName, shapePath, suffix, iSpline, displayLevel): +def importPolylines(document, shapeFile, shapeName, iSpline, displayLevel): """ """ - shapeFile = os.path.join(shapePath, shapeName+".shp") HYDROData_PolylineXY.ImportShapesFromFile(shapeFile) - shape = document.FindObjectByName(shapeName + suffix) shapeType = 0 # polyline if iSpline: shapeType = 1 # polyline - for i in range(shape.NbSections()): - shape.SetSectionType(i, shapeType) - shape.Update() - shape.SetZLevel( displayLevel ) - return shape + shapes = [] + isShapeFound = True + index = 0 + while isShapeFound: + shapeNameIndex = shapeName + "_%d" % index + index = index + 1 + print(shapeNameIndex) + shape = document.FindObjectByName(shapeNameIndex) + print(shape) + if shape is None: + isShapeFound = False + else: + for i in range(shape.NbSections()): + shape.SetSectionType(i, shapeType) + shape.Update() + shape.SetZLevel( displayLevel ) + shapes.append(shape) + return shapes def importBathymetry(document, bathyName, bathyPath): """ -- 2.39.2