mirror of https://gitee.com/cf-fz/WebCAD.git
parent
212111cf47
commit
090e3d0c9f
@ -0,0 +1,70 @@
|
|||||||
|
import { Polyline } from "../../DatabaseServices/Polyline";
|
||||||
|
import { arrayRemoveIf } from "../../Common/ArrayExt";
|
||||||
|
import { FixIndex } from "../../Common/Utils";
|
||||||
|
import { IntersectOption } from "../IntersectWith";
|
||||||
|
import { Arc } from "../../DatabaseServices/Arc";
|
||||||
|
import { Line } from "../../DatabaseServices/Line";
|
||||||
|
|
||||||
|
interface Vec3
|
||||||
|
{
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
z: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* V型刀走刀数据
|
||||||
|
* @param polyline
|
||||||
|
* @param feedingDepth
|
||||||
|
* @param knifAngle 通常为60度.按弧度表示
|
||||||
|
*/
|
||||||
|
function VKnifToolPath(polyline: Polyline, feedingDepth: number, knifAngle: number)
|
||||||
|
{
|
||||||
|
let x = feedingDepth * Math.tan(knifAngle);
|
||||||
|
let cus = polyline.Explode();
|
||||||
|
arrayRemoveIf(cus, c => c.Length < 0.01);
|
||||||
|
|
||||||
|
let offsetx = [x, -x];
|
||||||
|
|
||||||
|
let ptsbul: { pt: Vec3, bul: number }[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < cus.length; i++)
|
||||||
|
{
|
||||||
|
let nextIndex = FixIndex(i + 1, cus.length);
|
||||||
|
let c1 = cus[i];
|
||||||
|
let c2 = cus[nextIndex];
|
||||||
|
|
||||||
|
let d = { pt: c1.StartPoint, bul: 0 };
|
||||||
|
|
||||||
|
let curP = c1.EndPoint;
|
||||||
|
|
||||||
|
if (c1 instanceof Arc)
|
||||||
|
{
|
||||||
|
d.bul = c1.Bul;
|
||||||
|
c1 = new Line(curP.clone().sub(c1.GetFistDeriv(1).multiplyScalar(100)), curP);
|
||||||
|
}
|
||||||
|
if (c2 instanceof Arc)
|
||||||
|
c2 = new Line(c2.StartPoint, c2.StartPoint.add(c2.GetFistDeriv(0).multiplyScalar(100)));
|
||||||
|
|
||||||
|
for (let x of offsetx)
|
||||||
|
{
|
||||||
|
let co1 = c1.GetOffsetCurves(x)[0];
|
||||||
|
let co2 = c2.GetOffsetCurves(x)[0];
|
||||||
|
|
||||||
|
if (!co1 || !co2) continue;
|
||||||
|
|
||||||
|
let ipts = co1.IntersectWith(co2, IntersectOption.ExtendBoth);
|
||||||
|
|
||||||
|
if (ipts.length === 0) continue;
|
||||||
|
|
||||||
|
if (co1.PtOnCurve(ipts[0])) continue;
|
||||||
|
|
||||||
|
//抬刀路径
|
||||||
|
ptsbul.push({ pt: curP, bul: 0 });
|
||||||
|
ptsbul.push({ pt: ipts[0].setZ(feedingDepth), bul: 0 });
|
||||||
|
}
|
||||||
|
ptsbul.push(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ptsbul;
|
||||||
|
}
|
Loading…
Reference in new issue