|
|
|
@ -13,7 +13,7 @@ import { Box3Ext } from "../../Geometry/Box";
|
|
|
|
|
import { BSPGroupParse } from "../../Geometry/BSPGroupParse";
|
|
|
|
|
import { FastWireframe } from "../../Geometry/CreateWireframe";
|
|
|
|
|
import { EdgesGeometry } from "../../Geometry/EdgeGeometry";
|
|
|
|
|
import { equaln, equalv2, equalv3, isIntersect, isParallelTo, MoveMatrix, ZeroVec } from "../../Geometry/GeUtils";
|
|
|
|
|
import { equaln, equalv2, equalv3, isIntersect, isParallelTo, MoveMatrix, ZeroVec, IdentityMtx4 } from "../../Geometry/GeUtils";
|
|
|
|
|
import { OBB } from "../../Geometry/OBB/obb";
|
|
|
|
|
import { ScaleUV } from "../../Geometry/UVUtils";
|
|
|
|
|
import { RenderType } from "../../GraphicsSystem/RenderType";
|
|
|
|
@ -420,14 +420,32 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
return Status.False;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Subtract(extrudes: ExtrudeSolid[])
|
|
|
|
|
{
|
|
|
|
|
let grooves: ExtrudeSolid[] = [];
|
|
|
|
|
for (let br of extrudes)
|
|
|
|
|
{
|
|
|
|
|
let gs = this.ConverToLocalGroove(br);
|
|
|
|
|
grooves.push(...gs);
|
|
|
|
|
}
|
|
|
|
|
this.AppendGrooves(grooves);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppendGroove(groove: ExtrudeSolid)
|
|
|
|
|
{
|
|
|
|
|
if (groove.Width < 1e-3 || groove.Height < 1e-3 || groove.Thickness < 1e-3) return;
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
if (this.GrooveCheckPosition(groove) === Status.True)
|
|
|
|
|
{
|
|
|
|
|
this.grooves.push(groove);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 添加槽进板件,并且自动分裂.
|
|
|
|
|
* 通常槽已经校验过准确性,所以不在校验
|
|
|
|
|
*/
|
|
|
|
|
AppendGrooves(grooves: ExtrudeSolid[])
|
|
|
|
|
{
|
|
|
|
|
if (grooves.length === 0) return;
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
this.grooves.push(...grooves);
|
|
|
|
|
this.GrooveCheckAllAutoSplit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetObjectSnapPoints(
|
|
|
|
@ -725,10 +743,11 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
* @param target 该对象可能被修改(内部不拷贝该实体)
|
|
|
|
|
* @param useClone 转换后的实体是目标实体拷贝后修改的
|
|
|
|
|
*/
|
|
|
|
|
ConverToLocalGroove(target: this, useClone = false): ExtrudeSolid[]
|
|
|
|
|
ConverToLocalGroove(target: ExtrudeSolid): ExtrudeSolid[]
|
|
|
|
|
{
|
|
|
|
|
if (isParallelTo(this.Normal, target.Normal))
|
|
|
|
|
{
|
|
|
|
|
target = target.Clone();
|
|
|
|
|
if (this.GrooveCheckPosition(target) !== Status.True)
|
|
|
|
|
return [];
|
|
|
|
|
|
|
|
|
@ -753,9 +772,10 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
let box = new Box3().setFromPoints(pts);
|
|
|
|
|
let size = box.getSize(new Vector3());
|
|
|
|
|
|
|
|
|
|
let ext = useClone ? target.Clone() : new ExtrudeSolid();
|
|
|
|
|
if (useClone)
|
|
|
|
|
ext.grooves.length = 0;
|
|
|
|
|
let ext = new ExtrudeSolid();
|
|
|
|
|
ext.groovesAddDepth = target.groovesAddDepth;
|
|
|
|
|
ext.groovesAddLength = target.groovesAddLength;
|
|
|
|
|
ext.knifeRadius = target.knifeRadius;
|
|
|
|
|
ext.ConverToRectSolid(size.x, size.y, size.z);
|
|
|
|
|
ext.OCS = m.clone().setPosition(box.min.applyMatrix4(m));
|
|
|
|
|
|
|
|
|
@ -772,7 +792,7 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
*/
|
|
|
|
|
GrooveCheckPosition(target: ExtrudeSolid): Status
|
|
|
|
|
{
|
|
|
|
|
if (target.thickness <= 1e-3)
|
|
|
|
|
if (target.Width < 1e-3 || target.Height < 1e-3 || target.Thickness < 1e-3)
|
|
|
|
|
return Status.False;
|
|
|
|
|
|
|
|
|
|
let tp = target.Position.applyMatrix4(this.OCSInv);
|
|
|
|
@ -789,9 +809,10 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
}
|
|
|
|
|
else if (maxZ >= (this.thickness - 1e-3) && minZ > 0)//正面
|
|
|
|
|
target.Thickness = this.thickness - minZ;
|
|
|
|
|
else return Status.False;
|
|
|
|
|
else
|
|
|
|
|
return Status.False;
|
|
|
|
|
|
|
|
|
|
return target.Thickness > 0 ? Status.True : Status.False;
|
|
|
|
|
return Status.True;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -853,9 +874,6 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
*/
|
|
|
|
|
GrooveCheckContour(target: ExtrudeSolid): ExtrudeSolid[]
|
|
|
|
|
{
|
|
|
|
|
if (equaln(target.thickness, this.thickness))
|
|
|
|
|
return [target];
|
|
|
|
|
|
|
|
|
|
let matrixToTarget = target.OCSInv.multiply(this.OCS);
|
|
|
|
|
matrixToTarget.elements[14] = 0;//z->0
|
|
|
|
|
|
|
|
|
@ -984,6 +1002,8 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
this.IsNeedGrooveCheck = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.IsNeedGrooveCheck = false;
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
|
|
|
|
|
//校验Z轴位置
|
|
|
|
|
arrayRemoveIf(this.grooves, g =>
|
|
|
|
@ -1019,18 +1039,22 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修正凹槽轮廓
|
|
|
|
|
let splitGrooves = [];
|
|
|
|
|
let splitGrooves: ExtrudeSolid[] = [];
|
|
|
|
|
for (let g of this.grooves)
|
|
|
|
|
{
|
|
|
|
|
if (equaln(g.thickness, this.thickness))
|
|
|
|
|
splitGrooves.push(g);
|
|
|
|
|
else
|
|
|
|
|
splitGrooves.push(...this.GrooveCheckContour(g));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.grooves = splitGrooves;
|
|
|
|
|
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LazyGrooveCheckAll()
|
|
|
|
|
{
|
|
|
|
|
if (this.IsNeedGrooveCheck)
|
|
|
|
|
/** 校验内部槽并且自动分裂 */
|
|
|
|
|
GrooveCheckAllAutoSplit()
|
|
|
|
|
{
|
|
|
|
|
let splitEntitys: this[] = [];
|
|
|
|
|
this.GrooveCheckAll(splitEntitys);
|
|
|
|
@ -1042,7 +1066,11 @@ export class ExtrudeSolid extends Entity
|
|
|
|
|
record.Add(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.IsNeedGrooveCheck = false;
|
|
|
|
|
|
|
|
|
|
LazyGrooveCheckAll()
|
|
|
|
|
{
|
|
|
|
|
if (this.IsNeedGrooveCheck)
|
|
|
|
|
this.GrooveCheckAllAutoSplit();
|
|
|
|
|
this.IsLazyGrooveCheck = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|