Reads a triangle .node file. First line is nPts 2 0 0 followed by nPts lines having id X Y \d (the last digit is ignored) Returns a list of (x,y) pairs. The id is ignored because entries appear in consecutive order starting at 1. Thus points[26] has x,y f
(File)
| 40 | print(f'wrote {File}') |
| 41 | # }}} |
| 42 | def load_node_file(File): # {{{ |
| 43 | """ |
| 44 | Reads a triangle .node file. First line is |
| 45 | nPts 2 0 0 |
| 46 | followed by nPts lines having |
| 47 | id X Y \d |
| 48 | (the last digit is ignored) |
| 49 | Returns a list of (x,y) pairs. |
| 50 | The id is ignored because entries appear |
| 51 | in consecutive order starting at 1. |
| 52 | Thus points[26] has x,y for id=27. |
| 53 | """ |
| 54 | if not os.path.isfile(File): |
| 55 | print(f'load_node_file({File}): no such file') |
| 56 | return None |
| 57 | points = [] |
| 58 | with open(File, 'r') as fh: |
| 59 | L = fh.readline() # header line; don't need it |
| 60 | for L in fh: |
| 61 | L = L.rstrip().lstrip() |
| 62 | if not L: continue # blank line |
| 63 | if L.startswith('#'): continue # comment line |
| 64 | words = L.split() |
| 65 | if words[0].startswith('#'): continue |
| 66 | x, y = float(words[1]), float(words[2]) |
| 67 | points.append( (x,y) ) |
| 68 | return np.array(points) |
| 69 | # }}} |
| 70 | def load_ele_file(File, # {{{ |
| 71 | Rod=False): |