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

Shapes are placed within other shapes when there is not a hole. #12

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

Shapes are placed within other shapes when there is not a hole. #12

Thejipppp opened this issue Feb 19, 2020 · 0 comments

Comments

@Thejipppp
Copy link

I've tested the code with the x10 scaled testset SHAPES2 and a bin size of 20 000 x 150 (simulating an open ended plate).

main.java
        NestPath bin = new NestPath();
        double binWidth = 20000;
        double binHeight = 150;
        bin.add(0, 0);
        bin.add(binWidth, 0);
        bin.add(binWidth, binHeight);
        bin.add(0, binHeight);

        List<NestPath> polygons = transferSvgIntoPolygons();

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

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

        List<String> strings = SvgUtil.svgGenerator(polygons, appliedPlacement, binWidth, binHeight);
        saveSvgFile(strings);
SHAPES2.xml
<root>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<polygon points="500,500 520,490 540,500 540,530 520,540 500,530 " />
<polygon points="500,1500 520,1490 540,1500 540,1530 520,1540 500,1530 " />
<polygon points="500,3500 520,3490 540,3500 540,3530 520,3540 500,3530 " />
<polygon points="500,6500 520,6490 540,6500 540,6530 520,6540 500,6530 " />
<polygon points="1500,500 1530,500 1520,520 1530,540 1530,550 1510,550 1490,530 1490,510 " />
<polygon points="1500,1500 1530,1500 1520,1520 1530,1540 1530,1550 1510,1550 1490,1530 1490,1510 " />
<polygon points="1500,3500 1530,3500 1520,3520 1530,3540 1530,3550 1510,3550 1490,3530 1490,3510 " />
<polygon points="1500,6500 1530,6500 1520,6520 1530,6540 1530,6550 1510,6550 1490,6530 1490,6510 " />
<polygon points="2500,500 2520,500 2530,510 2530,530 2520,540 2500,540 2490,530 2490,510 " />
<polygon points="2500,1500 2520,1500 2530,1510 2530,1530 2520,1540 2500,1540 2490,1530 2490,1510 " />
<polygon points="2500,3500 2520,3500 2530,3510 2530,3530 2520,3540 2500,3540 2490,3530 2490,3510 " />
<polygon points="2500,6500 2520,6500 2530,6510 2530,6530 2520,6540 2500,6540 2490,6530 2490,6510 " />
<polygon points="3500,500 3520,510 3540,500 3530,520 3540,550 3520,540 3500,550 3510,530 " />
<polygon points="3500,1500 3520,1510 3540,1500 3530,1520 3540,1550 3520,1540 3500,1550 3510,1530 " />
<polygon points="3500,3500 3520,3510 3540,3500 3530,3520 3540,3550 3520,3540 3500,3550 3510,3530 " />
<polygon points="3500,6500 3520,6510 3540,6500 3530,6520 3540,6550 3520,6540 3500,6550 3510,6530 " />
<polygon points="4500,500 4550,500 4550,550 4540,550 4530,530 4520,520 4500,510 " />
<polygon points="4500,1500 4550,1500 4550,1550 4540,1550 4530,1530 4520,1520 4500,1510 " />
<polygon points="4500,3500 4550,3500 4550,3550 4540,3550 4530,3530 4520,3520 4500,3510 " />
<polygon points="4500,6500 4550,6500 4550,6550 4540,6550 4530,6530 4520,6520 4500,6510 " />
<polygon points="5500,500 5520,530 5480,530 " />
<polygon points="5500,1500 5520,1530 5480,1530 " />
<polygon points="5500,3500 5520,3530 5480,3530 " />
<polygon points="5500,6500 5520,6530 5480,6530 " />
<polygon points="6500,500 6520,500 6520,520 6500,520 " />
<polygon points="6500,1500 6520,1500 6520,1520 6500,1520 " />
<polygon points="6500,3500 6520,3500 6520,3520 6500,3520 " />
<polygon points="6500,6500 6520,6500 6520,6520 6500,6520 " />
</root>
SHAPES2.svg
<!DOCTYPE html>
<html>
<body>

