| Crates.io | pack3d |
| lib.rs | pack3d |
| version | 0.1.2 |
| created_at | 2026-01-10 19:03:12.142119+00 |
| updated_at | 2026-01-10 19:36:55.311854+00 |
| description | A 3D bin packing application written in Rust. |
| homepage | |
| repository | https://github.com/chen-qingyu/pack3d |
| max_upload_size | |
| id | 2034559 |
| size | 1,668,737 |
Pack All~
draw.py.
First, it is agreed that the program uniformly adopts a right-handed coordinate system, defined as follows:
The input file is in JSON format and contains the following fields:
| Field Name | Type | Description |
|---|---|---|
id |
string | Unique identifier for the container type |
lx |
integer | Length of the container type |
ly |
integer | Width of the container type |
lz |
integer | Height of the container type |
payload |
number | Maximum payload of the container type (optional) |
quantity |
integer | Available quantity of the container type (optional, default is unlimited) |
| Field Name | Type | Description |
|---|---|---|
id |
string | Unique identifier for the box type |
lx |
integer | Length of the box type |
ly |
integer | Width of the box type |
lz |
integer | Height of the box type |
orients |
array | Allowed placement orientations for the box type (optional) |
The placement orientation of a box type is represented by a string, with six possible orientations:
"XYZ": Length (lx) along the X-axis, width (ly) along the Y-axis, height (lz) along the Z-axis (height is vertical)"YXZ": Width (ly) along the X-axis, length (lx) along the Y-axis, height (lz) along the Z-axis (height is vertical)"XZY": Length (lx) along the X-axis, height (lz) along the Y-axis, width (ly) along the Z-axis (width is vertical)"ZXY": Height (lz) along the X-axis, length (lx) along the Y-axis, width (ly) along the Z-axis (width is vertical)"YZX": Width (ly) along the X-axis, height (lz) along the Y-axis, length (lx) along the Z-axis (length is vertical)"ZYX": Height (lz) along the X-axis, width (ly) along the Y-axis, length (lx) along the Z-axis (length is vertical)For example, "orients": ["XYZ", "YXZ"] means that boxes of this type can only be placed flat, not upright.
If the orients field is not specified, the default is ["XYZ", "YXZ"], which means only flat placement is allowed.
| Field Name | Type | Description |
|---|---|---|
id |
string | Unique identifier for the box |
type |
string | Type of the box |
weight |
number | Weight of the box (optional) |
| Field Name | Type | Description |
|---|---|---|
container_types |
array | List of available container types |
box_types |
array | List of available box types |
boxes |
array | List of boxes to be packed |
For an example input, please refer to demo.json.
The output file is in JSON format and contains the following fields:
| Field Name | Type | Description |
|---|---|---|
type |
object | The type of the container |
boxes |
array | List of packed boxes |
volume_rate |
number | Volume utilization rate of the container |
weight_rate |
number | Weight utilization rate of the container |
| Field Name | Type | Description |
|---|---|---|
id |
string | Unique identifier for the box |
type |
string | Unique identifier for the box type |
x |
integer | X-axis coordinate of the placement |
y |
integer | Y-axis coordinate of the placement |
z |
integer | Z-axis coordinate of the placement |
orient |
string | Placement orientation |
| Field Name | Type | Description |
|---|---|---|
box_types |
array | List of box types |
containers |
array | List of containers |
unpacked_boxes |
array | List of unpacked boxes |
A tree diagram of the complete output format is as follows:
output
├── box_types
│ ├── box_type#1
│ ├── box_type#2
│ └── ...
├── containers
│ ├── container#1
│ │ ├── type
│ │ └── boxes
│ │ │ ├── box#1
│ │ │ ├── box#2
│ │ │ └── ...
│ │ ├── volume_rate
│ │ └── weight_rate
│ ├── container#2
│ │ ├── type
│ │ └── boxes
│ │ │ ├── box#3
│ │ │ ├── box#4
│ │ │ └── ...
│ │ ├── volume_rate
│ │ └── weight_rate
│ └── ...
└── unpacked_boxes
├── box#5
├── box#6
└── ...
cargo doc to generate documentationcargo fmt to format the code, following the official Rust code style