From: Paul RASCLE Date: Thu, 16 Jul 2020 20:22:17 +0000 (+0200) Subject: fix free borders X-Git-Tag: SH_V2_2_0~92 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=488eeec57cc6f474ec82401acddb31ad84e5b222;p=modules%2Fhydro.git fix free borders --- diff --git a/src/HYDROTools/shapesGroups.py b/src/HYDROTools/shapesGroups.py index cac3e446..aeb10c61 100644 --- a/src/HYDROTools/shapesGroups.py +++ b/src/HYDROTools/shapesGroups.py @@ -19,6 +19,7 @@ def freeBordersGroup(meshFile): smesh = smeshBuilder.New() smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed ([MESH], status) = smesh.CreateMeshesFromMED(meshFile) + nbAdded, MESH, addedBnd = MESH.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, []) groups = MESH.GetGroups() aCriteria = [] aCriterion = smesh.GetCriterion(SMESH.EDGE,SMESH.FT_FreeBorders,SMESH.FT_Undefined,0) @@ -26,10 +27,12 @@ def freeBordersGroup(meshFile): aFilter = smesh.GetFilterFromCriteria(aCriteria) aFilter.SetMesh(MESH.GetMesh()) FreeBorders = MESH.GroupOnFilter( SMESH.EDGE, 'FreeBorders', aFilter ) - smesh.SetName(MESH, 'MESH') - newMeshName = '/tmp/freeBorders.med' + a = os.path.splitext(meshFile) + smesh.SetName(MESH, os.path.basename(a[0])) + newMeshName = a[0] + '_brd' + a[1] + print(newMeshName) try: - MESH.ExportMED(newMeshName,auto_groups=0,minor=41,overwrite=1,meshPart=None,autoDimension=1) + MESH.ExportMED(newMeshName,auto_groups=0,minor=40,overwrite=1,meshPart=None,autoDimension=1) pass except: print('ExportMED() failed. Invalid file name?') @@ -153,13 +156,16 @@ def exploreEdgeGroups(meshFile, offsetX=0., offsetY=0.): d1=-1 # when dimension 2, edges are dim -1 if dim == 3: # when dimension 3, edges are dim -2 d1=-2 + a = os.path.splitext(meshFile) + prefix = os.path.basename(a[0]) grp_names = mcMesh.getGroupsOnSpecifiedLev(d1) #names of edges groups groups = [mcMesh.getGroup(d1, name) for name in grp_names] for (grp, grpName) in zip(groups, grp_names): - nodeChains = explodeGroup(grp, grpName) - writeShapeLines(mcMesh, grpName, nodeChains, offsetX, offsetY) - writeShapePoints(mcMesh, grpName, nodeChains, offsetX, offsetY) + fullGrpName = prefix + '_' + grpName + nodeChains = explodeGroup(grp, fullGrpName) + writeShapeLines(mcMesh, fullGrpName, nodeChains, offsetX, offsetY) + writeShapePoints(mcMesh, fullGrpName, nodeChains, offsetX, offsetY) def fitShapePointsToMesh(freeBorderShapefile, shapefileToAdjust):