!1909 修复:酷家乐导入因为重复点导致的半圆错误

pull/1874/MERGE
ChenX 2 years ago
parent 817d4377bf
commit e2c07eaeaa

@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`删除多段线重复的点 1`] = `
Array [
0,
1,
4,
5,
]
`;
exports[`删除多段线重复的点 2`] = `
Array [
Array [
-0.1,
2,
3,
0.2,
],
]
`;

@ -0,0 +1,12 @@
import { ArrayRemoveDupSavePre } from "../../src/Common/ArrayExt";
test('删除多段线重复的点', () =>
{
let pts = [0, 1, 1, 1, 1, 4, 5, 5, 5];
let buls = [[-0.1, 0.1, 0.5, 1, 2, 3, 4, 0.1, 0.2]];
ArrayRemoveDupSavePre(pts, buls);
expect(pts).toMatchSnapshot();
expect(buls).toMatchSnapshot();
});

@ -1,7 +1,7 @@
import { Intent } from "@blueprintjs/core";
import { Box3, Euler, Matrix4, Vector2, Vector3 } from "three";
import { app } from "../ApplicationServices/Application";
import { arrayLast } from "../Common/ArrayExt";
import { arrayLast, ArrayRemoveDupSavePre } from "../Common/ArrayExt";
import { EBoardKeyList } from "../Common/BoardKeyList";
import { safeEval } from "../Common/eval";
import { FileSystem } from "../Common/FileSystem";
@ -883,24 +883,10 @@ function ParsePathOutlineAndHole(path: KJL_Path, edgeBandingAll?: number[], dril
});
//移除重复的点
let j = 1;
for (let i = 1, l = ptsAll.length; i < l; i++)
if (!(ptsAll[j - 1] === ptsAll[i]))
{
let jplus = j++;
ptsAll[jplus] = ptsAll[i];
radiusAll[jplus] = radiusAll[i];
if (edgeBandingAll)
edgeBandingAll[jplus] = edgeBandingAll[i];
if (drillData?.drillSides)
drillData.drillSides[jplus] = drillData.drillSides[i];
}
ptsAll.length = j;
if (edgeBandingAll)
edgeBandingAll.length = j;
if (drillData?.drillSides)
drillData.drillSides.length = j;;
radiusAll.length = j;
let arrs = [radiusAll];
if (edgeBandingAll) arrs.push(edgeBandingAll);
if (drillData?.drillSides) arrs.push(drillData.drillSides);
ArrayRemoveDupSavePre(ptsAll, arrs);
let polylines: Polyline[] = [];
let edgeBandings: number[][] = [];

@ -91,6 +91,31 @@ export function arrayRemoveDuplicateBySort<T>(arr: Array<T>, checkFuction: (e1:
return arr;
}
//因为多段线的数据关系,我们需要保留下一段的数据
export function ArrayRemoveDupSavePre(baseCompareArray: any[], arrs: (any[])[])
{
let index = 0;//set index
let pre = 0;//前一个点
for (let next = 1; next <= baseCompareArray.length; next++)
{
if (baseCompareArray[pre] !== baseCompareArray[next])
{
baseCompareArray[index] = baseCompareArray[pre];
for (let arr of arrs)
arr[index] = arr[pre];
index++;
}
pre++;
}
baseCompareArray.length = index;
for (let arr of arrs)
arr.length = index;
}
//原地更新数组,注意这个函数并不会比map快.
export function arrayMap<T>(arr: Array<T>, mapFunc: (v: T) => T): Array<T>
{

Loading…
Cancel
Save