clipperlib

C# clip linesegment with clipper library

早过忘川 提交于 2019-12-01 20:28:12
I am using clipper for performing a bunch of operations on polygons which represent the outlines of objects in my program. The thing is, I now want to clip a grid of line segments to fill these outlines but I am struggling to do this with Clipper. At the moment I am converting my lines to rectangles with a thickness of 2 units which I then do an intersection operation with and then finally I need to revert the new polygons back to line segments. This is quite inefficient though and produces quite a few errors. Can this be done with Clipper, if not is there something else that I can use or do I

Converting polygon coordinates from Double to Long for use with Clipper library

妖精的绣舞 提交于 2019-12-01 17:17:29
I have two polygons with their vertices stored as Double coordinates. I'd like to find the intersecting area of these polygons, so I'm looking at the Clipper library (C++ version). The problem is, Clipper only works with integer math (it uses the Long type). Is there a way I can safely transform both my polygons with the same scale factor, convert their coordinates to Longs, perform the Intersection algorithm with Clipper, and scale the resulting intersection polygon back down with the same factor, and convert it back to a Double without too much loss of precision? I can't quite get my head