diff --git a/__test__/Polyline/rectOffset.test.ts b/__test__/Polyline/rectOffset.test.ts index 377e68a54..130095ded 100644 --- a/__test__/Polyline/rectOffset.test.ts +++ b/__test__/Polyline/rectOffset.test.ts @@ -92,4 +92,14 @@ describe("矩形偏移", () => expect(rectInfo).toMatchSnapshot(); expect(pl.LineData).toMatchSnapshot(); }); + + test('不是矩形', () => + { + let d = + [1, "Polyline", 10, 2, 0, 0, 0, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 2, 4, [49.95586871614796, 0], 0, [49.96160816995791, 0], 0, [49.95586871614796, 2352.839413948619], 0, [49.95586871614796, 2352.0000499849994], 0, true]; + + let pl = LoadEntityFromFileData(d)[0] as Polyline; + let rectInfo = IsRect(pl); + expect(rectInfo).toBeUndefined(); + }); }); diff --git a/src/Common/CurveUtils.ts b/src/Common/CurveUtils.ts index 758956eb6..dab5c3267 100644 --- a/src/Common/CurveUtils.ts +++ b/src/Common/CurveUtils.ts @@ -9,7 +9,7 @@ import { IsPointInBowArc } from '../DatabaseServices/PointInPolyline'; import { Spline } from '../DatabaseServices/Spline'; import { Count } from '../Geometry/Count'; import { CurveMap, Vertice } from '../Geometry/CurveMap'; -import { AsVector2, AsVector3, equaln, equalv2, equalv3, isIntersect, isParallelTo, XAxis, YAxis, ZAxis, ZeroVec } from '../Geometry/GeUtils'; +import { AsVector2, AsVector3, XAxis, YAxis, ZAxis, ZeroVec, equaln, equalv2, equalv3, isIntersect, isParallelTo } from '../Geometry/GeUtils'; import { Vec3 } from '../Geometry/IVec3'; import { Matrix2 } from '../Geometry/Matrix2'; import { Orbit } from '../Geometry/Orbit'; @@ -585,7 +585,7 @@ export function IsRect(cu: Curve): IRectInfo | undefined preV.copy(nowV).negate();//翻转它 以便下一次计算 } - if (pts4.length === 4 && !crossV)//没有90度 (就不是矩形) + if (pts4.length !== 4 || !crossV)//没有90度 (就不是矩形) return; let rectOCS: Matrix4;