!2657 优化:走刀时是否过滤板边缘大孔

pull/2611/MERGE
黄诗津 6 months ago
parent c0fa1030c1
commit eb921eab79

@ -121,6 +121,7 @@ export class DrawDrillingTool extends Singleton
if (bigRad)
{
pxlEnt = CylinderHole.CreateCylHole(bigRad, pxlDepth, GangDrillType.WoodPXL);
pxlEnt.AllowPxl = this.m_Option.allowPxl;
pxlEnt.ColorIndex = 6;
this.woodPins.push(pxlEnt);
//将三个实体移动到相应的位置
@ -214,6 +215,7 @@ export class DrawDrillingTool extends Singleton
if (this.m_Option.pxlRad && pxlDepth)
{
pxlEnt = CylinderHole.CreateCylHole(this.m_Option.pxlRad, pxlDepth, GangDrillType.Pxl);
pxlEnt.AllowPxl = this.m_Option.allowPxl;
this.drillEnts.push(pxlEnt);
//将三个实体移动到相应的位置
@ -725,14 +727,14 @@ export class DrawDrillingTool extends Singleton
else
{
let ocs = interBoard.OCSInv.multiply(this.m_Face.OCS).multiply(MoveMatrix(new Vector3(dist)));
return CyHoleInBoard(this.drillEnts as CylinderHole[], interBoard, ocs, false, this.m_Option.allowPxl);
return CyHoleInBoard(this.drillEnts as CylinderHole[], interBoard, ocs, false);
}
}
private CheckWoodInBoard(dist: number)
{
let br = this.m_Face.InterBoard;
let ocs = br.OCSInv.multiply(this.m_Face.OCS).multiply(MoveMatrix(new Vector3(dist)));
return CyHoleInBoard(this.woodPins as CylinderHole[], br, ocs, false, this.m_Option.allowPxl);
return CyHoleInBoard(this.woodPins as CylinderHole[], br, ocs, false);
}
private CheckModelingCollision(localBoxs: Box3[], intBox3s: Box3[], dist: number)
{
@ -950,8 +952,8 @@ export class DrawDrillingTool extends Singleton
needRemoveDrillList.add(hole);
}
//偏移后判断是否在板件外面
else if (!CyHoleInBoard(moveAfterDrills, this.m_Face.InterBoard, this.m_Face.InterBoard.OCSInv, false, this.m_Option.allowPxl) &&
!CyHoleInBoard(moveAfterDrills, this.m_Face.LocalBoard, this.m_Face.LocalBoard.OCSInv, false, this.m_Option.allowPxl))
else if (!CyHoleInBoard(moveAfterDrills, this.m_Face.InterBoard, this.m_Face.InterBoard.OCSInv, false) &&
!CyHoleInBoard(moveAfterDrills, this.m_Face.LocalBoard, this.m_Face.LocalBoard.OCSInv, false))
{
this._InteractionLog(`${isWoodPinss ? "木销" : "通孔排钻"}偏移后在板件外,跳过绘制`);
needRemoveDrillList.add(hole);

@ -15,7 +15,7 @@ import { DrillType } from "./DrillType";
export const SCALAR = 0.1;
export function CyHoleInBoard(cys: CylinderHole[], br: Board, ocs: Matrix4, checkAll = false, allowPxl = false)
export function CyHoleInBoard(cys: CylinderHole[], br: Board, ocs: Matrix4, checkAll = false)
{
if (!checkAll && cys.length === 1 && cys[0].Type === GangDrillType.Ymj)
return true;
@ -87,10 +87,15 @@ export function CyHoleInBoard(cys: CylinderHole[], br: Board, ocs: Matrix4, chec
{
let center = cy.Position.applyMatrix4(ocs).setZ(0);
let cir = new Circle(center, pxl.Radius - SCALAR);
if (allowPxl || !HostApplicationServices.forceFilterPxl)
return outline.IntersectWith(cir, 0).length <= 1 && !outline.PtInCurve(center);
if (HostApplicationServices.forceFilterPxl)
{
if (pxl.AllowPxl)
return outline.IntersectWith(cir, 0).length <= 1 && !outline.PtInCurve(center);
else
return outline.IntersectWith(cir, 0).length > 0 || !outline.PtInCurve(center);
}
else
return outline.IntersectWith(cir, 0).length > 0 || !outline.PtInCurve(center);
return outline.IntersectWith(cir, 0).length <= 1 && !outline.PtInCurve(center);
}))
return false;
}

@ -12,6 +12,7 @@ export abstract class Hole extends Entity
@AutoRecord MId: ObjectId;//层板钉:{mid=层板} 排钻:{mid=面}
protected _Height: number;
@AutoRecord OtherHalfTongKong: ObjectId;
protected allowHoleAtBoardEdge: boolean = false; //允许大孔面在板边缘
protected type: GangDrillType = GangDrillType.Pxl;
get Height()
{
@ -40,6 +41,19 @@ export abstract class Hole extends Entity
}
}
get AllowPxl()
{
return this.allowHoleAtBoardEdge;
}
set AllowPxl(v: boolean)
{
if (this.allowHoleAtBoardEdge !== v)
{
this.WriteAllObjectRecord();
this.allowHoleAtBoardEdge = v;
}
}
Clone()
{
let ent = super.Clone();
@ -61,19 +75,27 @@ export abstract class Hole extends Entity
this.FId = file.ReadSoftObjectId();
this.MId = file.ReadSoftObjectId();
}
if (ver >= 6)
if (ver > 5)
{
this.OtherHalfTongKong = file.ReadSoftObjectId();
}
if (ver > 6)
{
this.allowHoleAtBoardEdge = file.ReadBool();
}
else
{
this.allowHoleAtBoardEdge = false;
}
}
WriteFile(file: CADFiler)
{
super.WriteFile(file);
file.Write(6);//ver
file.Write(7);//ver
file.Write(this._Height);
file.WriteSoftObjectId(this.FId);
file.WriteSoftObjectId(this.MId);
file.WriteSoftObjectId(this.OtherHalfTongKong);
file.WriteBool(this.allowHoleAtBoardEdge);
}
}

@ -598,7 +598,7 @@ export namespace Production
{
pos.z = thickness - pos.z;
}
function HoleInBoard(center: Vector3, radius: number, outline: ExtrudeContourCurve, isYMJ = false)
function HoleInBoard(center: Vector3, radius: number, outline: ExtrudeContourCurve, allowPxl: boolean, isYMJ = false)
{
let cir = new Circle(center, radius - SCALAR);
if (isYMJ)
@ -607,10 +607,10 @@ export namespace Production
}
else
{
if (HostApplicationServices.forceFilterPxl)
return outline.IntersectWith(cir, 0).length === 0 && outline.PtInCurve(center);
else
if (allowPxl || !HostApplicationServices.forceFilterPxl)
return outline.IntersectWith(cir, 0).length > 1 || outline.PtInCurve(center);
else
return outline.IntersectWith(cir, 0).length === 0 && outline.PtInCurve(center);
}
}
/**分析常规排钻 */
@ -638,7 +638,7 @@ export namespace Production
{
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;
|| !HoleInBoard(position.clone().setZ(0), cyHole.Radius, outline, cyHole.AllowPxl)) return;
position.sub(offsetTanslation);
@ -733,7 +733,7 @@ export namespace Production
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), cyHole.Radius, outline, true)) return;
|| !HoleInBoard(position.clone().setZ(0), cyHole.Radius, outline, cyHole.AllowPxl, true)) return;
position.sub(offsetTanslation);
holes = data.frontBackHoles;

Loading…
Cancel
Save