功能:更新文件序列化

This commit is contained in:
ChenX
2022-05-31 11:42:44 +08:00
parent 0431e9ab86
commit 21d68fcf3c
41 changed files with 152 additions and 46 deletions

View File

@@ -460,7 +460,7 @@ function AutoRecord(target, property, descriptor) {
});
}
const UE_REX_DEL = /_.*/g;
//const UE_REX_DEL = /_.*/g;
/**
* CAD对象工厂,通过注册 和暴露的创建方法,动态创建对象
*/
@@ -469,7 +469,8 @@ class CADFactory {
this.objectNameMap = new Map();
}
static RegisterObject(C) {
this.factory.objectNameMap.set(C.name.replace(UE_REX_DEL, ""), C);
//this.factory.objectNameMap.set(C.name.replace(UE_REX_DEL, ""), C);
this.factory.objectNameMap.set(C.name, C);
}
static RegisterObjectAlias(C, name) {
this.factory.objectNameMap.set(name, C);
@@ -1512,8 +1513,7 @@ let Entity = Entity_1 = class Entity extends CADObject {
if (this._Matrix.elements[14] === 0)
return this;
this.WriteAllObjectRecord();
this._Matrix.elements[14] = 0;
this.Update(UpdateDraw.Matrix);
this.Move({ x: 0, y: 0, z: -this.Z });
return this;
}
//坐标系二维化
@@ -17718,17 +17718,17 @@ class BoardGetFace {
}
}
//坐标系共面且法线相反
function MatrixIsCoplane2(matrixFrom, matrixTo, fuzz = 1e-5) {
function MatrixIsCoplane2(matrixFrom, matrixTo, zFuzz) {
let nor1 = new Vector3().setFromMatrixColumn(matrixFrom, 2);
let nor2 = new Vector3().setFromMatrixColumn(matrixTo, 2);
//法线共面
if (!equalv3(nor1, nor2.negate(), fuzz))
if (!equalv3(nor1, nor2.negate(), 1e-5))
return false;
//高共面
let pt = new Vector3().setFromMatrixPosition(matrixTo);
//变换到自身对象坐标系.
pt.applyMatrix4(new Matrix4().getInverse(matrixFrom));
return equaln$1(pt.z, 0, fuzz);
return equaln$1(pt.z, 0, zFuzz);
}
function GetSideFaceMtx(cu, inverseZ = false) {
let x = cu.GetFistDeriv(0).normalize();
@@ -20878,6 +20878,8 @@ function InsertSortedIndex(array, element, comparefunc) {
let compareresult = comparefunc(element, testelement);
if (compareresult > 0) // element > testelement
leftbound = testindex + 1;
else if (compareresult === 0) //因为函数 FindBestRange 会取index-1 来取范围
leftbound = testindex + 1;
else
rightbound = testindex;
}
@@ -27432,15 +27434,19 @@ let RoomWallBase = class RoomWallBase extends RoomBase {
this.RelevancyHoles.push(id);
}
}
if (ver > 2) {
this._Height = file.Read();
}
}
//对象将自身数据写入到文件.
WriteFile(file) {
file.Write(2);
file.Write(3);
super.WriteFile(file);
file.Write(this._Thickness);
file.Write(this.RelevancyHoles.length);
for (let id of this.RelevancyHoles)
file.WriteObjectId(id);
file.Write(this._Height);
}
};
RoomWallBase.SnapMode = WallSnapMode.All;
@@ -35422,7 +35428,8 @@ class RoomRegionParse {
floor.OCS = con.contour.Curve.OCSNoClone;
floor.UpdateContourHoles(con.contour.Curve, con.children.map(c => c.contour.Curve));
top.UpdateContourHoles(con.contour.Curve, con.children.map(c => c.contour.Curve));
top.Move({ x: 0, y: 0, z: 2700 }); //等轮廓设置完在移动 否则设置失败
floor.Z = minZ;
top.Z = maxZ; //等轮廓设置完在移动 否则设置失败
oldR.Position = pos;
oldR.Area = floor.Area;
});
@@ -35650,7 +35657,7 @@ class RoomWallParse {
return map;
};
//按Z轴区分
let zgroupMap = GroupWalls(walls, w => Math.round(w.OCSNoClone.elements[14] * 100));
let zgroupMap = GroupWalls(walls, w => Math.round(w.Z * 100));
for (let [, walls] of zgroupMap) {
this.PraseWallsFromSameFloor(walls, changeWalls);
regionPrase.Do(walls);