X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROTools%2FshapesGroups.py;h=7f3b7e0b99794aaa46ea6c239253c48f092a2746;hb=3bece499e83cc9ca95536228c7f6740030e9d5d8;hp=f4673d800e977a5d1ee196980532d34b4b93be10;hpb=d3919797a21987e0e481c62695634a5d637e0ce3;p=modules%2Fhydro.git diff --git a/src/HYDROTools/shapesGroups.py b/src/HYDROTools/shapesGroups.py index f4673d80..7f3b7e0b 100644 --- a/src/HYDROTools/shapesGroups.py +++ b/src/HYDROTools/shapesGroups.py @@ -12,7 +12,7 @@ import medcoupling as mc import shapefile import math import os - +import json def freeBordersGroup(meshFileIn, meshFileOut=""): """ @@ -159,6 +159,7 @@ def writeShapeLines(mcMesh, grpName, nodeChains, outputDirectory, offsetX=0., of w.line([chaincoords]) w.record(chainName) w.close() + return shapeFileName + '.shp' def writeShapePoints(mcMesh, grpName, nodeChains, outputDirectory, offsetX=0., offsetY=0.): @@ -216,12 +217,16 @@ def exploreEdgeGroups(meshFile, outputDirectory="", offsetX=0., offsetY=0.): groups = [mcMesh.getGroup(d1, name) for name in grp_names] # list of groups in their name order + filenames = [] for (grp, grpName) in zip(groups, grp_names): fullGrpName = prefix + '_' + grpName nodeChains = explodeGroup(grp, fullGrpName) - writeShapeLines(mcMesh, fullGrpName, nodeChains, outputDirectory, offsetX, offsetY) + filename = writeShapeLines(mcMesh, fullGrpName, nodeChains, outputDirectory, offsetX, offsetY) writeShapePoints(mcMesh, fullGrpName, nodeChains, outputDirectory, offsetX, offsetY) - + filenames.append(filename) + shapesListFile = os.path.join(outputDirectory, "shapesList.json") + with open(shapesListFile, 'w') as f: + json.dump(filenames, f) def fitShapePointsToMesh(freeBorderShapefile, shapefileToAdjust, outputDirectory="", splitFreeBorder=True, splitShapeAdjusted=True): """ @@ -304,7 +309,7 @@ def fitShapePointsToMesh(freeBorderShapefile, shapefileToAdjust, outputDirectory outputDirectory = os.path.dirname(shapefileToAdjust) a = os.path.splitext(os.path.basename(shapefileToAdjust)) shapefileAdjusted = os.path.join(outputDirectory, a[0] + '_adj' + a[1]) - chainName = a[0] + chainName = a[0] + '_adj' w = shapefile.Writer(shapefileAdjusted) w.shapeType = 3 @@ -354,7 +359,7 @@ def fitShapePointsToMesh(freeBorderShapefile, shapefileToAdjust, outputDirectory outputDirectory = os.path.dirname(freeBorderShapefile) a = os.path.splitext(os.path.basename(freeBorderShapefile)) freeBorderSplit = os.path.join(outputDirectory, a[0] + '_split' + a[1]) - chainName = a[0] + chainName = a[0] + '_split' w = shapefile.Writer(freeBorderSplit) w.shapeType = 3