Ignore:
Timestamp:
Sep 28, 2004, 4:18:34 PM (21 years ago)
Author:
duncan
Message:

added test for fit_to_mesh_file, removed bugs from loadASCII.

File:
1 edited

Legend:

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

    r342 r346  
    4242    #for fragment in fragments:
    4343    #    print fragment
    44     NumOfVertices = fragments[0]
    45     NumOfVertAttributes = fragments[1]
     44    if fragments ==[]:
     45        NumOfVertices = 0
     46        NumOfVertAttributes = 0
     47    else:
     48        NumOfVertices = fragments[0]
     49        NumOfVertAttributes = fragments[1]
    4650    points = []
    4751    pointattributes = []
     
    140144
    141145def read_mesh(fd):
     146    """
     147    Note, if a file has no mesh info, it can still be read - the meshdic
     148    returned will be 'empty'.
     149    """
    142150    delimiter = " " # warning: split() calls are using default whitespace
    143151   
     
    147155    fragments = line.split()
    148156    #for fragment in fragments:
    149     #    print fragment
    150     NumOfVertices = fragments[0]
    151     NumOfVertAttributes = fragments[1]
     157    if fragments ==[]:
     158        NumOfVertices = 0
     159        NumOfVertAttributes = 0
     160    else:
     161        NumOfVertices = fragments[0]
     162        NumOfVertAttributes = fragments[1]
    152163    points = []
    153164    pointattributes = []
     
    173184    #for fragment in fragments:
    174185    #    print fragment
    175     NumOfSegments = fragments[0]
     186    if fragments ==[]:
     187        NumOfSegments = 0
     188    else:
     189        NumOfSegments = fragments[0]
    176190    segments = []
    177191    segmentmarkers = []
     
    199213    #for fragment in fragments:
    200214    #    print fragment
    201     numOfHoles = fragments[0]
     215    if fragments ==[]:
     216        numOfHoles = 0
     217    else:
     218        numOfHoles = fragments[0]
    202219    holes = []
    203220    for index in range(int(numOfHoles)):       
     
    216233    #for fragment in fragments:
    217234    #    print fragment
    218     numOfRegions = fragments[0]
     235    if fragments ==[]:
     236        numOfRegions = 0
     237    else:
     238        numOfRegions = fragments[0]
    219239    regions = []
    220240    regionattributes = []
     
    321341                else:
    322342                    neighbors +=  "-1 "
    323                
     343        if triangles_attributes[index] == ['']:
     344            att = ""
     345        else:
     346            att = str(triangles_attributes[index])
    324347        fd.write(str(index) + " "
    325348                 + str(tri[0]) + " "
     
    327350                 + str(tri[2]) + " "
    328351                 + neighbors + " "
    329                  + str(triangles_attributes[index]) + "\n")
     352                 + att + "\n")
    330353           
    331354    #One line:  <# of segments>
Note: See TracChangeset for help on using the changeset viewer.