更新版本
This commit is contained in:
339
api.esm.js
339
api.esm.js
@@ -1,7 +1,7 @@
|
||||
import geom2 from '@jscad/modeling/src/geometries/geom2';
|
||||
import geom3, { transform } from '@jscad/modeling/src/geometries/geom3';
|
||||
import poly3, { create, measureArea } from '@jscad/modeling/src/geometries/poly3';
|
||||
import { intersect, union, subtract } from '@jscad/modeling/src/operations/booleans';
|
||||
import poly3, { create } from '@jscad/modeling/src/geometries/poly3';
|
||||
import { intersect } from '@jscad/modeling/src/operations/booleans';
|
||||
import extrudeLinear from '@jscad/modeling/src/operations/extrusions/extrudeLinear';
|
||||
import extrudeRotate from '@jscad/modeling/src/operations/extrusions/extrudeRotate';
|
||||
import retessellate from '@jscad/modeling/src/operations/modifiers/retessellate';
|
||||
@@ -1024,17 +1024,17 @@ let HistorycRecord = class HistorycRecord {
|
||||
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
|
||||
//对象从文件中读取数据,初始化自身
|
||||
ReadFile(file) {
|
||||
file.Read();
|
||||
let ver = file.Read();
|
||||
this.undoData = file.ReadObject();
|
||||
this.redoData = file.ReadObject();
|
||||
this.userData = file.ReadObject();
|
||||
if (ver === 1)
|
||||
file.ReadObject();
|
||||
}
|
||||
//对象将自身数据写入到文件.
|
||||
WriteFile(file) {
|
||||
file.Write(1);
|
||||
file.Write(2);
|
||||
file.WriteObject(this.undoData);
|
||||
file.WriteObject(this.redoData);
|
||||
file.WriteObject(this.userData);
|
||||
}
|
||||
};
|
||||
HistorycRecord = __decorate([
|
||||
@@ -3642,6 +3642,8 @@ let Curve = class Curve extends Entity {
|
||||
*/
|
||||
InitDrawObject(renderType = RenderType.Wireframe) {
|
||||
let pts = this.Shape.getPoints(this.GetDrawCount());
|
||||
if (pts.length === 0)
|
||||
pts.push(new Vector3);
|
||||
if (renderType === RenderType.WireframePrint) {
|
||||
let array = [];
|
||||
for (let p of pts)
|
||||
@@ -8689,6 +8691,9 @@ let Polyline = Polyline_1 = class Polyline extends Curve {
|
||||
}
|
||||
if (ver > 1)
|
||||
this._ClosedMark = file.Read();
|
||||
// 某些时候会画出这样的多段线 尚未知道是为什么画出的
|
||||
// if (this._LineData.length === 0)
|
||||
// this.Erase();
|
||||
}
|
||||
//对象将自身数据写入到文件.
|
||||
WriteFile(file) {
|
||||
@@ -11915,12 +11920,6 @@ function CyHoleInBoard(cys, br, ocs, checkAll = false) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const TempRectHoleOption = {
|
||||
up: "",
|
||||
down: "",
|
||||
left: "",
|
||||
right: "",
|
||||
};
|
||||
/**分析上下左右排钻 */
|
||||
function ParseBoardRectHoleType(br, outBrRectHoleType = {}) {
|
||||
let dir = Math.sign(br.ContourCurve.Area2);
|
||||
@@ -11996,6 +11995,27 @@ function AddEntityDrawObject(obj, embedEntity, renderType = RenderType.Wireframe
|
||||
obj.add(embedObject);
|
||||
}
|
||||
|
||||
var LogType;
|
||||
(function (LogType) {
|
||||
LogType["Error"] = "ERROR";
|
||||
LogType["Warning"] = "WARNING";
|
||||
LogType["Info"] = "INFO";
|
||||
LogType["Command"] = "COMMAND";
|
||||
LogType["All"] = "ALL";
|
||||
})(LogType || (LogType = {}));
|
||||
const _LogInjectFunctions = [];
|
||||
//Log(`板:${br.Name}没有提供排钻信息!`, LogType.Warning, [br]);
|
||||
function Log(message, ...optionalParams) {
|
||||
for (let f of _LogInjectFunctions)
|
||||
f(message, ...optionalParams);
|
||||
}
|
||||
const _LogInjectInteractionFunctions = [];
|
||||
//InteractionLog([{ msg: "警告:" }, { msg: `板件${br.Name}`, entity: [br, cyHole] }, { msg: "侧孔与板无交点,无法加工该侧孔!" }], LogType.Warning);
|
||||
function InteractionLog(message, ...optionalParams) {
|
||||
for (let f of _LogInjectInteractionFunctions)
|
||||
f(message, ...optionalParams);
|
||||
}
|
||||
|
||||
class BoardUVGenerator {
|
||||
generateTopUV(geometry, vertices, indexA, indexB, indexC) {
|
||||
var a_x = vertices[indexA * 3];
|
||||
@@ -12061,6 +12081,17 @@ class BoardUVGenerator2 extends BoardUVGenerator {
|
||||
let boardUVGenerator = new BoardUVGenerator();
|
||||
let boardUVGenerator2 = new BoardUVGenerator2();
|
||||
|
||||
const _CSGSubtractInjectInteractionFunctions = [];
|
||||
function AddCSGSubtractTask(task) {
|
||||
for (let f of _CSGSubtractInjectInteractionFunctions)
|
||||
f(task);
|
||||
}
|
||||
const _TerminateTaskInjectInteractionFunctions = [];
|
||||
function TerminateCSGTask(task) {
|
||||
for (let f of _TerminateTaskInjectInteractionFunctions)
|
||||
f(task);
|
||||
}
|
||||
|
||||
/** Epsilon used during determination of near zero distances.
|
||||
* @default
|
||||
*/
|
||||
@@ -12889,27 +12920,6 @@ class SweepGeometrySimple extends SweepGeometry {
|
||||
BuildLid(shapePts2d, verts) { }
|
||||
}
|
||||
|
||||
var LogType;
|
||||
(function (LogType) {
|
||||
LogType["Error"] = "ERROR";
|
||||
LogType["Warning"] = "WARNING";
|
||||
LogType["Info"] = "INFO";
|
||||
LogType["Command"] = "COMMAND";
|
||||
LogType["All"] = "ALL";
|
||||
})(LogType || (LogType = {}));
|
||||
const _LogInjectFunctions = [];
|
||||
//Log(`板:${br.Name}没有提供排钻信息!`, LogType.Warning, [br]);
|
||||
function Log(message, ...optionalParams) {
|
||||
for (let f of _LogInjectFunctions)
|
||||
f(message, ...optionalParams);
|
||||
}
|
||||
const _LogInjectInteractionFunctions = [];
|
||||
//InteractionLog([{ msg: "警告:" }, { msg: `板件${br.Name}`, entity: [br, cyHole] }, { msg: "侧孔与板无交点,无法加工该侧孔!" }], LogType.Warning);
|
||||
function InteractionLog(message, ...optionalParams) {
|
||||
for (let f of _LogInjectInteractionFunctions)
|
||||
f(message, ...optionalParams);
|
||||
}
|
||||
|
||||
//为了避免Core对UI库的依赖,导致测试用例失败,导致外部项目引用失败,我们分离了这个函数
|
||||
var Intent;
|
||||
(function (Intent) {
|
||||
@@ -13371,7 +13381,7 @@ const DefaultClosingStripOption = {
|
||||
};
|
||||
Object.freeze(DefaultClosingStripOption);
|
||||
const DefaultBoardFindOption = {
|
||||
version: 7,
|
||||
version: 8,
|
||||
condition: {
|
||||
layer: false,
|
||||
height: false,
|
||||
@@ -13395,6 +13405,7 @@ const DefaultBoardFindOption = {
|
||||
useKeyWord: false,
|
||||
addRemarks: false,
|
||||
composingFace: false,
|
||||
openDir: false,
|
||||
sealedUp: false,
|
||||
sealedDown: false,
|
||||
sealedLeft: false,
|
||||
@@ -13422,6 +13433,7 @@ const DefaultBoardFindOption = {
|
||||
bigHoleDir: ECompareType.Equal,
|
||||
drillType: ECompareType.Equal,
|
||||
composingFace: ECompareType.Equal,
|
||||
openDir: ECompareType.Equal,
|
||||
[EBoardKeyList.KnifeRad]: ECompareType.Equal,
|
||||
},
|
||||
tolerance: {
|
||||
@@ -13445,6 +13457,8 @@ const DefaultBoardFindOption = {
|
||||
bigHoleDir: FaceDirection.Front,
|
||||
drillType: "",
|
||||
composingFace: ComposingType.Positive,
|
||||
openDir: BoardOpenDir.None,
|
||||
hardwareDoorName: "",
|
||||
sealedUp: "",
|
||||
sealedDown: "",
|
||||
sealedLeft: "",
|
||||
@@ -13536,9 +13550,9 @@ const DefaultDoorOption = {
|
||||
lbSealedLeft: 1,
|
||||
lbSealedRight: 1,
|
||||
lbHightDrillOption: { up: "", down: "", left: "", right: "" },
|
||||
deviation: 100,
|
||||
useBoardProcessOption: true,
|
||||
isModifyHardwareMaterial: false,
|
||||
deviation: 100 //偏移量
|
||||
};
|
||||
Object.freeze(DefaultDoorOption);
|
||||
const DefaultHingeOption = {
|
||||
@@ -13863,7 +13877,7 @@ const DefaultParseBoardNameOPtion = {
|
||||
};
|
||||
Object.freeze(DefaultParseBoardNameOPtion);
|
||||
const DefaultR2bOption = {
|
||||
version: 7,
|
||||
version: 8,
|
||||
cabinetDeep: 400,
|
||||
cabinetBrThick: 18,
|
||||
cabinetCurtail: 0,
|
||||
@@ -13904,7 +13918,9 @@ const DefaultR2bOption = {
|
||||
closeStripThickness: 18,
|
||||
useSktTemplate: false,
|
||||
sktTemplate: null,
|
||||
sktTemplateId: ""
|
||||
sktTemplateId: "",
|
||||
rightSktTemplateId: "",
|
||||
topSktTemplateId: "",
|
||||
};
|
||||
Object.freeze(DefaultR2bOption);
|
||||
const DefaultR2b2Option = {
|
||||
@@ -16559,7 +16575,7 @@ function GetIntersection(cu1, cu2) {
|
||||
else
|
||||
m = new Map();
|
||||
intCache.set(cu1, m);
|
||||
let r = cu1.IntersectWith2(cu2, IntersectOption.ExtendNone);
|
||||
let r = cu1.IntersectWith2(cu2, IntersectOption.ExtendNone, 1e-4);
|
||||
let cu1EndParam = cu1.EndParam;
|
||||
let cu2EndParam = cu2.EndParam;
|
||||
for (let d of r) {
|
||||
@@ -17200,6 +17216,7 @@ let ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends Entity {
|
||||
* @returns 切割是否成功
|
||||
*/
|
||||
Subtract(extrudes, output = undefined, checkIntersect = true) {
|
||||
//del_exp2_start
|
||||
if (checkIntersect) {
|
||||
let box = this.BoundingBox;
|
||||
extrudes = extrudes.filter(e => box.intersectsBox(e.BoundingBox));
|
||||
@@ -17236,6 +17253,7 @@ let ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends Entity {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//del_exp2_end
|
||||
return false;
|
||||
}
|
||||
RelevanceSubtract(knif, check = false) {
|
||||
@@ -18001,6 +18019,9 @@ let ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends Entity {
|
||||
this._MeshGeometry["IsMesh"] = true;
|
||||
this._EdgeGeometry = BufferGeometryUtils.MergeBufferGeometries(edges);
|
||||
}
|
||||
//因为这里更新了mesh geom 所以我们必须更新它.
|
||||
this._MeshGeometry = this.UpdateMeshGeom(this._MeshGeometry);
|
||||
this._MeshGeometry["IsMesh"] = true;
|
||||
//我们加入一些拓展信息,以便排钻能够使用(或者其他的,比如发送到效果图?,BBS)(布局视口会直接添加实体到场景,所以我们只在这里设置OriginEntity)
|
||||
for (let i = 0; i < this.__CacheSplitExtrudes.length; i++) {
|
||||
this.__CacheSplitExtrudes[i].objectId = new ObjectId(this.Id.Index * -100 - i);
|
||||
@@ -20875,7 +20896,7 @@ var Production;
|
||||
angle = 0;
|
||||
if (depth > CanDrawHoleFuzz)
|
||||
data.frontBackHoles.push({
|
||||
type: d.isThrough ? GangDrillType.TK : d.Type,
|
||||
type: d.isThrough ? GangDrillType.TK : (isRelativeHardware ? GangDrillType.Ljg : d.Type),
|
||||
position: z0 < CanDrawHoleFuzz ? p : p.setZ(br.Thickness),
|
||||
radius: cir.Radius,
|
||||
depth,
|
||||
@@ -21964,6 +21985,8 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
this.bevelEnabled = true;
|
||||
//二维刀路 id -> polyline
|
||||
this._KnifePolylineMap = new Map();
|
||||
this._workerCalcedGeom = null; //worker计算后,暂时存入到这里
|
||||
this._async2DPathIng = false;
|
||||
//偏移缓存
|
||||
this._OffsetPathCache = new Map();
|
||||
this.InitBoardData();
|
||||
@@ -22514,8 +22537,8 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
* 异形->矩形
|
||||
*/
|
||||
//上下左右排钻属性(在矩形时生效)
|
||||
TempRectHoleOption.up = undefined;
|
||||
ParseBoardRectHoleType(this, TempRectHoleOption); //分析旧的上下左右排钻
|
||||
let rectHoleOpt = {};
|
||||
ParseBoardRectHoleType(this, rectHoleOpt); //分析旧的上下左右排钻
|
||||
let oldHightSealCurves = GetBoardSealingCurves(this); //旧的封边轮廓
|
||||
let oldHightSealDatas = GetBoardHighSeal(this, oldHightSealCurves); //旧的封边数据
|
||||
let oldContour = this.ContourCurve; //旧的轮廓
|
||||
@@ -22530,8 +22553,8 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
defaultDrillType = HostApplicationServices.DrillConfigs.size ? HostApplicationServices.DrillConfigs.entries().next().value[0] : DrillType.None;
|
||||
super.ContourCurve = newContour; //设置新的轮廓
|
||||
//保持排钻边属性
|
||||
if (this.isRect && TempRectHoleOption.up) //矩形->矩形
|
||||
SetBrHighHoleTypeFromRectHoleType(this, TempRectHoleOption); //直接应用旧的矩形数据
|
||||
if (this.isRect && rectHoleOpt.up) //矩形->矩形
|
||||
SetBrHighHoleTypeFromRectHoleType(this, rectHoleOpt); //直接应用旧的矩形数据
|
||||
else //异形->矩形 矩形->异形 异形->异形
|
||||
{
|
||||
let indexMap = [];
|
||||
@@ -23014,9 +23037,11 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
let mt4 = new Matrix4().setPosition(cu.Radius, 0, 0);
|
||||
let arcKnifeGeom = geom2.transform(mt4.elements, knifeGeom);
|
||||
let rotateGeom = extrudeRotate({ segments: GetArcDrawCount(cu.Radius), angle: cu.AllAngle }, arcKnifeGeom);
|
||||
//圆弧的旋转分量
|
||||
let extractRotation = new Matrix4().extractRotation(cu.OCSNoClone);
|
||||
rotateGeom = retessellate(rotateGeom);
|
||||
//放置Geom
|
||||
let rotateMat = new Matrix4().makeRotationZ(cu.IsClockWise ? cu.EndAngle : cu.StartAngle).setPosition(cu.Position);
|
||||
let rotateMat = new Matrix4().makeRotationZ(cu.IsClockWise ? cu.EndAngle : cu.StartAngle).setPosition(cu.Position).multiply(extractRotation);
|
||||
rotateGeom = transform(rotateMat.elements, rotateGeom);
|
||||
geom3s.push(rotateGeom);
|
||||
//端点部分
|
||||
@@ -23041,69 +23066,50 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
}
|
||||
//#endregion
|
||||
get Has2DPath() { return this._2DModelingList.length > 0; }
|
||||
GoodBye() {
|
||||
super.GoodBye();
|
||||
TerminateCSGTask({ key: this });
|
||||
}
|
||||
//del_exp2_start
|
||||
//二维刀路切割后返回几何体
|
||||
UpdateMeshGeom(geo) {
|
||||
let path2dCsgs = this.Get2DPathCsgs();
|
||||
if (!path2dCsgs.length || !HostApplicationServices.show2DPathObject) {
|
||||
if (!this._workerCalcedGeom) {
|
||||
let path2dCsgs = this.Get2DPathCsgs();
|
||||
if (!path2dCsgs.length || !HostApplicationServices.show2DPathObject) {
|
||||
if (geo instanceof Geometry)
|
||||
return new BufferGeometry().fromGeometry(geo);
|
||||
return geo;
|
||||
}
|
||||
let geom = Geometry2CSG2(geo);
|
||||
this._async2DPathIng = true;
|
||||
// 使用线程池
|
||||
const task = {
|
||||
key: this,
|
||||
data: [path2dCsgs, geom],
|
||||
then: (e) => {
|
||||
let data = e.data;
|
||||
if (data.status || !data.geom.polygons) {
|
||||
this._AsyncIngTextEntity.TextString = "二维刀路建模失败";
|
||||
Log(`板:${this.Name}二维刀路建模失败!`, LogType.Error, [this]);
|
||||
return;
|
||||
}
|
||||
this.UpdateDrawGeometry();
|
||||
this._workerCalcedGeom = data.geom;
|
||||
this.Update();
|
||||
this.AsyncUpdated();
|
||||
this.MeshGeometry; //保证刷新这个
|
||||
this._workerCalcedGeom = null;
|
||||
}
|
||||
};
|
||||
AddCSGSubtractTask(task); // 往线程池里添加任务
|
||||
//进入到异步后,直接先返回
|
||||
if (geo instanceof Geometry)
|
||||
return new BufferGeometry().fromGeometry(geo);
|
||||
return geo;
|
||||
}
|
||||
// TestDrawGeom3s(path2dCsgs);
|
||||
let gemUnion = path2dCsgs[0];
|
||||
for (let i = 1; i < path2dCsgs.length; i++)
|
||||
gemUnion = union(gemUnion, path2dCsgs[i]);
|
||||
let geom = Geometry2CSG2(geo);
|
||||
let newGeom = subtract(geom, gemUnion);
|
||||
//删除小面积(只留一个)
|
||||
{
|
||||
let fuzz = new FuzzyFactory;
|
||||
let vmap = new Map;
|
||||
for (let poly of newGeom.polygons) {
|
||||
for (let v of poly.vertices) {
|
||||
let key = fuzz.lookupOrCreate(v, v);
|
||||
let arr = vmap.get(key);
|
||||
if (!arr) {
|
||||
arr = [];
|
||||
vmap.set(key, arr);
|
||||
}
|
||||
arr.push(poly);
|
||||
v["__key__"] = key;
|
||||
}
|
||||
}
|
||||
let polys = newGeom.polygons.concat();
|
||||
let polyGroups = [];
|
||||
let calcs = new Set;
|
||||
while (polys.length) {
|
||||
let poly1 = polys.pop();
|
||||
calcs.add(poly1);
|
||||
let polyGroup = [poly1];
|
||||
polyGroups.push(polyGroup);
|
||||
for (let i = 0; i < polyGroup.length; i++) {
|
||||
let poly = polyGroup[i];
|
||||
for (let v of poly.vertices) {
|
||||
let key = v["__key__"];
|
||||
let arr = vmap.get(key);
|
||||
for (let vpoly of arr) {
|
||||
if (calcs.has(vpoly))
|
||||
continue;
|
||||
calcs.add(vpoly);
|
||||
polyGroup.push(vpoly);
|
||||
}
|
||||
}
|
||||
}
|
||||
// arrayRemoveIf(polys, poly => !calcs.has(poly)); //加上这个无法提高性能
|
||||
}
|
||||
let areas = polyGroups.map(polys => {
|
||||
let area = 0;
|
||||
for (let poly of polys)
|
||||
area += measureArea(poly);
|
||||
return area;
|
||||
});
|
||||
let maxIndex = Max(areas, (t1, t2) => t2 > t1);
|
||||
newGeom.polygons = polyGroups[maxIndex];
|
||||
}
|
||||
this._async2DPathIng = false;
|
||||
const newGeom = this._workerCalcedGeom;
|
||||
this._workerCalcedGeom = undefined; //保护
|
||||
this._EdgeGeometry = new EdgesGeometry().FromCSG(newGeom);
|
||||
const geometry = CSG2Geometry2(newGeom);
|
||||
const bufferGeometry = new BufferGeometry().fromGeometry(geometry);
|
||||
@@ -23214,6 +23220,7 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
}
|
||||
}
|
||||
}
|
||||
//del_exp2_start
|
||||
InitDrawObject(renderType = RenderType.Wireframe) {
|
||||
let obj;
|
||||
if (renderType === RenderType.Edge //封边检查
|
||||
@@ -23228,6 +23235,7 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
else {
|
||||
obj = super.InitDrawObject(renderType);
|
||||
this.UpdateDrawObjectByBoardInfo(renderType, obj);
|
||||
this.DrawAsyncText(obj);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
@@ -23273,8 +23281,33 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
//#endregion
|
||||
}
|
||||
this.UpdateDrawObjectByBoardInfo(renderType, obj);
|
||||
this.DrawAsyncText(obj);
|
||||
return o;
|
||||
}
|
||||
DrawAsyncText(obj) {
|
||||
if (this._async2DPathIng) {
|
||||
//#region 添加文字
|
||||
if (!this._AsyncIngTextEntity) {
|
||||
this._AsyncIngTextEntity = new Text();
|
||||
this._AsyncIngTextEntity.TextAligen = TextAligen.Mid;
|
||||
this._AsyncIngTextEntity.IsDoubleMesh = true;
|
||||
this._AsyncIngTextEntity.IsFsText = this._BoardType === BoardType.Layer;
|
||||
this._AsyncIngTextEntity.IsEmbedEntity = true;
|
||||
}
|
||||
if (this._BoardType === BoardType.Layer)
|
||||
this._AsyncIngTextEntity.OCSNoClone.makeRotationZ(-Math.PI / 2).setPosition(this.width * 0.5, this.height * 0.5, this.thickness * 0.5);
|
||||
else
|
||||
this._AsyncIngTextEntity.OCSNoClone.identity().setPosition(this.width * 0.5, this.height * 0.5, this.thickness * 0.5);
|
||||
this._AsyncIngTextEntity.TextString = "二维刀路建模中!";
|
||||
let o = this._AsyncIngTextEntity.GetDrawObjectFromRenderType(RenderType.Conceptual);
|
||||
if (o) {
|
||||
o.traverse(obj => obj.userData = {});
|
||||
AddEntityDrawObject(obj, this._AsyncIngTextEntity, RenderType.Conceptual);
|
||||
}
|
||||
//#endregion
|
||||
}
|
||||
}
|
||||
//del_exp2_end
|
||||
//绘制排版面时使用的颜色
|
||||
get PlaceColor() { return this._Color === 8 ? 9 : this._Color; }
|
||||
//排版面网格
|
||||
@@ -25348,7 +25381,7 @@ class Path {
|
||||
file.Write(-1);
|
||||
}
|
||||
}
|
||||
function TranslatePath_Self(pts, mx, my) {
|
||||
function PathTranslate_Self(pts, mx, my) {
|
||||
for (let pt of pts) {
|
||||
pt.x += mx;
|
||||
pt.y += my;
|
||||
@@ -25364,46 +25397,6 @@ function PathScale(pts, scale) {
|
||||
return pts;
|
||||
}
|
||||
|
||||
class NestCache {
|
||||
/**
|
||||
* 用于创建原点在0点的矩形路径
|
||||
*/
|
||||
static CreatePath(x, y, knifRadius = 3.5) {
|
||||
let minX = -knifRadius;
|
||||
let maxX = x + knifRadius;
|
||||
let minY = -knifRadius;
|
||||
let maxY = y + knifRadius;
|
||||
return new Path([
|
||||
{ x: minX, y: minY },
|
||||
{ x: maxX, y: minY },
|
||||
{ x: maxX, y: maxY },
|
||||
{ x: minX, y: maxY },
|
||||
]);
|
||||
}
|
||||
static Clear() {
|
||||
this.CachePartPosCount = 0;
|
||||
this.CacheNoSetCount = 0;
|
||||
this.CacheRect.clear();
|
||||
this.PositionCache = {};
|
||||
}
|
||||
}
|
||||
//放置零件时,命中缓存的次数
|
||||
NestCache.CachePartPosCount = 0;
|
||||
//放置零件时,命中无法放置缓存的次数
|
||||
NestCache.CacheNoSetCount = 0; //noset
|
||||
NestCache.PositionCache = {};
|
||||
NestCache.NoPutCache = {};
|
||||
NestCache.CacheRect = new Map();
|
||||
|
||||
function Path2Polyline(path) {
|
||||
let pl = new Polyline();
|
||||
pl.LineData = path.map(p => {
|
||||
return { pt: AsVector2(p), bul: 0 };
|
||||
});
|
||||
pl.CloseMark = true;
|
||||
return pl;
|
||||
}
|
||||
|
||||
function Polyline2Points(pl, outside, knifeRadius) {
|
||||
let pts = [];
|
||||
if (!outside)
|
||||
@@ -25415,6 +25408,9 @@ function Polyline2Points(pl, outside, knifeRadius) {
|
||||
let bul = pl.GetBulgeAt(i);
|
||||
if (bul !== 0) {
|
||||
let arc = pl.GetCurveAtIndex(i);
|
||||
// //小圆弧内嵌时忽略小圆(直线连接) 有可能产生自交 放弃这个
|
||||
// if (!outside && arc.Radius < 30 && bul > 0) continue;
|
||||
// if (outside && arc.Radius < 30 && bul < 0) continue;
|
||||
let allAngle = arc.AllAngle;
|
||||
let arcLength = arc.Length;
|
||||
let minCount = Math.floor(allAngle * 4 / Math.PI);
|
||||
@@ -25866,12 +25862,52 @@ RoomRegion = __decorate([
|
||||
Factory
|
||||
], RoomRegion);
|
||||
|
||||
function Path2Polyline(path) {
|
||||
let pl = new Polyline();
|
||||
pl.LineData = path.map(p => {
|
||||
return { pt: AsVector2(p), bul: 0 };
|
||||
});
|
||||
pl.CloseMark = true;
|
||||
return pl;
|
||||
}
|
||||
|
||||
class NestCache {
|
||||
/**
|
||||
* 用于创建原点在0点的矩形路径
|
||||
*/
|
||||
static CreatePath(x, y, knifRadius = 3.5) {
|
||||
let minX = -knifRadius;
|
||||
let maxX = x + knifRadius;
|
||||
let minY = -knifRadius;
|
||||
let maxY = y + knifRadius;
|
||||
return new Path([
|
||||
{ x: minX, y: minY },
|
||||
{ x: maxX, y: minY },
|
||||
{ x: maxX, y: maxY },
|
||||
{ x: minX, y: maxY },
|
||||
]);
|
||||
}
|
||||
static Clear() {
|
||||
this.CachePartPosCount = 0;
|
||||
this.CacheNoSetCount = 0;
|
||||
this.CacheRect.clear();
|
||||
this.PositionCache = {};
|
||||
}
|
||||
}
|
||||
//放置零件时,命中缓存的次数
|
||||
NestCache.CachePartPosCount = 0;
|
||||
//放置零件时,命中无法放置缓存的次数
|
||||
NestCache.CacheNoSetCount = 0; //noset
|
||||
NestCache.PositionCache = {};
|
||||
NestCache.NoPutCache = {};
|
||||
NestCache.CacheRect = new Map();
|
||||
|
||||
const TEXT_BOX = NestCache.CreatePath(570, 110);
|
||||
//分析文字放置位置
|
||||
function ParseRegionTextPos(contour, holes) {
|
||||
let hasTextBox = true;
|
||||
let path = new Path(contour);
|
||||
let nfps = path.GetInsideNFP(TEXT_BOX)?.map(nfp => Path2Polyline(TranslatePath_Self(PathScale(nfp, 1e-4), path.OrigionMinPoint.x, path.OrigionMinPoint.y))); //可能无法获得
|
||||
let nfps = path.GetInsideNFP(TEXT_BOX)?.map(nfp => Path2Polyline(PathTranslate_Self(PathScale(nfp, 1e-4), path.OrigionMinPoint.x, path.OrigionMinPoint.y))); //可能无法获得
|
||||
if (!nfps || nfps.length === 0) {
|
||||
nfps = [Path2Polyline(contour)];
|
||||
hasTextBox = false;
|
||||
@@ -25881,7 +25917,7 @@ function ParseRegionTextPos(contour, holes) {
|
||||
let hpath = new Path(hole);
|
||||
let nfps = hpath.GetOutsideNFP(TEXT_BOX);
|
||||
let nfp = nfps[Max(nfps, (n1, n2) => Area(n2) > Area(n1))];
|
||||
let pl = Path2Polyline(TranslatePath_Self(PathScale(nfp, 1e-4), hpath.OrigionMinPoint.x, hpath.OrigionMinPoint.y));
|
||||
let pl = Path2Polyline(PathTranslate_Self(PathScale(nfp, 1e-4), hpath.OrigionMinPoint.x, hpath.OrigionMinPoint.y));
|
||||
let box = pl.BoundingBox;
|
||||
let boxpl = new Polyline().RectangleFrom2Pt(new Vector3(box.min.x - 1e5, box.min.y - 1), new Vector3(box.max.x + 1e5, box.min.y + 1));
|
||||
let con1 = Contour.CreateContour(pl, false);
|
||||
@@ -31091,8 +31127,11 @@ let SymbolTable = class SymbolTable extends CADObject {
|
||||
if (ver === 1)
|
||||
file.Read();
|
||||
let record = file.ReadObject();
|
||||
if (record)
|
||||
if (record) {
|
||||
this.Symbols.set(record.Name, record);
|
||||
if (!record.Owner)
|
||||
record.Owner = this.objectId;
|
||||
}
|
||||
}
|
||||
}
|
||||
WriteFile(file) {
|
||||
@@ -31452,8 +31491,12 @@ let ObjectCollection = class ObjectCollection extends CADObject {
|
||||
let cout = file.Read();
|
||||
for (let i = 0; i < cout; i++) {
|
||||
let obj = file.ReadObject();
|
||||
if (obj)
|
||||
if (obj) {
|
||||
this.Objects.push(obj);
|
||||
//由于旧的图纸可能没有这个Owner 可能造成一些错误,这里修复它
|
||||
if (!obj.Owner)
|
||||
obj.Owner = this.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
//对象将自身数据写入到文件.
|
||||
@@ -32169,8 +32212,6 @@ let HistoricManage = HistoricManage_1 = class HistoricManage extends CADObject {
|
||||
* 请调用 commandMachine.CommandStart
|
||||
*/
|
||||
StartCmd(cmdName) {
|
||||
if (cmdName === "REDO" || cmdName === "U")
|
||||
return;
|
||||
//删除当前状态以后的所有状态
|
||||
this.historyRecord.splice(this.curIndex + 1, this.historyRecord.length - (this.curIndex + 1));
|
||||
this.historyRecord.push(new CommandHistoryRecord(cmdName));
|
||||
@@ -41035,10 +41076,6 @@ let TemplateBoardRecord = class TemplateBoardRecord extends TemplateRecord {
|
||||
br.Width = nbrs[i].Width;
|
||||
br.Height = nbrs[i].Height;
|
||||
br.Thickness = nbrs[i].Thickness;
|
||||
if (refBr) {
|
||||
br.IsChaiDan = refBr.IsChaiDan;
|
||||
br.RelevanceMeats = refBr.RelevanceMeats;
|
||||
}
|
||||
}
|
||||
else {
|
||||
let br = nbrs[i];
|
||||
|
Reference in New Issue
Block a user