This commit is contained in:
ChenX
2023-05-30 18:22:43 +08:00
parent 738c42e64e
commit bf1b1186c1
108 changed files with 389 additions and 272 deletions

View File

@@ -234,7 +234,10 @@ class IHostApplicationServices {
noModeingData: "",
statTk: false,
statSt: false,
drillRemark: false //拆单获取排钻备注
drillRemark: false,
checkSealType: "1",
sealMaxValue: 10,
sealValues: '' //封边值列表
};
this.viewSize = {
minViewHeight: 1e-3,
@@ -2127,6 +2130,32 @@ exports.EntityColorHistoryRecord = __decorate([
Factory
], exports.EntityColorHistoryRecord);
var StoreageKeys;
(function (StoreageKeys) {
StoreageKeys["IsLogin"] = "isLogin";
StoreageKeys["PlatSession"] = "platSession";
StoreageKeys["PlatToken"] = "platToken";
StoreageKeys["UserName"] = "userName";
StoreageKeys["UserPhone"] = "userPhone";
StoreageKeys["ShopName"] = "shopName";
StoreageKeys["AgentShopName"] = "AgentShopName";
StoreageKeys["AgentPhone"] = "AgentPhone";
StoreageKeys["VersionName"] = "VersionName";
StoreageKeys["RegisterTime"] = "RegisterTime";
StoreageKeys["RenderType"] = "renderType";
StoreageKeys["ExactDrill"] = "openExactDrill";
StoreageKeys["ConfigName"] = "configName_";
StoreageKeys["IsNewErp"] = "isNewErp";
StoreageKeys["RoomName"] = "roomName";
StoreageKeys["LastOpenFileId"] = "lastfid";
StoreageKeys["Uid"] = "uid";
StoreageKeys["Goods"] = "Goods_";
StoreageKeys["DrillTemp"] = "drilltemp_";
StoreageKeys["DrillReactor"] = "drillRreactor";
StoreageKeys["kjlConfig"] = "kjl";
StoreageKeys["HistoryWs"] = "HistoryWs";
})(StoreageKeys || (StoreageKeys = {}));
let OPERATORS = new Set(["+", "-", "*", "/"]);
/**
* eval2("+10", { L: 100 }, "L")
@@ -2170,32 +2199,6 @@ function ParseExpr(expr, params) {
return expr;
}
var StoreageKeys;
(function (StoreageKeys) {
StoreageKeys["IsLogin"] = "isLogin";
StoreageKeys["PlatSession"] = "platSession";
StoreageKeys["PlatToken"] = "platToken";
StoreageKeys["UserName"] = "userName";
StoreageKeys["UserPhone"] = "userPhone";
StoreageKeys["ShopName"] = "shopName";
StoreageKeys["AgentShopName"] = "AgentShopName";
StoreageKeys["AgentPhone"] = "AgentPhone";
StoreageKeys["VersionName"] = "VersionName";
StoreageKeys["RegisterTime"] = "RegisterTime";
StoreageKeys["RenderType"] = "renderType";
StoreageKeys["ExactDrill"] = "openExactDrill";
StoreageKeys["ConfigName"] = "configName_";
StoreageKeys["IsNewErp"] = "isNewErp";
StoreageKeys["RoomName"] = "roomName";
StoreageKeys["LastOpenFileId"] = "lastfid";
StoreageKeys["Uid"] = "uid";
StoreageKeys["Goods"] = "Goods_";
StoreageKeys["DrillTemp"] = "drilltemp_";
StoreageKeys["DrillReactor"] = "drillRreactor";
StoreageKeys["kjlConfig"] = "kjl";
StoreageKeys["HistoryWs"] = "HistoryWs";
})(StoreageKeys || (StoreageKeys = {}));
/**扣除封边是否相连和连接共用精度 */
const LINK_FUZZ = 1e-3;
function clamp(value, min, max) {
@@ -3679,6 +3682,8 @@ class PlaneExt extends three.Plane {
}
}
const ROTATE_MTX2 = new Matrix2().set(0, -1, 1, 0);
var Line_1;
exports.Line = Line_1 = class Line extends exports.Curve {
constructor(_StartPoint = new three.Vector3, _EndPoint = new three.Vector3) {
@@ -3963,10 +3968,12 @@ exports.Line = Line_1 = class Line extends exports.Curve {
return this;
}
GetOffsetCurves(offsetDist) {
let derv = this.GetFistDeriv(0).normalize().multiplyScalar(offsetDist);
derv.applyMatrix4(new three.Matrix4().makeRotationAxis(this.Normal, -Math.PI / 2));
let offset = this._EndPoint.clone().sub(this._StartPoint).normalize().multiplyScalar(offsetDist);
ROTATE_MTX2.applyVector(offset);
let newLine = this.Clone();
newLine.SetStartEndPoint(this.StartPoint.add(derv), this.EndPoint.add(derv));
newLine.ClearDraw();
newLine._StartPoint.add(offset);
newLine._EndPoint.add(offset);
return [newLine];
}
get BoundingBox() {
@@ -4782,9 +4789,18 @@ exports.Circle = Circle_1 = __decorate([
Factory
], exports.Circle);
const ARC_SplitLength = 4; //圆的分段长度
const ARC_SplitLength = 0.4; //圆的分段长度(虚幻引擎的尺寸单位是厘米)
const ARC_RADIUS_MIN = 2.5; //大于半径25的自动优化成36等分圆 保证绘制光滑
const Arc_MinSplitCount = 8; //圆的最小分段个数
const ARC_MaxSplitCount = 90; //圆的最大分段个数
function GetArcDrawCount(arc) {
let splitCount = arc.Radius / ARC_SplitLength;
//保证是偶数(避免奇数和Shape2计算方式一致导致的干涉)
splitCount = clamp(Math.floor(splitCount * 0.5) * 2, Arc_MinSplitCount, ARC_MaxSplitCount);
if (arc.Radius > ARC_RADIUS_MIN)
splitCount = Math.max(36, splitCount);
return splitCount;
}
/**
*
* @param cu
@@ -4792,9 +4808,7 @@ const ARC_MaxSplitCount = 90; //圆的最大分段个数
function SplitCurveParams(cu) {
let xparams = [];
if (cu instanceof exports.Circle) {
let splitCount = cu.Radius / ARC_SplitLength;
//保证是偶数(避免奇数和Shape2计算方式一致导致的干涉)
splitCount = clamp(Math.floor(splitCount * 0.5) * 2, Arc_MinSplitCount, ARC_MaxSplitCount);
let splitCount = GetArcDrawCount(cu);
for (let i = 0; i < splitCount; i++)
xparams.push(i / splitCount);
}
@@ -4805,8 +4819,7 @@ function SplitCurveParams(cu) {
if (!equaln$1(cu.GetBulgeAt(i), 0, BUL_IS_LINE_FUZZ)) // is arc
{
let arc = cu.GetCurveAtIndex(i);
let splitCount = arc.Radius / ARC_SplitLength;
splitCount = clamp(Math.floor(splitCount), Arc_MinSplitCount, ARC_MaxSplitCount);
let splitCount = GetArcDrawCount(arc);
if (splitCount === 0)
continue;
let a = Math.PI * 2 / splitCount;
@@ -4831,8 +4844,7 @@ function SplitCurveParams(cu) {
function SplitCurvePoints(cu) {
let pts = [];
if (cu instanceof exports.Circle) {
let splitCount = cu.Radius / ARC_SplitLength;
splitCount = clamp(Math.floor(splitCount), Arc_MinSplitCount, ARC_MaxSplitCount);
let splitCount = GetArcDrawCount(cu);
for (let i = 0; i < splitCount; i++)
pts.push(cu.GetPointAtParam(i / splitCount));
}
@@ -4843,8 +4855,7 @@ function SplitCurvePoints(cu) {
if (!equaln$1(cu.GetBulgeAt(i), 0, BUL_IS_LINE_FUZZ)) // is arc
{
let arc = cu.GetCurveAtIndex(i);
let splitCount = arc.Radius / ARC_SplitLength;
splitCount = clamp(Math.floor(splitCount), Arc_MinSplitCount, ARC_MaxSplitCount);
let splitCount = GetArcDrawCount(arc);
if (splitCount === 0)
continue;
let divParam = 1 / splitCount;
@@ -4858,8 +4869,7 @@ function SplitCurvePoints(cu) {
return pts;
}
function SplitArcParams(arc) {
let splitCount = arc.Radius / ARC_SplitLength;
splitCount = clamp(Math.floor(splitCount), Arc_MinSplitCount, ARC_MaxSplitCount);
let splitCount = GetArcDrawCount(arc);
if (splitCount === 0)
return [];
let a = Math.PI * 2 / splitCount;
@@ -4894,8 +4904,7 @@ class Shape2 extends three.Shape {
tempArc.EndAngle = curve.aEndAngle;
tempArc.Radius = Math.abs(curve.xRadius);
//根据圆的半径来确定绘制个数(与SplitCurveParams一致)
let splitCount = tempArc.Radius / ARC_SplitLength;
splitCount = clamp(Math.floor(splitCount * 0.5) * 2, Arc_MinSplitCount, ARC_MaxSplitCount);
let splitCount = GetArcDrawCount(tempArc);
resolution = Math.max(1, Math.ceil(Math.abs((tempArc.AllAngle * 0.5) / Math.PI) * splitCount * 0.5)) * 2;
}
else
@@ -9815,10 +9824,10 @@ function GetPointAtCurveDir(cu, pt) {
let cp = cu.GetClosestPointTo(pt, false);
if (equalv3(cp, pt, 1e-6))
return 0;
//最近点参数
let cparam = cu.GetParamAtPoint(cp);
let dri = cu.GetFistDeriv(cparam);
let cross = dri.cross(pt.clone().sub(cp)).applyMatrix4(cu.OCSInv);
//最近点的切线
let deriv = cu.GetFistDeriv(cu.GetParamAtPoint(cp));
let vec2 = pt.clone().sub(cp);
let cross = deriv.cross(vec2).applyMatrix4(cu.OCSInv.setPosition(0, 0, 0));
return -Math.sign(cross.z);
}
function ConverCircleToPolyline(cir) {
@@ -12965,11 +12974,24 @@ function Max(arr, compart) {
return bestIndex;
}
var LogType;
(function (LogType) {
LogType["Error"] = "ERROR";
LogType["Warning"] = "WARNING";
LogType["Info"] = "INFO";
LogType["Command"] = "COMMAND";
LogType["All"] = "ALL";
})(LogType || (LogType = {}));
const _LogInjectFunctions = [];
function Log(message, ...optionalParams) {
for (let f of _LogInjectFunctions)
f(message, ...optionalParams);
}
const _LogInjectInteractionFunctions = [];
function InteractionLog(message, ...optionalParams) {
for (let f of _LogInjectInteractionFunctions)
f(message, ...optionalParams);
}
/**
* 使用轮廓和扫描路径构建扫描几何体,实现衣柜中的顶线或者地脚线之类的实体.
@@ -13411,7 +13433,7 @@ exports.SweepSolid = SweepSolid_1 = class SweepSolid extends exports.Entity {
else
this._Contour.ApplyMatrix(toWcsMat4);
}
Log("错误:提供的轮廓没有和路径垂直!");
Log("错误:提供的轮廓没有和路径垂直!", LogType.Error);
}
get MeshGeometry() {
if (this._MeshGeometry)
@@ -13695,7 +13717,7 @@ exports.SweepSolid = SweepSolid_1 = class SweepSolid extends exports.Entity {
this._PathCurve = file.ReadObject();
if (this._Contour instanceof exports.Spline || this._PathCurve instanceof exports.Spline) {
this._isErase = true;
Log("放样实体是样条线生成的,自动删除它!");
Log("放样实体是样条线生成的,自动删除它!", LogType.Info);
}
}
WriteFile(file) {
@@ -13960,10 +13982,11 @@ class LookOverBoardInfosTool {
sealCount.push({ name: k, count: v / 1000, unit: "米" });
}
for (let [k, bs] of this.boardMap) {
const chaiDan = bs.filter(b => b.IsChaiDan);
areaCount.push({
entity: bs[0],
count: bs.length,
count2: this.GetBoardsArea(bs)
count: chaiDan.length,
count2: this.GetBoardsArea(chaiDan)
});
}
return { drillCount, hardwareCount, sealCount, areaCount };
@@ -13993,21 +14016,25 @@ class LookOverBoardInfosTool {
addDrillToMap(`${name},${unit},${factory},${this.ParseSpec(h, spec)},${model},${brand}`, h);
}
this.UpdateBoardMap(brsProps);
for (let b of brsProps) {
let dlist = b.DrillList;
if (equaln$1(b.ContourCurve.Area, 0)) {
//统计 排钻 封边 关联的五金(排钻?)
for (let br of brsProps) {
if (!br.IsChaiDan) //非拆单板我们不统计
continue;
//排钻 层板钉
let dlist = br.DrillList;
if (equaln$1(br.ContourCurve.Area, 0)) {
ToasterShowEntityMsg({
msg: `${b.BoardProcessOption.roomName} ${b.BoardProcessOption.cabinetName} ${b.Name}轮廓有有问题,请检查`,
msg: `${br.BoardProcessOption.roomName} ${br.BoardProcessOption.cabinetName} ${br.Name}轮廓有有问题,请检查`,
timeout: 5000,
intent: Intent.DANGER,
ent: b
ent: br
});
continue;
}
for (let [id, idList] of dlist) {
for (let ids of idList) {
let holes = ids.map(id => id.Object).filter(h => h);
if (!holes[0] || !HoleInBoard(holes, b))
if (!holes[0] || !HoleInBoard(holes, br))
continue;
let isTk = false;
let spliteName;
@@ -14019,7 +14046,7 @@ class LookOverBoardInfosTool {
break;
const group = gd.GroupId?.Object;
if (!group) {
Toaster({ message: `柜名:${b.BoardProcessOption.cabinetName} 板名:${b.Name} 的排钻的编组丢失,统计排钻个数时会丢失该个数!`, timeout: 5000, intent: Intent.DANGER });
Toaster({ message: `柜名:${br.BoardProcessOption.cabinetName} 板名:${br.Name} 的排钻的编组丢失,统计排钻个数时会丢失该个数!`, timeout: 5000, intent: Intent.DANGER });
break;
}
if (gd instanceof exports.CylinderHole) {
@@ -14065,13 +14092,13 @@ class LookOverBoardInfosTool {
}
}
// 被复制的层板钉暂未加入LayerNails数组 等做好关联后解除注释
if (b.LayerNails.length > 0)
for (let objId of b.LayerNails) {
if (br.LayerNails.length > 0)
for (let objId of br.LayerNails) {
if (!objId?.IsErase)
addDrillToMap("层板钉", objId.Object);
}
//分析五金
for (const mId of b.RelativeHardware) {
for (const mId of br.RelativeHardware) {
let metal = mId?.Object;
if (metal && !metal.IsErase && metal.HardwareOption) {
let { name, unit, factory, spec, model, brand } = metal.HardwareOption;
@@ -14079,24 +14106,24 @@ class LookOverBoardInfosTool {
}
}
//封边
let sealContour = GetSealedBoardContour(b, true, true);
let sealContour = GetSealedBoardContour(br, true, true);
if (!sealContour) {
ToasterShowEntityMsg({
intent: Intent.DANGER,
msg: "板件扣封边失败,请检查板件轮廓!",
timeout: 10000,
ent: b
ent: br
});
throw "错误:板扣除封边失败!";
}
let sealData = GetBoardSealingData(sealContour);
let color = b.BoardProcessOption[EBoardKeyList.Color];
let color = br.BoardProcessOption[EBoardKeyList.Color];
for (let data of sealData) {
if (equaln$1(0, data.size))
continue;
let k = `${data.size}-${FixedNotZero(b.Thickness, 2)}-${color}`;
let k = `${data.size}-${FixedNotZero(br.Thickness, 2)}-${color}`;
if (options && options.sealGruopKey) {
options.sealGruopKey(k, b, data.size);
options.sealGruopKey(k, br, data.size);
}
let len = this.sealMap.get(k);
if (!len)
@@ -15907,7 +15934,7 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
this.width = size.x;
this.height = size.y;
if (equaln$1(size.x, 0) || equaln$1(size.y, 0))
Log(`注意!!该板件尺寸为0!`);
Log(`注意!!该板件尺寸为0!`, LogType.Warning);
this.isRect = equaln$1(this.width * this.height, this.ContourCurve.Area, 0.1);
// if (area2 < 0)
// this.contourCurve.Reverse();//矩形板的封边与排钻不需要考虑 异形板的排钻封边可能会错误(无所谓了)
@@ -16056,9 +16083,9 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
if (!equaln$1(sum1, sum2) || !equaln$1(area1, area2)) {
if (!this.ReadFileIng && this instanceof exports.Board) {
if (this.Id)
Log(`${this.Name}(${this.Id.Index})被切割成功!`);
InteractionLog([{ msg: `${this.Name}(${this.Id.Index})`, entity: [this] }, { msg: "被切割成功" }], LogType.Info);
else if (this.__OriginalId__)
Log(`${this.Name}(${this.__OriginalId__.Index})关联切割成功更新槽!`);
InteractionLog([{ msg: `${this.Name}(${this.__OriginalId__.Index})`, entity: [this] }, { msg: "关联切割成功更新槽!" }], LogType.Info);
}
return true;
}
@@ -16813,7 +16840,7 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
this instanceof exports.Board &&
this.__CacheVolume__ !== undefined &&
!equaln$1(this.__CacheVolume__, this.Volume))
Log(`${this.Name}(${id.Index})关联槽已逃离!`);
InteractionLog([{ msg: `${this.Name}(${id.Index})`, entity: [this] }, { msg: "关联槽已逃离!" }], LogType.Warning);
this.__CacheVolume__ = undefined;
this.__CacheSplitExtrudes = [this];
}
@@ -16824,7 +16851,7 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
this instanceof exports.Board &&
this.__CacheVolume__ !== undefined &&
!equaln$1(this.__CacheVolume__, this.Volume))
Log(`${this.Name}(${this.Id.Index})关联槽已逃离或者被清除!`);
InteractionLog([{ msg: `${this.Name}(${this.Id.Index})`, entity: [this] }, { msg: "关联槽已逃离或者被清除!" }], LogType.Warning);
this.__CacheSplitExtrudes = [this];
this.__CacheVolume__ = undefined;
}
@@ -19532,17 +19559,17 @@ var Production;
return;
if (!(z0 < CanDrawHoleFuzz || z1 > (br.Thickness - CanDrawHoleFuzz))) //禁止在中间挖洞
{
Log(`警告:板:{${br.Name}}的孔嵌在板中间,无法加工,已经跳过!`);
InteractionLog([{ msg: "警告:" }, { msg: `板件${br.Name}`, entity: [br] }, { msg: "的孔嵌在板中间,无法加工,已经跳过!" }], LogType.Warning);
return;
}
if (!(outline.PtInCurve(p))) //在轮廓内
{
Log(`警告:板:{${br.Name}}的孔不在板轮廓内,无法加工,已经跳过!`);
InteractionLog([{ msg: "警告:" }, { msg: `板件${br.Name}`, entity: [br] }, { msg: "的孔不在板轮廓内,无法加工,已经跳过!" }], LogType.Warning);
return;
}
if (groovesOutlines.some(g => g.PtInCurve(p))) //在洞内
{
Log(`警告:板:{${br.Name}}的孔在造型内,无法加工,已经跳过!`);
InteractionLog([{ msg: "警告:" }, { msg: `板件${br.Name}`, entity: [br] }, { msg: "的孔在造型内,无法加工,已经跳过!" }], LogType.Warning);
return;
}
let depth = z0 < CanDrawHoleFuzz ? z1 : br.Thickness - z0;
@@ -19573,7 +19600,7 @@ var Production;
let line = new exports.Line(sp, ep);
let pt = outline.IntersectWith(line, 0)[0];
if (!pt) {
Log(`警告:板:${br.Name}的排钻嵌在板件内部,已经跳过!`);
InteractionLog([{ msg: "警告:" }, { msg: `板件${br.Name}`, entity: [br] }, { msg: "的排钻嵌在板件内部,已经跳过!" }], LogType.Warning);
return;
}
let position = pt.clone().setZ(oldZ);
@@ -29231,7 +29258,7 @@ function BuildLayerBoards(opt, space, grooveOption) {
let frontShrink = safeEval(opt.calcFrontShrink, params);
width -= frontShrink;
if (width <= 0) {
Log("宽度无效,可能前缩过大,请修正");
Log("宽度无效,可能前缩过大,请修正", LogType.Error);
return [];
}
let leftShrink = safeEval(opt.calcLeftShrink, params);
@@ -29239,7 +29266,7 @@ function BuildLayerBoards(opt, space, grooveOption) {
let thickness = opt.thickness;
let len = size.x - leftShrink - rightShrink;
if (len <= 0) {
Log("长度无效,可能左缩右缩过大,请修正");
Log("长度无效,可能左缩右缩过大,请修正", LogType.Error);
return [];
}
let board = exports.Board.CreateBoard(len, width, thickness, BoardType.Layer);
@@ -29283,7 +29310,7 @@ function BuildVerticalBoards(opt, space, grooveOption) {
width = safeEval(opt.calcWidth, params);
}
if (width <= 0) {
Log("宽度无效,可能前缩过大,请修正");
Log("宽度无效,可能前缩过大,请修正", LogType.Error);
return [];
}
let length;
@@ -29477,10 +29504,10 @@ class DrawLatticeDrawerTool extends Singleton {
config.arcLen = addH;
}
else
Log("挡板高度大于等于格子抽板高度,无法自动识别弧度!");
Log("挡板高度大于等于格子抽板高度,无法自动识别弧度!", LogType.Error);
}
if (this.haveTopBr) {
Log("顶板不为空,绘制格子抽可能错误!");
Log("顶板不为空,绘制格子抽可能错误!", LogType.Error);
}
}
ChangeLeftRightBr(refBr) {
@@ -29573,7 +29600,7 @@ class DrawLatticeDrawerTool extends Singleton {
}
else {
if (config.arcLen > size.z || config.arcLen > size.y) {
Log("圆弧角过大");
Log("圆弧角过大", LogType.Error);
return false;
}
let cu = br.ContourCurve;
@@ -31633,7 +31660,7 @@ exports.TemplateRecord = TemplateRecord_1 = class TemplateRecord extends SymbolT
this._Positioning.SpaceSize = new three.Vector3(this.LParam.value, this.WParam.value, this.HParam.value);
}
else {
Log(`模块:(${this.name})定位错误!`);
Log(`模块:(${this.name})定位错误!`, LogType.Error);
return; //出事故
}
}
@@ -35004,8 +35031,6 @@ exports.LineAngularDimension = __decorate([
Factory
], exports.LineAngularDimension);
const ROTATE_MTX2 = new Matrix2().set(0, -1, 1, 0);
/**用于提供捕捉的多段线 */
let snapPolyline = new exports.Polyline([{ pt: new three.Vector2, bul: 0 }, { pt: new three.Vector2, bul: 0 }, { pt: new three.Vector2, bul: 0 }, { pt: new three.Vector2, bul: 0 }]);
/**