rm-graphical-computing 1.0.53 → 1.0.54

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.
Files changed (2) hide show
  1. package/README.md +229 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,229 @@
1
+ # rm-graphical-computing
2
+
3
+ Three.js 建筑点云处理工具库 —— 提供墙体几何处理、梁线/柱线检测、点云语义合并、墙-窗匹配等功能。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install rm-graphical-computing
9
+ ```
10
+
11
+ ## API 文档
12
+
13
+ ### 1. 墙-窗匹配算法
14
+
15
+ #### processData
16
+
17
+ 墙-窗匹配主函数,自动筛选窗户并完成匹配。
18
+
19
+ ```typescript
20
+ processData(
21
+ wallSegments: WallSegment[],
22
+ objects: any[],
23
+ options?: FindWallOptions & { printOnly?: boolean }
24
+ ): { segments: WallSegment[]; matches: WindowWallMatch[]; sourceMap: number[][] }
25
+ ```
26
+
27
+ **参数说明:**
28
+ | 参数 | 类型 | 说明 |
29
+ |------|------|------|
30
+ | `wallSegments` | `WallSegment[]` | 墙线段数组 |
31
+ | `objects` | `any[]` | 所有物体数组,内部自动筛选 `category === 'window'` 的物体 |
32
+ | `options` | `FindWallOptions` | 匹配选项(可选) |
33
+
34
+ **返回值:**
35
+ | 字段 | 类型 | 说明 |
36
+ |------|------|------|
37
+ | `segments` | `WallSegment[]` | 合并后的墙线段(含 `drawWindow` 属性) |
38
+ | `matches` | `WindowWallMatch[]` | 窗户匹配详情列表 |
39
+ | `sourceMap` | `number[][]` | 每条输出线段对应的原始线段索引 |
40
+
41
+ #### findWindowWalls
42
+
43
+ 窗户匹配核心函数。
44
+
45
+ ```typescript
46
+ findWindowWalls(
47
+ windowObjs: WindowObject[],
48
+ wallSegments: WallSegment[],
49
+ options?: FindWallOptions
50
+ ): WindowWallMatch[]
51
+ ```
52
+
53
+ #### mergeCollinearSegments
54
+
55
+ 共线线段合并。
56
+
57
+ ```typescript
58
+ mergeCollinearSegments(
59
+ segments: WallSegment[],
60
+ angleTol?: number, // 角度容差,默认 5°
61
+ gapTol?: number // 间隙容差,默认 0.05m
62
+ ): { segments: WallSegment[]; sourceMap: number[][] }
63
+ ```
64
+
65
+ #### computeLocalFloorZ
66
+
67
+ 计算局部地面高度。
68
+
69
+ ```typescript
70
+ computeLocalFloorZ(walls: WallSegment[], cx: number, cy: number): number
71
+ ```
72
+
73
+ #### FindWallOptions 选项
74
+
75
+ | 选项 | 类型 | 默认值 | 说明 |
76
+ |------|------|--------|------|
77
+ | `minLengthRatio` | `number` | `1.0` | 墙线长度至少为窗户长边的倍数 |
78
+ | `maxDistance` | `number` | `0.5` | 窗户中心到墙线的最大垂直距离(m) |
79
+ | `angleThreshold` | `number` | `45` | 墙线与窗户长边方向的最大夹角(°) |
80
+ | `projectionMargin` | `number` | `0.1` | 垂足在线段上的容许范围 |
81
+ | `printOnly` | `boolean` | `false` | 是否仅打印信息而不写入 `drawWindow` |
82
+
83
+ ### 2. 梁线检测
84
+
85
+ ```typescript
86
+ getBeamLine(lines: any[], runDataList: any[], pcdData: any): Promise<any>
87
+ getMainBeamLine(lines: any[], runDataList: any[], pcdData: any): Promise<any>
88
+ usegetBeamLine(lines: any[], runDataList: any[], pcdData: any): Promise<any>
89
+ ```
90
+
91
+ ### 3. 柱线检测
92
+
93
+ ```typescript
94
+ getColLine(lines: any[], runDataList: any[]): Promise<any>
95
+ ```
96
+
97
+ ### 4. 墙体几何处理
98
+
99
+ ```typescript
100
+ getAllGeometry(data: any): any
101
+ ```
102
+
103
+ ### 5. 点云语义合并
104
+
105
+ ```typescript
106
+ getMergeMeaning(allProjectionResults: any[]): any
107
+ ```
108
+
109
+ ### 6. 工具函数
110
+
111
+ | 函数 | 说明 |
112
+ |------|------|
113
+ | `segmentsIntersect2D(a, b)` | 判断两条线段是否相交(2D) |
114
+ | `isParallel(a, b, tolerance?)` | 判断两个向量是否平行 |
115
+ | `getParallelism(a, b)` | 获取向量平行度信息 |
116
+ | `perpendicularInfo(segment)` | 获取线段的垂直信息 |
117
+ | `classifySegments(segments)` | 分类线段(共线/偏移/重叠) |
118
+ | `getPointCoverageOnQuad(points, quad)` | 计算点云在四边形上的覆盖率 |
119
+ | `getPointCloudMinMax(points)` | 获取点云的最小/最大边界 |
120
+ | `removeNoisePoints(points, threshold)` | 去除噪点 |
121
+ | `updateStEdPoint(line, start, end)` | 更新线段端点 |
122
+
123
+ ## 类型定义
124
+
125
+ ### Point3D
126
+
127
+ ```typescript
128
+ interface Point3D {
129
+ x: number
130
+ y: number
131
+ z: number
132
+ }
133
+ ```
134
+
135
+ ### WallSegment
136
+
137
+ ```typescript
138
+ interface WallSegment {
139
+ start: Point3D
140
+ end: Point3D
141
+ length: number
142
+ direction: Point3D
143
+ points: Point3D[]
144
+ originalPoints?: Point3D[]
145
+ rooftopPz?: number
146
+ drawWindow?: DrawWindow[]
147
+ // ... 其他属性
148
+ }
149
+ ```
150
+
151
+ ### DrawWindow
152
+
153
+ ```typescript
154
+ interface DrawWindow {
155
+ p: Point3D // 窗户中心点
156
+ width: number // 窗户宽度(m)
157
+ height: number // 窗户高度(m)
158
+ full: boolean // 是否贯穿整面墙
159
+ groundClearance: number // 离地高度(m)
160
+ }
161
+ ```
162
+
163
+ ### WindowWallMatch
164
+
165
+ ```typescript
166
+ interface WindowWallMatch {
167
+ windowName: string
168
+ windowCategory: string
169
+ windowCenter: Point3D
170
+ wallSegment: WallSegment
171
+ distance: number // 窗户中心到墙线的垂直距离(m)
172
+ wallLengthRatio: number // 墙线长度 / 窗户长边
173
+ drawWindow?: DrawWindow
174
+ }
175
+ ```
176
+
177
+ ## 使用示例
178
+
179
+ ```typescript
180
+ import { processData } from 'rm-graphical-computing'
181
+
182
+ // 墙线段数据
183
+ const wallSegments = [
184
+ {
185
+ start: { x: 0, y: 0, z: 0 },
186
+ end: { x: 5, y: 0, z: 0 },
187
+ length: 5,
188
+ direction: { x: 1, y: 0, z: 0 },
189
+ points: []
190
+ }
191
+ ]
192
+
193
+ // 物体数据(包含窗户)
194
+ const objects = [
195
+ {
196
+ name: 'Window_001',
197
+ category: 'window',
198
+ center: { x: 2.5, y: 0.2, z: 1 },
199
+ box: { min: { x: 2, y: 0, z: 0.5 }, max: { x: 3, y: 0.4, z: 1.5 } },
200
+ coordinatesByArea: { coordinates: [...] }
201
+ }
202
+ ]
203
+
204
+ // 执行匹配
205
+ const result = processData(wallSegments, objects, {
206
+ maxDistance: 0.5,
207
+ minLengthRatio: 0.95
208
+ })
209
+
210
+ console.log(result.segments) // 合并后的墙线段
211
+ console.log(result.matches) // 匹配结果
212
+ ```
213
+
214
+ ## 技术特性
215
+
216
+ 1. **共线合并**:自动合并角度相近、方向一致的墙线段
217
+ 2. **多信号评分**:综合端点连接度、距离方差、垂直墙同侧性进行匹配评分
218
+ 3. **drawWindow 注入**:将窗户位置信息写入墙线段,便于后续渲染
219
+ 4. **TypeScript 支持**:完整的类型定义
220
+
221
+ ## 依赖
222
+
223
+ - `three`: ^0.183.2
224
+ - `three-mesh-bvh`: ^0.9.10
225
+ - `d3-delaunay`: ^6.0.4
226
+
227
+ ## 许可证
228
+
229
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rm-graphical-computing",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "description": "Three.js wall segment processing utilities.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -11,7 +11,8 @@
11
11
  }
12
12
  },
13
13
  "files": [
14
- "dist"
14
+ "dist",
15
+ "README.md"
15
16
  ],
16
17
  "scripts": {
17
18
  "dev": "vite",