Nest4J icon indicating copy to clipboard operation
Nest4J copied to clipboard

Hollow Polygon

Open donatellosantoro opened this issue 7 years ago • 2 comments

Hi there, we found an issue regarding the placing of hollow polygons with USE_HOLE = false. In particular we expect that using this parameter we'll never have a polygon inside another.

However, running the following code, we have the same result both with USE_HOLE = false and USE_HOLE = true.

    NestPath binPolygon = new NestPath();
    double width = 400;
    double height = 400;
    binPolygon.add(0, 0);
    binPolygon.add(0, height);
    binPolygon.add(width, height);
    binPolygon.add(width, 0);

    List<NestPath> list = new ArrayList<NestPath>();
    NestPath outer = new NestPath();
    outer.add(600, 0);
    outer.add(600, 200);
    outer.add(800, 200);
    outer.add(800, 0);
    outer.setRotation(0);
    outer.bid = 1;
    list.add(outer);
    NestPath inner = new NestPath();
    inner.add(650, 50);
    inner.add(650, 150);
    inner.add(750, 150);
    inner.add(750, 50);
    inner.bid = 2;
    list.add(inner);

    Config config = new Config();
    config.SPACING = 0;
    config.USE_HOLE = false;
    Nest nest = new Nest(binPolygon, list, config, 2);
    List<List<Placement>> appliedPlacement = nest.startNest();

The result is the follow: as you can see, the second polygon is placed inside the first one. schermata 2018-07-16 alle 12 17 56

Can you confirm that this is not the expected behavior? Thanks

donatellosantoro avatar Jul 16 '18 10:07 donatellosantoro

We use several NestPath to describe a Ploygon with Holes. If you want to have a Hollow polygon with one hole, you have to create 2 NestPath . So in your Example, NestPath outer and NestPath inner described ONE hollow polygon with rect hole, so it is correct for the result. The Svg result have some bugs dealing with expressing Hollow Polygon currently in my project.

Yisaer avatar Jul 16 '18 10:07 Yisaer

@donatellosantoro It would be much appreciated if you help us build some JUnit test classes in this scenario~

oreasono avatar Jul 16 '18 10:07 oreasono