build-dxf 0.1.150 → 0.1.152

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.150",
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.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
+ }
package/src/build.js CHANGED
@@ -2681,7 +2681,7 @@ class Quadtree {
2681
2681
  }
2682
2682
  return result;
2683
2683
  }
2684
- raycaster(origin, direct, near = 0, far = 10) {
2684
+ raycast(origin, direct, near = 0, far = 10) {
2685
2685
  const result = [];
2686
2686
  const rayBox = new Box2(
2687
2687
  Math.min(origin.x, origin.x + direct.x * far),
@@ -2715,7 +2715,7 @@ class Quadtree {
2715
2715
  }
2716
2716
  if (!this.isLeaf) {
2717
2717
  for (const child of this.children) {
2718
- result.push(...child.raycaster(origin, direct, near, far));
2718
+ result.push(...child.raycast(origin, direct, near, far));
2719
2719
  }
2720
2720
  }
2721
2721
  if (this.depth == 1) result.sort((a2, b4) => a2.distance - b4.distance);
@@ -9955,7 +9955,7 @@ class BoundExt {
9955
9955
  let appendLines = [];
9956
9956
  exteriorLines.forEach((line) => {
9957
9957
  const mode = line.userData.expandDirect, direction = mode === "left" ? line.getRightDirection() : line.getLeftDirection();
9958
- const intersectCount = quadtree.raycaster(line.center, direction, 1e-3, wallWidth).length;
9958
+ const intersectCount = quadtree.raycast(line.center, direction, 1e-3, wallWidth).length;
9959
9959
  if (intersectCount > 0) return;
9960
9960
  line.points.forEach((point2) => {
9961
9961
  const id = point2.hashCode();
@@ -10227,8 +10227,8 @@ function clippingInsertObjectDoubleWall(lines) {
10227
10227
  const wioLine = WallHole.holeDataToLine(line, d2);
10228
10228
  wioLine.setLength(wioLine.length - 4e-3);
10229
10229
  const len = wioLine.length;
10230
- let startResults = quadtree.raycaster(wioLine.start, normal, 1e-4, far).filter((item) => item.targetLine.isParallelTo(wioLine));
10231
- let endResults = quadtree.raycaster(wioLine.end, normal, 1e-4, far).filter((item) => item.targetLine.isParallelTo(wioLine));
10230
+ let startResults = quadtree.raycast(wioLine.start, normal, 1e-4, far).filter((item) => item.targetLine.isParallelTo(wioLine));
10231
+ let endResults = quadtree.raycast(wioLine.end, normal, 1e-4, far).filter((item) => item.targetLine.isParallelTo(wioLine));
10232
10232
  if (startResults.length > 1) startResults = startResults.filter((item) => item.targetLine.projectLineSegment(wioLine).length / len > 0.01);
10233
10233
  if (endResults.length > 1) endResults = endResults.filter((item) => item.targetLine.projectLineSegment(wioLine).length / len > 0.01);
10234
10234
  if (startResults.length === 0 || endResults.length === 0) return;
@@ -13540,6 +13540,7 @@ class Scenario {
13540
13540
  box;
13541
13541
  singleLineWallValue;
13542
13542
  liangNum;
13543
+ zhuNum;
13543
13544
  static _instance;
13544
13545
  static get Instance() {
13545
13546
  return Scenario._instance;
@@ -13552,6 +13553,7 @@ class Scenario {
13552
13553
  this.controls = controls;
13553
13554
  this.axesHelper = new THREE.AxesHelper(20);
13554
13555
  this.liangNum = 0;
13556
+ this.zhuNum = 0;
13555
13557
  this.scene.add(this.axesHelper);
13556
13558
  this.group = null;
13557
13559
  this.closedArray = [];
@@ -13620,6 +13622,7 @@ class Scenario {
13620
13622
  }
13621
13623
  this.group = new Group$1();
13622
13624
  this.liangNum = 0;
13625
+ this.zhuNum = 0;
13623
13626
  this.expandedList = [];
13624
13627
  if (!BayWindow.Instance) new BayWindow();
13625
13628
  BayWindow.Instance.bayWindowExpansion = [];
@@ -13732,7 +13735,14 @@ class Scenario {
13732
13735
  }
13733
13736
  return false;
13734
13737
  });
13735
- const Mesh = this.drawTheModel(E, 0, Number(i), wallHeight, a2[i]);
13738
+ let Mesh;
13739
+ if (a2[i][0].userData.type === "pillar") {
13740
+ Mesh = this.generateColumnModel(E, a2[i], wallHeight);
13741
+ this.group.add(Mesh);
13742
+ continue;
13743
+ } else {
13744
+ Mesh = this.drawTheModel(E, 0, Number(i), wallHeight, a2[i]);
13745
+ }
13736
13746
  if (Mesh) {
13737
13747
  Mesh.material.envMap = texture;
13738
13748
  Mesh.material.needsUpdate = true;
@@ -13835,6 +13845,7 @@ class Scenario {
13835
13845
  const edges = new THREE.EdgesGeometry(geometry);
13836
13846
  new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0 }));
13837
13847
  if (colorValue && liangOriginalData) {
13848
+ cube.material.color = new THREE.Color(5214420);
13838
13849
  const point1 = new THREE.Vector3(liangOriginalData.start.x, liangOriginalData.start.y, 0);
13839
13850
  const point2 = new THREE.Vector3(liangOriginalData.end.x, liangOriginalData.end.y, 0);
13840
13851
  this.liangNum = this.liangNum + 1;
@@ -13891,8 +13902,8 @@ class Scenario {
13891
13902
  new THREE.LineBasicMaterial({
13892
13903
  color: 65280
13893
13904
  });
13894
- const MobileX = this.angleToXAxisDegrees(data.start.x, data.start.y, data.end.x, data.end.y, DEFAULT_WALL_HALF_WIDTH + 0.01, true);
13895
- const MobileY = this.angleToXAxisDegrees(data.start.x, data.start.y, data.end.x, data.end.y, DEFAULT_WALL_HALF_WIDTH + 0.01, false);
13905
+ const MobileX = this.angleToXAxisDegrees(data.start.x, data.start.y, data.end.x, data.end.y, DEFAULT_WALL_HALF_WIDTH, true);
13906
+ const MobileY = this.angleToXAxisDegrees(data.start.x, data.start.y, data.end.x, data.end.y, DEFAULT_WALL_HALF_WIDTH, false);
13896
13907
  let startingPoint = this.xinLine(MobileX, MobileY, data.start, 0);
13897
13908
  let finishLine = this.xinLine(MobileX, MobileY, data.end, 1);
13898
13909
  const grid = PointSpatialHash.fromByLines(this.lines);
@@ -14665,7 +14676,20 @@ class Scenario {
14665
14676
  a2 = { start: listS[x].dian, end: listS[Number(x) + 1].dian, isTheFirst: true, index: x };
14666
14677
  }
14667
14678
  const wallHeight = listS[x].wallHeight;
14668
- let Mesh = this.executionOffset(a2, Number(x) / 2, wallHeight, winDraw);
14679
+ let Mesh;
14680
+ let status = false;
14681
+ for (const y in winDraw) {
14682
+ if (winDraw[Number(y)].userData.type === "beam") {
14683
+ status = true;
14684
+ Mesh = this.generateBeamModel(data[Number(x) / 2]);
14685
+ }
14686
+ }
14687
+ if (status) {
14688
+ if (Mesh) this.group.add(Mesh);
14689
+ continue;
14690
+ } else {
14691
+ Mesh = this.executionOffset(a2, Number(x) / 2, wallHeight, winDraw);
14692
+ }
14669
14693
  for (const y in winDraw) {
14670
14694
  if (winDraw[Number(y)].userData.type === "beam") {
14671
14695
  Mesh.userData.start = a2.start;
@@ -14725,6 +14749,96 @@ class Scenario {
14725
14749
  }
14726
14750
  }
14727
14751
  }
14752
+ // 生成梁模型
14753
+ 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];
14762
+ const geometry = this.createParallelepipedFromBase(basePoints, line.userData.height);
14763
+ const material = new THREE.MeshStandardMaterial({
14764
+ // color: 0x4f90d4,
14765
+ color: this.color,
14766
+ side: THREE.DoubleSide
14767
+ });
14768
+ const cube = new THREE.Mesh(geometry, material);
14769
+ const bodyGeometry = this.createParallelepipedFromBase(basePoints, line.userData.rooftopPz);
14770
+ const brush1 = new Brush(cube.geometry);
14771
+ brush1.updateMatrixWorld();
14772
+ const brush2 = new Brush(bodyGeometry);
14773
+ brush2.updateMatrixWorld();
14774
+ const evaluator = new Evaluator();
14775
+ const result = evaluator.evaluate(brush1, brush2, SUBTRACTION);
14776
+ result.material = cube.material;
14777
+ this.liangNum = this.liangNum + 1;
14778
+ result.name = `梁_${this.liangNum}`;
14779
+ result.userData.category = "beam";
14780
+ result.userData.width = line.length;
14781
+ result.userData.depth = line.userData.expansionWidth;
14782
+ result.userData.height = line.userData.height - line.userData.rooftopPz;
14783
+ result.userData.groundHeight = line.userData.rooftopPz;
14784
+ return result;
14785
+ }
14786
+ // 生成柱模型
14787
+ generateColumnModel(data, lines, Height) {
14788
+ console.log(lines);
14789
+ let basePoints = [];
14790
+ for (const i in data) {
14791
+ basePoints.push(new THREE.Vector3(data[i].x, data[i].y, this.height ? this.height : 0));
14792
+ }
14793
+ let longerSide = 0;
14794
+ let shortSide = 100;
14795
+ for (const w in lines) {
14796
+ if (lines[w].length > longerSide) {
14797
+ longerSide = lines[w].length;
14798
+ }
14799
+ if (lines[w].length < shortSide) {
14800
+ shortSide = lines[w].length;
14801
+ }
14802
+ }
14803
+ if (basePoints.length === 4) {
14804
+ const spacing = basePoints[0].distanceTo(basePoints[3]);
14805
+ if (spacing < 5e-3) {
14806
+ return null;
14807
+ } else {
14808
+ const geometry = this.createParallelepipedFromBase(basePoints, Height);
14809
+ const material = new THREE.MeshStandardMaterial({
14810
+ // color: 0xf3feb0,
14811
+ color: this.color,
14812
+ side: THREE.DoubleSide
14813
+ });
14814
+ const cube = new THREE.Mesh(geometry, material);
14815
+ this.zhuNum = this.zhuNum + 1;
14816
+ cube.name = `柱_${this.zhuNum}`;
14817
+ cube.userData.category = "pillar";
14818
+ cube.userData.width = longerSide;
14819
+ cube.userData.depth = shortSide;
14820
+ cube.userData.height = Height;
14821
+ cube.userData.groundHeight = 0;
14822
+ return cube;
14823
+ }
14824
+ } else {
14825
+ const geometry = this.createParallelepipedFromBase(basePoints, Height);
14826
+ const material = new THREE.MeshStandardMaterial({
14827
+ // color: 0xf3feb0,
14828
+ color: this.color,
14829
+ side: THREE.DoubleSide
14830
+ });
14831
+ const cube = new THREE.Mesh(geometry, material);
14832
+ this.zhuNum = this.zhuNum + 1;
14833
+ cube.name = `柱_${this.zhuNum}`;
14834
+ cube.userData.category = "pillar";
14835
+ cube.userData.width = longerSide;
14836
+ cube.userData.depth = shortSide;
14837
+ cube.userData.height = Height;
14838
+ cube.userData.groundHeight = 0;
14839
+ return cube;
14840
+ }
14841
+ }
14728
14842
  //
14729
14843
  createAPlane(lines, menList) {
14730
14844
  const lineList = lines;
@@ -22771,6 +22885,40 @@ function doorToHole(lines, option) {
22771
22885
  });
22772
22886
  return lines;
22773
22887
  }
22888
+ function getBeamNearWallVec(line) {
22889
+ const iterator = WallHole.getIterator(line);
22890
+ for (const hole of iterator) {
22891
+ if ("beamNearWallVec" in hole) return Point.from(hole.beamNearWallVec);
22892
+ }
22893
+ }
22894
+ function beamSupportLine(lines, {}) {
22895
+ const lsh = Quadtree.from(lines);
22896
+ lines.forEach((line) => {
22897
+ if (WallHole.isBeam(line)) {
22898
+ const findLine = line.clone();
22899
+ findLine.setLength(findLine.length - 4e-3);
22900
+ let rectangle = line.toRectangle(2, "butt");
22901
+ const center = findLine.center;
22902
+ const beamNearWallVec = getBeamNearWallVec(line);
22903
+ const list = lsh.queryRect(rectangle).filter((target) => {
22904
+ if (target.line === line) return false;
22905
+ if (!target.line.isParallelTo(findLine, 10)) return false;
22906
+ if (beamNearWallVec) {
22907
+ const dir = target.line.center.directionFrom(center);
22908
+ if (dir.dot(beamNearWallVec) < 0) return false;
22909
+ }
22910
+ return true;
22911
+ }).map((item) => item.line).sort((a2, b4) => a2.distanceToPoint(center) - b4.distanceToPoint(center));
22912
+ if (list.length) {
22913
+ const line2 = list[0];
22914
+ const point2 = line2.projectPoint(center, false);
22915
+ line.userData.expansionWidth = point2.distance(center);
22916
+ line.userData.expansionDirction = point2.directionFrom(center);
22917
+ }
22918
+ }
22919
+ });
22920
+ return lines;
22921
+ }
22774
22922
  const builtinFun = {
22775
22923
  init,
22776
22924
  DoorToHole: doorToHole,
@@ -22792,7 +22940,8 @@ const builtinFun = {
22792
22940
  DoorSpaceHandle: doorSpaceHandle,
22793
22941
  /** 移除与双线墙链接的短线段
22794
22942
  */
22795
- RemoveShortDoubleWall: removeShortDoubleWall
22943
+ RemoveShortDoubleWall: removeShortDoubleWall,
22944
+ BeamSupportLine: beamSupportLine
22796
22945
  };
22797
22946
  const TYPE = "LINE";
22798
22947
  class LinePipeline extends Pipeline {
@@ -23815,7 +23964,7 @@ async function buildJson(opt, dxfSystem2 = new DxfSystem()) {
23815
23964
  dxfSystem2.Dxf.linePipeline.add(LinePipeline.builtin.init).add(LinePipeline.builtin.WallHeightHandle).add(LinePipeline.builtin.DoorToHole);
23816
23965
  doorFind && dxfSystem2.Dxf.linePipeline.add(LinePipeline.builtin.DoorFind);
23817
23966
  if (opt.axisAlignCorr !== false) {
23818
- dxfSystem2.Dxf.linePipeline.add(LinePipeline.builtin.AxisAlignCorr).add(LinePipeline.builtin.RemoveShortDoubleWall);
23967
+ dxfSystem2.Dxf.linePipeline.add(LinePipeline.builtin.AxisAlignCorr).add(LinePipeline.builtin.RemoveShortDoubleWall).add(LinePipeline.builtin.BeamSupportLine);
23819
23968
  }
23820
23969
  if (trajectory2) {
23821
23970
  if (typeof trajectory2 === "string") {
@@ -28,7 +28,7 @@ export interface HoleData {
28
28
  nearDoorId?: number;
29
29
  pair?: string | number;
30
30
  }
31
- export type EntityType = "beams" | "door";
31
+ export type EntityType = "beams" | "door" | "pillar";
32
32
  export type Shape = "line" | "arc" | "polygon";
33
33
  export type WallLineGlobalOption = {
34
34
  uuid?: string;
@@ -55,6 +55,11 @@ export type WallLineGlobalOption = {
55
55
  isDoor?: boolean;
56
56
  doorAutomaticFind?: boolean;
57
57
  doorDirectConnection?: boolean;
58
+ expansionWidth?: number;
59
+ expansionDirction?: {
60
+ x: number;
61
+ y: number;
62
+ };
58
63
  isPassageEntrance?: boolean;
59
64
  topClearance?: number;
60
65
  isVerticalReferenceLine?: boolean;
@@ -0,0 +1,3 @@
1
+ import { LineUserData, SetDataOption } from '../../../type';
2
+ import { LineSegment } from '../../../../utils';
3
+ export declare function beamSupportLine(lines: LineSegment<LineUserData>[], {}: SetDataOption): LineSegment<LineUserData>[];
@@ -7,6 +7,7 @@ import { doorSpaceHandle } from './door-space-handle';
7
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
+ import { beamSupportLine } from './beam-support-line';
10
11
  /**
11
12
  * 默认提供的预处理函数
12
13
  */
@@ -32,4 +33,5 @@ export declare const builtinFun: {
32
33
  /** 移除与双线墙链接的短线段
33
34
  */
34
35
  RemoveShortDoubleWall: typeof removeShortDoubleWall;
36
+ BeamSupportLine: typeof beamSupportLine;
35
37
  };
@@ -12,6 +12,7 @@ export declare class LinePipeline<T = SetDataOption> extends Pipeline<LineSegmen
12
12
  WallHeightHandle: typeof import('./builtin/wall-height-handle').wallHeightHandle;
13
13
  DoorSpaceHandle: typeof import('./builtin/door-space-handle').doorSpaceHandle;
14
14
  RemoveShortDoubleWall: typeof import('./builtin/remove-short-double-wall').removeShortDoubleWall;
15
+ BeamSupportLine: typeof import('./builtin/beam-support-line').beamSupportLine;
15
16
  };
16
17
  constructor();
17
18
  add(handle: (lines: LineSegment<LineUserData>[], option: T) => LineSegment<LineUserData>[]): this;
@@ -73,7 +73,7 @@ export declare class Quadtree<T = any> {
73
73
  * @returns 相交的节点数组
74
74
  */
75
75
  queryLineSegment(lineSegment: LineSegment, endpoint?: boolean): QuadtreeNode<T>[];
76
- raycaster(origin: Point, direct: Point, near?: number, far?: number): {
76
+ raycast(origin: Point, direct: Point, near?: number, far?: number): {
77
77
  targetLine: LineSegment;
78
78
  intersectPoint: Point;
79
79
  distance: number;
@@ -39,6 +39,7 @@ export default class Scenario {
39
39
  box: any;
40
40
  singleLineWallValue: any;
41
41
  liangNum: number;
42
+ zhuNum: number;
42
43
  private static _instance?;
43
44
  static get Instance(): Scenario | undefined;
44
45
  constructor(scene: THREE.Scene, camera: THREE.PerspectiveCamera, renderer: THREE.WebGLRenderer, controls: OrbitControls);
@@ -73,6 +74,8 @@ export default class Scenario {
73
74
  overhangWallOffset(data: any, index: string, height: number): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
74
75
  dashedLineCeilingTreatment(data: any, index: number | string, item: any): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
75
76
  overallTreatmentOfSingleLineWalls(data: any): void;
77
+ generateBeamModel(line: any): Brush | null;
78
+ generateColumnModel(data: any, lines: any, Height: number): THREE.Mesh<THREE.ExtrudeGeometry, THREE.MeshStandardMaterial, THREE.Object3DEventMap> | null;
76
79
  createAPlane(lines: LineSegment<Record<string, any>>[], menList: LineSegment<Record<string, any>>[]): void;
77
80
  modelLoader(): Promise<void>;
78
81
  windowModelLoader(): Promise<void>;