import shapefile
import math
import os
-
+import json
def freeBordersGroup(meshFileIn, meshFileOut=""):
"""
w.line([chaincoords])
w.record(chainName)
w.close()
+ return shapeFileName + '.shp'
def writeShapePoints(mcMesh, grpName, nodeChains, 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):
"""
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
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