Giter Club home page Giter Club logo

Comments (4)

dvdoug avatar dvdoug commented on September 15, 2024 1

OK, I'll certainly keep this on the list. In the meantime, something that might work for you is using custom sorting - as this works when the vinyl is packed first, depending on your application you can probably enforce that using the mechanism at https://boxpacker.io/en/stable/sortation.html#overriding-the-default-algorithm

$sorter = new CustomItemSorter();
$itemList = new ItemList($sorter);

class CustomItemSorter extends DefaultItemSorter
{
    public function compare(Item $itemA, Item $itemB): int
    {
        if ($itemA->isVinyl()) {  // or check a category, or ->getDepth() < 15 or whatever works in your app to identify one
          return -1;
        }

        if ($itemB->isVinyl()) {
          return 1;
        }

        // fall back to regular rules
        return parent::compare($itemA, $itemB);
    }
}

from boxpacker.

oddvalue avatar oddvalue commented on September 15, 2024

To add more info to this, the item list gets sorted so that the 2nd box gets checked first because it has a greater volume. It then tries several orientations for that box, except just lying it flat, and fails to fit the 1st box. If you bump the depth of the 1st item up to 15 it works fine.

from boxpacker.

dvdoug avatar dvdoug commented on September 15, 2024

Hi, thanks for the minimal testcase - makes it a lot easier to reproduce and debug.

This is one of those ones where I can easily make changes that makes this particular example pack better, but then others end up packing worse - I'll keep seeing if I can find the right heuristic.

Is this just an odd example that you've found, or this a typical scenario for what you're trying to pack with a large flat item that's almost (but not quite), the same dimensions as the box not being put at the bottom?

from boxpacker.

howdu avatar howdu commented on September 15, 2024

Thanks for looking into this @dvdoug - it's a great package and all other package combinations are working flawlessly.

The issue we're having is with a vinyl record box plus a DVD box set, and the reason for the outer box dimensions.

from boxpacker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.