3d-bin-packing 中文文档教程

发布于 8年前 浏览 28 项目主页 更新于 3年前

Packer

具有多个包装纸(盒子)的 3D 装箱。

Red Printing

Red-Printing是Betterway-systems支持的印刷服务品牌。

레드 프린팅은 베러웨이시스템즈에서 실시하는 인쇄 서비스의 브랜드 명입니다。 많은이용바랍니다。

Packer를 이용하시는 여러분, 인쇄 주문은 꼭 레드프린팅에서해 주세요。

http://redprinting.co.kr/

Author

References

Demo

Packer Demo GIF

  • Web: http://betterwaysystems.github.io/packer/demo
  • Video: http://betterwaysystems.github.io/packer/demo/packer.mp4
Programming
  • API Documents
    • C++ API Document: http://betterwaysystems.github.io/packer/api/cpp/
    • TypeScript API Document: http://betterwaysystems.github.io/packer/api/ts
Algorithm from Airforce Bin Packing

Installation

Node.JS
npm install -g 3d-bin-packing
tsd install 3d-bin-packing
TypeScript (JavaScript) only

如果你想要 TypeScript (JavaScript ) only 模式,不需要任何安装程序。

  • http://betterwaysystems.github.io/packer/demo/
  • release/ts/index.html
Build Cloud Server

但是,如果要安装 C++ 模式,则必须安装 Visual C++ Redistributable for Visual Studio 2015。安装后,执行 release/cpp/Packer.exe。 然后会开启一个云服务器扣壳解决方案。 运行云服务器后,打开release/browser/index.html

你也可以分离云服务器(C++)和客户端(Web),让用户连接远程Packer服务器,通过在release/browser/server.xml

  • https://www.microsoft.com/en-US/download/details.aspx?id=48145
  • release/cpp/Packer.exe
  • release/browser/index.html
  • release/browser/server.xml

Implementation

Design

alt text

Languages
  • C++
  • Server solving packing problem.
  • Deduct the best optimization result with genetic algorithm
  • TypeScript
  1. Act a role of client connecting to C++ server.
  2. Do packing itself without C++ server and do not use genetic algorithm.
    • The optimization result can be inferior than C++
Dependency
  • C++
    • Samchon Framework (SDN Framework) - https://github.com/samchon/framework
  • TypeScript (JavaScript)
    • TypeScript-STL (STL containers and algorithms for TypeScript) - https://github.com/samchon/typescript-stl
    • Samchon Framework (SDN Framework) - https://github.com/samchon/framework
    • Three.js (JavaScript library handling 3-D objects) - http://threejs.org
    • React - https://facebook.github.io/react
    • React-Data-Grid - https://github.com/adazzle/react-data-grid

Usage

TypeScript (Node.JS)
import packer = require("3d-bin-packing");
import samchon = require("samchon-framework");

function main(): void
{
    ///////////////////////////
    // CONSTRUCT OBJECTS
    ///////////////////////////
    let wrapperArray: packer.WrapperArray = new packer.WrapperArray();
    let instanceArray: packer.InstanceArray = new packer.InstanceArray();

    // Wrappers
    wrapperArray.push
    (
        new packer.Wrapper("Large", 1000, 40, 40, 15, 0),
        new packer.Wrapper("Medium", 700, 20, 20, 10, 0),
        new packer.Wrapper("Small", 500, 15, 15, 8, 0)
    );

    ///////
    // Each Instance is repeated #15
    ///////
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Eraser", 1, 2, 5));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Book", 15, 30, 3));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Drink", 3, 3, 10));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Umbrella", 5, 5, 20));

    // Wrappers also can be packed into another Wrapper.
    instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Notebook-Box", 2000, 30, 40, 4, 2));
    instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Tablet-Box", 2500, 20, 28, 2, 0));

    ///////////////////////////
    // BEGINS PACKING
    ///////////////////////////
    // CONSTRUCT PACKER
    let my_packer: packer.Packer = new packer.Packer(wrapperArray, instanceArray);

    ///////
    // PACK (OPTIMIZE)
    let result: packer.WrapperArray = my_packer.optimize();
    ///////

    ///////////////////////////
    // TRACE PACKING RESULT
    ///////////////////////////
    let xml: samchon.library.XML = result.toXML();
    console.log(xml.toString());
}

main();
C++
#include <iostream>
#include <bws/packer/Packer.hpp>

#include <bws/packer/WrapperArray.hpp>
#include <bws/packer/InstanceArray.hpp>
# include <bws/packer/Product.hpp>
# include <bws/packer/Wrapper.hpp>

using namespace std;
using namespace samchon::library;
using namespace bws::packer;

