src/main/java/dev/rsoliveira/tools/binpacking/simulation/PalletPackingSimulation.java
/**
     * AABB validation for the items. In this case, the objects' faces can overlap.
     * @param state a packing state.
     * @return true if there is a collision, false otherwise.
     */
AABB validation for the items. In this case, the objects' faces can overlap.
@param state a packing state.
@return true if there is a collision, false otherwise.
AABB validation for the items . In this case the objects ' faces can overlap . @param state a packing state . @return true if there is a collision false otherwise .
private boolean isSolutionValid(PalletPackingState state) {
        boolean hasCollision = false;
        for (Item item1 : state.getItemsToPack()) {
            for (Item item2 : state.getItemsToPack()) {
                if (item1.getId() != item2.getId()) {
                    if ((item1.getMinPositionX() < item2.getMaxPositionX() && item1.getMaxPositionX() > item2.getMinPositionX()) &&
                        (item1.getMinPositionY() < item2.getMaxPositionY() && item1.getMaxPositionY() > item2.getMinPositionY()) &&
                        (item1.getMinPositionZ() < item2.getMaxPositionZ() && item1.getMaxPositionZ() > item2.getMinPositionZ())) {
                        hasCollision = true;
                        break;
                    }
                }
            }
            if (hasCollision) break;
        }
        return !hasCollision;
    }
private boolean isSolutionValid ( PalletPackingState state ) { boolean hasCollision = false ; for ( Item item1 : state . getItemsToPack ( ) ) { for ( Item item2 : state . getItemsToPack ( ) ) { if ( item1 . getId ( ) != item2 . getId ( ) ) { if ( ( item1 . getMinPositionX ( ) < item2 . getMaxPositionX ( ) && item1 . getMaxPositionX ( ) > item2 . getMinPositionX ( ) ) && ( item1 . getMinPositionY ( ) < item2 . getMaxPositionY ( ) && item1 . getMaxPositionY ( ) > item2 . getMinPositionY ( ) ) && ( item1 . getMinPositionZ ( ) < item2 . getMaxPositionZ ( ) && item1 . getMaxPositionZ ( ) > item2 . getMinPositionZ ( ) ) ) { hasCollision = true ; break ; } } } if ( hasCollision ) break ; } return ! hasCollision ; }
AABB validation for the items.
AABB validation for the items .
// boxes' faces can touch, but cannot overlap