Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrating with gui #32

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/


Expand Down
44 changes: 22 additions & 22 deletions plugins/mesh_surface/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "............................................."

Expand All @@ -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 "............................................."

Expand All @@ -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 "............................................."
Expand All @@ -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")



Expand All @@ -122,21 +122,21 @@

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"

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'
Expand Down
58 changes: 54 additions & 4 deletions plugins/mesh_surface/mesh_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions plugins/mesh_surface/scripts/PreMeshingFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;