- Timestamp:
- Dec 15, 2008, 4:56:07 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/river2d_integration/River2DMesh_ANUGAMesh.py
r6061 r6077 20 20 print "\nFILES are open ready for conversion....\n" 21 21 22 read pts=023 type=1 24 blank_line_count=022 reading_points = True 23 reading_vertices = False 24 last_point_index = 0 25 25 for line in infid.readlines(): 26 print 'line', line 26 print 'line', line.strip() 27 28 if line.strip() == '': 29 continue 27 30 28 #print 'type = ',type 29 if line.strip() == '': 30 #blank_line_count=blank_line_count+1 31 type=2 # blank line 31 if line.lower().startswith('no more nodes'): 32 reading_vertices = True 33 reading_points = False 32 34 continue 33 34 print 'readpts= %i, Type = %i Blank Line = %i'%(readpts, type, blank_line_count) 35 if readpts==0 and type==1: # Start to read Points 35 36 if line.lower().startswith('no more boundary segments'): 37 break 38 39 if reading_points is True: # Read Points 40 41 # Check that point indices are consecutive 42 s = line[:5] 43 index = int(s.strip()) 44 assert index-1 == last_point_index 45 last_point_index = index 46 47 # Get points 36 48 s = line[9:38] 37 49 fields = s.split(' ') 38 50 x=float(fields[0]) 39 51 y=float(fields[1]) 40 #z=float(fields[3]) 41 outfid1.write('%.3f,%.3f\n' %(x, y)) 42 elif readpts==1 and blank_line_count==2: # Start to read Vertices 52 #z=float(fields[3]) # TODO: Get elevation data a separate list 53 outfid1.write('%.3f, %.3f\n' % (x, y)) 54 55 elif reading_vertices is True: # Read Vertices 43 56 fields = line.split(' ') 44 pt1=int(line[1:6])45 pt2=int(line[10:16])46 pt3=int(line[20:26])47 outfid2.write('%i,%i,%i\n' %(pt1, pt2,pt3))48 57 49 if line=='no more boundary segments.': 50 print 'no more Vertices ALL DONE!!!!' 51 type=5 # End of File can stop processing 52 if line=='no more nodes.': 53 print 'no more nodes!!!!' 54 type=3 # End of Points 55 readpts=1 56 if line.strip() == '': 57 blank_line_count=blank_line_count+1 58 type=4 # blank line 59 readpts=1 58 # Create indices and make them start from 0 59 pt1=int(line[1:6]) - 1 60 pt2=int(line[10:16]) - 1 61 pt3=int(line[20:26]) - 1 62 outfid2.write('%d, %d, %d\n' % (pt1, pt2,pt3)) 63 60 64 61 65 outfid1.close() 62 66 outfid2.close() 63 67 print "\nConversion complete.\n" 64 raw_input("Press ENTER to exit.\n") 68
Note: See TracChangeset
for help on using the changeset viewer.