<svg height="8000" width="8000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink"><polygon points="500,1500 520,1490 540,1500 540,1530 520,1540 500,1530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="500,2500 520,2490 540,2500 540,2530 520,2540 500,2530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="500,3500 520,3490 540,3500 540,3530 520,3540 500,3530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="500,4500 520,4490 540,4500 540,4530 520,4540 500,4530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="1500,1500 1530,1500 1520,1520 1530,1540 1530,1550 1510,1550 1490,1530 1490,1510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="1500,2500 1530,2500 1520,2520 1530,2540 1530,2550 1510,2550 1490,2530 1490,2510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="1500,3500 1530,3500 1520,3520 1530,3540 1530,3550 1510,3550 1490,3530 1490,3510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="1500,4500 1530,4500 1520,4520 1530,4540 1530,4550 1510,4550 1490,4530 1490,4510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="2500,1500 2520,1500 2530,1510 2530,1530 2520,1540 2500,1540 2490,1530 2490,1510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="2500,2500 2520,2500 2530,2510 2530,2530 2520,2540 2500,2540 2490,2530 2490,2510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="2500,3500 2520,3500 2530,3510 2530,3530 2520,3540 2500,3540 2490,3530 2490,3510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="2500,4500 2520,4500 2530,4510 2530,4530 2520,4540 2500,4540 2490,4530 2490,4510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="3500,1500 3520,1510 3540,1500 3530,1520 3540,1550 3520,1540 3500,1550 3510,1530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="3500,2500 3520,2510 3540,2500 3530,2520 3540,2550 3520,2540 3500,2550 3510,2530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="3500,3500 3520,3510 3540,3500 3530,3520 3540,3550 3520,3540 3500,3550 3510,3530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="3500,4500 3520,4510 3540,4500 3530,4520 3540,4550 3520,4540 3500,4550 3510,4530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="4500,1500 4550,1500 4550,1550 4540,1550 4530,1530 4520,1520 4500,1510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="4500,2500 4550,2500 4550,2550 4540,2550 4530,2530 4520,2520 4500,2510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="4500,3500 4550,3500 4550,3550 4540,3550 4530,3530 4520,3520 4500,3510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="4500,4500 4550,4500 4550,4550 4540,4550 4530,4530 4520,4520 4500,4510 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="5500,1500 5520,1530 5480,1530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="5500,2500 5520,2530 5480,2530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="5500,3500 5520,3530 5480,3530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="5500,4500 5520,4530 5480,4530 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="6500,1500 6520,1500 6520,1520 6500,1520 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="6500,2500 6520,2500 6520,2520 6500,2520 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="6500,3500 6520,3500 6520,3520 6500,3520 " style="fill:lime;stroke:purple;stroke-width:1" />
<polygon points="6500,4500 6520,4500 6520,4520 6500,4520 " style="fill:lime;stroke:purple;stroke-width:1" />
</svg>

</body>
</html>

Some squares are added within the octagons when they obviously shouldn't.

image

result.svg
<?xml version="1.0" standalone="no"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 
<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">
 <g transform="translate(10  0)">
    <rect x="0" y="0" width="20000.0" height="150.0"  fill="none" stroke="#010101" stroke-width="1" />
