tamasmeszaros / libnest2d

2D irregular bin packaging and nesting library written in modern C++
GNU Lesser General Public License v3.0
315 stars 104 forks source link

Strange "starting_point" behavior in NfpPlacer #52

Open Daniil-SV opened 1 year ago

Daniil-SV commented 1 year ago

Hey, I'm trying to pack polygons into one or several tight square bins. I had a problem that result contained a lot of free space in corners, an example is below. image

I started experimenting with NfpPlacer settings and found that "starting_point" parameter contains the most suitable result but at the same time it has a very strange bug. For some reason first few items are placed "wrong" and then a square zone starts that seems normal, example and code used below. NestConfig<NfpPlacer> cfg; cfg.placer_config.alignment = NfpPlacer::Config::Alignment::BOTTOM_LEFT; cfg.placer_config.starting_point = NfpPlacer::Config::Alignment::BOTTOM_LEFT; size_t bins = nest( items, Box(2048, 2048, { 1024 , 1024 }), 2 cfg, {} ); ` image

From very beginning of my adventure with this library, I tried BottomLeftPlacer algorithm, but it also leaves a lot of space in some cases, so I decided to try NfpPlacer and here I am