public void execute(PolyTree solution, double delta) { solution.Clear(); fixOrientations(); doOffset(delta); // now clean up 'corners' ... final DefaultClipper clpr = new DefaultClipper(Clipper.REVERSE_SOLUTION); clpr.addPaths(destPolys, PolyType.SUBJECT, true); if (delta > 0) { clpr.execute(ClipType.UNION, solution, PolyFillType.POSITIVE, PolyFillType.POSITIVE); } else { final LongRect r = destPolys.getBounds(); final Path outer = new Path(4); outer.add(new LongPoint(r.left - 10, r.bottom + 10, 0)); outer.add(new LongPoint(r.right + 10, r.bottom + 10, 0)); outer.add(new LongPoint(r.right + 10, r.top - 10, 0)); outer.add(new LongPoint(r.left - 10, r.top - 10, 0)); clpr.addPath(outer, PolyType.SUBJECT, true); clpr.execute(ClipType.UNION, solution, PolyFillType.NEGATIVE, PolyFillType.NEGATIVE); // remove the outer PolyNode rectangle ... if (solution.getChildCount() == 1 && solution.getChilds().get(0).getChildCount() > 0) { final PolyNode outerNode = solution.getChilds().get(0); solution.getChilds().set(0, outerNode.getChilds().get(0)); solution.getChilds().get(0).setParent(solution); for (int i = 1; i < outerNode.getChildCount(); i++) { solution.addChild(outerNode.getChilds().get(i)); } } else { solution.Clear(); } } }
public void execute(Paths solution, double delta) { solution.clear(); fixOrientations(); doOffset(delta); // now clean up 'corners' ... final DefaultClipper clpr = new DefaultClipper(Clipper.REVERSE_SOLUTION); clpr.addPaths(destPolys, PolyType.SUBJECT, true); if (delta > 0) { clpr.execute(ClipType.UNION, solution, PolyFillType.POSITIVE, PolyFillType.POSITIVE); } else { final LongRect r = destPolys.getBounds(); final Path outer = new Path(4); outer.add(new LongPoint(r.left - 10, r.bottom + 10, 0)); outer.add(new LongPoint(r.right + 10, r.bottom + 10, 0)); outer.add(new LongPoint(r.right + 10, r.top - 10, 0)); outer.add(new LongPoint(r.left - 10, r.top - 10, 0)); clpr.addPath(outer, PolyType.SUBJECT, true); clpr.execute(ClipType.UNION, solution, PolyFillType.NEGATIVE, PolyFillType.NEGATIVE); if (solution.size() > 0) { solution.remove(0); } } }