<g transform="translate(-500.010 -490.00) rotate(0.0)"> 
<path d="M500.0 500.0 L520.0 490.0 L540.0 500.0 L540.0 530.0 L520.0 540.0 L500.0 530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-500.010 -1440.00) rotate(0.0)"> 
<path d="M500.0 1500.0 L520.0 1490.0 L540.0 1500.0 L540.0 1530.0 L520.0 1540.0 L500.0 1530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(540.010 3640.00) rotate(180.0)"> 
<path d="M500.0 3500.0 L520.0 3490.0 L540.0 3500.0 L540.0 3530.0 L520.0 3540.0 L500.0 3530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(580.010 6640.00) rotate(180.0)"> 
<path d="M500.0 6500.0 L520.0 6490.0 L540.0 6500.0 L540.0 6530.0 L520.0 6540.0 L500.0 6530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-1450.010 -450.00) rotate(0.0)"> 
<path d="M1500.0 500.0 L1530.0 500.0 L1520.0 520.0 L1530.0 540.0 L1530.0 550.0 L1510.0 550.0 L1490.0 530.0 L1490.0 510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-1430.010 -1500.00) rotate(0.0)"> 
<path d="M1500.0 1500.0 L1530.0 1500.0 L1520.0 1520.0 L1530.0 1540.0 L1530.0 1550.0 L1510.0 1550.0 L1490.0 1530.0 L1490.0 1510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-1415.010 -3450.00) rotate(0.0)"> 
<path d="M1500.0 3500.0 L1530.0 3500.0 L1520.0 3520.0 L1530.0 3540.0 L1530.0 3550.0 L1510.0 3550.0 L1490.0 3530.0 L1490.0 3510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-1395.010 -6500.00) rotate(0.0)"> 
<path d="M1500.0 6500.0 L1530.0 6500.0 L1520.0 6520.0 L1530.0 6540.0 L1530.0 6550.0 L1510.0 6550.0 L1490.0 6530.0 L1490.0 6510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(4630.010 649.99990) rotate(180.0)"> 
<path d="M4500.0 500.0 L4550.0 500.0 L4550.0 550.0 L4540.0 550.0 L4530.0 530.0 L4520.0 520.0 L4500.0 510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(4665.010 1632.49990) rotate(180.0)"> 
<path d="M4500.0 1500.0 L4550.0 1500.0 L4550.0 1550.0 L4540.0 1550.0 L4530.0 1530.0 L4520.0 1520.0 L4500.0 1510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-4392.010 -3435.99990) rotate(0.0)"> 
<path d="M4500.0 3500.0 L4550.0 3500.0 L4550.0 3550.0 L4540.0 3550.0 L4530.0 3530.0 L4520.0 3520.0 L4500.0 3510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(2660.010 539.99990) rotate(180.0)"> 
<path d="M2500.0 500.0 L2520.0 500.0 L2530.0 510.0 L2530.0 530.0 L2520.0 540.0 L2500.0 540.0 L2490.0 530.0 L2490.0 510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(4708.010 6619.00) rotate(180.0)"> 
<path d="M4500.0 6500.0 L4550.0 6500.0 L4550.0 6550.0 L4540.0 6550.0 L4530.0 6530.0 L4520.0 6520.0 L4500.0 6510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-2330.510 -1469.49990) rotate(0.0)"> 
<path d="M2500.0 1500.0 L2520.0 1500.0 L2530.0 1510.0 L2530.0 1530.0 L2520.0 1540.0 L2500.0 1540.0 L2490.0 1530.0 L2490.0 1510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(2716.666610 3603.33330) rotate(180.0)"> 
<path d="M2500.0 3500.0 L2520.0 3500.0 L2530.0 3510.0 L2530.0 3530.0 L2520.0 3540.0 L2500.0 3540.0 L2490.0 3530.0 L2490.0 3510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(2718.999810 6540.00) rotate(180.0)"> 
<path d="M2500.0 6500.0 L2520.0 6500.0 L2530.0 6510.0 L2530.0 6530.0 L2520.0 6540.0 L2500.0 6540.0 L2490.0 6530.0 L2490.0 6510.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(3760.010 649.99990) rotate(180.0)"> 
<path d="M3500.0 500.0 L3520.0 510.0 L3540.0 500.0 L3530.0 520.0 L3540.0 550.0 L3520.0 540.0 L3500.0 550.0 L3510.0 530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-3277.333410 -3448.66660) rotate(0.0)"> 
<path d="M3500.0 3500.0 L3520.0 3510.0 L3540.0 3500.0 L3530.0 3520.0 L3540.0 3550.0 L3520.0 3540.0 L3500.0 3550.0 L3510.0 3530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-3274.333510 -1500.00) rotate(0.0)"> 
<path d="M3500.0 1500.0 L3520.0 1510.0 L3540.0 1500.0 L3530.0 1520.0 L3540.0 1550.0 L3520.0 1540.0 L3500.0 1550.0 L3510.0 1530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(3792.666610 6621.33340) rotate(180.0)"> 
<path d="M3500.0 6500.0 L3520.0 6510.0 L3540.0 6500.0 L3530.0 6520.0 L3540.0 6550.0 L3520.0 6540.0 L3500.0 6550.0 L3510.0 6530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(5682.666710 649.00) rotate(180.0)"> 
<path d="M5500.0 500.0 L5520.0 530.0 L5480.0 530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(5775.666510 1549.99980) rotate(180.0)"> 
<path d="M5500.0 1500.0 L5520.0 1530.0 L5480.0 1530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-5222.010 -3385.99990) rotate(0.0)"> 
<path d="M5500.0 3500.0 L5520.0 3530.0 L5480.0 3530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-5218.555810 -6458.66650) rotate(0.0)"> 
<path d="M5500.0 6500.0 L5520.0 6530.0 L5480.0 6530.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-6370.010 -490.00) rotate(0.0)"> 
<path d="M6500.0 500.0 L6520.0 500.0 L6520.0 520.0 L6500.0 520.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(6655.010 3564.00) rotate(180.0)"> 
<path d="M6500.0 3500.0 L6520.0 3500.0 L6520.0 3520.0 L6500.0 3520.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(-6340.510 -1459.49990) rotate(0.0)"> 
<path d="M6500.0 1500.0 L6520.0 1500.0 L6520.0 1520.0 L6500.0 1520.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
<g transform="translate(6715.333410 6649.99990) rotate(180.0)"> 
<path d="M6500.0 6500.0 L6520.0 6500.0 L6520.0 6520.0 L6500.0 6520.0 Z" fill="#8498d1" stroke="#010101" stroke-width="1" /> 
</g> 
</g> 
</svg>

Any idea why this could be the case?

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