开发:清理全局导入THREE
This commit is contained in:
405
api.esm.js
405
api.esm.js
@@ -1,4 +1,3 @@
|
||||
import * as THREE from 'three';
|
||||
import { Vector3, Matrix4, Box3, Color, MeshPhysicalMaterial, Object3D, Vector2 as Vector2$1, Quaternion, MathUtils, Shape as Shape$1, EllipseCurve, FrontSide, LineDashedMaterial, DoubleSide, MeshBasicMaterial, LineBasicMaterial, ShaderMaterial, BufferGeometry, ShapeGeometry, BufferAttribute, Line as Line$1, Plane, Line3, CatmullRomCurve3, Path as Path$1, LineSegments, Mesh, CylinderBufferGeometry, Float32BufferAttribute, Geometry, ShapeUtils, Face3, BoxBufferGeometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, ExtrudeGeometry, BoxGeometry, AmbientLight as AmbientLight$1, DirectionalLightHelper, SphereBufferGeometry, Matrix3, Group, DirectionalLight as DirectionalLight$1, HemisphereLight as HemisphereLight$1, MirroredRepeatWrapping, Texture, OrthographicCamera, PerspectiveCamera, Scene, WebGLRenderTarget, Frustum, MeshNormalMaterial, PointLight as PointLight$1, SphereGeometry, BackSide, RectAreaLight as RectAreaLight$1, SpotLight as SpotLight$1, ConeGeometry, PointsMaterial, Points, Box2 as Box2$1, Raycaster } from 'three';
|
||||
import { iaop, end } from 'xaop';
|
||||
import { Line2 } from 'three/examples/jsm/lines/Line2';
|
||||
@@ -461,6 +460,7 @@ function AutoRecord(target, property, descriptor) {
|
||||
});
|
||||
}
|
||||
|
||||
const UE_REX_DEL = /_.*/g;
|
||||
/**
|
||||
* CAD对象工厂,通过注册 和暴露的创建方法,动态创建对象
|
||||
*/
|
||||
@@ -469,7 +469,7 @@ class CADFactory {
|
||||
this.objectNameMap = new Map();
|
||||
}
|
||||
static RegisterObject(C) {
|
||||
this.factory.objectNameMap.set(C.name, C);
|
||||
this.factory.objectNameMap.set(C.name.replace(UE_REX_DEL, ""), C);
|
||||
}
|
||||
static RegisterObjectAlias(C, name) {
|
||||
this.factory.objectNameMap.set(name, C);
|
||||
@@ -9409,7 +9409,7 @@ function ConverCircleToPolyline(cir) {
|
||||
// return pl;
|
||||
let arcs = cir.GetSplitCurves([0, 0.5]);
|
||||
let pl = new Polyline();
|
||||
pl.OCS = cir.OCS;
|
||||
pl.OCS = cir.OCSNoClone;
|
||||
pl.Join(arcs[0]);
|
||||
pl.Join(arcs[1]);
|
||||
return pl;
|
||||
@@ -13437,7 +13437,7 @@ class LookOverBoardInfosTool {
|
||||
Toaster({ message: `柜名:${b.BoardProcessOption.cabinetName} 板名:${b.Name} 的排钻的编组丢失,统计排钻个数时会丢失该个数!`, timeout: 5000, intent: Intent.DANGER });
|
||||
break;
|
||||
}
|
||||
if (gd instanceof CylinderHole)
|
||||
if (gd instanceof CylinderHole) {
|
||||
switch (gd.Type) {
|
||||
case GangDrillType.Pxl:
|
||||
pxlCount++;
|
||||
@@ -13455,6 +13455,8 @@ class LookOverBoardInfosTool {
|
||||
default:
|
||||
break findHole;
|
||||
}
|
||||
options?.getHoles && options?.getHoles(spliteName || group.Name || "未命名", gd);
|
||||
}
|
||||
else {
|
||||
if (gd.isThrough)
|
||||
isTk = true;
|
||||
@@ -13492,13 +13494,13 @@ class LookOverBoardInfosTool {
|
||||
}
|
||||
}
|
||||
//封边
|
||||
let sealData = Production.GetBoardSealingData(b);
|
||||
let sealData = GetBoardSealingData(GetSealedBoardContour(b, true, true));
|
||||
let color = b.BoardProcessOption[EBoardKeyList.Color];
|
||||
for (let data of sealData) {
|
||||
if (equaln$1(0, data.size))
|
||||
continue;
|
||||
let k = `${data.size}-${FixedNotZero(b.Thickness, 2)}-${color}`;
|
||||
if (options) {
|
||||
if (options && options.sealGruopKey) {
|
||||
options.sealGruopKey(k, b, data.size);
|
||||
}
|
||||
let len = this.sealMap.get(k);
|
||||
@@ -18455,12 +18457,48 @@ function GetModelingFromCustomDrill(br) {
|
||||
return { modeling, sideModeling };
|
||||
}
|
||||
|
||||
//转换成多段线点表(pts bul)
|
||||
function ConverToPtsBul(cu, isOutline = true) {
|
||||
let ptsBuls;
|
||||
if (cu instanceof Circle) {
|
||||
let pl = ConverCircleToPolyline(cu);
|
||||
ptsBuls = pl.PtsBuls;
|
||||
}
|
||||
else {
|
||||
if (isOutline && cu.IsClose && cu.Normal.z * cu.Area2 < 0)
|
||||
cu.Reverse();
|
||||
ptsBuls = cu.PtsBuls;
|
||||
}
|
||||
let ocs = cu.OCSNoClone;
|
||||
if (!equaln$1(ocs.elements[0], 1)
|
||||
|| !equaln$1(ocs.elements[9], 0)
|
||||
|| !equaln$1(ocs.elements[10], 0)) {
|
||||
for (let i = 0; i < ptsBuls.pts.length; i++) {
|
||||
Vector2ApplyMatrix4(ocs, ptsBuls.pts[i]);
|
||||
ptsBuls.buls[i] *= cu.Normal.z;
|
||||
}
|
||||
}
|
||||
return ptsBuls;
|
||||
}
|
||||
//转换成多段线点表(pts bul)
|
||||
function ConverArcToPtsBul(arc, hasEnd = false) {
|
||||
let result = { pts: [], buls: [] };
|
||||
let bul = arc.Bul;
|
||||
result.pts.push(arc.StartPoint);
|
||||
result.buls.push(bul);
|
||||
if (hasEnd) {
|
||||
result.pts.push(arc.EndPoint);
|
||||
result.buls.push(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
var Production;
|
||||
(function (Production) {
|
||||
/**获取板件拆单数据 */
|
||||
function GetBoardSplitOrderData(br) {
|
||||
let sealedContour = GetSealedBoardContour(br, true);
|
||||
if (!sealedContour || equaln$1(sealedContour.Area, 0)) {
|
||||
let orgContour = GetSealedBoardContour(br, true, true);
|
||||
if (!orgContour || equaln$1(orgContour.Area, 0)) {
|
||||
Toaster({
|
||||
message: br.Name + " 轮廓错误,可能存在轮廓自交,请检查后重新拆单!(错误的板已经选中,您可以按住鼠标中键查看该板!)(使用FISC命令可以修复自交轮廓!)",
|
||||
timeout: 8000,
|
||||
@@ -18469,8 +18507,8 @@ var Production;
|
||||
Report([br.__OriginalEnt__ ?? br], br.Name + " 轮廓错误");
|
||||
return undefined;
|
||||
}
|
||||
let outline = GetSealedBoardContour(br, false);
|
||||
if (!outline || equaln$1(outline.Area, 0)) {
|
||||
let sealedOutline = GetSealedBoardContour(br, false);
|
||||
if (!sealedOutline || equaln$1(sealedOutline.Area, 0)) {
|
||||
Toaster({
|
||||
message: br.Name + "扣除封边轮廓有误,请检查后重新拆单!(错误的板已经选中,您可以按住鼠标中键查看该板!)",
|
||||
timeout: 8000,
|
||||
@@ -18479,28 +18517,28 @@ var Production;
|
||||
Report([br.__OriginalEnt__ ?? br], br.Name + "扣除封边轮廓有误");
|
||||
return;
|
||||
}
|
||||
let offsetTanslation = outline.BoundingBox.min;
|
||||
outline.Position = outline.Position.sub(offsetTanslation);
|
||||
let outlinePtsBul = ConverToPolylineAndSplitArc(outline);
|
||||
let offsetTanslation = sealedOutline.BoundingBox.min;
|
||||
sealedOutline.Position = sealedOutline.Position.sub(offsetTanslation);
|
||||
let sealedOutlinePtsBul = ConverToPtsBul(sealedOutline); //不分裂圆弧转点表
|
||||
//外轮廓去掉最后的闭合点
|
||||
outlinePtsBul.pts.pop();
|
||||
outlinePtsBul.buls.pop();
|
||||
let size = outline.BoundingBox.getSize(new Vector3);
|
||||
sealedOutlinePtsBul.pts.pop();
|
||||
sealedOutlinePtsBul.buls.pop();
|
||||
let size = sealedOutline.BoundingBox.getSize(new Vector3);
|
||||
//不扣除封边的轮廓信息
|
||||
let originOutlinePtsBul = ConverToPolylineAndSplitArc(sealedContour);
|
||||
let originOutlinePtsBul = ConverToPtsBul(orgContour);
|
||||
originOutlinePtsBul.pts.pop();
|
||||
originOutlinePtsBul.buls.pop();
|
||||
let { modeling, sideModeling } = GetBoardModelingData(br, offsetTanslation);
|
||||
let boardContour;
|
||||
if (GetSpiteSize(br))
|
||||
boardContour = ConverToPolylineAndSplitArc(br.ContourCurve);
|
||||
boardContour = ConverToPtsBul(br.ContourCurve); //不分裂圆弧转点表
|
||||
return {
|
||||
info: GetBoardInfo(br, size),
|
||||
originOutlin: originOutlinePtsBul,
|
||||
outline: outlinePtsBul,
|
||||
sealing: GetBoardSealingData(br),
|
||||
outline: sealedOutlinePtsBul,
|
||||
sealing: GetBoardSealingData(orgContour),
|
||||
modeling,
|
||||
holes: GetBoardHolesData(br, offsetTanslation, sealedContour),
|
||||
holes: GetBoardHolesData(br, offsetTanslation, orgContour),
|
||||
sideModeling,
|
||||
offsetTanslation,
|
||||
metalsData: GetBoardMetals(br),
|
||||
@@ -18535,161 +18573,6 @@ var Production;
|
||||
};
|
||||
}
|
||||
Production.GetBoardInfo = GetBoardInfo;
|
||||
/**
|
||||
* 转换成多段线并且将圆弧打断(大于1/4的话)
|
||||
*/
|
||||
function ConverToPolylineAndSplitArc(cu, isOutline = true, isSplite = true) {
|
||||
let ptsBuls;
|
||||
if (cu instanceof Circle) {
|
||||
let pl = ConverCircleToPolyline(cu);
|
||||
ptsBuls = pl.PtsBuls;
|
||||
}
|
||||
else {
|
||||
if (isOutline && cu.IsClose && cu.Normal.z * cu.Area2 < 0)
|
||||
cu.Reverse();
|
||||
if (isSplite)
|
||||
ptsBuls = SplitePolylineAtArc(cu);
|
||||
else
|
||||
ptsBuls = cu.PtsBuls;
|
||||
}
|
||||
let ocs = cu.OCS;
|
||||
if (!equaln$1(ocs.elements[0], 1)
|
||||
|| !equaln$1(ocs.elements[9], 0)
|
||||
|| !equaln$1(ocs.elements[10], 0)) {
|
||||
for (let i = 0; i < ptsBuls.pts.length; i++) {
|
||||
Vector2ApplyMatrix4(ocs, ptsBuls.pts[i]);
|
||||
ptsBuls.buls[i] *= cu.Normal.z;
|
||||
}
|
||||
}
|
||||
return ptsBuls;
|
||||
}
|
||||
Production.ConverToPolylineAndSplitArc = ConverToPolylineAndSplitArc;
|
||||
function ConverCircleToPolyline(cir) {
|
||||
let arcs = cir.GetSplitCurves([0, 0.25, 0.5, 0.75]);
|
||||
let pl = new Polyline();
|
||||
pl.OCS = cir.OCS;
|
||||
for (let arc of arcs)
|
||||
pl.Join(arc);
|
||||
return pl;
|
||||
}
|
||||
Production.ConverCircleToPolyline = ConverCircleToPolyline;
|
||||
const SPLITBUL = Math.tan(Math.PI / 8);
|
||||
function GetSpliteCount(allAngle) {
|
||||
return Math.ceil(Math.abs(allAngle) / Math.PI * 2);
|
||||
}
|
||||
/** 打断多段线超过1/4圆的圆弧*/
|
||||
function SplitePolylineAtArc(cu, isSplite = true) {
|
||||
let ptsBuls = cu.PtsBuls;
|
||||
let ocsInv = cu.OCSInv;
|
||||
let result = { pts: [], buls: [] };
|
||||
if (ptsBuls.pts.length === 0)
|
||||
return result;
|
||||
for (let i = 0; i < ptsBuls.buls.length - 1; i++) {
|
||||
let bul = ptsBuls.buls[i];
|
||||
if (Math.abs(bul) > SPLITBUL + 1e-8 && isSplite) {
|
||||
let allAngle = Math.atan(bul) * 4;
|
||||
let splitCount = GetSpliteCount(allAngle);
|
||||
let arc = cu.GetCurveAtIndex(i);
|
||||
let paramDiv = 1 / splitCount;
|
||||
let newBul = Math.tan((allAngle / splitCount) / 4);
|
||||
for (let i = 0; i < splitCount; i++) {
|
||||
let param = i * paramDiv;
|
||||
let p = arc.GetPointAtParam(param).applyMatrix4(ocsInv);
|
||||
let p2 = AsVector2(p);
|
||||
//暂时不处理0长度段
|
||||
{
|
||||
result.pts.push(p2);
|
||||
result.buls.push(newBul);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//暂时不处理0长度段
|
||||
{
|
||||
result.pts.push(ptsBuls.pts[i]);
|
||||
result.buls.push(ptsBuls.buls[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.pts.push(arrayLast(ptsBuls.pts));
|
||||
result.buls.push(arrayLast(ptsBuls.buls));
|
||||
//测试是否存在无效的边(0长度边)
|
||||
// for (let i = 1; i < result.pts.length; i++)
|
||||
// {
|
||||
// if (equalv2(result.pts[i], result.pts[i - 1], 0.01))
|
||||
// alert("存在无效的边");
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
Production.SplitePolylineAtArc = SplitePolylineAtArc;
|
||||
function SplitetArc(arc, hasEnd = false) {
|
||||
let result = { pts: [], buls: [] };
|
||||
let bul = arc.Bul;
|
||||
if (Math.abs(bul) > SPLITBUL + 1e-8) {
|
||||
let allAngle = Math.atan(bul) * 4;
|
||||
let splitCount = GetSpliteCount(allAngle);
|
||||
let paramDiv = 1 / splitCount;
|
||||
let newBul = Math.tan((allAngle / splitCount) / 4);
|
||||
for (let i = 0; i < splitCount; i++) {
|
||||
let param = i * paramDiv;
|
||||
let p = arc.GetPointAtParam(param);
|
||||
result.pts.push(p);
|
||||
result.buls.push(newBul);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.pts.push(arc.StartPoint);
|
||||
result.buls.push(bul);
|
||||
}
|
||||
if (hasEnd) {
|
||||
result.pts.push(arc.EndPoint);
|
||||
result.buls.push(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Production.SplitetArc = SplitetArc;
|
||||
/**
|
||||
* 获取封边数据
|
||||
* 封边数据未统一逆时针顺序,用于拆单
|
||||
* */
|
||||
function GetBoardSealingData(br) {
|
||||
let sealCus = GetBoardSealingCurves(br);
|
||||
let highSeal = GetBoardHighSeal(br, sealCus);
|
||||
let sealData = [];
|
||||
for (let i = 0; i < sealCus.length; i++) {
|
||||
let sealCu = sealCus[i];
|
||||
let data = highSeal[i];
|
||||
let cus = [];
|
||||
if (sealCu instanceof Polyline)
|
||||
cus.push(...sealCu.Explode());
|
||||
else
|
||||
cus.push(sealCu);
|
||||
for (let cu of cus) {
|
||||
if (cu instanceof Line) {
|
||||
sealData.push(Object.assign({}, data, { length: cu.Length }));
|
||||
}
|
||||
else if (cu instanceof Arc) {
|
||||
let splitCount = GetSpliteCount(cu.AllAngle);
|
||||
let len = 2 * Math.PI * cu.Radius / 4;
|
||||
for (let i = 0; i < splitCount; i++) {
|
||||
let arcLen = i !== splitCount - 1 ? len : cu.Length - (splitCount - 1) * len;
|
||||
if (!equaln$1(arcLen, 0))
|
||||
sealData.push(Object.assign({}, data, { length: arcLen }));
|
||||
}
|
||||
}
|
||||
else if (cu instanceof Circle) {
|
||||
let length = 2 * Math.PI * cu.Radius / 4;
|
||||
sealData.push(...Array.from({ length: 4 }, () => {
|
||||
return { ...data, length };
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (br.ContourCurve instanceof Polyline && br.ContourCurve.Area2 < 0)
|
||||
sealData.reverse();
|
||||
return sealData;
|
||||
}
|
||||
Production.GetBoardSealingData = GetBoardSealingData;
|
||||
function GetMetalTotalEntitys(md, isHole = false, filter) {
|
||||
let holes = [];
|
||||
if (isHole && !md.HardwareOption.isHole)
|
||||
@@ -18718,8 +18601,8 @@ var Production;
|
||||
if (HostApplicationServices.chaidanOption.useDefaultRad)
|
||||
m.knifeRadius = HostApplicationServices.chaidanOption.radius;
|
||||
data.push({
|
||||
outline: ConverToPolylineAndSplitArc(cu.Clone(), false, false),
|
||||
holes: m.shape.Holes.map(h => ConverToPolylineAndSplitArc(h.Curve.Clone(), false, false)),
|
||||
outline: ConverToPtsBul(cu.Clone(), false),
|
||||
holes: m.shape.Holes.map(h => ConverToPtsBul(h.Curve.Clone(), false)),
|
||||
thickness: m.thickness + (m.addDepth ?? 0),
|
||||
dir: m.dir,
|
||||
knifeRadius: m.knifeRadius,
|
||||
@@ -18747,7 +18630,7 @@ var Production;
|
||||
let paths = tool.GetModelFeedPath(br, m);
|
||||
if (!isSide)
|
||||
paths.forEach(path => path.ApplyMatrix(tMtx));
|
||||
let feeding = paths.map((c) => ConverToPolylineAndSplitArc(c, false));
|
||||
let feeding = paths.map((c) => ConverToPtsBul(c, false));
|
||||
if (feeding.length > 0)
|
||||
data.push({
|
||||
feeding,
|
||||
@@ -18755,8 +18638,8 @@ var Production;
|
||||
dir: m.dir,
|
||||
knifeRadius: m.knifeRadius,
|
||||
origin: {
|
||||
outline: ConverToPolylineAndSplitArc(cu.Clone(), false, false),
|
||||
holes: m.shape.Holes.map(h => ConverToPolylineAndSplitArc(h.Curve.Clone(), false, false)),
|
||||
outline: ConverToPtsBul(cu.Clone(), false),
|
||||
holes: m.shape.Holes.map(h => ConverToPtsBul(h.Curve.Clone(), false)),
|
||||
addLen: m.addLen,
|
||||
addWidth: m.addWidth,
|
||||
addDepth: m.addDepth,
|
||||
@@ -19244,7 +19127,7 @@ var Production;
|
||||
for (let m of br.Modeling2D) {
|
||||
let path = m.path.Clone().ApplyMatrix(tmtx);
|
||||
res.push({
|
||||
path: ConverToPolylineAndSplitArc(path),
|
||||
path: ConverToPtsBul(path),
|
||||
dir: m.dir,
|
||||
items: m.items.map(item => ({ ...item }))
|
||||
});
|
||||
@@ -19272,7 +19155,7 @@ var Production;
|
||||
}
|
||||
else {
|
||||
let arc = new Arc().ParseFromBul(d1.pt.clone().sub(offset), d2.pt.clone().sub(offset), d1.bul);
|
||||
let r = SplitetArc(arc, false);
|
||||
let r = ConverArcToPtsBul(arc, false);
|
||||
r.pts.forEach(p => InvertPosition(p, br.Thickness));
|
||||
d.path.pts.push(...r.pts);
|
||||
d.path.buls.push(...r.buls);
|
||||
@@ -19302,11 +19185,51 @@ var Production;
|
||||
thickness,
|
||||
dir, knifeRadius, addLen, addWidth, addDepth
|
||||
});
|
||||
return paths.map((c) => ConverToPolylineAndSplitArc(c, false));
|
||||
return paths.map((c) => ConverToPtsBul(c, false));
|
||||
}
|
||||
Production.GetChaiDanFeedingPath = GetChaiDanFeedingPath;
|
||||
})(Production || (Production = {}));
|
||||
|
||||
/**
|
||||
* 分析曲线的上下左右位置的线
|
||||
* @param curves
|
||||
*/
|
||||
function ParseEdgeSealDir(curves) {
|
||||
let boxAll = new Box3;
|
||||
let fb = new Flatbush(curves.length);
|
||||
for (let c of curves) {
|
||||
let box = c.BoundingBox;
|
||||
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, dirRef) => {
|
||||
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];
|
||||
}
|
||||
|
||||
/**
|
||||
*曲线列表分段
|
||||
* @l-arc-l,l-arc-arc-l,l-arc-l-arc-l....
|
||||
@@ -19398,9 +19321,9 @@ function ParagraphCulist(cus) {
|
||||
}
|
||||
}
|
||||
/**
|
||||
*计算封边
|
||||
* 计算封边(删除无效线,连接尖角)
|
||||
*/
|
||||
function CalcEdgeSealing(cus) {
|
||||
function CalcEdgeSealing(cus, highSeals) {
|
||||
if (cus.length <= 1)
|
||||
return;
|
||||
let oldLine;
|
||||
@@ -19414,16 +19337,23 @@ function CalcEdgeSealing(cus) {
|
||||
return false;
|
||||
}
|
||||
let dist = frontLine.EndPoint.distanceToSquared(laterLine.StartPoint);
|
||||
if (dist < LINK_FUZZ ** 2) {
|
||||
if (dist < LINK_FUZZ ** 2) //直连共线(只有共线才有可能起点等于终点)
|
||||
{
|
||||
if (frontLine instanceof Line && laterLine instanceof Line) {
|
||||
if (frontLine.PtOnCurve(laterLine.EndPoint)) {
|
||||
if (frontLine.PtOnCurve(laterLine.EndPoint)) //反向共线 later 在front内
|
||||
{
|
||||
//删除线
|
||||
cus.splice(laterIndex, 1);
|
||||
highSeals?.splice(laterIndex, 1);
|
||||
if (laterIndex === 0)
|
||||
firstLine = cus[0].Clone();
|
||||
i -= 2;
|
||||
}
|
||||
else if (laterLine.PtOnCurve(frontLine.StartPoint)) {
|
||||
else if (laterLine.PtOnCurve(frontLine.StartPoint)) //反向共线 front 在 later内
|
||||
{
|
||||
//删除线
|
||||
cus.splice(i, 1);
|
||||
highSeals?.splice(i, 1);
|
||||
i -= 2;
|
||||
if (i < -1)
|
||||
i = -1;
|
||||
@@ -19434,13 +19364,14 @@ function CalcEdgeSealing(cus) {
|
||||
let refLine = oldLine ?? frontLine;
|
||||
let refLine2 = i === cus.length - 1 ? firstLine : laterLine;
|
||||
let iPts = refLine.IntersectWith(refLine2, IntersectOption.ExtendBoth);
|
||||
let tPts = iPts.filter(p => refLine.PtOnCurve(p)
|
||||
&& refLine2.PtOnCurve(p));
|
||||
let tPts = iPts.filter(p => refLine.PtOnCurve(p) && refLine2.PtOnCurve(p));
|
||||
let iPt = SelectNearP(tPts.length > 0 ? tPts : iPts, refLine.EndPoint);
|
||||
if (!iPt) {
|
||||
//没交点,如果删过线,则尝试继续连接
|
||||
if (cus.length !== oldLen && cus.length > 2) {
|
||||
//删除线
|
||||
cus.splice(i, 1);
|
||||
highSeals?.splice(i, 1);
|
||||
i -= 2;
|
||||
if (i < -1)
|
||||
i = -1;
|
||||
@@ -19453,6 +19384,7 @@ function CalcEdgeSealing(cus) {
|
||||
//前面线的点无效直接删除
|
||||
if (par < 1e-6) {
|
||||
cus.splice(i, 1);
|
||||
highSeals?.splice(i, 1);
|
||||
i -= 2;
|
||||
if (i < -1)
|
||||
i = -1;
|
||||
@@ -19466,7 +19398,9 @@ function CalcEdgeSealing(cus) {
|
||||
//后面线点无效,如果是起始线,则删除,否则缓存原始线,继续尝试连接
|
||||
if (par > 1 - 1e-6) {
|
||||
if (laterIndex === 0) {
|
||||
//删除线
|
||||
cus.shift();
|
||||
highSeals?.shift();
|
||||
firstLine = cus[0].Clone();
|
||||
i -= 2;
|
||||
continue;
|
||||
@@ -19557,32 +19491,47 @@ function GetBoardSealingCurves(br, isOffset = false) {
|
||||
return cus;
|
||||
}
|
||||
}
|
||||
const SEAL_VALUE_KEY = "__highSeals__";
|
||||
/**
|
||||
* 获取板件轮廓
|
||||
* 结果轮廓拆单用,统一逆时针数据
|
||||
* hasSealing 轮廓是否包含封边
|
||||
* 用户计算拆单侧孔面id
|
||||
* TODO:如果封边一致,那么应该直接偏移!!!
|
||||
*
|
||||
* //返回的曲线中 如果 hasSealing isParseSeal 那么将可以取出封边信息
|
||||
*/
|
||||
function GetSealedBoardContour(br, hasSealing) {
|
||||
function GetSealedBoardContour(br, hasSealing, isParseSeal = false) {
|
||||
let area2 = br.ContourCurve.Area2;
|
||||
if (Math.abs(area2) < 10)
|
||||
return;
|
||||
let offsetCus = [];
|
||||
let cus = GetBoardSealingCurves(br);
|
||||
let curves = GetBoardSealingCurves(br);
|
||||
let dir = Math.sign(area2);
|
||||
let highSealsExpd; //展开后的封边信息(仅在未扣除封边的分支中计算)
|
||||
if (hasSealing) {
|
||||
for (let c of cus) {
|
||||
if (c instanceof Polyline)
|
||||
offsetCus.push(...c.Explode());
|
||||
else
|
||||
let highSeals;
|
||||
if (isParseSeal) {
|
||||
highSeals = GetBoardHighSeal(br, curves);
|
||||
highSealsExpd = [];
|
||||
}
|
||||
for (let i = 0; i < curves.length; i++) {
|
||||
let curve = curves[i];
|
||||
const PushCurve = (c) => {
|
||||
offsetCus.push(c);
|
||||
highSealsExpd?.push({ size: highSeals[i].size, length: c.Length });
|
||||
};
|
||||
if (curve instanceof Polyline)
|
||||
for (let cu of curve.Explode())
|
||||
PushCurve(cu);
|
||||
else
|
||||
PushCurve(curve);
|
||||
}
|
||||
}
|
||||
else {
|
||||
let highSeals = GetBoardHighSeal(br, cus);
|
||||
if (cus[0] instanceof Circle)
|
||||
dir = 1;
|
||||
let highSeals = GetBoardHighSeal(br, curves);
|
||||
//圆的dir始终等于1
|
||||
// if (cus[0] instanceof Circle)
|
||||
// dir = 1;
|
||||
//所有的封边都一样时
|
||||
if (highSeals.every(s => equaln$1(s.size, highSeals[0].size), 1e-3)) {
|
||||
let brContour = br.ContourCurve;
|
||||
@@ -19613,42 +19562,55 @@ function GetSealedBoardContour(br, hasSealing) {
|
||||
if (retPl)
|
||||
return retPl;
|
||||
}
|
||||
for (let i = 0; i < cus.length; i++) {
|
||||
for (let i = 0; i < curves.length; i++) {
|
||||
let cs;
|
||||
if (!highSeals[i].size)
|
||||
cs = [cus[i].Clone()];
|
||||
cs = [curves[i].Clone()];
|
||||
else
|
||||
cs = cus[i].GetOffsetCurves(-highSeals[i].size * dir);
|
||||
cs = curves[i].GetOffsetCurves(-highSeals[i].size * dir);
|
||||
for (let c of cs) {
|
||||
if (c instanceof Polyline)
|
||||
offsetCus.push(...c.Explode());
|
||||
arrayPushArray(offsetCus, c.Explode());
|
||||
else
|
||||
offsetCus.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (offsetCus.length === 1 && offsetCus[0] instanceof Circle)
|
||||
return offsetCus[0];
|
||||
if (!CalcEdgeSealing(offsetCus))
|
||||
if (offsetCus.length === 1 && offsetCus[0] instanceof Circle) {
|
||||
let cir = offsetCus[0];
|
||||
if (highSealsExpd)
|
||||
cir[SEAL_VALUE_KEY] = highSealsExpd;
|
||||
return cir;
|
||||
}
|
||||
if (!CalcEdgeSealing(offsetCus, highSealsExpd))
|
||||
return;
|
||||
let pl = Polyline.FastCombine(offsetCus, LINK_FUZZ);
|
||||
if (pl && dir < 0)
|
||||
if (pl && dir < 0) {
|
||||
pl.Reverse();
|
||||
highSealsExpd?.reverse();
|
||||
}
|
||||
if (highSealsExpd)
|
||||
pl[SEAL_VALUE_KEY] = highSealsExpd;
|
||||
return pl;
|
||||
}
|
||||
function GetBoardSealingData(curve) {
|
||||
return curve[SEAL_VALUE_KEY];
|
||||
}
|
||||
/**处理常规板件封边数据和上下左右封边值 */
|
||||
function HandleRectBoardSealingData(br, edges, cus) {
|
||||
let dir = Math.sign(br.ContourCurve.Area2);
|
||||
if (!cus)
|
||||
cus = br.ContourCurve.Explode();
|
||||
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) {
|
||||
//现在我们不管是否有拆单尺寸,我们总是关系封边值
|
||||
// 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 (!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();
|
||||
else
|
||||
@@ -19662,6 +19624,13 @@ function HandleRectBoardSealingData(br, edges, cus) {
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21765,7 +21734,7 @@ let HistoricManage = HistoricManage_1 = class HistoricManage extends CADObject {
|
||||
this.curIndex = -1; //当前执行位置,也就是当前的状态, undo时,撤销当前状态,redo时,应用下一个状态
|
||||
this.lockIndex = -1; //锁定极限撤销索引(将无法在往前撤销)
|
||||
this.historyRecord = []; //历史记录
|
||||
this.doing = false;
|
||||
this.doing = false; //正在执行工作 例如: 文件读取中 撤销中 重做中
|
||||
this.Enable = true;
|
||||
}
|
||||
Clear() {
|
||||
@@ -24090,7 +24059,7 @@ let Cylineder = class Cylineder extends Entity {
|
||||
return new ExtrudeGeometry(cir, extrudeSettings);
|
||||
}
|
||||
InitDrawObject(renderType) {
|
||||
return new THREE.Mesh(this.CreateGeometry(), new MeshNormalMaterial());
|
||||
return new Mesh(this.CreateGeometry(), new MeshNormalMaterial());
|
||||
}
|
||||
UpdateDrawObject(type, en) {
|
||||
let obj = en;
|
||||
|
Reference in New Issue
Block a user