@@ -58,21 +58,24 @@ GI.coordinates.(cut_polys)
58
58
[[[5.0, 0.0], [10.0, 0.0], [10.0, 10.0], [5.0, 10.0], [5.0, 0.0]]]
59
59
```
60
60
"""
61
- cut (geom, line, :: Type{T} = Float64) where {T <: AbstractFloat } =
62
- _cut (T, GI. trait (geom), geom, GI. trait (line), line; exact = True ())
61
+ cut (geom, line, :: Type{T} = Float64) where {T <: AbstractFloat } = cut (FosterHormannClipping (), geom, line, T)
62
+ cut (m:: Manifold , geom, line, :: Type{T} = Float64) where {T <: AbstractFloat } = cut (FosterHormannClipping (m), geom, line, T)
63
+
64
+ cut (alg:: FosterHormannClipping{M, A} , geom, line, :: Type{T} = Float64) where {T <: AbstractFloat , M, A} =
65
+ _cut (alg, T, GI. trait (geom), geom, GI. trait (line), line; exact = True ())
63
66
64
67
#= Cut a given polygon by given line. Add polygon holes back into resulting pieces if there
65
68
are any holes. =#
66
- function _cut (:: Type{T} , :: GI.PolygonTrait , poly, :: GI.LineTrait , line; exact) where T
69
+ function _cut (alg :: FosterHormannClipping{M, A} , :: Type{T} , :: GI.PolygonTrait , poly, :: GI.LineTrait , line; exact) where {T, M, A}
67
70
ext_poly = GI. getexterior (poly)
68
- poly_list, intr_list = _build_a_list (T, ext_poly, line; exact)
71
+ poly_list, intr_list = _build_a_list (alg, T, ext_poly, line; exact)
69
72
n_intr_pts = length (intr_list)
70
73
# If an impossible number of intersection points, return original polygon
71
74
if n_intr_pts < 2 || isodd (n_intr_pts)
72
75
return [tuples (poly)]
73
76
end
74
77
# Cut polygon by line
75
- cut_coords = _cut (T, ext_poly, line, poly_list, intr_list, n_intr_pts; exact)
78
+ cut_coords = _cut (alg, T, ext_poly, line, poly_list, intr_list, n_intr_pts; exact)
76
79
# Close coords and create polygons
77
80
for c in cut_coords
78
81
push! (c, c[1 ])
0 commit comments