同步代码

This commit is contained in:
ChenX
2022-06-08 09:43:31 +08:00
parent 38e7ab4a80
commit 8c0aa22524
59 changed files with 302 additions and 206 deletions

View File

@@ -178,11 +178,15 @@ exports.RenderType = void 0;
/**物理带线框 */
RenderType[RenderType["Physical2Print"] = 106] = "Physical2Print";
})(exports.RenderType || (exports.RenderType = {}));
function IsPhysical(renderType) {
return renderType === exports.RenderType.Physical || renderType === exports.RenderType.Physical2 || renderType === exports.RenderType.PhysicalPrint || renderType === exports.RenderType.Physical2Print;
}
class IHostApplicationServices {
constructor() {
this.UseShadow = true;
this.isShowLightShadow = true; //灯光阴影 (除太阳光外)
this.ShowHistoryLog = true;
this.DrawWallBottomFace = false; //绘制底面
//#region _RenderType 渲染类型
this._renderType = exports.RenderType.Wireframe;
//#endregion
@@ -247,6 +251,9 @@ class IHostApplicationServices {
async LoadMetalEnv() { return; }
}
IHostApplicationServices.__ProxyKeys__ = []; //代理对象,当代理对象存在时,获取内部的值指向代理对象
__decorate([
ProxyValue
], IHostApplicationServices.prototype, "isShowLightShadow", void 0);
__decorate([
ProxyValue
], IHostApplicationServices.prototype, "_renderType", void 0);
@@ -4980,7 +4987,7 @@ class CurveIntersection {
* @param {Curve[]} cus 请注意数组的顺序会被更改,如果你在意数组的顺序,请拷贝数组后传进来
* @memberof CurveIntersection
*/
constructor(cus, parseIntersectionParam = false, intType = IntersectOption.OnBothOperands, fuzz = 1e-6, parseRecord = false) {
constructor(cus, parseIntersectionParam = false, intType = IntersectOption.ExtendNone, fuzz = 1e-6, parseRecord = false) {
this.fuzz = fuzz;
//用来缓存的曲线包围盒
this.boxMap = new Map();
@@ -5551,7 +5558,7 @@ function isTargetCurInOrOnSourceCur(sourceCur, targetCur) {
}
//获取交点处上下距0.01par的点
function getIntPtContextPts(sourceCur, cu, pts = []) {
let interPts = cu.IntersectWith(sourceCur, IntersectOption.OnBothOperands);
let interPts = cu.IntersectWith(sourceCur, IntersectOption.ExtendNone);
if (interPts.length > 0) {
let pars = interPts.map(pt => cu.GetParamAtPoint(pt));
for (let par of pars) {
@@ -5742,7 +5749,7 @@ class Contour {
//可能会有提升,但是好像不大(并且还有更慢的趋势)
// if (!sourceOutline.BoundingBox.intersectsBox(targetOutline.BoundingBox, 1e-3))
// return { intersectionList, unionList };
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, COMBINE_FUZZ);
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.ExtendNone, COMBINE_FUZZ);
let sourceContainerTarget;
let targetContainerSource;
if (sourceOutline.Area > targetOutline.Area) {
@@ -5814,7 +5821,7 @@ class Contour {
let sourceOutline = this._Curve;
let targetOutline = target.Curve;
let isEqualNormal = equalv3(sourceOutline.Normal, targetOutline.Normal, 1e-3);
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.OnBothOperands, COMBINE_FUZZ);
let interPts = sourceOutline.IntersectWith2(targetOutline, IntersectOption.ExtendNone, COMBINE_FUZZ);
if (interPts.length <= 1) {
//反包含
if (fastCurveInCurve2(targetOutline, sourceOutline) || equalCurve(targetOutline, sourceOutline))
@@ -5894,7 +5901,7 @@ class Contour {
const targetOutline = con.Curve;
if (!IntersectBox2(outBox, targetOutline.BoundingBox))
continue;
let pts = sourceOutline.IntersectWith2(con.Curve, IntersectOption.OnBothOperands, COMBINE_FUZZ);
let pts = sourceOutline.IntersectWith2(con.Curve, IntersectOption.ExtendNone, COMBINE_FUZZ);
if (pts.length <= 1) {
//反包含
if (fastCurveInCurve2(targetOutline, sourceOutline) || equalCurve(targetOutline, sourceOutline))
@@ -6043,7 +6050,7 @@ class CurveTreeNode {
}
}
//交点参数列表
let iParams = this.curve.IntersectWith(contour.Curve, IntersectOption.OnBothOperands)
let iParams = this.curve.IntersectWith(contour.Curve, IntersectOption.ExtendNone)
.map(p => this.curve.GetParamAtPoint2(p));
let cus = this.curve.GetSplitCurves(iParams);
if (cus.length === 0) {
@@ -6301,7 +6308,7 @@ class OffsetPolyline {
let [p1, p2, p3, p4] = [cu1.StartPoint, cu2.StartPoint, cu1.EndPoint, cu2.EndPoint];
let l1 = new exports.Line(p1, p2);
let l2 = new exports.Line(p3, p4);
let ipts = l1.IntersectWith(l2, IntersectOption.OnBothOperands, 1e-8);
let ipts = l1.IntersectWith(l2, IntersectOption.ExtendNone, 1e-8);
if (ipts.length > 0) {
let p = ipts[0];
l1.EndPoint = p;
@@ -6321,8 +6328,8 @@ class OffsetPolyline {
let l2Intact = true;
if (cu2 instanceof exports.Arc) {
if (Math.sign(cu2.Bul) !== this._OffsetDistSign) {
let ipts1 = cu2.IntersectWith(l1, IntersectOption.OnBothOperands);
let ipts2 = cu2.IntersectWith(l2, IntersectOption.OnBothOperands);
let ipts1 = cu2.IntersectWith(l1, IntersectOption.ExtendNone);
let ipts2 = cu2.IntersectWith(l2, IntersectOption.ExtendNone);
let sp;
let ep;
if (ipts1.length === 2)
@@ -6349,7 +6356,7 @@ class OffsetPolyline {
if (l1Intact && d.preCurve && d.preCurve instanceof exports.Arc) {
let a = d.preCurve;
if (Math.sign(a.Bul) !== this._OffsetDistSign && a.AllAngle > 1e-6) {
let ipts = a.IntersectWith(l1, IntersectOption.OnBothOperands);
let ipts = a.IntersectWith(l1, IntersectOption.ExtendNone);
if (ipts.length === 2) {
let sp = SelectNearP(ipts, p1);
l1.EndPoint = sp;
@@ -6361,7 +6368,7 @@ class OffsetPolyline {
if (l2Intact && d.nextCurve && d.nextCurve instanceof exports.Arc) {
let a = d.nextCurve;
if (Math.sign(a.Bul) !== this._OffsetDistSign && a.AllAngle > 1e-6) {
let ipts = a.IntersectWith(l2, IntersectOption.OnBothOperands);
let ipts = a.IntersectWith(l2, IntersectOption.ExtendNone);
if (ipts.length === 2) {
let ep = SelectNearP(ipts, p3);
l2.EndPoint = ep;
@@ -7695,7 +7702,7 @@ exports.Polyline = Polyline_1 = class Polyline extends exports.Curve {
let d1 = this._LineData[i];
let d2 = this._LineData[FixIndex$1(i + 1, this._LineData)];
let curve;
if (equaln$1(d1.bul, 0, 1e-8))
if (equaln$1(d1.bul, 0, 1e-5))
curve = new exports.Line(AsVector3(d1.pt), AsVector3(d2.pt)).ApplyMatrix(this.OCSNoClone);
else
curve = new exports.Arc().ParseFromBul(d1.pt, d2.pt, d1.bul).ApplyMatrix(this.OCSNoClone);
@@ -7715,7 +7722,7 @@ exports.Polyline = Polyline_1 = class Polyline extends exports.Curve {
let c = cus[i];
for (let j = i + 2; j < cus.length; j++) {
let c2 = cus[j];
let pts = c.IntersectWith(c2, IntersectOption.OnBothOperands);
let pts = c.IntersectWith(c2, IntersectOption.ExtendNone);
for (let p of pts) {
intParams.push(i + c.GetParamAtPoint(p));
intParams.push(j + c2.GetParamAtPoint(p));
@@ -8095,7 +8102,7 @@ var IntersectOption;
/**
* 两者都不延伸
*/
IntersectOption[IntersectOption["OnBothOperands"] = 0] = "OnBothOperands";
IntersectOption[IntersectOption["ExtendNone"] = 0] = "ExtendNone";
/**
* 延伸自身
*/
@@ -8539,7 +8546,7 @@ function IntersectEllipseAndCircleOrArc(el, cir, type) {
if (type === IntersectOption.ExtendBoth)
type = IntersectOption.ExtendArg;
else if (type !== IntersectOption.ExtendArg)
type = IntersectOption.OnBothOperands;
type = IntersectOption.ExtendNone;
let intPts = IntersectPolylineAndCurve(pl, cirClone, type);
intPts.forEach(r => r.pt.applyMatrix4(el.OCS));
return intPts;
@@ -14965,7 +14972,7 @@ function GetIntersection(cu1, cu2) {
else
m = new Map();
intCache.set(cu1, m);
let r = cu1.IntersectWith2(cu2, IntersectOption.OnBothOperands);
let r = cu1.IntersectWith2(cu2, IntersectOption.ExtendNone);
let cu1EndParam = cu1.EndParam;
let cu2EndParam = cu2.EndParam;
for (let d of r) {
@@ -20973,20 +20980,20 @@ class CurveTrim {
this._curve = _curve;
this._TrimParams = [];
this._IsErase = false;
this._Box = _curve.BoundingBox;
this._Box = _curve.BoundingBox.expandByVector(new three.Vector3(0.01, 0.01));
}
TrimBy(contour, box) {
TrimBy(contour, box, saveSyntropy = false) {
if (this._IsErase)
return;
//交点参数列表
let iParams = this._curve.IntersectWith2(contour.Curve, IntersectOption.OnBothOperands).map(p => p.thisParam).filter(p => p > 1e-4 && p < 0.9999);
let iParams = this._curve.IntersectWith2(contour.Curve, IntersectOption.ExtendNone).map(p => p.thisParam).filter(p => p > 1e-6 && p < 0.999999);
iParams.push(0, 1);
iParams.sort((a, b) => a - b);
arrayRemoveDuplicateBySort(iParams, (a1, a2) => equaln(a1, a2, 1e-4));
arrayRemoveDuplicateBySort(iParams, (a1, a2) => equaln(a1, a2, 1e-6));
if (iParams.length === 2) //[0,1]全包含 或者在外部
{
let p = this._curve.GetPointAtParam(0.5);
if (this.PointInContour(p, contour, box))
let p = this.GetPointAtParam(0.5);
if (this.PointInContour(p, contour, box, saveSyntropy))
this._IsErase = true;
return;
}
@@ -20996,8 +21003,8 @@ class CurveTrim {
if (insertIndex !== 0 && this._TrimParams[insertIndex - 1][1] > eparam) //包含在已经被切割的范围内,那么直接不用重复判断 (只可能被前一段包含)
continue;
let midParam = (sparam + eparam) * 0.5;
let p = this._curve.GetPointAtParam(midParam); //这个性能不高 可以优化
if (this.PointInContour(p, contour, box)) {
let p = this.GetPointAtParam(midParam);
if (this.PointInContour(p, contour, box, saveSyntropy)) {
InsertRangeAndUnion(this._TrimParams, sparam, eparam, insertIndex);
if (this._TrimParams.length === 1 && this._TrimParams[0][0] === 0 && this._TrimParams[0][1] === 1) {
this._IsErase = true;
@@ -21006,7 +21013,7 @@ class CurveTrim {
}
}
}
PointInContour(p, contour, contourBox) {
PointInContour(p, contour, contourBox, saveSyntropy = false) {
return contourBox.containsPoint(p) && (contour.Curve.PtInCurve(p) && !contour.Curve.PtOnCurve(p));
}
TrimParam(sparam, eparam) {
@@ -21035,7 +21042,7 @@ class CurveTrimLine extends CurveTrim {
GetPointAtParam(param) {
return this._Fd.clone().multiplyScalar(param).add(this._Sp);
}
PointInContour(p, contour, contourBox) {
PointInContour(p, contour, contourBox, saveSyntropy = false) {
if (!contourBox.containsPoint(p))
return false;
let pl = contour.Curve;
@@ -21046,12 +21053,14 @@ class CurveTrimLine extends CurveTrim {
if (cu.ParamOnCurve(d.param) && equalv3(d.closestPt, p, 1e-5)) //点在线上
{
let derv = cu.GetFistDeriv(d.param).normalize();
return equalv3(derv, this.derv);
return equalv3(derv, this.derv, 1e-4) || (saveSyntropy && equalv3(derv.negate(), this.derv, 1e-4)); //因为墙体为顺时针 轮廓为逆时针 所以这里相等=反向
}
}
else {
if (cu.PtOnCurve(p))
return equalv3(this.derv, cu.GetFistDeriv(cu.GetParamAtPoint2(p)).normalize());
if (cu.PtOnCurve(p, 1e-5)) {
let derv = cu.GetFistDeriv(cu.GetParamAtPoint2(p)).normalize();
return equalv3(this.derv, derv, 1e-4) || (saveSyntropy && equalv3(derv.negate(), this.derv, 1e-4));
}
}
}
return contour.Curve.PtInCurve(p);
@@ -21080,27 +21089,27 @@ class CurveTrimArc extends CurveTrim {
this._curve = _curve;
this._IsLeft = _IsLeft;
}
PointInContour(p, contour, contourBox) {
PointInContour(p, contour, contourBox, saveSyntropy = false) {
if (!contourBox.containsPoint(p))
return false;
let pl = contour.Curve;
let thisDerv = this._curve.GetFistDeriv(p).normalize();
if (this._IsLeft)
thisDerv.negate();
for (let i = 0; i < pl.EndParam; i++) {
let cu = pl.GetCurveAtIndex(i);
if (cu instanceof exports.Line) {
let d = cu.GetClosestAtPoint(p, true);
if (cu.ParamOnCurve(d.param) && equalv3(d.closestPt, p, 1e-5)) //点在线上
if (cu.ParamOnCurve(d.param) && equalv3(d.closestPt, p, 1e-5)) //点在线上 //这个代码似乎是错误的,因为直线和圆弧不可能重合
{
let derv = cu.GetFistDeriv(d.param).normalize();
return equalv3(derv, thisDerv);
return equalv3(derv, thisDerv, 1e-4) || (saveSyntropy && equalv3(derv.negate(), thisDerv, 1e-4)); //因为墙体为顺时针 轮廓为逆时针 所以这里相等=反向
}
}
else {
if (cu.PtOnCurve(p)) {
let derv = this._curve.GetFistDeriv(this._curve.GetParamAtPoint2(p)).normalize();
if (this._IsLeft)
derv.negate();
return equalv3(derv, cu.GetFistDeriv(cu.GetParamAtPoint2(p)).normalize());
if (cu.PtOnCurve(p, 1e-5)) {
let cuDerv = cu.GetFistDeriv(cu.GetParamAtPoint2(p)).normalize();
return equalv3(thisDerv, cuDerv, 1e-4) || (saveSyntropy && equalv3(cuDerv.negate(), thisDerv, 1e-4));
}
}
}
@@ -21414,8 +21423,9 @@ exports.RoomHolePolyline = class RoomHolePolyline extends exports.RoomHoleBase {
let endX = lid.Length * 1e-3;
let startZ = 0;
let endZ = this._Height * 1e-3;
let parse = CreateGetCurveParam(lid);
geo.faces.push(new three.Face3(startIndex, startIndex + 2, startIndex + 1, parse.LeftDir), new three.Face3(startIndex + 1, startIndex + 2, startIndex + 3, parse.LeftDir));
let normal = p2.clone().sub(p1).normalize();
LEFT_ROTATE_MTX2.applyVector(normal);
geo.faces.push(new three.Face3(startIndex, startIndex + 2, startIndex + 1, normal), new three.Face3(startIndex + 1, startIndex + 2, startIndex + 3, normal));
geo.faceVertexUvs[0].push([new three.Vector2(startX, startZ), new three.Vector2(startX, endZ), new three.Vector2(endX, startZ)], [new three.Vector2(endX, startZ), new three.Vector2(startX, endZ), new three.Vector2(endX, endZ)]);
}
if (this.Regions)
@@ -22764,7 +22774,6 @@ exports.Light = Light_1 = class Light extends exports.Entity {
en.intensity = this.WebIntensity;
en.color = this._LightColor;
en.visible = this._OpenLight;
en.castShadow = this.CaseShadow;
}
get Intensity() {
return this._Intensity;
@@ -22929,7 +22938,9 @@ exports.DirectionalLight = class DirectionalLight extends exports.Light {
InitDrawObject(renderType = exports.RenderType.Wireframe) {
let lightGroup = new three.Group();
let light = new three.DirectionalLight(this._LightColor, this.WebIntensity);
light.castShadow = HostApplicationServices.UseShadow;
Object.defineProperty(light, "castShadow", {
get: () => this.CaseShadow //HostApplicationServices.isShowLightShadow //太阳光无视这个配置!
});
light.shadow.camera.matrixAutoUpdate = true;
light.shadow.camera.near = 1;
light.shadow.camera.far = 100000;
@@ -24357,7 +24368,7 @@ class CameraUpdate {
}
this.Update();
}
ZoomExtensBox3(box3) {
ZoomExtentsBox3(box3) {
if (!box3 || box3.isEmpty())
return;
this.Camera.updateMatrixWorld(false);
@@ -24618,7 +24629,7 @@ exports.ViewportEntity = ViewportEntity_1 = class ViewportEntity extends exports
}
if (box.isEmpty())
box.set(new three.Vector3(), new three.Vector3(1000 * (this.Width / this.Height), 1000, 1000));
this.camera.ZoomExtensBox3(box);
this.camera.ZoomExtentsBox3(box);
this.camera.Zoom(1.2);
}
ZoomtoEntitys(ens) {
@@ -24626,7 +24637,7 @@ exports.ViewportEntity = ViewportEntity_1 = class ViewportEntity extends exports
ens.reduce((b, e) => b.union(e.BoundingBox), box);
if (box.isEmpty())
return;
this.camera.ZoomExtensBox3(box);
this.camera.ZoomExtentsBox3(box);
this.camera.Zoom(1.2);
}
get RenderType() {
@@ -26934,7 +26945,7 @@ exports.PointLight = class PointLight extends exports.Light {
InitDrawObject(renderType = exports.RenderType.Wireframe) {
let lightGroup = new three.Group();
let ptLight = new three.PointLight(this._LightColor, this.WebIntensity, this._Distance, this._Decay);
ptLight.castShadow = HostApplicationServices.UseShadow;
Object.defineProperty(ptLight, "castShadow", { get: () => HostApplicationServices.isShowLightShadow && this.CaseShadow });
ptLight.shadow.camera.matrixAutoUpdate = true;
ptLight.shadow.camera.far = 10000;
//绘制灯光助手
@@ -27563,7 +27574,7 @@ exports.SpotLight = class SpotLight extends exports.Light {
light.target.position.set(0, 0, -1);
light.target.updateMatrix();
light.add(light.target);
light.castShadow = HostApplicationServices.UseShadow;
Object.defineProperty(light, "castShadow", { get: () => HostApplicationServices.isShowLightShadow && this.CaseShadow });
light.shadow.camera.matrixAutoUpdate = true;
light.shadow.camera.far = this._Distance;
group.add(light); //灯光
@@ -28537,15 +28548,18 @@ exports.RoomWallArc = class RoomWallArc extends exports.RoomWallBase {
let startIndex = geo.vertices.length;
for (let p of pts)
geo.vertices.push(new three.Vector3(p.x, p.y, this._Height));
for (let p of pts)
geo.vertices.push(new three.Vector3(p.x, p.y, 0));
if (HostApplicationServices.DrawWallBottomFace)
for (let p of pts)
geo.vertices.push(new three.Vector3(p.x, p.y, 0));
for (let i = 0; i < faces.length; i++) {
let [a, b, c] = faces[i];
geo.faces.push(new three.Face3(startIndex + a, startIndex + b, startIndex + c, normal));
let uvs = faces[i].map(index => pts[index].clone());
geo.faceVertexUvs[0].push(uvs);
geo.faces.push(new three.Face3(startIndex + pts.length + c, startIndex + pts.length + b, startIndex + pts.length + a, normaln));
geo.faceVertexUvs[0].push(uvs.concat().reverse().map(v => v.clone()));
if (HostApplicationServices.DrawWallBottomFace) {
geo.faces.push(new three.Face3(startIndex + pts.length + c, startIndex + pts.length + b, startIndex + pts.length + a, normaln));
geo.faceVertexUvs[0].push(uvs.concat().reverse().map(v => v.clone()));
}
}
// //todo:为了优化显示 我们可以把侧面也画出来 (应该使用和酷家乐一样的技术 在视线对准时,隐藏整个墙)
// let d = this._EndPoint.clone().sub(this._StartPoint).normalize();
@@ -29122,7 +29136,7 @@ class FilletUtils {
// offCu2.ColorIndex = 6;
// JigUtils.Draw(offCu1.Clone());
// JigUtils.Draw(offCu2.Clone());
let center = offCu1.IntersectWith(offCu2, IntersectOption.OnBothOperands)
let center = offCu1.IntersectWith(offCu2, IntersectOption.ExtendNone)
.sort((p1, p2) => {
return p1.distanceToSquared(iPt) - p2.distanceToSquared(iPt);
})[0];
@@ -33764,7 +33778,7 @@ class DrawObliqueWineRackTool extends DrawWineRackTool {
let d = lData[i];
let dists = [];
for (let d2 of rData) {
let intPts = d.pl.IntersectWith(d2.pl, IntersectOption.OnBothOperands);
let intPts = d.pl.IntersectWith(d2.pl, IntersectOption.ExtendNone);
if (intPts.length === 4) {
dists.push(...intPts.map(p => {
let p1 = p.applyMatrix4(d.matInv);
@@ -34567,19 +34581,21 @@ exports.RoomWallLine = class RoomWallLine extends exports.RoomWallBase {
let pts = this.Region.MatrixAlignTo2(this.OCSNoClone).pts;
this.Region.OCSNoClone.elements[14] = bakZ;
let faces = three.ShapeUtils.triangulateShape(pts, []);
//top
let startIndex = geo.vertices.length;
for (let p of pts)
geo.vertices.push(new three.Vector3(p.x, p.y, this._Height));
for (let p of pts)
geo.vertices.push(new three.Vector3(p.x, p.y, 0));
if (HostApplicationServices.DrawWallBottomFace)
for (let p of pts)
geo.vertices.push(new three.Vector3(p.x, p.y, 0));
for (let i = 0; i < faces.length; i++) {
let [a, b, c] = faces[i];
geo.faces.push(new three.Face3(startIndex + a, startIndex + b, startIndex + c, normal));
let uvs = faces[i].map(index => pts[index].clone());
geo.faceVertexUvs[0].push(uvs);
geo.faces.push(new three.Face3(startIndex + pts.length + c, startIndex + pts.length + b, startIndex + pts.length + a, normaln));
geo.faceVertexUvs[0].push(uvs.concat().reverse().map(v => v.clone()));
if (HostApplicationServices.DrawWallBottomFace) {
geo.faces.push(new three.Face3(startIndex + pts.length + c, startIndex + pts.length + b, startIndex + pts.length + a, normaln));
geo.faceVertexUvs[0].push(uvs.concat().reverse().map(v => v.clone()));
}
}
// //todo:为了优化显示 我们可以把侧面也画出来 (应该使用和酷家乐一样的技术 在视线对准时,隐藏整个墙)
// let d = this._EndPoint.clone().sub(this._StartPoint).normalize();
@@ -35620,7 +35636,9 @@ class RoomRegionParse {
for (let c of wall.LidCurves)
curves.push(c);
}
let parse = new RegionParse(curves);
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) {
if (leftCurves.has(orgArc))
for (let arc of arcs)
@@ -35630,7 +35648,7 @@ class RoomRegionParse {
let map = new Map();
//分析内外墙1内2外
for (let routes of parse.RegionsOutline) {
let pl = exports.Polyline.Combine(routes.map(r => r.curve), 1e-3);
let pl = exports.Polyline.Combine(routes.map(r => r.curve), POLYLINE_JOIN_FUZZ);
// for (let i = 0; i < routes.length; i++)
// {
if (leftCurves.has(routes[0].curve))
@@ -35653,6 +35671,7 @@ class RoomRegionParse {
}
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);
@@ -35664,7 +35683,9 @@ class RoomRegionParse {
else
for (let r of routes)
r.curve[CURVE_FACE_TYPE_KEY] = exports.WallFaceType.Outside;
//未来我们需要返回这个轮廓,以便在ue中可以绘制真正的屋顶
//我们需要返回这个轮廓,以便在ue中可以绘制真正的屋顶
con.contour.Curve.Z = maxZ;
roofs.push(con.contour.Curve);
}
else if (con.contour.Curve.ColorIndex === 1) //内空区域
{
@@ -35735,6 +35756,7 @@ class RoomRegionParse {
// wall.RightCurves && arrayRemoveDuplicateBySort(wall.RightCurves, (cu1: Curve, cu2: Curve) => cu1.Join(cu2) === Status.True);
wall.Update();
}
return roofs;
}
End() {
if (this._UpdateDb) {
@@ -35923,6 +35945,7 @@ class RoomWallParse {
RoomWallParse._CacheWallNodePoints = [];
RoomWallParse._CacheWallMaps = [];
RoomWallParse._CacheCurveWallMaps = new Map();
RoomWallParse._CacheRoofs = [];
}
let regionPrase = new RoomRegionParse(this._UpdateDb);
const GroupWalls = (walls, fn) => {
@@ -35942,7 +35965,9 @@ class RoomWallParse {
let zgroupMap = GroupWalls(walls, w => Math.round(w.Z * 100));
for (let [, walls] of zgroupMap) {
this.PraseWallsFromSameFloor(walls, changeWalls);
regionPrase.Do(walls);
let roofs = regionPrase.Do(walls);
if (this._IsCacheWallNodePoints)
arrayPushArray(RoomWallParse._CacheRoofs, roofs);
}
regionPrase.End();
}
@@ -36119,7 +36144,7 @@ class RoomWallParse {
else
tempC.StartPoint = p;
line = new exports.Line(v.position.clone(), p);
let ipts = line.IntersectWith(tempC, IntersectOption.OnBothOperands);
let ipts = line.IntersectWith(tempC, IntersectOption.ExtendNone);
if (ipts.length === 2)
p = undefined;
}
@@ -36131,7 +36156,7 @@ class RoomWallParse {
tempC.StartPoint = p;
if (!line)
line = new exports.Line(v.position.clone(), p);
let ipts = line.IntersectWith(tempC, IntersectOption.OnBothOperands);
let ipts = line.IntersectWith(tempC, IntersectOption.ExtendNone);
if (ipts.length === 2)
p = undefined;
}
@@ -36151,8 +36176,9 @@ class RoomWallParse {
nowCurve[SAVE_SP_KEY] = tp;
}
else {
//如果两线平行 无交点时,应该只补厚墙的盖子
if (iPts.length === 0) {
//如果两线(直线)平行 无交点时,应该只补厚墙的盖子
if (code === 1 && iPts.length === 0) //&& false 尽管是false 这里的代码还是成立的 没有禁用这个代码是因为能带来一丢丢性能提升
{
let w1 = curveWallMap.get(breakData._SplitCurve2OrgCurveMap.get(preR.curve));
let w2 = curveWallMap.get(breakData._SplitCurve2OrgCurveMap.get(nowR.curve));
let sp = preR.isReverse ? preCurve.EndPoint : preCurve.StartPoint;
@@ -36314,6 +36340,7 @@ class RoomWallParse {
pts.push(p4, p3);
let pl = new exports.Polyline(pts.map(p => { return { pt: AsVector2(p), bul: 0 }; }));
pl.CloseMark = true;
pl.Z = p1.z;
let contour = Contour.CreateContour(pl, false);
// let reg = Region.CreateFromCurves([contour.Curve]);
// if (reg)
@@ -36379,10 +36406,7 @@ class RoomWallParse {
else if (type === CurveType.EndLid)
dir = getParam.RightDir;
if (!dir) {
dir = offsetCurve.GetFistDeriv(0).normalize();
LEFT_ROTATE_MTX2.applyVector(dir);
if (type !== CurveType.Left)
dir.negate();
dir = offsetCurve.GetFistDeriv(0).normalize().negate();
}
trim = new CurveTrimLine(offsetCurve, dir);
}
@@ -36391,7 +36415,7 @@ class RoomWallParse {
//需要更快的判断直线会不会被轮廓切割?
this.fb.search(trim._Box.min.x - 1e-2, trim._Box.min.y - 1e-2, trim._Box.max.x + 1e-2, trim._Box.max.y + 1e-2, (id => {
// if (id !== index) //裁剪的好处是有些细的盖子将会消失
trim.TrimBy(trimContours[id], this.boxs[id]);
trim.TrimBy(trimContours[id], this.boxs[id], index > id);
return false;
}));
let curves = trim.Curves;
@@ -36441,8 +36465,10 @@ class RoomWallParse {
return;
let fb = new Flatbush__default["default"](trimContours.length);
this.boxs = [];
let v = new three.Vector3(1e-2, 1e-2);
for (let con of trimContours) {
let box = con.BoundingBox;
box.expandByVector(v);
fb.add(box.min.x, box.min.y, box.max.x, box.max.y);
this.boxs.push(box);
}
@@ -36453,6 +36479,7 @@ class RoomWallParse {
RoomWallParse._CacheWallNodePoints = [];
RoomWallParse._CacheWallMaps = [];
RoomWallParse._CacheCurveWallMaps = new Map();
RoomWallParse._CacheRoofs = [];
function UpdateStartEndPoint(curve) {
let sp = curve[SAVE_SP_KEY];
let ep = curve[SAVE_EP_KEY];
@@ -36487,6 +36514,7 @@ exports.FastMeshGeometry = FastMeshGeometry;
exports.GetBoxGeoBufferGeometry = GetBoxGeoBufferGeometry;
exports.Groove = Groove;
exports.InitClipperCpp = InitClipperCpp;
exports.IsPhysical = IsPhysical;
exports.MaxDrawGrooveCount = MaxDrawGrooveCount;
exports.RoomWallParse = RoomWallParse;
exports.Shape2 = Shape2;