build-dxf 0.1.152 → 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 CHANGED
@@ -1,49 +1,49 @@
1
- {
2
- "name": "build-dxf",
3
- "version": "0.1.152",
4
- "description": "",
5
- "main": "./src/index.js",
6
- "types": "./src/index.d.ts",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "exports": {
11
- ".": {
12
- "import": {
13
- "types": "./src/build.d.ts",
14
- "default": "./src/index.js",
15
- "style": "./src/index.css"
16
- },
17
- "require": {
18
- "types": "./src/build.d.ts",
19
- "default": "./src/index.js"
20
- }
21
- },
22
- "./RenderPlugin": {
23
- "import": {
24
- "types": "./src/utils/DxfSystem/plugin/RenderPlugin/index.d.ts",
25
- "default": "./src/index2.js"
26
- },
27
- "require": {
28
- "types": "./src/index.d.ts",
29
- "default": "./src/index2.js"
30
- }
31
- },
32
- "./index.css": "./src/index.css"
33
- },
34
- "style": "src/index.css",
35
- "dependencies": {
36
- "@tweenjs/tween.js": ">=25.0.0",
37
- "clipper-lib": ">=6.4.2",
38
- "dxf-writer": ">=1.18.4",
39
- "vue": ">=3.0.0",
40
- "canvas": "3.2.0",
41
- "three-mesh-bvh": "^0.6.6",
42
- "three-bvh-csg": ">=0.0.17",
43
- "three-csg-ts": ">=3.2.0",
44
- "three": ">=0.181.0",
45
- "node-three-gltf": "2.1.0"
46
- },
47
- "author": "夏过初秋",
48
- "license": "UNLICENSED"
49
- }
1
+ {
2
+ "name": "build-dxf",
3
+ "version": "0.1.154",
4
+ "description": "",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./src/build.d.ts",
14
+ "default": "./src/index.js",
15
+ "style": "./src/index.css"
16
+ },
17
+ "require": {
18
+ "types": "./src/build.d.ts",
19
+ "default": "./src/index.js"
20
+ }
21
+ },
22
+ "./RenderPlugin": {
23
+ "import": {
24
+ "types": "./src/utils/DxfSystem/plugin/RenderPlugin/index.d.ts",
25
+ "default": "./src/index2.js"
26
+ },
27
+ "require": {
28
+ "types": "./src/index.d.ts",
29
+ "default": "./src/index2.js"
30
+ }
31
+ },
32
+ "./index.css": "./src/index.css"
33
+ },
34
+ "style": "src/index.css",
35
+ "dependencies": {
36
+ "@tweenjs/tween.js": ">=25.0.0",
37
+ "clipper-lib": ">=6.4.2",
38
+ "dxf-writer": ">=1.18.4",
39
+ "vue": ">=3.0.0",
40
+ "canvas": "3.2.0",
41
+ "three-mesh-bvh": "^0.6.6",
42
+ "three-bvh-csg": ">=0.0.17",
43
+ "three-csg-ts": ">=3.2.0",
44
+ "three": ">=0.181.0",
45
+ "node-three-gltf": "2.1.0"
46
+ },
47
+ "author": "夏过初秋",
48
+ "license": "UNLICENSED"
49
+ }
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) => line.userData.isBalconyRailing ? "balconyRailing" : "lines")).handle("lines", (lines2) => {
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) {
@@ -12667,8 +12528,18 @@ class BayWindow {
12667
12528
  }
12668
12529
  }
12669
12530
  }
12670
- this.bayWindowGroup.name = `飘窗_${i}`;
12531
+ const num = Number(i) + 1;
12532
+ this.bayWindowGroup.name = `飘窗_${num}`;
12671
12533
  this.bayWindowGroup.userData.category = "bayWindow";
12534
+ this.bayWindowGroup.userData.width = data[i].data.windowWidth;
12535
+ this.bayWindowGroup.userData.height = data[i].data.height2;
12536
+ this.bayWindowGroup.userData.groundHeight = data[i].data.height3;
12537
+ this.bayWindowGroup.userData.distanceToTheTop = data[i].data.height1;
12538
+ for (const w in data[i].lines) {
12539
+ if (data[i].lines[w].userData.isWindow) {
12540
+ this.bayWindowGroup.userData.depth = data[i].dottedLine.distanceToSegment(data[i].lines[w]);
12541
+ }
12542
+ }
12672
12543
  Scenario.Instance.group.add(this.bayWindowGroup);
12673
12544
  }
12674
12545
  }
@@ -13455,8 +13326,8 @@ class BayWindow {
13455
13326
  let height2 = Scenario.Instance.height + objData.height3 + objData.height2;
13456
13327
  mesh.position.z = height1;
13457
13328
  mesh2.position.z = height2;
13458
- Scenario.Instance?.group.add(mesh);
13459
- Scenario.Instance?.group.add(mesh2);
13329
+ this.bayWindowGroup.add(mesh);
13330
+ this.bayWindowGroup.add(mesh2);
13460
13331
  }
13461
13332
  // 共用线处理
13462
13333
  // sharedLineProcessing(sharedLine: any, data: any) {
