build-dxf 0.1.76 → 0.1.78

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,6 +1,6 @@
1
1
  {
2
2
  "name": "build-dxf",
3
- "version": "0.1.76",
3
+ "version": "0.1.78",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -1300,6 +1300,9 @@ class LineSegment {
1300
1300
  currentData = {};
1301
1301
  // line: any
1302
1302
  uuid = uuid();
1303
+ get len() {
1304
+ return this.length();
1305
+ }
1303
1306
  get center() {
1304
1307
  return new Point(
1305
1308
  this.points[0].x + (this.points[1].x - this.points[0].x) * 0.5,
@@ -5933,6 +5936,9 @@ var Side = /* @__PURE__ */ ((Side2) => {
5933
5936
  return Side2;
5934
5937
  })(Side || {});
5935
5938
  class MiniCircles {
5939
+ debug = {
5940
+ angle: false
5941
+ };
5936
5942
  /** 通过并查集,查找为环的一部分边
5937
5943
  * @description
5938
5944
  * @param lines
@@ -6038,6 +6044,7 @@ class MiniCircles {
6038
6044
  A = B;
6039
6045
  B = minC;
6040
6046
  path.add(mineLie);
6047
+ if (this.debug.angle) drawText(minAngle.toFixed(), mineLie?.center);
6041
6048
  } else return;
6042
6049
  }
6043
6050
  }
@@ -6540,17 +6547,6 @@ class MaxiCircles extends MiniCircles {
6540
6547
  }
6541
6548
  const maxiCircles = new MaxiCircles();
6542
6549
  let trajectory;
6543
- function isPolyHasTrajectoryPoint(lines) {
6544
- if (!trajectory) return true;
6545
- const ploy = Polygon.fromByLines2(lines);
6546
- const box = ploy.getBox2();
6547
- for (let i = 0; i < trajectory.length; i++) {
6548
- const p2 = trajectory[i];
6549
- if (p2.x < box.minX || p2.x > box.maxX || p2.y < box.minY || p2.y > box.maxY) continue;
6550
- if (ploy.pointWithin(p2)) return false;
6551
- }
6552
- return true;
6553
- }
6554
6550
  function isDoublePeDoorCircle(circle) {
6555
6551
  const doors = circle.filter((line) => line.userData.passageEntrance?.some((item) => item.type === "door")), map = /* @__PURE__ */ new Map(), matching = [];
6556
6552
  doors.forEach((door) => {
@@ -6563,8 +6559,20 @@ function isDoublePeDoorCircle(circle) {
6563
6559
  });
6564
6560
  return matching.length > 0;
6565
6561
  }
6562
+ function isPolyHasTrajectoryPoint(lines) {
6563
+ if (isDoublePeDoorCircle(lines)) return true;
6564
+ if (!trajectory) return true;
6565
+ const ploy = Polygon.fromByLines2(lines);
6566
+ const box = ploy.getBox2();
6567
+ for (let i = 0; i < trajectory.length; i++) {
6568
+ const p2 = trajectory[i];
6569
+ if (p2.x < box.minX || p2.x > box.maxX || p2.y < box.minY || p2.y > box.maxY) continue;
6570
+ if (ploy.pointWithin(p2)) return false;
6571
+ }
6572
+ return true;
6573
+ }
6566
6574
  function buildDoubleWallGroup_(lines_, clearInternalLine = false) {
6567
- const doorLines = [], otherLines = [], peDoorLines = [];
6575
+ const doorLines = [], otherLines = [];
6568
6576
  for (let i = 0; i < lines_.length; i++) {
6569
6577
  const line = lines_[i];
6570
6578
  if (line.userData.isDoor) {
@@ -6574,15 +6582,10 @@ function buildDoubleWallGroup_(lines_, clearInternalLine = false) {
6574
6582
  if (line.userData.isBayWindow) {
6575
6583
  continue;
6576
6584
  }
6577
- if (WallInsertObject.isDoor(line)) peDoorLines.push(line);
6578
- else otherLines.push(line);
6585
+ otherLines.push(line);
6579
6586
  }
6580
6587
  let { internalEdges, circles } = maxiCircles.maxiCircles(otherLines, (circles2) => circles2.filter(isPolyHasTrajectoryPoint));
6581
- let peDoorCircles = maxiCircles.miniCircle(lines_, {
6582
- circleEdges: peDoorLines,
6583
- side: Side.IN
6584
- }).circles.filter(isPolyHasTrajectoryPoint).filter(isDoublePeDoorCircle);
6585
- const finalCircles = maxiCircles.mergeCircles([...circles, ...peDoorCircles], internalEdges).circles.filter((circle) => circle.length > 3);
6588
+ const finalCircles = circles.filter((circle) => circle.length > 3);
6586
6589
  lines_.forEach((line) => LineGroupType.removeByTypes(line, ["doubleWall", "wall"]));
6587
6590
  const grid = new PointVirtualGrid(), finalCirclesSet = new Set(finalCircles.flat(2));
6588
6591
  otherLines.forEach((line) => !finalCirclesSet.has(line) && grid.insert(line.center, line));
@@ -6748,7 +6751,7 @@ class DoubleWallHelper {
6748
6751
  addClipingMap(line1, project1);
6749
6752
  });
6750
6753
  clipingMap.forEach((list, line) => {
6751
- const newLines = LineSegment.clipping(line, list, clippingLineUserData);
6754
+ const newLines = LineSegment.clipping(line, list);
6752
6755
  lines.push(...newLines);
6753
6756
  });
6754
6757
  lines = lines.filter((line) => !removeLines.has(line));
@@ -6971,6 +6974,7 @@ class WallInsertObjectDrawData {
6971
6974
  * @returns
6972
6975
  */
6973
6976
  static doubleDrawLine(lines) {
6977
+ if (lines.length < 3) return [];
6974
6978
  lines = [...lines].sort((a2, b4) => a2.length() - b4.length());
6975
6979
  const line1 = lines[0], line2 = lines[1], wallWidth = Math.min(line1.length(), line2.length());
6976
6980
  let wallHeight = 0;
@@ -8235,7 +8239,7 @@ class DxfDataPlugin extends Pipeline {
8235
8239
  line.end.add(direct.clone().multiplyScalar(-DEFAULT_WALL_WIDTH * 0.5));
8236
8240
  }
8237
8241
  });
8238
- cad.addGroupAndOffset([...untreatedWall, ...passageEntrance], { type: "wall" });
8242
+ cad.addGroupAndOffset([...untreatedWall], { type: "wall" });
8239
8243
  cad.addGroups(untreatedDoubleWallGroup, "doubleWall");
8240
8244
  cad.unionGroupAll("wall");
8241
8245
  const offsetWidth = 0.05;
@@ -8610,7 +8614,7 @@ function axisAlignCorr$1(lines, targettLine, option) {
8610
8614
  }
8611
8615
  new WallInsertObject(lines).recomputed().merge();
8612
8616
  newLines.push(...doorLines);
8613
- Point.adsorb(newLines.flatMap((line) => line.points), 1e-5);
8617
+ Point.adsorb(newLines.flatMap((line) => line.points), 1e-4);
8614
8618
  lines = removeShortLine(lines, 0.05);
8615
8619
  return newLines;
8616
8620
  }
@@ -8719,7 +8723,7 @@ class BoundExt {
8719
8723
  const walls = lines.filter((line) => !line.userData.isDoor);
8720
8724
  lines = [...LineSegment.brokenLineMerging(walls, mergeLineUserData), ...doors];
8721
8725
  WallInsertObject.recomputed(lines);
8722
- lines = lines.filter((line) => line.length() > 0.01).filter((line) => line.userData.isDoor ? line.length() > 0.25 : true);
8726
+ lines = lines.filter((line) => line.length() > 1e-4).filter((line) => line.userData.isDoor ? line.length() > 0.25 : true);
8723
8727
  findCallBack && findCallBack([...exteriorLines, ...appendLines], trajectoryPoints);
8724
8728
  return {
8725
8729
  lines,
@@ -10934,10 +10938,7 @@ class Scenario {
10934
10938
  this.installWindows(winDraw[x2], x2);
10935
10939
  } else if (winDraw[x2].userData.type === "door") {
10936
10940
  this.singleLineWallMountedDoor(winDraw[x2], x2);
10937
- console.log("安装了门");
10938
- } else {
10939
- console.log("单线垭口");
10940
- }
10941
+ } else ;
10941
10942
  new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0 }));
10942
10943
  let mesh = this.windowTreatment(winDraw[x2], houMesh, wallHeight);
10943
10944
  mesh.name = `单线墙_${Number(x2) / 2}`;
@@ -10948,10 +10949,7 @@ class Scenario {
10948
10949
  this.installWindows(winDraw[x2], x2);
10949
10950
  } else if (winDraw[x2].userData.type === "door") {
10950
10951
  this.singleLineWallMountedDoor(winDraw[x2], x2);
10951
- console.log("安装了门");
10952
- } else {
10953
- console.log("单线垭口");
10954
- }
10952
+ } else ;
10955
10953
  houMesh = this.windowTreatment(winDraw[x2], houMesh, wallHeight);
10956
10954
  }
10957
10955
  } else {
@@ -10959,10 +10957,7 @@ class Scenario {
10959
10957
  this.installWindows(winDraw[x2], x2);
10960
10958
  } else if (winDraw[x2].userData.type === "door") {
10961
10959
  this.singleLineWallMountedDoor(winDraw[x2], x2);
10962
- console.log("安装了门");
10963
- } else {
10964
- console.log("单线垭口");
10965
- }
10960
+ } else ;
10966
10961
  houMesh = this.windowTreatment(winDraw[x2], Mesh, wallHeight);
10967
10962
  }
