Parse [VERTICES]
This commit is contained in:
@@ -78,3 +78,29 @@ def delete_vertex(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
result.redo_cs |= g_delete_prefix
|
||||
result.undo_cs |= g_add_prefix
|
||||
return execute_command(name, result)
|
||||
|
||||
|
||||
def inp_in_vertex(section: list[str]) -> ChangeSet:
|
||||
vertices: dict[str, list[dict[str, float]]] = {}
|
||||
|
||||
for s in section:
|
||||
tokens = s.split()
|
||||
if tokens[0] not in vertices:
|
||||
vertices[tokens[0]] = []
|
||||
vertices[tokens[0]].append({'x': float(tokens[1]), 'y': float(tokens[2])})
|
||||
|
||||
cs = ChangeSet()
|
||||
for link, coords in vertices.items():
|
||||
cs.append(g_add_prefix | {'type': 'vertex', 'link' : link, 'coords' : coords})
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_vertex(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, f"select * from vertices order by _order")
|
||||
for obj in objs:
|
||||
link = obj['link']
|
||||
x = obj['x']
|
||||
y = obj['y']
|
||||
lines.append(f"{link} {x} {y}")
|
||||
return lines
|
||||
|
||||
Reference in New Issue
Block a user