@kruschdev/pascal-mep-kernel 0.1.0 → 0.1.1

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.
@@ -43,6 +43,8 @@ function aabb3Intersects2(a, b) {
43
43
  return a.minX <= b.maxX && a.maxX >= b.minX && a.minY <= b.maxY && a.maxY >= b.minY && a.minZ <= b.maxZ && a.maxZ >= b.minZ;
44
44
  }
45
45
  function segmentIntersectsAabb32(a, b, box, margin = 0, eps = 0.000001) {
46
+ if (!isVec32(a) || !isVec32(b) || !Number.isFinite(eps))
47
+ return false;
46
48
  const [mx, my, mz] = typeof margin === "number" ? [margin, margin, margin] : margin;
47
49
  const minX = box.minX - mx;
48
50
  const maxX = box.maxX + mx;
@@ -50,6 +52,9 @@ function segmentIntersectsAabb32(a, b, box, margin = 0, eps = 0.000001) {
50
52
  const maxY = box.maxY + my;
51
53
  const minZ = box.minZ - mz;
52
54
  const maxZ = box.maxZ + mz;
55
+ if (!Number.isFinite(minX) || !Number.isFinite(maxX) || !Number.isFinite(minY) || !Number.isFinite(maxY) || !Number.isFinite(minZ) || !Number.isFinite(maxZ) || minX > maxX || minY > maxY || minZ > maxZ) {
56
+ return false;
57
+ }
53
58
  let tMin = 0;
54
59
  let tMax = 1;
55
60
  const axes = [
@@ -78,7 +83,18 @@ function segmentIntersectsAabb32(a, b, box, margin = 0, eps = 0.000001) {
78
83
  return tMax >= -eps && tMin <= 1 + eps;
79
84
  }
80
85
  function createOrientedPrismY2(params) {
81
- const { centerX, centerZ, cos, sin, lxMin, lxMax, lzMin, lzMax, yMin, yMax } = params;
86
+ const { centerX, centerZ } = params;
87
+ const lxMin = Math.min(params.lxMin, params.lxMax);
88
+ const lxMax = Math.max(params.lxMin, params.lxMax);
89
+ const lzMin = Math.min(params.lzMin, params.lzMax);
90
+ const lzMax = Math.max(params.lzMin, params.lzMax);
91
+ const yMin = Math.min(params.yMin, params.yMax);
92
+ const yMax = Math.max(params.yMin, params.yMax);
93
+ const rawCos = Number.isFinite(params.cos) ? params.cos : 1;
94
+ const rawSin = Number.isFinite(params.sin) ? params.sin : 0;
95
+ const rotLen = Math.hypot(rawCos, rawSin);
96
+ const cos = rotLen > 0.000000001 ? rawCos / rotLen : 1;
97
+ const sin = rotLen > 0.000000001 ? rawSin / rotLen : 0;
82
98
  let minX = Number.POSITIVE_INFINITY;
83
99
  let maxX = Number.NEGATIVE_INFINITY;
84
100
  let minZ = Number.POSITIVE_INFINITY;
@@ -198,6 +214,7 @@ function polylineHorizontalLengthM2(path) {
198
214
  }
199
215
  return total;
200
216
  }
217
+ var MIN_PATH_SEGMENT_LEN_M = 0.0001;
201
218
  function countPathBendDegrees2(path) {
202
219
  let total = 0;
203
220
  let prevDir = null;
@@ -208,7 +225,7 @@ function countPathBendDegrees2(path) {
208
225
  const dy = b[1] - a[1];
209
226
  const dz = b[2] - a[2];
210
227
  const len = Math.hypot(dx, dy, dz);
211
- if (len < 0.00001)
228
+ if (len < MIN_PATH_SEGMENT_LEN_M)
212
229
  continue;
213
230
  const dir = [dx / len, dy / len, dz / len];
214
231
  if (prevDir) {
@@ -232,7 +249,7 @@ function countPathElbows2(path) {
232
249
  const dy = b[1] - a[1];
233
250
  const dz = b[2] - a[2];
234
251
  const len = Math.hypot(dx, dy, dz);
235
- if (len < 0.0001)
252
+ if (len < MIN_PATH_SEGMENT_LEN_M)
236
253
  continue;
237
254
  const dir = [dx / len, dy / len, dz / len];
238
255
  if (prevDir) {
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  round22,
22
22
  round32,
23
23
  round42
24
- } from "./chunk-jfzqztgh.js";
24
+ } from "./chunk-yd3hcm7n.js";
25
25
  import {
26
26
  resolveNodeLevelId2,
27
27
  belongsToLevel2,
@@ -81,19 +81,19 @@ import {
81
81
  extractCanonicalRoofSegments2,
82
82
  compileLevelRoofShell2,
83
83
  compileBuildingAnatomy2
84
- } from "./chunk-2e23cyn0.js";
84
+ } from "./chunk-kmtew7g8.js";
85
85
  import {
86
86
  compileLegalCavityGraph2,
87
87
  findLegalWallRiserPier2,
88
88
  routeInLegalCavities2
89
- } from "./chunk-0w98adg9.js";
89
+ } from "./chunk-q8cxxynd.js";
90
90
  import {
91
91
  effectivePlacementThreshold2,
92
92
  evaluatePlacementCandidate2,
93
93
  filterLegalCandidates2,
94
94
  evaluateDeclarativeRules2,
95
95
  validateRuleTable2
96
- } from "./chunk-sab5aaa6.js";
96
+ } from "./chunk-92mknkfa.js";
97
97
  export {
98
98
  ELECTRICAL_CONDUIT_HALF_OD_M2 as ELECTRICAL_CONDUIT_HALF_OD_M,
99
99
  FEET_TO_METERS2 as FEET_TO_METERS,
@@ -16,7 +16,7 @@
16
16
  * `footprint` (`precedence: 'room-first'`) and strictly beneath `roofShell.roofEnvelopeY`.
17
17
  * - Connects orthogonal neighbors (plus attic diagonals) ONLY when both `footprint.isSegmentInside`
18
18
  * and `roofShell.isPathClearOfRoof` pass, eliminating courtyard bridging and roof pokes.
19
- * 3. Under-Slab / Crawlspace Trench Layer (`under-slab`):
19
+ * 3. Under-Slab / Crawlspace Trench Layer (`under-slab` / `crawlspace`):
20
20
  * - Emits interior-footprint vertices and orthogonal edges at `subFloorElevationM` (default `-0.35 m`),
21
21
  * connected downward from solid wall riser piers.
22
22
  *
@@ -2,9 +2,9 @@ import {
2
2
  compileLegalCavityGraph2,
3
3
  findLegalWallRiserPier2,
4
4
  routeInLegalCavities2
5
- } from "../chunk-0w98adg9.js";
6
- import"../chunk-2e23cyn0.js";
7
- import"../chunk-jfzqztgh.js";
5
+ } from "../chunk-q8cxxynd.js";
6
+ import"../chunk-kmtew7g8.js";
7
+ import"../chunk-yd3hcm7n.js";
8
8
  export {
9
9
  compileLegalCavityGraph2 as compileLegalCavityGraph,
10
10
  findLegalWallRiserPier2 as findLegalWallRiserPier,
@@ -4,8 +4,8 @@ import {
4
4
  filterLegalCandidates2,
5
5
  evaluateDeclarativeRules2,
6
6
  validateRuleTable2
7
- } from "../chunk-sab5aaa6.js";
8
- import"../chunk-jfzqztgh.js";
7
+ } from "../chunk-92mknkfa.js";
8
+ import"../chunk-yd3hcm7n.js";
9
9
  export {
10
10
  effectivePlacementThreshold2 as effectivePlacementThreshold,
11
11
  evaluateDeclarativeRules2 as evaluateDeclarativeRules,
@@ -64,6 +64,11 @@ export type ElevationBandParams = {
64
64
  readonly maxYM?: number;
65
65
  readonly minAboveFloodRimM?: number;
66
66
  readonly maxHandleHeightM?: number;
67
+ /**
68
+ * Signed vertical clearance below `roofSurfaceYM` (`y <= roofSurfaceYM - effRoofMargin`).
69
+ * Positive values require clearance below the roof surface; negative values express an
70
+ * audit tolerance above the roof plane (paired with `placementMarginM >= 0` for stricter placement).
71
+ */
67
72
  readonly roofMarginM?: number;
68
73
  readonly atticThresholdOffsetM?: number;
69
74
  };
@@ -223,5 +228,5 @@ export type RuleEvaluationSummary = {
223
228
  };
224
229
  export type RuleTableValidationResult = {
225
230
  readonly valid: boolean;
226
- readonly errors: string[];
231
+ readonly errors: readonly string[];
227
232
  };
package/dist/types.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  round22,
22
22
  round32,
23
23
  round42
24
- } from "./chunk-jfzqztgh.js";
24
+ } from "./chunk-yd3hcm7n.js";
25
25
  export {
26
26
  FEET_TO_METERS2 as FEET_TO_METERS,
27
27
  INCHES_TO_METERS2 as INCHES_TO_METERS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kruschdev/pascal-mep-kernel",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Shared zero-dependency 3-layer spatial anatomy, legal-cavity MEP routing graph, and single-source declarative code constraint engine for Pascal Editor plugins.",
5
5
  "author": "Kevin Ruschman <kruschdev@users.noreply.github.com>",
6
6
  "license": "MIT",