Clipper.jl icon indicating copy to clipboard operation
Clipper.jl copied to clipboard

Issue when taking unions

Open AndrewGibbs opened this issue 1 year ago • 1 comments

Hi,

I run the following code with two overlapping quadrilaterals:

using Clipper
path1 = Vector{IntPoint}()
mag = 2
pres = 8
push!(path1, IntPoint(0.0, 0.0, mag, pres))
push!(path1, IntPoint(0.0, 1.0, mag, pres))
push!(path1, IntPoint(1.0, 1.0, mag, pres))
push!(path1, IntPoint(1.3, 0.1, mag, pres))

path2 = Vector{IntPoint}()
push!(path2, IntPoint(1.0, 0.0, mag, pres))
push!(path2, IntPoint(1.0, 1.0, mag, pres))
push!(path2, IntPoint(2.0, 1.0, mag, pres))
push!(path2, IntPoint(2.0, 0.0, mag, pres))

c = Clip()
add_path!(c, path1, PolyTypeSubject, true)
add_path!(c, path2, PolyTypeSubject, true)

result, polys = execute(c, ClipTypeUnion, PolyFillTypeEvenOdd, PolyFillTypeEvenOdd)

The output variable polys consists of two polygons. I would expect this to be a single polygon, the union of the original two.

Perhaps I am misunderstanding how to take a union, that seems more likely than a bug. Either way, any help would be very much appreciated.

Thanks,

Andrew

AndrewGibbs avatar Oct 22 '24 09:10 AndrewGibbs

Update - this can be fixed by changing either one of the PolyTypeSubject to PolyTypeClip. I don't get why though...

AndrewGibbs avatar Oct 28 '24 12:10 AndrewGibbs