Beispiel #1
0
    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)
Beispiel #2
0
    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)