|
|
@ -1,10 +1,11 @@
|
|
|
|
import { Matrix4, Vector3 } from "three";
|
|
|
|
import { Matrix4, Vector3 } from "three";
|
|
|
|
|
|
|
|
import { MatrixPlanarizere } from "../../Common/Matrix4Utils";
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
import { Board } from "../../DatabaseServices/Entity/Board";
|
|
|
|
import { Line } from "../../DatabaseServices/Entity/Line";
|
|
|
|
import { Line } from "../../DatabaseServices/Entity/Line";
|
|
|
|
import { Region } from "../../DatabaseServices/Entity/Region";
|
|
|
|
import { Region } from "../../DatabaseServices/Entity/Region";
|
|
|
|
import { BoolOpeartionType } from "../../GraphicsSystem/BoolOperateUtils";
|
|
|
|
import { BoolOpeartionType } from "../../GraphicsSystem/BoolOperateUtils";
|
|
|
|
import { Box3Ext } from "../Box";
|
|
|
|
import { Box3Ext } from "../Box";
|
|
|
|
import { XAxis, equaln } from "../GeUtils";
|
|
|
|
import { equaln, XAxis } from "../GeUtils";
|
|
|
|
import { BoardFaceType } from "./BoardGetFace";
|
|
|
|
import { BoardFaceType } from "./BoardGetFace";
|
|
|
|
|
|
|
|
|
|
|
|
export interface BoardFaceParams
|
|
|
|
export interface BoardFaceParams
|
|
|
@ -80,17 +81,15 @@ export class Face
|
|
|
|
Intersect(f: Face): Face[]
|
|
|
|
Intersect(f: Face): Face[]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//获得侧面和非侧面
|
|
|
|
//获得侧面和非侧面
|
|
|
|
let [sideFace, noSideFace] = this.type === BoardFaceType.Side ?
|
|
|
|
let [sideFace, noSideFace] = this.type === BoardFaceType.Side ? [this, f] : [f, this];
|
|
|
|
[this, f] : [f, this];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let sideOcs = sideFace.OCS.clone();
|
|
|
|
|
|
|
|
let interMat = noSideFace.OCS.clone();
|
|
|
|
|
|
|
|
//布尔面和被布尔面得差异矩阵
|
|
|
|
//布尔面和被布尔面得差异矩阵
|
|
|
|
let diffMat = new Matrix4().multiplyMatrices(new Matrix4().getInverse(sideOcs), interMat);
|
|
|
|
let diffMtx = new Matrix4().getInverse(sideFace.OCS).multiply(noSideFace.OCS);
|
|
|
|
|
|
|
|
MatrixPlanarizere(diffMtx);
|
|
|
|
|
|
|
|
|
|
|
|
let isSuccess = false;
|
|
|
|
let isSuccess = false;
|
|
|
|
|
|
|
|
|
|
|
|
let x = new Vector3().setFromMatrixColumn(diffMat, 0);
|
|
|
|
let x = new Vector3().setFromMatrixColumn(diffMtx, 0);
|
|
|
|
let ang = x.angleTo(XAxis);
|
|
|
|
let ang = x.angleTo(XAxis);
|
|
|
|
//盒子旋转0,90,180度不会被破坏
|
|
|
|
//盒子旋转0,90,180度不会被破坏
|
|
|
|
let canUseBoxCalc = equaln(ang, 0) || equaln(ang, Math.PI / 2) || equaln(ang, Math.PI);
|
|
|
|
let canUseBoxCalc = equaln(ang, 0) || equaln(ang, Math.PI / 2) || equaln(ang, Math.PI);
|
|
|
@ -102,7 +101,8 @@ export class Face
|
|
|
|
if (!noSideFace.IsRect || !canUseBoxCalc)
|
|
|
|
if (!noSideFace.IsRect || !canUseBoxCalc)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let sideReg = sideFace.Region;
|
|
|
|
let sideReg = sideFace.Region;
|
|
|
|
isSuccess = sideReg.BooleanOper(noSideFace.Region.Clone().ApplyMatrix(diffMat), BoolOpeartionType.Intersection);
|
|
|
|
let toReg = noSideFace.Region.Clone().ApplyMatrix(diffMtx);
|
|
|
|
|
|
|
|
isSuccess = sideReg.BooleanOper(toReg, BoolOpeartionType.Intersection);
|
|
|
|
for (let s of sideReg.ShapeManager.ShapeList)
|
|
|
|
for (let s of sideReg.ShapeManager.ShapeList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let box = s.BoundingBox as Box3Ext;
|
|
|
|
let box = s.BoundingBox as Box3Ext;
|
|
|
@ -114,8 +114,8 @@ export class Face
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let retBox = new Box3Ext(new Vector3(), new Vector3(sideFace.m_Length, sideFace.m_Width));
|
|
|
|
let retBox = new Box3Ext(new Vector3(), new Vector3(sideFace.m_Length, sideFace.m_Width));
|
|
|
|
|
|
|
|
|
|
|
|
let p1 = new Vector3().applyMatrix4(diffMat).setZ(0);
|
|
|
|
let p1 = new Vector3().setFromMatrixPosition(diffMtx);
|
|
|
|
let p2 = new Vector3(noSideFace.m_Length, noSideFace.m_Width).applyMatrix4(diffMat).setZ(0);
|
|
|
|
let p2 = new Vector3(noSideFace.m_Length, noSideFace.m_Width).applyMatrix4(diffMtx);
|
|
|
|
let box3 = new Box3Ext().setFromPoints([p1, p2]);
|
|
|
|
let box3 = new Box3Ext().setFromPoints([p1, p2]);
|
|
|
|
|
|
|
|
|
|
|
|
if (retBox.intersectsBox(box3))
|
|
|
|
if (retBox.intersectsBox(box3))
|
|
|
@ -143,10 +143,10 @@ export class Face
|
|
|
|
newFace.m_Width = sizes[i].y;
|
|
|
|
newFace.m_Width = sizes[i].y;
|
|
|
|
|
|
|
|
|
|
|
|
let min = retBoxs[i].min;
|
|
|
|
let min = retBoxs[i].min;
|
|
|
|
min.applyMatrix4(sideOcs);
|
|
|
|
min.applyMatrix4(sideFace.OCS);
|
|
|
|
|
|
|
|
|
|
|
|
//构建碰撞面坐标系
|
|
|
|
//构建碰撞面坐标系
|
|
|
|
newFace.OCS = sideOcs.clone().setPosition(min);
|
|
|
|
newFace.OCS = sideFace.OCS.clone().setPosition(min);
|
|
|
|
|
|
|
|
|
|
|
|
newFace.IsPositiveFace = sideFace.IsPositiveFace;
|
|
|
|
newFace.IsPositiveFace = sideFace.IsPositiveFace;
|
|
|
|
newFace.drillType = sideFace.drillType;
|
|
|
|
newFace.drillType = sideFace.drillType;
|
|
|
|