|
|
|
@ -16,6 +16,14 @@ import { INailRule, IShinkOption, LayerNailOption } from "../../UI/Store/BoardIn
|
|
|
|
|
class ActivityLayerBoardTool
|
|
|
|
|
{
|
|
|
|
|
NailRules: INailRule[];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 求面与板的交点 得到板和交点
|
|
|
|
|
* @param face 层板的侧面
|
|
|
|
|
* @param objects 其他板
|
|
|
|
|
* @param br 层板
|
|
|
|
|
* @returns 交点信息(点 实体)
|
|
|
|
|
*/
|
|
|
|
|
private GetBoardIntersection(face: Face, objects: Object3D[], br: Board)
|
|
|
|
|
{
|
|
|
|
|
for (let s of [0.5, 0.1, 0.9])
|
|
|
|
@ -205,68 +213,68 @@ class ActivityLayerBoardTool
|
|
|
|
|
if (face.type === BoardFaceType.Side)
|
|
|
|
|
{
|
|
|
|
|
let shrink = 0;
|
|
|
|
|
if (option)
|
|
|
|
|
if (option)//求内缩值
|
|
|
|
|
{
|
|
|
|
|
shrink = this.GetShrinkDist(face, br, option);
|
|
|
|
|
this.GetShrinkBoardIndexesMap(face, br, shrink, vecIndexMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#region 画层板钉
|
|
|
|
|
if (!nailOption.isDraw) continue;
|
|
|
|
|
if (!nailOption.isInBack && isParallelTo(face.Normal, xVec)) continue;
|
|
|
|
|
|
|
|
|
|
let intersection = this.GetBoardIntersection(face, objects, br);
|
|
|
|
|
if (intersection)
|
|
|
|
|
let intersection = this.GetBoardIntersection(face, objects, br);//射线求交 得到板和交点
|
|
|
|
|
if (!intersection || (intersection.distance - 1 + shrink >= refDist)) //防止板件悬空 #I1DPHR
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
let otherBoard = GetEntity(intersection.object) as Board;
|
|
|
|
|
|
|
|
|
|
this.IntersectFace(otherBoard, face);
|
|
|
|
|
|
|
|
|
|
let nail = CylinderHole.CreateCylHole(nailOption.rad, nailOption.length, GangDrillType.Nail);
|
|
|
|
|
nail.ColorIndex = 4;
|
|
|
|
|
let fNor = face.Normal;
|
|
|
|
|
let ang = -angleTo(fNor, otherBoard.Normal.negate());
|
|
|
|
|
if (equaln(Math.abs(ang), Math.PI, 1e-3))
|
|
|
|
|
ang = 0;
|
|
|
|
|
|
|
|
|
|
let xDist = nailOption.front;
|
|
|
|
|
let yDist = - nailOption.rad - shrink * Math.sin(ang);
|
|
|
|
|
let zDist = 0;
|
|
|
|
|
let zRoMat = new Matrix4().makeRotationX(ang);
|
|
|
|
|
|
|
|
|
|
let p = new Vector3().setFromMatrixPosition(face.OCS.clone().multiply(zRoMat)).applyMatrix4(otherBoard.OCSInv);
|
|
|
|
|
if (p.z < 1e-6)
|
|
|
|
|
{
|
|
|
|
|
zDist = -p.z;
|
|
|
|
|
}
|
|
|
|
|
else if (p.z > otherBoard.Thickness - 1e-6)
|
|
|
|
|
{
|
|
|
|
|
//防止板件悬空 #I1DPHR
|
|
|
|
|
if (intersection.distance - 1 + shrink >= refDist)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
let otherBoard = GetEntity(intersection.object) as Board;
|
|
|
|
|
|
|
|
|
|
this.IntersectFace(otherBoard, face);
|
|
|
|
|
|
|
|
|
|
let nail = CylinderHole.CreateCylHole(nailOption.rad, nailOption.length, GangDrillType.Nail);
|
|
|
|
|
nail.ColorIndex = 4;
|
|
|
|
|
let fNor = face.Normal;
|
|
|
|
|
let ang = -angleTo(fNor, otherBoard.Normal.negate());
|
|
|
|
|
if (equaln(Math.abs(ang), Math.PI, 1e-3))
|
|
|
|
|
ang = 0;
|
|
|
|
|
|
|
|
|
|
let xDist = nailOption.front;
|
|
|
|
|
let yDist = - nailOption.rad - shrink * Math.sin(ang);
|
|
|
|
|
let zDist = 0;
|
|
|
|
|
let zRoMat = new Matrix4().makeRotationX(ang);
|
|
|
|
|
|
|
|
|
|
let p = new Vector3().setFromMatrixPosition(face.OCS.clone().multiply(zRoMat)).applyMatrix4(otherBoard.OCSInv);
|
|
|
|
|
if (p.z < 1e-6)
|
|
|
|
|
{
|
|
|
|
|
zDist = -p.z;
|
|
|
|
|
}
|
|
|
|
|
else if (p.z > otherBoard.Thickness - 1e-6)
|
|
|
|
|
{
|
|
|
|
|
zDist = p.z - otherBoard.Thickness;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
console.error("不该存在的情况");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zDist += (- nail.Height + nailOption.depth);
|
|
|
|
|
|
|
|
|
|
nail.Position = nail.Position.add(new Vector3(xDist, yDist, zDist));
|
|
|
|
|
nail.ApplyMatrix(zRoMat).ApplyMatrix(face.OCS);
|
|
|
|
|
|
|
|
|
|
//层板钉数
|
|
|
|
|
let nailCount = nailOption.count;
|
|
|
|
|
if (option || this.NailRules)
|
|
|
|
|
nailCount = this.GetRuleCount(face.Length, rules);
|
|
|
|
|
|
|
|
|
|
let yVec = new Vector3().setFromMatrixColumn(otherBoard.OCS, 1);
|
|
|
|
|
|
|
|
|
|
let nails = this.BuildNails(nail, nailOption, face, yVec, nailCount);
|
|
|
|
|
for (let nail of nails)
|
|
|
|
|
nailBoardMap.set(nail, otherBoard);
|
|
|
|
|
allNails.push(...nails);
|
|
|
|
|
zDist = p.z - otherBoard.Thickness;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
console.error("不该存在的情况");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zDist += (- nail.Height + nailOption.depth);
|
|
|
|
|
|
|
|
|
|
nail.Position = nail.Position.add(new Vector3(xDist, yDist, zDist));
|
|
|
|
|
nail.ApplyMatrix(zRoMat).ApplyMatrix(face.OCS);
|
|
|
|
|
|
|
|
|
|
//层板钉数
|
|
|
|
|
let nailCount = nailOption.count;
|
|
|
|
|
if (option || this.NailRules)
|
|
|
|
|
nailCount = this.GetRuleCount(face.Length, rules);
|
|
|
|
|
|
|
|
|
|
let yVec = new Vector3().setFromMatrixColumn(otherBoard.OCS, 1);
|
|
|
|
|
|
|
|
|
|
let nails = this.BuildNails(nail, nailOption, face, yVec, nailCount);
|
|
|
|
|
for (let nail of nails)
|
|
|
|
|
nailBoardMap.set(nail, otherBoard);
|
|
|
|
|
allNails.push(...nails);
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.AppendBoard(br, nailBoardMap, allNails);
|
|
|
|
|