pack() places the items; a second, separate call reads those placements back and reports, per item, whether it can be reached without moving anything blocking it - the loading question and the fitting question are answered by two different tools, not conflated into one.
SHOWN IN Node / JavaScript
import { pack, placementReachability } from '@packvium/engine';
const request = {
items: [
{ id: 'stop-1-crate', quantity: 1, weight: '10 kg',
dimensions: { length: '300', width: '300', height: '300' } },
{ id: 'stop-2-crate', quantity: 1, weight: '10 kg',
dimensions: { length: '300', width: '300', height: '300' } },
],
containers: [
{ id: 'van', cost_minor: 100, max_payload: '200 kg',
inner_dimensions: { length: '600', width: '300', height: '300' } },
],
};
const result = pack(request);
const container = result.containers[0];
const mm = (scalar) => Number(scalar.value);
const boxes = container.placements.map((placement) => ({
origin: { x: mm(placement.position.x), y: mm(placement.position.y), z: mm(placement.position.z) },
dimensions: {
length: mm(placement.dimensions.length),
width: mm(placement.dimensions.width),
height: mm(placement.dimensions.height),
},
}));
const dims = {
length: mm(container.inner_dimensions.length),
width: mm(container.inner_dimensions.width),
height: mm(container.inner_dimensions.height),
};
const stops = [0, 1];
console.log(placementReachability(boxes, dims, stops));
WHAT COMES BACK
The crate for stop 1 comes back reachable: true. The crate for stop 2 comes back reachable: false, blocked_by_route: [0] - it sits behind the first crate, which is exactly where it should be, since it isn't due out until the first crate already is.