diff --git a/__test__/Interfere/intf.test.ts b/__test__/Interfere/intf.test.ts index 37713167f..3e33a8bd3 100644 --- a/__test__/Interfere/intf.test.ts +++ b/__test__/Interfere/intf.test.ts @@ -1,7 +1,8 @@ import { Contour } from "../../src/DatabaseServices/Contour"; +import { Board } from "../../src/DatabaseServices/Entity/Board"; import { Polyline } from "../../src/DatabaseServices/Entity/Polyline"; import "../Utils/jest.util"; -import { LoadEntityFromFileData } from "../Utils/LoadEntity.util"; +import { LoadBoardsFromFileData, LoadEntityFromFileData } from "../Utils/LoadEntity.util"; test('求交集错误', () => { @@ -22,3 +23,14 @@ test('求交集错误', () => for (let c of res.intersectionList) expect(c.Length).toMatchNumberSnapshot(); }); + + +test('obb 无法求交', () => +{ + let d = + { "file": [2, "Board", 10, 2, 100, 0, 1, 2, 71, [0, -1.8369701987210297e-16, -1, 0, -1, 0, 0, 0, 0, 1, -1.8369701987210297e-16, 0, 2119.1214642262894, 559.840266222962, 462, 1], 0, 0, 1, [1, 0, 0, 0, 0, -1.8369701987210297e-16, -1, 0, 0, 1, -1.8369701987210297e-16, 0, 2119.1214642262894, 559.840266222962, 462, 1], 0, 0, 1, 3, 1892, 462, 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, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 2, 4, [0, 0], 0, [462, 0], 0, [462, 1892], 0, [0, 1892], 0, true, 0, 3, 0, 0, 0, 0, 0, 11, 0, "层板", "2", "榻榻米", "18里精致灰生态板", "生态板", "精致灰", 0, 0, "xxx三", 2, 0, "1", "1", "1", "1", "", "", "", 4, "xxx三", "xxx三", "xxx三", "xxx三", false, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null, "Board", 10, 2, 101, 0, 1, 2, 71, [0, 1, -2.828030789094926e-16, 0, 4.281864857152846e-9, 2.828030789094926e-16, 1, 0, 1, 0, 0, 0, 1164.1214642262896, -4.159733777038266, 60, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, -2.828030789094926e-16, 0, 4.281864857152846e-9, 2.828030789094926e-16, 1, 0, 1164.1214642262896, -4.159733777038266, 60, 1], 0, 0, 1, 3, 402, 582, 18, false, "Polyline", 10, 2, 0, 0, 0, 7, 71, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 352.00000000000017, 0, 1], 0, 0, 1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, 1, 2, 6, [582, -352.00000000000017], 0, [582, 49.99999999999983], 0, [18, 49.99999999999983], 0, [18, 5.684341886080802e-14], 0, [0, 0], 0, [0, -352.00000000000017], 0, true, 0, 3, 0, 0, 0, 0, 0, 11, 1, "立板", "2", "榻榻米", "18里精致灰生态板", "生态板", "精致灰", 0, 0, "xxx三", 2, 6, 1, 1, 1, 1, 1, 1, "1", "1", "1", "1", "", "", "", 6, "xxx三", "xxx三", "xxx三", "xxx三", "xxx三", "xxx三", true, true, 0, 0, 0, 0, 0, 0, 0, 0, true, 0, 0, null], "basePt": { "x": 227.1214642262894, "y": -4.159733777038266, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] }; + + let brs = LoadBoardsFromFileData(d) as Board[]; + + expect(brs[0].OBB.intersectsOBB(brs[1].OBB)).toBeTruthy(); +}); diff --git a/src/Common/InterfereUtil.ts b/src/Common/InterfereUtil.ts index e23e56200..216832b38 100644 --- a/src/Common/InterfereUtil.ts +++ b/src/Common/InterfereUtil.ts @@ -1,8 +1,6 @@ import { Geom3 } from "@jscad/modeling/src/geometries/types"; import { Box3, Material, Mesh } from "three"; import { OBB } from "three/examples/jsm/math/OBB"; -import { FuzzyFactory } from "../csg/core/FuzzyFactory"; -import { CSG2Geometry2, Geometry2CSG2 } from "../csg/core/Geometry2CSG"; import { ExtrudeHole } from "../DatabaseServices/3DSolid/ExtrudeHole"; import { SweepSolid } from "../DatabaseServices/3DSolid/SweepSolid"; import { Board } from "../DatabaseServices/Entity/Board"; @@ -14,8 +12,10 @@ import { ProcessingGroupRecord } from "../DatabaseServices/ProcessingGroup/Proce import { TemplateLatticeRecord } from "../DatabaseServices/Template/ProgramTempate/TemplateLatticeRecord"; import { TemplateWineRackRecord } from "../DatabaseServices/Template/ProgramTempate/TemplateWineRackRecord"; import { BoxIsSolid } from "../Geometry/Box"; -import { ColorMaterial } from "./ColorPalette"; +import { FuzzyFactory } from "../csg/core/FuzzyFactory"; +import { CSG2Geometry2, Geometry2CSG2 } from "../csg/core/Geometry2CSG"; import { CSGIntersect } from "./CSGIntersect"; +import { ColorMaterial } from "./ColorPalette"; import { Log, LogType } from "./Log"; import { Sleep } from "./Sleep"; @@ -126,7 +126,8 @@ export class CheckInterfereTool if (!box1.intersectsBox(this.GetBox(e2))) continue; - if (!obb1.intersectsOBB(this.GetOBB(e2))) + let obb2 = this.GetOBB(e2); + if (!obb1.intersectsOBB(obb2)) continue; function EntityTypeCode(ext: Entity): 0 | 1 | 2 diff --git a/src/DatabaseServices/Entity/Entity.ts b/src/DatabaseServices/Entity/Entity.ts index 377e8bc56..5ecf1a735 100644 --- a/src/DatabaseServices/Entity/Entity.ts +++ b/src/DatabaseServices/Entity/Entity.ts @@ -1,4 +1,4 @@ -import { Material, Matrix3, Matrix4, MeshStandardMaterial, Object3D, Vector3 } from 'three'; +import { Material, Matrix3, Matrix4, MeshStandardMaterial, Object3D, Quaternion, Vector3 } from 'three'; import { OBB } from 'three/examples/jsm/math/OBB'; import { iaop } from 'xaop'; import { HostApplicationServices } from '../../ApplicationServices/HostApplicationServices'; @@ -169,7 +169,8 @@ export class Entity extends CADObject let center = box.getCenter(new Vector3); center.applyMatrix4(ocs); let size = box.getSize(new Vector3).multiplyScalar(0.5); - return new OBB(center, size, new Matrix3().setFromMatrix4(ocs)); + let qua = new Quaternion().setFromRotationMatrix(ocs);//因为ijk变了 所以obb 错了 + return new OBB(center, size, new Matrix3().setFromMatrix4(new Matrix4().makeRotationFromQuaternion(qua))); } /** diff --git a/src/UI/Components/MainContent/MainContent.tsx b/src/UI/Components/MainContent/MainContent.tsx index 1d2444cd2..ccb8af3d5 100644 --- a/src/UI/Components/MainContent/MainContent.tsx +++ b/src/UI/Components/MainContent/MainContent.tsx @@ -4,10 +4,10 @@ import * as React from 'react'; import { app } from '../../../ApplicationServices/Application'; import { IsDev } from '../../../Common/Deving'; import { ResourcesCDN_HOST, SignUrl } from '../../../Common/HostUrl'; -import { inflateBase64 } from '../../../Common/inflate'; import { Post, RequestStatus } from '../../../Common/Request'; import { StoreageKeys } from '../../../Common/StoreageKeys'; import { ZINDEX } from '../../../Common/ZIndex'; +import { inflateBase64 } from '../../../Common/inflate'; import { CADFiler } from '../../../DatabaseServices/CADFiler'; import { FileServer } from '../../../DatabaseServices/FileServer'; import { TopPanelStore } from '../../Store/TopPanelStore'; @@ -47,6 +47,8 @@ export class MainContent extends React.Component<{ store?: TopPanelStore; }> let lastId = searchParams.get("lastid"); if (lastId) localStorage.setItem(StoreageKeys.LastOpenFileId, lastId); + else if (IsDev()) + lastId = localStorage.getItem(StoreageKeys.LastOpenFileId); if (data.ext_info.if_admin === 1) GalleryStore.GetInstance().isAdmin = 1; else GalleryStore.GetInstance().isAdmin = 0;