From 71c148ffd5471ae011b8d989e1bcf0d9e3db957f Mon Sep 17 00:00:00 2001 From: ChenX Date: Thu, 3 Nov 2022 15:45:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E6=9B=B2=E7=BA=BF=E5=9C=A8?= =?UTF-8?q?=E5=8F=B3=E8=A7=86=E5=9B=BE=E4=B8=AD=E6=B1=82=E4=BA=A4=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Interest/3d.test.ts | 15 +++++++++++++++ src/GraphicsSystem/IntersectWith.ts | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 __test__/Interest/3d.test.ts diff --git a/__test__/Interest/3d.test.ts b/__test__/Interest/3d.test.ts new file mode 100644 index 000000000..17aa86bd4 --- /dev/null +++ b/__test__/Interest/3d.test.ts @@ -0,0 +1,15 @@ +import { Curve } from "../../src/DatabaseServices/Entity/Curve"; +import { IntersectOption } from "../../src/GraphicsSystem/IntersectWith"; +import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; + +test('错误的使用2维点判断导致的交点丢失', () => +{ + let d = + { "file": [2, "Polyline", 8, 2, 107, false, 1, 7, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 684.2249657064676, 1564.334705075446, -91.90672153635137, 1], 0, 0, true, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 684.2249657064676, 1564.334705075446, -91.90672153635137, 1], 0, 2, 4, [0, 0], 0, [600, 0], 0, [600, 2000], 0, [0, 2000], 0, true, "Circle", 8, 2, 108, false, 1, 7, 0, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 684.2249657064676, 2164.334705075446, 908.0932784636486, 1], 0, 0, true, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 684.2249657064472, 518.1069958847737, 0, 1], 0, 1, 308.64197530864226], "basePt": { "x": 684.2249657064676, "y": 1564.334705075446, "z": -91.90672153635137 }, "ucs": [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1] }; + + let cus = LoadEntityFromFileData(d) as Curve[]; + + let ipts = cus[0].IntersectWith2(cus[1], IntersectOption.ExtendNone); + + expect(ipts.length).toBe(2); +}); diff --git a/src/GraphicsSystem/IntersectWith.ts b/src/GraphicsSystem/IntersectWith.ts index 17294e99e..43920b928 100644 --- a/src/GraphicsSystem/IntersectWith.ts +++ b/src/GraphicsSystem/IntersectWith.ts @@ -6,7 +6,7 @@ import { Curve } from '../DatabaseServices/Entity/Curve'; import { Ellipse } from '../DatabaseServices/Entity/Ellipse'; import { Line } from '../DatabaseServices/Entity/Line'; import { Polyline } from '../DatabaseServices/Entity/Polyline'; -import { ComparePointFnGenerate, equaln, equalv2, equalv3 } from '../Geometry/GeUtils'; +import { ComparePointFnGenerate, equaln, equalv3 } from '../Geometry/GeUtils'; /** * 相交延伸选项. @@ -459,7 +459,7 @@ export function IntersectPolylineAndCurve(pl: Polyline, cu: Curve, extType: Inte let fn = ComparePointFnGenerate("xyz", tolerance); intRes.sort((p1, p2) => fn(p1.pt, p2.pt)); - arrayRemoveDuplicateBySort(intRes, (p1, p2) => equalv2(p1.pt, p2.pt, tolerance)); + arrayRemoveDuplicateBySort(intRes, (p1, p2) => equalv3(p1.pt, p2.pt, tolerance)); return intRes; }