JuliaGeometry / Clipper.jl

Julia wrapping of clipper
Other
30 stars 17 forks source link

execute polytree for offsetting #48

Open Wikunia opened 2 years ago

Wikunia commented 2 years ago

It seems like offsetting in this wrapper can only return a list of polygons and not a polytree. This is harder to work with when one wants to offset polygons that include holes as matching holes to the correct outer polygon isn't straightforward.

From the Clipper documentation: http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/ClipperOffset/Methods/Execute.htm it looks like Clipper itself supports this. Would there be interest in having this functionality in this wrapper? Would love to help with implementation but probably need some advice as I've never worked with a C++ wrapper in Julia before.

A bit more information: The CPP code: https://github.com/Geri-Borbas/Clipper/blob/master/cpp/clipper.cpp#L3917-L3955

The current Julia part: https://github.com/JuliaGeometry/Clipper.jl/blob/master/src/Clipper.jl#L278-L285

I don't know what the arguments in ccall are.

sjkelly commented 2 years ago

In the past, I found this easier to accomplish on the Julia side of things.

Also I am not sure such hierarchies are strictly required, since E.g. slicing any mesh should have interior polygons with the opposite winding order from the ones that contain them, and so forth all the way down. Offsetting IIRC takes into account winding order.

Wikunia commented 2 years ago

Yeah the problem might appear when a single polygon with a hole gets split up into two polygons due to a narrow bridge inside the initial polygon which gets disconnected when deflating the polygon. Then one needs to check in which of the two the hole is. Which would be saved directly in the polytree.