Changeset 721


Ignore:
Timestamp:
Dec 23, 2004, 11:14:48 AM (20 years ago)
Author:
duncan
Message:

do changes to .tsh comment lines, like Chris wanted

Location:
inundation/ga/storm_surge/pmesh
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py

    r719 r721  
    336336    else:
    337337        numVertAttrib = str(len(vertices_attributes[0]))
    338     fd.write(numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes] ...Triangulation Vertices..." + "\n")
     338    fd.write(numVert + " " + numVertAttrib + " # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Triangulation Vertices..." + "\n")
    339339
    340340    #<vertex #> <x> <y> [attributes]   
     
    358358    #<# of triangles>
    359359    n = len(triangles)
    360     fd.write(str(n) + " # <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." + "\n")
     360    fd.write(str(n) + " # <# of triangles>, next lines <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." + "\n")
    361361       
    362362    # <triangle #> <vertex #>  <vertex #> <vertex #> <neigbouring triangle #> <neigbouring triangle #> <neigbouring triangle #> [attribute of region]
     
    391391    #One line:  <# of segments>
    392392    fd.write(str(len(segments)) +
    393              " # <segment #> <vertex #>  <vertex #> [boundary marker] ...Triangulation Segments..." + "\n")
     393             " # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary marker] ...Triangulation Segments..." + "\n")
    394394       
    395395    #Following lines:  <segment #> <vertex #>  <vertex #> [boundary marker]
  • inundation/ga/storm_surge/pmesh/mesh.py

    r719 r721  
    15141514        else:
    15151515            numVertAttrib = str(len(userVertices[0].attributes))
    1516         fd.write(numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes] ...Mesh Vertices..." + "\n")
     1516        fd.write(numVert + " " + numVertAttrib + " # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Mesh Vertices..." + "\n")
    15171517       
    15181518        # <x> <y> [attributes]
     
    15321532        #One line:  <# of segments>
    15331533        fd.write(str(len(userSegments)) +
    1534                  " # <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments..." + "\n")
     1534                 " # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments..." + "\n")
    15351535       
    15361536        #Following lines:  <vertex #>  <vertex #> [boundary marker]
     
    15451545        #One line:  <# of holes>
    15461546        fd.write(str(len(holes)) +
    1547                  " # <Hole #> <x> <y> ...Mesh Holes..." + "\n")   
     1547                 " # <# of holes>, next lines <Hole #> <x> <y> ...Mesh Holes..." + "\n")   
    15481548        # <x> <y>
    15491549        index = 0
     
    15561556        #One line:  <# of regions>
    15571557        fd.write(str(len(regions)) +
    1558                  " # <Region #> <x> <y> <tag>...Mesh Regions..." + "\n")   
     1558                 " # <# of regions>, next lines <Region #> <x> <y> <tag>...Mesh Regions..." + "\n")   
    15591559        # <index> <x> <y> <tag>
    15601560        index = 0
     
    15711571        #One line:  <# of regions>
    15721572        fd.write(str(len(regions)) +
    1573                  " # <Region #> [Max Area] ...Mesh Regions..." + "\n")
     1573                 " # <# of regions>, next lines <Region #> [Max Area] ...Mesh Regions..." + "\n")
    15741574        for r in regions:
    15751575            area = r.getMaxArea()
  • inundation/ga/storm_surge/pmesh/meshHarness.py

    r719 r721  
    490490        #print "@^@^"
    491491
    492         self.failUnless(lFile[0] == "5 0 # <vertex #> <x> <y> [attributes] ...Triangulation Vertices..."
     492        # no need to check the title again
     493        #self.failUnless(lFile[0] == "5 0 # <vertex #> <x> <y> [attributes] ...Triangulation Vertices..."
     494          #              ,'Ascii file is wrong, vertex title')
     495        self.failUnless(lFile[1] == "0 0.0 0.0 " and #1.1 " and
     496                        lFile[2] == "1 0.0 4.0 " and #1.2 " and
     497                        lFile[3] == "2 4.0 0.0 " and #1.3 " and
     498                        lFile[4] == "3 1.0 1.0 " and #1.4 " and
     499                        lFile[5] == "4 2.0 2.0 "  #1.25 "
     500                        ,
     501                        'Ascii file is wrong, vertex')
     502       
     503        #self.failUnless(lFile[6] == "# attribute column titles ...Triangulation Vertex Titles..."
     504          #              ,'Ascii file is wrong, attribute column title')
     505        self.failUnless(lFile[8] == "0 3 2 4 -1 2 3  " and
     506                        lFile[9] == "1 1 0 3 3 2 -1  " and
     507                        lFile[10] == "2 3 4 1 -1 1 0  " and
     508                        lFile[11] == "3 2 3 0 1 -1 0  "
     509                        ,
     510                        'Ascii file is wrong, triangle')
     511
     512        self.failUnless( lFile[13] == "0 0 1 exterior" and
     513                        lFile[14] == "1 1 4 exterior" and
     514                        lFile[15] == "2 2 0 exterior" and
     515                        lFile[16] == "3 0 3 " and
     516                        lFile[17] == "4 4 2 exterior" ,
     517                        'Ascii file is wrong, segment')
     518       
     519       # self.failUnless(lFile[18] == '4 0 # <vertex #> <x> <y> [attributes] ...Mesh Vertices...',
     520        #                'Ascii file is wrong, Mesh Vertices Title')
     521       
     522        self.failUnless(lFile[19] == '0 0.0 0.0 ' and #1.1 ' and
     523                        lFile[20] == '1 0.0 4.0 ' and #1.2 ' and
     524                        lFile[21] == '2 4.0 0.0 ' and #1.3 ' and
     525                        lFile[22] == '3 1.0 1.0 ' #1.4 '
     526                        ,
     527                        'Ascii file is wrong, Mesh Vertices II')
     528       
     529        self.failUnless(lFile[24] == '0 0 1 ' and
     530                        lFile[25] == '1 1 2 ' and
     531                        lFile[26] == '2 0 2 ' and
     532                        lFile[27] == '3 0 3 '
     533                        ,'Ascii file is wrong, Mesh Segments')       
     534
     535 
     536    def test_ascii_file(self):
     537   
     538        a = Vertex (0.0, 0.0) #, attributes = [1.1])
     539        d = Vertex (0.0, 4.0) #, attributes = [1.2])
     540        f = Vertex (4.0,0.0) #, attributes = [1.3])
     541        e = Vertex (1.0,1.0) #, attributes = [1.4])
     542   
     543        s1 = Segment(a,d)
     544        s2 = Segment(d,f)
     545        s3 = Segment(a,f)
     546        s4 = Segment(a,e)
     547     
     548        m = Mesh(userVertices=[a,d,f,e], userSegments=[s1,s2,s3,s4])
     549
     550        m.generateMesh("QApz", maxArea = 2.1 )
     551
     552        seg = m.getMeshSegments()
     553       
     554        fileName = tempfile.mktemp(".txt")
     555        m.exportASCIItrianglulationfile(fileName)
     556        file = open(fileName)
     557        lFile = file.read().split('\n')
     558        file.close()
     559        os.remove(fileName)
     560       
     561        print "@^@^"
     562        for l in lFile:
     563            print l,"<"
     564        print "@^@^"
     565        self.failUnless(lFile[0] == "5 0 # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Triangulation Vertices..."
    493566                        ,
    494567                        'Ascii file is wrong, vertex title')
     
    504577                        ,
    505578                        'Ascii file is wrong, attribute column title')
    506         self.failUnless(lFile[7] == "4 # <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." and
     579        self.failUnless(lFile[7] == "4 # <# of triangles>, next lines <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." and
    507580                        lFile[8] == "0 3 2 4 -1 2 3  " and
    508581                        lFile[9] == "1 1 0 3 3 2 -1  " and
     
    512585                        'Ascii file is wrong, triangle')
    513586
    514         self.failUnless(lFile[12] == "5 # <segment #> <vertex #>  <vertex #> [boundary marker] ...Triangulation Segments..." and
     587        self.failUnless(lFile[12] == "5 # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary marker] ...Triangulation Segments..." and
    515588                        lFile[13] == "0 0 1 exterior" and
    516589                        lFile[14] == "1 1 4 exterior" and
     
    520593                        'Ascii file is wrong, segment')
    521594       
    522         self.failUnless(lFile[18] == '4 0 # <vertex #> <x> <y> [attributes] ...Mesh Vertices...',
     595        self.failUnless(lFile[18] == '4 0 # <# of verts> <# of vert attributes>, next lines <vertex #> <x> <y> [attributes] ...Mesh Vertices...',
    523596                        'Ascii file is wrong, Mesh Vertices Title')
    524597       
     
    530603                        'Ascii file is wrong, Mesh Vertices II')
    531604       
    532         self.failUnless(lFile[23] == '4 # <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments...' and
     605        self.failUnless(lFile[23] == '4 # <# of segments>, next lines <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments...' and
    533606                        lFile[24] == '0 0 1 ' and
    534607                        lFile[25] == '1 1 2 ' and
    535608                        lFile[26] == '2 0 2 ' and
    536609                        lFile[27] == '3 0 3 ' and
    537                         lFile[28] == '0 # <Hole #> <x> <y> ...Mesh Holes...' and
    538                         lFile[29] == '0 # <Region #> <x> <y> <tag>...Mesh Regions...'
    539                         ,
    540                         'Ascii file is wrong, Mesh Segments')       
    541 
    542  
    543     def test_ascii_file(self):
    544    
    545         a = Vertex (0.0, 0.0) #, attributes = [1.1])
    546         d = Vertex (0.0, 4.0) #, attributes = [1.2])
    547         f = Vertex (4.0,0.0) #, attributes = [1.3])
    548         e = Vertex (1.0,1.0) #, attributes = [1.4])
    549    
    550         s1 = Segment(a,d)
    551         s2 = Segment(d,f)
    552         s3 = Segment(a,f)
    553         s4 = Segment(a,e)
    554      
    555         m = Mesh(userVertices=[a,d,f,e], userSegments=[s1,s2,s3,s4])
    556 
    557         m.generateMesh("QApz", maxArea = 2.1 )
    558 
    559         seg = m.getMeshSegments()
    560        
    561         fileName = tempfile.mktemp(".txt")
    562         m.exportASCIItrianglulationfile(fileName)
    563         file = open(fileName)
    564         lFile = file.read().split('\n')
    565         file.close()
    566         os.remove(fileName)
    567        
    568         #print "@^@^"
    569         #for l in lFile:
    570         #    print l,"<"
    571         #print "@^@^"
    572         self.failUnless(lFile[0] == "5 0 # <vertex #> <x> <y> [attributes] ...Triangulation Vertices..."
    573                         ,
    574                         'Ascii file is wrong, vertex title')
    575         self.failUnless(lFile[1] == "0 0.0 0.0 " and #1.1 " and
    576                         lFile[2] == "1 0.0 4.0 " and #1.2 " and
    577                         lFile[3] == "2 4.0 0.0 " and #1.3 " and
    578                         lFile[4] == "3 1.0 1.0 " and #1.4 " and
    579                         lFile[5] == "4 2.0 2.0 "  #1.25 "
    580                         ,
    581                         'Ascii file is wrong, vertex')
    582        
    583         self.failUnless(lFile[6] == "# attribute column titles ...Triangulation Vertex Titles..."
    584                         ,
    585                         'Ascii file is wrong, attribute column title')
    586         self.failUnless(lFile[7] == "4 # <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles..." and
    587                         lFile[8] == "0 3 2 4 -1 2 3  " and
    588                         lFile[9] == "1 1 0 3 3 2 -1  " and
    589                         lFile[10] == "2 3 4 1 -1 1 0  " and
    590                         lFile[11] == "3 2 3 0 1 -1 0  "
    591                         ,
    592                         'Ascii file is wrong, triangle')
    593 
    594         self.failUnless(lFile[12] == "5 # <segment #> <vertex #>  <vertex #> [boundary marker] ...Triangulation Segments..." and
    595                         lFile[13] == "0 0 1 exterior" and
    596                         lFile[14] == "1 1 4 exterior" and
    597                         lFile[15] == "2 2 0 exterior" and
    598                         lFile[16] == "3 0 3 " and
    599                         lFile[17] == "4 4 2 exterior" ,
    600                         'Ascii file is wrong, segment')
    601        
    602         self.failUnless(lFile[18] == '4 0 # <vertex #> <x> <y> [attributes] ...Mesh Vertices...',
    603                         'Ascii file is wrong, Mesh Vertices Title')
    604        
    605         self.failUnless(lFile[19] == '0 0.0 0.0 ' and #1.1 ' and
    606                         lFile[20] == '1 0.0 4.0 ' and #1.2 ' and
    607                         lFile[21] == '2 4.0 0.0 ' and #1.3 ' and
    608                         lFile[22] == '3 1.0 1.0 ' #1.4 '
    609                         ,
    610                         'Ascii file is wrong, Mesh Vertices II')
    611        
    612         self.failUnless(lFile[23] == '4 # <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments...' and
    613                         lFile[24] == '0 0 1 ' and
    614                         lFile[25] == '1 1 2 ' and
    615                         lFile[26] == '2 0 2 ' and
    616                         lFile[27] == '3 0 3 ' and
    617                         lFile[28] == '0 # <Hole #> <x> <y> ...Mesh Holes...' and
    618                         lFile[29] == '0 # <Region #> <x> <y> <tag>...Mesh Regions...'
     610                        lFile[28] == '0 # <# of holes>, next lines <Hole #> <x> <y> ...Mesh Holes...' and
     611                        lFile[29] == '0 # <# of regions>, next lines <Region #> <x> <y> <tag>...Mesh Regions...'
    619612                        ,
    620613                        'Ascii file is wrong, Mesh Segments')       
Note: See TracChangeset for help on using the changeset viewer.