diff --git a/__test__/Room/RoomParse.test.ts b/__test__/Room/RoomParse.test.ts index e770f28ee..ed007b6a4 100644 --- a/__test__/Room/RoomParse.test.ts +++ b/__test__/Room/RoomParse.test.ts @@ -311,3 +311,12 @@ test('圆弧和直线更好的连接', () => TestWallCurveParse(walls); }); + +test('墙体厚度导致左侧线长度为0', () => +{ + let d = + { "file": [7, "RoomWallLine", 1, 3, 10, 2, 622, 0, 1, 7, 498, [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, 200, 0, 2700, 18168.522308571442, 15251.502132819674, 0, 20009.303680586454, 15251.502132819674, 0, "RoomWallLine", 1, 3, 10, 2, 623, 0, 1, 7, 498, [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, 200, 0, 2700, 20009.303680586454, 15251.502132819674, 0, 20009.303680586454, 15051.502131717672, 0, "RoomWallLine", 1, 3, 10, 2, 624, 0, 1, 7, 498, [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, 200, 0, 2700, 20009.303680586454, 15051.502131717672, 0, 20209.303680586454, 15051.502129513668, 0, "RoomWallLine", 1, 3, 10, 2, 625, 0, 1, 7, 498, [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, 200, 0, 2700, 20209.303680586454, 15051.502129513668, 0, 20209.303680586454, 15251.502132819674, 0, "RoomWallLine", 1, 3, 10, 2, 626, 0, 1, 7, 498, [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, 200, 0, 2700, 20209.303680586454, 15251.502132819674, 0, 21537.951376377354, 15251.502132819674, 0, "RoomWallLine", 1, 3, 10, 2, 627, 0, 1, 7, 498, [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, 200, 0, 2700, 21537.951376377354, 15251.502132819674, 0, 21537.951376377354, 13456.26600336619, 0, "RoomWallLine", 1, 3, 10, 2, 628, 0, 1, 7, 498, [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, 200, 0, 2700, 21537.951376377354, 13456.26600336619, 0, 18168.522308571442, 15251.502132819674, 0], "basePt": { "x": 18121.50004652788, "y": 13368.011219516779, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + let walls = LoadEntityFromFileData(d); + + TestWallCurveParse(walls); +}); diff --git a/__test__/Room/__snapshots__/RoomParse.test.ts.snap b/__test__/Room/__snapshots__/RoomParse.test.ts.snap index 418c147c4..9f952407d 100644 --- a/__test__/Room/__snapshots__/RoomParse.test.ts.snap +++ b/__test__/Room/__snapshots__/RoomParse.test.ts.snap @@ -766,6 +766,94 @@ Array [ ] `; +exports[`墙体厚度导致左侧线长度为0 1`] = ` +Array [ + 2341.1338341636874, + 0, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 2`] = ` +Array [ + 1340.4289098663357, + 0, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 3`] = ` +Array [ + 0, + -200, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 4`] = ` +Array [ + 400, + -0.000004408007953315973, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 5`] = ` +Array [ + 0, + 200.00000440800795, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 6`] = ` +Array [ + 1528.6476957909, + 0, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 7`] = ` +Array [ + 1128.6476957909, + 0, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 8`] = ` +Array [ + 0, + -2061.8245631121354, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 9`] = ` +Array [ + 0, + -1528.6476957948325, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 10`] = ` +Array [ + -3869.7815299545873, + 2061.824563112137, + 0, +] +`; + +exports[`墙体厚度导致左侧线长度为0 11`] = ` +Array [ + -2869.0766056572356, + 1528.6476957948307, + 0, +] +`; + exports[`墙厚度导致的破面 1`] = ` Array [ -2361.953972758025, diff --git a/src/DatabaseServices/Room/Entity/Wall/RoomWallLine.ts b/src/DatabaseServices/Room/Entity/Wall/RoomWallLine.ts index f5f8709ff..c276656f1 100644 --- a/src/DatabaseServices/Room/Entity/Wall/RoomWallLine.ts +++ b/src/DatabaseServices/Room/Entity/Wall/RoomWallLine.ts @@ -1,4 +1,4 @@ -import { Box3, BufferGeometry, Face3, Geometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, Line as TLine, LineSegments, MathUtils, Matrix3, Mesh, Object3D, ShapeUtils, Vector2, Vector3 } from "three"; +import { Box3, BufferGeometry, Face3, Geometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, LineSegments, MathUtils, Matrix3, Mesh, Object3D, ShapeUtils, Line as TLine, Vector2, Vector3 } from "three"; import { Line2 } from "three/examples/jsm/lines/Line2"; import { LineGeometry } from "three/examples/jsm/lines/LineGeometry"; import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices"; @@ -9,14 +9,14 @@ import { ObjectSnapMode } from "../../../../Editor/ObjectSnapMode"; import { Box3Ext } from "../../../../Geometry/Box"; import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils"; import { SubtractRange, Tape } from "../../../../Geometry/ExtrudeMeshGeomBuilder/ExtrudeEdgeGeometry2"; -import { equaln, equalv3, midPoint, MoveMatrix, ZAxis, ZeroVec } from "../../../../Geometry/GeUtils"; +import { MoveMatrix, ZAxis, ZeroVec, equaln, equalv3, midPoint } from "../../../../Geometry/GeUtils"; import { RenderType } from "../../../../GraphicsSystem/RenderType"; import { Factory } from "../../../CADFactory"; import { CADFiler } from "../../../CADFiler"; import { Curve } from "../../../Entity/Curve"; import { Line } from "../../../Entity/Line"; import { GetLineParam } from "../../ParseService/GetCurveParam"; -import { applyMixins, CURVE_FACE_TYPE_KEY, RoomWallBase, WallFaceType } from "./RoomWallBase"; +import { CURVE_FACE_TYPE_KEY, RoomWallBase, WallFaceType, applyMixins } from "./RoomWallBase"; import { WallSnapMode } from "./WallSnapMode"; const SnapTempLine = new Line; @@ -440,6 +440,8 @@ export class RoomWallLine extends RoomWallBase { let tapes = [new Tape(0, 1, 0, this._Height)]; let curveParam = new GetLineParam(curve); + if (curveParam.Length === 0) + return; let holes = this.RealHoles; if (holes.length) @@ -508,6 +510,8 @@ export class RoomWallLine extends RoomWallBase { let tapes = [new Tape(0, 1, 0, this._Height)]; let curveParam = new GetLineParam(curve); + if (curveParam.Length === 0) + return; let holes = this.RealHoles; if (holes.length) diff --git a/src/DatabaseServices/Room/ParseService/RoomWallParse.ts b/src/DatabaseServices/Room/ParseService/RoomWallParse.ts index d4e2b36ce..730afed96 100644 --- a/src/DatabaseServices/Room/ParseService/RoomWallParse.ts +++ b/src/DatabaseServices/Room/ParseService/RoomWallParse.ts @@ -2,7 +2,7 @@ import Flatbush from 'flatbush'; import { Box3, Vector3 } from "three"; import { arrayPushArray } from '../../../Common/ArrayExt'; import { CurveMap, Vertice } from "../../../Geometry/CurveMap"; -import { AsVector2, equalv3, midPoint, SelectNearP } from "../../../Geometry/GeUtils"; +import { AsVector2, SelectNearP, equalv3, midPoint } from "../../../Geometry/GeUtils"; import { CalcRouteAngle, RegionParse } from "../../../Geometry/RegionParse"; import { IntersectOption } from "../../../GraphicsSystem/IntersectWith"; import { EntityEncode2 } from "../../../GraphicsSystem/OffsetPolyline"; @@ -682,6 +682,8 @@ export class RoomWallParse const Trim = (splitCurve: Curve, offsetCurve: Curve, index: number, type: CurveType) => { + if (offsetCurve.Length < 1e-3) return []; + let trim: CurveTrim; if (offsetCurve instanceof Line) {