There's a new version of Clipper that's about to be released that addresses this issue together with a number of other improvements.
You can download a preview of Clipper ver 6 from the SF trunk here:
See also: the SF discussion about this here
문제
I have the following code:
class Program {
static void Main(string[] args) {
Polygon a = new Polygon();
a.Add(new IntPoint(0,0));
a.Add(new IntPoint(2,0));
a.Add(new IntPoint(2,1));
a.Add(new IntPoint(1,1));
a.Add(new IntPoint(1,2));
a.Add(new IntPoint(2,2));
a.Add(new IntPoint(2,3));
a.Add(new IntPoint(0,3));
Polygon b = new Polygon();
b.Add(new IntPoint(2,0));
b.Add(new IntPoint(3,0));
b.Add(new IntPoint(3,3));
b.Add(new IntPoint(2,3));
PolyTree solution = new PolyTree();
Clipper c = new Clipper();
c.AddPolygon(a,PolyType.ptSubject);
c.AddPolygon(b,PolyType.ptSubject);
c.Execute(ClipType.ctUnion,solution);
printPolygonTree(solution);
Console.ReadLine();
}
static void printPolygonTree(PolyNode tree) {
Console.WriteLine((tree.IsHole?"Hole":"Polygon")+":");
foreach(IntPoint point in tree.Contour) {
Console.WriteLine(point.X+"/"+point.Y);
}
foreach(PolyNode node in tree.Childs) {
printPolygonTree(node);
}
}
}
It should unify the polygons a and b, which should result in a big square that contains a small square as a hole. But I get one polygon instead, that has a cut to connect the inner and outer polygon into one polygon.
Is there a way to unify the 2 polygons as expected?
Graphic: