!1919 变更:在修改封边时,总是更新板的上下左右封边

pull/1914/MERGE
ChenX 2 years ago
parent 9f30433bea
commit 6c2f51331a

@ -127,14 +127,15 @@ export class ErpParseData
let boardData = Production.GetBoardSplitOrderData(entity);
if (!boardData)
return;//返回空数据,提示用户修改,结束拆单
//封边
if (boardData.info.isRect)
{
// if (boardData.info.isRect)
// {
//矩形和异形封边
block.SealedDown = this.GetNumberBit(Number(entity.BoardProcessOption.sealedDown), 3); //封边下
block.SealedLeft = this.GetNumberBit(Number(entity.BoardProcessOption.sealedLeft), 3); //封边左
block.SealedUp = this.GetNumberBit(Number(entity.BoardProcessOption.sealedUp), 3); //封边上
block.SealedRight = this.GetNumberBit(Number(entity.BoardProcessOption.sealedRight), 3); //封边右
}
//}
let splitSize = Production.GetSpiteSize(entity);
if (splitSize)
{

@ -0,0 +1,27 @@
import { app } from "../../ApplicationServices/Application";
import { Log } from "../../Common/Log";
import { Curve } from "../../DatabaseServices/Entity/Curve";
import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { ParseEdgeSealDir } from "../../GraphicsSystem/ParseEdgeSealDir";
export class Command_TestParseEdgeSealDir implements Command
{
async exec()
{
let ssRes = await app.Editor.GetSelection({ Filter: { filterTypes: [Curve] } });
if (ssRes.Status !== PromptStatus.OK) return;
let ents = ssRes.SelectSet.SelectEntityList as Curve[];
let arr = ParseEdgeSealDir(ents);
Log(`左右上下,1234色,结果:${arr.join(",")}`);
for (let i = 0; i < arr.length; i++)
{
let id = arr[i];
let c = ents[id];
c.ColorIndex = i + 1;
}
}
}

@ -200,6 +200,7 @@ import { Command_TemplateSearch } from "../Add-on/TemplateSearch";
// import { DrawFloor } from '../Add-on/DrawFloor';
// import { RevTarget, SaveTarget } from '../Add-on/RenderTarget';
import { TestIntersect } from "../Add-on/test/testIntersect";
import { Command_TestParseEdgeSealDir } from "../Add-on/test/TestParseEdgeSealDir";
import { Command_TestTape } from "../Add-on/test/TestTape";
import { Command_UpdateLight } from "../Add-on/testEntity/CMD_UpdateLight";
import { Command_DebugTemplateAssocCount } from "../Add-on/testEntity/DebugShowTemplateAssocEntityCount";
@ -526,6 +527,7 @@ export function registerCommand()
//多段线变碎点多段线
commandMachine.RegisterCommand("TestPolyline2PointsPolyline", new Command_TestPolyline2PointsPolyline());
commandMachine.RegisterCommand("TestParseEdgeSealDir", new Command_TestParseEdgeSealDir());
}
commandMachine.RegisterCommand(CommandNames.SimplifyPolyline, new Command_SimplifyPolyline());

@ -14,6 +14,7 @@ import { angle, equaln, equalv3, isParallelTo, SelectNearP, XAxis } from "../Geo
import { Production } from "../Production/Product";
import { IHighSealedItem, ISealingData } from "../UI/Store/BoardInterface";
import { IntersectOption } from "./IntersectWith";
import { ParseEdgeSealDir } from "./ParseEdgeSealDir";
/**
*线
@ -571,17 +572,19 @@ export function HandleRectBoardSealingData(br: Board, edges: IHighSealedItem[],
if (!cus)
cus = br.ContourCurve.Explode() as Curve[];
let param = { L: br.Height, W: br.Width, H: br.Thickness };
let spliteHeight = safeEval(br.BoardProcessOption.spliteHeight, param, "L");
let spliteWidth = safeEval(br.BoardProcessOption.spliteWidth, param, "W");
let spliteThickness = safeEval(br.BoardProcessOption.spliteThickness, param, "H");
//现在我们不管是否有拆单尺寸,我们总是关系封边值
// let param = { L: br.Height, W: br.Width, H: br.Thickness };
// let spliteHeight = safeEval(br.BoardProcessOption.spliteHeight, param, "L");
// let spliteWidth = safeEval(br.BoardProcessOption.spliteWidth, param, "W");
// let spliteThickness = safeEval(br.BoardProcessOption.spliteThickness, param, "H");
// if ((spliteHeight && spliteWidth && spliteThickness) || !br.IsSpecialShape && cus.length === 4)
if ((spliteHeight && spliteWidth && spliteThickness) || !br.IsSpecialShape && cus.length === 4)
if (!br.IsSpecialShape && cus.length === 4)
{
for (let i = 0; i < 4; i++)
{
let derv = cus[i].GetFistDeriv(0);
if (isParallelTo(derv, XAxis))
let derv = cus[i].GetFistDeriv(0).normalize();
if (isParallelTo(derv, XAxis, 1e-4))
{
if (derv.x * dir > 0)
br.BoardProcessOption[EBoardKeyList.DownSealed] = edges[i].size.toString();
@ -596,6 +599,13 @@ export function HandleRectBoardSealingData(br: Board, edges: IHighSealedItem[],
br.BoardProcessOption[EBoardKeyList.LeftSealed] = edges[i].size.toString();
}
}
}
else
{
let [left, right, top, bottom] = ParseEdgeSealDir(cus);
br.BoardProcessOption[EBoardKeyList.LeftSealed] = edges[left].size.toString();
br.BoardProcessOption[EBoardKeyList.RightSealed] = edges[right].size.toString();
br.BoardProcessOption[EBoardKeyList.UpSealed] = edges[top].size.toString();
br.BoardProcessOption[EBoardKeyList.DownSealed] = edges[bottom].size.toString();
}
}

@ -0,0 +1,59 @@
import Flatbush from 'flatbush';
import { Box3, Vector3 } from "three";
import { Curve } from "../DatabaseServices/Entity/Curve";
import { XAxis, YAxis } from '../Geometry/GeUtils';
/**
* 线线
* @param curves
*/
export function ParseEdgeSealDir(curves: Curve[]): [number, number, number, number]
{
let boxAll = new Box3;
let boxs: Box3[] = [];
let fb = new Flatbush(curves.length);
for (let c of curves)
{
let box = c.BoundingBox;
boxs.push(box);
boxAll.union(box);
fb.add(box.min.x, box.min.y, box.max.x, box.max.y);
}
fb.finish();
let leftids = fb.search(boxAll.min.x - 1, boxAll.min.y - 1, boxAll.min.x + 1, boxAll.max.y + 1);
let rightids = fb.search(boxAll.max.x - 1, boxAll.min.y - 1, boxAll.max.x + 1, boxAll.max.y + 1);
let topids = fb.search(boxAll.min.x - 1, boxAll.max.y - 1, boxAll.max.x + 1, boxAll.max.y + 1);
let bottomids = fb.search(boxAll.min.x - 1, boxAll.min.y - 1, boxAll.max.x + 1, boxAll.min.y + 1);
const FindBestCurveIndex = (ids: number[], dirRef: Vector3) =>
{
if (ids.length === 1) return ids[0];
let maxLength = -Infinity;
let bestIndex = -1;
for (let id of ids)
{
let c = curves[id];
let dir = c.EndPoint.sub(c.StartPoint).normalize();
let length = Math.abs(dir.dot(dirRef));//取模(模越长 表示和dirRef越平行(接近))
if (length > maxLength)
{
bestIndex = id;
maxLength = length;
}
}
return bestIndex;
};
let left = FindBestCurveIndex(leftids, YAxis);
let right = FindBestCurveIndex(rightids, YAxis);
let top = FindBestCurveIndex(topids, XAxis);
let bottom = FindBestCurveIndex(bottomids, XAxis);
return [left, right, top, bottom];
}
Loading…
Cancel
Save