Changeset 431


Ignore:
Timestamp:
Oct 20, 2004, 3:15:06 PM (20 years ago)
Author:
duncan
Message:

increased functionality of ungenerate

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

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pmesh/mesh.py

    r420 r431  
    15681568            vert = [float(fragments.pop(0)),float(fragments.pop(0))]
    15691569            points.append(vert)
    1570             ThisVertIndex = len(points)-1
    1571             segment = [PreviousVertIndex,ThisVertIndex]
     1570            thisVertIndex = len(points)-1
     1571            segment = [PreviousVertIndex,thisVertIndex]
    15721572            segments.append(segment)
    1573             PreviousVertIndex = ThisVertIndex
     1573            PreviousVertIndex = thisVertIndex
    15741574            line = fd.readline() #Read the next line
    15751575            i =+ 1
     1576        # If the last and first segments are the same,
    15761577        # Remove the last segment and the last vertex
    15771578        # then add a segment from the second last vert to the 1st vert
    1578         points.pop()
    1579         segments.pop()
    1580         ThisVertIndex = len(points)-1
    1581         segments.append([ThisVertIndex, firstVertIndex])
     1579        thisVertIndex = len(points)-1
     1580        firstVert = points[firstVertIndex]
     1581        thisVert = points[thisVertIndex]
     1582        #print "firstVert",firstVert
     1583        #print "thisVert",thisVert
     1584        if (firstVert[0] == thisVert[0] and firstVert[1] == thisVert[1]):
     1585            points.pop()
     1586            segments.pop()
     1587            thisVertIndex = len(points)-1
     1588            segments.append([thisVertIndex, firstVertIndex])
    15821589       
    15831590        line = fd.readline() # read <# of polynomial> <x> <y> OR END
  • inundation/ga/storm_surge/pmesh/meshHarness.py

    r407 r431  
    593593                        'same_x_y False failed')
    594594
    595     def teszt_import_mesh(self):
     595    def test_import_mesh(self):
    596596       
    597597        a_att = [5.0,2.0]
     
    891891        self.failUnless(m.userSegments[10].marker == tag,
    892892                        'wrong tag.')
     893   
     894    def test_ungenerateFileLoadingII(self):
     895       
     896        fileName = tempfile.mktemp(".txt")
     897        file = open(fileName,"w")
     898        file.write("         1       ??      ??\n\
     899       0.0       0.0\n\
     900       1.0       0.0\n\
     901       1.0       1.0\n\
     902       0.0       1.0\n\
     903       0.0       0.0\n\
     904END\n\
     905         2      ?? ??\n\
     906       10.0       10.0\n\
     907       10.0       20.0\n\
     908       20.0       20.0\n\
     909END\n\
     910END\n")
     911        file.close()
     912       
     913       
     914        a = Vertex (0.0, 0.0) #, attributes = [1.1])
     915        b = Vertex (0.0, 40.0) #, attributes = [1.2])
     916        c = Vertex (40.0,40.0) #, attributes = [1.3])
     917        d = Vertex (40.0,0.0) #, attributes = [1.4])
     918   
     919        s1 = Segment(a,b)
     920        s2 = Segment(b,c)
     921        s3 = Segment(c,d)
     922        s4 = Segment(d,a)
     923     
     924        m = Mesh(userVertices=[a,b,c,d], userSegments=[s1,s2,s3,s4])
     925        dict = importUngenerateFile(fileName)
     926
     927        tag = "DSG"
     928        Segment.set_default_tag(tag)
     929        m.addVertsSegs(dict)
     930
     931        # have to reset this , since it's a class attribute
     932        Segment.set_default_tag("")
     933           
     934        self.failUnless(len(m.userSegments) ==10,
     935                        'Wrong segment list length.')
     936        self.failUnless(len(m.userVertices) == 11,
     937                        'Wrong vertex list length.')
    893938       
    894939#-------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.