Simplified BestCombination.FindFrom2
This commit is contained in:
@@ -7,24 +7,21 @@ namespace SawCut
|
|||||||
public static BestComboResult FindFrom2(double length1, double length2, double stockLength)
|
public static BestComboResult FindFrom2(double length1, double length2, double stockLength)
|
||||||
{
|
{
|
||||||
var result = InitializeResult(length1, length2);
|
var result = InitializeResult(length1, length2);
|
||||||
stockLength += Tolerance.Epsilon;
|
|
||||||
|
|
||||||
if (length1 > stockLength)
|
bool item1Fits = length1 <= stockLength;
|
||||||
{
|
bool item2Fits = length2 <= stockLength;
|
||||||
if (length2 > stockLength)
|
|
||||||
|
if (!item1Fits && !item2Fits)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
if (!item1Fits)
|
||||||
return CalculateSingleItemResult(result, length2, stockLength, false);
|
return CalculateSingleItemResult(result, length2, stockLength, false);
|
||||||
}
|
|
||||||
else if (length2 > stockLength)
|
if (!item2Fits)
|
||||||
{
|
|
||||||
return CalculateSingleItemResult(result, length1, stockLength, true);
|
return CalculateSingleItemResult(result, length1, stockLength, true);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return CalculateOptimalCombination(result, length1, length2, stockLength);
|
return CalculateOptimalCombination(result, length1, length2, stockLength);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static BestComboResult InitializeResult(double length1, double length2)
|
private static BestComboResult InitializeResult(double length1, double length2)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user