功能:提供房间和墙体关联关系

This commit is contained in:
ChenX
2022-11-01 17:38:37 +08:00
parent 35f2e8fea9
commit e74917cf54
139 changed files with 1064 additions and 494 deletions

View File

@@ -1604,28 +1604,15 @@ exports.Entity = Entity_1 = class Entity extends CADObject {
Move(v) {
if (equaln$1(v.x, 0) && equaln$1(v.y, 0) && equaln$1(v.z, 0))
return;
this.WriteAllObjectRecord();
this._Matrix.elements[12] += v.x;
this._Matrix.elements[13] += v.y;
this._Matrix.elements[14] += v.z;
this._SpaceOCS.elements[12] += v.x;
this._SpaceOCS.elements[13] += v.y;
this._SpaceOCS.elements[14] += v.z;
this.Update(exports.UpdateDraw.Matrix);
tempMatrix1.identity().setPosition(v.x, v.y, v.z);
this.ApplyMatrix(tempMatrix1);
return this;
}
set Position(pt) {
let moveX = pt.x - this._Matrix.elements[12];
let moveY = pt.y - this._Matrix.elements[13];
let moveZ = pt.z - this._Matrix.elements[14];
if (moveX === 0 && moveY === 0 && moveZ === 0)
return;
this.WriteAllObjectRecord();
this._Matrix.setPosition(pt);
this._SpaceOCS.elements[12] += moveX;
this._SpaceOCS.elements[13] += moveY;
this._SpaceOCS.elements[14] += moveZ;
this.Update(exports.UpdateDraw.Matrix);
this.Move({ x: moveX, y: moveY, z: moveZ });
}
get Z() { return this._Matrix.elements[14]; }
set Z(z) {
@@ -2859,7 +2846,7 @@ function CreatePolylinePath(pts, buls) {
return shape;
}
function GetGoodShaderSimple(color = new three.Vector3, side = three.FrontSide) {
function GetGoodShaderSimple(color = new three.Vector3, side = three.FrontSide, logBuf = false) {
return {
uniforms: {
"SurfaceColor": { value: color }
@@ -3175,7 +3162,7 @@ class ColorMaterial {
let key = `${color}${side}`;
if (this._ConceptualMaterial.has(key))
return this._ConceptualMaterial.get(key);
let shaderParams = GetGoodShaderSimple(new three.Vector3().fromArray(this.GetColor(color).toArray()), side);
let shaderParams = GetGoodShaderSimple(new three.Vector3().fromArray(this.GetColor(color).toArray()), side, ColorMaterial.UseLogBuf);
let mtl = new three.ShaderMaterial(shaderParams);
this._ConceptualMaterial.set(key, mtl);
return mtl;
@@ -3513,8 +3500,8 @@ exports.Curve = class Curve extends exports.Entity {
GetPointAtDistance(distance) { return; }
GetDistAtParam(param) { return; }
GetDistAtPoint(pt) { return; }
GetParamAtPoint(pt) { return; }
GetParamAtPoint2(pt) { return this.GetParamAtPoint(pt); }
GetParamAtPoint(pt, fuzz = 1e-6) { return; }
GetParamAtPoint2(pt, fuzz = 1e-6) { return this.GetParamAtPoint(pt, fuzz); }
GetParamAtDist(d) { return; }
/**
* 返回曲线在指定位置的一阶导数(在wcs内)
@@ -3563,8 +3550,8 @@ exports.Curve = class Curve extends exports.Entity {
//翻转曲线.首尾调换.
Reverse() { return this; }
//点在曲线上
PtOnCurve(pt, fuzz = 1e-6) {
return equalv3(this.StartPoint, pt, fuzz) || equalv3(this.EndPoint, pt, fuzz) || this.ParamOnCurve(this.GetParamAtPoint(pt));
PtOnCurve(pt, fuzz = 1e-5) {
return equalv3(this.StartPoint, pt, fuzz) || equalv3(this.EndPoint, pt, fuzz) || this.ParamOnCurve(this.GetParamAtPoint(pt, fuzz));
}
//点在曲线中,不在起点或者终点.
PtOnCurve2(pt) {
@@ -3846,9 +3833,9 @@ exports.Line = Line_1 = class Line extends exports.Curve {
GetPointAtParam(param) {
return this.StartPoint.add(this.GetFistDeriv(0).multiplyScalar(param));
}
GetParamAtPoint(pt) {
GetParamAtPoint(pt, fuzz = 1e-5) {
let { closestPt, param } = this.GetClosestAtPoint(pt, true);
if (!equalv3(closestPt, pt, 1e-5))
if (!equalv3(closestPt, pt, fuzz))
return NaN;
return param;
}
@@ -5649,20 +5636,20 @@ var BoolOpeartionType;
})(BoolOpeartionType || (BoolOpeartionType = {}));
const fuzz = 1e-3;
let fuzzV3 = new three.Vector3(fuzz, fuzz, fuzz);
//判断曲线是否在源封闭曲线内
function isTargetCurInOrOnSourceCur(sourceCur, targetCur) {
if (!sourceCur.BoundingBox.expandByVector(fuzzV3).containsBox(targetCur.BoundingBox))
//判断曲线是不是被大曲线包含(或者重叠?)
function isTargetCurInOrOnSourceCur(bigCurve, smallCurve) {
if (!bigCurve.BoundingBox.expandByVector(fuzzV3).containsBox(smallCurve.BoundingBox))
return false;
let cus = [];
if (targetCur instanceof exports.Polyline)
cus = targetCur.Explode();
if (smallCurve instanceof exports.Polyline)
cus = smallCurve.Explode();
else
cus = [targetCur];
cus = [smallCurve];
return cus.every(c => {
let pts = getIntPtContextPts(sourceCur, c);
let pts = getIntPtContextPts(bigCurve, c);
if (pts.length <= 1)
pts.push(c.StartPoint, c.EndPoint);
return IsPtsAllInOrOnReg(sourceCur, pts);
return IsPtsAllInOrOnReg(bigCurve, pts);
});
}
//获取交点处上下距0.01par的点
@@ -5862,12 +5849,12 @@ class Contour {
let sourceContainerTarget;
let targetContainerSource;
if (sourceOutline.Area > targetOutline.Area) {
sourceContainerTarget = interPts.length === 0 ? fastCurveInCurve(sourceOutline, targetOutline) : this.CuInOutline(targetOutline);
sourceContainerTarget = CurveContainerCurve(sourceOutline, targetOutline, interPts);
targetContainerSource = false;
}
else {
sourceContainerTarget = false;
targetContainerSource = interPts.length === 0 ? fastCurveInCurve(targetOutline, sourceOutline) : target.CuInOutline(sourceOutline);
targetContainerSource = CurveContainerCurve(targetOutline, sourceOutline, interPts);
}
//包含.相交.分离(三种状态)
if (sourceContainerTarget) //源包含目标
@@ -6104,8 +6091,15 @@ class Contour {
get Shape() {
return this._Curve.Shape;
}
CuInOutline(targetCur) {
return isTargetCurInOrOnSourceCur(this._Curve, targetCur);
/**
* 判断是否完全包含曲线
* @param smallCurve 传入的这个曲线不能比本轮廓还大(这个需要自己优化?)
* @returns
*/
ContainerCurve(smallCurve, isAreaCheckd = false, ipts = undefined) {
if (!isAreaCheckd && this.Area < smallCurve.Area)
return false;
return CurveContainerCurve(this._Curve, smallCurve, ipts);
}
Equal(tar) {
return equalCurve(this._Curve, tar._Curve);
@@ -6124,15 +6118,30 @@ function fastEqualCurve(c1, c2, tolerance = 1e-3) {
return false;
return equalv3(c1.Midpoint, c2.Midpoint, tolerance);
}
//对于双多段线互相切割后的结果,快速判断曲线是否在另一条曲线内部
//也许有一天这个中点算法需要改一下, 使用.MidPoint比较稳妥
function fastCurveInCurve(sourceCu, targetCu) {
return sourceCu.PtInCurve(targetCu.Midpoint);
/**
* 对于双多段线互相切割后的结果(或者交点个数为0),快速判断曲线是否在另一条曲线内部
* @param bigCurve
* @param smallCurve
* @returns
*/
function fastCurveInCurve(bigCurve, smallCurve) {
return bigCurve.PtInCurve(smallCurve.Midpoint);
}
//当交点小于等于1时
function fastCurveInCurve2(sourceCu, targetCu) {
return sourceCu.PtInCurve(targetCu.StartPoint) ||
sourceCu.PtInCurve(targetCu.Midpoint);
function fastCurveInCurve2(bigCurve, smallCurve) {
return bigCurve.PtInCurve(smallCurve.StartPoint) ||
bigCurve.PtInCurve(smallCurve.Midpoint);
}
//大曲线是否完全包含小曲线(或者重合)
function CurveContainerCurve(bigCurve, smallCurve, ipts = undefined, fuzz = COMBINE_FUZZ) {
if (!ipts)
ipts = bigCurve.IntersectWith2(smallCurve, IntersectOption.ExtendNone, fuzz);
if (ipts.length === 0)
return fastCurveInCurve(bigCurve, smallCurve);
else if (ipts.length === 1)
return fastCurveInCurve2(bigCurve, smallCurve);
else
return isTargetCurInOrOnSourceCur(bigCurve, smallCurve);
}
class CurveTreeNode {
@@ -7680,10 +7689,10 @@ exports.Polyline = Polyline_1 = class Polyline extends exports.Curve {
pl.LineData = lineData;
return pl;
}
PtOnCurve(pt) {
PtOnCurve(pt, fuzz = 1e-6) {
for (let i = 0; i < this.EndParam; i++) {
let c = this.GetCurveAtIndex(i);
if (c.PtOnCurve(pt))
if (c.PtOnCurve(pt, fuzz))
return true;
}
return false;
@@ -7900,6 +7909,17 @@ exports.Polyline = Polyline_1 = class Polyline extends exports.Curve {
}
return box;
}
SetPtsBuls(pts, buls) {
this.WriteAllObjectRecord();
this._LineData.length = 0;
for (let i = 0; i < pts.length; i++) {
let pt = pts[i];
let bul = buls[i];
this._LineData.push({ pt, bul });
}
this.Update();
return this;
}
/**
* 得到曲线有用的点表和凸度(闭合曲线首尾重复)
*/
@@ -9855,11 +9875,9 @@ function ScaleUV2(geo, ocs, xScale = 1e-3, yScale = 1e-3, isInvert = false) {
}
class Shape {
constructor(out, hols) {
this._Holes = [];
this._Shape = new three.Shape();
this._Outline = out || new Contour();
hols && this._Holes.push(...hols);
constructor(_Outline = new Contour, _Holes = []) {
this._Outline = _Outline;
this._Holes = _Holes;
}
get Outline() {
return this._Outline;
@@ -9875,17 +9893,27 @@ class Shape {
get BoundingBox() {
return this._Outline.BoundingBox;
}
set Outline(cus) {
this._Outline = cus;
this.UpdateShape();
set Outline(con) {
this._Outline = con;
}
set Holes(cus) {
this._Holes = cus;
this.UpdateShape();
set Holes(holes) {
this._Holes = holes;
}
get Shape() {
this.UpdateShape();
return this._Shape;
let shape = this.Outline.Shape;
for (let h of this._Holes) {
if (h.Curve instanceof exports.Polyline)
h.Curve.UpdateOCSTo(this.Outline.Curve.OCS);
if (h.Curve instanceof exports.Circle) {
let sp = new three.Path();
let cen = h.Curve.Center.applyMatrix4(this.Outline.Curve.OCSInv);
sp.ellipse(cen.x, cen.y, h.Curve.Radius, h.Curve.Radius, 0, 2 * Math.PI, false, 0);
shape.holes.push(sp);
}
else
shape.holes.push(h.Shape);
}
return shape;
}
get Position() {
return this._Outline.Curve.Position;
@@ -10036,8 +10064,8 @@ class Shape {
//合并运算时提取出运算后的孔洞和形状
const pickUpHoleOrShape = (srcHoles, tarHoles, outline) => {
srcHoles.forEach(cu => {
let tmpContours = cu.SubstactBoolOperation(outline).sort((a, b) => b.Area - a.Area);
let isAllContainered = tmpContours.length > 1 && tmpContours.slice(1).every((cu, index) => tmpContours[0].CuInOutline(cu.Curve));
let tmpContours = cu.SubstactBoolOperation(outline).sort((a, b) => b.Area - a.Area); //面积从大到校
let isAllContainered = tmpContours.length > 1 && tmpContours.slice(1).every((cu, index) => tmpContours[0].ContainerCurve(cu.Curve, true));
//洞是否被最大的洞包含,是,则把被包含的洞都提取出来加入形状数组
if (isAllContainered) {
shapes.push(...this.targetOutlinesSubHoles(tmpContours.slice(1).map(c => new Shape(c)), tarHoles.map(c => new Shape(c))));
@@ -10151,7 +10179,7 @@ class Shape {
let outline = contours.shift();
//取出包含的洞
arrayRemoveIf(contours, (con) => {
let bisIn = outline.CuInOutline(con.Curve);
let bisIn = outline.ContainerCurve(con.Curve, true);
if (bisIn)
tmpHoles.push(con);
return bisIn;
@@ -10238,30 +10266,15 @@ class Shape {
let holes = [];
if (tmpHoles.length <= 1)
return tmpHoles;
tmpHoles.sort((a, b) => b.Area - a.Area);
tmpHoles.sort((a, b) => b.Area - a.Area); //面积从大到小排序
while (tmpHoles.length) {
let srcHole = tmpHoles.shift();
holes.push(srcHole);
//移除包含的洞
arrayRemoveIf(tmpHoles, h => srcHole.CuInOutline(h.Curve));
arrayRemoveIf(tmpHoles, h => srcHole.ContainerCurve(h.Curve, true));
}
return holes;
}
UpdateShape() {
this._Shape = this.Outline.Shape;
for (let h of this._Holes) {
if (h.Curve instanceof exports.Polyline)
h.Curve.UpdateOCSTo(this.Outline.Curve.OCS);
if (h.Curve instanceof exports.Circle) {
let sp = new three.Path();
let cen = h.Curve.Center.applyMatrix4(this.Outline.Curve.OCSInv);
sp.ellipse(cen.x, cen.y, h.Curve.Radius, h.Curve.Radius, 0, 2 * Math.PI, false, 0);
this._Shape.holes.push(sp);
}
else
this._Shape.holes.push(h.Shape);
}
}
//读写文件
ReadFile(file) {
file.Read(); //1
@@ -11634,6 +11647,7 @@ class PointShapeUtils {
}
}
//为了避免Core对UI库的依赖,导致测试用例失败,导致外部项目引用失败,我们分离了这个函数
var Intent;
(function (Intent) {
Intent["NONE"] = "none";
@@ -11647,6 +11661,11 @@ function Toaster(option) {
for (let f of ToasterInjectFunctions)
f(option);
}
const ToasterShowEntityMsgInjectFunctions = [];
function ToasterShowEntityMsg(option) {
for (let f of ToasterShowEntityMsgInjectFunctions)
f(option);
}
var EMetalsType;
(function (EMetalsType) {
@@ -11666,6 +11685,7 @@ var EFindType;
EFindType[EFindType["RemoveModelingAndSpecial"] = 7] = "RemoveModelingAndSpecial";
EFindType[EFindType["ModifyHardware"] = 8] = "ModifyHardware";
EFindType[EFindType["FindMinSize"] = 9] = "FindMinSize";
EFindType[EFindType["GetHardWareOption"] = 10] = "GetHardWareOption";
})(EFindType || (EFindType = {}));
var ECompareType;
(function (ECompareType) {
@@ -12010,7 +12030,7 @@ const DefaultClosingStripOption = {
};
Object.freeze(DefaultClosingStripOption);
const DefaultBoardFindOption = {
version: 5,
version: 6,
condition: {
layer: false,
height: false,
@@ -12024,6 +12044,7 @@ const DefaultBoardFindOption = {
useSpecial: false,
useModeling: false,
roomName: false,
hardwareName: false,
cabinetName: false,
brName: false,
material: false,
@@ -12051,6 +12072,7 @@ const DefaultBoardFindOption = {
roomName: ECompareType.Equal,
cabinetName: ECompareType.Equal,
brName: ECompareType.Equal,
hardwareName: ECompareType.Equal,
[EBoardKeyList.Mat]: ECompareType.Equal,
[EBoardKeyList.Color]: ECompareType.Equal,
[EBoardKeyList.BrMat]: ECompareType.Equal,
@@ -12073,6 +12095,7 @@ const DefaultBoardFindOption = {
roomName: "",
cabinetName: "",
brName: "",
hardwareName: "",
[EBoardKeyList.BrMat]: "",
material: "",
color: "",
@@ -13668,7 +13691,17 @@ class LookOverBoardInfosTool {
}
}
//封边
let sealData = GetBoardSealingData(GetSealedBoardContour(b, true, true));
let sealContour = GetSealedBoardContour(b, true, true);
if (!sealContour) {
ToasterShowEntityMsg({
intent: Intent.DANGER,
msg: "板件扣封边失败,请检查板件轮廓!",
timeout: 10000,
ent: b
});
throw "错误:板扣除封边失败!";
}
let sealData = GetBoardSealingData(sealContour);
let color = b.BoardProcessOption[EBoardKeyList.Color];
for (let data of sealData) {
if (equaln$1(0, data.size))
@@ -13762,12 +13795,6 @@ class LookOverBoardInfosTool {
}
const lookOverBoardInfosTool = new LookOverBoardInfosTool();
const ReportFunctionList = [];
function SendReport(msg) {
for (let f of ReportFunctionList)
f(msg);
}
const ShowObjectsFunctionList = [];
function ShowSelectObjects(ens) {
for (let f of ShowObjectsFunctionList)
@@ -13811,7 +13838,25 @@ function FastWireframe(br, color = 0, divCount = 6, optArc = true) {
}
return result;
}
function FastExtrudeEdgeGeometryOfShape(shape, z0, z1, divCount = 6, optArc = true, coords = []) {
let ptss = [shape.getPoints(divCount, optArc)];
for (let hole of shape.holes)
ptss.push(hole.getPoints(divCount, optArc));
for (let pts of ptss)
for (let i = 0; i < pts.length; i++) {
let p = pts[i];
let nextp = pts[FixIndex$1(i + 1, pts)];
//底面
coords.push(p.x, p.y, z0, nextp.x, nextp.y, z0);
//顶面
coords.push(p.x, p.y, z1, nextp.x, nextp.y, z1);
if (p["_mask_"]) //侧面
coords.push(p.x, p.y, z0, p.x, p.y, z1);
}
return coords;
}
let tempP = new three.Vector3;
//这个代码天生不和Mesh对齐,因为独立坐标系的原因,槽的坐标系可能和主题的坐标系不一致导致的
function FastExtrudeEdgeGeometry(ext, color = 0, divCount = 6, optArc = true, coords = [], inv = undefined) {
color = color || ext.ColorIndex;
let thickness = ext.Thickness;
@@ -15417,20 +15462,6 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
}
return this;
}
get Position() {
return super.Position;
}
set Position(p) {
let v = p.clone().sub(this.Position);
if (equalv3(v, ZeroVec))
return;
super.Position = p;
let m = MoveMatrix(v);
for (let g of this.grooves)
g.ApplyMatrix(m);
//由于修改矩阵会导致bsp错误
this.csg = undefined;
}
get Width() {
return this.width;
}
@@ -16360,9 +16391,9 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
//分裂后重新将排钻实体设置给不同的实体
HandleSpliteEntitys(splitEntitys) { }
LazyGrooveCheckAll() {
this.IsLazyGrooveCheck = false;
if (this.IsNeedGrooveCheck)
this.GrooveCheckAllAutoSplit();
this.IsLazyGrooveCheck = false;
}
//#endregion
//#region Draw
@@ -16558,7 +16589,7 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
let holes = [];
let ocsInv = this.OCSInv;
let alMatrix4 = new three.Matrix4();
if (grooves.length < 1000)
if (grooves.length < MaxDrawGrooveCount)
for (let g of grooves) {
alMatrix4.multiplyMatrices(ocsInv, g.OCSNoClone);
let gContour = g.ContourCurve.Clone();
@@ -16579,6 +16610,15 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
bgeo["IsMesh"] = true;
this._MeshGeometry = bgeo;
this.GenWorldUV(bgeo);
//edge geometry
if (grooves.length < MaxDrawGrooveCount) //这个代码保证线框和概念对齐
{
let coords = FastExtrudeEdgeGeometryOfShape(shape.Shape, 0, this.thickness, 12, true);
let edgeGeo = new three.BufferGeometry();
edgeGeo.setAttribute('position', new three.Float32BufferAttribute(coords, 3));
edgeGeo.applyMatrix4(contour.OCSNoClone);
this._EdgeGeometry = edgeGeo;
}
return bgeo;
}
let builder = new ExtrudeGeometryBuilder(this);
@@ -16597,7 +16637,7 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
return this._EdgeGeometry;
//这里我们超过100就用这个,为了性能 和MaxDrawGrooveCount不一致
if (this.grooves.length > 100 || this.grooves.every(g => equaln$1(g.thickness, this.thickness)) || this.grooves.length === 0) {
let coords = FastExtrudeEdgeGeometry(this, this.ColorIndex, 20, true);
let coords = FastExtrudeEdgeGeometry(this, this.ColorIndex, 12, true);
let edgeGeo = new three.BufferGeometry();
edgeGeo.setAttribute('position', new three.Float32BufferAttribute(coords, 3));
this._EdgeGeometry = edgeGeo;
@@ -17642,6 +17682,9 @@ class Face {
if (!sideReg || !noSideFace.Region)
return [];
let toReg = noSideFace.Region.Clone().ApplyMatrix(diffMtx);
//注意: 排钻因为布尔运算失败的重灾区
// TestDraw(sideReg.Clone(), 1);
// TestDraw(toReg.Clone(), 2);
isSuccess = sideReg.BooleanOper(toReg, BoolOpeartionType.Intersection);
for (let s of sideReg.ShapeManager.ShapeList) {
let box = s.BoundingBox;
@@ -18239,7 +18282,10 @@ class FeedingToolPath extends Singleton {
let isInt = false;
for (let c of retCus) {
if (holes.length > 0) {
isInt = holes.some(h => h.Curve.IntersectWith(c, 0).length > 0 || h.CuInOutline(c));
isInt = holes.some(h => {
let ipts = h.Curve.IntersectWith2(c, 0);
return ipts.length > 0 || h.ContainerCurve(c, false, ipts);
});
if (isInt)
break;
}
@@ -18313,7 +18359,7 @@ class FeedingToolPath extends Singleton {
if (isCd)
arrayRemoveIf(modelings, m => {
let c = m.shape.Outline.Curve;
if (c instanceof exports.Circle && c.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
if (m.shape.Holes.length === 0 && c instanceof exports.Circle && c.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
return true;
return false;
});
@@ -18435,7 +18481,7 @@ class FeedingToolPath extends Singleton {
modelings[i].knifeRadius = HostApplicationServices.chaidanOption.radius;
let m = modelings[i];
let cu = m.shape.Outline.Curve;
if (cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
if (m.shape.Holes.length === 0 && cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
continue;
let cus = this.GetModelFeedPath(br, m);
if (cus.length === 0)
@@ -18448,7 +18494,7 @@ class FeedingToolPath extends Singleton {
let errHoles = [];
for (let m of [...modeling, ...sideModeling]) {
let cu = m.shape.Outline.Curve;
if (cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
if (m.shape.Holes.length === 0 && cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
continue;
if (HostApplicationServices.chaidanOption.useDefaultRad)
m.knifeRadius = HostApplicationServices.chaidanOption.radius;
@@ -18685,7 +18731,7 @@ var Production;
timeout: 8000,
intent: Intent.DANGER,
});
Report([br.__OriginalEnt__ ?? br], br.Name + " 轮廓错误");
ShowSelectObjects([br.__OriginalEnt__ ?? br]);
return undefined;
}
let sealedOutline = GetSealedBoardContour(br, false);
@@ -18695,7 +18741,7 @@ var Production;
timeout: 8000,
intent: Intent.DANGER,
});
Report([br.__OriginalEnt__ ?? br], br.Name + "扣除封边轮廓有误");
ShowSelectObjects([br.__OriginalEnt__ ?? br]);
return;
}
let offsetTanslation = sealedOutline.BoundingBox.min;
@@ -18777,7 +18823,7 @@ var Production;
let data = [];
for (let m of ms) {
let cu = m.shape.Outline.Curve;
if (cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
if (m.shape.Holes.length === 0 && cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
continue;
if (HostApplicationServices.chaidanOption.useDefaultRad)
m.knifeRadius = HostApplicationServices.chaidanOption.radius;
@@ -18804,7 +18850,7 @@ var Production;
let data = [];
for (let m of ms) {
let cu = m.shape.Outline.Curve;
if (cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
if (m.shape.Holes.length === 0 && cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6)
continue;
if (HostApplicationServices.chaidanOption.useDefaultRad)
m.knifeRadius = HostApplicationServices.chaidanOption.radius;
@@ -18952,7 +18998,7 @@ var Production;
}
for (let m of modelings) {
let cu = m.shape.Outline.Curve;
if (cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6) {
if (m.shape.Holes.length === 0 && cu instanceof exports.Circle && cu.Radius < HostApplicationServices.chaidanOption.modeling2HoleRad + 1e-6) {
let center = cu.Center.setZ(0).sub(offsetTanslation);
data.frontBackHoles.push({
type: exports.GangDrillType.Pxl,
@@ -19011,12 +19057,13 @@ var Production;
}
}
else if (d.Type === exports.GangDrillType.Ljg || d.Type === exports.GangDrillType.Wood) {
if (!isParallelTo(d.Normal, brNormal, CanDrawHoleFuzz)) {
if (isPerpendicularityTo(d.Normal, brNormal, CanDrawHoleFuzz)) //侧孔
{
let z = position.z;
if (!IsBetweenA2B(z, -d.Radius, br.Thickness + d.Radius, 1e-6))
return;
let sp = position.clone().setZ(0).add(d.Normal.multiplyScalar(-CanDrawHoleFuzz).applyMatrix4(roMat)); //加长线(以便加大容差)
let ep = position.clone().setZ(0).add(d.Normal.multiplyScalar(d.Height + CanDrawHoleFuzz).applyMatrix4(roMat)); //加长线
let sp = position.clone().add(d.Normal.multiplyScalar(-CanDrawHoleFuzz).applyMatrix4(roMat)).setZ(0); //加长线(以便加大容差)
let ep = position.clone().add(d.Normal.multiplyScalar(d.Height + CanDrawHoleFuzz).applyMatrix4(roMat)).setZ(0); //加长线
let line = new exports.Line(sp, ep);
let pt = outline.IntersectWith(line, 0)[0];
if (!pt) {
@@ -19308,11 +19355,6 @@ var Production;
return pl;
}
Production.Data2Polyline = Data2Polyline;
function Report(ens, msg) {
ShowSelectObjects(ens);
SendReport(msg);
}
Production.Report = Report;
function Get2DModeing(br, offset) {
let res = [];
let tmtx = MoveMatrix(offset.clone().negate());
@@ -19917,20 +19959,9 @@ function VData2Curve(data) {
}
var Board_1;
//转换板件类型成为空间类型. 0x 1y 2z
function ConverBoardTypeToSpaceType(type) {
switch (type) {
case BoardType.Layer:
return 2;
case BoardType.Vertical:
return 0;
case BoardType.Behind:
return 1;
}
}
//排钻配置名是合法的
function IsValidDriName(name) {
return name === "不排" || HostApplicationServices.DrillConfigs.has(name);
return name === DrillType.None || name === DrillType.More || HostApplicationServices.DrillConfigs.has(name);
}
/**
* 板件实体
@@ -21427,19 +21458,26 @@ class Matrix2 {
}
function EntityUpdateWrap(ent, exec) {
let bak = ent.AutoUpdate;
let oldAutoUpdate = ent.AutoUpdate;
ent.AutoUpdate = false;
exec();
ent.DeferUpdate();
ent.AutoUpdate = bak;
if (oldAutoUpdate) //如果原先是自动更新的,那么我们更新它,否则还是不更新(避免层层嵌套导致的性能优化丢失)
ent.DeferUpdate();
ent.AutoUpdate = oldAutoUpdate;
}
function EntitysUpdateWrap(ens, exec) {
let baks = ens.map(e => e.AutoUpdate);
let baks = ens.map(e => {
let oldAutoUpdate = e.AutoUpdate;
e.AutoUpdate = false;
return oldAutoUpdate;
});
exec();
for (let i = 0; i < ens.length; i++) {
let en = ens[i];
en.DeferUpdate();
en.AutoUpdate = baks[i];
if (baks[i]) {
let en = ens[i];
en.DeferUpdate();
en.AutoUpdate = true;
}
}
}
@@ -21838,6 +21876,8 @@ var WallSnapMode;
})(WallSnapMode || (WallSnapMode = {}));
const CURVE_FACE_TYPE_KEY = "__CURVE_FACE_TYPE_KEY__"; //用来存储墙体类型的key
const CURVE_DIR_TYPE_KEY = "__CURVE_DIR_TYPE_KEY__"; //方向
const CURVE_WALL_TYPE_KEY = "__CURVE_WALL_TYPE_KEY__"; //墙
exports.WallFaceType = void 0;
(function (WallFaceType) {
WallFaceType[WallFaceType["Inside"] = 0] = "Inside";
@@ -23799,7 +23839,7 @@ exports.Light = Light_1 = class Light extends exports.Entity {
}
set Color(color) {
this.WriteAllObjectRecord();
this._LightColor = color;
this._LightColor.set(color);
this.Update();
}
get ShowHelper() {
@@ -23973,6 +24013,24 @@ exports.DirectionalLight = class DirectionalLight extends exports.Light {
this.Update();
}
}
get SunPosition() { return super.Position; }
set SunPosition(p) {
if (equaln$1(p.x, this._Matrix.elements[12])
&& equaln$1(p.y, this._Matrix.elements[13])
&& equaln$1(p.z, this._Matrix.elements[14]))
return;
this.WriteAllObjectRecord();
this._Matrix.setPosition(p);
this.Update(exports.UpdateDraw.Geometry);
}
get Position() { return super.Position; }
set Position(p) {
console.error("不支持的用法! 错误的设计");
let bak = this._Target.toArray();
super.Position = p;
this._Target.fromArray(bak);
this.Update(exports.UpdateDraw.Geometry);
}
get WebIntensity() {
let x = this._Intensity / 150;
x = Math.pow(x, 0.4);
@@ -23995,7 +24053,7 @@ exports.DirectionalLight = class DirectionalLight extends exports.Light {
if (indexList[0] === 0)
this.Position = this.Position.add(vec);
else
this.Target = this.Target.add(vec);
this._Target.add((vec));
}
InitDrawObject(renderType = exports.RenderType.Wireframe) {
let lightGroup = new three.Group();
@@ -26624,6 +26682,11 @@ exports.TemplateParam = __decorate([
Factory
], exports.TemplateParam);
const BoardType2SplitType = [2, 0, 1];
//转换板件类型成为空间类型. 0x 1y 2z
function ConverBoardTypeToSplitType(type) {
return BoardType2SplitType[type];
}
/**
* 夹层空间分析
*/
@@ -26642,7 +26705,7 @@ class ClampSpaceParse extends ISpaceParse {
//单层空间(用于切割)
let spliteBoxs = new Map();
for (let [boardType, boards] of this.BoardMap) {
let splitType = ConverBoardTypeToSpaceType(boardType);
let splitType = ConverBoardTypeToSplitType(boardType);
let boardBoxCol = this.ParseBoardBox(boards, splitType);
//#IWFYY
if (boardType === BoardType.Behind && this.BoardMap.size > 1 && boardBoxCol.length > 1) {
@@ -26703,13 +26766,13 @@ class ClampSpaceParse extends ISpaceParse {
this.ParseOK = false;
return;
}
let splitType = ConverBoardTypeToSpaceType(type);
let splitType = ConverBoardTypeToSplitType(type);
let p1 = box.min.clone().setComponent(splitType, box.min.getComponent(splitType) - dist);
let p2 = box.max.clone().setComponent(splitType, box.min.getComponent(splitType));
let p3 = box.min.clone().setComponent(splitType, box.max.getComponent(splitType));
let p4 = box.max.clone().setComponent(splitType, box.max.getComponent(splitType) + dist);
let boxs = [new Box3Ext().setFromPoints([p1, p2]), new Box3Ext().setFromPoints([p3, p4])];
this.SpaceBox = await this.WrapSelectBox(boxs, ConverBoardTypeToSpaceType(br.BoardType));
this.SpaceBox = await this.WrapSelectBox(boxs, splitType);
if (this.SpaceBox)
this.ParseOK = true;
}
@@ -26750,6 +26813,8 @@ class ClampSpaceParse extends ISpaceParse {
}
for (let [splitType, spBox] of spliteBoxes) {
let remBoxs = orgBox.substract(spBox, splitType);
if (remBoxs[0] === orgBox) //如果切割失败,证明这个板没办法影响空间分析,所以移除它.
;
if (remBoxs.length === 0)
return undefined;
else if (remBoxs.length === 1) {
@@ -27242,8 +27307,6 @@ exports.TemplateRecord = TemplateRecord_1 = class TemplateRecord extends SymbolT
this.RZParam.expr = "";
}
}
//相对定位. use PX PY PZ
this.UpdatePosition(paramMap, evaled);
//更新LWH(通过定位空间)
this.LParam.UpdateParam(this._CacheSpaceSize.x);
this.WParam.UpdateParam(this._CacheSpaceSize.y);
@@ -27259,6 +27322,8 @@ exports.TemplateRecord = TemplateRecord_1 = class TemplateRecord extends SymbolT
//删除材质变量(材质变量仅在KJL导入中使用,重新出现在右侧列表中是不明智的?) (但是用户可能编辑更新了它?)
// arrayRemoveIf(this.Params, p => p.type === TemplateParamType.Material);
this.UpdateEntitys();
//相对定位. use PX PY PZ(这个代码在这里,保证所有的变量都是最新的. 这样我们就可以使用H/2自己定位到自己空间的一半位置)(这个只会修改定位,所以放在这里并不会影响其他的代码)
this.UpdatePosition(paramMap, evaled);
//变换到新的模版空间
for (let en of ens) {
en.ApplyMatrix(this._CacheSpaceCS);
@@ -29043,6 +29108,7 @@ exports.TemplateWineRackRecord = __decorate([
Factory
], exports.TemplateWineRackRecord);
//铰链
function IsHinge(en) {
if (en instanceof exports.HardwareCompositeEntity) {
if (en.Template) {
@@ -29277,6 +29343,7 @@ exports.Text = class Text extends exports.Entity {
exports.Text = __decorate([
Factory
], exports.Text);
const DbText = exports.Text;
const EmptyArray = [];
exports.VisualSpaceBox = class VisualSpaceBox extends exports.Entity {
@@ -29641,7 +29708,7 @@ class CameraUpdate {
*/
Pan(mouseMove) {
mouseMove.y *= -1;
mouseMove.multiplyScalar(-this._ViewHeight / (this._Height * window.devicePixelRatio));
mouseMove.multiplyScalar(-this._ViewHeight / this._Height);
mouseMove.applyQuaternion(this.Camera.quaternion);
this._Target.add(mouseMove);
this._Target.clamp(ViewScopeMin, ViewScopeMax);
@@ -33905,6 +33972,46 @@ exports.PositioningBoardSpace = __decorate([
Factory
], exports.PositioningBoardSpace);
/**
* 拉手的定位空间
*/
exports.PositioningHandleSpace = class PositioningHandleSpace extends exports.Positioning {
constructor(_ObjectId) {
super();
this.ObjectId = _ObjectId;
}
/**
* 定位
*/
async Positioning() {
this.SpaceCS = undefined;
this.SpaceSize = undefined;
if (this.ObjectId && !this.ObjectId.IsErase) {
let ent = this.ObjectId.Object;
this.SpaceCS = ent.SpaceOCS;
let box = ent.GetBoundingBoxInMtx(ent.SpaceOCSInv);
this.SpaceSize = box.getSize(new three.Vector3);
let baseP = box.min.applyMatrix4(this.SpaceCS);
this.SpaceCS.setPosition(baseP);
}
}
//#region File
ReadFile(file) {
file.Read();
this.ObjectId = file.ReadObjectId();
}
WriteFile(file) {
file.Write(1);
file.WriteObjectId(this.ObjectId);
}
};
__decorate([
AutoRecord
], exports.PositioningHandleSpace.prototype, "ObjectId", void 0);
exports.PositioningHandleSpace = __decorate([
Factory
], exports.PositioningHandleSpace);
/**
* 板件模板的基类.(层板,立板,背板)
*/
@@ -34286,23 +34393,22 @@ class ActivityLayerBoardTool {
}
return 0;
}
BuildNails(initNail, nailOpt, face, fYVec) {
BuildNails(initNail, nailOpt, face, fYVec, nailCount) {
let fXVec = new three.Vector3().setFromMatrixColumn(face.OCS, 0);
let addCount = nailOpt.addCount;
let count = nailOpt.count;
let dist = nailOpt.dist;
let frontDist = nailOpt.front;
let backDist = nailOpt.behind;
let singleDist;
//绘制数量为1时,层板钉在中间位置
if (count === 1)
if (nailCount === 1)
singleDist = face.Length / 2 - frontDist;
else
singleDist = (face.Length - frontDist - backDist) / (count - 1);
singleDist = (face.Length - frontDist - backDist) / (nailCount - 1);
let buildNails = [];
//构建层板钉
for (let i = 0; i < count; i++) {
if (count === 1) {
for (let i = 0; i < nailCount; i++) {
if (nailCount === 1) {
initNail.ApplyMatrix(MoveMatrix(fXVec.multiplyScalar(singleDist)));
buildNails.push(initNail);
}
@@ -34388,10 +34494,12 @@ class ActivityLayerBoardTool {
zDist += (-nail.Height + nailOption.depth);
nail.Position = nail.Position.add(new three.Vector3(xDist, yDist, zDist));
nail.ApplyMatrix(zRoMat).ApplyMatrix(face.OCS);
//层板钉数
let nailCount = nailOption.count;
if (option || this.NailRules)
nailOption.count = this.GetRuleCount(face.Length, rules);
nailCount = this.GetRuleCount(face.Length, rules);
let yVec = new three.Vector3().setFromMatrixColumn(otherBoard.OCS, 1);
let nails = this.BuildNails(nail, nailOption, face, yVec);
let nails = this.BuildNails(nail, nailOption, face, yVec, nailCount);
for (let nail of nails)
nailBoardMap.set(nail, otherBoard);
allNails.push(...nails);
@@ -34650,18 +34758,20 @@ exports.TemplateLeftRightBoardRecord = class TemplateLeftRightBoardRecord extend
let thickness = this.GetParam("BH")?.value ?? 18;
let zs = this.GetParam("ZS")?.value ?? 0; //左缩
let ys = this.GetParam("YS")?.value ?? 0; //右缩
lBr.Thickness = thickness;
rBr.Thickness = thickness;
if (!this._CacheSpaceSize) {
console.warn("左右侧板模板数据错误无法更新");
return;
}
lBr.Height = this._CacheSpaceSize.z;
rBr.Height = this._CacheSpaceSize.z;
lBr.Width = this._CacheSpaceSize.y - zs;
rBr.Width = this._CacheSpaceSize.y - ys;
lBr.Position = new three.Vector3(0, zs, 0);
rBr.Position = new three.Vector3(this._CacheSpaceSize.x - rBr.Thickness, ys, 0);
EntitysUpdateWrap([lBr, rBr], () => {
lBr.Thickness = thickness;
rBr.Thickness = thickness;
if (!this._CacheSpaceSize) {
console.warn("左右侧板模板数据错误无法更新");
return;
}
lBr.Height = this._CacheSpaceSize.z;
rBr.Height = this._CacheSpaceSize.z;
lBr.Width = this._CacheSpaceSize.y - zs; //似乎用拉伸来做比较好,这样能保持住背板对他的拉槽.
rBr.Width = this._CacheSpaceSize.y - ys;
lBr.Position = new three.Vector3(0, zs, 0);
rBr.Position = new three.Vector3(this._CacheSpaceSize.x - rBr.Thickness, ys, 0);
});
}
ReadFile(file) {
super.ReadFile(file);
@@ -36336,6 +36446,14 @@ class RegionReplacement {
//分析可用的内空间(墙面方向指向空间内部为内空间) 否则为外墙空间
//构造面域树? 不需要了? 还是需要的 需要一个最大的天花板
//区域对象 (地面+天花?)
const ROOM_REGION_CURVES_KEY = "__ROOM_REGION_CURVES_KEY__";
//墙内曲线的类型
var WallCurveDirType;
(function (WallCurveDirType) {
WallCurveDirType[WallCurveDirType["left"] = 0] = "left";
WallCurveDirType[WallCurveDirType["right"] = 1] = "right";
WallCurveDirType[WallCurveDirType["lid"] = 2] = "lid";
})(WallCurveDirType || (WallCurveDirType = {}));
/**
* 区域分析(房间+外墙+全屋顶)
*/
@@ -36364,24 +36482,32 @@ class RoomRegionParse {
for (let c of wall.LeftCurves) {
curves.push(c);
leftCurves.add(c);
c[CURVE_DIR_TYPE_KEY] = WallCurveDirType.left;
c[CURVE_WALL_TYPE_KEY] = wall;
}
for (let c of wall.RightCurves)
for (let c of wall.RightCurves) {
curves.push(c);
for (let c of wall.LidCurves)
c[CURVE_DIR_TYPE_KEY] = WallCurveDirType.right;
c[CURVE_WALL_TYPE_KEY] = wall;
}
for (let c of wall.LidCurves) {
curves.push(c);
c[CURVE_DIR_TYPE_KEY] = WallCurveDirType.lid;
c[CURVE_WALL_TYPE_KEY] = wall;
}
}
const REGION_PARSE_NUM = 3;
const POLYLINE_JOIN_FUZZ = Math.pow(10, -REGION_PARSE_NUM);
let parse = new RegionParse(curves, REGION_PARSE_NUM);
for (let [orgArc, arcs] of parse.ExpLineMap) {
let regParse = new RegionParse(curves, REGION_PARSE_NUM);
for (let [orgArc, arcs] of regParse.ExpLineMap) {
if (leftCurves.has(orgArc))
for (let arc of arcs)
leftCurves.add(arc);
}
let regionPolylines = [];
let map = new Map();
let regPolyline2RoutesMap = new Map(); //区域轮廓多段线->墙线 映射
//分析内外墙1内2外
for (let routes of parse.RegionsOutline) {
for (let routes of regParse.RegionsOutline) {
let pl = exports.Polyline.Combine(routes.map(r => r.curve), POLYLINE_JOIN_FUZZ);
// for (let i = 0; i < routes.length; i++)
// {
@@ -36395,20 +36521,27 @@ class RoomRegionParse {
// }
// TestDraw(routes[0].curve); //test
regionPolylines.push(pl);
map.set(pl, routes);
regPolyline2RoutesMap.set(pl, routes);
}
//不可能有内部轮廓 如果有 就证明错了
for (let routes of parse.RegionsInternal) {
for (let routes of regParse.RegionsInternal) {
let pl = exports.Polyline.Combine(routes.map(r => r.curve));
pl.ColorIndex = pl.Area2 > 0 ? 3 : 4;
// throw "未知错误 出现外部轮廓"
}
//面域分析炸开的线和原始轮廓的关联关系
for (let [orgArc, newArcs] of regParse.ExpLineMap) {
for (let arc of newArcs) {
arc[CURVE_DIR_TYPE_KEY] = orgArc[CURVE_DIR_TYPE_KEY];
arc[CURVE_WALL_TYPE_KEY] = orgArc[CURVE_WALL_TYPE_KEY];
}
}
let cons = regionPolylines.map(pl => new ContourTreeNode(Contour.CreateContour(pl, false)));
ContourTreeNode.ParseContourTree(cons);
let roofs = [];
//解析 天花板区域 内空区域
for (let con of cons) {
let routes = map.get(con.contour.Curve);
let routes = regPolyline2RoutesMap.get(con.contour.Curve);
if (con.contour.Curve.ColorIndex === 2) //天花板区域(或者柱子)
{
if (con.Depth !== 0 || con.area < 1e6) //柱子
@@ -36476,6 +36609,7 @@ class RoomRegionParse {
this._UpdateDb.ModelSpace.Append(floor);
this._UpdateDb.ModelSpace.Append(top);
let region = new exports.RoomRegion(name, top.Id, floor.Id, floor.Area);
region[ROOM_REGION_CURVES_KEY] = routes.map(r => r.curve);
region.Position = pos;
this._UpdateDb.ModelSpace.Append(region);
floor.RegionId = region.Id;
@@ -36483,8 +36617,8 @@ class RoomRegionParse {
}
}
}
for (let [orgArc, arcs] of parse.ExpLineMap)
orgArc[CURVE_FACE_TYPE_KEY] = arcs[0][CURVE_FACE_TYPE_KEY];
for (let [orgArc, arcs] of regParse.ExpLineMap)
orgArc[CURVE_FACE_TYPE_KEY] = arcs[0][CURVE_FACE_TYPE_KEY]; //圆弧不可能被两个房间拥有,所以这个写法没问题
for (let wall of walls) {
// 因为我们现在没有分裂圆弧 所以我们不需要在合并线
// wall.LeftCurves && arrayRemoveDuplicateBySort(wall.LeftCurves, (cu1: Curve, cu2: Curve) => cu1.Join(cu2) === Status.True);
@@ -37242,12 +37376,14 @@ exports.AxisCS = AxisCS;
exports.BUL_IS_LINE_FUZZ = BUL_IS_LINE_FUZZ;
exports.CADFactory = CADFactory;
exports.CADFiler = CADFiler;
exports.CURVE_DIR_TYPE_KEY = CURVE_DIR_TYPE_KEY;
exports.CURVE_FACE_TYPE_KEY = CURVE_FACE_TYPE_KEY;
exports.CURVE_MESH_NAMES = CURVE_MESH_NAMES;
exports.CURVE_WALL_TYPE_KEY = CURVE_WALL_TYPE_KEY;
exports.CameraUpdate = CameraUpdate;
exports.ContourTreeNode = ContourTreeNode;
exports.ConverBoardTypeToSpaceType = ConverBoardTypeToSpaceType;
exports.CurveTapeShape = CurveTapeShape;
exports.DbText = DbText;
exports.DisposeTextShapeCache = DisposeTextShapeCache;
exports.ExtrudeBuildConfig = ExtrudeBuildConfig;
exports.ExtrudeGeometryBuilder = ExtrudeGeometryBuilder;