src/main/java/dev/rsoliveira/tools/binpacking/simulation/PalletPackingSimulation.java
/**
     * Verifies if the given item dimensions fit in the remaining container space;<br>
     * if true, update the remaining space and item dimensions;<br>
     * if false, reserve the found values for a possible greater layer thickness.<br>
     *
     * @param state       the packing state.
     * @param index       the actual box index being evaluated.
     * @param maxGapX     the container x-dimension.
     * @param currentGapZ the currently used z-dimension.
     * @param maxGapZ     the container z-dimension.
     * @param orientation the item dimensions.
     */
Verifies if the given item dimensions fit in the remaining container space;
if true, update the remaining space and item dimensions;
if false, reserve the found values for a possible greater layer thickness.

@param state       the packing state.
@param index       the actual box index being evaluated.
@param maxGapX     the container x-dimension.
@param currentGapZ the currently used z-dimension.
@param maxGapZ     the container z-dimension.
@param orientation the item dimensions.
Verifies if the given item dimensions fit in the remaining container space ; if true update the remaining space and item dimensions ; if false reserve the found values for a possible greater layer thickness . @param state the packing state . @param index the actual box index being evaluated . @param maxGapX the container x - dimension . @param currentGapZ the currently used z - dimension . @param maxGapZ the container z - dimension . @param orientation the item dimensions .
private void analyzeBox(PalletPackingState state, int index, long maxGapX, long currentGapZ, long maxGapZ, Volume orientation) {
        long dimension1 = orientation.getDimension1();
        long dimension2 = orientation.getDimension2();
        long dimension3 = orientation.getDimension3();
        long diff1 = Math.abs(maxGapX - dimension1);
        long diff2 = Math.abs(state.getLayerThickness() - dimension2);
        long diff3 = Math.abs(currentGapZ - dimension3);
        if (dimension1 <= maxGapX && dimension2 <= state.getMaxAvailableThickness() && dimension3 <= maxGapZ) {
            if (dimension2 <= state.getLayerThickness()) {
                if ((diff2 < state.getBoxFittingY()) ||
                    (diff2 == state.getBoxFittingY() && diff1 < state.getBoxFittingX()) ||
                    (diff2 == state.getBoxFittingY() && diff1 == state.getBoxFittingX() && diff3 < state.getBoxFittingZ())) {
                    state.setBoxX(dimension1);
                    state.setBoxY(dimension2);
                    state.setBoxZ(dimension3);
                    state.setBoxFittingX(diff1);
                    state.setBoxFittingY(diff2);
                    state.setBoxFittingZ(diff3);
                    state.setBoxFittingIndex(index);
                }
            } else {
                if ((diff2 < state.getBoxNotFittingY()) ||
                    (diff2 == state.getBoxNotFittingY() && diff1 < state.getBoxNotFittingX()) ||
                    (diff2 == state.getBoxNotFittingY() && diff1 == state.getBoxNotFittingX() && diff3 < state.getBotNotFittingZ())) {
                    state.setbBoxX(dimension1);
                    state.setbBoxY(dimension2);
                    state.setbBoxZ(dimension3);
                    state.setBoxNotFittingX(diff1);
                    state.setBoxNotFittingY(diff2);
                    state.setBotNotFittingZ(diff3);
                    state.setBoxNotFittingIndex(index);
                }
            }
        }
    }
private void analyzeBox ( PalletPackingState state , int index , long maxGapX , long currentGapZ , long maxGapZ , Volume orientation ) { long dimension1 = orientation . getDimension1 ( ) ; long dimension2 = orientation . getDimension2 ( ) ; long dimension3 = orientation . getDimension3 ( ) ; long diff1 = Math . abs ( maxGapX - dimension1 ) ; long diff2 = Math . abs ( state . getLayerThickness ( ) - dimension2 ) ; long diff3 = Math . abs ( currentGapZ - dimension3 ) ; if ( dimension1 <= maxGapX && dimension2 <= state . getMaxAvailableThickness ( ) && dimension3 <= maxGapZ ) { if ( dimension2 <= state . getLayerThickness ( ) ) { if ( ( diff2 < state . getBoxFittingY ( ) ) || ( diff2 == state . getBoxFittingY ( ) && diff1 < state . getBoxFittingX ( ) ) || ( diff2 == state . getBoxFittingY ( ) && diff1 == state . getBoxFittingX ( ) && diff3 < state . getBoxFittingZ ( ) ) ) { state . setBoxX ( dimension1 ) ; state . setBoxY ( dimension2 ) ; state . setBoxZ ( dimension3 ) ; state . setBoxFittingX ( diff1 ) ; state . setBoxFittingY ( diff2 ) ; state . setBoxFittingZ ( diff3 ) ; state . setBoxFittingIndex ( index ) ; } } else { if ( ( diff2 < state . getBoxNotFittingY ( ) ) || ( diff2 == state . getBoxNotFittingY ( ) && diff1 < state . getBoxNotFittingX ( ) ) || ( diff2 == state . getBoxNotFittingY ( ) && diff1 == state . getBoxNotFittingX ( ) && diff3 < state . getBotNotFittingZ ( ) ) ) { state . setbBoxX ( dimension1 ) ; state . setbBoxY ( dimension2 ) ; state . setbBoxZ ( dimension3 ) ; state . setBoxNotFittingX ( diff1 ) ; state . setBoxNotFittingY ( diff2 ) ; state . setBotNotFittingZ ( diff3 ) ; state . setBoxNotFittingIndex ( index ) ; } } } }
Verifies if the given item dimensions fit in the remaining container space;<br>
 if true, update the remaining space and item dimensions;<br>
 if false, reserve the found values for a possible greater layer thickness.<br>
Verifies if the given item dimensions fit in the remaining container space ; <br > if true update the remaining space and item dimensions ; <br > if false reserve the found values for a possible greater layer thickness . <br >