build-dxf 0.1.78 → 0.1.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/build.js +187 -124
- package/src/utils/DxfSystem/components/CorrectionDxf.d.ts +1 -1
- package/src/utils/DxfSystem/components/Dxf.d.ts +1 -1
- package/src/utils/DxfSystem/type.d.ts +2 -0
- package/src/utils/DxfSystem/utils/lineHandle/CadPreProcessor/index.d.ts +3 -3
- package/src/utils/DxfSystem/utils/lineHandle/CadPreProcessor/{stepElimination.d.ts → linesSmoothing.d.ts} +1 -1
- package/src/utils/DxfSystem/utils/lineHandle/buildGroup/buildBayWindowGroup.d.ts +7 -0
- package/src/utils/DxfSystem/utils/lineHandle/{buildGroup.d.ts → buildGroup/buildDoubleWallGroup.d.ts} +2 -7
- package/src/utils/DxfSystem/utils/lineHandle/buildGroup/index.d.ts +2 -0
- package/src/utils/DxfSystem/utils/tools/WallInsertObject.d.ts +15 -10
- package/src/utils/algorithmsStructures/stepElimination.d.ts +1 -1
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -3073,10 +3073,8 @@ class Box2 {
|
|
|
3073
3073
|
class WallInsertObject {
|
|
3074
3074
|
static mountedObjectType = [];
|
|
3075
3075
|
lines;
|
|
3076
|
-
mountedObjectLines;
|
|
3077
3076
|
constructor(lines) {
|
|
3078
3077
|
this.lines = lines;
|
|
3079
|
-
this.mountedObjectLines = lines.filter((line) => this.isInsertObject(line));
|
|
3080
3078
|
}
|
|
3081
3079
|
/** 是否是墙体嵌入物
|
|
3082
3080
|
* @param line
|
|
@@ -3093,11 +3091,26 @@ class WallInsertObject {
|
|
|
3093
3091
|
* @returns
|
|
3094
3092
|
*/
|
|
3095
3093
|
static isDoor(line) {
|
|
3096
|
-
if (line.userData.isPassageEntrance) {
|
|
3094
|
+
if (line.userData.isPassageEntrance && line.userData.passageEntrance?.length) {
|
|
3097
3095
|
return line.userData.passageEntrance?.some((insertObject) => insertObject.type === "door");
|
|
3098
3096
|
}
|
|
3099
3097
|
return false;
|
|
3100
3098
|
}
|
|
3099
|
+
static isDoubleDoor(line) {
|
|
3100
|
+
if (line.userData.isPassageEntrance && line.userData.passageEntrance?.length) {
|
|
3101
|
+
const isDoubleDoor = line.userData.passageEntrance.some((item) => item.type === "door" && typeof this.getId(item) === "number");
|
|
3102
|
+
return isDoubleDoor;
|
|
3103
|
+
}
|
|
3104
|
+
return false;
|
|
3105
|
+
}
|
|
3106
|
+
static getId(item) {
|
|
3107
|
+
return item.id ?? item.doorId;
|
|
3108
|
+
}
|
|
3109
|
+
static getNearId(item) {
|
|
3110
|
+
let nearId = item.nearId ?? item.nearDoorId;
|
|
3111
|
+
if (nearId === -1) nearId = void 0;
|
|
3112
|
+
return nearId;
|
|
3113
|
+
}
|
|
3101
3114
|
/** 遍历孔洞
|
|
3102
3115
|
* @param line
|
|
3103
3116
|
* @returns
|
|
@@ -3117,16 +3130,27 @@ class WallInsertObject {
|
|
|
3117
3130
|
* @param line
|
|
3118
3131
|
* @returns
|
|
3119
3132
|
*/
|
|
3120
|
-
getMinWidth(key) {
|
|
3133
|
+
static getMinWidth(key, type) {
|
|
3121
3134
|
if (key === "drawWindow") return 0.3;
|
|
3122
|
-
if (key === "passageEntrance")
|
|
3135
|
+
if (key === "passageEntrance") {
|
|
3136
|
+
if (type === "door") return 0.3;
|
|
3137
|
+
}
|
|
3123
3138
|
return 0;
|
|
3124
3139
|
}
|
|
3140
|
+
getMinWidth(key, type) {
|
|
3141
|
+
return WallInsertObject.getMinWidth(key, type);
|
|
3142
|
+
}
|
|
3143
|
+
static clear(target, key) {
|
|
3144
|
+
const eabledKey = key === "drawWindow" ? "isWindow" : "isPassageEntrance";
|
|
3145
|
+
const key_ = key === "drawWindow" ? "drawWindow" : "passageEntrance";
|
|
3146
|
+
target.userData[eabledKey] = false;
|
|
3147
|
+
delete target.userData[key_];
|
|
3148
|
+
}
|
|
3125
3149
|
/**
|
|
3126
3150
|
* 重新计算
|
|
3127
3151
|
*/
|
|
3128
|
-
recomputed() {
|
|
3129
|
-
|
|
3152
|
+
static recomputed(lines) {
|
|
3153
|
+
lines.forEach((line) => {
|
|
3130
3154
|
this.forEachInsertObjectData(line, (data, key) => {
|
|
3131
3155
|
data.forEach((w) => {
|
|
3132
3156
|
try {
|
|
@@ -3142,17 +3166,21 @@ class WallInsertObject {
|
|
|
3142
3166
|
} catch (error) {
|
|
3143
3167
|
}
|
|
3144
3168
|
});
|
|
3145
|
-
|
|
3146
|
-
line.userData[key]
|
|
3169
|
+
line.userData[key] = data.filter((w) => w.width > WallInsertObject.getMinWidth(key, w.type));
|
|
3170
|
+
if (line.userData[key].length === 0) WallInsertObject.clear(line, key);
|
|
3147
3171
|
});
|
|
3148
3172
|
});
|
|
3149
3173
|
return this;
|
|
3150
3174
|
}
|
|
3175
|
+
recomputed(lines = this.lines) {
|
|
3176
|
+
WallInsertObject.recomputed(lines);
|
|
3177
|
+
return this;
|
|
3178
|
+
}
|
|
3151
3179
|
/**
|
|
3152
3180
|
* 重新计算位置
|
|
3153
3181
|
*/
|
|
3154
|
-
recomputedCenter() {
|
|
3155
|
-
|
|
3182
|
+
static recomputedCenter(lines) {
|
|
3183
|
+
lines.forEach((line) => {
|
|
3156
3184
|
this.forEachInsertObjectData(line, (data, key) => {
|
|
3157
3185
|
data.forEach((w) => {
|
|
3158
3186
|
try {
|
|
@@ -3171,11 +3199,15 @@ class WallInsertObject {
|
|
|
3171
3199
|
});
|
|
3172
3200
|
return this;
|
|
3173
3201
|
}
|
|
3202
|
+
recomputedCenter(lines = this.lines) {
|
|
3203
|
+
WallInsertObject.recomputedCenter(lines);
|
|
3204
|
+
return this;
|
|
3205
|
+
}
|
|
3174
3206
|
/**
|
|
3175
3207
|
* 对重合的进行合并
|
|
3176
3208
|
*/
|
|
3177
|
-
merge() {
|
|
3178
|
-
|
|
3209
|
+
static merge(lines) {
|
|
3210
|
+
lines.forEach((line) => {
|
|
3179
3211
|
this.forEachInsertObjectData(line, (data, key) => {
|
|
3180
3212
|
const direction = line.direction();
|
|
3181
3213
|
const embeddedLines = data.map((w) => {
|
|
@@ -3229,6 +3261,10 @@ class WallInsertObject {
|
|
|
3229
3261
|
});
|
|
3230
3262
|
return this;
|
|
3231
3263
|
}
|
|
3264
|
+
merge(lines = this.lines) {
|
|
3265
|
+
WallInsertObject.merge(lines);
|
|
3266
|
+
return this;
|
|
3267
|
+
}
|
|
3232
3268
|
/** 添加孔洞
|
|
3233
3269
|
* @param target
|
|
3234
3270
|
* @param insertObject
|
|
@@ -3258,16 +3294,8 @@ class WallInsertObject {
|
|
|
3258
3294
|
copyInsertObject(target, source) {
|
|
3259
3295
|
WallInsertObject.copyInsertObject(target, source);
|
|
3260
3296
|
}
|
|
3261
|
-
static recomputed(lines) {
|
|
3262
|
-
new WallInsertObject(lines).recomputed();
|
|
3263
|
-
}
|
|
3264
|
-
static recomputedCenter(lines) {
|
|
3265
|
-
new WallInsertObject(lines).recomputedCenter();
|
|
3266
|
-
}
|
|
3267
|
-
static merge(lines) {
|
|
3268
|
-
new WallInsertObject(lines).merge();
|
|
3269
|
-
}
|
|
3270
3297
|
}
|
|
3298
|
+
const WIO = WallInsertObject;
|
|
3271
3299
|
function clippingLineUserData(newLine, line2) {
|
|
3272
3300
|
const { drawWindow, passageEntrance, ...opt } = line2.userData;
|
|
3273
3301
|
WallInsertObject.forEachInsertObjectData(line2, (data, key) => {
|
|
@@ -6545,22 +6573,56 @@ class MaxiCircles extends MiniCircles {
|
|
|
6545
6573
|
};
|
|
6546
6574
|
}
|
|
6547
6575
|
}
|
|
6576
|
+
const maxiCircles$1 = new MaxiCircles();
|
|
6577
|
+
function buildBayWindowGroup(lines, clear = true) {
|
|
6578
|
+
const bayWindowLines = lines.filter((line) => line.userData.isBayWindow), groupedLineSet = /* @__PURE__ */ new Set();
|
|
6579
|
+
const removeSet = findDiscretePointLine2(lines, null, true);
|
|
6580
|
+
const lines_ = lines.filter((line) => !removeSet.has(line));
|
|
6581
|
+
lines.forEach((line) => {
|
|
6582
|
+
if (LineGroupType.hasType(line, "bayWindow")) {
|
|
6583
|
+
if (line.userData.isWindow) line.currentData.isBayWindowLine = true;
|
|
6584
|
+
LineGroupType.removeByType(line, "bayWindow");
|
|
6585
|
+
}
|
|
6586
|
+
});
|
|
6587
|
+
const grid = createPointVirtualGrid(lines);
|
|
6588
|
+
removeSet.clear();
|
|
6589
|
+
bayWindowLines.forEach((bayWindowLine) => {
|
|
6590
|
+
let { circles } = maxiCircles$1.miniCircle(lines_, { circleEdges: [bayWindowLine] });
|
|
6591
|
+
circles = circles.filter((group) => group.some((line) => line.userData.isWindow && line.currentData.isBayWindowLine));
|
|
6592
|
+
if (circles.length) {
|
|
6593
|
+
grid.queryPolygon(Polygon.fromByLines(circles[0]), "inside").forEach((res) => removeSet.add(res.userData));
|
|
6594
|
+
}
|
|
6595
|
+
const id = uuid();
|
|
6596
|
+
if (circles.length) {
|
|
6597
|
+
const group = circles[0];
|
|
6598
|
+
group.forEach((line) => {
|
|
6599
|
+
clear && LineGroupType.clear(line);
|
|
6600
|
+
LineGroupType.set(line, id, "bayWindow", true);
|
|
6601
|
+
groupedLineSet.add(line);
|
|
6602
|
+
});
|
|
6603
|
+
} else clear && LineGroupType.clear(bayWindowLine);
|
|
6604
|
+
});
|
|
6605
|
+
lines = lines.filter((line) => !removeSet.has(line));
|
|
6606
|
+
clear && lines.forEach((line) => groupedLineSet.has(line) || LineGroupType.clear(line));
|
|
6607
|
+
return lines;
|
|
6608
|
+
}
|
|
6548
6609
|
const maxiCircles = new MaxiCircles();
|
|
6549
6610
|
let trajectory;
|
|
6550
6611
|
function isDoublePeDoorCircle(circle) {
|
|
6551
6612
|
const doors = circle.filter((line) => line.userData.passageEntrance?.some((item) => item.type === "door")), map = /* @__PURE__ */ new Map(), matching = [];
|
|
6552
6613
|
doors.forEach((door) => {
|
|
6553
6614
|
door.userData.passageEntrance.forEach((item) => {
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6615
|
+
const id = WIO.getId(item);
|
|
6616
|
+
const nearId = WIO.getNearId(item);
|
|
6617
|
+
if (typeof id === "number" && typeof nearId === "number") {
|
|
6618
|
+
if (map.has(nearId)) matching.push([map.get(nearId), door]);
|
|
6619
|
+
map.set(id, door);
|
|
6557
6620
|
}
|
|
6558
6621
|
});
|
|
6559
6622
|
});
|
|
6560
6623
|
return matching.length > 0;
|
|
6561
6624
|
}
|
|
6562
6625
|
function isPolyHasTrajectoryPoint(lines) {
|
|
6563
|
-
if (isDoublePeDoorCircle(lines)) return true;
|
|
6564
6626
|
if (!trajectory) return true;
|
|
6565
6627
|
const ploy = Polygon.fromByLines2(lines);
|
|
6566
6628
|
const box = ploy.getBox2();
|
|
@@ -6571,21 +6633,56 @@ function isPolyHasTrajectoryPoint(lines) {
|
|
|
6571
6633
|
}
|
|
6572
6634
|
return true;
|
|
6573
6635
|
}
|
|
6574
|
-
function
|
|
6575
|
-
const doorLines = [], otherLines = [];
|
|
6576
|
-
for (let i = 0; i <
|
|
6577
|
-
const line =
|
|
6636
|
+
function initData(lines) {
|
|
6637
|
+
const doorLines = [], otherLines = [], bayWindowLines = [], peDoors = [], peDoubleDoors = [];
|
|
6638
|
+
for (let i = 0; i < lines.length; i++) {
|
|
6639
|
+
const line = lines[i];
|
|
6578
6640
|
if (line.userData.isDoor) {
|
|
6579
6641
|
doorLines.push(line);
|
|
6580
6642
|
continue;
|
|
6581
6643
|
}
|
|
6582
6644
|
if (line.userData.isBayWindow) {
|
|
6645
|
+
bayWindowLines.push(line);
|
|
6646
|
+
continue;
|
|
6647
|
+
}
|
|
6648
|
+
if (line.userData.isPassageEntrance && line.userData.passageEntrance?.length) {
|
|
6649
|
+
const isDoubleDoor = line.userData.passageEntrance.some((item) => typeof WIO.getNearId(item) === "number");
|
|
6650
|
+
if (isDoubleDoor) peDoubleDoors.push(line);
|
|
6651
|
+
else peDoors.push(line);
|
|
6583
6652
|
continue;
|
|
6584
6653
|
}
|
|
6585
6654
|
otherLines.push(line);
|
|
6586
6655
|
}
|
|
6656
|
+
return { doorLines, otherLines, bayWindowLines, peDoors, peDoubleDoors };
|
|
6657
|
+
}
|
|
6658
|
+
function getPeDoubleDoorCircles(lines, peDoubleDoorLines) {
|
|
6659
|
+
let allLines = [...lines, ...peDoubleDoorLines];
|
|
6660
|
+
const notFoundLines = [];
|
|
6661
|
+
const circlesList = [];
|
|
6662
|
+
for (let i = 0; i < peDoubleDoorLines.length; i++) {
|
|
6663
|
+
const line = peDoubleDoorLines[i];
|
|
6664
|
+
let { circles } = maxiCircles.miniCircle(allLines, { circleEdges: [line] });
|
|
6665
|
+
const finalCircles = circles.filter(isDoublePeDoorCircle);
|
|
6666
|
+
if (finalCircles.length) circlesList.push(...finalCircles);
|
|
6667
|
+
else notFoundLines.push(line);
|
|
6668
|
+
}
|
|
6669
|
+
return {
|
|
6670
|
+
circlesList,
|
|
6671
|
+
notFoundLines
|
|
6672
|
+
};
|
|
6673
|
+
}
|
|
6674
|
+
function buildDoubleWallGroup_(lines_, clearInternalLine = false) {
|
|
6675
|
+
const {
|
|
6676
|
+
doorLines,
|
|
6677
|
+
otherLines,
|
|
6678
|
+
// bayWindowLines,
|
|
6679
|
+
// peDoors,
|
|
6680
|
+
peDoubleDoors
|
|
6681
|
+
} = initData(lines_);
|
|
6682
|
+
const { notFoundLines, circlesList } = getPeDoubleDoorCircles(otherLines, peDoubleDoors);
|
|
6683
|
+
otherLines.push(...notFoundLines);
|
|
6587
6684
|
let { internalEdges, circles } = maxiCircles.maxiCircles(otherLines, (circles2) => circles2.filter(isPolyHasTrajectoryPoint));
|
|
6588
|
-
const finalCircles =
|
|
6685
|
+
const { circles: finalCircles } = maxiCircles.mergeCircles([...circlesList, ...circles], internalEdges);
|
|
6589
6686
|
lines_.forEach((line) => LineGroupType.removeByTypes(line, ["doubleWall", "wall"]));
|
|
6590
6687
|
const grid = new PointVirtualGrid(), finalCirclesSet = new Set(finalCircles.flat(2));
|
|
6591
6688
|
otherLines.forEach((line) => !finalCirclesSet.has(line) && grid.insert(line.center, line));
|
|
@@ -6614,38 +6711,6 @@ const buildDoubleWallGroup = Object.assign(buildDoubleWallGroup_, {
|
|
|
6614
6711
|
else trajectory = void 0;
|
|
6615
6712
|
}
|
|
6616
6713
|
});
|
|
6617
|
-
function buildBayWindowGroup(lines, clear = true) {
|
|
6618
|
-
const bayWindowLines = lines.filter((line) => line.userData.isBayWindow), groupedLineSet = /* @__PURE__ */ new Set();
|
|
6619
|
-
const removeSet = findDiscretePointLine2(lines, null, true);
|
|
6620
|
-
const lines_ = lines.filter((line) => !removeSet.has(line));
|
|
6621
|
-
lines.forEach((line) => {
|
|
6622
|
-
if (LineGroupType.hasType(line, "bayWindow")) {
|
|
6623
|
-
if (line.userData.isWindow) line.currentData.isBayWindowLine = true;
|
|
6624
|
-
LineGroupType.removeByType(line, "bayWindow");
|
|
6625
|
-
}
|
|
6626
|
-
});
|
|
6627
|
-
const grid = createPointVirtualGrid(lines);
|
|
6628
|
-
removeSet.clear();
|
|
6629
|
-
bayWindowLines.forEach((bayWindowLine) => {
|
|
6630
|
-
let { circles } = maxiCircles.miniCircle(lines_, { circleEdges: [bayWindowLine] });
|
|
6631
|
-
circles = circles.filter((group) => group.some((line) => line.userData.isWindow && line.currentData.isBayWindowLine));
|
|
6632
|
-
if (circles.length) {
|
|
6633
|
-
grid.queryPolygon(Polygon.fromByLines(circles[0]), "inside").forEach((res) => removeSet.add(res.userData));
|
|
6634
|
-
}
|
|
6635
|
-
const id = uuid();
|
|
6636
|
-
if (circles.length) {
|
|
6637
|
-
const group = circles[0];
|
|
6638
|
-
group.forEach((line) => {
|
|
6639
|
-
clear && LineGroupType.clear(line);
|
|
6640
|
-
LineGroupType.set(line, id, "bayWindow", true);
|
|
6641
|
-
groupedLineSet.add(line);
|
|
6642
|
-
});
|
|
6643
|
-
} else clear && LineGroupType.clear(bayWindowLine);
|
|
6644
|
-
});
|
|
6645
|
-
lines = lines.filter((line) => !removeSet.has(line));
|
|
6646
|
-
clear && lines.forEach((line) => groupedLineSet.has(line) || LineGroupType.clear(line));
|
|
6647
|
-
return lines;
|
|
6648
|
-
}
|
|
6649
6714
|
class DoubleWallHelper {
|
|
6650
6715
|
static errorAngle = 4;
|
|
6651
6716
|
/** 线段投影分析
|
|
@@ -8448,7 +8513,7 @@ class AxisAlignCorr {
|
|
|
8448
8513
|
}
|
|
8449
8514
|
}
|
|
8450
8515
|
function shortDistanceLink(lines, radius = 0.1) {
|
|
8451
|
-
const
|
|
8516
|
+
const dpSet = findDiscretePoint(lines.filter((line) => !line.userData.isDoor)), pointVirtualGrid = createPointVirtualGrid(dpSet.map((v2) => v2)), appendLines = [], visited = /* @__PURE__ */ new Set();
|
|
8452
8517
|
const getWeight2 = (target, point2, line) => {
|
|
8453
8518
|
if (target.weight) return target.weight;
|
|
8454
8519
|
const targetLine = target.userData, targetPoint = target.point;
|
|
@@ -8456,24 +8521,21 @@ function shortDistanceLink(lines, radius = 0.1) {
|
|
|
8456
8521
|
target.weight = weight;
|
|
8457
8522
|
return weight;
|
|
8458
8523
|
};
|
|
8459
|
-
for (
|
|
8460
|
-
const line = dpLines[i];
|
|
8524
|
+
for (const [point2, line] of dpSet) {
|
|
8461
8525
|
if (line.userData.isDoor) continue;
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
const
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
else appendLines.push(new LineSegment(projectLine1.center, projectLine2.center));
|
|
8476
|
-
});
|
|
8526
|
+
if (visited.has(point2)) continue;
|
|
8527
|
+
const list = pointVirtualGrid.queryCircle(point2, radius, true).map((item) => Object.assign({}, item)).filter((item) => {
|
|
8528
|
+
const targetLine2 = item.userData, targetPoint2 = item.point, direct1 = line.getAnotherPoint(point2).directionFrom(point2), direct2 = targetLine2.getAnotherPoint(targetPoint2).directionFrom(targetPoint2), angle = direct1.angleBetween(direct2, "angle");
|
|
8529
|
+
return angle > 90;
|
|
8530
|
+
}).sort((a2, b4) => getWeight2(b4, point2, line) - getWeight2(a2, point2, line));
|
|
8531
|
+
if (list.length === 0) continue;
|
|
8532
|
+
const { point: targetPoint } = list[0];
|
|
8533
|
+
const targetLine = list[0].userData;
|
|
8534
|
+
visited.add(point2);
|
|
8535
|
+
visited.add(targetPoint);
|
|
8536
|
+
const projectLine1 = line.projectLineSegment(targetLine), projectLine2 = targetLine.projectLineSegment(line), len1 = projectLine1.length(), len2 = projectLine2.length();
|
|
8537
|
+
if (len1 === 0 && len2 === 0) appendLines.push(new LineSegment(point2.clone(), list[0].point.clone()));
|
|
8538
|
+
else appendLines.push(new LineSegment(projectLine1.center, projectLine2.center));
|
|
8477
8539
|
}
|
|
8478
8540
|
return [...lines, ...appendLines];
|
|
8479
8541
|
}
|
|
@@ -19229,19 +19291,16 @@ function removeShortDoubleWall(lineSegments) {
|
|
|
19229
19291
|
const doubleWalls = LineGroupType.getGroupsByType(lineSegments, "doubleWall"), freePointLines = [...findDiscretePointLine2(lineSegments)].filter((line) => line.length() < 0.3), grid = createPointVirtualGrid(doubleWalls.flat(4)), lines = freePointLines.filter((line) => grid.queryPoint(line.start).length > 0 || grid.queryPoint(line.end).length > 0), removeSet = new Set(lines);
|
|
19230
19292
|
return lineSegments.filter((line) => !removeSet.has(line));
|
|
19231
19293
|
}
|
|
19232
|
-
function
|
|
19294
|
+
function getNextPoint(point2, line, next, width) {
|
|
19233
19295
|
if (next.length === 0) {
|
|
19234
19296
|
const direct = point2.directionFrom(line.getAnotherPoint(point2));
|
|
19235
|
-
|
|
19236
|
-
return true;
|
|
19297
|
+
return direct.multiplyScalar(width);
|
|
19237
19298
|
}
|
|
19238
19299
|
const p2 = next[0].userData.projectPoint(point2, false);
|
|
19239
19300
|
if (!p2) return false;
|
|
19240
|
-
|
|
19241
|
-
next.forEach((d2) => d2.point.copy(p2));
|
|
19242
|
-
return true;
|
|
19301
|
+
return p2;
|
|
19243
19302
|
}
|
|
19244
|
-
function stepElimination
|
|
19303
|
+
function stepElimination(lineSegments, onMerge) {
|
|
19245
19304
|
const grid = createPointVirtualGrid(lineSegments);
|
|
19246
19305
|
const minWidth = 0.1;
|
|
19247
19306
|
function getIntersInfo(line, point2) {
|
|
@@ -19262,7 +19321,6 @@ function stepElimination$1(lineSegments, callBack) {
|
|
|
19262
19321
|
}
|
|
19263
19322
|
if (count !== 1) return;
|
|
19264
19323
|
if (!firstLine || !firstPoint) return;
|
|
19265
|
-
if (parallel2.length !== 0) return;
|
|
19266
19324
|
const firstOtherPoint = firstLine.getAnotherPoint(firstPoint);
|
|
19267
19325
|
const nextResult = grid.queryPoint(firstOtherPoint, true);
|
|
19268
19326
|
return {
|
|
@@ -19298,16 +19356,22 @@ function stepElimination$1(lineSegments, callBack) {
|
|
|
19298
19356
|
mainInfo = endInfo;
|
|
19299
19357
|
secondaryInfo = startInfo;
|
|
19300
19358
|
}
|
|
19301
|
-
const
|
|
19302
|
-
|
|
19303
|
-
|
|
19304
|
-
|
|
19305
|
-
|
|
19306
|
-
|
|
19307
|
-
|
|
19359
|
+
const parallel2 = startInfo.parallel.concat(endInfo.parallel);
|
|
19360
|
+
const newPoint = getNextPoint(mainInfo.firstPoint, mainInfo.firstLine, secondaryInfo.next, secondaryInfo.length);
|
|
19361
|
+
if (!newPoint) continue;
|
|
19362
|
+
if (parallel2.length === 0) {
|
|
19363
|
+
const oldLine = mainInfo.firstLine.clone();
|
|
19364
|
+
mainInfo.firstPoint.copy(newPoint);
|
|
19365
|
+
secondaryInfo.next.forEach((d2) => d2.point.copy(newPoint));
|
|
19366
|
+
removeLines.push(secondaryInfo.firstLine, line);
|
|
19367
|
+
line.points.concat(secondaryInfo.firstLine.points).forEach((p2) => grid.remove(p2));
|
|
19368
|
+
mainInfo.firstLine.points.forEach((p2) => grid.update(p2));
|
|
19369
|
+
if (typeof onMerge === "function") onMerge(mainInfo.firstLine, line, secondaryInfo.firstLine, oldLine);
|
|
19370
|
+
}
|
|
19308
19371
|
}
|
|
19309
19372
|
const removeLinesSet = new Set(removeLines);
|
|
19310
19373
|
lineSegments = lineSegments.filter((line) => !removeLinesSet.has(line));
|
|
19374
|
+
lineSegments = lineSegmentClipping(lineSegments, 0);
|
|
19311
19375
|
return lineSegments;
|
|
19312
19376
|
}
|
|
19313
19377
|
function repetitiveTask(count, callfun) {
|
|
@@ -19315,32 +19379,31 @@ function repetitiveTask(count, callfun) {
|
|
|
19315
19379
|
callfun(i);
|
|
19316
19380
|
}
|
|
19317
19381
|
}
|
|
19318
|
-
function
|
|
19319
|
-
|
|
19320
|
-
|
|
19321
|
-
|
|
19322
|
-
|
|
19323
|
-
|
|
19324
|
-
|
|
19325
|
-
|
|
19326
|
-
height: source.userData.drawDoorData.height,
|
|
19327
|
-
groundClearance: source.userData.drawDoorData.groundClearance
|
|
19328
|
-
});
|
|
19329
|
-
if (target.userData.isDoor) {
|
|
19330
|
-
delete target.userData.isDoor;
|
|
19331
|
-
WallInsertObject.addInsertObject(target, {
|
|
19332
|
-
p: oldLine.center.toJson(opt?.originalZ),
|
|
19333
|
-
width: oldLine.length(),
|
|
19334
|
-
full: false,
|
|
19335
|
-
type: "door",
|
|
19336
|
-
height: target.userData.drawDoorData?.height,
|
|
19337
|
-
groundClearance: target.userData.drawDoorData?.groundClearance ?? 0
|
|
19338
|
-
});
|
|
19339
|
-
}
|
|
19340
|
-
WallInsertObject.copyInsertObject(target, source);
|
|
19341
|
-
WallInsertObject.recomputed([target]);
|
|
19342
|
-
});
|
|
19382
|
+
function stepEliminationMerge(target, _, source, oldLine) {
|
|
19383
|
+
if (source.userData.isDoor) WallInsertObject.addInsertObject(target, {
|
|
19384
|
+
p: source.center.toJson(),
|
|
19385
|
+
width: source.length(),
|
|
19386
|
+
full: false,
|
|
19387
|
+
type: "door",
|
|
19388
|
+
height: source.userData.drawDoorData.height,
|
|
19389
|
+
groundClearance: source.userData.drawDoorData.groundClearance
|
|
19343
19390
|
});
|
|
19391
|
+
if (target.userData.isDoor) {
|
|
19392
|
+
delete target.userData.isDoor;
|
|
19393
|
+
WallInsertObject.addInsertObject(target, {
|
|
19394
|
+
p: oldLine.center.toJson(),
|
|
19395
|
+
width: oldLine.length(),
|
|
19396
|
+
full: false,
|
|
19397
|
+
type: "door",
|
|
19398
|
+
height: target.userData.drawDoorData?.height,
|
|
19399
|
+
groundClearance: target.userData.drawDoorData?.groundClearance ?? 0
|
|
19400
|
+
});
|
|
19401
|
+
}
|
|
19402
|
+
WallInsertObject.copyInsertObject(target, source);
|
|
19403
|
+
WallInsertObject.recomputed([target]);
|
|
19404
|
+
}
|
|
19405
|
+
function linesSmoothing(lines, _) {
|
|
19406
|
+
repetitiveTask(1, () => lines = stepElimination(lines, stepEliminationMerge));
|
|
19344
19407
|
return lines;
|
|
19345
19408
|
}
|
|
19346
19409
|
const PRE_PROCESSOR = {
|
|
@@ -19361,9 +19424,9 @@ const PRE_PROCESSOR = {
|
|
|
19361
19424
|
/** 处理门线垂直方向有其他线段遮挡的情况
|
|
19362
19425
|
*/
|
|
19363
19426
|
DoorSpaceHandle: doorSpaceHandle,
|
|
19364
|
-
/**
|
|
19427
|
+
/** 线段平滑处理
|
|
19365
19428
|
*/
|
|
19366
|
-
|
|
19429
|
+
LinesSmoothing: linesSmoothing,
|
|
19367
19430
|
/** 移除与双线墙链接的短线段
|
|
19368
19431
|
*/
|
|
19369
19432
|
RemoveShortDoubleWall: removeShortDoubleWall
|
|
@@ -22104,7 +22167,7 @@ async function buildJson(opt) {
|
|
|
22104
22167
|
doorFind && (dxfSystem.Dxf.addPreProcessor(PRE_PROCESSOR.DoorSpaceHandle), dxfSystem.Dxf.addPreProcessor(PRE_PROCESSOR.DoorFind), dxfSystem.Dxf.addPreProcessor(PRE_PROCESSOR.DoorSpaceHandle));
|
|
22105
22168
|
if (opt.axisAlignCorr !== false) {
|
|
22106
22169
|
dxfSystem.Dxf.addPreProcessor(PRE_PROCESSOR.AxisAlignCorr);
|
|
22107
|
-
dxfSystem.Dxf.addPreProcessor(PRE_PROCESSOR.
|
|
22170
|
+
dxfSystem.Dxf.addPreProcessor(PRE_PROCESSOR.LinesSmoothing);
|
|
22108
22171
|
dxfSystem.Dxf.addPreProcessor(PRE_PROCESSOR.RemoveShortDoubleWall);
|
|
22109
22172
|
}
|
|
22110
22173
|
if (trajectory2) {
|
|
@@ -15,7 +15,7 @@ export declare class CorrectionDxf<TEventMap extends {} = {}> extends Dxf<{} & T
|
|
|
15
15
|
DoubleWallAlignment: typeof import('../utils/lineHandle/CadPreProcessor/doubleWallAlignment').doubleWallAlignment;
|
|
16
16
|
WallHeightHandle: typeof import('../utils/lineHandle/CadPreProcessor/wallHeightHandle').wallHeightHandle;
|
|
17
17
|
DoorSpaceHandle: typeof import('../utils/lineHandle/CadPreProcessor/doorSpaceHandle').doorSpaceHandle;
|
|
18
|
-
|
|
18
|
+
LinesSmoothing: typeof import('../utils/lineHandle/CadPreProcessor/linesSmoothing').linesSmoothing;
|
|
19
19
|
RemoveShortDoubleWall: typeof import('../utils/lineHandle/CadPreProcessor/removeShortDoubleWall').removeShortDoubleWall;
|
|
20
20
|
};
|
|
21
21
|
rotateCorrCad?: CAD;
|
|
@@ -29,7 +29,7 @@ export declare class Dxf<TEventMap extends {} = {}> extends Component<{
|
|
|
29
29
|
DoubleWallAlignment: typeof import('../utils/lineHandle/CadPreProcessor/doubleWallAlignment').doubleWallAlignment;
|
|
30
30
|
WallHeightHandle: typeof import('../utils/lineHandle/CadPreProcessor/wallHeightHandle').wallHeightHandle;
|
|
31
31
|
DoorSpaceHandle: typeof import('../utils/lineHandle/CadPreProcessor/doorSpaceHandle').doorSpaceHandle;
|
|
32
|
-
|
|
32
|
+
LinesSmoothing: typeof import('../utils/lineHandle/CadPreProcessor/linesSmoothing').linesSmoothing;
|
|
33
33
|
RemoveShortDoubleWall: typeof import('../utils/lineHandle/CadPreProcessor/removeShortDoubleWall').removeShortDoubleWall;
|
|
34
34
|
};
|
|
35
35
|
width: number;
|
|
@@ -6,7 +6,7 @@ import { doubleWallAlignment } from './doubleWallAlignment';
|
|
|
6
6
|
import { wallHeightHandle } from './wallHeightHandle';
|
|
7
7
|
import { doorSpaceHandle } from './doorSpaceHandle';
|
|
8
8
|
import { removeShortDoubleWall } from './removeShortDoubleWall';
|
|
9
|
-
import {
|
|
9
|
+
import { linesSmoothing } from './linesSmoothing';
|
|
10
10
|
/**
|
|
11
11
|
* 默认提供的预处理函数
|
|
12
12
|
*/
|
|
@@ -28,9 +28,9 @@ export declare const PRE_PROCESSOR: {
|
|
|
28
28
|
/** 处理门线垂直方向有其他线段遮挡的情况
|
|
29
29
|
*/
|
|
30
30
|
DoorSpaceHandle: typeof doorSpaceHandle;
|
|
31
|
-
/**
|
|
31
|
+
/** 线段平滑处理
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
LinesSmoothing: typeof linesSmoothing;
|
|
34
34
|
/** 移除与双线墙链接的短线段
|
|
35
35
|
*/
|
|
36
36
|
RemoveShortDoubleWall: typeof removeShortDoubleWall;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { LineSegment } from '../../../../algorithmsStructures/LineSegment';
|
|
2
2
|
import { SetDataOption } from '../../../type';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function linesSmoothing(lines: LineSegment[], _?: SetDataOption): LineSegment<Record<string, any>>[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LineSegment } from '../../../../algorithmsStructures/LineSegment';
|
|
2
|
+
import { LineUserData } from '../../../type';
|
|
3
|
+
/** 构建飘窗组组结构
|
|
4
|
+
* @param lines
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildBayWindowGroup(lines: LineSegment<LineUserData>[], clear?: boolean): LineSegment<LineUserData>[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LineSegment } from '
|
|
2
|
-
import { LineUserData } from '
|
|
1
|
+
import { LineSegment } from '../../../../algorithmsStructures/LineSegment';
|
|
2
|
+
import { LineUserData } from '../../../type';
|
|
3
3
|
/** 双线墙
|
|
4
4
|
* @param lines_
|
|
5
5
|
* @param clearInternalLine
|
|
@@ -10,8 +10,3 @@ export declare function buildDoubleWallGroup_(lines_: LineSegment<LineUserData>[
|
|
|
10
10
|
export declare const buildDoubleWallGroup: typeof buildDoubleWallGroup_ & {
|
|
11
11
|
setTrajectory(trajectory_: Record<string, any> | undefined): void;
|
|
12
12
|
};
|
|
13
|
-
/** 构建飘窗组组结构
|
|
14
|
-
* @param lines
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export declare function buildBayWindowGroup(lines: LineSegment<LineUserData>[], clear?: boolean): LineSegment<LineUserData>[];
|
|
@@ -2,12 +2,11 @@ import { LineSegment } from '../../../algorithmsStructures/LineSegment';
|
|
|
2
2
|
import { InsertObject, LineUserData } from '../../type';
|
|
3
3
|
type InsertObjectKey = 'drawWindow' | 'passageEntrance';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 墙体嵌入物(窗户、空洞)处理
|
|
6
6
|
*/
|
|
7
7
|
export declare class WallInsertObject {
|
|
8
8
|
static mountedObjectType: never[];
|
|
9
9
|
lines: LineSegment<LineUserData>[];
|
|
10
|
-
mountedObjectLines: LineSegment<LineUserData>[];
|
|
11
10
|
constructor(lines: LineSegment<LineUserData>[]);
|
|
12
11
|
/** 是否是墙体嵌入物
|
|
13
12
|
* @param line
|
|
@@ -19,7 +18,10 @@ export declare class WallInsertObject {
|
|
|
19
18
|
* @param line
|
|
20
19
|
* @returns
|
|
21
20
|
*/
|
|
22
|
-
static isDoor(line: LineSegment<LineUserData>): boolean
|
|
21
|
+
static isDoor(line: LineSegment<LineUserData>): boolean;
|
|
22
|
+
static isDoubleDoor(line: LineSegment<LineUserData>): boolean;
|
|
23
|
+
static getId(item: InsertObject): number | undefined;
|
|
24
|
+
static getNearId(item: InsertObject): number | undefined;
|
|
23
25
|
/** 遍历孔洞
|
|
24
26
|
* @param line
|
|
25
27
|
* @returns
|
|
@@ -30,19 +32,24 @@ export declare class WallInsertObject {
|
|
|
30
32
|
* @param line
|
|
31
33
|
* @returns
|
|
32
34
|
*/
|
|
33
|
-
getMinWidth(key: InsertObjectKey): 0 | 0.3;
|
|
35
|
+
static getMinWidth(key: InsertObjectKey, type?: 'door'): 0 | 0.3;
|
|
36
|
+
getMinWidth(key: InsertObjectKey, type?: 'door'): 0 | 0.3;
|
|
37
|
+
static clear(target: LineSegment, key: InsertObjectKey): void;
|
|
34
38
|
/**
|
|
35
39
|
* 重新计算
|
|
36
40
|
*/
|
|
37
|
-
recomputed():
|
|
41
|
+
static recomputed(lines: LineSegment[]): typeof WallInsertObject;
|
|
42
|
+
recomputed(lines?: LineSegment<LineUserData>[]): this;
|
|
38
43
|
/**
|
|
39
44
|
* 重新计算位置
|
|
40
45
|
*/
|
|
41
|
-
recomputedCenter():
|
|
46
|
+
static recomputedCenter(lines: LineSegment[]): typeof WallInsertObject;
|
|
47
|
+
recomputedCenter(lines?: LineSegment[]): this;
|
|
42
48
|
/**
|
|
43
49
|
* 对重合的进行合并
|
|
44
50
|
*/
|
|
45
|
-
merge():
|
|
51
|
+
static merge(lines: LineSegment[]): typeof WallInsertObject;
|
|
52
|
+
merge(lines?: LineSegment[]): this;
|
|
46
53
|
/** 添加孔洞
|
|
47
54
|
* @param target
|
|
48
55
|
* @param insertObject
|
|
@@ -56,8 +63,6 @@ export declare class WallInsertObject {
|
|
|
56
63
|
*/
|
|
57
64
|
static copyInsertObject(target: LineSegment<LineUserData>, source: LineSegment<LineUserData>): void;
|
|
58
65
|
copyInsertObject(target: LineSegment<LineUserData>, source: LineSegment<LineUserData>): void;
|
|
59
|
-
static recomputed(lines: LineSegment[]): void;
|
|
60
|
-
static recomputedCenter(lines: LineSegment[]): void;
|
|
61
|
-
static merge(lines: LineSegment[]): void;
|
|
62
66
|
}
|
|
67
|
+
export declare const WIO: typeof WallInsertObject;
|
|
63
68
|
export {};
|
|
@@ -3,4 +3,4 @@ import { LineSegment } from './LineSegment';
|
|
|
3
3
|
* @param lineSegments
|
|
4
4
|
* @returns
|
|
5
5
|
*/
|
|
6
|
-
export declare function stepElimination(lineSegments: LineSegment[],
|
|
6
|
+
export declare function stepElimination(lineSegments: LineSegment[], onMerge?: (mainLine: LineSegment, sortLine: LineSegment, secondaryLine: LineSegment, oldLine: LineSegment) => void): LineSegment<Record<string, any>>[];
|