修复 动态规划导致的结果
This commit is contained in:
parent
596ab9dba3
commit
6ef1e8d8b0
31
api.cjs.js
31
api.cjs.js
@ -23079,10 +23079,10 @@ function GetMaxAreaFn(rects) {
|
||||
return Max(rects, (t1, t2) => t2[0] > t1[0]);
|
||||
}
|
||||
function GetMaxWidthFn(rects) {
|
||||
return Max(rects, (t1, t2) => t2[5] > t1[5]);
|
||||
return Max(rects, (t1, t2) => t2[5] === t1[5] ? t2[6] > t1[6] : t2[5] > t1[5]);
|
||||
}
|
||||
function GetMaxHeightFn(rects) {
|
||||
return Max(rects, (t1, t2) => t2[6] > t1[6]);
|
||||
return Max(rects, (t1, t2) => t2[6] === t1[6] ? t2[6] > t1[6] : t2[5] > t1[5]);
|
||||
}
|
||||
//最大内接矩形
|
||||
//1.分析盒子
|
||||
@ -23304,7 +23304,8 @@ class LargestInteriorRectangle {
|
||||
rects.push([area, down[i], j, xCount, yCount, width, height]);
|
||||
}
|
||||
}
|
||||
while (rects.length) {
|
||||
// while (rects.length)
|
||||
if (rects.length) {
|
||||
let maxIndex = this.GetMaxRectIndexFn(rects);
|
||||
let [area, maxXIndex, maxYIndex, xCount, yCount] = rects[maxIndex];
|
||||
let xMax = xs[maxXIndex];
|
||||
@ -23320,16 +23321,20 @@ class LargestInteriorRectangle {
|
||||
}
|
||||
}
|
||||
//如果有被标记的方块,则删除它
|
||||
arrayRemoveIf(rects, rect => {
|
||||
let [area, maxX, maxY, xCount, yCount] = rect;
|
||||
for (let i = 0; i < xCount; i++) {
|
||||
for (let j = 0; j < yCount; j++) {
|
||||
if (!matrix[maxX - 1 - i][maxY - j])
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//某些情况不适合这个算法,移除了它,保证结果正确性
|
||||
// arrayRemoveIf(rects, rect =>
|
||||
// {
|
||||
// let [area, maxX, maxY, xCount, yCount] = rect;
|
||||
// for (let i = 0; i < xCount; i++)
|
||||
// {
|
||||
// for (let j = 0; j < yCount; j++)
|
||||
// {
|
||||
// if (!matrix[maxX - 1 - i][maxY - j])
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// });
|
||||
}
|
||||
};
|
||||
let maxRects = [];
|
||||
|
File diff suppressed because one or more lines are too long
31
api.esm.js
31
api.esm.js
@ -23070,10 +23070,10 @@ function GetMaxAreaFn(rects) {
|
||||
return Max(rects, (t1, t2) => t2[0] > t1[0]);
|
||||
}
|
||||
function GetMaxWidthFn(rects) {
|
||||
return Max(rects, (t1, t2) => t2[5] > t1[5]);
|
||||
return Max(rects, (t1, t2) => t2[5] === t1[5] ? t2[6] > t1[6] : t2[5] > t1[5]);
|
||||
}
|
||||
function GetMaxHeightFn(rects) {
|
||||
return Max(rects, (t1, t2) => t2[6] > t1[6]);
|
||||
return Max(rects, (t1, t2) => t2[6] === t1[6] ? t2[6] > t1[6] : t2[5] > t1[5]);
|
||||
}
|
||||
//最大内接矩形
|
||||
//1.分析盒子
|
||||
@ -23295,7 +23295,8 @@ class LargestInteriorRectangle {
|
||||
rects.push([area, down[i], j, xCount, yCount, width, height]);
|
||||
}
|
||||
}
|
||||
while (rects.length) {
|
||||
// while (rects.length)
|
||||
if (rects.length) {
|
||||
let maxIndex = this.GetMaxRectIndexFn(rects);
|
||||
let [area, maxXIndex, maxYIndex, xCount, yCount] = rects[maxIndex];
|
||||
let xMax = xs[maxXIndex];
|
||||
@ -23311,16 +23312,20 @@ class LargestInteriorRectangle {
|
||||
}
|
||||
}
|
||||
//如果有被标记的方块,则删除它
|
||||
arrayRemoveIf(rects, rect => {
|
||||
let [area, maxX, maxY, xCount, yCount] = rect;
|
||||
for (let i = 0; i < xCount; i++) {
|
||||
for (let j = 0; j < yCount; j++) {
|
||||
if (!matrix[maxX - 1 - i][maxY - j])
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//某些情况不适合这个算法,移除了它,保证结果正确性
|
||||
// arrayRemoveIf(rects, rect =>
|
||||
// {
|
||||
// let [area, maxX, maxY, xCount, yCount] = rect;
|
||||
// for (let i = 0; i < xCount; i++)
|
||||
// {
|
||||
// for (let j = 0; j < yCount; j++)
|
||||
// {
|
||||
// if (!matrix[maxX - 1 - i][maxY - j])
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// });
|
||||
}
|
||||
};
|
||||
let maxRects = [];
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user