当前位置: 首页>>代码示例>>C++>>正文


C++ item_t::SpinAxisCalculate方法代码示例

本文整理汇总了C++中item_t::SpinAxisCalculate方法的典型用法代码示例。如果您正苦于以下问题:C++ item_t::SpinAxisCalculate方法的具体用法?C++ item_t::SpinAxisCalculate怎么用?C++ item_t::SpinAxisCalculate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在item_t的用法示例。


在下文中一共展示了item_t::SpinAxisCalculate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: splitBinWidth

bool BoxPacker3D::Fit( bin_t bin,  item_t item, bin_v_t &bins )
{
//    cout << "BoxPacker3D::Fit\n";
//    bin->Print();
//    item->Print();

    if( bin->Fit( item ) )
    {
        // item fits without rotation
    }
    else
    {
        // item does not fit
        // try rotating it

        item->Spin( 1 );
        if( bin->Fit( item ) )
        {
            //cout << "spin 1";
        }
        else
        {
            item->Spin( 1 );
            item->Spin( 2 );
            if( bin->Fit( item ) )
            {
                //cout << "spin 2";
            }
            else
            {
                item->Spin( 2 );
                item->Spin( 3 );
                if( bin->Fit( item ) )
                {
                    //cout << "spin 3";
                }
                else
                {
                    // Does not fit in any orientation
                    // spin back to original and give up
                    //cout << "No fit\n";
                    item->Spin( 3 );
                    return false;
                }
            }
        }
    }

    // packing item

    bin->set_item(item);
    item->setBin( bin->Root( bin )->progid() );
    item->setHLocation( bin->getLocationHeight() );
    item->setWLocation( bin->getLocationWidth() );
    item->setLLocation( bin->getLocationLength() );
    item->SpinAxisCalculate();

//   item->Print();

    splitBinWidth(bin, item);
    splitBinHeight(bin, item);
    splitBinLength(bin, item);


    if (bin->get_x_sub_bin() != NULL)
    {
        // we have created a new bin from the unused space when the item was added to the bin
        // check if this space could be merged with any previously unused space in the user specified bin
        if( ! merger( bin, bin->get_x_sub_bin(), bins ) )
        {

            bins.push_back(bin->get_x_sub_bin());
        }
        else
        {
            // unused space was merged, so forget about it
            bin->set_x_sub_bin( NULL );
        }

    }
    if (bin->get_y_sub_bin() != NULL)
    {
        // we have created a new bin from the unused space when the item was added to the bin
        // check if this space could be merged with any previously unused space in the user specified bin
        if( ! merger( bin, bin->get_y_sub_bin(), bins ) )
        {

            bins.push_back(bin->get_y_sub_bin());
        }
        else
        {
            // unused space was merged, so forget about it
            bin->set_y_sub_bin( NULL );
        }


    }
    if (bin->get_z_sub_bin() != NULL)
    {
        // we have created a new bin from the unused space when the item was added to the bin
//.........这里部分代码省略.........
开发者ID:rockiey,项目名称:Pack,代码行数:101,代码来源:BoxPacker3D.cpp


注:本文中的item_t::SpinAxisCalculate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。