jerry800416 / 3D-bin-packing

3D Bin Packing improvements based on https://github.com/enzoruiz/3dbinpacking
MIT License
158 stars 44 forks source link

Different output between the API and the examples #19

Open Nissou31 opened 1 year ago

Nissou31 commented 1 year ago

Hello,

I'm using your program to create a web application on top of it. By using your API I have setup a json sample like the example4.py, I have the same calculation results : both have 37 unfitted items and the same fitted item, but the difference is in the positions of the items. When I visualize your example4 with matplot , we have a beautiful and correct to the eye packing solution. But using the API and my front end ReactJS front, I have a weird stacking of the item, plus the API results is not the same, here's the logging sample :

API logs :

INFO:root:Creating and adding items for Dyson DC34 Animal INFO:root:Creating and adding items for wash INFO:root:Creating and adding items for cabint INFO:root:Creating and adding items for server INFO:root:Processing binding data... INFO:root:Returning packer, box, and binding... INFO:root:Possition of the box : (295.0, 122.0, 129.5) INFO:root:Position of the item cabint-1 : [30, 40, 100] INFO:root:Position of the item cabint-2 : [90, 40, 100] INFO:root:Position of the item cabint-3 : [150, 40, 100] INFO:root:Position of the item cabint-4 : [210, 40, 100] INFO:root:Position of the item cabint-5 : [270, 40, 100] INFO:root:Position of the item cabint-6 : [330, 40, 100] INFO:root:Position of the item cabint-7 : [390, 40, 100] INFO:root:Position of the item cabint-8 : [450, 40, 100] INFO:root:Position of the item cabint-9 : [510, 40, 100] INFO:root:Position of the item cabint-10 : [30, 120, 100] INFO:root:Position of the item cabint-11 : [90, 120, 100] INFO:root:Position of the item cabint-12 : [150, 120, 100] INFO:root:Position of the item cabint-13 : [210, 120, 100] INFO:root:Position of the item cabint-14 : [270, 120, 100] INFO:root:Position of the item cabint-15 : [330, 120, 100] INFO:root:Position of the item Dyson DC34 Animal-1 : [563, 41, 85] INFO:root:Position of the item Dyson DC34 Animal-2 : [445, 121, 23] INFO:root:Position of the item Dyson DC34 Animal-3 : [85, 201, 23] INFO:root:Position of the item Dyson DC34 Animal-4 : [255, 201, 23] INFO:root:Position of the item Dyson DC34 Animal-5 : [553, 123, 85] INFO:root:Position of the item Dyson DC34 Animal-6 : [425, 203, 23] INFO:root:Position of the item Dyson DC34 Animal-7 : [85, 41, 223] INFO:root:Position of the item Dyson DC34 Animal-8 : [255, 41, 223] INFO:root:Position of the item Dyson DC34 Animal-9 : [425, 41, 223] INFO:root:Position of the item Dyson DC34 Animal-10 : [85, 123, 223] INFO:root:Position of the item Dyson DC34 Animal-11 : [255, 123, 223] INFO:root:Position of the item Dyson DC34 Animal-12 : [563, 85, 211] INFO:root:Position of the item Dyson DC34 Animal-13 : [445, 121, 69] INFO:root:Position of the item Dyson DC34 Animal-14 : [85, 201, 69] INFO:root:Position of the item Dyson DC34 Animal-15 : [255, 201, 69] INFO:root:Position of the item wash-1 : [540, 194, 42] INFO:root:Position of the item wash-2 : [382, 192, 76] INFO:root:Position of the item wash-3 : [467, 192, 76] INFO:root:Position of the item wash-4 : [402, 110, 122] INFO:root:Position of the item wash-5 : [487, 110, 122] INFO:root:Position of the item wash-6 : [42, 190, 122] INFO:root:Position of the item wash-7 : [127, 190, 122] INFO:root:Position of the item wash-8 : [212, 190, 122] INFO:root:Position of the item wash-9 : [297, 190, 122] INFO:root:Position of the item wash-10 : [540, 194, 127] INFO:root:Position of the item wash-11 : [382, 190, 136] INFO:root:Position of the item wash-12 : [382, 190, 196] INFO:root:Position of the item wash-13 : [402, 112, 182] INFO:root:Position of the item wash-14 : [487, 112, 182] INFO:root:Position of the item server-1 : [50, 195, 167] INFO:root:Position of the item server-2 : [150, 195, 167] INFO:root:Position of the item server-3 : [250, 195, 167] INFO:root:Position of the item server-4 : [50, 199, 197] INFO:root:Position of the item server-5 : [150, 199, 197] INFO:root:Position of the item server-6 : [250, 199, 197] INFO:root:Position of the item server-7 : [50, 199, 227] INFO:root:Position of the item server-8 : [150, 199, 227] INFO:root:Position of the item server-9 : [250, 199, 227] INFO:root:Position of the item wash-15 : [42, 190, 90] INFO:root:Position of the item wash-16 : [127, 190, 90] INFO:root:Position of the item wash-17 : [212, 190, 90] INFO:root:Position of the item wash-18 : [297, 190, 90] INFO:root:Position of the item server-10 : [395, 95, 170] INFO:root:Position of the item server-11 : [35, 175, 170] INFO:root:Position of the item server-12 : [135, 175, 170] INFO:root:Position of the item server-13 : [235, 175, 170] INFO:root:Position of the item server-14 : [395, 95, 200] INFO:root:Position of the item server-15 : [35, 175, 200] INFO:root:Position of the item server-16 : [135, 175, 200] INFO:root:Position of the item server-17 : [235, 175, 200] INFO:root:Position of the item server-18 : [35, 175, 230] INFO:root:Position of the item server-19 : [135, 175, 230] INFO:root:Position of the item server-20 : [235, 175, 230] INFO:root:Position of the item server-21 : [35, 15, 50] INFO:root:Position of the item server-22 : [35, 15, 50] INFO:root:Position of the item server-23 : [35, 15, 50] INFO:root:Position of the item server-24 : [35, 15, 50] INFO:root:Position of the item server-25 : [35, 15, 50] INFO:root:Position of the item server-26 : [35, 15, 50] INFO:root:Position of the item server-27 : [35, 15, 50] INFO:root:Position of the item server-28 : [35, 15, 50] INFO:root:Position of the item server-29 : [35, 15, 50] INFO:root:Position of the item server-30 : [35, 15, 50] INFO:root:Position of the item server-31 : [35, 15, 50] INFO:root:Position of the item server-32 : [35, 15, 50] INFO:root:Position of the item server-33 : [35, 15, 50] INFO:root:Position of the item server-34 : [35, 15, 50] INFO:root:Position of the item server-35 : [35, 15, 50] INFO:root:Position of the item server-36 : [35, 15, 50] INFO:root:Position of the item server-37 : [35, 15, 50] INFO:root:Position of the item server-38 : [35, 15, 50] INFO:root:Position of the item server-39 : [35, 15, 50] INFO:root:Position of the item server-40 : [35, 15, 50] INFO:root:Position of the item server-41 : [35, 15, 50] INFO:root:Position of the item server-42 : [35, 15, 50]

