Move math utilities to OpenNest.Math namespace
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest
|
||||
{
|
||||
@@ -18,18 +19,18 @@ namespace OpenNest
|
||||
}
|
||||
|
||||
count1 = 0;
|
||||
count2 = (int)Math.Floor(overallLength / length2);
|
||||
count2 = (int)System.Math.Floor(overallLength / length2);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (length2 > overallLength)
|
||||
{
|
||||
count1 = (int)Math.Floor(overallLength / length1);
|
||||
count1 = (int)System.Math.Floor(overallLength / length1);
|
||||
count2 = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
var maxCountLength1 = (int)Math.Floor(overallLength / length1);
|
||||
var maxCountLength1 = (int)System.Math.Floor(overallLength / length1);
|
||||
|
||||
count1 = maxCountLength1;
|
||||
count2 = 0;
|
||||
@@ -45,7 +46,7 @@ namespace OpenNest
|
||||
|
||||
if (remnant1 >= length2)
|
||||
{
|
||||
var countLength2 = (int)Math.Floor(remnant1 / length2);
|
||||
var countLength2 = (int)System.Math.Floor(remnant1 / length2);
|
||||
var remnant2 = remnant1 - length2 * countLength2;
|
||||
|
||||
if (!(remnant2 < remnant))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.CirclePacking
|
||||
{
|
||||
@@ -15,7 +16,7 @@ namespace OpenNest.CirclePacking
|
||||
Bin.Right - item.BoundingBox.Right + Tolerance.Epsilon,
|
||||
Bin.Top - item.BoundingBox.Top + Tolerance.Epsilon);
|
||||
|
||||
var rows = Math.Floor((Bin.Height + Tolerance.Epsilon) / (item.Diameter));
|
||||
var rows = System.Math.Floor((Bin.Height + Tolerance.Epsilon) / (item.Diameter));
|
||||
|
||||
var diameter = item.Diameter;
|
||||
var remaining = Bin.Height - diameter * rows;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.CirclePacking
|
||||
{
|
||||
@@ -33,7 +34,7 @@ namespace OpenNest.CirclePacking
|
||||
bin.Right - item.BoundingBox.Right + Tolerance.Epsilon,
|
||||
bin.Top - item.BoundingBox.Top + Tolerance.Epsilon);
|
||||
|
||||
var count = Math.Floor((bin.Width + Tolerance.Epsilon) / item.Diameter);
|
||||
var count = System.Math.Floor((bin.Width + Tolerance.Epsilon) / item.Diameter);
|
||||
|
||||
if (count == 0)
|
||||
return bin;
|
||||
@@ -69,7 +70,7 @@ namespace OpenNest.CirclePacking
|
||||
Bin.Right - item.BoundingBox.Right + Tolerance.Epsilon,
|
||||
Bin.Top - item.BoundingBox.Top + Tolerance.Epsilon);
|
||||
|
||||
var count = Math.Floor((bin.Height + Tolerance.Epsilon) / item.Diameter);
|
||||
var count = System.Math.Floor((bin.Height + Tolerance.Epsilon) / item.Diameter);
|
||||
|
||||
if (count == 0)
|
||||
return bin;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenNest.Math;
|
||||
using OpenNest.RectanglePacking;
|
||||
|
||||
namespace OpenNest
|
||||
@@ -143,7 +144,7 @@ namespace OpenNest
|
||||
var item = items[i];
|
||||
var binItem = ConvertToRectangleItem(item, i);
|
||||
|
||||
int maxQty = (int)Math.Floor(Plate.Area() / binItem.Area());
|
||||
int maxQty = (int)System.Math.Floor(Plate.Area() / binItem.Area());
|
||||
|
||||
int qty = item.Quantity < maxQty
|
||||
? item.Quantity
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.RectanglePacking
|
||||
{
|
||||
@@ -45,8 +46,8 @@ namespace OpenNest.RectanglePacking
|
||||
if (!BestCombination.FindFrom2(item.Width, item.Height, bin.Width, out normalColumns, out rotateColumns))
|
||||
return bin;
|
||||
|
||||
var normalRows = (int)Math.Floor((bin.Height + Tolerance.Epsilon) / item.Height);
|
||||
var rotateRows = (int)Math.Floor((bin.Height + Tolerance.Epsilon) / item.Width);
|
||||
var normalRows = (int)System.Math.Floor((bin.Height + Tolerance.Epsilon) / item.Height);
|
||||
var rotateRows = (int)System.Math.Floor((bin.Height + Tolerance.Epsilon) / item.Width);
|
||||
|
||||
item.Location = bin.Location;
|
||||
|
||||
@@ -70,8 +71,8 @@ namespace OpenNest.RectanglePacking
|
||||
if (!BestCombination.FindFrom2(item.Height, item.Width, Bin.Height, out normalRows, out rotateRows))
|
||||
return bin;
|
||||
|
||||
var normalColumns = (int)Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
|
||||
var rotateColumns = (int)Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Height);
|
||||
var normalColumns = (int)System.Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
|
||||
var rotateColumns = (int)System.Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Height);
|
||||
|
||||
item.Location = bin.Location;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.RectanglePacking
|
||||
{
|
||||
@@ -13,8 +14,8 @@ namespace OpenNest.RectanglePacking
|
||||
|
||||
public override void Fill(Item item)
|
||||
{
|
||||
var ycount = (int)Math.Floor((Bin.Height + Tolerance.Epsilon) / item.Height);
|
||||
var xcount = (int)Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
|
||||
var ycount = (int)System.Math.Floor((Bin.Height + Tolerance.Epsilon) / item.Height);
|
||||
var xcount = (int)System.Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
|
||||
var count = ycount * xcount;
|
||||
|
||||
for (int i = 0; i < xcount; i++)
|
||||
@@ -35,8 +36,8 @@ namespace OpenNest.RectanglePacking
|
||||
|
||||
public override void Fill(Item item, int maxCount)
|
||||
{
|
||||
var ycount = (int)Math.Floor((Bin.Height + Tolerance.Epsilon) / item.Height);
|
||||
var xcount = (int)Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
|
||||
var ycount = (int)System.Math.Floor((Bin.Height + Tolerance.Epsilon) / item.Height);
|
||||
var xcount = (int)System.Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
|
||||
var count = ycount * xcount;
|
||||
|
||||
if (count <= maxCount)
|
||||
@@ -50,13 +51,13 @@ namespace OpenNest.RectanglePacking
|
||||
|
||||
if (NestDirection == NestDirection.Vertical)
|
||||
{
|
||||
columns = (int)Math.Ceiling((double)maxCount / ycount);
|
||||
rows = (int)Math.Ceiling((double)maxCount / columns);
|
||||
columns = (int)System.Math.Ceiling((double)maxCount / ycount);
|
||||
rows = (int)System.Math.Ceiling((double)maxCount / columns);
|
||||
}
|
||||
else
|
||||
{
|
||||
rows = (int)Math.Ceiling((double)maxCount / xcount);
|
||||
columns = (int)Math.Ceiling((double)maxCount / rows);
|
||||
rows = (int)System.Math.Ceiling((double)maxCount / xcount);
|
||||
columns = (int)System.Math.Ceiling((double)maxCount / rows);
|
||||
}
|
||||
|
||||
if (item.Width > item.Height)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.RectanglePacking
|
||||
{
|
||||
internal class FillSameRotation : FillEngine
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.RectanglePacking
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.RectanglePacking
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user