Compare commits

...

2 Commits

Author SHA1 Message Date
ChenX
01cac616f5 修复:并集错误 2023-12-20 17:24:49 +08:00
ChenX
6ef1e8d8b0 修复 动态规划导致的结果 2023-12-18 14:09:36 +08:00
4 changed files with 40 additions and 30 deletions

View File

@@ -6372,7 +6372,7 @@ class Contour {
hasEqualCus = fastEqualCurve(cu, pl, COMBINE_FUZZ);
if (hasEqualCus) {
//方向相同
if (equalv3(cu.GetFirstDeriv(cu.MidParam).normalize(), pl.GetFirstDeriv(pl.MidParam).normalize(), 1e-3)
if (equalv3(cu.GetFirstDeriv(cu.MidParam).normalize(), pl.GetFirstDeriv(pl.MidParam).normalize(), 1e-2)
=== isEqualNormal) {
unionList.push(pl);
intersectionList.push(pl);
@@ -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

View File

@@ -6363,7 +6363,7 @@ class Contour {
hasEqualCus = fastEqualCurve(cu, pl, COMBINE_FUZZ);
if (hasEqualCus) {
//方向相同
if (equalv3(cu.GetFirstDeriv(cu.MidParam).normalize(), pl.GetFirstDeriv(pl.MidParam).normalize(), 1e-3)
if (equalv3(cu.GetFirstDeriv(cu.MidParam).normalize(), pl.GetFirstDeriv(pl.MidParam).normalize(), 1e-2)
=== isEqualNormal) {
unionList.push(pl);
intersectionList.push(pl);
@@ -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