build-dxf 0.1.78 → 0.1.79
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
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,24 @@ 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
|
+
return item.nearId ?? item.nearDoorId;
|
|
3111
|
+
}
|
|
3101
3112
|
/** 遍历孔洞
|
|
3102
3113
|
* @param line
|
|
3103
3114
|
* @returns
|
|
@@ -3117,16 +3128,27 @@ class WallInsertObject {
|
|
|
3117
3128
|
* @param line
|
|
3118
3129
|
* @returns
|
|
3119
3130
|
*/
|
|
3120
|
-
getMinWidth(key) {
|
|
3131
|
+
static getMinWidth(key, type) {
|
|
3121
3132
|
if (key === "drawWindow") return 0.3;
|
|
3122
|
-
if (key === "passageEntrance")
|
|
3133
|
+
if (key === "passageEntrance") {
|
|
3134
|
+
if (type === "door") return 0.3;
|
|
3135
|
+
}
|
|
3123
3136
|
return 0;
|
|
3124
3137
|
}
|
|
3138
|
+
getMinWidth(key, type) {
|
|
3139
|
+
return WallInsertObject.getMinWidth(key, type);
|
|
3140
|
+
}
|
|
3141
|
+
static clear(target, key) {
|
|
3142
|
+
const eabledKey = key === "drawWindow" ? "isWindow" : "isPassageEntrance";
|
|
3143
|
+
const key_ = key === "drawWindow" ? "drawWindow" : "passageEntrance";
|
|
3144
|
+
target.userData[eabledKey] = false;
|
|
3145
|
+
delete target.userData[key_];
|
|
3146
|
+
}
|
|
3125
3147
|
/**
|
|
3126
3148
|
* 重新计算
|
|
3127
3149
|
*/
|
|
3128
|
-
recomputed() {
|
|
3129
|
-
|
|
3150
|
+
static recomputed(lines) {
|
|
3151
|
+
lines.forEach((line) => {
|
|
3130
3152
|
this.forEachInsertObjectData(line, (data, key) => {
|
|
3131
3153
|
data.forEach((w) => {
|
|
3132
3154
|
try {
|
|
@@ -3142,17 +3164,21 @@ class WallInsertObject {
|
|
|
3142
3164
|
} catch (error) {
|
|
3143
3165
|
}
|
|
3144
3166
|
});
|
|
3145
|
-
|
|
3146
|
-
line.userData[key]
|
|
3167
|
+
line.userData[key] = data.filter((w) => w.width > WallInsertObject.getMinWidth(key, w.type));
|
|
3168
|
+
if (line.userData[key].length === 0) WallInsertObject.clear(line, key);
|
|
3147
3169
|
});
|
|
3148
3170
|
});
|
|
3149
3171
|
return this;
|
|
3150
3172
|
}
|
|
3173
|
+
recomputed(lines = this.lines) {
|
|
3174
|
+
WallInsertObject.recomputed(lines);
|
|
3175
|
+
return this;
|
|
3176
|
+
}
|
|
3151
3177
|
/**
|
|
3152
3178
|
* 重新计算位置
|
|
3153
3179
|
*/
|
|
3154
|
-
recomputedCenter() {
|
|
3155
|
-
|
|
3180
|
+
static recomputedCenter(lines) {
|
|
3181
|
+
lines.forEach((line) => {
|
|
3156
3182
|
this.forEachInsertObjectData(line, (data, key) => {
|
|
3157
3183
|
data.forEach((w) => {
|
|
3158
3184
|
try {
|
|
@@ -3171,11 +3197,15 @@ class WallInsertObject {
|
|
|
3171
3197
|
});
|
|
3172
3198
|
return this;
|
|
3173
3199
|
}
|
|
3200
|
+
recomputedCenter(lines = this.lines) {
|
|
3201
|
+
WallInsertObject.recomputedCenter(lines);
|
|
3202
|
+
return this;
|
|
3203
|
+
}
|
|
3174
3204
|
/**
|
|
3175
3205
|
* 对重合的进行合并
|
|
3176
3206
|
*/
|
|
3177
|
-
merge() {
|
|
3178
|
-
|
|
3207
|
+
static merge(lines) {
|
|
3208
|
+
lines.forEach((line) => {
|
|
3179
3209
|
this.forEachInsertObjectData(line, (data, key) => {
|
|
3180
3210
|
const direction = line.direction();
|
|
3181
3211
|
const embeddedLines = data.map((w) => {
|
|
@@ -3229,6 +3259,10 @@ class WallInsertObject {
|
|
|
3229
3259
|
});
|
|
3230
3260
|
return this;
|
|
3231
3261
|
}
|
|
3262
|
+
merge(lines = this.lines) {
|
|
3263
|
+
WallInsertObject.merge(lines);
|
|
3264
|
+
return this;
|
|
3265
|
+
}
|
|
3232
3266
|
/** 添加孔洞
|
|
3233
3267
|
* @param target
|
|
3234
3268
|
* @param insertObject
|
|
@@ -3258,16 +3292,8 @@ class WallInsertObject {
|
|
|
3258
3292
|
copyInsertObject(target, source) {
|
|
3259
3293
|
WallInsertObject.copyInsertObject(target, source);
|
|
3260
3294
|
}
|
|
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
3295
|
}
|
|
3296
|
+
const WIO = WallInsertObject;
|
|
3271
3297
|
function clippingLineUserData(newLine, line2) {
|
|
3272
3298
|
const { drawWindow, passageEntrance, ...opt } = line2.userData;
|
|
3273
3299
|
WallInsertObject.forEachInsertObjectData(line2, (data, key) => {
|
|
@@ -6551,9 +6577,11 @@ function isDoublePeDoorCircle(circle) {
|
|
|
6551
6577
|
const doors = circle.filter((line) => line.userData.passageEntrance?.some((item) => item.type === "door")), map = /* @__PURE__ */ new Map(), matching = [];
|
|
6552
6578
|
doors.forEach((door) => {
|
|
6553
6579
|
door.userData.passageEntrance.forEach((item) => {
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6580
|
+
const id = WIO.getId(item);
|
|
6581
|
+
const nearId = WIO.getNearId(item);
|
|
6582
|
+
if (typeof id === "number" && typeof nearId === "number") {
|
|
6583
|
+
if (map.has(nearId)) matching.push([map.get(nearId), door]);
|
|
6584
|
+
map.set(id, door);
|
|
6557
6585
|
}
|
|
6558
6586
|
});
|
|
6559
6587
|
});
|
|
@@ -6572,7 +6600,7 @@ function isPolyHasTrajectoryPoint(lines) {
|
|
|
6572
6600
|
return true;
|
|
6573
6601
|
}
|
|
6574
6602
|
function buildDoubleWallGroup_(lines_, clearInternalLine = false) {
|
|
6575
|
-
const doorLines = [], otherLines = [];
|
|
6603
|
+
const doorLines = [], otherLines = [], peDoubleDoors = [];
|
|
6576
6604
|
for (let i = 0; i < lines_.length; i++) {
|
|
6577
6605
|
const line = lines_[i];
|
|
6578
6606
|
if (line.userData.isDoor) {
|
|
@@ -6582,9 +6610,17 @@ function buildDoubleWallGroup_(lines_, clearInternalLine = false) {
|
|
|
6582
6610
|
if (line.userData.isBayWindow) {
|
|
6583
6611
|
continue;
|
|
6584
6612
|
}
|
|
6613
|
+
if (line.userData.isPassageEntrance && line.userData.passageEntrance?.length) {
|
|
6614
|
+
const isDoubleDoor = line.userData.passageEntrance.some((item) => typeof WIO.getId(item) === "number");
|
|
6615
|
+
if (isDoubleDoor) peDoubleDoors.push(line);
|
|
6616
|
+
continue;
|
|
6617
|
+
}
|
|
6585
6618
|
otherLines.push(line);
|
|
6586
6619
|
}
|
|
6587
|
-
|
|
6620
|
+
otherLines.push(...peDoubleDoors);
|
|
6621
|
+
let { internalEdges, circles } = maxiCircles.maxiCircles(otherLines, (circles2) => {
|
|
6622
|
+
return circles2.filter(isPolyHasTrajectoryPoint);
|
|
6623
|
+
});
|
|
6588
6624
|
const finalCircles = circles.filter((circle) => circle.length > 3);
|
|
6589
6625
|
lines_.forEach((line) => LineGroupType.removeByTypes(line, ["doubleWall", "wall"]));
|
|
6590
6626
|
const grid = new PointVirtualGrid(), finalCirclesSet = new Set(finalCircles.flat(2));
|
|
@@ -8609,7 +8645,9 @@ function axisAlignCorr$1(lines, targettLine, option) {
|
|
|
8609
8645
|
if (wallGroup) {
|
|
8610
8646
|
newLines = DoubleWallHelper.complementSide(newLines);
|
|
8611
8647
|
WallInsertObject.recomputed(newLines);
|
|
8648
|
+
TEST = true;
|
|
8612
8649
|
newLines = buildDoubleWallGroup(newLines, true);
|
|
8650
|
+
TEST = false;
|
|
8613
8651
|
newLines = buildBayWindowGroup(newLines, false);
|
|
8614
8652
|
}
|
|
8615
8653
|
new WallInsertObject(lines).recomputed().merge();
|
|
@@ -7,7 +7,6 @@ type InsertObjectKey = 'drawWindow' | 'passageEntrance';
|
|
|
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 {};
|