build-dxf 0.0.15 → 0.0.16
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
package/src/build.js
CHANGED
|
@@ -2138,13 +2138,8 @@ class LineAnalysis extends Component {
|
|
|
2138
2138
|
* 门的位置判断
|
|
2139
2139
|
*/
|
|
2140
2140
|
doorsAnalysis() {
|
|
2141
|
-
|
|
2142
|
-
const doorPoints = [];
|
|
2143
|
-
const pointVirtualGrid = this.pointVirtualGrid;
|
|
2144
|
-
const quadtree = this.quadtree;
|
|
2145
|
-
const doorSearchNearAngle = this.doorSearchNearAngle;
|
|
2146
|
-
const doorSearchDistance = this.doorSearchDistance;
|
|
2147
|
-
const doors = [];
|
|
2141
|
+
this.parent?.findComponentByName("Renderer");
|
|
2142
|
+
const dxf = this.Dxf, doorPoints = [], pointVirtualGrid = this.pointVirtualGrid, quadtree = this.quadtree, doorSearchNearAngle = this.doorSearchNearAngle, doorSearchDistance = this.doorSearchDistance, doors = [];
|
|
2148
2143
|
const excludePoints = dxf.doors.flatMap((item) => {
|
|
2149
2144
|
const index2 = item[4];
|
|
2150
2145
|
const doorData = dxf.originalData[index2];
|
|
@@ -2362,24 +2357,79 @@ class LineAnalysis extends Component {
|
|
|
2362
2357
|
};
|
|
2363
2358
|
}).filter((i) => !!i && i.start.distance(i.end) < doorSearchDistance);
|
|
2364
2359
|
doors.push(...doors_);
|
|
2365
|
-
searchNearRasult.forEach((item) => {
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2360
|
+
searchNearRasult.forEach((item, i) => {
|
|
2361
|
+
const start = doorPoints[item.doorIndex].point.clone();
|
|
2362
|
+
const end = doorPoints[item.findDoorIndex].point.clone();
|
|
2363
|
+
const startLine = this.findLongLineSegment(doorPoints[item.doorIndex].line);
|
|
2364
|
+
const endLine = this.findLongLineSegment(doorPoints[item.findDoorIndex].line);
|
|
2365
|
+
const p = startLine.projectPoint(end);
|
|
2366
|
+
if (p) {
|
|
2367
|
+
start.copy(p);
|
|
2368
|
+
const l = new LineSegment(start, end);
|
|
2369
|
+
const angle = endLine.includedAngle(l);
|
|
2370
|
+
if (angle < 10 || angle > 170 || Math.abs(90 - angle) < 10) {
|
|
2371
|
+
doors.push({
|
|
2372
|
+
start,
|
|
2373
|
+
end,
|
|
2374
|
+
index: doorPoints[item.doorIndex].index
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2377
|
+
} else {
|
|
2378
|
+
const p2 = endLine.projectPoint(start);
|
|
2379
|
+
if (p2) end.copy(p2);
|
|
2380
|
+
const l = new LineSegment(start, end);
|
|
2381
|
+
const angle = startLine.includedAngle(l);
|
|
2382
|
+
if (angle < 10 || angle > 170 || Math.abs(90 - angle) < 10) {
|
|
2383
|
+
doors.push({
|
|
2384
|
+
start,
|
|
2385
|
+
end,
|
|
2386
|
+
index: doorPoints[item.doorIndex].index
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2371
2390
|
});
|
|
2372
2391
|
dxf.doorLineSegment.length = 0;
|
|
2373
|
-
doors.forEach((p) =>
|
|
2374
|
-
|
|
2375
|
-
const len =
|
|
2376
|
-
if (len < 0.4) return
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2392
|
+
doors.forEach((p) => {
|
|
2393
|
+
const line = new LineSegment(p?.start, p?.end);
|
|
2394
|
+
const len = line.length();
|
|
2395
|
+
if (len < 0.4) return;
|
|
2396
|
+
const center = line.center, normal = line.normal();
|
|
2397
|
+
const rLine = new LineSegment(
|
|
2398
|
+
center.clone(),
|
|
2399
|
+
center.clone().add(normal.clone().multiplyScalar(1))
|
|
2400
|
+
);
|
|
2401
|
+
rLine.directionMove(normal, -0.5);
|
|
2402
|
+
const res = this.quadtree?.queryLineSegment(rLine);
|
|
2403
|
+
if (res?.length) return;
|
|
2404
|
+
dxf.doorLineSegment.push(line);
|
|
2381
2405
|
});
|
|
2382
2406
|
}
|
|
2407
|
+
findLongLineSegment(line) {
|
|
2408
|
+
const resLine = line.clone();
|
|
2409
|
+
const res1 = this.pointVirtualGrid.queryPoint(line.start);
|
|
2410
|
+
const res2 = this.pointVirtualGrid.queryPoint(line.end);
|
|
2411
|
+
for (let i = 0; i < res1.length; i++) {
|
|
2412
|
+
const { userData } = res1[i];
|
|
2413
|
+
const line2 = this.lineSegmentList[userData?.index];
|
|
2414
|
+
if (line2 === line) continue;
|
|
2415
|
+
if (line2 && line2.directionEqual(line)) {
|
|
2416
|
+
if (line2.start.equal(line.start)) resLine.start.copy(line2.end);
|
|
2417
|
+
else resLine.start.copy(line2.start);
|
|
2418
|
+
break;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
for (let i = 0; i < res2.length; i++) {
|
|
2422
|
+
const { userData } = res2[i];
|
|
2423
|
+
const line2 = this.lineSegmentList[userData?.index];
|
|
2424
|
+
if (line2 === line) continue;
|
|
2425
|
+
if (line2 && line2.directionEqual(line)) {
|
|
2426
|
+
if (line2.end.equal(line.end)) resLine.end.copy(line2.start);
|
|
2427
|
+
else resLine.end.copy(line2.end);
|
|
2428
|
+
break;
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
return resLine;
|
|
2432
|
+
}
|
|
2383
2433
|
}
|
|
2384
2434
|
class DxfSystem extends ComponentManager {
|
|
2385
2435
|
Dxf;
|