|
|
|
@ -8,18 +8,17 @@ import { Circle } from "../../DatabaseServices/Entity/Circle";
|
|
|
|
|
import { Curve } from "../../DatabaseServices/Entity/Curve";
|
|
|
|
|
import { Line } from "../../DatabaseServices/Entity/Line";
|
|
|
|
|
import { Polyline } from "../../DatabaseServices/Entity/Polyline";
|
|
|
|
|
import { HardwareCompositeEntity } from '../../DatabaseServices/Hardware/HardwareCompositeEntity';
|
|
|
|
|
import { Shape } from "../../DatabaseServices/Shape";
|
|
|
|
|
import { ShapeManager } from "../../DatabaseServices/ShapeManager";
|
|
|
|
|
import { Route } from "../../Geometry/CurveMap";
|
|
|
|
|
import { GetSideFaceMtx } from "../../Geometry/DrillParse/BoardGetFace";
|
|
|
|
|
import { angleTo, isParallelTo, MoveMatrix, XAxis } from "../../Geometry/GeUtils";
|
|
|
|
|
import { RegionParse } from "../../Geometry/RegionParse";
|
|
|
|
|
import { Production } from "../../Production/Product";
|
|
|
|
|
import { FaceDirection } from "../../UI/Store/BoardInterface";
|
|
|
|
|
import { BoolOpeartionType, isTargetCurInOrOnSourceCur } from "../BoolOperateUtils";
|
|
|
|
|
import { GetSealedBoardContour } from "../CalcEdgeSealing";
|
|
|
|
|
import { GetCurveToInDir, GetOffsetCurves, OptimizeToolPath } from "./OptimizeToolPath";
|
|
|
|
|
import { FixIndex } from "../../Nest/Common/Util";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*计算走刀工具类
|
|
|
|
@ -158,7 +157,7 @@ export class FeedingToolPath extends Singleton
|
|
|
|
|
let modelings = br.BoardModeling;
|
|
|
|
|
let allModeling = GetModelingFromCustomDrill(br);
|
|
|
|
|
modelings.push(...allModeling.modeling);
|
|
|
|
|
let cus = this.CalcPath(modelings, br.Thickness);
|
|
|
|
|
let cus = this.CalcPath(modelings, br);
|
|
|
|
|
|
|
|
|
|
let outline = br.ContourCurve as Polyline;
|
|
|
|
|
let dir = Math.sign(outline.Area2);
|
|
|
|
@ -180,7 +179,7 @@ export class FeedingToolPath extends Singleton
|
|
|
|
|
sideOutlines.push(pl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cus.push(...this.CalcPath(allModeling.sideModeling, br.Height));
|
|
|
|
|
cus.push(...this.CalcPath(allModeling.sideModeling, br));
|
|
|
|
|
//加入板件轮廓
|
|
|
|
|
cus.unshift(br.ContourCurve.Clone());
|
|
|
|
|
if (cus.length === 1)
|
|
|
|
@ -210,17 +209,18 @@ export class FeedingToolPath extends Singleton
|
|
|
|
|
* 计算走刀路径
|
|
|
|
|
* TODO:圆孔半径===刀半径时推送ys 显示点
|
|
|
|
|
*/
|
|
|
|
|
CalcPath(modelings: IModeling[], thickness: number): Curve[]
|
|
|
|
|
CalcPath(modelings: IModeling[], br: Board): Curve[]
|
|
|
|
|
{
|
|
|
|
|
let cus: Curve[] = [];
|
|
|
|
|
for (let m of modelings)
|
|
|
|
|
{
|
|
|
|
|
cus.push(...this.GetModelFeedPath(thickness, m));
|
|
|
|
|
cus.push(...this.GetModelFeedPath(br, m));
|
|
|
|
|
}
|
|
|
|
|
return cus;
|
|
|
|
|
}
|
|
|
|
|
GetModelFeedPath(brThickness: number, m: IModeling): Curve[]
|
|
|
|
|
GetModelFeedPath(br: Board, m: IModeling): Curve[]
|
|
|
|
|
{
|
|
|
|
|
const brThickness = br.Thickness;
|
|
|
|
|
let cus: Curve[] = [];
|
|
|
|
|
let { shape, thickness, knifeRadius, addLen, addWidth, addDepth } = m;
|
|
|
|
|
if (!knifeRadius) knifeRadius = 3;
|
|
|
|
@ -228,6 +228,7 @@ export class FeedingToolPath extends Singleton
|
|
|
|
|
shape = shape.Clone();
|
|
|
|
|
shape.Z0();
|
|
|
|
|
this.GrooveAddSize(shape, addLen, addWidth);
|
|
|
|
|
this.HandleThoughGroove(br, shape, knifeRadius);
|
|
|
|
|
|
|
|
|
|
if (thickness >= brThickness)
|
|
|
|
|
{
|
|
|
|
@ -323,12 +324,97 @@ export class FeedingToolPath extends Singleton
|
|
|
|
|
let modelings = br.BoardModeling;
|
|
|
|
|
for (let i = 0; i < modelings.length; i++)
|
|
|
|
|
{
|
|
|
|
|
let cus = this.GetModelFeedPath(br.Thickness, modelings[i]);
|
|
|
|
|
let cus = this.GetModelFeedPath(br, modelings[i]);
|
|
|
|
|
if (cus.length === 0)
|
|
|
|
|
errorIndexs.push(i);
|
|
|
|
|
}
|
|
|
|
|
return errorIndexs;
|
|
|
|
|
}
|
|
|
|
|
HandleThoughGroove(br: Board, shape: Shape, knifeRadius: number)
|
|
|
|
|
{
|
|
|
|
|
let brCon = br.ContourCurve;
|
|
|
|
|
let outline = shape.Outline.Curve;
|
|
|
|
|
if (outline instanceof Circle) return;
|
|
|
|
|
|
|
|
|
|
let cus = outline.Explode();
|
|
|
|
|
let hasChange = false;
|
|
|
|
|
for (let i = 0; i < cus.length; i++)
|
|
|
|
|
{
|
|
|
|
|
let c = cus[i];
|
|
|
|
|
if (c instanceof Line)
|
|
|
|
|
{
|
|
|
|
|
let mp = c.Midpoint;
|
|
|
|
|
if (brCon.PtOnCurve(mp))
|
|
|
|
|
{
|
|
|
|
|
hasChange = true;
|
|
|
|
|
let cs = c.GetOffsetCurves(knifeRadius);
|
|
|
|
|
cus[i] = cs[0];
|
|
|
|
|
let fline = cus[FixIndex(i - 1, cus.length)];
|
|
|
|
|
if (fline instanceof Line)
|
|
|
|
|
{
|
|
|
|
|
let intPts = fline.IntersectWith(cs[0], 3);
|
|
|
|
|
if (intPts.length === 0)
|
|
|
|
|
{
|
|
|
|
|
console.error("未知错误情况");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fline.EndPoint = intPts[0];
|
|
|
|
|
cs[0].StartPoint = intPts[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let newLine = new Line(fline.EndPoint, cs[0].StartPoint);
|
|
|
|
|
if (i === 0)
|
|
|
|
|
{
|
|
|
|
|
cus.push(newLine);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cus.splice(i, 0, newLine);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let backLine = cus[FixIndex(i + 1, cus.length)];
|
|
|
|
|
|
|
|
|
|
if (backLine instanceof Line)
|
|
|
|
|
{
|
|
|
|
|
let intPts = backLine.IntersectWith(cs[0], 3);
|
|
|
|
|
if (intPts.length === 0)
|
|
|
|
|
{
|
|
|
|
|
console.error("未知错误情况");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
backLine.StartPoint = intPts[0];
|
|
|
|
|
cs[0].EndPoint = intPts[0];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let newLine = new Line(cs[0].EndPoint, backLine.StartPoint);
|
|
|
|
|
if (i + 1 === cus.length)
|
|
|
|
|
{
|
|
|
|
|
cus.unshift(newLine);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cus.splice(i + 1, 0, newLine);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (hasChange)
|
|
|
|
|
{
|
|
|
|
|
let con = Contour.CreateContour(Polyline.Combine(cus));
|
|
|
|
|
if (con)
|
|
|
|
|
shape.Outline = con;
|
|
|
|
|
else
|
|
|
|
|
console.error("错误");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
export function GetModelingFromCustomDrill(br: Board)
|
|
|
|
|
{
|
|
|
|
|