本文整理汇总了C++中item_t::setWLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ item_t::setWLocation方法的具体用法?C++ item_t::setWLocation怎么用?C++ item_t::setWLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item_t
的用法示例。
在下文中一共展示了item_t::setWLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool BoxPacker3D::checkFitsNoConstr( bin_t bin, item_t item, bin_v_t &bins )
{
cout << "\nBoxPacker3D::checkFitsNoConstr\n";
//sort both bin and item
if (bin->side_1()->size() < bin->side_2()->size())
{
Side *tmps;
tmps = bin->side_1();
bin->set_side_1(bin->side_2());
bin->set_side_2(tmps);
}
if (bin->side_1()->size() < bin->side_3()->size())
{
Side *tmps;
tmps = bin->side_1();
bin->set_side_1(bin->side_3());
bin->set_side_3(tmps);
}
if (bin->side_2()->size() < bin->side_3()->size())
{
Side *tmps;
tmps = bin->side_2();
bin->set_side_2(bin->side_3());
bin->set_side_3(tmps);
}
cout << "DBG1 ";
item->Print();
if (item->side_1()->size() < item->side_2()->size())
{
Side *tmps;
tmps = item->side_1();
item->set_side_1(item->side_2());
item->set_side_2(tmps);
}
if (item->side_1()->size() < item->side_3()->size())
{
Side *tmps;
tmps = item->side_1();
item->set_side_1(item->side_3());
item->set_side_3(tmps);
}
bin->Print();
item->Print();
if (item->side_2()->size() < item->side_3()->size())
{
Side *tmps;
tmps = item->side_2();
item->set_side_2(item->side_3());
item->set_side_3(tmps);
}
cout << "DBG2 ";
item->Print();
if (item->side_1()->size() <= bin->side_1()->size() &&
item->side_2()->size() <= bin->side_2()->size() &&
item->side_3()->size() <= bin->side_3()->size())
{
// packing item
bin->set_item(item);
item->setBin( bin->Root( bin )->progid() );
item->setHLocation( bin->getLocationHeight() );
item->setWLocation( bin->getLocationWidth() );
item->setLLocation( bin->getLocationLength() );
if( item->side_1()->orig_side() == 'w' )
item->SpinAxis( 1 );
else if( item->side_2()->orig_side() == 'h' )
item->SpinAxis( 2 );
else if( item->side_3()->orig_side() == 'l' )
item->SpinAxis( 3 );
else
item->SpinAxis( 0 );
bin->Print();
item->Print();
splitBinWidth(bin, item);
splitBinHeight(bin, item);
splitBinLength(bin, item);
if (bin->get_x_sub_bin() != NULL)
{
//.........这里部分代码省略.........
示例2: 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
//.........这里部分代码省略.........