int main()
{
    ///////////////////////////
    // CONSTRUCT OBJECTS
    ///////////////////////////
    shared_ptr<WrapperArray> wrapperArray(new WrapperArray());
    shared_ptr<InstanceArray> instanceArray(new InstanceArray());

    // Wrappers
    wrapperArray->emplace_back(new bws.packer.Wrapper("Large", 1000, 40, 40, 15, 0));
    wrapperArray->emplace_back(new Wrapper("Medium", 700, 20, 20, 10, 0));
    wrapperArray->emplace_back(new Wrapper("Small", 500, 15, 15, 8, 0));

    ///////
    // Each Instance is repeated #15
    ///////
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Eraser", 1, 2, 5));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Book", 15, 30, 3));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Drink", 3, 3, 10));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Umbrella", 5, 5, 20));

    // Wrappers also can be packed into another Wrapper.
    instanceArray->insert(instanceArray->end(), 15, make_shared<Wrapper>("Notebook-Box", 2000, 30, 40, 4, 2));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Wrapper>("Tablet-Box", 2500, 20, 28, 2, 0));

    ///////////////////////////
    // BEGINS PACKING
    ///////////////////////////
    // CONSTRUCT PACKER
    Packer packer(wrapperArray, instanceArray);
    GAParameters gaParams = {500, 100, 50, 0.2};

    ///////
    // PACK (OPTIMIZE)
    ///////
    shared_ptr<WrapperArray> &result = packer.optimize(gaParams);

    ///////////////////////////
    // TRACE PACKING RESULT
    ///////////////////////////
    shared_ptr<XML> xml = result->toXML();
    cout << xml->toString() << endl;

    return 0;
}

License

BSD v3.

版权所有 (c) 2016,betterwaysystems 版权所有。

以源代码和二进制形式重新分发和使用,有或没有 如果满足以下条件,则允许修改:

  • 源代码的重新分发必须保留上述版权声明,本 条件列表和以下免责声明。

  • 以二进制形式重新分发必须复制上述版权声明, 此条件列表和文档中的以下免责声明 和/或随分发提供的其他材料。

  • 既不是包装商的名字也不是它的名字 贡献者可用于认可或推广源自 本软件未经特定的事先书面许可。

本软件由版权持有者和贡献者“按原样”提供 以及任何明示或暗示的保证,包括但不限于 对适销性和特定用途的适用性的默示保证是 免责声明。 在任何情况下,版权持有者或贡献者均不承担任何责任 对于任何直接的、间接的、偶然的、特殊的、示范性的或后果性的 损坏(包括但不限于采购替代品或 服务; 使用、数据或利润的损失; 或业务中断)但是 引起和任何责任理论,无论是在合同中,严格责任, 或以任何方式因使用而引起的侵权行为(包括疏忽或其他) 本软件,即使被告知此类损坏的可能性。

Packer

3D Bin Packing with multiple wrappers (boxes).

Red Printing

Red-Printing is a brand name of printing service supported by Betterway-systems.

레드 프린팅은 베러웨이시스템즈에서 실시하는 인쇄 서비스의 브랜드 명입니다. 많은 이용 바랍니다.

Packer를 이용하시는 여러분, 인쇄 주문은 꼭 레드프린팅에서 해 주세요.

http://redprinting.co.kr/

Author

References

Demo

Packer Demo GIF

  • Web: http://betterwaysystems.github.io/packer/demo
  • Video: http://betterwaysystems.github.io/packer/demo/packer.mp4
Programming
  • API Documents
    • C++ API Document: http://betterwaysystems.github.io/packer/api/cpp/
    • TypeScript API Document: http://betterwaysystems.github.io/packer/api/ts
Algorithm from Airforce Bin Packing

Installation

Node.JS
npm install -g 3d-bin-packing
tsd install 3d-bin-packing
TypeScript (JavaScript) only

If you want the TypeScript (JavaScript) only mode, any installation procedure is not required.

  • http://betterwaysystems.github.io/packer/demo/
  • release/ts/index.html
Build Cloud Server

However, if you want to install the C++ mode, you've to install Visual C++ Redistributable for Visual Studio 2015. After the installation, execute release/cpp/Packer.exe. Then a cloud server deducting packer solution will be opened. After running the cloud server, open release/browser/index.html.

You also can separate cloud server(C++) and clients(Web), let users to connect remote Packer server, by editing ip address in release/browser/server.xml

  • https://www.microsoft.com/en-US/download/details.aspx?id=48145
  • release/cpp/Packer.exe
  • release/browser/index.html
  • release/browser/server.xml

Implementation

Design

alt text

