build-dxf 0.1.107 → 0.1.108

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.107",
3
+ "version": "0.1.108",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -9572,6 +9572,10 @@ const holeTypeMap = {
9572
9572
  passageEntrance: "WALL_HOLE",
9573
9573
  bay_window: "BAY_WINDOW"
9574
9574
  };
9575
+ const placeHoldersMap = {
9576
+ switch: "开关",
9577
+ socket: "插座"
9578
+ };
9575
9579
  const WALL_HEIGHT_KEY = /* @__PURE__ */ Symbol("height");
9576
9580
  class ThreeVJiaPipeline extends Pipeline {
9577
9581
  manager;
@@ -9604,17 +9608,10 @@ class ThreeVJiaPipeline extends Pipeline {
9604
9608
  if (lines2.length < 4) return lines2;
9605
9609
  let newLine = null;
9606
9610
  let wallWidth = 0;
9607
- const poly = Polygon.fromByLinePath(lines2).getMinimumBoundingRectangle();
9608
- if (poly) {
9609
- const len1 = poly[0].distance(poly[1]), len2 = poly[1].distance(poly[2]), direct = len1 > len2 ? poly[0].directionFrom(poly[1]) : poly[1].directionFrom(poly[2]), center = poly.getCenter(), len = Math.max(len1, len2);
9610
- newLine = center.expandAsLine(direct, len).translate(-len * 0.5, direct);
9611
- wallWidth = Math.min(len1, len2);
9612
- } else {
9613
- lines2 = [...lines2].sort((a2, b4) => a2.length() - b4.length());
9614
- const line1 = lines2[0], line2 = lines2[1];
9615
- newLine = new LineSegment(line1.center.clone(), line2.center.clone());
9616
- wallWidth = line1.length();
9617
- }
9611
+ lines2 = [...lines2].sort((a2, b4) => a2.length() - b4.length());
9612
+ const line1 = lines2[0], line2 = lines2[1];
9613
+ newLine = new LineSegment(line1.center.clone(), line2.center.clone());
9614
+ wallWidth = line1.length();
9618
9615
  mergeLineUserData(newLine, lines2);
9619
9616
  newLine.userData.wallWidth = wallWidth;
9620
9617
  return [newLine];
@@ -9795,13 +9792,13 @@ class ThreeVJiaPipeline extends Pipeline {
9795
9792
  const rooms = json.rooms, roomPloys = rooms.map((room) => new Polygon(room.polygon.map((p2) => Point.from(p2))));
9796
9793
  if (roomPloys.length === 0) return json;
9797
9794
  publicInfo.itemInfo.forEach((item, i) => {
9798
- if (item.category !== "switch" && item.category !== "socket") return;
9795
+ if (!placeHoldersMap[item.category]) return;
9799
9796
  const itemPoly = new Polygon(item.contour.map((p2) => Point.from(p2).rotate(json.center, json.angle))), center = itemPoly.getCenter(), index2 = roomPloys.findIndex((poly) => poly.pointWithin(center));
9800
9797
  if (index2 < 0) return;
9801
9798
  json.placeHolders.push({
9802
- name: item.category,
9803
- polygon: item.contour,
9804
- direction: item.direction,
9799
+ name: placeHoldersMap[item.category],
9800
+ polygon: itemPoly.getMinimumBoundingRectangle().map((p2) => p2.toJson2D()),
9801
+ direction: Point.from(item.direction).rotate(Point.zero(), json.angle),
9805
9802
  height: item.box.max.z - item.box.min.z,
9806
9803
  sillHeight: item.box.min.z - z,
9807
9804
  roomId: rooms[index2].roomTypeId,
@@ -11335,7 +11332,22 @@ function axisAlignCorr(lines, option, verticalReferenceLine) {
11335
11332
  }
11336
11333
  return lines;
11337
11334
  }
11335
+ function sparse(trajectory2, size2 = 0.4) {
11336
+ const idSet = /* @__PURE__ */ new Set();
11337
+ Object.keys(trajectory2 ?? {}).forEach((key) => {
11338
+ const p2 = trajectory2[key], i = Math.round(p2.x / size2), j = Math.round(p2.y / size2), id = BigInt(i) << 32n | BigInt(j) & 0xffffffffn;
11339
+ if (idSet.has(id)) {
11340
+ delete trajectory2[key];
11341
+ return;
11342
+ }
11343
+ idSet.add(id);
11344
+ });
11345
+ }
11338
11346
  function init(lines, option) {
11347
+ if (option.trajectory) {
11348
+ sparse(option.trajectory, 0.2);
11349
+ sparse(option.trajectory, 0.5);
11350
+ }
11339
11351
  BuildGroup.doubleWall.setTrajectory(option.trajectory);
11340
11352
  lines = lines.map((line) => line.clone());
11341
11353
  return lines;
@@ -0,0 +1 @@
1
+ export {};