build-dxf 0.1.134 → 0.1.136
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 +1 -1
- package/src/api/getSocket.d.ts +1 -0
- package/src/build.js +110 -23
- package/src/index3.js +5 -1
- package/src/utils/algorithms/AlignToParallelSegments.d.ts +1 -0
- package/src/utils/algorithms/LLM.d.ts +47 -0
- package/src/utils/algorithms/LineSegmentSpatialHash.d.ts +4 -0
- package/src/utils/algorithms/PointUtils.d.ts +11 -0
- package/src/utils/algorithms/Polygon.d.ts +4 -0
- package/src/utils/algorithms/Rectangle.d.ts +9 -1
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getPjPointAndPathSocketApi: (idRegion: any, resourceType: any) => Promise<any>;
|
package/src/build.js
CHANGED
|
@@ -305,6 +305,20 @@ class Rectangle {
|
|
|
305
305
|
};
|
|
306
306
|
return isPointInRectangle(line.points[0]) && isPointInRectangle(line.points[1]);
|
|
307
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* 获取所有点在轴上的投影,并且返回区间
|
|
310
|
+
* @param rect
|
|
311
|
+
* @param axis
|
|
312
|
+
* @returns
|
|
313
|
+
*/
|
|
314
|
+
projectRectangle(rect, axis) {
|
|
315
|
+
const projections = rect.points.map((point2) => point2.dot(axis));
|
|
316
|
+
return [Math.min(...projections), Math.max(...projections)];
|
|
317
|
+
}
|
|
318
|
+
// 检测两个投影区间是否重叠
|
|
319
|
+
isProjectionOverlap(proj1, proj2) {
|
|
320
|
+
return proj1[0] < proj2[1] && proj2[0] < proj1[1];
|
|
321
|
+
}
|
|
308
322
|
/**
|
|
309
323
|
* 判断矩形是否与矩形相交
|
|
310
324
|
* @description 使用分离轴定理
|
|
@@ -323,17 +337,10 @@ class Rectangle {
|
|
|
323
337
|
const p2 = rectangle.points[(i + 1) % 4];
|
|
324
338
|
axes.push(p1.leftNormal(p2));
|
|
325
339
|
}
|
|
326
|
-
function projectRectangle(rect, axis) {
|
|
327
|
-
const projections = rect.points.map((point2) => point2.dot(axis));
|
|
328
|
-
return [Math.min(...projections), Math.max(...projections)];
|
|
329
|
-
}
|
|
330
|
-
function isProjectionOverlap(proj1, proj2) {
|
|
331
|
-
return proj1[0] < proj2[1] && proj2[0] < proj1[1];
|
|
332
|
-
}
|
|
333
340
|
for (const axis of axes) {
|
|
334
|
-
const proj1 = projectRectangle(this, axis);
|
|
335
|
-
const proj2 = projectRectangle(rectangle, axis);
|
|
336
|
-
if (!isProjectionOverlap(proj1, proj2)) {
|
|
341
|
+
const proj1 = this.projectRectangle(this, axis);
|
|
342
|
+
const proj2 = this.projectRectangle(rectangle, axis);
|
|
343
|
+
if (!this.isProjectionOverlap(proj1, proj2)) {
|
|
337
344
|
return false;
|
|
338
345
|
}
|
|
339
346
|
}
|
|
@@ -360,15 +367,15 @@ class Rectangle {
|
|
|
360
367
|
*
|
|
361
368
|
* @returns
|
|
362
369
|
*/
|
|
363
|
-
toBox() {
|
|
370
|
+
toBox(out = new Box2()) {
|
|
364
371
|
let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
|
|
365
372
|
this.points.forEach((p2) => {
|
|
366
373
|
maxX = Math.max(p2.x, maxX);
|
|
367
374
|
minX = Math.min(p2.x, minX);
|
|
368
|
-
maxY = Math.max(p2.
|
|
369
|
-
minY = Math.min(p2.
|
|
375
|
+
maxY = Math.max(p2.y, maxY);
|
|
376
|
+
minY = Math.min(p2.y, minY);
|
|
370
377
|
});
|
|
371
|
-
return
|
|
378
|
+
return out.set(minX, minY, maxX, maxY);
|
|
372
379
|
}
|
|
373
380
|
/**
|
|
374
381
|
*
|
|
@@ -798,6 +805,24 @@ class PointUtils {
|
|
|
798
805
|
static get globalPoint() {
|
|
799
806
|
return this._globalPoint.value;
|
|
800
807
|
}
|
|
808
|
+
static getCenter(points) {
|
|
809
|
+
let area2 = 0;
|
|
810
|
+
let cx = 0;
|
|
811
|
+
let cy = 0;
|
|
812
|
+
for (let i = 0, n = points.length; i < n; i++) {
|
|
813
|
+
const p1 = points[i];
|
|
814
|
+
const p2 = points[(i + 1) % n];
|
|
815
|
+
const cross = p1.x * p2.y - p2.x * p1.y;
|
|
816
|
+
area2 += cross;
|
|
817
|
+
cx += (p1.x + p2.x) * cross;
|
|
818
|
+
cy += (p1.y + p2.y) * cross;
|
|
819
|
+
}
|
|
820
|
+
area2 *= 0.5;
|
|
821
|
+
return new Point(
|
|
822
|
+
cx / (6 * area2),
|
|
823
|
+
cy / (6 * area2)
|
|
824
|
+
);
|
|
825
|
+
}
|
|
801
826
|
/** 值网格化
|
|
802
827
|
* @param points
|
|
803
828
|
* @param tolerance
|
|
@@ -893,6 +918,30 @@ class PointUtils {
|
|
|
893
918
|
else if (point22) point2.copy(point22);
|
|
894
919
|
return point2;
|
|
895
920
|
}
|
|
921
|
+
/** 导出为数组
|
|
922
|
+
* @param points
|
|
923
|
+
* @returns
|
|
924
|
+
*/
|
|
925
|
+
static toArray(points) {
|
|
926
|
+
const array = new Float32Array(points.length * 2);
|
|
927
|
+
for (let i = 0; i < points.length; i++) {
|
|
928
|
+
const point2 = points[i];
|
|
929
|
+
array[i * 2 + 0] = point2.x;
|
|
930
|
+
array[i * 2 + 1] = point2.y;
|
|
931
|
+
}
|
|
932
|
+
return array;
|
|
933
|
+
}
|
|
934
|
+
/** 导出为数组
|
|
935
|
+
* @param points
|
|
936
|
+
* @returns
|
|
937
|
+
*/
|
|
938
|
+
static fromArray(array) {
|
|
939
|
+
const points = new Array();
|
|
940
|
+
for (let i = 0; i < array.length; i += 2) {
|
|
941
|
+
points.push(new Point(array[i], array[i + 1]));
|
|
942
|
+
}
|
|
943
|
+
return points;
|
|
944
|
+
}
|
|
896
945
|
}
|
|
897
946
|
const LINE_SYMBOL = /* @__PURE__ */ Symbol("LINE_SYMBOL");
|
|
898
947
|
class LineSegment {
|
|
@@ -2075,8 +2124,8 @@ class Box2 {
|
|
|
2075
2124
|
}
|
|
2076
2125
|
get center() {
|
|
2077
2126
|
return new Point(
|
|
2078
|
-
|
|
2079
|
-
|
|
2127
|
+
(this.maxX + this.minX) * 0.5,
|
|
2128
|
+
(this.maxY + this.minY) * 0.5
|
|
2080
2129
|
);
|
|
2081
2130
|
}
|
|
2082
2131
|
constructor(minX = 0, maxX = 0, minY = 0, maxY = 0) {
|
|
@@ -3076,6 +3125,31 @@ class LineSegmentSpatialHash {
|
|
|
3076
3125
|
out.length = write;
|
|
3077
3126
|
return out;
|
|
3078
3127
|
}
|
|
3128
|
+
rectangleBounds = new Box2();
|
|
3129
|
+
/** 通过矩形查询 */
|
|
3130
|
+
queryRectangle(rectangle, out = []) {
|
|
3131
|
+
const bounds = rectangle.toBox(this.rectangleBounds);
|
|
3132
|
+
this.visited.clear();
|
|
3133
|
+
out.length = 0;
|
|
3134
|
+
const minCellX = this.toCell(bounds.minX);
|
|
3135
|
+
const minCellY = this.toCell(bounds.minY);
|
|
3136
|
+
const maxCellX = this.toCell(bounds.maxX);
|
|
3137
|
+
const maxCellY = this.toCell(bounds.maxY);
|
|
3138
|
+
for (let x = minCellX; x <= maxCellX; x++) {
|
|
3139
|
+
for (let y = minCellY; y <= maxCellY; y++) {
|
|
3140
|
+
const bucket = this.buckets.get(this.getKey(x, y));
|
|
3141
|
+
if (!bucket) continue;
|
|
3142
|
+
for (const line of bucket) {
|
|
3143
|
+
if (this.visited.has(line)) continue;
|
|
3144
|
+
this.visited.add(line);
|
|
3145
|
+
if (rectangle.containsPoint(line.start) || rectangle.containsPoint(line.end) || rectangle.intersectLineSegment(line)) {
|
|
3146
|
+
out.push(line);
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
return out;
|
|
3152
|
+
}
|
|
3079
3153
|
rayIntersectSegment(origin, dir, seg) {
|
|
3080
3154
|
const x1 = origin.x;
|
|
3081
3155
|
const y1 = origin.y;
|
|
@@ -5988,6 +6062,10 @@ class Polygon extends Array {
|
|
|
5988
6062
|
this.set(result);
|
|
5989
6063
|
return this;
|
|
5990
6064
|
}
|
|
6065
|
+
/** 通过线段分割
|
|
6066
|
+
* @param line
|
|
6067
|
+
* @returns
|
|
6068
|
+
*/
|
|
5991
6069
|
clipByLine(line) {
|
|
5992
6070
|
if (this.length < 3) return [];
|
|
5993
6071
|
const intersections = [];
|
|
@@ -8845,6 +8923,7 @@ class WallHole {
|
|
|
8845
8923
|
*/
|
|
8846
8924
|
static splitHole(target, source) {
|
|
8847
8925
|
if (!Array.isArray(source)) source = [];
|
|
8926
|
+
source = source.filter((line) => line.length > 1e-9);
|
|
8848
8927
|
const iterator = this.getIterator(target);
|
|
8849
8928
|
for (const hole of iterator) {
|
|
8850
8929
|
let find = false, min = Infinity, maxLine = null;
|
|
@@ -9377,7 +9456,7 @@ const buildDoubleWallGroup = Object.assign((lines_, clearInternalLine) => {
|
|
|
9377
9456
|
return group(lines_, clearInternalLine);
|
|
9378
9457
|
}, {
|
|
9379
9458
|
setTrajectory(trajectory_) {
|
|
9380
|
-
if (trajectory_) trajectory = Object.values(trajectory_);
|
|
9459
|
+
if (trajectory_) trajectory = Object.values(trajectory_).filter((p2) => !(p2.x < 0.01 && p2.y < 0.01));
|
|
9381
9460
|
else trajectory = void 0;
|
|
9382
9461
|
}
|
|
9383
9462
|
});
|
|
@@ -10810,8 +10889,11 @@ function innerWallLine(lines, trajectory2) {
|
|
|
10810
10889
|
}
|
|
10811
10890
|
singleLine.push(...temLine.setLength(temLine.length + 1e-4).toRectangle(wallWidth, "butt").toLines());
|
|
10812
10891
|
});
|
|
10813
|
-
const
|
|
10814
|
-
|
|
10892
|
+
const paths = Polygon.multipleFromByLines(singleLine);
|
|
10893
|
+
if (paths.length > 1) {
|
|
10894
|
+
const [p1, ...pn2] = paths;
|
|
10895
|
+
singleLine = Polygon.booleanOp(p1, pn2, { type: "Union", scale: 1e4 }).flatMap((p2) => p2.toLines());
|
|
10896
|
+
}
|
|
10815
10897
|
singleLine = singleLine.filter((line) => line.length > 0.2);
|
|
10816
10898
|
singleLine = LineSegmentUtils.deduplicate(
|
|
10817
10899
|
LineSegmentUtils.splitIntersections(singleLine, {
|
|
@@ -11611,7 +11693,7 @@ function layoutDesign(lines, axis, intersectPoints, opt) {
|
|
|
11611
11693
|
});
|
|
11612
11694
|
const newLines = [];
|
|
11613
11695
|
for (let i = 0; i < blocks.length; i++) {
|
|
11614
|
-
const block = blocks[i], line = lines[block.index];
|
|
11696
|
+
const block = blocks[i], line = lines[block.index], occupationIndexList = [];
|
|
11615
11697
|
let ranges = [];
|
|
11616
11698
|
let start = block.range[0];
|
|
11617
11699
|
for (let j = i + 1; j < blocks.length; j++) {
|
|
@@ -11622,6 +11704,7 @@ function layoutDesign(lines, axis, intersectPoints, opt) {
|
|
|
11622
11704
|
ranges.push([start, nextBlock.range[0]]);
|
|
11623
11705
|
}
|
|
11624
11706
|
start = Math.max(start, nextBlock.range[1]);
|
|
11707
|
+
occupationIndexList.push(nextBlock.index);
|
|
11625
11708
|
}
|
|
11626
11709
|
if (start < block.range[1]) ranges.push([start, block.range[1]]);
|
|
11627
11710
|
ranges = ranges.filter((range) => range[1] - range[0] > 1e-4);
|
|
@@ -11636,7 +11719,10 @@ function layoutDesign(lines, axis, intersectPoints, opt) {
|
|
|
11636
11719
|
newLines.push(newLine);
|
|
11637
11720
|
}
|
|
11638
11721
|
}
|
|
11639
|
-
if (ranges.length === 0)
|
|
11722
|
+
if (ranges.length === 0) {
|
|
11723
|
+
line.currentData[DELETE_SYMBOL] = true;
|
|
11724
|
+
opt.onSegmentClippedAway?.(line, occupationIndexList.map((i2) => lines[i2]).filter((line2) => !line2.currentData[DELETE_SYMBOL]));
|
|
11725
|
+
}
|
|
11640
11726
|
}
|
|
11641
11727
|
sortByAxis(newLines, axis);
|
|
11642
11728
|
const psh = PointSpatialHash.from(intersectPoints);
|
|
@@ -11646,7 +11732,7 @@ function layoutDesign(lines, axis, intersectPoints, opt) {
|
|
|
11646
11732
|
const nextLine = newLines[i + 1];
|
|
11647
11733
|
nextLine.start.copy(line.start);
|
|
11648
11734
|
line.currentData[DELETE_SYMBOL] = true;
|
|
11649
|
-
opt.onMergeLine
|
|
11735
|
+
opt.onMergeLine?.(nextLine, line);
|
|
11650
11736
|
}
|
|
11651
11737
|
lines.length = 0;
|
|
11652
11738
|
lines.push(...newLines);
|
|
@@ -11855,7 +11941,8 @@ function correction(lines, targettLine, option) {
|
|
|
11855
11941
|
group2.forEach((line) => {
|
|
11856
11942
|
line.userData.wallWidth = dist;
|
|
11857
11943
|
});
|
|
11858
|
-
}
|
|
11944
|
+
},
|
|
11945
|
+
onSegmentClippedAway: WallHole.splitHole.bind(WallHole)
|
|
11859
11946
|
// esp: 0.4
|
|
11860
11947
|
});
|
|
11861
11948
|
}).handle("balconyRailing", (lines2) => AlignToParallelSegments.align(lines2)).merge();
|
package/src/index3.js
CHANGED
|
@@ -16813,7 +16813,7 @@ class PointDrag extends Command {
|
|
|
16813
16813
|
const wallObj = new Wall2D(wallLine, 0.02).setColor(new THREE.Color(65280));
|
|
16814
16814
|
this.container.add(wallObj);
|
|
16815
16815
|
const lineSelector = new LineSelector(this.editor);
|
|
16816
|
-
lineSelector.onPointerMove = (line22) => {
|
|
16816
|
+
lineSelector.onPointerMove = (_, line22) => {
|
|
16817
16817
|
if (line22) {
|
|
16818
16818
|
wallLine.copy(line22);
|
|
16819
16819
|
wallObj.visible = true;
|
|
@@ -16853,6 +16853,8 @@ class PointDrag extends Command {
|
|
|
16853
16853
|
line2.start.copy(newData.start);
|
|
16854
16854
|
line2.end.copy(newData.end);
|
|
16855
16855
|
WallHole.filterIllegal([line2]);
|
|
16856
|
+
this.renderManager.removeLine(line2);
|
|
16857
|
+
this.renderManager.addLine(line2);
|
|
16856
16858
|
});
|
|
16857
16859
|
}
|
|
16858
16860
|
this.renderManager.draw();
|
|
@@ -16870,6 +16872,8 @@ class PointDrag extends Command {
|
|
|
16870
16872
|
line2.start.copy(newData.start);
|
|
16871
16873
|
line2.end.copy(newData.end);
|
|
16872
16874
|
WallHole.filterIllegal([line2]);
|
|
16875
|
+
this.renderManager.removeLine(line2);
|
|
16876
|
+
this.renderManager.addLine(line2);
|
|
16873
16877
|
});
|
|
16874
16878
|
}
|
|
16875
16879
|
this.renderManager.draw();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare class Message {
|
|
2
|
+
readonly msg: string;
|
|
3
|
+
private readonly memory;
|
|
4
|
+
constructor(msg: string, memory?: Message[]);
|
|
5
|
+
getMemory(): Message[];
|
|
6
|
+
createNewMessage(msg: string): Message;
|
|
7
|
+
eqMemory(message: Message): boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface TopicTemplate {
|
|
10
|
+
ask(message: Message, pipeline: LLMPipeline): TaskResult;
|
|
11
|
+
}
|
|
12
|
+
export declare class Task {
|
|
13
|
+
private template;
|
|
14
|
+
name: string;
|
|
15
|
+
constructor(template: TopicTemplate, name?: string);
|
|
16
|
+
ask(message: Message, pipeline: LLMPipeline): Promise<TaskResult>;
|
|
17
|
+
}
|
|
18
|
+
export interface TaskResult {
|
|
19
|
+
message: Message;
|
|
20
|
+
nextTasks?: Task[];
|
|
21
|
+
stop?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare class LLMPipeline {
|
|
24
|
+
queue: Task[];
|
|
25
|
+
private currentTaskIndex;
|
|
26
|
+
/** 获取当前任务顺序
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
getTaskIndex(): number;
|
|
30
|
+
/** 插入任务, 默认队尾
|
|
31
|
+
* @param task
|
|
32
|
+
* @param index
|
|
33
|
+
*/
|
|
34
|
+
insert(task: Task, index?: number): void;
|
|
35
|
+
/** 当前任务后插入
|
|
36
|
+
* @param task
|
|
37
|
+
*/
|
|
38
|
+
insertNext(task: Task | Task[]): void;
|
|
39
|
+
/** 清理
|
|
40
|
+
*/
|
|
41
|
+
clear(): void;
|
|
42
|
+
/** 执行
|
|
43
|
+
* @param message
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
execute(msg: string): Promise<Message>;
|
|
47
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Box2 } from './Box2';
|
|
2
2
|
import { LineSegment } from './LineSegment';
|
|
3
3
|
import { Point } from './Point';
|
|
4
|
+
import { Rectangle } from './Rectangle';
|
|
4
5
|
export interface RaycastHit {
|
|
5
6
|
line: LineSegment;
|
|
6
7
|
point: Point;
|
|
@@ -60,6 +61,9 @@ export declare class LineSegmentSpatialHash {
|
|
|
60
61
|
* 查询相交线段
|
|
61
62
|
*/
|
|
62
63
|
queryLine(line: LineSegment, out?: LineSegment[]): LineSegment<Record<string, any>>[];
|
|
64
|
+
private rectangleBounds;
|
|
65
|
+
/** 通过矩形查询 */
|
|
66
|
+
queryRectangle(rectangle: Rectangle, out?: LineSegment[]): LineSegment<Record<string, any>>[];
|
|
63
67
|
private rayIntersectSegment;
|
|
64
68
|
/**
|
|
65
69
|
* 射线检测
|
|
@@ -3,6 +3,7 @@ import { Point } from './Point';
|
|
|
3
3
|
export declare class PointUtils {
|
|
4
4
|
private static _globalPoint;
|
|
5
5
|
static get globalPoint(): Point<Record<string, any>>;
|
|
6
|
+
static getCenter(points: Point[]): Point<Record<string, any>>;
|
|
6
7
|
/** 值网格化
|
|
7
8
|
* @param points
|
|
8
9
|
* @param tolerance
|
|
@@ -33,4 +34,14 @@ export declare class PointUtils {
|
|
|
33
34
|
* @returns
|
|
34
35
|
*/
|
|
35
36
|
static constrainPointToAxis(point: Point, baseLine: LineSegment, normalStartPoint?: Point | null, baseNormalLine?: LineSegment): Point<Record<string, any>>;
|
|
37
|
+
/** 导出为数组
|
|
38
|
+
* @param points
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
static toArray(points: Point[]): Float32Array<ArrayBuffer>;
|
|
42
|
+
/** 导出为数组
|
|
43
|
+
* @param points
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
static fromArray(array: Array<number> | Float32Array): Point<Record<string, any>>[];
|
|
36
47
|
}
|
|
@@ -45,6 +45,10 @@ export declare class Polygon<T = any> extends Array<Point<T>> {
|
|
|
45
45
|
* @param width
|
|
46
46
|
*/
|
|
47
47
|
closedExpansion(width: number, scale?: number): this | null;
|
|
48
|
+
/** 通过线段分割
|
|
49
|
+
* @param line
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
48
52
|
clipByLine(line: LineSegment): Polygon<Record<string, any>>[];
|
|
49
53
|
/**
|
|
50
54
|
* 获取点相对于多边形的位置
|
|
@@ -27,6 +27,14 @@ export declare class Rectangle {
|
|
|
27
27
|
* @returns 是否完全在矩形内部
|
|
28
28
|
*/
|
|
29
29
|
containsLineSegment(line: LineSegment): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 获取所有点在轴上的投影,并且返回区间
|
|
32
|
+
* @param rect
|
|
33
|
+
* @param axis
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
private projectRectangle;
|
|
37
|
+
private isProjectionOverlap;
|
|
30
38
|
/**
|
|
31
39
|
* 判断矩形是否与矩形相交
|
|
32
40
|
* @description 使用分离轴定理
|
|
@@ -43,7 +51,7 @@ export declare class Rectangle {
|
|
|
43
51
|
*
|
|
44
52
|
* @returns
|
|
45
53
|
*/
|
|
46
|
-
toBox(): Box2;
|
|
54
|
+
toBox(out?: Box2): Box2;
|
|
47
55
|
/**
|
|
48
56
|
*
|
|
49
57
|
* @param line
|