修复:判断矩形错误导致干涉检查失败

pull/2321/MERGE
ChenX 1 year ago
parent ea1fbad9b8
commit ccfaf50500

@ -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();
});
});

@ -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;

Loading…
Cancel
Save