mirror of https://gitee.com/cf-fz/WebCAD.git
parent
31c15b75f4
commit
07d6fb7e25
@ -0,0 +1,92 @@
|
|||||||
|
import { Factory } from "../../src/DatabaseServices/CADFactory";
|
||||||
|
import { Board } from "../../src/DatabaseServices/Board";
|
||||||
|
import { CADFile } from "../../src/DatabaseServices/CADFile";
|
||||||
|
import { Curve } from "../../src/DatabaseServices/Curve";
|
||||||
|
import { calcEdgeSealing } from "../../src/GraphicsSystem/CalcEdgeSealing";
|
||||||
|
import { Polyline } from "../../src/DatabaseServices/Polyline";
|
||||||
|
|
||||||
|
Factory(Board);
|
||||||
|
|
||||||
|
function loadFile(data)
|
||||||
|
{
|
||||||
|
let file = new CADFile();
|
||||||
|
file.Data = data;
|
||||||
|
let brs: Board[] = [];
|
||||||
|
let count = file.Read();
|
||||||
|
for (let i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
brs.push(file.ReadObject(undefined) as Board);
|
||||||
|
}
|
||||||
|
return brs;
|
||||||
|
}
|
||||||
|
function testBrSealing(br: Board, sealingSize: number[])
|
||||||
|
{
|
||||||
|
let originCurve = br.Shape.Outline.Curve;
|
||||||
|
let dir = Math.sign(originCurve.Area2) * -1;
|
||||||
|
let calcCus = originCurve.Explode() as Curve[];
|
||||||
|
let offsetCus: Curve[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < calcCus.length; i++)
|
||||||
|
{
|
||||||
|
let cu = calcCus[i];
|
||||||
|
offsetCus.push(...cu.GetOffsetCurves(sealingSize[i] * dir))
|
||||||
|
}
|
||||||
|
calcEdgeSealing(offsetCus);
|
||||||
|
let pl = new Polyline();
|
||||||
|
for (let cu of offsetCus)
|
||||||
|
{
|
||||||
|
let res = pl.Join(cu);
|
||||||
|
expect(res).toBeTruthy();
|
||||||
|
}
|
||||||
|
pl.ApplyMatrix(br.OCS);
|
||||||
|
expect(pl.IsClose).toBeTruthy();
|
||||||
|
expect(pl.Area).toMatchSnapshot();
|
||||||
|
}
|
||||||
|
test("常规板件,常规坐标系", () =>
|
||||||
|
{
|
||||||
|
let data = [1, ["Board", 1, 1, 3, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 145.29914529914527, -290.5982905982906, 0, 1], 0, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]]
|
||||||
|
let layerBr = loadFile(data)[0];
|
||||||
|
let sealingSize = [1, 1, 1, 1];
|
||||||
|
testBrSealing(layerBr, sealingSize);
|
||||||
|
sealingSize = [3, 2, 3, 2];
|
||||||
|
testBrSealing(layerBr, sealingSize);
|
||||||
|
data = [1, ["Board", 1, 1, 3, false, 7, -1, [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -292.022792022792, -213.67521367521368, 0, 1], 1, 1, ["Polyline", 1, 1, -1, false, 7, -1, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 2, 4, [0, 0], 0, [600, 0], 0, [600, 1200], 0, [0, 1200], 0, true], 0, 1200, 600, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -292.022792022792, -213.67521367521368, 0, 1], 1, "", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]]
|
||||||
|
let vBr = loadFile(data)[0];
|
||||||
|
sealingSize = [2, 2, 2, 2];
|
||||||
|
testBrSealing(vBr, sealingSize);
|
||||||
|
})
|
||||||
|
|
||||||
|
test("异型板件,常规坐标系", () =>
|
||||||
|
{
|
||||||
|
let data = [1, ["Board", 1, 1, 9, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 1, 1, ["Polyline", 1, 1, -1, true, 7, -1, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1396.2632810116759, 3681.8686077049847, 0, 1], 2, 5, [2345.694899782759, -1396.263281011676], 0, [3681.8686077049847, -1396.263281011676], 0, [3681.8686077049847, 443.1597468696174], 0.41421356237309503, [3481.8686077049847, 643.1597468696174], 0, [2345.694899782759, 643.1597468696174], 0, true], 0, 1336.1737079222257, 2039.4230278812934, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3681.8686077049847, -1396.263281011676, 0, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]];
|
||||||
|
//第三段为圆弧
|
||||||
|
let br = loadFile(data)[0];
|
||||||
|
let sealingSize = [1, 1, 1, 1, 1];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
sealingSize = [3, 3, 10, 3, 3];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
sealingSize = [10, 10, 5, 5, 10];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
// 2,4,6,8段为圆弧
|
||||||
|
data = [1, ["Board", 1, 1, 11, false, 7, -1, [0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 1, 1, ["Polyline", 1, 1, -1, true, 7, -1, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 1330.0896939146, 6239.212423224621, 0, 1], 2, 8, [5263.6654731094095, -1330.0896939146003], 0, [5939.212423224621, -1330.0896939146003], 0.41421356237309503, [6239.212423224621, -1030.0896939146003], 0, [6239.212423224621, 495.8218896107525], 0.41421356237309503, [5939.212423224621, 795.8218896107526], 0, [5263.6654731094095, 795.8218896107526], 0.4142135623730949, [4963.6654731094095, 495.8218896107527], 0, [4963.6654731094095, -1030.0896939146003], 0.4142135623730949, true], 0, 1275.546950115211, 2125.911583525353, 18, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 6239.212423224621, -1330.0896939146003, 0, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\",\"highSealed\":[]}", 0]]
|
||||||
|
br = loadFile(data)[0];
|
||||||
|
sealingSize = [1, 1, 1, 1, 1, 1, 1, 1];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
sealingSize = [1, 3, 1, 3, 1, 2, 1, 3];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
sealingSize = [5, 3, 5, 3, 5, 2, 5, 3];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
|
||||||
|
})
|
||||||
|
test("异型板件,非常规坐标系", () =>
|
||||||
|
{
|
||||||
|
let data = [1, ["Board", 1, 1, 15, false, 7, -1, [0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 1, 1, ["Polyline", 1, 1, -1, true, 7, -1, [6.123233995736766e-17, -1, 0, 0, 1, 6.123233995736766e-17, 0, 0, 0, 0, 1, 0, 2833.8341445119845, 15844.064994449893, 0, 1], 2, 6, [5008.758238702114, -2833.834144511985], 0, [5008.758238702114, 2775.380162574158], -0.414213562373095, [7222.921780972962, 4989.543704845006], 0, [13759.976048629745, 4989.543704845006], -0.8565683416116343, [14392.594203564273, 919.700241432878], 0, [14076.28512609701, -2833.834144511985], 0, true], 0, 10835.306755747779, 7823.377849356992, 18, [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 15844.064994449893, 0, -2833.834144511985, 1], 0, "层板", "{\"roomName\":\"\",\"cabinetName\":\"\",\"boardName\":\"\",\"material\":\"\",\"color\":\"\",\"lines\":0,\"bigHoleDir\":0,\"drillType\":\"three\",\"composingFace\":2,\"highSealed\":[],\"sealedUp\":\"1.0\",\"sealedDown\":\"1.0\",\"sealedLeft\":\"1.0\",\"sealedRight\":\"1.0\",\"knifeRad\":\"0\",\"grooveAddLength\":\"0\",\"grooveAddWidth\":\"0\",\"grooveAddDepth\":\"0\",\"spliteHeight\":\"\",\"spliteWidth\":\"\",\"spliteThickness\":\"\"}", 0]]
|
||||||
|
//第2,4段为圆弧
|
||||||
|
let br = loadFile(data)[0];
|
||||||
|
let sealingSize = [1, 1, 1, 1, 1, 1];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
sealingSize = [3, 5, 3, 3, 3, 3];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
sealingSize = [10, 5, 5, 5, 10, 5];
|
||||||
|
testBrSealing(br, sealingSize);
|
||||||
|
})
|
@ -0,0 +1,25 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`常规板件,常规坐标系 1`] = `716404`;
|
||||||
|
|
||||||
|
exports[`常规板件,常规坐标系 2`] = `711624`;
|
||||||
|
|
||||||
|
exports[`常规板件,常规坐标系 3`] = `712816`;
|
||||||
|
|
||||||
|
exports[`异型板件,常规坐标系 1`] = `2709777.7883832143`;
|
||||||
|
|
||||||
|
exports[`异型板件,常规坐标系 2`] = `2696477.36609459`;
|
||||||
|
|
||||||
|
exports[`异型板件,常规坐标系 3`] = `2657160.4995995373`;
|
||||||
|
|
||||||
|
exports[`异型板件,常规坐标系 4`] = `2628158.6443366623`;
|
||||||
|
|
||||||
|
exports[`异型板件,常规坐标系 5`] = `2628158.6443366623`;
|
||||||
|
|
||||||
|
exports[`异型板件,常规坐标系 6`] = `2607100.626176849`;
|
||||||
|
|
||||||
|
exports[`异型板件,非常规坐标系 1`] = `75939516.39226122`;
|
||||||
|
|
||||||
|
exports[`异型板件,非常规坐标系 2`] = `75870817.54933015`;
|
||||||
|
|
||||||
|
exports[`异型板件,非常规坐标系 3`] = `75754806.13472572`;
|
@ -1,18 +0,0 @@
|
|||||||
import { fixAngle } from '../../src/Geometry/GeUtils';
|
|
||||||
|
|
||||||
test("GeUtils.angle", () =>
|
|
||||||
{
|
|
||||||
let pi2 = Math.PI * 0.5;
|
|
||||||
let pi4 = pi2 * 0.5;
|
|
||||||
|
|
||||||
console.log(fixAngle(0.05, pi2, 0.1)/*?*/ == 0);
|
|
||||||
|
|
||||||
console.log(fixAngle(0.08, pi2, 0.1)/*?*/ == 0);
|
|
||||||
console.log(fixAngle(0.09, pi2, 0.1)/*?*/ == 0);
|
|
||||||
console.log(fixAngle(-0.05, pi2, 0.1)/*?*/ == Math.PI * 2);
|
|
||||||
|
|
||||||
console.log(fixAngle(Math.PI / 2 + 0.01, pi2, 0.1)/*?*/ == Math.PI / 2);
|
|
||||||
|
|
||||||
console.log(fixAngle(0.3, pi2));
|
|
||||||
})
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 1`] = `1.1376403544773546`;
|
exports[`补充bug测试#IKWGF 1`] = `1.1376403544773552`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 2`] = `0.4457395323615243`;
|
exports[`补充bug测试#IKWGF 2`] = `0.44573953236152586`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 3`] = `10.732981364094249`;
|
exports[`补充bug测试#IKWGF 3`] = `10.732981364094256`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 4`] = `12.786911814880924`;
|
exports[`补充bug测试#IKWGF 4`] = `12.78691181488093`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 5`] = `0.6246933440840133`;
|
exports[`补充bug测试#IKWGF 5`] = `0.6246933440840137`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 6`] = `10.586693752451833`;
|
exports[`补充bug测试#IKWGF 6`] = `10.586693752451833`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 7`] = `14.067113755971715`;
|
exports[`补充bug测试#IKWGF 7`] = `14.067113755971711`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 8`] = `2.168984971098264`;
|
exports[`补充bug测试#IKWGF 8`] = `2.168984971098264`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 9`] = `11.891017922899268`;
|
exports[`补充bug测试#IKWGF 9`] = `11.891017922899273`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 10`] = `1.0803374679586222`;
|
exports[`补充bug测试#IKWGF 10`] = `1.0803374679586235`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 11`] = `0.394745939838908`;
|
exports[`补充bug测试#IKWGF 11`] = `0.39474593983890816`;
|
||||||
|
|
||||||
exports[`补充bug测试#IKWGF 12`] = `10.69886845125427`;
|
exports[`补充bug测试#IKWGF 12`] = `10.69886845125427`;
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
import { FixIndex } from "../Common/Utils";
|
||||||
|
import { Curve } from "../DatabaseServices/Curve";
|
||||||
|
import { Polyline } from "../DatabaseServices/Polyline";
|
||||||
|
import { IntersectOption } from "./IntersectWith";
|
||||||
|
import { PolyOffsetUtil } from "./OffsetPolyline";
|
||||||
|
|
||||||
|
export function calcEdgeSealing(cus: Curve[])
|
||||||
|
{
|
||||||
|
if (cus.length <= 1)
|
||||||
|
return;
|
||||||
|
for (let i = 0; i < cus.length; i++)
|
||||||
|
{
|
||||||
|
let frontLine = cus[i];
|
||||||
|
let laterLine = cus[FixIndex(i + 1, cus)];
|
||||||
|
let iPts = frontLine.IntersectWith(laterLine, IntersectOption.ExtendBoth);
|
||||||
|
let tPts = iPts.filter(p =>
|
||||||
|
frontLine.PtOnCurve(p)
|
||||||
|
&& laterLine.PtOnCurve(p)
|
||||||
|
);
|
||||||
|
|
||||||
|
let iPt = PolyOffsetUtil.selectFitInterPt(tPts.length > 0 ? tPts : iPts, frontLine.EndPoint);
|
||||||
|
|
||||||
|
let iPt1 = iPt.clone();
|
||||||
|
if (frontLine instanceof Polyline)
|
||||||
|
iPt1.applyMatrix4(frontLine.OCSInv);
|
||||||
|
frontLine.EndPoint = iPt1;
|
||||||
|
|
||||||
|
if (laterLine instanceof Polyline)
|
||||||
|
iPt.applyMatrix4(laterLine.OCSInv)
|
||||||
|
laterLine.StartPoint = iPt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,218 @@
|
|||||||
|
import { Button, Classes, Intent, Popover } from '@blueprintjs/core';
|
||||||
|
import { observable } from 'mobx';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
|
import * as React from 'react';
|
||||||
|
import { Matrix4 } from 'three';
|
||||||
|
import { app } from '../../../ApplicationServices/Application';
|
||||||
|
import { Board } from '../../../DatabaseServices/Board';
|
||||||
|
import { Curve } from '../../../DatabaseServices/Curve';
|
||||||
|
import { Line } from '../../../DatabaseServices/Line';
|
||||||
|
import { Polyline } from '../../../DatabaseServices/Polyline';
|
||||||
|
import { Text } from '../../../DatabaseServices/Text/Text';
|
||||||
|
import { Jig } from '../../../Editor/Jig';
|
||||||
|
import { calcEdgeSealing } from '../../../GraphicsSystem/CalcEdgeSealing';
|
||||||
|
|
||||||
|
@observer
|
||||||
|
export class EdgeSealingComponent extends React.Component<{ br: Board }, {}>
|
||||||
|
{
|
||||||
|
private ulList: HTMLUListElement;
|
||||||
|
@observable private cuList: Curve[] = [];
|
||||||
|
constructor(props)
|
||||||
|
{
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
private EditorEdgeSealing = () =>
|
||||||
|
{
|
||||||
|
let br = this.props.br;
|
||||||
|
let cus = br.Shape.Outline.Curve.Explode() as Curve[];
|
||||||
|
|
||||||
|
this.ParagraphCulist(cus);
|
||||||
|
|
||||||
|
app.m_Viewer.m_CameraCtrl.LookAt(br.Normal.negate());
|
||||||
|
app.m_Editor.UCSMatrix = new Matrix4().extractRotation(br.OCS);
|
||||||
|
app.m_Editor.UpdateScreen();
|
||||||
|
|
||||||
|
Jig.Destroy();
|
||||||
|
for (let i = 0; i < this.cuList.length; i++)
|
||||||
|
{
|
||||||
|
let cu = this.cuList[i];
|
||||||
|
let p = cu.GetPointAtParam(cu.EndParam / 2);
|
||||||
|
Jig.Draw(new Text(p, (i + 1).toString()).ApplyMatrix(br.OCS));
|
||||||
|
//显示对应设置的边
|
||||||
|
let refCu = cu.Clone();
|
||||||
|
refCu.ColorIndex = i + 1
|
||||||
|
Jig.Draw(refCu.ApplyMatrix(br.OCS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//曲线列表分段
|
||||||
|
private ParagraphCulist = (cus: Curve[]) =>
|
||||||
|
{
|
||||||
|
let newCulist: Curve[][] = [];
|
||||||
|
let usedCu: WeakSet<Curve> = new WeakSet();
|
||||||
|
|
||||||
|
//归类曲线,返回归类是否成功
|
||||||
|
const paragraph = (cu: Curve, originCu: Curve, cus: Curve[]) =>
|
||||||
|
{
|
||||||
|
if (usedCu.has(cu) || (cu instanceof Line && originCu instanceof Line))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
cus.push(cu);
|
||||||
|
usedCu.add(cu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cus.length > 0)
|
||||||
|
{
|
||||||
|
let originCu = cus.shift();
|
||||||
|
if (usedCu.has(originCu))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
let originCus = [originCu];
|
||||||
|
usedCu.add(originCu);
|
||||||
|
//往后搜索
|
||||||
|
for (let i = 0; i < cus.length; i++)
|
||||||
|
{
|
||||||
|
if (!paragraph(cus[i], originCu, originCus))
|
||||||
|
break;
|
||||||
|
originCu = cus[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
originCu = originCus[0];
|
||||||
|
//往前搜索
|
||||||
|
for (let i = cus.length - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (!paragraph(cus[i], originCu, originCus))
|
||||||
|
break;
|
||||||
|
originCu = cus[i];
|
||||||
|
}
|
||||||
|
newCulist.push(originCus);
|
||||||
|
}
|
||||||
|
|
||||||
|
//同组多条曲线连接为多段线
|
||||||
|
for (let g of newCulist)
|
||||||
|
{
|
||||||
|
if (g.length === 1)
|
||||||
|
cus.push(g[0]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let pl = new Polyline();
|
||||||
|
for (let c of g)
|
||||||
|
{
|
||||||
|
pl.Join(c)
|
||||||
|
}
|
||||||
|
cus.push(pl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//替换曲线列表
|
||||||
|
observable(this.cuList).replace(cus);
|
||||||
|
}
|
||||||
|
private CalcEdgeSealing = () =>
|
||||||
|
{
|
||||||
|
let originCurve = this.props.br.Shape.Outline.Curve;
|
||||||
|
let dir = Math.sign(originCurve.Area2) * -1;
|
||||||
|
|
||||||
|
let infoEls = this.ulList.querySelectorAll('li input');
|
||||||
|
let edgeSealingNum: number[] = [];
|
||||||
|
let highSeal = this.props.br.BoardProcessOption.highSealed;
|
||||||
|
highSeal.length = 0;
|
||||||
|
infoEls.forEach(el =>
|
||||||
|
{
|
||||||
|
let size = parseFloat((el as HTMLInputElement).value);
|
||||||
|
highSeal.push({
|
||||||
|
size
|
||||||
|
})
|
||||||
|
edgeSealingNum.push(size * dir);
|
||||||
|
});
|
||||||
|
|
||||||
|
let calcCus = this.cuList;
|
||||||
|
let offsetCus: Curve[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < calcCus.length; i++)
|
||||||
|
{
|
||||||
|
let cu = calcCus[i];
|
||||||
|
offsetCus.push(...cu.GetOffsetCurves(edgeSealingNum[i]));
|
||||||
|
}
|
||||||
|
calcEdgeSealing(offsetCus);
|
||||||
|
this.ShowSealingResult(offsetCus);
|
||||||
|
}
|
||||||
|
private ShowSealingResult = (offsetCus: Curve[]) =>
|
||||||
|
{
|
||||||
|
offsetCus.forEach((cu, i) =>
|
||||||
|
{
|
||||||
|
cu.ApplyMatrix(this.props.br.OCS);
|
||||||
|
Jig.Draw(cu);
|
||||||
|
})
|
||||||
|
app.m_Editor.UpdateScreen();
|
||||||
|
}
|
||||||
|
render()
|
||||||
|
{
|
||||||
|
let highSeal = this.props.br.BoardProcessOption.highSealed;
|
||||||
|
//兼容以前没有这个属性的版本
|
||||||
|
if (!highSeal)
|
||||||
|
{
|
||||||
|
this.props.br.BoardProcessOption.highSealed = [];
|
||||||
|
highSeal = [];
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Popover
|
||||||
|
usePortal={false}
|
||||||
|
modifiers={{
|
||||||
|
arrow: { enabled: false },
|
||||||
|
flip: { enabled: true },
|
||||||
|
keepTogether: { enabled: true },
|
||||||
|
preventOverflow: { enabled: true, boundariesElement: "scrollParent" }
|
||||||
|
}}
|
||||||
|
content={
|
||||||
|
<div tabIndex={-1} className={Classes.CARD}>
|
||||||
|
<h6 className={Classes.HEADING}>封边编辑</h6>
|
||||||
|
<ul
|
||||||
|
className={Classes.LIST_UNSTYLED}
|
||||||
|
ref={el => this.ulList = el}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
this.cuList.map((cu, i) =>
|
||||||
|
{
|
||||||
|
let defaultValue = "1.0";
|
||||||
|
if (highSeal.length > 0)
|
||||||
|
defaultValue = highSeal[i] ? highSeal[i].size.toString() : "1";
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<label className="bp3-label bp3-inline .modifier">
|
||||||
|
{"封边(" + (i + 1).toString() + ")"}
|
||||||
|
<input
|
||||||
|
defaultValue={defaultValue}
|
||||||
|
className="bp3-input"
|
||||||
|
placeholder="输入封边大小"
|
||||||
|
dir="auto" />
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
<div style={{ display: "flex", justifyContent: "flex-end", marginTop: 15 }}>
|
||||||
|
<Button
|
||||||
|
onClick={this.CalcEdgeSealing}
|
||||||
|
text="确定"
|
||||||
|
className={Classes.POPOVER_DISMISS}
|
||||||
|
intent={Intent.SUCCESS}
|
||||||
|
style={{ marginRight: 10 }} />
|
||||||
|
<Button
|
||||||
|
text="取消"
|
||||||
|
onClick={() => Jig.Destroy()}
|
||||||
|
intent={Intent.DANGER}
|
||||||
|
className={Classes.POPOVER_DISMISS} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
target={
|
||||||
|
<Button
|
||||||
|
onClick={this.EditorEdgeSealing}
|
||||||
|
text="高级编辑"
|
||||||
|
intent="success"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue