diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2025-09-04 04:20:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-04 04:20:54 +0200 |
| commit | e2e14bb0a4e2d403965f644429e930684b718169 (patch) | |
| tree | 5372b19b80591b17d981d07953f644df183ee911 /lib/utils/clamp_path.py | |
| parent | 91f90b163823dfd02074600f8405f4a695ac28a3 (diff) | |
fix meander clamp (2) (#3945)
Diffstat (limited to 'lib/utils/clamp_path.py')
| -rw-r--r-- | lib/utils/clamp_path.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/utils/clamp_path.py b/lib/utils/clamp_path.py index c1f6fe25..415277b4 100644 --- a/lib/utils/clamp_path.py +++ b/lib/utils/clamp_path.py @@ -88,7 +88,7 @@ def clamp_fully_external_path(path, polygon): return adjust_line_end(shorter, start) -def clamp_path_to_polygon(path, polygon): +def clamp_path_to_polygon(path, polygon, check_distance=True): """Constrain a path to a Polygon. The path is expected to have at least some part inside the Polygon. @@ -131,7 +131,10 @@ def clamp_path_to_polygon(path, polygon): # The second part of this or condition checks whether part of the # path was removed by difference() above, because it coincided # with part of the shape border. - if not was_inside and last_point_inside is not None: + if last_point_inside is not None and ( + not was_inside or + (check_distance and last_point_inside.distance(start) > 0.01) + ): # We traveled outside or on the border of the shape for # a while. In either case, we need to add a path along the # border between the exiting and entering points. |
