<x>0</x>
<y>0</y>
<width>814</width>
- <height>369</height>
+ <height>389</height>
</rect>
</property>
<property name="windowTitle">
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="cb_loadFreeBorders">
+ <property name="text">
+ <string>Load free borders shape</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="cb_loadOthers">
+ <property name="text">
+ <string>Load all other edge shapes</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
import os
import sys
+import salome
+
+salome.salome_init()
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import uic
+from HYDROPy import *
+import json
from salome.hydrotools.shapesGroups import freeBordersGroup, exploreEdgeGroups
+from salome.hydrotools.hydroGeoMeshUtils import importPolylines
#import sysconfig
#pythonVersion = 'python' + sysconfig.get_python_version()
offsetX = self.dsb_offsetX.value()
offsetY = self.dsb_offsetY.value()
isOutMedKept = self.cb_keepOutMed.isChecked()
+ isLoadFreeBorders = self.cb_loadFreeBorders.isChecked()
+ isLoadOthers = self.cb_loadOthers.isChecked()
self.accept()
print(medFile)
print(outDir)
if not isOutMedKept:
print("remove", medFileOut)
os.remove(medFileOut)
+ shapesListFile = os.path.join(outDir, "shapesList.json")
+ fileShapes = []
+ with open(shapesListFile, 'r') as f:
+ fileShapes = json.load(f)
+ print(fileShapes)
+ hydro_doc = HYDROData_Document.Document()
+ l = []
+ if isLoadFreeBorders:
+ l = l + [ a for a in fileShapes if "FreeBorders.shp" in a]
+ if isLoadOthers:
+ l = l + [ a for a in fileShapes if "FreeBorders.shp" not in a]
+ for fileShape in l:
+ a = os.path.splitext(os.path.basename(fileShape))
+ shapeName = a[0]
+ shapes = importPolylines(hydro_doc, fileShape, shapeName, 0, 0)
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser()
+
def on_reject(self):
print("reject")
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):
"""