本文整理汇总了C++中Stat::MakeZero方法的典型用法代码示例。如果您正苦于以下问题:C++ Stat::MakeZero方法的具体用法?C++ Stat::MakeZero怎么用?C++ Stat::MakeZero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stat
的用法示例。
在下文中一共展示了Stat::MakeZero方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckAndCalcStat
void OldLayoutResult::CheckAndCalcStat(scalar cutThickness, const Rect& rect, Stat* outStat) const
{
Stat stat;
stat.MakeZero();
stat.Opilki += (double)rect.Size[!s] * (double)std::min(cutThickness, rect.Size[s] - (cut + cutThickness) * kratnostj + cutThickness);
scalar detailsWithCutsLength = 0;
unsigned cuts = 0;
for(Details::const_iterator i = details.begin(); i != details.end(); i++)
{
detailsWithCutsLength += (i->size + cutThickness) * i->num;
cuts += i->num;
}
stat.Opilki += ((cut + cutThickness) * kratnostj - cutThickness) * std::min(cutThickness, rect.Size[!s] - detailsWithCutsLength + cutThickness);
stat.Opilki += (detailsWithCutsLength - cutThickness) * cutThickness * (kratnostj - 1);
stat.Opilki += cut * cutThickness * (cuts - 1) * kratnostj;
Stat remainStat;
Rect remainRect;
remainRect.Size[s] = std::max<scalar>((cut + cutThickness) * kratnostj - cutThickness, 0);
remainRect.Size[!s] = std::max<scalar>(rect.Size[!s] - detailsWithCutsLength, 0);
if(premain != 0)
{
premain->CheckAndCalcStat(cutThickness, remainRect, &remainStat);
}
else
{
remainStat.MakeZero();
remainStat.AddScrap(remainRect);
}
stat += remainStat;
Stat recurseStat;
Rect recurseRect;
recurseRect.Size[s] = std::max<scalar>(rect.Size[s] - (cut + cutThickness) * kratnostj, 0);
recurseRect.Size[!s] = rect.Size[!s];
if(precurse != 0)
{
precurse->CheckAndCalcStat(cutThickness, recurseRect, &recurseStat);
}
else
{
recurseStat.MakeZero();
recurseStat.AddScrap(recurseRect);
}
stat += recurseStat;
*outStat = stat;
}
示例2: NextResult
bool ResultsGenerator::NextResult(Result& out)
{
// check if there are still remaining parts
auto pRemain = m_remains.begin();
for (; pRemain != m_remains.end(); pRemain++)
if (*pRemain > 0)
break;
if (pRemain == m_remains.end())
return false; // no more parts
Result bestResult;
Amounts bestRashod(m_remains.size());
bool first = true;
m_layout2d.ResetCompletedCounter();
for (auto pSheet = m_sheets.begin(); pSheet != m_sheets.end(); pSheet++)
{
Stat stat;
stat.MakeZero();
OldLayoutResult raskroy;
Amounts rashod(m_remains.size());
if (!m_layout2d.Optimize(pSheet->rect, stat, 0, raskroy, rashod))
continue;
if (bestResult.Statistics < stat || first) {
bestResult.amount = m_remains / rashod;
if (ControlRemains && bestResult.amount > pSheet->Amount)
continue; // not enough sheets
bestResult.Statistics = stat;
bestResult.raskroy = raskroy;
bestResult.sheet = pSheet;
bestRashod = rashod;
first = false;
}
}
if (first)
throw CannotSetPartsException(&m_sheets, m_sizes, &m_remains);
m_remains -= bestRashod * bestResult.amount;
RemoveExostedSizes();
if (ControlRemains)
bestResult.sheet->Amount -= bestResult.amount;
#ifdef _DEBUG
CheckResult(bestResult);
#endif
out = bestResult;
return true;
}