|
|
|
@ -527,46 +527,61 @@ export namespace Production
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**分析常规排钻 */
|
|
|
|
|
function ParseCylHoles(d: CylinderHole, br: Board, offsetTanslation: Vector3, data: IBoardHoleInfo, outline: ExtrudeContourCurve)
|
|
|
|
|
function ParseCylHoles(cyHole: CylinderHole, br: Board, offsetTanslation: Vector3, data: IBoardHoleInfo, outline: ExtrudeContourCurve)
|
|
|
|
|
{
|
|
|
|
|
let processData = br.BoardProcessOption;
|
|
|
|
|
let brInv = br.OCSInv;
|
|
|
|
|
let brNormal = br.Normal;
|
|
|
|
|
let roMat = new Matrix4().extractRotation(br.OCSInv);
|
|
|
|
|
let position = d.Position.applyMatrix4(br.OCSInv);
|
|
|
|
|
let roMat = new Matrix4().extractRotation(brInv);
|
|
|
|
|
let position = cyHole.Position.applyMatrix4(brInv);
|
|
|
|
|
let holes = data.frontBackHoles;
|
|
|
|
|
let face: FaceDirection;
|
|
|
|
|
let face: FaceDirection;//孔面方向
|
|
|
|
|
let isPush = false;
|
|
|
|
|
let endPt: Vector3;
|
|
|
|
|
let depth = d.Height;
|
|
|
|
|
let diffMat = br.OCSInv.multiply(d.OCS);
|
|
|
|
|
let depth = cyHole.Height;
|
|
|
|
|
let diffMat = brInv.clone().multiply(cyHole.OCSNoClone);
|
|
|
|
|
let x = new Vector3().setFromMatrixColumn(diffMat, 0);
|
|
|
|
|
let angle = angleTo(XAxis, x);
|
|
|
|
|
|
|
|
|
|
let nor = d.Normal.applyMatrix4(roMat);
|
|
|
|
|
let pos2 = position.clone().add(nor.multiplyScalar(depth));
|
|
|
|
|
let cyNormal = cyHole.Normal.applyMatrix4(roMat);
|
|
|
|
|
let pos2 = position.clone().add(cyNormal.multiplyScalar(depth));
|
|
|
|
|
|
|
|
|
|
if (d.Type === GangDrillType.Pxl || d.Type === GangDrillType.WoodPXL)
|
|
|
|
|
if (cyHole.Type === GangDrillType.Pxl || cyHole.Type === GangDrillType.WoodPXL)
|
|
|
|
|
{
|
|
|
|
|
if (isParallelTo(d.Normal, brNormal, CanDrawHoleFuzz))
|
|
|
|
|
if (isParallelTo(cyHole.Normal, brNormal, CanDrawHoleFuzz))
|
|
|
|
|
{
|
|
|
|
|
if (!IsBetweenA2B(position.x, -d.Radius, br.Width + d.Radius, 1e-6)
|
|
|
|
|
|| !IsBetweenA2B(position.y, -d.Radius, br.Height + d.Radius, 1e-6)
|
|
|
|
|
|| !isIntersect2(0, br.Thickness, position.z, pos2.z, -CanDrawHoleFuzz)
|
|
|
|
|
|| !HoleInBoard(position.clone().setZ(0), d.Radius, outline)) return;
|
|
|
|
|
if (!IsBetweenA2B(position.x, -cyHole.Radius, br.Width + cyHole.Radius, 1e-6)
|
|
|
|
|
|| !IsBetweenA2B(position.y, -cyHole.Radius, br.Height + cyHole.Radius, 1e-6)
|
|
|
|
|
|| !HoleInBoard(position.clone().setZ(0), cyHole.Radius, outline)) return;
|
|
|
|
|
|
|
|
|
|
position.sub(offsetTanslation);
|
|
|
|
|
face = processData[EBoardKeyList.BigHole];
|
|
|
|
|
|
|
|
|
|
//#region 求得真实的求交范围
|
|
|
|
|
let z0 = position.z;
|
|
|
|
|
let z1 = pos2.z;
|
|
|
|
|
if (z0 > z1) [z0, z1] = [z1, z0];
|
|
|
|
|
|
|
|
|
|
let i1 = Math.max(z0, 0);
|
|
|
|
|
let i2 = Math.min(z1, br.Thickness);
|
|
|
|
|
if (i2 - i1 < CanDrawHoleFuzz) return;//相交范围小于0.1
|
|
|
|
|
|
|
|
|
|
if (equaln(i1, 0, CanDrawHoleFuzz)) face = FaceDirection.Back;
|
|
|
|
|
else if (equaln(i2, br.Thickness, CanDrawHoleFuzz)) face = FaceDirection.Front;
|
|
|
|
|
else return;//不在正面 也不在反面
|
|
|
|
|
|
|
|
|
|
depth = i2 - i1;//真实的相交范围
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
isPush = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (d.Type === GangDrillType.Ljg || d.Type === GangDrillType.Wood)
|
|
|
|
|
else if (cyHole.Type === GangDrillType.Ljg || cyHole.Type === GangDrillType.Wood)
|
|
|
|
|
{
|
|
|
|
|
if (isPerpendicularityTo(d.Normal, brNormal, CanDrawHoleFuzz))//侧孔
|
|
|
|
|
if (isPerpendicularityTo(cyHole.Normal, brNormal, CanDrawHoleFuzz))//侧孔
|
|
|
|
|
{
|
|
|
|
|
let z = position.z;
|
|
|
|
|
if (!IsBetweenA2B(z, -d.Radius, br.Thickness + d.Radius, 1e-6)) return;
|
|
|
|
|
let sp = position.clone().add(d.Normal.multiplyScalar(- CanDrawHoleFuzz).applyMatrix4(roMat)).setZ(0);//加长线(以便加大容差)
|
|
|
|
|
let ep = position.clone().add(d.Normal.multiplyScalar(d.Height + CanDrawHoleFuzz).applyMatrix4(roMat)).setZ(0);//加长线
|
|
|
|
|
if (!IsBetweenA2B(z, -cyHole.Radius, br.Thickness + cyHole.Radius, 1e-6)) return;
|
|
|
|
|
let sp = position.clone().add(cyHole.Normal.multiplyScalar(- CanDrawHoleFuzz).applyMatrix4(roMat)).setZ(0);//加长线(以便加大容差)
|
|
|
|
|
let ep = position.clone().add(cyHole.Normal.multiplyScalar(cyHole.Height + CanDrawHoleFuzz).applyMatrix4(roMat)).setZ(0);//加长线
|
|
|
|
|
let line = new Line(sp, ep);
|
|
|
|
|
let pt = outline.IntersectWith(line, 0)[0];
|
|
|
|
|
if (!pt)
|
|
|
|
@ -597,14 +612,14 @@ export namespace Production
|
|
|
|
|
InvertPosition(position, br.Thickness);
|
|
|
|
|
InvertPosition(endPt, br.Thickness);
|
|
|
|
|
}
|
|
|
|
|
else if (d.Type === GangDrillType.Wood)
|
|
|
|
|
else if (cyHole.Type === GangDrillType.Wood)
|
|
|
|
|
{
|
|
|
|
|
if (!outline.PtInCurve(position.clone().setZ(0))) return;
|
|
|
|
|
face = position.z > 0 ? FaceDirection.Front : FaceDirection.Back;
|
|
|
|
|
holes = data.frontBackHoles;
|
|
|
|
|
if (position.z > 0)
|
|
|
|
|
{
|
|
|
|
|
let z1 = position.z - d.Height;
|
|
|
|
|
let z1 = position.z - cyHole.Height;
|
|
|
|
|
if (z1 > 0 && z1 < br.Thickness)
|
|
|
|
|
{
|
|
|
|
|
depth = br.Thickness - z1;
|
|
|
|
@ -613,7 +628,7 @@ export namespace Production
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let z1 = position.z + d.Height;
|
|
|
|
|
let z1 = position.z + cyHole.Height;
|
|
|
|
|
if (z1 > 0 && z1 < br.Thickness)
|
|
|
|
|
{
|
|
|
|
|
depth = z1;
|
|
|
|
@ -625,23 +640,23 @@ export namespace Production
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (isParallelTo(d.Normal, brNormal, CanDrawHoleFuzz))
|
|
|
|
|
if (isParallelTo(cyHole.Normal, brNormal, CanDrawHoleFuzz))
|
|
|
|
|
{
|
|
|
|
|
if (!IsBetweenA2B(position.x, -d.Radius, br.Width + d.Radius, CanDrawHoleFuzz)
|
|
|
|
|
|| !IsBetweenA2B(position.y, -d.Radius, br.Height + d.Radius, CanDrawHoleFuzz)
|
|
|
|
|
if (!IsBetweenA2B(position.x, -cyHole.Radius, br.Width + cyHole.Radius, CanDrawHoleFuzz)
|
|
|
|
|
|| !IsBetweenA2B(position.y, -cyHole.Radius, br.Height + cyHole.Radius, CanDrawHoleFuzz)
|
|
|
|
|
|| !isIntersect2(0, br.Thickness, position.z, pos2.z, -CanDrawHoleFuzz)
|
|
|
|
|
|| !HoleInBoard(position.clone().setZ(0), d.Radius, outline, true)) return;
|
|
|
|
|
|| !HoleInBoard(position.clone().setZ(0), cyHole.Radius, outline, true)) return;
|
|
|
|
|
|
|
|
|
|
position.sub(offsetTanslation);
|
|
|
|
|
holes = data.frontBackHoles;
|
|
|
|
|
face = !equalv3(d.Normal, brNormal, CanDrawHoleFuzz) ? FaceDirection.Front : FaceDirection.Back;
|
|
|
|
|
face = !equalv3(cyHole.Normal, brNormal, CanDrawHoleFuzz) ? FaceDirection.Front : FaceDirection.Back;
|
|
|
|
|
isPush = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
isPush && holes.push({
|
|
|
|
|
type: d.Type,
|
|
|
|
|
type: cyHole.Type,
|
|
|
|
|
position,
|
|
|
|
|
radius: d.Radius,
|
|
|
|
|
radius: cyHole.Radius,
|
|
|
|
|
depth,
|
|
|
|
|
face,
|
|
|
|
|
endPt,
|
|
|
|
|