def create(self): info = "" info += "Input data:\n" # read input meshes nodes = {} mesh = {} if self.ui.lineEditInputMesh.text() != "": try: nodes, mesh = fh.readT3S(self.ui.lineEditInputMesh.text()) info += " - Mesh loaded with {0} nodes and {1} elements.\n".format(len(nodes), len(mesh)) except: QMessageBox.critical(self.widget, "Error", "Not able to load mesh file!\nCheck filename or content!") return # read input line sets linesetNodes = {} lineset = {} dim = 2 if self.ui.lineEditInputLineSet.text() != "": try: if self.ui.lineEditInputLineSet.text().split(".")[-1] == "i2s": linesetNodes, lineset = fh.readI2S(self.ui.lineEditInputLineSet.text()) dim = 2 else: linesetNodes, lineset = fh.readI3S(self.ui.lineEditInputLineSet.text()) dim = 3 info += " - Line set loaded with {0} lines and {1} nodes.\n".format(len(lineset), len(linesetNodes)) except: QMessageBox.critical(self.widget, "Error", "Not able to load line set!\nCheck filename or content!") return info += "\nOutput data:\n" # write mesh if self.ui.checkBoxOutputMesh.isChecked() and self.ui.lineEditInputMesh.text() != "": try: fh.writeMeshDXF(self.ui.lineEditOutputMesh.text(), nodes, mesh, self.typeDXFmesh) info += " - Mesh written to {0}.\n".format(self.ui.lineEditOutputMesh.text()) except: QMessageBox.critical(self.widget, "Error", "Not able to write mesh!") return # write line set if self.ui.checkBoxOutputLineSet.isChecked() and self.ui.lineEditInputLineSet.text() != "": try: fh.writeLineSetDXF(self.ui.lineEditOutputLineSet.text(), linesetNodes, lineset, dim) info += " - Line set written to {0}.\n".format(self.ui.lineEditOutputLineSet.text()) except: QMessageBox.critical(self.widget, "Error", "Not able to write line sets!") return QMessageBox.information(self.widget, "Module BK2DXF", info)
def create(self): info = "Input data:\n" try: nodRaw, proRaw = fh.readI3S(self.ui.lineEditProfiles.text()) info += " - Profiles:\t\t\t{0}\n".format(len(proRaw)) except: QMessageBox.critical(self.widget, "Error", "Not able to load profiles file!\nCheck filename or content!") return try: nodReach = fh.readI2S(self.ui.lineEditReach.text())[0] info += " - Reach nodes:\t\t{0}\n".format(len(nodReach)) except: QMessageBox.critical(self.widget, "Error", "Not able to load reach file!\nCheck filename or content!") return if len(proRaw) != len(nodReach): QMessageBox.critical(self.widget, "Error", "Number of profiles must correspond to number of reach nodes!") return nnC = self.ui.spinBoxNNC.value() length = self.ui.doubleSpinBoxEL.value() nnL = None nodLBL = None if self.ui.checkBoxLBL.isChecked(): nnL = self.ui.spinBoxNNL.value() try: if self.ui.lineEditLBL.text().split(".")[-1] == "i2s": nodLBL = fh.readI2S(self.ui.lineEditLBL.text())[0] else: nodLBL = fh.readI3S(self.ui.lineEditLBL.text())[0] info += " - Left breakline nodes:\t{0}\n".format(len(nodLBL)) except: QMessageBox.critical(self.widget, "Error", "Not able to load left breakline file!\nCheck filename or content!") return else: nnL = None nodLBL = None nnR = None nodRBL = None if self.ui.checkBoxRBL.isChecked(): nnR = self.ui.spinBoxNNR.value() try: if self.ui.lineEditRBL.text().split(".")[-1] == "i2s": nodRBL = fh.readI2S(self.ui.lineEditRBL.text())[0] else: nodRBL = fh.readI3S(self.ui.lineEditRBL.text())[0] info += " - Right breakline nodes:\t{0}\n".format(len(nodRBL)) except: QMessageBox.critical(self.widget, "Error", "Not able to load right breakline file!\nCheck filename or content!") return else: nnR = None nodRBL = None nodLBO = None if self.ui.checkBoxLBO.isChecked(): try: if self.ui.lineEditLBO.text().split(".")[-1] == "i2s": nodLBO = fh.readI2S(self.ui.lineEditLBO.text())[0] else: nodLBO = fh.readI3S(self.ui.lineEditLBO.text())[0] info += " - Left boundary nodes:\t{0}\n".format(len(nodLBO)) except: QMessageBox.critical(self.widget, "Error", "Not able to load left boundary file!\nCheck filename or content!") return else: nodLBO = None nodRBO = None if self.ui.checkBoxRBO.isChecked(): try: if self.ui.lineEditRBO.text().split(".")[-1] == "i2s": nodRBO = fh.readI2S(self.ui.lineEditRBO.text())[0] else: nodRBO = fh.readI3S(self.ui.lineEditRBO.text())[0] info += " - Right boundary nodes:\t{0}\n".format(len(nodRBO)) except: QMessageBox.critical(self.widget, "Error", "Not able to load right boundary file!\nCheck filename or content!") return else: nodRBO = None self.mesh = CalcMesh( nodRaw, proRaw, nodReach, nnC, length, nodLBL, nodRBL, nodLBO, nodRBO, nnL, nnR ) try: info += self.mesh.determineFlowDirection() except: QMessageBox.critical(self.widget, "Error", "Not able to determine flow direction!\nCheck inputs!") return try: info += self.mesh.normalizeProfiles() except: QMessageBox.critical(self.widget, "Error", "Not able to normalize profiles!\nCheck inputs!") return try: info += self.mesh.interpolateChannel() except: QMessageBox.critical(self.widget, "Error", "Not able to interpolate channel!\nCheck inputs!") return try: info += self.mesh.interpolateElevation() except: QMessageBox.critical(self.widget, "Error", "Not able to interpolate elevation!\nCheck inputs!") return if self.ui.checkBoxEC.isChecked(): try: info += self.mesh.interpolateElevationCorrection() except: QMessageBox.critical(self.widget, "Error", "Not able to interpolate elevation correction!\nCheck inputs!") return try: info += self.mesh.createMesh() except: QMessageBox.critical(self.widget, "Error", "Not able to create mesh!\nCheck inputs!") return try: self.writeOutput() except: QMessageBox.critical(self.widget, "Error", "Not able to write output!") return QMessageBox.information(self.widget, "Module Mesh", info)
def create(self): info = "Input data:\n" try: self.nodProfiles, self.proProfiles = fh.readI2S(self.ui.lineEditInputProfiles.text()) info += " - Profiles:\t\t\t{0}\n".format(len(self.proProfiles)) except: QMessageBox.critical(self.widget, "Error", "Not able to load profiles file!\nCheck filename or content!") return try: self.nodReach = fh.readI2S(self.ui.lineEditInputReach.text())[0] info += " - Reach nodes:\t\t{0}\n".format(len(self.nodReach)) except: QMessageBox.critical(self.widget, "Error", "Not able to load reach file!\nCheck filename or content!") return try: rows = self.ui.tableWidget.rowCount() for row in range(rows): self.ui.tableWidget.item(row, 0).text() self.ui.tableWidget.item(row, 1).text() str(self.ui.tableWidget.item(row, 2).text()).split(",")[2] info += " - Water surface results:\t{0}\n".format(rows) except: QMessageBox.critical(self.widget, "Error", "Check filename, surface name and colour!") return self.proArranged, self.reachStation, self.profileStation, direction = po.determineFlowDirection(self.nodReach, self.nodProfiles, self.proProfiles) info += "\nFlow direction:\n" for pID_Arranged in direction: info += ' - Profile {0}:\t{1}\n'.format(pID_Arranged, direction[pID_Arranged]) # create bottom cross sections try: bottom = fh.readT3StoShapely(self.ui.lineEditInputBottom.text()) bottomCrossSections = self.getCrossSections(bottom) except: QMessageBox.critical(self.widget, "Error", "Not able to interpolate bottom profile!") return # create water surface cross sections try: rows = self.ui.tableWidget.rowCount() wsCrossSections = {} colRGB = {} if rows > 0: for row in range(rows): filename = self.ui.tableWidget.item(row, 0).text() name = self.ui.tableWidget.item(row, 1).text() watersurface = fh.readT3StoShapely(filename) wsCrossSections[name] = self.getCrossSections(watersurface) col = Colour(str(self.ui.tableWidget.item(row, 2).text()).split(",")) col.create() colRGB[name] = col.getRGB() except: QMessageBox.critical(self.widget, "Error", "Not able to interpolate water surface profiles!") return scale = self.ui.spinBoxScale.value() superelevation = self.ui.doubleSpinBoxSuperelevation.value() info += "\nOutput data:\n" if self.ui.checkBoxOutputProfiles.isChecked(): try: cs = ProfileWriter(self.ui.lineEditOutputProfiles.text(),\ bottomCrossSections, self.reachStation, self.profileStation, scale, superelevation, self.settings, self.ui.lineEditInputReachName.text()) cs.drawBottom() cs.drawWaterSurface(wsCrossSections, colRGB) cs.saveDXF() info += " - DXF file written to {0}.\n".format(self.ui.lineEditOutputProfiles.text()) except: info += " - ERROR: Not able to write profiles!\n" QMessageBox.information(self.widget, "Module ProfilesDXF", info)
def create(self): info = "" info += "Input data:\n" textfile = [] # read input meshes try: x, y, z, triangles = fh.readT3STriangulation(self.ui.lineEditInputMesh.text()) info += " - Mesh loaded with {0} nodes and {1} elements.\n".format(len(x), len(triangles)) except: QMessageBox.critical(self, "Error", "Not able to load mesh file!\nCheck filename or content!") return try: tube_coords, tubes = fh.readI2S(self.ui.lineEditInputLineSet.text()) info += " - Line Set loaded with {0} lines.\n".format(len(tubes)) except: QMessageBox.critical(self.widget, "Error", "Not able to load *.i2s file!\nCheck filename or content!") return # reshape coordinates a = np.array([x, y]) b = np.reshape(a, (2*len(x)), order='F') mesh_coords = np.reshape(b, (len(x), 2)) Rel = str(self.ui.doubleSpinBoxRel.value()) Ce1 = str(self.ui.doubleSpinBoxCe1.value()) Ce2 = str(self.ui.doubleSpinBoxCe2.value()) Cs1 = str(self.ui.doubleSpinBoxCs1.value()) Cs2 = str(self.ui.doubleSpinBoxCs2.value()) Lrg = str(self.ui.doubleSpinBoxLrg.value()) Hau = str(self.ui.doubleSpinBoxHau.value()) Clp = str(self.ui.spinBoxClp.value()) L12 = str(self.ui.doubleSpinBoxL12.value()) textfile.append("Relaxation") textfile.append(Rel) textfile.append("I1\tI2\tCe1\tCe2\tCs1\tCs2\tLrg\tHau\tClp\tL12\tz1\tz2") for tID in tubes: line = "" tube = tubes[tID] nodes = "" z_val = "" for i in range(2): p = tube_coords[tube[i]] vert = np.array(p) vert = vert.reshape((1,2)) temp = mesh_coords-p norm = np.linalg.norm(temp, axis = 1) I = np.argmin(norm)+1 nodes += str(I) nodes += "\t" z_val += str(z[I-1]) z_val += "\t" line += nodes line += str(Ce1) + "\t" line += str(Ce2) + "\t" line += str(Cs1) + "\t" line += str(Cs2) + "\t" line += str(Lrg) + "\t" line += str(Hau) + "\t" line += str(Clp) + "\t" line += str(L12) + "\t" line += z_val textfile.append(line) info += "\nOutput data:\n" try: fh.writeTextFile(self.ui.lineEditOutput.text(), textfile) info += " - Tubes data file written to {0}.\n".format(self.ui.lineEditOutput.text()) except: QMessageBox.critical(self.widget, "Error", "Not able to write tubes data file!") return QMessageBox.information(self.widget, "Module Tube", info)
def create(self): info = "Input data:\n" try: self.nodProfiles, self.proProfiles = fh.readI2S(self.ui.lineEditInputProfiles.text()) info += " - Profiles:\t\t\t{0}\n".format(len(self.proProfiles)) except: QMessageBox.critical(self.widget, "Error", "Not able to load profiles file!\nCheck filename or content!") return try: self.nodReach = fh.readI2S(self.ui.lineEditInputReach.text())[0] info += " - Reach nodes:\t\t{0}\n".format(len(self.nodReach)) except: QMessageBox.critical(self.widget, "Error", "Not able to load reach file!\nCheck filename or content!") return try: self.points = fh.readXYZ(self.ui.lineEditInputPoints.text()) info += " - Points:\t\t\t{0}\n".format(len(self.points)) except: QMessageBox.critical(self.widget, "Error", "Not able to load points file!\nCheck filename or content!") return self.proArranged, self.reachStation, self.profileStation, direction = po.determineFlowDirection(self.nodReach, self.nodProfiles, self.proProfiles) info += "\nProfile information:\n" for pID_Arranged in direction: info += ' - Profile {0}:\tFlow direction: {1}\tStation: {2}\t\n'.format(pID_Arranged, direction[pID_Arranged], round(self.reachStation[pID_Arranged], 2)) self.pointsNormalized, self.segmentStation = self.normalizeProfiles() info += "\nOutput data:\n" if self.ui.checkBoxOutputTextfile.isChecked(): try: self.writeTXT() info += " - Textfile written to {0}.\n".format(self.ui.lineEditOutputTextfile.text()) except: info += " - ERROR: Not able to write textfile!\n" if self.ui.checkBoxOutputDXF.isChecked(): scale = self.ui.spinBoxScale.value() superelevation = self.ui.doubleSpinBoxSuperelevation.value() try: cs = ProfileWriter(self.ui.lineEditOutputDXF.text(),\ self.pointsNormalized, self.reachStation, self.profileStation, scale, superelevation, self.settings, self.ui.lineEditInputReachName.text()) cs.drawBottom() cs.saveDXF() info += " - DXF file written to {0}.\n".format(self.ui.lineEditOutputDXF.text()) except: info += " - ERROR: Not able to write DXF file!\n" if self.ui.checkBoxOutputHECRAS.isChecked(): self.writeGEO() try: self.writeGEO() info += " - GEO file written to {0}.\n".format(self.ui.lineEditOutputHECRAS.text()) except: info += " - ERROR: Not able to write geo file!\n" QMessageBox.information(self.widget, "Module XYZ2Profiles", info)