Languages
  • C++
  • Server solving packing problem.
  • Deduct the best optimization result with genetic algorithm
  • TypeScript
  1. Act a role of client connecting to C++ server.
  2. Do packing itself without C++ server and do not use genetic algorithm.
    • The optimization result can be inferior than C++
Dependency
  • C++
    • Samchon Framework (SDN Framework) - https://github.com/samchon/framework
  • TypeScript (JavaScript)
    • TypeScript-STL (STL containers and algorithms for TypeScript) - https://github.com/samchon/typescript-stl
    • Samchon Framework (SDN Framework) - https://github.com/samchon/framework
    • Three.js (JavaScript library handling 3-D objects) - http://threejs.org
    • React - https://facebook.github.io/react
    • React-Data-Grid - https://github.com/adazzle/react-data-grid

Usage

TypeScript (Node.JS)
import packer = require("3d-bin-packing");
import samchon = require("samchon-framework");

function main(): void
{
    ///////////////////////////
    // CONSTRUCT OBJECTS
    ///////////////////////////
    let wrapperArray: packer.WrapperArray = new packer.WrapperArray();
    let instanceArray: packer.InstanceArray = new packer.InstanceArray();

    // Wrappers
    wrapperArray.push
    (
        new packer.Wrapper("Large", 1000, 40, 40, 15, 0),
        new packer.Wrapper("Medium", 700, 20, 20, 10, 0),
        new packer.Wrapper("Small", 500, 15, 15, 8, 0)
    );

    ///////
    // Each Instance is repeated #15
    ///////
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Eraser", 1, 2, 5));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Book", 15, 30, 3));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Drink", 3, 3, 10));
    instanceArray.insert(instanceArray.end(), 15, new packer.Product("Umbrella", 5, 5, 20));

    // Wrappers also can be packed into another Wrapper.
    instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Notebook-Box", 2000, 30, 40, 4, 2));
    instanceArray.insert(instanceArray.end(), 15, new packer.Wrapper("Tablet-Box", 2500, 20, 28, 2, 0));

    ///////////////////////////
    // BEGINS PACKING
    ///////////////////////////
    // CONSTRUCT PACKER
    let my_packer: packer.Packer = new packer.Packer(wrapperArray, instanceArray);

    ///////
    // PACK (OPTIMIZE)
    let result: packer.WrapperArray = my_packer.optimize();
    ///////

    ///////////////////////////
    // TRACE PACKING RESULT
    ///////////////////////////
    let xml: samchon.library.XML = result.toXML();
    console.log(xml.toString());
}

main();
C++
#include <iostream>
#include <bws/packer/Packer.hpp>

#include <bws/packer/WrapperArray.hpp>
#include <bws/packer/InstanceArray.hpp>
# include <bws/packer/Product.hpp>
# include <bws/packer/Wrapper.hpp>

using namespace std;
using namespace samchon::library;
using namespace bws::packer;

int main()
{
    ///////////////////////////
    // CONSTRUCT OBJECTS
    ///////////////////////////
    shared_ptr<WrapperArray> wrapperArray(new WrapperArray());
    shared_ptr<InstanceArray> instanceArray(new InstanceArray());

    // Wrappers
    wrapperArray->emplace_back(new bws.packer.Wrapper("Large", 1000, 40, 40, 15, 0));
    wrapperArray->emplace_back(new Wrapper("Medium", 700, 20, 20, 10, 0));
    wrapperArray->emplace_back(new Wrapper("Small", 500, 15, 15, 8, 0));

    ///////
    // Each Instance is repeated #15
    ///////
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Eraser", 1, 2, 5));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Book", 15, 30, 3));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Drink", 3, 3, 10));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Product>("Umbrella", 5, 5, 20));

    // Wrappers also can be packed into another Wrapper.
    instanceArray->insert(instanceArray->end(), 15, make_shared<Wrapper>("Notebook-Box", 2000, 30, 40, 4, 2));
    instanceArray->insert(instanceArray->end(), 15, make_shared<Wrapper>("Tablet-Box", 2500, 20, 28, 2, 0));

    ///////////////////////////
    // BEGINS PACKING
    ///////////////////////////
    // CONSTRUCT PACKER
    Packer packer(wrapperArray, instanceArray);
    GAParameters gaParams = {500, 100, 50, 0.2};

    ///////
    // PACK (OPTIMIZE)
    ///////
    shared_ptr<WrapperArray> &result = packer.optimize(gaParams);

    ///////////////////////////
    // TRACE PACKING RESULT
    ///////////////////////////
    shared_ptr<XML> xml = result->toXML();
    cout << xml->toString() << endl;

    return 0;
}

License

BSD v3.

Copyright (c) 2016, betterwaysystems All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of packer nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文