build-dxf 0.1.93 → 0.1.94

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.93",
3
+ "version": "0.1.94",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -48,4 +48,3 @@
48
48
  "license": "UNLICENSED"
49
49
  }
50
50
 
51
-
package/src/build.js CHANGED
@@ -3142,7 +3142,7 @@ class LineSegmentUtils {
3142
3142
  const parallelLines = [], otherLines = [];
3143
3143
  for (let i = 0; i < lines.length; i++) {
3144
3144
  const line = lines[i];
3145
- if (axisLine.isPerpendicularTo(line, errAngle)) parallelLines.push(line);
3145
+ if (axisLine.isParallelTo(line, errAngle)) parallelLines.push(line);
3146
3146
  else otherLines.push(line);
3147
3147
  }
3148
3148
  return [parallelLines, otherLines];
@@ -18955,22 +18955,26 @@ function vertical(line, baseline) {
18955
18955
  return line;
18956
18956
  }
18957
18957
  class AxisAlignCorr {
18958
- static start(lines, targettLine) {
18959
- return new AxisAlignCorr(lines, targettLine).start();
18958
+ static start(lines, targettLine, excludeLines) {
18959
+ return new AxisAlignCorr(lines, targettLine, excludeLines).start();
18960
18960
  }
18961
18961
  lines;
18962
18962
  baseline;
18963
+ excludeLines;
18963
18964
  grid;
18964
- constructor(lines, baseline) {
18965
+ constructor(lines, baseline, excludeLines) {
18965
18966
  this.lines = lines;
18966
18967
  this.baseline = baseline;
18968
+ this.excludeLines = excludeLines ?? [];
18967
18969
  this.grid = createPointVirtualGrid(lines);
18968
18970
  }
18969
18971
  visited = /* @__PURE__ */ new Set();
18970
18972
  newLines = [];
18971
18973
  start() {
18974
+ const excludeSet = new Set(this.excludeLines);
18972
18975
  for (let i = 0; i < this.lines.length; i++) {
18973
18976
  const line = this.lines[i];
18977
+ if (excludeSet.size && excludeSet.has(line)) continue;
18974
18978
  if (this.visited.has(line)) continue;
18975
18979
  this.correction(line);
18976
18980
  }
@@ -19380,7 +19384,6 @@ function breakpointMerging(lines) {
19380
19384
  return [...defaultLines, ...doorLines];
19381
19385
  }
19382
19386
  function correction(lines, targettLine, option) {
19383
- lines = lines.map((line) => line.clone());
19384
19387
  lines = breakpointMerging(lines);
19385
19388
  lines = lineSegmentClipping(lines, 1e-9);
19386
19389
  lines = preprocessing(lines);
@@ -19389,8 +19392,8 @@ function correction(lines, targettLine, option) {
19389
19392
  lines = lineSegmentClipping(lines, 1e-9);
19390
19393
  lines = removeDangline(lines, 0.1, false);
19391
19394
  lines = linesSmoothing(lines);
19392
- let newLines = lines.filter((line) => !line.userData.isDoor);
19393
- let doorLines = lines.filter((line) => line.userData.isDoor);
19395
+ let newLines = lines.filter((line) => !line.userData.isDoor && !line.userData.isBalconyRailing);
19396
+ let doorLines = lines.filter((line) => line.userData.isDoor || line.userData.isBalconyRailing);
19394
19397
  newLines = buildBayWindowGroup(newLines, false);
19395
19398
  const { wallGroup = true } = option ?? {};
19396
19399
  if (wallGroup) {
@@ -19401,9 +19404,7 @@ function correction(lines, targettLine, option) {
19401
19404
  new WallInsertObject(newLines).recomputed().merge();
19402
19405
  newLines.push(...doorLines);
19403
19406
  newLines = removeDangline(newLines, 0.15, true);
19404
- TEST = true;
19405
19407
  newLines = linesSmoothing(newLines);
19406
- TEST = false;
19407
19408
  return newLines.filter((line) => line.length() > 1e-9);
19408
19409
  }
19409
19410
  function axisAlignCorr(lines, option, verticalReferenceLine) {
@@ -19436,7 +19437,7 @@ function boundExt(lines, { trajectory: trajectory2, onBoundExt }) {
19436
19437
  }
19437
19438
  function doubleWallAlignment(lines) {
19438
19439
  const singleWall = lines.filter((line) => !LineGroupType.hasType(line, "doubleWall") && !line.userData.isDoor), doorLines = lines.filter((line) => line.userData.isDoor), grid = createPointVirtualGrid(singleWall.filter((line) => !line.userData.isDoor)), allGrid = createPointVirtualGrid(lines), doubleWalls = LineGroupType.getGroupsByType(lines, "doubleWall"), offset = -DEFAULT_WALL_WIDTH * 0.5, tree = createQuadtree(doubleWalls.flat());
19439
- const newDoubleWalls = doubleWalls.flatMap((doubleWall, i) => {
19440
+ const newDoubleWalls = doubleWalls.flatMap((doubleWall) => {
19440
19441
  const poly = Polygon.fromByLines2(doubleWall);
19441
19442
  Polygon.ensureCCW(poly);
19442
19443
  let doubleWall_ = poly.toLines();
@@ -19450,8 +19451,8 @@ function doubleWallAlignment(lines) {
19450
19451
  });
19451
19452
  const expLines = doubleWall.filter((line) => {
19452
19453
  if (line.length() < 1e-3) return false;
19453
- for (let i2 = 0; i2 < line.points.length; i2++) {
19454
- const point2 = line.points[i2];
19454
+ for (let i = 0; i < line.points.length; i++) {
19455
+ const point2 = line.points[i];
19455
19456
  let list = grid.queryPoint(point2);
19456
19457
  if (list.length !== 1) continue;
19457
19458
  list = grid.queryPoint(point2).filter((item) => item.userData?.isParallelTo(line));
@@ -19487,7 +19488,7 @@ function doubleWallAlignment(lines) {
19487
19488
  point2.copy(newPoint);
19488
19489
  return [];
19489
19490
  };
19490
- const newLines = expLines.flatMap((line, j) => {
19491
+ const newLines = expLines.flatMap((line) => {
19491
19492
  const normal = line.normal(), id = LineGroupType.getIdByType(line, "doubleWall");
19492
19493
  let step = normal.multiplyScalar(offset);
19493
19494
  const newLines2 = [];
@@ -8,14 +8,14 @@ import { Dxf } from './Dxf';
8
8
  export declare class CorrectionDxf<TEventMap extends {} = {}> extends Dxf<{} & TEventMap> {
9
9
  static name: string;
10
10
  static readonly PRE_PROCESSOR: {
11
- init: typeof import('../utils/lineHandle/DxfPreProcessor/init').init;
12
- AxisAlignCorr: typeof import('../utils/lineHandle/DxfPreProcessor/axisAlignCorr').axisAlignCorr;
11
+ init: typeof import('../utils/tools/DxfPreProcessor/init').init;
12
+ AxisAlignCorr: typeof import('../utils/tools/DxfPreProcessor/axisAlignCorr').axisAlignCorr;
13
13
  DoorFind: (lines: import('../..').LineSegment[]) => import('../..').LineSegment<Record<string, any>>[];
14
- BoundExt: typeof import('../utils/lineHandle/DxfPreProcessor/boundExt').boundExt;
15
- DoubleWallAlignment: typeof import('../utils/lineHandle/DxfPreProcessor/doubleWallAlignment').doubleWallAlignment;
16
- WallHeightHandle: typeof import('../utils/lineHandle/DxfPreProcessor/wallHeightHandle').wallHeightHandle;
17
- DoorSpaceHandle: typeof import('../utils/lineHandle/DxfPreProcessor/doorSpaceHandle').doorSpaceHandle;
18
- RemoveShortDoubleWall: typeof import('../utils/lineHandle/DxfPreProcessor/removeShortDoubleWall').removeShortDoubleWall;
14
+ BoundExt: typeof import('../utils/tools/DxfPreProcessor/boundExt').boundExt;
15
+ DoubleWallAlignment: typeof import('../utils/tools/DxfPreProcessor/doubleWallAlignment').doubleWallAlignment;
16
+ WallHeightHandle: typeof import('../utils/tools/DxfPreProcessor/wallHeightHandle').wallHeightHandle;
17
+ DoorSpaceHandle: typeof import('../utils/tools/DxfPreProcessor/doorSpaceHandle').doorSpaceHandle;
18
+ RemoveShortDoubleWall: typeof import('../utils/tools/DxfPreProcessor/removeShortDoubleWall').removeShortDoubleWall;
19
19
  };
20
20
  rotateCorrCad?: CAD;
21
21
  angle: number;
@@ -22,14 +22,14 @@ export declare class Dxf<TEventMap extends {} = {}> extends Component<{
22
22
  } & TEventMap> {
23
23
  static name: string;
24
24
  static readonly PRE_PROCESSOR: {
25
- init: typeof import('../utils/lineHandle/DxfPreProcessor/init').init;
26
- AxisAlignCorr: typeof import('../utils/lineHandle/DxfPreProcessor/axisAlignCorr').axisAlignCorr;
25
+ init: typeof import('../utils/tools/DxfPreProcessor/init').init;
26
+ AxisAlignCorr: typeof import('../utils/tools/DxfPreProcessor/axisAlignCorr').axisAlignCorr;
27
27
  DoorFind: (lines: LineSegment[]) => LineSegment<Record<string, any>>[];
28
- BoundExt: typeof import('../utils/lineHandle/DxfPreProcessor/boundExt').boundExt;
29
- DoubleWallAlignment: typeof import('../utils/lineHandle/DxfPreProcessor/doubleWallAlignment').doubleWallAlignment;
30
- WallHeightHandle: typeof import('../utils/lineHandle/DxfPreProcessor/wallHeightHandle').wallHeightHandle;
31
- DoorSpaceHandle: typeof import('../utils/lineHandle/DxfPreProcessor/doorSpaceHandle').doorSpaceHandle;
32
- RemoveShortDoubleWall: typeof import('../utils/lineHandle/DxfPreProcessor/removeShortDoubleWall').removeShortDoubleWall;
28
+ BoundExt: typeof import('../utils/tools/DxfPreProcessor/boundExt').boundExt;
29
+ DoubleWallAlignment: typeof import('../utils/tools/DxfPreProcessor/doubleWallAlignment').doubleWallAlignment;
30
+ WallHeightHandle: typeof import('../utils/tools/DxfPreProcessor/wallHeightHandle').wallHeightHandle;
31
+ DoorSpaceHandle: typeof import('../utils/tools/DxfPreProcessor/doorSpaceHandle').doorSpaceHandle;
32
+ RemoveShortDoubleWall: typeof import('../utils/tools/DxfPreProcessor/removeShortDoubleWall').removeShortDoubleWall;
33
33
  };
34
34
  width: number;
35
35
  originalData: OriginalDataItem[];
@@ -3,4 +3,4 @@ import { LineSegment } from '../../../../../algorithmsStructures/LineSegment';
3
3
  * @param lineSegments
4
4
  * @returns
5
5
  */
6
- export declare function removeQuad(lineSegments: LineSegment[], findMinWidth?: number, onMerge?: (mainLine: LineSegment, sortLine: LineSegment, secondaryLine: LineSegment, oldLine: LineSegment) => void): LineSegment<Record<string, any>>[];
6
+ export declare function removeQuad(lineSegments: LineSegment[], findMinWidth?: number, _?: (mainLine: LineSegment, sortLine: LineSegment, secondaryLine: LineSegment, oldLine: LineSegment) => void): LineSegment<Record<string, any>>[];
@@ -0,0 +1,8 @@
1
+ import { LineSegment } from './LineSegment';
2
+ export declare class AlignToParallelSegments {
3
+ /** 对齐到平行线段, 请在垂直纠正(AxisAlignCorr)后使用
4
+ * @param lines
5
+ * @returns
6
+ */
7
+ static align(lines: LineSegment[]): LineSegment<Record<string, any>>[];
8
+ }
@@ -1,11 +1,12 @@
1
1
  import { LineSegment } from './LineSegment';
2
2
  import { Point } from './Point';
3
3
  export declare class AxisAlignCorr {
4
- static start(lines: LineSegment[], targettLine: LineSegment): LineSegment<any>[];
4
+ static start(lines: LineSegment[], targettLine: LineSegment, excludeLines?: LineSegment[]): LineSegment<any>[];
5
5
  private lines;
6
6
  private baseline;
7
+ private excludeLines;
7
8
  private grid;
8
- constructor(lines: LineSegment[], baseline: LineSegment);
9
+ constructor(lines: LineSegment[], baseline: LineSegment, excludeLines?: LineSegment[]);
9
10
  private visited;
10
11
  private newLines;
11
12
  private start;