From 302b81f0a66b9957b8c33b437a8386a52a9a1c3b Mon Sep 17 00:00:00 2001 From: ChenX Date: Thu, 31 Mar 2022 17:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=E6=8F=90=E9=AB=98=E9=9D=A2?= =?UTF-8?q?=E5=9F=9F=E5=88=86=E6=9E=90=E7=9A=84=E7=B2=BE=E5=BA=A6,?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=94=99=E8=AF=AF=E7=9A=84=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E8=A2=AB=E5=88=86=E6=9E=90=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __test__/Room/RoomParse.test.ts | 30 +++++++++++++++---- .../Room/__snapshots__/RoomParse.test.ts.snap | 12 ++++++++ src/Geometry/RegionParse.ts | 2 +- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/__test__/Room/RoomParse.test.ts b/__test__/Room/RoomParse.test.ts index 6014e39df..b108a1900 100644 --- a/__test__/Room/RoomParse.test.ts +++ b/__test__/Room/RoomParse.test.ts @@ -1,6 +1,6 @@ import { Curve } from "../../src/DatabaseServices/Entity/Curve"; import { RoomWallArc } from "../../src/DatabaseServices/Room/Entity/Wall/RoomWallArc"; -import { RoomWallBase } from "../../src/DatabaseServices/Room/Entity/Wall/RoomWallBase"; +import { CURVE_FACE_TYPE_KEY, RoomWallBase } from "../../src/DatabaseServices/Room/Entity/Wall/RoomWallBase"; import { RoomWallLine } from "../../src/DatabaseServices/Room/Entity/Wall/RoomWallLine"; import { RoomWallParse } from "../../src/DatabaseServices/Room/ParseService/RoomWallParse"; import "../Utils/jest.util"; @@ -68,7 +68,7 @@ test('共线墙盖子方向正确性', () => new RoomWallParse(true, undefined, false).Do([walls[0]]); }); -function TestCurve(c: Curve) +function TestCurveDerv(c: Curve) { let derv = c.GetFistDeriv(0); expect(derv.toArray()).toMatchSnapshot(); @@ -79,9 +79,9 @@ function TestWallCurveParse(walls: RoomWallBase[]) for (let w of walls) { - w.LeftCurves.forEach(TestCurve); - w.RightCurves.forEach(TestCurve); - w.LidCurves.forEach(TestCurve); + w.LeftCurves.forEach(TestCurveDerv); + w.RightCurves.forEach(TestCurveDerv); + w.LidCurves.forEach(TestCurveDerv); } } @@ -181,3 +181,23 @@ test('圆弧与直线延伸连接错误', () => new RoomWallParse(true, undefined, false).Do(walls); TestWallCurveParse(walls); }); + +function TestCurveType(c: Curve) +{ + expect(c[CURVE_FACE_TYPE_KEY]).toMatchSnapshot(); +} + +test('因为面域分析导致的墙类型不对', () => +{ + let d = + { "file": [2, "RoomWallLine", 1, 1, 8, 2, 146, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 25294.194645009495, -1243.0158909486802, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 25294.194645009495, -1243.0158909486802, 0, 1], 0, 120, 4540.8123335336095, 1690.993449999878, 0, 8037.34909787654, 3003.6781037037035, 0, "RoomWallArc", 1, 8, 2, 147, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 33875.59985973879, -98.25468714960243, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 33875.59985973879, -98.25468714960243, 0, 1], 0, 120, 2, 1936.89677036127, 1.8555182812506865, 4.681440295344441, true], "basePt": { "x": 29813.9186811755, "y": -2094.4402340246024, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + + let walls = LoadEntityFromFileData(d); + new RoomWallParse(true, undefined, false).Do(walls); + for (let w of walls) + { + w.LeftCurves.forEach(TestCurveType); + w.RightCurves.forEach(TestCurveType); + w.LidCurves.forEach(TestCurveType); + } +}); diff --git a/__test__/Room/__snapshots__/RoomParse.test.ts.snap b/__test__/Room/__snapshots__/RoomParse.test.ts.snap index 5bbeda4a2..0dbfa1d76 100644 --- a/__test__/Room/__snapshots__/RoomParse.test.ts.snap +++ b/__test__/Room/__snapshots__/RoomParse.test.ts.snap @@ -96,6 +96,18 @@ Array [ ] `; +exports[`因为面域分析导致的墙类型不对 1`] = `2`; + +exports[`因为面域分析导致的墙类型不对 2`] = `2`; + +exports[`因为面域分析导致的墙类型不对 3`] = `2`; + +exports[`因为面域分析导致的墙类型不对 4`] = `2`; + +exports[`因为面域分析导致的墙类型不对 5`] = `2`; + +exports[`因为面域分析导致的墙类型不对 6`] = `2`; + exports[`圆弧与直线延伸连接错误 1`] = ` Array [ 1176.591242967297, diff --git a/src/Geometry/RegionParse.ts b/src/Geometry/RegionParse.ts index def3127c0..459673f78 100644 --- a/src/Geometry/RegionParse.ts +++ b/src/Geometry/RegionParse.ts @@ -227,7 +227,7 @@ export class RegionParse { let underPt = arc.Center.add(new Vector3(0, -arc.Radius)); let param = arc.GetParamAtPoint(underPt); - if (param > 0.01 && param < 0.99) + if (param > 1e-4 && param < 0.9999) return arc.GetSplitCurves(param); else return [arc];