Changeset 355
- Timestamp:
- Oct 5, 2004, 11:52:23 AM (20 years ago)
- Location:
- inundation/ga/storm_surge/pmesh
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py
r350 r355 453 453 return xya_dict 454 454 455 456 def export_xya_file( file_name, xya_dict, title): 457 """ 458 export a file, ofile, with the format 459 460 First line: Title variable 461 Following lines: <vertex #> <x> <y> [attributes] 462 463 file_name - the name of the new file 464 xya_dict - point and point attribute info in a dictionary 465 title - info to write in the first line 466 """ 467 #FIXME, move the test for this from meshharness to loadasciiharness 468 points = xya_dict['pointlist'] 469 pointattributes = xya_dict['pointattributelist'] 470 471 fd = open(file_name,'w') 472 473 fd.write(title+"\n") 474 #<vertex #> <x> <y> [attributes] 475 for vert, vertatts in map(None, points, pointattributes): 476 attlist = "" 477 for att in vertatts: 478 attlist = attlist + str(att)+" " 479 attlist.strip() 480 fd.write( str(vert[0]) + " " 481 + str(vert[1]) + " " 482 + attlist + "\n") 483 fd.close() 484 455 485 if __name__ == "__main__": 456 486 m = import_mesh("tee.txt") -
inundation/ga/storm_surge/pmesh/mesh.py
r349 r355 1528 1528 Following lines: <vertex #> <x> <y> [attributes] 1529 1529 """ 1530 1530 #load_mesh.loadASCII 1531 1531 1532 if self.meshVertices == []: 1532 1533 Vertices = self.userVertices … … 1538 1539 if Vertices == []: 1539 1540 raise RuntimeError 1540 fd = open(ofile,'w')1541 1541 numVertAttrib = str(len(Vertices[0].attributes)) 1542 fd.write(numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes]" + "\n") 1543 #Vertices = self.userVertices + self.meshVertices 1544 #[Vertices, counter]= self.removeDuplicatedVertices(Vertices) 1545 1546 #<vertex #> <x> <y> [attributes] 1542 title = numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes]" 1543 1544 #Convert the Vertices to pointlist and pointattributelist 1545 xya_dict = {} 1546 pointattributes = [] 1547 points = [] 1548 1547 1549 for vert in Vertices: 1548 attlist = "" 1549 for att in vert.attributes: 1550 attlist = attlist + str(att)+" " 1551 attlist.strip() 1552 fd.write( str(vert.x) + " " 1553 + str(vert.y) + " " 1554 + attlist + "\n") 1555 fd.close() 1550 points.append([vert.x,vert.y]) 1551 pointattributes.append(vert.attributes) 1552 1553 xya_dict['pointlist'] = points 1554 xya_dict['pointattributelist'] = pointattributes 1555 1556 load_mesh.loadASCII.export_xya_file(ofile, xya_dict, title) 1556 1557 1557 1558 -
inundation/ga/storm_surge/pmesh/meshHarness.py
r349 r355 721 721 lFile = file.read().split('\n') 722 722 file.close() 723 724 #print "**********************" 725 #print lFile 726 #print "**********************" 727 723 728 os.remove(fileName) 724 729 self.failUnless(lFile[0] == "5 0 # <vertex #> <x> <y> [attributes]" and
Note: See TracChangeset
for help on using the changeset viewer.