(edges: Iterable[Edge])
| 365 | |
| 366 | |
| 367 | def find_hull(edges: Iterable[Edge]) -> Wire: |
| 368 | |
| 369 | # initialize the hull |
| 370 | rv: Hull = [] |
| 371 | |
| 372 | # split into arcs and points |
| 373 | arcs, points = convert_and_validate(edges) |
| 374 | |
| 375 | # select the starting element |
| 376 | start = select_lowest(arcs, points) |
| 377 | rv.append(start) |
| 378 | |
| 379 | # initialize |
| 380 | entities: List[Entity] = [] |
| 381 | entities.extend(arcs) |
| 382 | entities.extend(points) |
| 383 | |
| 384 | current_e = start |
| 385 | current_angle = 0.0 |
| 386 | finished = False |
| 387 | |
| 388 | # march around |
| 389 | while not finished: |
| 390 | |
| 391 | angles = [] |
| 392 | segments = [] |
| 393 | |
| 394 | for e in entities: |
| 395 | angle, segment = get_angle(current_e, e) |
| 396 | angles.append(angle if angle >= current_angle else inf) |
| 397 | segments.append(segment) |
| 398 | |
| 399 | next_ix = int(argmin(angles)) |
| 400 | current_e, current_angle, finished = update_hull( |
| 401 | current_e, next_ix, entities, angles, segments, rv |
| 402 | ) |
| 403 | |
| 404 | # convert back to Edges and return |
| 405 | return finalize_hull(rv) |
no test coverage detected