Example4.py logs :

FITTED ITEMS: partno : Cabinet1 type : cabint color : #842B00 position : [Decimal('0'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet2 type : cabint color : #842B00 position : [Decimal('60'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet3 type : cabint color : #842B00 position : [Decimal('120'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet4 type : cabint color : #842B00 position : [Decimal('180'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet5 type : cabint color : #842B00 position : [Decimal('240'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet6 type : cabint color : #842B00 position : [Decimal('300'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet7 type : cabint color : #842B00 position : [Decimal('360'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet8 type : cabint color : #842B00 position : [Decimal('420'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet9 type : cabint color : #842B00 position : [Decimal('480'), Decimal('0'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet10 type : cabint color : #842B00 position : [Decimal('0'), Decimal('80'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet11 type : cabint color : #842B00 position : [Decimal('60'), Decimal('80'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet12 type : cabint color : #842B00 position : [Decimal('120'), Decimal('80'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet13 type : cabint color : #842B00 position : [Decimal('180'), Decimal('80'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet14 type : cabint color : #842B00 position : [Decimal('240'), Decimal('80'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Cabinet15 type : cabint color : #842B00 position : [Decimal('300'), Decimal('80'), Decimal('0')] rotation type : 0 WHD : 6080200 volume : 960000.0 weight : 80.0


partno : Dyson DC34 Animal1 type : Dyson color : #FF0000 position : [Decimal('540'), Decimal('0'), Decimal('0')] rotation type : 3 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal2 type : Dyson color : #FF0000 position : [Decimal('360'), Decimal('80'), Decimal('0')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal3 type : Dyson color : #FF0000 position : [Decimal('0'), Decimal('160'), Decimal('0')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal4 type : Dyson color : #FF0000 position : [Decimal('170'), Decimal('160'), Decimal('0')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal5 type : Dyson color : #FF0000 position : [Decimal('530'), Decimal('82'), Decimal('0')] rotation type : 3 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal6 type : Dyson color : #FF0000 position : [Decimal('340'), Decimal('162'), Decimal('0')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal7 type : Dyson color : #FF0000 position : [Decimal('0'), Decimal('0'), Decimal('200')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal8 type : Dyson color : #FF0000 position : [Decimal('170'), Decimal('0'), Decimal('200')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal9 type : Dyson color : #FF0000 position : [Decimal('340'), Decimal('0'), Decimal('200')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal10 type : Dyson color : #FF0000 position : [Decimal('0'), Decimal('82'), Decimal('200')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal11 type : Dyson color : #FF0000 position : [Decimal('170'), Decimal('82'), Decimal('200')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal12 type : Dyson color : #FF0000 position : [Decimal('540'), Decimal('0'), Decimal('170')] rotation type : 4 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal13 type : Dyson color : #FF0000 position : [Decimal('360'), Decimal('80'), Decimal('46')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal14 type : Dyson color : #FF0000 position : [Decimal('0'), Decimal('160'), Decimal('46')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : Dyson DC34 Animal15 type : Dyson color : #FF0000 position : [Decimal('170'), Decimal('160'), Decimal('46')] rotation type : 0 WHD : 1708246 volume : 641240.0 weight : 85.0


