Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Some shapes are placed wrong when using rotations and holes. #11

Open
Thejipppp opened this issue Feb 6, 2020 · 0 comments
Open

Some shapes are placed wrong when using rotations and holes. #11

Thejipppp opened this issue Feb 6, 2020 · 0 comments

Comments

@Thejipppp
Copy link

Hello.

Massive thanks for this code contribution.
I was playing around with the use_holes option and got some very strange results.

I used this code. It adds 2 big squares, a square hole in one of them and 4 little squares that should fit into the hole.

NestPath bin = new NestPath();
double binWidth = 500;
double binHeight = 200;
bin.add(0, 0);
bin.add(binWidth, 0);
bin.add(binWidth, binHeight);
bin.add(0, binHeight);

double mins[] = {0,60,101,300,310,320,330};
double maxs[] = {100,81,200,310,320,330,340};

List<NestPath> polygons = new ArrayList<NestPath>();
for(int i = 0; i < 7; i++){
	NestPath p = new NestPath();
	p.add(mins[i], mins[i]);
	p.add(mins[i], maxs[i]);
	p.add(maxs[i], maxs[i]);
	p.add(maxs[i], mins[i]);
	p.bid = i;
	p.setRotation(4);
	polygons.add(p);
}

Config config = new Config();
config.SPACING = 0;
config.POPULATION_SIZE = 5;
config.USE_HOLE = true;

Nest nest = new Nest(bin, polygons, config, 2);
List<List<Placement>> appliedPlacement = nest.startNest();

List<String> strings = SvgUtil.svgGenerator(polygons, appliedPlacement, binWidth, binHeight);
saveSvgFile(strings);

And I got the following result. Note that the hole is normally below the polygon in which it belongs, but I brought it up and colored it red.

image

It seems that some polygons try to use the hole with an OuterNFP instead of an innerNFP. I searched a little bit, but I did not find what could be possibly wrong.

When the polygons have no rotations, everything goes like expected and the hole is filled properly.

Do you have any idea what could be the issue or what I am doing wrong?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant