- Timestamp:
- Sep 28, 2004, 4:18:34 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/load_mesh/loadASCII.py
r342 r346 42 42 #for fragment in fragments: 43 43 # 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] 46 50 points = [] 47 51 pointattributes = [] … … 140 144 141 145 def 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 """ 142 150 delimiter = " " # warning: split() calls are using default whitespace 143 151 … … 147 155 fragments = line.split() 148 156 #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] 152 163 points = [] 153 164 pointattributes = [] … … 173 184 #for fragment in fragments: 174 185 # print fragment 175 NumOfSegments = fragments[0] 186 if fragments ==[]: 187 NumOfSegments = 0 188 else: 189 NumOfSegments = fragments[0] 176 190 segments = [] 177 191 segmentmarkers = [] … … 199 213 #for fragment in fragments: 200 214 # print fragment 201 numOfHoles = fragments[0] 215 if fragments ==[]: 216 numOfHoles = 0 217 else: 218 numOfHoles = fragments[0] 202 219 holes = [] 203 220 for index in range(int(numOfHoles)): … … 216 233 #for fragment in fragments: 217 234 # print fragment 218 numOfRegions = fragments[0] 235 if fragments ==[]: 236 numOfRegions = 0 237 else: 238 numOfRegions = fragments[0] 219 239 regions = [] 220 240 regionattributes = [] … … 321 341 else: 322 342 neighbors += "-1 " 323 343 if triangles_attributes[index] == ['']: 344 att = "" 345 else: 346 att = str(triangles_attributes[index]) 324 347 fd.write(str(index) + " " 325 348 + str(tri[0]) + " " … … 327 350 + str(tri[2]) + " " 328 351 + neighbors + " " 329 + str(triangles_attributes[index])+ "\n")352 + att + "\n") 330 353 331 354 #One line: <# of segments>
Note: See TracChangeset
for help on using the changeset viewer.