10968
10963
  }
@@ -19834,7 +19829,7 @@ function drawPoint(point2, parameters, offset = 1e-3) {
19834
19829
  }
19835
19830
  }
19836
19831
  }
19837
- function drawText(text, point2, style, offset = 1e-3) {
19832
+ function drawText$1(text, point2, style, offset = 1e-3) {
19838
19833
  const dxfSystem = DxfSystem.finalInstance;
19839
19834
  if (dxfSystem) {
19840
19835
  const renderer = dxfSystem.findComponentByName("Renderer");
@@ -22034,7 +22029,7 @@ class Log {
22034
22029
  if (typeof window !== "undefined") {
22035
22030
  window.drawLines = drawLines;
22036
22031
  window.drawPoint = drawPoint;
22037
- window.drawText = drawText;
22032
+ window.drawText = drawText$1;
22038
22033
  window.randomColor = () => Math.floor(Math.random() * 16777215);
22039
22034
  window.Log = Log;
22040
22035
  window.TEST = false;
@@ -22224,7 +22219,7 @@ export {
22224
22219
  cloneUserData as c,
22225
22220
  createQuadtree as d,
22226
22221
  Lines as e,
22227
- drawText as f,
22222
+ drawText$1 as f,
22228
22223
  getDefaultExportFromCjs as g,
22229
22224
  LineSegmentUndirectedGraph as h,
22230
22225
  mergeLineUserData as i,
@@ -9,6 +9,7 @@ export declare class LineSegment<T = Record<string, any>> {
9
9
  userData: T;
10
10
  currentData: Record<string | number | symbol, any>;
11
11
  uuid: string;
12
+ get len(): number;
12
13
  get center(): Point<Record<string, any>>;
13
14
  get start(): Point<Record<string, any>>;
14
15
  get end(): Point<Record<string, any>>;
@@ -13,6 +13,9 @@ export interface MiniCirclesOption {
13
13
  circleEdges?: LineSegment[];
14
14
  }
15
15
  export declare class MiniCircles {
16
+ debug: {
17
+ angle: boolean;
18
+ };
16
19
  /** 通过并查集,查找为环的一部分边
17
20
  * @description
18
21
  * @param lines