!1369 修复:多段线偏移错误

pull/1369/MERGE
ChenX 4 years ago
parent 23f56ec968
commit a0f811c677

@ -7,3 +7,11 @@ exports[`圆弧被压扁时 2`] = `"1260.08301"`;
exports[`圆弧被压扁时2 1`] = `1`;
exports[`圆弧被压扁时2 2`] = `"2922.62557"`;
exports[`由于点在线内错误导致的偏移错误 1`] = `1`;
exports[`由于点在线内错误导致的偏移错误 2`] = `"6230.72714"`;
exports[`由于点在线内错误导致的偏移错误 3`] = `1`;
exports[`由于点在线内错误导致的偏移错误 4`] = `"6180.46135"`;

@ -44,3 +44,13 @@ test('圆弧被压扁时2', () =>
testOffset(pl, -15);
});
test('由于点在线内错误导致的偏移错误', () =>
{
let pl = loadFile(
[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, 12, [964.1726917869288, 2166.0000000029972], 0, [81.82735810056852, 2166], 0.3415531568154667, [40.20999509376975, 2133.8164270510624], 0.05489447350760577, [0.000024946672056103125, 1768.2989623206213], 0, [0.00002495866783647216, 437.7012596801617], 0.04953932502193947, [40.21532578137385, 32.163083246120095], 0.3414157136434686, [81.8273581160156, 2.9976945370435715e-9], 0, [964.172691799029, 0], 0.3414157138387472, [1005.7847240515422, 32.16308280570047], 0.049539325021327685, [1046.0000249832037, 437.7009488243086], 0, [1046.0000249590144, 1768.2987401249993], 0.054894473508189726, [1005.7900548890677, 2133.8164267602974], 0.3415531571190822, true, "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, 10, [1050.0000249590144, 1768.298295468967], 0, [1050.0000249836708, 1768.2987401250723], 0.0548944072866294, [1009.6943012621955, 2134.6864039197217], 0.008757597397914658, [1009.6614374965075, 2134.8226060220663], 0.3415531571190834, [964.1726917869152, 2170.0000000029972], 0, [81.82735810055493, 2170], 0.3415531568154657, [36.33861249020625, 2134.8226063277452], 0.008757508805047694, [36.30574877822974, 2134.6864044689264], 0.054894407325456196, [-3.999975077955014, 1768.2989623205858], 0, [-3.99997505332794, 1768.2985179293778], 0, false]
)[0] as Polyline;
testOffset(pl, 4);
testOffset(pl, -4);
});

@ -1,4 +1,6 @@
import { debug } from "request-promise-native";
import { Box3, Matrix4, Vector3 } from "three";
import { TestDraw } from "../Add-on/test/TestUtil";
import { arrayLast } from "../Common/ArrayExt";
import { ConverCircleToPolyline } from "../Common/CurveUtils";
import { Status } from "../Common/Status";
@ -66,7 +68,7 @@ class CurveTreeNode
if (cus.length === 0)
{
let p = this.curve.GetPointAtParam(0.5);
if ((contour.Curve.PtInCurve(p) && !contour.Curve.PtOnCurve(p)))
if (box.containsPoint(p) && (contour.Curve.PtInCurve(p) && !contour.Curve.PtOnCurve(p)))
this.children = [];
}
else
@ -75,7 +77,7 @@ class CurveTreeNode
for (let c of cus)
{
let p = c.GetPointAtParam(0.5);
if (CurveIsFine(c) && (!contour.Curve.PtInCurve(p) || contour.Curve.PtOnCurve(p)))
if (CurveIsFine(c) && (!(box.containsPoint(p) && contour.Curve.PtInCurve(p)) || contour.Curve.PtOnCurve(p)))
this.children.push(new CurveTreeNode(c));
}
if (this.children.length === cus.length)

Loading…
Cancel
Save