修复:干涉检查错误

pull/1948/MERGE
ChenX 2 years ago
parent cde09ddbeb
commit 54dc1b47d2

@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`求交集错误 1`] = `2`;
exports[`求交集错误 2`] = `1`;
exports[`求交集错误 3`] = `"7704.00000"`;
exports[`求交集错误 4`] = `"5771.53229"`;
exports[`求交集错误 5`] = `"0.00000"`;

@ -0,0 +1,23 @@
import { Polyline } from "../../src/api";
import { Contour } from "../../src/DatabaseServices/Contour";
import "../Utils/jest.util";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
test('求交集错误', () =>
{
let d = [2, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 2, 4, [9.094947017729282e-12, -1411.0000000000002], 0, [9.094947017729282e-12, 2423], 0, [-17.999999999990905, 2423], 0, [-17.999999999990905, -1411.0000000000002], 0, true, "Polyline", 8, 2, 0, false, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5140442132778844, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5140442132778844, 0, 0, 1], 0, 2, 8, [540, 0], 0, [540, 102], 0, [552, 102], 0, [561, 2329], 0, [-0.5140442132778844, 2329], 0, [-0.5140442132778844, 2329], 0, [-0.5140442132778844, 2329], 0, [0, 0], 0, true];
let pls = LoadEntityFromFileData(d) as Polyline[];
let cons = pls.map(pl => Contour.CreateContour(pl));
let res = cons[0].GetIntersetAndUnionList(cons[1]);
expect(res.unionList.length).toMatchSnapshot();
expect(res.intersectionList.length).toMatchSnapshot();
for (let c of res.unionList)
expect(c.Length).toMatchNumberSnapshot();
for (let c of res.intersectionList)
expect(c.Length).toMatchNumberSnapshot();
});

@ -547,6 +547,8 @@ export class Polyline extends Curve
} }
GetParamAtDist(dist: number): number GetParamAtDist(dist: number): number
{ {
if (equaln(dist, 0)) return 0;
let cus = this.Explode(); let cus = this.Explode();
for (let i = 0; i < cus.length; i++) for (let i = 0; i < cus.length; i++)
{ {

Loading…
Cancel
Save