@@ -14259,6 +14130,11 @@ class Scenario {
14259
14130
  installBalconys(data, index2) {
14260
14131
  let balconyGroup = new Group$1();
14261
14132
  balconyGroup.name = `阳台${index2}`;
14133
+ balconyGroup.userData.category = "balcony";
14134
+ balconyGroup.userData.height = data.userData.height;
14135
+ balconyGroup.userData.width = data.length;
14136
+ balconyGroup.userData.depth = 0;
14137
+ balconyGroup.userData.groundHeight = 0;
14262
14138
  const point1 = new THREE.Vector3(data.start.x, data.start.y, 0);
14263
14139
  const point2 = new THREE.Vector3(data.end.x, data.end.y, 0);
14264
14140
  new THREE.Vector3(data.center.x, data.center.y, 0);
@@ -14282,7 +14158,7 @@ class Scenario {
14282
14158
  menModel.scale.set(distance2 / size2.x, height / size2.y, wallWidth / size2.z);
14283
14159
  menModel.position.set(data.center.x, data.center.y, this.height);
14284
14160
  menModel.name = `阳台_${index2}`;
14285
- menModel.userData.category = "balcony";
14161
+ menModel.userData.category = "balcony_";
14286
14162
  balconyGroup.add(menModel);
14287
14163
  this.group.add(balconyGroup);
14288
14164
  }
@@ -14317,7 +14193,7 @@ class Scenario {
14317
14193
  balconyModel.scale.set(spacing / size2.x, height / size2.y, wallWidth / size2.z);
14318
14194
  balconyModel.position.set(center.x, center.y, this.height);
14319
14195
  balconyModel.name = `阳台_${index2}`;
14320
- balconyModel.userData.category = "balcony";
14196
+ balconyModel.userData.category = "balcony_";
14321
14197
  balconyGroup.add(balconyModel);
14322
14198
  }
14323
14199
  this.group.add(balconyGroup);
@@ -14751,14 +14627,28 @@ class Scenario {
14751
14627
  }
14752
14628
  // 生成梁模型
14753
14629
  generateBeamModel(line) {
14754
- if (!line.userData.expansionDirction) return null;
14755
- const directionX = line.userData.expansionDirction.x * line.userData.expansionWidth;
14756
- const directionY = line.userData.expansionDirction.y * line.userData.expansionWidth;
14757
- let pointStart = new THREE.Vector3(line.start.x, line.start.y, this.height);
14758
- let pointEnd = new THREE.Vector3(line.end.x, line.end.y, this.height);
14759
- let startExpansion = new THREE.Vector3(pointStart.x + directionX, pointStart.y + directionY, this.height);
14760
- let endExpansion = new THREE.Vector3(pointEnd.x + directionX, pointEnd.y + directionY, this.height);
14761
- const basePoints = [pointStart, pointEnd, endExpansion, startExpansion];
14630
+ let basePoints;
14631
+ if (!line.userData.expansionWidth) {
14632
+ let wallWidth;
14633
+ if (line.userData.wallWidth) {
14634
+ wallWidth = line.userData.wallWidth;
14635
+ } else {
14636
+ wallWidth = 0.06;
14637
+ }
14638
+ const MobileX = this.angleToXAxisDegrees(line.start.x, line.start.y, line.end.x, line.end.y, wallWidth, true);
14639
+ const MobileY = this.angleToXAxisDegrees(line.start.x, line.start.y, line.end.x, line.end.y, wallWidth, false);
14640
+ let startingPoint = this.xinLine(MobileX, MobileY, line.start, 0);
14641
+ let finishLine = this.xinLine(MobileX, MobileY, line.end, 1);
14642
+ basePoints = [startingPoint[0], startingPoint[1], finishLine[1], finishLine[0]];
14643
+ } else {
14644
+ const directionX = line.userData.expansionDirction.x * line.userData.expansionWidth;
14645
+ const directionY = line.userData.expansionDirction.y * line.userData.expansionWidth;
14646
+ let pointStart = new THREE.Vector3(line.start.x, line.start.y, this.height);
14647
+ let pointEnd = new THREE.Vector3(line.end.x, line.end.y, this.height);
14648
+ let startExpansion = new THREE.Vector3(pointStart.x + directionX, pointStart.y + directionY, this.height);
14649
+ let endExpansion = new THREE.Vector3(pointEnd.x + directionX, pointEnd.y + directionY, this.height);
14650
+ basePoints = [pointStart, pointEnd, endExpansion, startExpansion];
14651
+ }
14762
14652
  const geometry = this.createParallelepipedFromBase(basePoints, line.userData.height);
14763
14653
  const material = new THREE.MeshStandardMaterial({
14764
14654
  // color: 0x4f90d4,
@@ -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 {};
@@ -74,7 +74,7 @@ export default class Scenario {
74
74
  overhangWallOffset(data: any, index: string, height: number): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
75
75
  dashedLineCeilingTreatment(data: any, index: number | string, item: any): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
76
76
  overallTreatmentOfSingleLineWalls(data: any): void;
77
- generateBeamModel(line: any): Brush | null;
77
+ generateBeamModel(line: any): Brush;
78
78
  generateColumnModel(data: any, lines: any, Height: number): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
79
79
  createAPlane(lines: LineSegment<Record<string, any>>[], menList: LineSegment<Record<string, any>>[]): void;
80
80
  modelLoader(): Promise<void>;