Changeset 1395
- Timestamp:
- May 16, 2005, 11:22:40 AM (20 years ago)
- Location:
- inundation/ga/storm_surge/pmesh
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pmesh/mesh.py
r1365 r1395 1731 1731 self.regions) 1732 1732 1733 # exportASCIImeshfile 1733 # exportASCIImeshfile - this function is used 1734 1734 def export_mesh_file(self,ofile): 1735 1735 """ … … 1773 1773 raise RuntimeError 1774 1774 numVertAttrib = str(len(Vertices[0].attributes)) 1775 title = numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes]"1775 #title = numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes]" 1776 1776 1777 1777 #Convert the Vertices to pointlist and pointattributelist … … 1788 1788 xya_dict['geo_reference'] = self.geo_reference 1789 1789 1790 load_mesh.loadASCII.export_ xya_file(ofile, xya_dict, title, delimiter = " ")1790 load_mesh.loadASCII.export_points_file(ofile, xya_dict) 1791 1791 1792 1792 … … 2732 2732 def importMeshFromFile(ofile): 2733 2733 """returns a mesh object, made from a .xya/.pts or .tsh/.msh file 2734 Often raises SyntaxError, IOError2734 Often raises IOError,RuntimeError 2735 2735 """ 2736 2736 newmesh = None 2737 if ofile[-4:]== ".xya": 2738 #print "loading " + ofile 2739 try: 2740 dict = load_mesh.loadASCII.load_points_file(ofile, delimiter = ',') 2741 except SyntaxError: 2742 dict = load_mesh.loadASCII.load_points_file(ofile, delimiter = ' ') 2743 #print "dict",dict outline_ 2744 dict['segmentlist'] = [] 2745 dict['segmenttaglist'] = [] 2746 dict['regionlist'] = [] 2747 dict['regionattributelist'] = [] 2748 dict['regionmaxarealist'] = [] 2749 dict['holelist'] = [] 2750 newmesh= Mesh() 2751 newmesh.setMesh(dict) #FIXME use IOOutline2Mesh 2752 counter = newmesh.removeDuplicatedUserVertices() 2753 if (counter >0): 2754 print "%i duplicate vertices removed from dataset" % (counter) 2755 elif ofile[-4:]== ".pts": 2756 #print "loading " + ofile 2757 dict = load_mesh.loadASCII.load_points_file(ofile) 2758 #print "dict",dict 2737 if (ofile[-4:]== ".xya" or ofile[-4:]== ".pts"): 2738 dict = load_mesh.loadASCII.import_points_file(ofile) 2759 2739 dict['points'] = dict['pointlist'] 2760 2740 dict['outline_segments'] = [] … … 2765 2745 dict['holes'] = [] 2766 2746 newmesh= Mesh(geo_reference = dict['geo_reference']) 2767 newmesh.IOOutline2Mesh(dict) #FIXME use IOOutline2Mesh2747 newmesh.IOOutline2Mesh(dict) 2768 2748 counter = newmesh.removeDuplicatedUserVertices() 2769 2749 if (counter >0): 2770 print "%i duplicate vertices removed from dataset" % (counter) 2750 print "%i duplicate vertices removed from dataset" % (counter) 2771 2751 elif (ofile[-4:]== ".tsh" or ofile[-4:]== ".msh"): 2772 dict = load_mesh.loadASCII.import_ triangulation(ofile)2752 dict = load_mesh.loadASCII.import_mesh_file(ofile) 2773 2753 #print "********" 2774 2754 #print "zq mesh.dict",dict -
inundation/ga/storm_surge/pmesh/pmesh.py
r1228 r1395 1373 1373 self.ResizeToFit() 1374 1374 1375 except SyntaxError:1376 #this is assuming that the SyntaxError is thrown in1377 #loadxyafile1378 showerror('File error',1379 ofile + ' is not in the correct format.')1380 1375 except IOError: 1381 1376 #!!! this error type can not be thrown? 1382 1377 showerror('File error', 1383 'file ' + ofile + ' could not be found.')1378 'file ' + ofile + ' could not be loaded.') 1384 1379 1385 1380 except RuntimeError: … … 1450 1445 1451 1446 if ofile: 1447 # .tsh is the default file format 1452 1448 if (ofile[-4:] == ".tsh" or ofile[-4:] == ".msh"): 1453 1449 self.currentFilePathName = ofile -
inundation/ga/storm_surge/pmesh/test_mesh.py
r1362 r1395 894 894 holes = [h1]) 895 895 896 fileName = tempfile.mktemp(". txt")896 fileName = tempfile.mktemp(".xya") 897 897 m.exportxyafile(fileName) 898 898 file = open(fileName)
Note: See TracChangeset
for help on using the changeset viewer.