build-dxf 0.1.17 → 0.1.18

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.17",
3
+ "version": "0.1.18",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -1491,7 +1491,7 @@ class LineSegment {
1491
1491
  const p3 = line.start;
1492
1492
  const p4 = line.end;
1493
1493
  const denom = (p1.x - p2.x) * (p3.y - p4.y) - (p1.y - p2.y) * (p3.x - p4.x);
1494
- if (Math.abs(denom) < 1e-9) {
1494
+ if (Math.abs(denom) < 1e-10) {
1495
1495
  return null;
1496
1496
  }
1497
1497
  const t = ((p1.x - p3.x) * (p3.y - p4.y) - (p1.y - p3.y) * (p3.x - p4.x)) / denom;
@@ -13886,7 +13886,7 @@ class SceneAutoGenerat {
13886
13886
  await Promise.all(this.itemList.map(async (item) => await this.getModel(item)));
13887
13887
  }
13888
13888
  static itemParse(item) {
13889
- const contour = Point.fromByList(item.contour), rectangle = new Polygon(Qa(contour.map((p) => [p.x, p.y])).map((p) => Point.from(p)));
13889
+ const contour = Point.fromByList(item.contour ?? []), rectangle = new Polygon(Qa(contour.map((p) => [p.x, p.y])).map((p) => Point.from(p)));
13890
13890
  rectangle.pop();
13891
13891
  const z = item.box.min.z, height = Math.abs(item.box.max.z - z), max = rectangle.getMaxLengthInfo(), min = rectangle.getMinLengthInfo(), direction = max.start.y < max.end.y ? max.start.direction(max.end) : max.end.direction(max.start), shape = new THREE.Shape();
13892
13892
  rectangle.forEach((p, i) => {
@@ -13940,7 +13940,7 @@ class HeightQuery {
13940
13940
  newLine.endShrink(len * 0.2);
13941
13941
  inLinePoints.push([center.x, center.y], [newLine.start.x, newLine.start.y], [newLine.end.x, newLine.end.y]);
13942
13942
  const contoursData = this.whichContourContainsPoint(inLinePoints, rootTopContourInfo);
13943
- contoursData.sort((a, b) => a.averagePz - b.averagePz);
13943
+ contoursData.sort((a, b) => b.averagePz - a.averagePz);
13944
13944
  const height = contoursData[0]?.averagePz ?? DEFAULT_WALL_HEIGHT;
13945
13945
  return height;
13946
13946
  }
@@ -13958,6 +13958,7 @@ class HeightQuery {
13958
13958
  points.filter((p) => {
13959
13959
  point.set(p[0], p[1]);
13960
13960
  new Array(...new Set(quadtree?.queryCircle(point, 0.4).map((item) => item.line.currentData.contourIndex))).forEach((index2) => {
13961
+ if (index2 === maxContourIndex) return;
13961
13962
  contoursData.push({ i: index2, averagePz: contours[index2].averagePz });
13962
13963
  });
13963
13964
  });
@@ -14198,8 +14199,8 @@ const PRE_PROCESSOR = {
14198
14199
  }
14199
14200
  lineSegments.forEach((line) => {
14200
14201
  if (!("height" in line.userData)) {
14201
- if (line.userData.rooftopPz) line.userData.height = Math.abs(line.userData.rooftopPz - (option.originalZ ?? 0));
14202
- else if (option?.publicInfo?.rootTopContourInfo) line.userData.height = HeightQuery.query(line, option.publicInfo.rootTopContourInfo);
14202
+ if (!line.userData.rooftopPz && option?.publicInfo?.rootTopContourInfo) line.userData.rooftopPz = HeightQuery.query(line, option.publicInfo.rootTopContourInfo);
14203
+ if ("rooftopPz" in line.userData) line.userData.height = Math.abs(line.userData.rooftopPz - (option.originalZ ?? 0));
14203
14204
  }
14204
14205
  });
14205
14206
  return lineSegments;
@@ -15391,6 +15392,7 @@ export {
15391
15392
  Box2 as B,
15392
15393
  Component as C,
15393
15394
  Dxf as D,
15395
+ HeightQuery as H,
15394
15396
  LineSegment as L,
15395
15397
  PointVirtualGrid as P,
15396
15398
  Quadtree as Q,
package/src/index3.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Component, P as PointVirtualGrid, Q as Quadtree, B as Box2, a as Point, c as cloneUserData, L as LineSegment, b as Lines, u as uuid, r as recomputedWindow, A as AxisAlignCorr, W as WhiteModel, T as ThreeVJia, V as Variable, S as SelectLocalFile, d as CommandManager } from "./build.js";
1
+ import { C as Component, P as PointVirtualGrid, Q as Quadtree, B as Box2, a as Point, c as cloneUserData, L as LineSegment, b as Lines, H as HeightQuery, u as uuid, r as recomputedWindow, A as AxisAlignCorr, W as WhiteModel, T as ThreeVJia, V as Variable, S as SelectLocalFile, d as CommandManager } from "./build.js";
2
2
  import * as THREE from "three";
3
3
  import "clipper-lib";
4
4
  import "dxf-writer";
@@ -9607,7 +9607,7 @@ class RenderManager extends Component {
9607
9607
  this.updatedMode = "self";
9608
9608
  const dxf2 = this.dxf;
9609
9609
  const json = this.toJson();
9610
- dxf2.set(json);
9610
+ dxf2.set(json, dxf2.options);
9611
9611
  });
9612
9612
  }
9613
9613
  get renderer() {
@@ -9971,6 +9971,11 @@ class Default extends CommandFlowComponent {
9971
9971
  } else {
9972
9972
  const rectangle = wiLine.expandToRectangle(0.025, "bothSides");
9973
9973
  object3D.geometry = editor.renderManager.createGeometry({ position: rectangle.createGeometry() }, 6);
9974
+ const center = wiLine.center;
9975
+ let info = "";
9976
+ textObj3D.element.innerText = info + parseInt(wiLine.length() * 1e3 + "") + " mm";
9977
+ textObj3D.position.set(center.x, center.y, 0);
9978
+ textObj3D.visible = true;
9974
9979
  }
9975
9980
  this.container.add(object3D);
9976
9981
  } else {
@@ -10269,6 +10274,12 @@ class DrawLine extends CommandFlowComponent {
10269
10274
  for (let i = 0; i < points.length; i += 2) {
10270
10275
  lines.push(new LineSegment(Point.from(points[i]), Point.from(points[i + 1])));
10271
10276
  }
10277
+ lines.forEach((line2) => {
10278
+ if (this.renderManager.dxf.options.publicInfo?.rootTopContourInfo) {
10279
+ const rooftopPz = HeightQuery.query(line2, this.renderManager.dxf.options.publicInfo?.rootTopContourInfo);
10280
+ line2.userData.rooftopPz = rooftopPz;
10281
+ }
10282
+ });
10272
10283
  next(lines);
10273
10284
  }
10274
10285
  /** 执行完成
@@ -15,6 +15,10 @@ interface IByTrajAnOriginData {
15
15
  updateDoubleWallGroup?: boolean;
16
16
  findCallBack?: (lines: LineSegment[], trajectory: Point[]) => void;
17
17
  }
18
+ /** 执行纠正
19
+ * @param line
20
+ * @param grid
21
+ */
18
22
  export declare class BoundExt {
19
23
  /** 通过轨迹点查找外墙
20
24
  * @param lines
@@ -1,30 +1,48 @@
1
- type ValueType = "number" | "boolean" | "vec2" | "vec3" | "vec4" | "mat3x3" | "mat4x4";
1
+ type ValueType = "f32" | "vec2" | "vec3" | "vec4" | "mat3x3" | "mat4x4";
2
2
  type OptionType = {
3
3
  workgroup_size?: [number, number, number];
4
- structName?: string;
5
- dataName?: string;
4
+ workgroupCount: [number, number?, number?];
6
5
  globalInvocationIdName?: string;
6
+ workgroupIndexName?: string;
7
+ synchronize?: string[];
8
+ };
9
+ type BufferType = {
10
+ buffer: number[];
11
+ stride: number;
12
+ layout: {
13
+ name: string;
14
+ type: ValueType;
15
+ offset: number;
16
+ size: number;
17
+ }[];
18
+ count: number;
7
19
  };
8
20
  export declare class GpuComputed {
9
21
  constructor();
10
22
  getDevice(): Promise<{
11
23
  adapter: GPUAdapter | null;
12
24
  device: GPUDevice;
13
- groupLayout: GPUBindGroupLayout;
14
25
  }>;
15
- createPipleline(code: string, buffer: Float32Array<ArrayBuffer>): Promise<void>;
16
- buildBuffer(data: Record<string, any>[], keys?: string[], types?: ValueType[]): {
17
- buffer: number[];
18
- stride: number;
19
- layout: {
26
+ createPipleline(code: string, buffers: Record<string, BufferType>): Promise<{
27
+ pipeline: GPUComputePipeline;
28
+ group: GPUBindGroup;
29
+ device: GPUDevice;
30
+ bufferInfoList: {
20
31
  name: string;
21
- type: ValueType;
22
- offset: number;
23
- size: number;
32
+ buffer: GPUBuffer;
33
+ float32Array: Float32Array<ArrayBuffer>;
34
+ groupLayoutItem: GPUBindGroupLayoutEntry;
35
+ groupItem: {
36
+ binding: number;
37
+ resource: {
38
+ buffer: GPUBuffer;
39
+ };
40
+ };
24
41
  }[];
25
- count: number;
26
- };
42
+ }>;
43
+ private buildBuffer;
44
+ capitalize(str: string): string;
27
45
  private buildCode;
28
- computed(data: any[], code: string, option?: OptionType): Promise<void>;
46
+ computed(code: string, data: Record<string, any[]>, option: OptionType): Promise<number[][]>;
29
47
  }
30
48
  export {};