|
楼主 |
发表于 2023-2-23 13:21:17
|
显示全部楼层
public (uint, uint) CalculateRowCol(double _width, double _height, double gap, double waferDiameter)
{
double diameter = waferDiameter;
double radius = diameter / 2.0; // 圆的半径,单位为mm
double area = Math.PI * radius * radius; // 圆的面积,单位为平方mm
double width = _width; // 18.03; // 矩形宽,单位为mm
double height = _height; // 17.94; // 矩形高,单位为mm
double rectangleArea = width * height; // 矩形面积,单位为平方mm
uint maxRowCount = (uint)Math.Floor((diameter - height) / (height + gap)) + 1; // 最大行数
uint maxColCount = (uint)Math.Floor((diameter - width) / (width + gap)) + 1; // 最大列数
uint maxDieCount = (uint)Math.Floor(area / rectangleArea); // 圆形区域内最多容纳的矩形数量
//uint rowCount = (uint)Math.Floor(diameter / height); // 每一行矩形的数量
//uint columnCount = (uint)Math.Floor(diameter / width); // 每一列矩形的数量
uint defaultRowCount = (uint)Math.Sqrt(maxDieCount); // 默认行数
uint defaultColCount = (uint)Math.Floor((double)maxDieCount / defaultRowCount); // 默认列数
double maxDensity = 0;
uint bestRowCount = 0;
uint bestColCount = 0;
double halfWidth = width / 2;
double halfHeight = height / 2;
for (uint rowCount = maxRowCount - 1; rowCount <= maxRowCount; rowCount++)
{
for (uint colCount = maxColCount - 1; colCount <= maxColCount; colCount++)
{
uint dieCount = rowCount * colCount;
double totalDieWidth = colCount * dieWidth + (colCount - 1) * gap; // 总宽度
double totalDieHeight = rowCount * dieHeight + (rowCount - 1) * gap; // 总高度
double xMargin = (waferDiameter - totalDieWidth) / 2;
double yMargin = (waferDiameter - totalDieHeight) / 2;
double density = dieCount * dieWidth * dieHeight / (Math.PI * Math.Pow(waferDiameter / 2, 2)); // 密度
if (dieCount > maxDieCount)
{
if (xMargin > width || yMargin > height)
{
continue;
}
else
{
//if (density > maxDensity)
{
//maxDensity = density;
return (rowCount, colCount);
}
}
}
if (density > maxDensity)
{
maxDensity = density;
bestRowCount = rowCount;
bestColCount = colCount;
}
}
}
// 微调
//if (rowCount * columnCount > maxCount)
//{
// if (width > height)
// {
// columnCount -= 1;
// // 如果超出了最大容纳数,尝试将行数减少一行
// uint newRowCount = (uint)Math.Floor((double)maxCount / columnCount);
// if (newRowCount < rowCount)
// {
// rowCount -= 1;
// }
// }
// else
// {
// // 如果超出了最大容纳数,尝试将行数减少一列
// rowCount -= 1;
// uint newCount = (uint)Math.Floor((double)maxCount / rowCount);
// if (newCount < columnCount)
// {
// columnCount -= 1;
// }
// }
//}
return (bestRowCount, bestColCount);
}
|
|