Changeset 1401 for inundation/ga/storm_surge/pmesh/mesh.py
- Timestamp:
- May 16, 2005, 4:23:25 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pmesh/mesh.py
r1395 r1401 545 545 for element in dic_mesh.keys(): 546 546 dic[element] = dic_mesh[element] 547 547 for element in dic.keys(): 548 dic[element].sort() 549 548 550 # A dic for the exported/imported m 549 551 dic_other = other.Mesh2triangList() … … 551 553 for element in dic_mesh.keys(): 552 554 dic_other[element] = dic_mesh[element] 555 for element in dic.keys(): 556 dic_other[element].sort() 553 557 554 558 #print "dsg************************8" … … 569 573 PreCondition: maxArea is a double 570 574 """ 571 print "mode ",mode575 #print "mode ",mode 572 576 if mode == None: 573 577 self.mode = "" … … 736 740 Precondition: Each vertex has a dupindex, which is the list 737 741 index. 742 743 Note: this removes vertices that have the same x,y values, 744 not duplicate instances in the Vertices list. 738 745 """ 739 746 remove = [] … … 1312 1319 expand_pinch=expand_pinch) 1313 1320 boundary_segs = self.shape.get_boundary() 1314 print "boundary_segs",boundary_segs1321 #print "boundary_segs",boundary_segs 1315 1322 segs2delete = self.alphaUserSegments 1316 1323 … … 1622 1629 #Most probably, the Tkinter module is not available. 1623 1630 #""" 1624 # FIXME let's not use this function,1625 # use export _mesh_file instead1626 def export_triangulation_file(self,ofile):1627 """1628 export a file, ofile, with the format1629 1630 First line: <# of vertices> <# of attributes>1631 Following lines: <vertex #> <x> <y> [attributes]1632 One line: <vertex attribute titles>1633 One line: <# of triangles>1634 Following lines: <triangle #> <vertex #> <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region]1635 One line: <# of segments>1636 Following lines: <segment #> <vertex #> <vertex #> [boundary tag]1637 """1638 gen_dict = self.Mesh2IODict()1639 if (ofile[-4:] == ".tsh"):1640 fd = open(ofile,'w')1641 load_mesh.loadASCII.write_ASCII_triangulation(fd,gen_dict)1642 self.writeASCIImesh(fd,1643 self.userVertices,1644 self.getUserSegments(),1645 self.holes,1646 self.regions)1647 fd.close()1648 elif (ofile[-4:] == ".msh"):1649 #print "mesh gen_dict",gen_dict1650 load_mesh.loadASCII.write_msh_file(ofile, gen_dict)1651 1631 1652 # self.writeASCIImesh(fd, does anything use this?1653 1654 #FIXME this function has a bug..1655 def exportASCIIsegmentoutlinefile(self,ofile):1656 """1657 export a file, ofile, with no triangulation and only vertices connected to segments.1658 """1659 fd = open(ofile,'w')1660 meshDict = {}1661 1662 meshDict['vertices'] = []1663 meshDict['vertex_attributes'] = []1664 meshDict['segments'] = []1665 meshDict['segment_tags'] = []1666 meshDict['triangles'] = []1667 meshDict['triangle_tags'] = []1668 meshDict['triangle_neighbors'] = []1669 1670 load_mesh.loadASCII.write_ASCII_triangulation(fd,meshDict)1671 self.writeASCIIsegmentoutline(fd,1672 self.userVertices,1673 self.getUserSegments(),1674 self.holes,1675 self.regions)1676 fd.close()1677 1632 1678 1633 def exportASCIIobj(self,ofile): … … 1706 1661 + str(tri.vertices[1].index1) + " " 1707 1662 + str(tri.vertices[2].index1) + "\n") 1708 1709 #FIXME I think this has a bug... 1710 def writeASCIIsegmentoutline(self, 1711 fd, 1712 userVertices, 1713 userSegments, 1714 holes, 1715 regions): 1716 """Write the user mesh info, only with vertices that are connected to segs 1717 """ 1718 verts = [] 1719 #dupindex = 0 1720 for seg in self.userSegments: 1721 verts.append(seg.vertices[0]) 1722 verts.append(seg.vertices[1]) 1723 print 'verts>',verts 1724 1725 verts, count = self.removeDuplicatedVertices(verts) 1726 print 'verts no dups>',verts 1727 self.writeASCIImesh(fd, 1728 verts, 1729 self.getUserSegments(), 1730 self.holes, 1731 self.regions) 1663 1664 def exportASCIIsegmentoutlinefile(self,ofile): 1665 """Write the boundary user mesh info, eg 1666 vertices that are connected to segments, 1667 segments 1668 """ 1669 1670 verts = {} 1671 for seg in self.getUserSegments(): 1672 verts[seg.vertices[0]] = seg.vertices[0] 1673 verts[seg.vertices[1]] = seg.vertices[1] 1674 #print "verts.values()",verts.values() 1675 meshDict = self.Mesh2IOOutlineDict(userVertices=verts.values()) 1676 load_mesh.loadASCII.export_mesh_file(ofile,meshDict) 1732 1677 1733 1678 # exportASCIImeshfile - this function is used … … 1740 1685 load_mesh.loadASCII.export_mesh_file(ofile,dict) 1741 1686 1742 # is this function obsolete? 1743 def writeASCIImesh(self, 1744 fd, 1745 userVertices, 1746 userSegments, 1747 holes, 1748 regions): 1749 1750 #print "mesh.writeASCIImesh*********" 1751 #print "dict",dict 1752 #print "mesh*********" 1753 load_mesh.loadASCII.write_ASCII_outline(fd, dict) 1754 1755 #FIXME the title is wrong, need more comments 1756 def exportxyafile(self,ofile): 1757 """ 1758 export a file, ofile, with the format 1759 1760 First line: <# of vertices> <# of attributes> 1761 Following lines: <vertex #> <x> <y> [attributes] 1762 """ 1763 #load_mesh.loadASCII 1764 #FIXME, this should be a mesh2io method 1765 if self.meshVertices == []: 1766 Vertices = self.userVertices 1687 def exportPointsFile(self,ofile): 1688 """ 1689 export a points (.xya or .pts) file, ofile. 1690 1691 """ 1692 1693 mesh_dict = self.Mesh2IODict() 1694 point_dict = {} 1695 point_dict['attributelist'] = {} #this will need to be expanded.. 1696 # if attributes are brought back in. 1697 point_dict['geo_reference'] = self.geo_reference 1698 if mesh_dict['vertices'] == []: 1699 point_dict['pointlist'] = mesh_dict['points'] 1767 1700 else: 1768 Vertices = self.meshVertices 1769 1770 numVert = str(len(Vertices)) 1771 1772 if Vertices == []: 1773 raise RuntimeError 1774 numVertAttrib = str(len(Vertices[0].attributes)) 1775 #title = numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes]" 1776 1777 #Convert the Vertices to pointlist and pointattributelist 1778 xya_dict = {} 1779 pointattributes = [] 1780 points = [] 1781 1782 for vert in Vertices: 1783 points.append([vert.x,vert.y]) 1784 pointattributes.append(vert.attributes) 1785 1786 xya_dict['pointlist'] = points 1787 xya_dict['pointattributelist'] = pointattributes 1788 xya_dict['geo_reference'] = self.geo_reference 1789 1790 load_mesh.loadASCII.export_points_file(ofile, xya_dict) 1701 point_dict['pointlist'] = mesh_dict['vertices'] 1702 1703 load_mesh.loadASCII.export_points_file(ofile,point_dict) 1791 1704 1792 1705 … … 1844 1757 vertices=[] 1845 1758 vertex_attributes=[] 1846 1847 1759 1848 1760 self.maxVertexIndex=0 … … 1963 1875 #print "*(*(" 1964 1876 return meshDict 1965 1966 1877 1967 1878 def IOTriangulation2Mesh(self, genDict): … … 2010 1921 self.meshTriangles[index].setAttribute("") 2011 1922 else: 2012 # Note, is the first attribute always the region att?2013 # haven't confirmed this2014 #Peter - I think so (from manuel)2015 #...the first such value is assumed to be a regional attribute...2016 1923 self.meshTriangles[index].setAttribute(att) 2017 1924 index += 1
Note: See TracChangeset
for help on using the changeset viewer.