build-dxf 0.1.147 → 0.1.148
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 +25 -19
- package/src/dxf-system/plugins/editor/Command/DrawHole.d.ts +2 -2
- package/src/dxf-system/plugins/editor/Command/DrawWindow.d.ts +2 -2
- package/src/dxf-system/type.d.ts +2 -2
- package/src/dxf-system/utils/WallHole.d.ts +5 -5
- package/src/index3.js +3 -2
- package/src/utils/algorithms/Quadtree.d.ts +1 -1
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -2739,9 +2739,9 @@ class Quadtree {
|
|
|
2739
2739
|
}));
|
|
2740
2740
|
return array;
|
|
2741
2741
|
}
|
|
2742
|
-
static from(lines) {
|
|
2742
|
+
static from(lines, userDataFun) {
|
|
2743
2743
|
const quadtree = new Quadtree(Box2.fromByLineSegment(...lines));
|
|
2744
|
-
lines.forEach((line) => quadtree.insert({ line, userData: void 0 }));
|
|
2744
|
+
lines.forEach((line, index2) => quadtree.insert({ line, userData: userDataFun ? userDataFun(line, index2) : void 0 }));
|
|
2745
2745
|
return quadtree;
|
|
2746
2746
|
}
|
|
2747
2747
|
}
|
|
@@ -8855,7 +8855,7 @@ class WallHole {
|
|
|
8855
8855
|
otherLines.push(line);
|
|
8856
8856
|
return [];
|
|
8857
8857
|
}
|
|
8858
|
-
WallHole.
|
|
8858
|
+
WallHole.forEachStorageType(line, (data, k) => {
|
|
8859
8859
|
if (k !== "passageEntrance") return;
|
|
8860
8860
|
data.forEach((v2) => {
|
|
8861
8861
|
const id = WallHole.getId(v2);
|
|
@@ -8911,7 +8911,7 @@ class WallHole {
|
|
|
8911
8911
|
* @param line
|
|
8912
8912
|
* @returns
|
|
8913
8913
|
*/
|
|
8914
|
-
static
|
|
8914
|
+
static forEachStorageType(line, callBack) {
|
|
8915
8915
|
if (line.userData.isWindow) {
|
|
8916
8916
|
line.userData.drawWindow?.forEach((item) => item.type = "window");
|
|
8917
8917
|
callBack(line.userData.drawWindow ?? [], "drawWindow");
|
|
@@ -8928,6 +8928,7 @@ class WallHole {
|
|
|
8928
8928
|
if (key === "drawWindow") return 0.3;
|
|
8929
8929
|
if (key === "passageEntrance") {
|
|
8930
8930
|
if (type === "door") return 0.4;
|
|
8931
|
+
else if (type === "passageEntrance") return 0.2;
|
|
8931
8932
|
}
|
|
8932
8933
|
return 0.05;
|
|
8933
8934
|
}
|
|
@@ -8954,7 +8955,7 @@ class WallHole {
|
|
|
8954
8955
|
line.forEach((line2) => this.miniWidthFilter(line2));
|
|
8955
8956
|
return this;
|
|
8956
8957
|
}
|
|
8957
|
-
this.
|
|
8958
|
+
this.forEachStorageType(line, (data, key) => {
|
|
8958
8959
|
line.userData[key] = data.filter((w) => w.width > WallHole.getMinWidth(key, w.type));
|
|
8959
8960
|
if (line.userData[key].length === 0) WallHole.clear(line, key);
|
|
8960
8961
|
});
|
|
@@ -8968,7 +8969,7 @@ class WallHole {
|
|
|
8968
8969
|
line.forEach((line2) => this.filterIllegal(line2));
|
|
8969
8970
|
return this;
|
|
8970
8971
|
}
|
|
8971
|
-
this.
|
|
8972
|
+
this.forEachStorageType(line, (data, key) => {
|
|
8972
8973
|
data.forEach((w) => {
|
|
8973
8974
|
if (!w.type && key === "drawWindow") w.type = "window";
|
|
8974
8975
|
try {
|
|
@@ -8992,7 +8993,7 @@ class WallHole {
|
|
|
8992
8993
|
*/
|
|
8993
8994
|
static recomputedCenter(lines) {
|
|
8994
8995
|
lines.forEach((line) => {
|
|
8995
|
-
this.
|
|
8996
|
+
this.forEachStorageType(line, (data, key) => {
|
|
8996
8997
|
data.forEach((w) => {
|
|
8997
8998
|
try {
|
|
8998
8999
|
const center = line.projectPoint(Point.from(w.p));
|
|
@@ -9084,7 +9085,7 @@ class WallHole {
|
|
|
9084
9085
|
* @param insertObject
|
|
9085
9086
|
*/
|
|
9086
9087
|
static removeHole(target, insertObject) {
|
|
9087
|
-
this.
|
|
9088
|
+
this.forEachStorageType(target, (data, key) => {
|
|
9088
9089
|
let index2 = data.indexOf(insertObject);
|
|
9089
9090
|
if (index2 > -1) {
|
|
9090
9091
|
data.splice(index2, 1);
|
|
@@ -9097,7 +9098,7 @@ class WallHole {
|
|
|
9097
9098
|
* @param source
|
|
9098
9099
|
*/
|
|
9099
9100
|
static copyHole(target, source) {
|
|
9100
|
-
WallHole.
|
|
9101
|
+
WallHole.forEachStorageType(source, (data, key) => {
|
|
9101
9102
|
data.forEach((item) => {
|
|
9102
9103
|
WallHole.addHole(target, cloneUserData(item), key);
|
|
9103
9104
|
});
|
|
@@ -9110,6 +9111,7 @@ class WallHole {
|
|
|
9110
9111
|
*/
|
|
9111
9112
|
static splitHole(target, source) {
|
|
9112
9113
|
if (!Array.isArray(source)) source = [];
|
|
9114
|
+
this.filterIllegal(target);
|
|
9113
9115
|
source = source.filter((line) => line.length > 1e-9);
|
|
9114
9116
|
const iterator = this.getIterator(target);
|
|
9115
9117
|
for (const hole of iterator) {
|
|
@@ -9129,7 +9131,8 @@ class WallHole {
|
|
|
9129
9131
|
}
|
|
9130
9132
|
}
|
|
9131
9133
|
if (!find && maxLine) {
|
|
9132
|
-
|
|
9134
|
+
let v2 = maxLine.projectPointValue(hole.p);
|
|
9135
|
+
v2 = Math.min(1, Math.max(0, v2));
|
|
9133
9136
|
const point2 = maxLine.pointAt(v2, PointUtils.globalPoint);
|
|
9134
9137
|
hole.p.x = point2.x;
|
|
9135
9138
|
hole.p.y = point2.y;
|
|
@@ -10214,7 +10217,7 @@ function clippingInsertObjectDoubleWall(lines) {
|
|
|
10214
10217
|
if (WallHole.isHole(line)) {
|
|
10215
10218
|
const normal = line.normal(), center = line.center;
|
|
10216
10219
|
if (!poly.pointWithin(center.add(normal.clone().multiplyScalar(1e-6)))) normal.multiplyScalar(-1);
|
|
10217
|
-
WallHole.
|
|
10220
|
+
WallHole.forEachStorageType(line, (data) => data.forEach((d2) => {
|
|
10218
10221
|
const wioLine = WallHole.holeDataToLine(line, d2);
|
|
10219
10222
|
wioLine.setLength(wioLine.length - 4e-3);
|
|
10220
10223
|
const len = wioLine.length;
|
|
@@ -10281,7 +10284,7 @@ class WallHoleDrawData {
|
|
|
10281
10284
|
if ("expandDirect" in line.userData) {
|
|
10282
10285
|
openDirect = line.userData.expandDirect === "left" ? line.getRightDirection() : line.getLeftDirection();
|
|
10283
10286
|
}
|
|
10284
|
-
WallHole.
|
|
10287
|
+
WallHole.forEachStorageType(line, (data, k) => {
|
|
10285
10288
|
const list = grid && doubleWallPoint$1(grid, line), dwh = defaultWallWidth$1 * 0.5;
|
|
10286
10289
|
data.map(({ full, width, p: p2, height, groundClearance, uuid: uuid2, type }) => {
|
|
10287
10290
|
if (full) width = line.length;
|
|
@@ -10332,7 +10335,7 @@ class WallHoleDrawData {
|
|
|
10332
10335
|
mergeLineUserData(newLine, lines);
|
|
10333
10336
|
WallHole.merge([newLine]);
|
|
10334
10337
|
const newLines = [];
|
|
10335
|
-
WallHole.
|
|
10338
|
+
WallHole.forEachStorageType(newLine, (data, key) => {
|
|
10336
10339
|
data.forEach(({ full, width, p: p2, height, groundClearance, type }) => {
|
|
10337
10340
|
const point2 = Point.from(p2), direct = newLine.direction();
|
|
10338
10341
|
if (full) width = newLine.length;
|
|
@@ -10853,7 +10856,7 @@ class ThreeVJiaPipeline extends Pipeline {
|
|
|
10853
10856
|
let centerVec2 = null;
|
|
10854
10857
|
lineSegments = LineSegmentUndirectedGraph.rotate(lineSegments.map((line) => line.clone()), angle, (line, center, angle2) => {
|
|
10855
10858
|
if (!centerVec2) centerVec2 = { x: center.x, y: center.y };
|
|
10856
|
-
WallHole.
|
|
10859
|
+
WallHole.forEachStorageType(line, (data) => {
|
|
10857
10860
|
data.forEach((item) => {
|
|
10858
10861
|
const point2 = Point.from(item.p);
|
|
10859
10862
|
point2.rotate(center, angle2);
|
|
@@ -10864,7 +10867,7 @@ class ThreeVJiaPipeline extends Pipeline {
|
|
|
10864
10867
|
const heights = [];
|
|
10865
10868
|
lineSegments.forEach((line) => {
|
|
10866
10869
|
if (line.userData.isDoor) heights.push(line.userData.height ?? 0);
|
|
10867
|
-
WallHole.
|
|
10870
|
+
WallHole.forEachStorageType(line, (data) => {
|
|
10868
10871
|
heights.push(line.userData.height ?? 0);
|
|
10869
10872
|
data.forEach((item) => {
|
|
10870
10873
|
const h = (item.height ?? 0) + (item.groundClearance ?? 0);
|
|
@@ -10889,10 +10892,12 @@ function mmTom(value) {
|
|
|
10889
10892
|
return Number((value / 1e3).toFixed(4));
|
|
10890
10893
|
}
|
|
10891
10894
|
function getLineIndexByCenter(targetLines, lines) {
|
|
10892
|
-
const grid = Quadtree.from(lines);
|
|
10895
|
+
const grid = Quadtree.from(lines, (_, i) => ({ index: i }));
|
|
10893
10896
|
const indices = targetLines.map((line) => {
|
|
10894
10897
|
const res = grid.queryPoint(line.center);
|
|
10895
|
-
if (res.length)
|
|
10898
|
+
if (res.length) {
|
|
10899
|
+
return res[0].userData.index;
|
|
10900
|
+
}
|
|
10896
10901
|
return -1;
|
|
10897
10902
|
});
|
|
10898
10903
|
return indices;
|
|
@@ -11009,7 +11014,7 @@ function mergeChainsLine(lines, callBack, removeLines, newLines) {
|
|
|
11009
11014
|
}
|
|
11010
11015
|
function clippingLineUserData(newLine, line2) {
|
|
11011
11016
|
const { drawWindow, passageEntrance, ...opt } = line2.userData;
|
|
11012
|
-
WallHole.
|
|
11017
|
+
WallHole.forEachStorageType(line2, (data, key) => {
|
|
11013
11018
|
if (key === "drawWindow") {
|
|
11014
11019
|
return;
|
|
11015
11020
|
}
|
|
@@ -12146,6 +12151,7 @@ function correction(lines, targettLine, option) {
|
|
|
12146
12151
|
lines = recoveryBayWindow(lines, bayWindow);
|
|
12147
12152
|
lines = removeDangline(lines, 0.1, false);
|
|
12148
12153
|
lines = removeShortDoor(lines);
|
|
12154
|
+
WallHole.miniWidthFilter(lines);
|
|
12149
12155
|
lines = LineSegmentUtils.GroupBuilder(LineSegmentUtils.group(lines, (line) => line.userData.isDoor || line.userData.isBalconyRailing ? "otherLines" : "newLines")).handle("newLines", (newLines) => {
|
|
12150
12156
|
newLines = BuildGroup.bayWindow(newLines, false);
|
|
12151
12157
|
const { wallGroup = true } = option ?? {};
|
|
@@ -23856,7 +23862,7 @@ function hasCircle(lineData, startIndex, direction) {
|
|
|
23856
23862
|
let lines = originalDataToLineData(lineData).lineSegments;
|
|
23857
23863
|
const center = lines[startIndex].center;
|
|
23858
23864
|
let findlines = splitIntersectedLine(lines.map((line2) => line2.clone()), 1e-9);
|
|
23859
|
-
let removeSet =
|
|
23865
|
+
let removeSet = findDiscretePointLine(findlines);
|
|
23860
23866
|
findlines = findlines.filter((line2) => !removeSet.has(line2));
|
|
23861
23867
|
const list = findlines.filter((line2) => line2.userData.isBayWindow && line2.isPointOnSegment(center));
|
|
23862
23868
|
if (list.length === 0) return null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from './Command';
|
|
2
2
|
import { LineSegment } from '../../../../utils/algorithms/LineSegment';
|
|
3
3
|
import { ComponentContainer } from '../../../../utils/ecs';
|
|
4
|
-
import { HoleData,
|
|
4
|
+
import { HoleData, HoleStorageType, HoleType, LineUserData } from '../../../type';
|
|
5
5
|
import { Point } from '../../../../utils';
|
|
6
6
|
import * as THREE from "three";
|
|
7
7
|
export interface DrawHoleData {
|
|
@@ -25,7 +25,7 @@ export declare class DrawHole extends Command<{
|
|
|
25
25
|
defaultHeight: number;
|
|
26
26
|
defaultGroundClearance: number;
|
|
27
27
|
holeType?: HoleType;
|
|
28
|
-
holeKey:
|
|
28
|
+
holeKey: HoleStorageType;
|
|
29
29
|
showEditWidth: boolean;
|
|
30
30
|
showEditHeight: boolean;
|
|
31
31
|
showEditGroundClearance: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HoleStorageType, HoleType } from '../../../type';
|
|
2
2
|
import { DrawHole } from './DrawHole';
|
|
3
3
|
import * as THREE from "three";
|
|
4
4
|
export declare class DrawWindow extends DrawHole {
|
|
@@ -7,5 +7,5 @@ export declare class DrawWindow extends DrawHole {
|
|
|
7
7
|
static shortcutKeys: string[];
|
|
8
8
|
static commandName: string;
|
|
9
9
|
holeType: HoleType;
|
|
10
|
-
holeKey:
|
|
10
|
+
holeKey: HoleStorageType;
|
|
11
11
|
}
|
package/src/dxf-system/type.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export interface GroupItem {
|
|
|
7
7
|
id: string;
|
|
8
8
|
type?: string;
|
|
9
9
|
}
|
|
10
|
-
export type
|
|
11
|
-
export type HoleType = "door" | "window" | "beam";
|
|
10
|
+
export type HoleStorageType = 'drawWindow' | 'passageEntrance';
|
|
11
|
+
export type HoleType = "door" | "window" | "beam" | "passageEntrance";
|
|
12
12
|
export interface HoleData {
|
|
13
13
|
p: {
|
|
14
14
|
x: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LineSegment } from '../../utils/algorithms/LineSegment';
|
|
2
|
-
import { HoleData,
|
|
2
|
+
import { HoleData, HoleStorageType, HoleType, LineUserData } from '../type';
|
|
3
3
|
/**
|
|
4
4
|
* 墙体嵌入物(窗户、空洞)处理对象
|
|
5
5
|
*/
|
|
@@ -80,17 +80,17 @@ export declare class WallHole {
|
|
|
80
80
|
* @param line
|
|
81
81
|
* @returns
|
|
82
82
|
*/
|
|
83
|
-
static
|
|
83
|
+
static forEachStorageType(line: LineSegment<LineUserData>, callBack: (data: HoleData[], key: HoleStorageType) => void): void;
|
|
84
84
|
/** 获取最小
|
|
85
85
|
* @param line
|
|
86
86
|
* @returns
|
|
87
87
|
*/
|
|
88
|
-
static getMinWidth(key:
|
|
88
|
+
static getMinWidth(key: HoleStorageType, type?: HoleType): 0.4 | 0.2 | 0.05 | 0.3;
|
|
89
89
|
/** 清理孔洞
|
|
90
90
|
* @param target
|
|
91
91
|
* @param key
|
|
92
92
|
*/
|
|
93
|
-
static clear(target: LineSegment, key?:
|
|
93
|
+
static clear(target: LineSegment, key?: HoleStorageType): void;
|
|
94
94
|
/** 过滤宽度最小值孔洞
|
|
95
95
|
* @param line
|
|
96
96
|
*/
|
|
@@ -113,7 +113,7 @@ export declare class WallHole {
|
|
|
113
113
|
* @param insertObject
|
|
114
114
|
* @param type
|
|
115
115
|
*/
|
|
116
|
-
static addHole(target: LineSegment<LineUserData>, insertObject: HoleData, type?:
|
|
116
|
+
static addHole(target: LineSegment<LineUserData>, insertObject: HoleData, type?: HoleStorageType): void;
|
|
117
117
|
/** 移除孔洞
|
|
118
118
|
* @param target
|
|
119
119
|
* @param insertObject
|
package/src/index3.js
CHANGED
|
@@ -17733,7 +17733,7 @@ class Drawer extends Pipeline {
|
|
|
17733
17733
|
const color = new THREE.Color(5745151);
|
|
17734
17734
|
const holeLines = ctx.data.flatMap((line2) => {
|
|
17735
17735
|
const holeLines2 = [];
|
|
17736
|
-
WallHole.
|
|
17736
|
+
WallHole.forEachStorageType(line2, (data, key) => {
|
|
17737
17737
|
data.forEach((item) => {
|
|
17738
17738
|
let type = key == "drawWindow" ? "window" : item.type;
|
|
17739
17739
|
const holeLine = WallHole.holeDataToLine(line2, item);
|
|
@@ -17812,6 +17812,7 @@ class Drawer extends Pipeline {
|
|
|
17812
17812
|
const colors = {
|
|
17813
17813
|
default: new THREE.Color(16776960),
|
|
17814
17814
|
// 0xff5722
|
|
17815
|
+
passageEntrance: new THREE.Color(16776960),
|
|
17815
17816
|
window: new THREE.Color(16711935),
|
|
17816
17817
|
door: new THREE.Color(16776960),
|
|
17817
17818
|
beam: new THREE.Color(16711680)
|
|
@@ -17820,7 +17821,7 @@ class Drawer extends Pipeline {
|
|
|
17820
17821
|
const type = line2.userData.type ?? "default";
|
|
17821
17822
|
const color = colors[type] ?? colors.default;
|
|
17822
17823
|
line2.points.forEach((p) => {
|
|
17823
|
-
if (type === "default") {
|
|
17824
|
+
if (type === "default" || type === "passageEntrance") {
|
|
17824
17825
|
ctx.cache.lineDasheds.push(p.x, p.y, 0);
|
|
17825
17826
|
ctx.cache.lineDashedColor.push(color.r, color.g, color.b);
|
|
17826
17827
|
} else {
|
|
@@ -85,5 +85,5 @@ export declare class Quadtree<T = any> {
|
|
|
85
85
|
* @returns
|
|
86
86
|
*/
|
|
87
87
|
boundsToArray(array?: number[], colors?: number[], recursion?: boolean): number[];
|
|
88
|
-
static from(lines: LineSegment[]): Quadtree<any>;
|
|
88
|
+
static from(lines: LineSegment[], userDataFun?: (line: LineSegment, index: number) => any): Quadtree<any>;
|
|
89
89
|
}
|