修复:在板件插件中,如果法向量相反,刀有洞,导致的切割不正确

pull/2171/head
ChenX 1 year ago
parent 9f5b19609d
commit 9a0ef8b41d

@ -0,0 +1,15 @@
import { Board } from "../../src/DatabaseServices/Entity/Board";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
test('板件插件中,如果法向量相反,刀有洞,导致的切割不正确', () =>
{
let d =
{ "file": [2, "Board", 10, 2, 122, 0, 1, 3, 71, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 857.3549084858569, 557.9750457173377, 0.000012982282000084666, 1], 127, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 857.3549084858569, 557.9750327173376, 0, 1], 0, 0, 1, 3, 797, 297.00000000000006, 18, true, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [6.123233995736766e-17, 1, 0, 0, -1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 297, 0, 0, 1], 0, 0, 1, 2, 4, [297, 0], 0, [0, 1.8186004967338195e-14], 0, [5.684341886080802e-14, 797], 0, [297.00000000000006, 797], 0, true, 0, 1, 1, 1, 1, 0, 1, 125, 11, 2, "金属扣线门板右", "未命名", "自由柜", "", "白色麻面-F4标板", "", 0, 0, null, 2, 4, 0.8, 0.8, 0.8, 0.8, "0.8", "0.8", "0.8", "0.8", "", "", "", 4, null, null, null, null, true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, "Board", 10, 2, 125, 0, 1, 3, 71, [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 905.8549084858569, 539.9750415173377, 748.5, 1], 126, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 904.3549084858569, 545.9750327173377, 47, 1], 0, 0, 1, 3, 700, 200.00000000000006, 6, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, [6.123233995736766e-17, 1, 0, 0, -1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 201.5, -1.5, 0, 1], 0, 0, 1, 2, 8, [200, 0], 0, [0, 1.2434497875801753e-14], 0, [2.842170943040401e-14, 350], 0, [30.00000000000003, 350], 0, [30.00000000000003, 503], 0, [2.842170943040401e-14, 503], 0, [5.684341886080802e-14, 700], 0, [200.00000000000006, 700], 0, true, 1, 3, 194, 694, 6, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -4.5, -4.5, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -4.5, -4.5, 0, 1], 0, 0, 1, 2, 8, [4.5, 4.5], 0, [4.5, 198.5], 0, [348.5, 198.5], 0, [348.5, 168.5], 0, [507.5, 168.5], 0, [507.5, 198.5], 0, [698.5, 198.5], 0, [698.5, 4.5], 0, true, 0, 1.4, 0, 0, 0, 0, 0, [0, 0, -1, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1102.8549084858569, 539.9750415173377, 745.5, 1], 1, 1, 1, 1, 1, 122, 0, 11, 2, "金属扣线3-辅助板", "未命名", "自由柜", "", "水曲柳(默认材质)", "", 0, 0, "无效配置", 2, 8, 1, 1, 1, 1, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 8, null, null, null, null, null, null, null, null, true, true, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0, null], "basePt": { "x": 857.3549084858569, "y": 539.9750415173377, "z": 0.000012982282000084666 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let [br1, br2] = LoadEntityFromFileData(d) as [Board, Board];
br1.Subtract([br2]);
expect(br1.Grooves.length).toBe(1);
expect(br1.Grooves[0].Grooves.length).toBe(1);
});

@ -9,7 +9,7 @@ import { CSGIntersect } from '../../Common/CSGIntersect';
import { equalCurve, PolylineSpliteRect } from "../../Common/CurveUtils";
import { DisposeThreeObj, Object3DRemoveAll } from "../../Common/Dispose";
import { Log } from "../../Common/Log";
import { reviseMirrorMatrix, SetMtxVector, tempMatrix1, TransformVector, Vector2ApplyMatrix4 } from "../../Common/Matrix4Utils";
import { MakeMirrorMtx, reviseMirrorMatrix, tempMatrix1, TransformVector, Vector2ApplyMatrix4 } from "../../Common/Matrix4Utils";
import { Status, UpdateDraw } from "../../Common/Status";
import { Geometry2CSG2 } from "../../csg/core/Geometry2CSG";
import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
@ -1090,12 +1090,11 @@ export class ExtrudeSolid extends Entity
target = target.Clone().ClearDraw();
if (parType === 2)
{
let mtx = target._Matrix;
SetMtxVector(mtx, 2, n1);
let p = n1.setFromMatrixColumn(mtx, 3);
p.add(n2.multiplyScalar(target.thickness));
SetMtxVector(mtx, 3, p);
let p = target.Position;
p.add(n2.clone().multiplyScalar(target.thickness * 0.5));
target.ApplyMatrix(MakeMirrorMtx(n2, p));
}
if (this.GrooveCheckPosition(target) !== Status.True)
return [];

Loading…
Cancel
Save