diff --git a/Makefile b/Makefile index 214068b..9d4b410 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ localplugindir = ${HOME}/.qgis/python/plugins/ DEVPACKAGEFILES = mesh_surface meshing_raster_calc rasterise_polygons boundary_identification PACKAGEFILES = mesh_surface meshing_raster_calc rasterise_polygons Polygonizer QuickMultiAttributeEdit -testdir = ./plugins/mesh_netcdf/ +testdir = ./plugins/mesh_surface/ outputdir = ./tests/output/ diff --git a/plugins/mesh_surface/generator.py b/plugins/mesh_surface/generator.py index d573b7a..105ae27 100644 --- a/plugins/mesh_surface/generator.py +++ b/plugins/mesh_surface/generator.py @@ -73,7 +73,7 @@ print "............................................." os.system("mkdir "+test +"/annulus_BN") -os.system("python mesh_terminal --line BN -g "+test+"/annulus_BN/test_annulus_BN.geo "+data+"/annulus.shp --mesh --mval 10") +os.system("python mesh_surface --line BN -g "+test+"/annulus_BN/test_annulus_BN.geo "+data+"/annulus.shp --mesh --mval 10") print "............................................." @@ -82,10 +82,10 @@ print "............................................." os.system("mkdir "+test +"/annulus_BY") -os.system("python "+pwd+"/mesh_terminal --line BY -g "+test+"/annulus_BY/test_annulus_BY.geo "+data+"/annulus.shp --mesh --mval 10") -os.system("python "+pwd+"/mesh_terminal --line BY -g "+test+"/annulus_BY/test_annulus_BY_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump.nc") -os.system("python "+pwd+"/mesh_terminal --line BY -g "+test+"/annulus_BY/test_annulus_BY_medium_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump_medium.nc") -os.system("python "+pwd+"/mesh_terminal --line BY -g "+test+"/annulus_BY/test_annulus_BY_coarse_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump_coarse.nc") +os.system("python "+pwd+"/mesh_surface --line BY -g "+test+"/annulus_BY/test_annulus_BY.geo "+data+"/annulus.shp --mesh --mval 10") +os.system("python "+pwd+"/mesh_surface --line BY -g "+test+"/annulus_BY/test_annulus_BY_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump.nc") +os.system("python "+pwd+"/mesh_surface --line BY -g "+test+"/annulus_BY/test_annulus_BY_medium_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump_medium.nc") +os.system("python "+pwd+"/mesh_surface --line BY -g "+test+"/annulus_BY/test_annulus_BY_coarse_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump_coarse.nc") print "............................................." @@ -94,11 +94,11 @@ print "............................................." os.system("mkdir "+test +"/annulus_LY") -os.system("python "+pwd+"/mesh_terminal --line LY -g "+test+"/annulus_LY/test_annulus_LY.geo "+data+"/annulus.shp --mesh --mval 10") -os.system("python "+pwd+"/mesh_terminal --line LY -g "+test+"/annulus_LY/test_annulus_LY_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump.nc") -os.system("python "+pwd+"/mesh_terminal --line LY -g "+test+"/annulus_LY/test_annulus_LY_medium_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump_medium.nc") -os.system("python "+pwd+"/mesh_terminal --line LY -g "+test+"/annulus_LY/test_annulus_LY_coarse_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump_coarse.nc") - +os.system("python "+pwd+"/mesh_surface --line LY -g "+test+"/annulus_LY/test_annulus_LY.geo "+data+"/annulus.shp --mesh --mval 10") +os.system("python "+pwd+"/mesh_surface --line LY -g "+test+"/annulus_LY/test_annulus_LY_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump.nc") +os.system("python "+pwd+"/mesh_surface --line LY -g "+test+"/annulus_LY/test_annulus_LY_medium_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump_medium.nc") +os.system("python "+pwd+"/mesh_surface --line LY -g "+test+"/annulus_LY/test_annulus_LY_coarse_metric.geo "+data+"/annulus.shp --mesh -m "+test+"/gaussian_bump_coarse.nc") +mesh_surface print "............................................." @@ -107,10 +107,10 @@ print "............................................." os.system("mkdir "+test +"/BN") -os.system("python "+pwd+"/mesh_terminal --line BN -g "+test+"/BN/testfileBN_0.geo "+rtponedomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal --line BN -g "+test+"/BN/testfileBN_1.geo --id "+idfile+" "+rtponedomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal --line BN -g "+test+"/BN/testfileBN_2.geo "+rtpmultdomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal --line BN -g "+test+"/BN/testfileBN_3.geo --id "+idfile+" "+rtpmultdomain+" --mesh") +os.system("python "+pwd+"/mesh_surface --line BN -g "+test+"/BN/testfileBN_0.geo "+rtponedomain+" --mesh") +os.system("python "+pwd+"/mesh_surface --line BN -g "+test+"/BN/testfileBN_1.geo --id "+idfile+" "+rtponedomain+" --mesh") +os.system("python "+pwd+"/mesh_surface --line BN -g "+test+"/BN/testfileBN_2.geo "+rtpmultdomain+" --mesh") +os.system("python "+pwd+"/mesh_surface --line BN -g "+test+"/BN/testfileBN_3.geo --id "+idfile+" "+rtpmultdomain+" --mesh") @@ -122,10 +122,10 @@ print "............................................." os.system("mkdir "+test +"/LY") -os.system("python "+pwd+"/mesh_terminal -l LY -g "+test+"/LY/testfileLY_0.geo "+rtponedomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal -l LY -g "+test+"/LY/testfileLY_1.geo --id "+idfile+" "+rtponedomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal -l LY -g "+test+"/LY/testfileLY_2.geo "+rtpmultdomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal -l LY -g "+test+"/LY/testfileLY_3.geo --id "+idfile+" "+rtpmultdomain+" --mesh") +os.system("python "+pwd+"/mesh_surface -l LY -g "+test+"/LY/testfileLY_0.geo "+rtponedomain+" --mesh") +os.system("python "+pwd+"/mesh_surface -l LY -g "+test+"/LY/testfileLY_1.geo --id "+idfile+" "+rtponedomain+" --mesh") +os.system("python "+pwd+"/mesh_surface -l LY -g "+test+"/LY/testfileLY_2.geo "+rtpmultdomain+" --mesh") +os.system("python "+pwd+"/mesh_surface -l LY -g "+test+"/LY/testfileLY_3.geo --id "+idfile+" "+rtpmultdomain+" --mesh") print "............................................." print "Testing: BSplines = True Compounds = True" @@ -133,10 +133,10 @@ print "............................................." os.system("mkdir "+test +"/BY") -os.system("python "+pwd+"/mesh_terminal -l BY -g "+test+"/BY/testfileBY_0."+rtponedomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal -l BY -g "+test+"/BY/testfileBY_1.geo --id "+idfile+" "+rtponedomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal -l BY -g "+test+"/BY/testfileBY_2.geo "+rtpmultdomain+" --mesh") -os.system("python "+pwd+"/mesh_terminal -l BY -g "+test+"/BY/testfileBY_3.geo --id "+idfile+" "+rtpmultdomain+" --mesh") +os.system("python "+pwd+"/mesh_surface -l BY -g "+test+"/BY/testfileBY_0."+rtponedomain+" --mesh") +os.system("python "+pwd+"/mesh_surface -l BY -g "+test+"/BY/testfileBY_1.geo --id "+idfile+" "+rtponedomain+" --mesh") +os.system("python "+pwd+"/mesh_surface -l BY -g "+test+"/BY/testfileBY_2.geo "+rtpmultdomain+" --mesh") +os.system("python "+pwd+"/mesh_surface -l BY -g "+test+"/BY/testfileBY_3.geo --id "+idfile+" "+rtpmultdomain+" --mesh") print '\033[1m' + "============================================================" + '\033[0m' diff --git a/plugins/mesh_surface/mesh_surface.py b/plugins/mesh_surface/mesh_surface.py index f907677..4329567 100644 --- a/plugins/mesh_surface/mesh_surface.py +++ b/plugins/mesh_surface/mesh_surface.py @@ -58,9 +58,12 @@ from scripts.PreMeshingFunctions import PreMesh from scripts.MeshOperations import MeshOp from scripts.ErrorMessages import * +from scripts.export_geo import * from scripts.define_id import * from scripts.flat_mesh_to_spherical import flat_mesh_spherical +import pdb + # with args? class MeshSurface(PreMesh, MeshOp): @@ -347,6 +350,7 @@ def run(self): # QtGui.QMessageBox.critical(None,"Error: No Active Layer","There are no active layers. Please load a layer.") # raise AssertionError ("Error: No Active Layer.") + self.setDropDownOptions() layers = self.iface.mapCanvas().layers() self.dlg.ui.IdDropdown.clear() @@ -364,11 +368,57 @@ def run(self): startTime = datetime.datetime.now() print "Operation Started: " + str(strftime("%Y-%m-%d %H:%M:%S", gmtime())) self._checkForErrors() - self.MeshSurface() - + #self.MeshSurface() + + # pyqtRemoveInputHook() + # pdb.set_trace() + + ### BSplines doesnt work currently hence on LY and LN + lineType = "LN " + + if self.dlg.ui.compoundCheckBox.isChecked(): + if self.dlg.ui.lineRadioButton.isChecked(): + lineType = "LY " + + ## mesh the shape file + mesh = "" + if self.dlg.ui.commandEdit.isChecked(): + mesh = "--mesh " + + + ## select the shape file or the supplied geo file + domainShapefile = str(self.dlg.ui.domainShapefileLayerDropDown.itemData(self.domainShapefileLayerIndex).toString()) + if self.dlg.ui.chooseGeoFileRadioButton.isChecked(): + geoFile = " -g "+self.dlg.ui.chooseGeoFileLineEdit.text()+" " + else: + geofile = " -g "+domainShapefile[:-4]+".geo " + + ##ADDing the netcdf to it + netCDFFileName = "" + if self.dlg.ui.singleNetCDFChooseFilesRadioButton.isChecked(): + filename = str(self.dlg.ui.singleNetCDFLayerDropDown.itemData(self.singleNetCDFLayerIndex).toString()) + netCDFFileName = " -m "+filename + + ##Adding the IDs + + idFile = "" + defID = "" + + if self.dlg.ui.grpDefID.isChecked(): + idText = self.dlg.ui.IdDropdown.currentText() + idIndex = self.dlg.ui.IdDropdown.findText(idText) + idFile = " --id "+str(self.dlg.ui.IdDropdown.itemData(idIndex).toString()) + defID = " --defid "+str(self.dlg.ui.Default_Id.text()) + + + + os.system("python plugins/mesh_surface/mesh_surface -l "+lineType+geofile+idFile+" "+defID+" "+mesh+netCDFFileName+" "+domainShapefile) + + + print "Operation Stopped: " + str(strftime("%Y-%m-%d %H:%M:%S", gmtime())) - timePassed = datetime.datetime.now() - startTime - print "Time Elapsed: " + str(timePassed.seconds) + " seconds." + timePassed = datetime.datetime.now() - startTime + print "Time Elapsed: " + str(timePassed.seconds) + " seconds." except AssertionError as e: print e.message diff --git a/plugins/mesh_surface/scripts/PreMeshingFunctions.py b/plugins/mesh_surface/scripts/PreMeshingFunctions.py index 3c54c5a..53d6795 100644 --- a/plugins/mesh_surface/scripts/PreMeshingFunctions.py +++ b/plugins/mesh_surface/scripts/PreMeshingFunctions.py @@ -39,10 +39,11 @@ from StandardModules import * from PyQt4.QtGui import * from export_geo import * +import pdb +#import export_geo -class PreMesh(DefineDomain): - +class PreMesh(DefineDomain, geometry_writer): """ Once the user has selected something from the drop-downs and clicked OK these functions retrieve the layer names as well as the source files of the layers. @@ -94,7 +95,8 @@ def runIdDef(self): self.define_bounds(self.dlg.ui.grpDefID.isChecked()) # Write the Geo. - self.GeoWriter() + pdb.set_trace() + geometry_writer.GeoWriter() """ Retrieve the information from the drop-down boxes. diff --git a/tests/model_answers/test_annulus_Compound_lines_coarse_metric/test_annulus_Compound_lines_coarse_metric.geo b/tests/model_answers/test_annulus_Compound_lines_coarse_metric/test_annulus_Compound_lines_coarse_metric.geo index 76c2b00..98e46e2 100644 --- a/tests/model_answers/test_annulus_Compound_lines_coarse_metric/test_annulus_Compound_lines_coarse_metric.geo +++ b/tests/model_answers/test_annulus_Compound_lines_coarse_metric/test_annulus_Compound_lines_coarse_metric.geo @@ -680,6 +680,5 @@ Physical Surface(0) = {1}; Mesh.RemeshAlgorithm=1; Field[1] = Structured; -Field[1].FileName = "/home/mg2111/QGIS-Meshing/tests/support_files/gaussian_bump_coarse.fld"; Field[1].TextFormat = 1; Background Field = 1; diff --git a/tests/model_answers/test_annulus_Compound_lines_medium_metric/test_annulus_Compound_lines_medium_metric.geo b/tests/model_answers/test_annulus_Compound_lines_medium_metric/test_annulus_Compound_lines_medium_metric.geo index dc06598..98e46e2 100644 --- a/tests/model_answers/test_annulus_Compound_lines_medium_metric/test_annulus_Compound_lines_medium_metric.geo +++ b/tests/model_answers/test_annulus_Compound_lines_medium_metric/test_annulus_Compound_lines_medium_metric.geo @@ -680,6 +680,5 @@ Physical Surface(0) = {1}; Mesh.RemeshAlgorithm=1; Field[1] = Structured; -Field[1].FileName = "/home/mg2111/QGIS-Meshing/tests/support_files/gaussian_bump_medium.fld"; Field[1].TextFormat = 1; Background Field = 1; diff --git a/tests/model_answers/test_annulus_Compound_lines_metric/test_annulus_Compound_lines_metric.geo b/tests/model_answers/test_annulus_Compound_lines_metric/test_annulus_Compound_lines_metric.geo index 37a621e..98e46e2 100644 --- a/tests/model_answers/test_annulus_Compound_lines_metric/test_annulus_Compound_lines_metric.geo +++ b/tests/model_answers/test_annulus_Compound_lines_metric/test_annulus_Compound_lines_metric.geo @@ -680,6 +680,5 @@ Physical Surface(0) = {1}; Mesh.RemeshAlgorithm=1; Field[1] = Structured; -Field[1].FileName = "/home/mg2111/QGIS-Meshing/tests/support_files/gaussian_bump.fld"; Field[1].TextFormat = 1; Background Field = 1;