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