partno : wash1 type : wash color : #FFFF37 position : [Decimal('510'), Decimal('164'), Decimal('0')] rotation type : 2 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash2 type : wash color : #FFFF37 position : [Decimal('340'), Decimal('162'), Decimal('46')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash3 type : wash color : #FFFF37 position : [Decimal('425'), Decimal('162'), Decimal('46')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash4 type : wash color : #FFFF37 position : [Decimal('360'), Decimal('80'), Decimal('92')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash5 type : wash color : #FFFF37 position : [Decimal('445'), Decimal('80'), Decimal('92')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash6 type : wash color : #FFFF37 position : [Decimal('0'), Decimal('160'), Decimal('92')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash7 type : wash color : #FFFF37 position : [Decimal('85'), Decimal('160'), Decimal('92')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash8 type : wash color : #FFFF37 position : [Decimal('170'), Decimal('160'), Decimal('92')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash9 type : wash color : #FFFF37 position : [Decimal('255'), Decimal('160'), Decimal('92')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash10 type : wash color : #FFFF37 position : [Decimal('510'), Decimal('164'), Decimal('85')] rotation type : 2 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash11 type : wash color : #FFFF37 position : [Decimal('340'), Decimal('160'), Decimal('106')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash12 type : wash color : #FFFF37 position : [Decimal('340'), Decimal('160'), Decimal('166')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash13 type : wash color : #FFFF37 position : [Decimal('360'), Decimal('82'), Decimal('152')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash14 type : wash color : #FFFF37 position : [Decimal('445'), Decimal('82'), Decimal('152')] rotation type : 0 WHD : 856060 volume : 306000.0 weight : 10.0


partno : Server1 type : server color : #0000E3 position : [Decimal('0'), Decimal('160'), Decimal('152')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server2 type : server color : #0000E3 position : [Decimal('100'), Decimal('160'), Decimal('152')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server3 type : server color : #0000E3 position : [Decimal('200'), Decimal('160'), Decimal('152')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server4 type : server color : #0000E3 position : [Decimal('0'), Decimal('164'), Decimal('182')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server5 type : server color : #0000E3 position : [Decimal('100'), Decimal('164'), Decimal('182')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server6 type : server color : #0000E3 position : [Decimal('200'), Decimal('164'), Decimal('182')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server7 type : server color : #0000E3 position : [Decimal('0'), Decimal('164'), Decimal('212')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server8 type : server color : #0000E3 position : [Decimal('100'), Decimal('164'), Decimal('212')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server9 type : server color : #0000E3 position : [Decimal('200'), Decimal('164'), Decimal('212')] rotation type : 1 WHD : 7010030 volume : 210000.0 weight : 20.0



UNFITTED ITEMS: partno : wash15 type : wash color : #FFFF37 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash16 type : wash color : #FFFF37 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash17 type : wash color : #FFFF37 WHD : 856060 volume : 306000.0 weight : 10.0


partno : wash18 type : wash color : #FFFF37 WHD : 856060 volume : 306000.0 weight : 10.0


partno : Server10 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server11 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server12 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server13 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server14 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server15 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server16 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server17 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server18 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server19 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server20 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server21 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server22 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server23 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server24 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server25 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server26 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server27 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server28 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server29 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server30 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server31 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server32 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server33 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server34 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server35 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server36 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server37 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server38 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server39 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server40 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server41 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0


partno : Server42 type : server color : #0000E3 WHD : 7010030 volume : 210000.0 weight : 20.0

This bothering me as I don't find the source of this issue. FYI, I'm using the same parameters for the packer function. And here's a sample of my example4.json file :

{ "box": [ { "name": "example 4 contenair", "WHD": [ 589.8, 243.8, 259.1 ], "weight": 28080, "openTop": [ 0 ], "corner": 15 } ], "item": [ { "name": "Dyson DC34 Animal", "WHD": [ 170, 82, 46 ], "count": 15, "updown": true, "type": "cube", "level": 1, "loadbear": 100, "weight": 85.12, "color": "1" }, { "name": "wash", "WHD": [ 85, 60, 60 ], "count": 18, "updown": true, "type": "cube", "level": 1, "loadbear": 100, "weight": 10, "color": "6" }, { "name": "cabint", "WHD": [ 60, 80, 200 ], "count": 15, "updown": true, "type": "cube", "level": 1, "loadbear": 100, "weight": 80, "color": "3" }, { "name": "server", "WHD": [ 70, 100, 30 ], "count": 42, "updown": true, "type": "cube", "level": 1, "loadbear": 100, "weight": 20, "color": "4" } ], "binding": [ [ "server", "cabint", "wash" ] ] }

PS : thank you for your work, it's a great project.

Nissou31 commented 1 year ago

To complete my issue, here's the result from my app : image

The gap between those item shouldn't be there, as two of the boxes are packed in top of a small surface.

jerry800416 commented 1 year ago

@Nissou31 : I am sorry for forgetting to update this file, the correction of the api file will be corrected in the next version update.

Nissou31 commented 4 months ago

Hello, any news update the updated version ?