build-dxf 0.1.153 → 0.1.154
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 +5 -144
- package/src/dxf-system/utils/DoubleWallFinder.d.ts +0 -35
package/package.json
CHANGED
package/src/build.js
CHANGED
|
@@ -9665,148 +9665,6 @@ class BuildGroup {
|
|
|
9665
9665
|
}
|
|
9666
9666
|
}
|
|
9667
9667
|
class DoubleWallFinder {
|
|
9668
|
-
static errorAngle = 4;
|
|
9669
|
-
/** 线段投影分析
|
|
9670
|
-
* @param index
|
|
9671
|
-
* @param sourceLineSegment
|
|
9672
|
-
* @param lineSegmentList
|
|
9673
|
-
* @returns
|
|
9674
|
-
*/
|
|
9675
|
-
static projectionAnalysis(index2, sourceIndex, sourceLineSegment, lineSegmentList) {
|
|
9676
|
-
const temLineSegment = lineSegmentList[index2], direct = sourceLineSegment.direction(), temDirect = temLineSegment.direction(), angle = direct.angle(temDirect, { unit: "degree", range: "180" });
|
|
9677
|
-
if (angle < this.errorAngle || angle > 180 - this.errorAngle) {
|
|
9678
|
-
let data;
|
|
9679
|
-
let dist = sourceLineSegment.distanceToSegment(temLineSegment);
|
|
9680
|
-
const p1 = temLineSegment.projectLineSegment(sourceLineSegment), p2 = sourceLineSegment.projectLineSegment(temLineSegment);
|
|
9681
|
-
if (p1.length > p2.length) {
|
|
9682
|
-
data = {
|
|
9683
|
-
target: temLineSegment,
|
|
9684
|
-
targetIndex: index2,
|
|
9685
|
-
source: sourceLineSegment,
|
|
9686
|
-
sourceIndex,
|
|
9687
|
-
project: p1,
|
|
9688
|
-
project2: p2,
|
|
9689
|
-
minDistance: dist
|
|
9690
|
-
};
|
|
9691
|
-
} else {
|
|
9692
|
-
data = {
|
|
9693
|
-
target: sourceLineSegment,
|
|
9694
|
-
targetIndex: sourceIndex,
|
|
9695
|
-
source: temLineSegment,
|
|
9696
|
-
sourceIndex: index2,
|
|
9697
|
-
project: p2,
|
|
9698
|
-
project2: p1,
|
|
9699
|
-
minDistance: dist
|
|
9700
|
-
};
|
|
9701
|
-
}
|
|
9702
|
-
if (!data || data.project.length < 0.08 || data.project2.length < 0.08) return;
|
|
9703
|
-
return data;
|
|
9704
|
-
}
|
|
9705
|
-
}
|
|
9706
|
-
/** 查找
|
|
9707
|
-
* @param lines
|
|
9708
|
-
* @param wallWidth
|
|
9709
|
-
* @returns
|
|
9710
|
-
*/
|
|
9711
|
-
static findDoubleLine(lines, wallWidth = 0.4) {
|
|
9712
|
-
let walls = lines.filter((line) => !line.userData.isDoor), visited = /* @__PURE__ */ new Set(), resultList = [];
|
|
9713
|
-
walls = walls.filter((line) => !line.userData.isWindowWall);
|
|
9714
|
-
let quadtree = new Quadtree(Box2.fromByLineSegment(...walls));
|
|
9715
|
-
walls.forEach((line, index2) => quadtree.insert({ line, userData: index2 }));
|
|
9716
|
-
walls.forEach((sourceLineSegment, i) => {
|
|
9717
|
-
const rectangle = Rectangle.fromByLineSegment(sourceLineSegment, wallWidth * 2, false, -0.01), ids = quadtree.queryRect(rectangle).map((i2) => i2.userData).filter((index2) => index2 !== i);
|
|
9718
|
-
ids.forEach((id) => {
|
|
9719
|
-
try {
|
|
9720
|
-
if (visited.has(`${i}-${id}`) || visited.has(`${id}-${i}`)) return;
|
|
9721
|
-
const res = this.projectionAnalysis(id, i, sourceLineSegment, walls);
|
|
9722
|
-
if (res) resultList.push(res);
|
|
9723
|
-
visited.add(`${i}-${id}`);
|
|
9724
|
-
} catch (error) {
|
|
9725
|
-
console.log(error);
|
|
9726
|
-
}
|
|
9727
|
-
});
|
|
9728
|
-
});
|
|
9729
|
-
resultList.forEach((result) => {
|
|
9730
|
-
const project0 = result.project, project1 = result.project2;
|
|
9731
|
-
if (project0.angle(project1, { unit: "degree", range: "180" }) > 135) {
|
|
9732
|
-
project1.points = [project1.points[1], project1.points[0]];
|
|
9733
|
-
}
|
|
9734
|
-
});
|
|
9735
|
-
return {
|
|
9736
|
-
resultList,
|
|
9737
|
-
walls,
|
|
9738
|
-
quadtree
|
|
9739
|
-
};
|
|
9740
|
-
}
|
|
9741
|
-
/** 补双线墙壁
|
|
9742
|
-
* @param lines
|
|
9743
|
-
* @param wallWidth
|
|
9744
|
-
* @returns
|
|
9745
|
-
*/
|
|
9746
|
-
static complementSide(lines, obstacleAegment = [], wallWidth = 0.4) {
|
|
9747
|
-
const otherLines = [];
|
|
9748
|
-
lines = lines.filter((line) => {
|
|
9749
|
-
if (line.userData.isBayWindow || line.userData.isBalconyRailing || LineGroupType.hasType(line, "bayWindow") && line.userData.isWindow) {
|
|
9750
|
-
otherLines.push(line);
|
|
9751
|
-
return false;
|
|
9752
|
-
}
|
|
9753
|
-
return true;
|
|
9754
|
-
});
|
|
9755
|
-
let { resultList, quadtree } = this.findDoubleLine(lines, wallWidth), removeLines = /* @__PURE__ */ new Set(), clipingMap = /* @__PURE__ */ new Map(), appendLines = [];
|
|
9756
|
-
function addClipingMap(line, line1) {
|
|
9757
|
-
if (!clipingMap.has(line)) clipingMap.set(line, []);
|
|
9758
|
-
const startProj = line.projectPoint(line1.start);
|
|
9759
|
-
const endProj = line.projectPoint(line1.end);
|
|
9760
|
-
const list = clipingMap.get(line);
|
|
9761
|
-
if (startProj) list.push(startProj);
|
|
9762
|
-
if (endProj) list.push(endProj);
|
|
9763
|
-
removeLines.add(line);
|
|
9764
|
-
quadtree.remove(line);
|
|
9765
|
-
}
|
|
9766
|
-
resultList.forEach((result) => {
|
|
9767
|
-
const project0 = result.project, project1 = result.project2, line0 = result.source, line1 = result.target;
|
|
9768
|
-
const newLine1 = new LineSegment(project0.start.clone(), project1.start.clone());
|
|
9769
|
-
const newLine2 = new LineSegment(project0.end.clone(), project1.end.clone());
|
|
9770
|
-
newLine1.userData.height = line0.userData.height;
|
|
9771
|
-
newLine1.userData.rooftopPz = line0.userData.rooftopPz;
|
|
9772
|
-
newLine2.userData.height = line1.userData.height;
|
|
9773
|
-
newLine2.userData.rooftopPz = line1.userData.rooftopPz;
|
|
9774
|
-
appendLines.push(newLine1, newLine2);
|
|
9775
|
-
addClipingMap(line0, project0);
|
|
9776
|
-
addClipingMap(line1, project1);
|
|
9777
|
-
});
|
|
9778
|
-
clipingMap.forEach((list, line) => {
|
|
9779
|
-
const newLines = LineSegmentUtils.clippingByPoints(line, list);
|
|
9780
|
-
newLines.forEach((newLine) => {
|
|
9781
|
-
newLine.userData.height = line.userData.height;
|
|
9782
|
-
newLine.userData.rooftopPz = line.userData.rooftopPz;
|
|
9783
|
-
});
|
|
9784
|
-
lines.push(...newLines);
|
|
9785
|
-
});
|
|
9786
|
-
lines = lines.filter((line) => !removeLines.has(line));
|
|
9787
|
-
quadtree.clear();
|
|
9788
|
-
quadtree = Quadtree.from([...lines, ...otherLines, ...obstacleAegment]);
|
|
9789
|
-
appendLines = splitIntersectedLine(appendLines, 1e-9);
|
|
9790
|
-
appendLines.flatMap((line) => {
|
|
9791
|
-
const queryLines = quadtree.queryRect(line.toRectangle(1e-3, "butt")).filter((item) => item.line.isParallelTo(line)).map((item) => item.line);
|
|
9792
|
-
if (queryLines.length) {
|
|
9793
|
-
const newLines = LineSegmentUtils.clippingByLines(line, queryLines);
|
|
9794
|
-
if (newLines) return newLines.forEach((newLine) => {
|
|
9795
|
-
newLine.userData.height = line.userData.height;
|
|
9796
|
-
newLine.userData.rooftopPz = line.userData.rooftopPz;
|
|
9797
|
-
quadtree.insert(newLine);
|
|
9798
|
-
lines.push(newLine);
|
|
9799
|
-
});
|
|
9800
|
-
}
|
|
9801
|
-
quadtree.insert(line);
|
|
9802
|
-
lines.push(line);
|
|
9803
|
-
});
|
|
9804
|
-
quadtree.clear();
|
|
9805
|
-
lines.push(...otherLines);
|
|
9806
|
-
lines = splitIntersectedLine(lines, 1e-9);
|
|
9807
|
-
PointUtils.adsorb(lines.flatMap((line) => line.points), 1e-4);
|
|
9808
|
-
return lines.filter((line) => line.length > 1e-9);
|
|
9809
|
-
}
|
|
9810
9668
|
/**
|
|
9811
9669
|
* @param lines
|
|
9812
9670
|
* @param parallelAxis
|
|
@@ -9854,7 +9712,7 @@ class DoubleWallFinder {
|
|
|
9854
9712
|
*/
|
|
9855
9713
|
static find(lines, obstacle = [], esp = 0.4) {
|
|
9856
9714
|
lines = LineSegmentUtils.GroupBuilder(LineSegmentUtils.group(lines, (line) => WallHole.isBeam(line) ? "beam" : "lines")).handle("lines", (lines2) => {
|
|
9857
|
-
const parallelAxis = lines2[0], verticalAxis = parallelAxis.clone().rotate(Math.PI * 0.5), [group1, group2] = LineSegmentUtils.groupByParallelToAxis(lines2, lines2[0]), newLines1 = this.group(group1, parallelAxis, verticalAxis, esp), newLines2 = this.group(group2, verticalAxis, parallelAxis, esp), appendLines = newLines1.concat(newLines2);
|
|
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);
|
|
9858
9716
|
lines2 = lines2.concat(appendLines);
|
|
9859
9717
|
return lines2;
|
|
9860
9718
|
}).merge();
|
|
@@ -12140,7 +11998,10 @@ function correction(lines, targettLine, option) {
|
|
|
12140
11998
|
const bayWindow = lines.filter((line) => line.userData.isBayWindow).map((line) => line.center);
|
|
12141
11999
|
lines = splitIntersectedLine(lines, 1e-9);
|
|
12142
12000
|
WallHole.filterIllegal(lines).merge(lines);
|
|
12143
|
-
lines = LineSegmentUtils.GroupBuilder(LineSegmentUtils.group(lines, (line) =>
|
|
12001
|
+
lines = LineSegmentUtils.GroupBuilder(LineSegmentUtils.group(lines, (line) => {
|
|
12002
|
+
if (WallHole.isBeam(line)) return "beam";
|
|
12003
|
+
return line.userData.isBalconyRailing ? "balconyRailing" : "lines";
|
|
12004
|
+
})).handle("lines", (lines2) => {
|
|
12144
12005
|
lines2 = AlignToParallelSegments.align(lines2, {
|
|
12145
12006
|
onMergeLine: mergeLineUserData,
|
|
12146
12007
|
onGroup(group2, projValues, axis) {
|
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
import { LineSegment } from '../../utils/algorithms/LineSegment';
|
|
2
|
-
import { Quadtree } from '../../utils/algorithms/Quadtree';
|
|
3
2
|
import { LineUserData } from '../type';
|
|
4
|
-
type ProjectionAnalysisResult = {
|
|
5
|
-
source: LineSegment;
|
|
6
|
-
sourceIndex: number;
|
|
7
|
-
target: LineSegment;
|
|
8
|
-
targetIndex: number;
|
|
9
|
-
project: LineSegment;
|
|
10
|
-
project2: LineSegment;
|
|
11
|
-
minDistance: number;
|
|
12
|
-
};
|
|
13
3
|
export declare class DoubleWallFinder {
|
|
14
|
-
static errorAngle: number;
|
|
15
|
-
/** 线段投影分析
|
|
16
|
-
* @param index
|
|
17
|
-
* @param sourceLineSegment
|
|
18
|
-
* @param lineSegmentList
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
|
-
private static projectionAnalysis;
|
|
22
|
-
/** 查找
|
|
23
|
-
* @param lines
|
|
24
|
-
* @param wallWidth
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
static findDoubleLine(lines: LineSegment<LineUserData>[], wallWidth?: number): {
|
|
28
|
-
resultList: ProjectionAnalysisResult[];
|
|
29
|
-
walls: LineSegment<LineUserData>[];
|
|
30
|
-
quadtree: Quadtree<number>;
|
|
31
|
-
};
|
|
32
|
-
/** 补双线墙壁
|
|
33
|
-
* @param lines
|
|
34
|
-
* @param wallWidth
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
static complementSide(lines: LineSegment<LineUserData>[], obstacleAegment?: LineSegment[], wallWidth?: number): LineSegment<LineUserData>[];
|
|
38
4
|
/**
|
|
39
5
|
* @param lines
|
|
40
6
|
* @param parallelAxis
|
|
@@ -56,4 +22,3 @@ export declare class DoubleWallFinder {
|
|
|
56
22
|
*/
|
|
57
23
|
static buildGroup(lineSegments: LineSegment<LineUserData>[]): (LineSegment<Record<string, any>> | LineSegment<LineUserData>)[];
|
|
58
24
|
}
|
|
59
|
-
export {};
|