build-dxf 0.1.155 → 0.1.157
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
|
@@ -9711,7 +9711,7 @@ class DoubleWallFinder {
|
|
|
9711
9711
|
* @returns
|
|
9712
9712
|
*/
|
|
9713
9713
|
static find(lines, obstacle = [], esp = 0.4) {
|
|
9714
|
-
lines = LineSegmentUtils.GroupBuilder(LineSegmentUtils.group(lines, (
|
|
9714
|
+
lines = LineSegmentUtils.GroupBuilder(LineSegmentUtils.group(lines, (_line) => "lines")).handle("lines", (lines2) => {
|
|
9715
9715
|
const parallelAxis = lines2[0], verticalAxis = parallelAxis.clone().rotate(Math.PI * 0.5), [group1, group2] = LineSegmentUtils.groupByParallelToAxis(lines2, lines2[0], 5), newLines1 = this.group(group1, parallelAxis, verticalAxis, esp), newLines2 = this.group(group2, verticalAxis, parallelAxis, esp), appendLines = newLines1.concat(newLines2);
|
|
9716
9716
|
lines2 = lines2.concat(appendLines);
|
|
9717
9717
|
return lines2;
|
|
@@ -22947,12 +22947,71 @@ function beamSupportLine(lines, {}) {
|
|
|
22947
22947
|
const line2 = list[0];
|
|
22948
22948
|
const point2 = line2.projectPoint(center, false);
|
|
22949
22949
|
line.userData.expansionWidth = point2.distance(center);
|
|
22950
|
-
line.userData.expansionDirction = point2.directionFrom(center);
|
|
22950
|
+
line.userData.expansionDirction = point2.directionFrom(center).toJson2D();
|
|
22951
22951
|
}
|
|
22952
22952
|
}
|
|
22953
22953
|
});
|
|
22954
22954
|
return lines;
|
|
22955
22955
|
}
|
|
22956
|
+
function roomTest(trajectory2) {
|
|
22957
|
+
return (lines) => {
|
|
22958
|
+
const doubleLines = lines.filter((line) => WH.isDouble(line));
|
|
22959
|
+
if (WH.isPairing(doubleLines)) {
|
|
22960
|
+
return false;
|
|
22961
|
+
}
|
|
22962
|
+
const ply = Polygon.fromByLinePath(lines);
|
|
22963
|
+
if (trajectory2) {
|
|
22964
|
+
let has = Object.keys(trajectory2).some((k) => {
|
|
22965
|
+
const p2 = trajectory2[k];
|
|
22966
|
+
if (ply.pointWithin(p2)) return true;
|
|
22967
|
+
return false;
|
|
22968
|
+
});
|
|
22969
|
+
if (!has) return false;
|
|
22970
|
+
}
|
|
22971
|
+
return true;
|
|
22972
|
+
};
|
|
22973
|
+
}
|
|
22974
|
+
function findRooms(lines, trajectory2) {
|
|
22975
|
+
lines = lines.map((line) => line.clone());
|
|
22976
|
+
lines = splitIntersectedLine(lines, 0);
|
|
22977
|
+
const rooms = [];
|
|
22978
|
+
const maxiCircles = new MaxiCircles();
|
|
22979
|
+
LineSegmentUtils.groupByPath(lines).forEach((group2) => {
|
|
22980
|
+
const removeSet = findDiscretePointLine2(group2, null, true);
|
|
22981
|
+
lines = group2.filter((line) => !removeSet.has(line) && !line.userData.isBayWindow);
|
|
22982
|
+
const circles = maxiCircles.miniCircle(lines).circles.filter(roomTest(trajectory2));
|
|
22983
|
+
const ploys = circles.map(((p2) => Polygon.fromByLinePath(p2)));
|
|
22984
|
+
ploys.forEach((ploy, i) => {
|
|
22985
|
+
const xList = [];
|
|
22986
|
+
const yList = [];
|
|
22987
|
+
ploy.forEach((p2) => {
|
|
22988
|
+
xList.push(p2.x);
|
|
22989
|
+
yList.push(p2.y);
|
|
22990
|
+
});
|
|
22991
|
+
const minX = Math.min(...xList), maxX = Math.max(...xList), minY = Math.min(...yList), maxY = Math.max(...yList), center = new Point((maxX - minX) * 0.5 + minX, (maxY - minY) * 0.5 + minY);
|
|
22992
|
+
rooms.push({
|
|
22993
|
+
lines: circles[i],
|
|
22994
|
+
ploy,
|
|
22995
|
+
center
|
|
22996
|
+
});
|
|
22997
|
+
});
|
|
22998
|
+
});
|
|
22999
|
+
return rooms;
|
|
23000
|
+
}
|
|
23001
|
+
function removeRoomSundries(lines, { trajectory: trajectory2 }) {
|
|
23002
|
+
if (trajectory2) {
|
|
23003
|
+
const rooms = findRooms(lines, trajectory2), counterMap = new CounterMap();
|
|
23004
|
+
findDiscretePoint(lines).forEach((l) => counterMap.increment(l));
|
|
23005
|
+
const ls2 = counterMap.getByCount(2), removeLines = ls2.filter((line) => {
|
|
23006
|
+
const center = line.center;
|
|
23007
|
+
return !!rooms.find((room) => {
|
|
23008
|
+
return room.ploy.pointWithin(center) && !room.lines.find((l) => l == line);
|
|
23009
|
+
});
|
|
23010
|
+
}), set2 = new Set(removeLines);
|
|
23011
|
+
lines = lines.filter((line) => !set2.has(line));
|
|
23012
|
+
}
|
|
23013
|
+
return lines;
|
|
23014
|
+
}
|
|
22956
23015
|
const builtinFun = {
|
|
22957
23016
|
init,
|
|
22958
23017
|
DoorToHole: doorToHole,
|
|
@@ -22975,7 +23034,8 @@ const builtinFun = {
|
|
|
22975
23034
|
/** 移除与双线墙链接的短线段
|
|
22976
23035
|
*/
|
|
22977
23036
|
RemoveShortDoubleWall: removeShortDoubleWall,
|
|
22978
|
-
BeamSupportLine: beamSupportLine
|
|
23037
|
+
BeamSupportLine: beamSupportLine,
|
|
23038
|
+
RemoveRoomSundries: removeRoomSundries
|
|
22979
23039
|
};
|
|
22980
23040
|
const TYPE = "LINE";
|
|
22981
23041
|
class LinePipeline extends Pipeline {
|
|
@@ -23466,51 +23526,6 @@ class CorrectionDxf extends Dxf {
|
|
|
23466
23526
|
return this.rotateCorrCad?.downloadDxf(filename, unit);
|
|
23467
23527
|
}
|
|
23468
23528
|
}
|
|
23469
|
-
function roomTest(trajectory2) {
|
|
23470
|
-
return (lines) => {
|
|
23471
|
-
const doubleLines = lines.filter((line) => WH.isDouble(line));
|
|
23472
|
-
if (WH.isPairing(doubleLines)) {
|
|
23473
|
-
return false;
|
|
23474
|
-
}
|
|
23475
|
-
const ply = Polygon.fromByLinePath(lines);
|
|
23476
|
-
if (trajectory2) {
|
|
23477
|
-
let has = Object.keys(trajectory2).some((k) => {
|
|
23478
|
-
const p2 = trajectory2[k];
|
|
23479
|
-
if (ply.pointWithin(p2)) return true;
|
|
23480
|
-
return false;
|
|
23481
|
-
});
|
|
23482
|
-
if (!has) return false;
|
|
23483
|
-
}
|
|
23484
|
-
return true;
|
|
23485
|
-
};
|
|
23486
|
-
}
|
|
23487
|
-
function findRooms(lines, trajectory2) {
|
|
23488
|
-
lines = lines.map((line) => line.clone());
|
|
23489
|
-
lines = splitIntersectedLine(lines, 0);
|
|
23490
|
-
const rooms = [];
|
|
23491
|
-
const maxiCircles = new MaxiCircles();
|
|
23492
|
-
LineSegmentUtils.groupByPath(lines).forEach((group2) => {
|
|
23493
|
-
const removeSet = findDiscretePointLine2(group2, null, true);
|
|
23494
|
-
lines = group2.filter((line) => !removeSet.has(line) && !line.userData.isBayWindow);
|
|
23495
|
-
const circles = maxiCircles.miniCircle(lines).circles.filter(roomTest(trajectory2));
|
|
23496
|
-
const ploys = circles.map(((p2) => Polygon.fromByLinePath(p2)));
|
|
23497
|
-
ploys.forEach((ploy, i) => {
|
|
23498
|
-
const xList = [];
|
|
23499
|
-
const yList = [];
|
|
23500
|
-
ploy.forEach((p2) => {
|
|
23501
|
-
xList.push(p2.x);
|
|
23502
|
-
yList.push(p2.y);
|
|
23503
|
-
});
|
|
23504
|
-
const minX = Math.min(...xList), maxX = Math.max(...xList), minY = Math.min(...yList), maxY = Math.max(...yList), center = new Point((maxX - minX) * 0.5 + minX, (maxY - minY) * 0.5 + minY);
|
|
23505
|
-
rooms.push({
|
|
23506
|
-
lines: circles[i],
|
|
23507
|
-
ploy,
|
|
23508
|
-
center
|
|
23509
|
-
});
|
|
23510
|
-
});
|
|
23511
|
-
});
|
|
23512
|
-
return rooms;
|
|
23513
|
-
}
|
|
23514
23529
|
class ThreeVJia extends Component {
|
|
23515
23530
|
static name = "ThreeVJia";
|
|
23516
23531
|
lineSegments = [];
|
|
@@ -23998,7 +24013,7 @@ async function buildJson(opt, dxfSystem2 = new DxfSystem()) {
|
|
|
23998
24013
|
dxfSystem2.Dxf.linePipeline.add(LinePipeline.builtin.init).add(LinePipeline.builtin.WallHeightHandle).add(LinePipeline.builtin.DoorToHole);
|
|
23999
24014
|
doorFind && dxfSystem2.Dxf.linePipeline.add(LinePipeline.builtin.DoorFind);
|
|
24000
24015
|
if (opt.axisAlignCorr !== false) {
|
|
24001
|
-
dxfSystem2.Dxf.linePipeline.add(LinePipeline.builtin.AxisAlignCorr).add(LinePipeline.builtin.RemoveShortDoubleWall).add(LinePipeline.builtin.BeamSupportLine);
|
|
24016
|
+
dxfSystem2.Dxf.linePipeline.add(LinePipeline.builtin.AxisAlignCorr).add(LinePipeline.builtin.RemoveShortDoubleWall).add(LinePipeline.builtin.BeamSupportLine).add(LinePipeline.builtin.RemoveRoomSundries);
|
|
24002
24017
|
}
|
|
24003
24018
|
if (trajectory2) {
|
|
24004
24019
|
if (typeof trajectory2 === "string") {
|
|
@@ -8,6 +8,7 @@ import { removeShortDoubleWall } from './remove-short-double-wall';
|
|
|
8
8
|
import { doorToHole } from './door-to-hole';
|
|
9
9
|
import { LineSegment } from '../../../../utils/algorithms/LineSegment';
|
|
10
10
|
import { beamSupportLine } from './beam-support-line';
|
|
11
|
+
import { removeRoomSundries } from './remove-room-sundries';
|
|
11
12
|
/**
|
|
12
13
|
* 默认提供的预处理函数
|
|
13
14
|
*/
|
|
@@ -34,4 +35,5 @@ export declare const builtinFun: {
|
|
|
34
35
|
*/
|
|
35
36
|
RemoveShortDoubleWall: typeof removeShortDoubleWall;
|
|
36
37
|
BeamSupportLine: typeof beamSupportLine;
|
|
38
|
+
RemoveRoomSundries: typeof removeRoomSundries;
|
|
37
39
|
};
|
|
@@ -13,6 +13,7 @@ export declare class LinePipeline<T = SetDataOption> extends Pipeline<LineSegmen
|
|
|
13
13
|
DoorSpaceHandle: typeof import('./builtin/door-space-handle').doorSpaceHandle;
|
|
14
14
|
RemoveShortDoubleWall: typeof import('./builtin/remove-short-double-wall').removeShortDoubleWall;
|
|
15
15
|
BeamSupportLine: typeof import('./builtin/beam-support-line').beamSupportLine;
|
|
16
|
+
RemoveRoomSundries: typeof import('./builtin/remove-room-sundries').removeRoomSundries;
|
|
16
17
|
};
|
|
17
18
|
constructor();
|
|
18
19
|
add(handle: (lines: LineSegment<LineUserData>[], option: T) => LineSegment<LineUserData>[]): this;
|