|
|
@ -23,18 +23,21 @@ const CanPutPaths = [
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function ParseOddments(container: Container, binPath: Path, knifeRadius: number = 3.5, squarePath: Path = SquarePath, canPutPaths: Path[] = CanPutPaths): Path[]
|
|
|
|
export function ParseOddments(container: Container, binPath: Path, knifeRadius: number = 3.5, squarePath: Path = SquarePath, canPutPaths: Path[] = CanPutPaths): Path[]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//构建轮廓数据
|
|
|
|
let partPaths: ClipInput[] = [];
|
|
|
|
let partPaths: ClipInput[] = container.PlacedParts.map(part =>
|
|
|
|
for (let part of container.PlacedParts)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//直接在这里偏移,而不缓存,应该没有性能问题
|
|
|
|
//外偏移一个刀半径
|
|
|
|
let newPts = clipperCpp.lib.offsetToPaths({
|
|
|
|
let offsetPathArray = clipperCpp.lib.offsetToPaths({
|
|
|
|
delta: knifeRadius * 1e4,
|
|
|
|
delta: knifeRadius * 1e4,
|
|
|
|
offsetInputs: [{ data: part.State.Contour.BigIntPoints, joinType: JoinType.Miter, endType: EndType.ClosedPolygon }]
|
|
|
|
offsetInputs: [{ data: part.State.Contour.BigIntPoints, joinType: JoinType.Miter, endType: EndType.ClosedPolygon }]
|
|
|
|
})[0];
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let path = PathTranslate(newPts, { x: part.PlacePosition.x - 5e3, y: part.PlacePosition.y - 5e3 });//因为移动了0.5,0.5,所以这里也要移动0.5
|
|
|
|
for (let path of offsetPathArray)
|
|
|
|
return { data: path };
|
|
|
|
{
|
|
|
|
});
|
|
|
|
let movePath = PathTranslate(path, { x: part.PlacePosition.x - 5e3, y: part.PlacePosition.y - 5e3 });//因为移动了0.5,0.5,所以这里也要移动0.5
|
|
|
|
|
|
|
|
partPaths.push({ data: movePath });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//所有的余料(使用布尔差集)
|
|
|
|
//所有的余料(使用布尔差集)
|
|
|
|
let oddmentsPolygon = clipperCpp.lib.clipToPolyTree({
|
|
|
|
let oddmentsPolygon = clipperCpp.lib.clipToPolyTree({
|
|
|
|