brepjs-bim 0.24.1 → 0.24.2

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.
@@ -1,7 +1,7 @@
1
1
  import { ValidSolid, Result } from 'brepjs';
2
2
  import { AnyBimElement } from '../types/bimTypes.js';
3
3
  import { BimError } from '../errors/bimError.js';
4
- import { FrameInput } from '../import/placement.js';
4
+ import { FrameInput } from '../placementFrame.js';
5
5
  export interface PlacedGeometryTestHooks {
6
6
  readonly afterPlaced?: ((solid: ValidSolid) => void) | undefined;
7
7
  }
@@ -0,0 +1,11 @@
1
+ import { Result } from 'brepjs';
2
+ import { TransformOp } from 'brepjs-families';
3
+ import { BimError } from './errors/bimError.js';
4
+ import { RigidFrame } from './placementFrame.js';
5
+ export declare function frameFromOps(ops: readonly TransformOp[]): Result<RigidFrame, BimError>;
6
+ /** Private projection control flow: the outer adapter converts this back to Result. */
7
+ export declare class FrameProjectionError extends Error {
8
+ readonly error: BimError;
9
+ constructor(error: BimError);
10
+ }
11
+ export declare function requireFrame(result: Result<RigidFrame, BimError>): RigidFrame;
@@ -2,7 +2,7 @@ import { Result, Solid, ValidSolid, csg } from 'brepjs';
2
2
  import { ResolvedElement } from 'brepjs-families';
3
3
  import { BimError } from './errors/bimError.js';
4
4
  import { ProductBody } from './types/productBody.js';
5
- import { Frame } from './placementFrame.js';
5
+ import { RigidFrame } from './placementFrame.js';
6
6
  type ExactProductBody = Extract<ProductBody, {
7
7
  readonly kind: 'EXACT';
8
8
  }>;
@@ -19,7 +19,7 @@ export interface CivilProductBodyInput {
19
19
  readonly element: ResolvedElement;
20
20
  readonly category: 'WALL' | 'RAILING';
21
21
  readonly evaluator: csg.Evaluator;
22
- readonly productWorldFrame: Frame;
22
+ readonly productWorldFrame: RigidFrame;
23
23
  /** Borrowed model-owned comparison candidate after registered openings. */
24
24
  readonly parametricBody: ParametricProductBody;
25
25
  }
@@ -1,6 +1,6 @@
1
1
  import { ValidSolid } from 'brepjs';
2
2
  import { IfcWriter } from './ifcWriter.js';
3
- import { FrameInput } from '../import/placement.js';
3
+ import { FrameInput } from '../placementFrame.js';
4
4
  import { NonEmpty } from '../types/productBody.js';
5
5
  export interface TessellationResult {
6
6
  readonly productDefinitionShapeId: number;
@@ -1,30 +1,5 @@
1
- import { MatrixTransform } from 'brepjs';
1
+ import { Mat4x4, Vec3 } from '../placementFrame.js';
2
2
  import { SpfReader } from './spfReader.js';
3
- /**
4
- * Column-major 4x4 transform, matching the layout web-ifc and OCCT use:
5
- * column c, row r lives at index c*4 + r. Columns 0-2 are the basis vectors
6
- * (axisX, axisY, axisZ); column 3 is the translation; the bottom row is
7
- * [0,0,0,1].
8
- */
9
- export type Mat4x4 = readonly [
10
- number,
11
- number,
12
- number,
13
- number,
14
- number,
15
- number,
16
- number,
17
- number,
18
- number,
19
- number,
20
- number,
21
- number,
22
- number,
23
- number,
24
- number,
25
- number
26
- ];
27
- export type Vec3 = readonly [number, number, number];
28
3
  /** A placement decomposed into origin + the two stored IFC axes (Z, X). */
29
4
  export interface WorldPlacement {
30
5
  /** Translation in millimetres (file units scaled to mm). */
@@ -78,26 +53,6 @@ export declare function composeWorldPlacement(reader: SpfReader, placementExpres
78
53
  * always a proper rotation.
79
54
  */
80
55
  export declare function readAxis2Placement3D(reader: SpfReader, placementExpressId: number, scale: number): Mat4x4 | null;
81
- /** An (origin, axisX, axisZ) frame in mm — the authoring/display side of a placement. */
82
- export interface FrameInput {
83
- readonly origin: Vec3;
84
- readonly axisX: Vec3;
85
- readonly axisZ: Vec3;
86
- }
87
- /**
88
- * Builds a row-major MatrixTransform (for brepjs `applyMatrix`) from an
89
- * (origin, axisX, axisZ) frame, using the SAME IFC orthonormalization as
90
- * {@link readAxis2Placement3D}: z = normalize(axisZ); x = normalize(axisX
91
- * projected onto the plane ⊥ z); y = z × x. The basis vectors are the matrix
92
- * columns, so the row-major linear array is [Xx,Yx,Zx, Xy,Yy,Zy, Xz,Yz,Zz];
93
- * translation = origin (mm). This is the display-side counterpart to the IFC
94
- * writer's Axis2Placement3D (Axis=Z, RefDirection=X) so on-screen placement and
95
- * the IFC export agree.
96
- */
97
- export declare function placementToMatrix(f: FrameInput): MatrixTransform;
98
- /** Decomposes a column-major matrix into origin (mm) + IFC axes (Z, X). */
99
- export declare function decomposePlacement(m: Mat4x4): WorldPlacement;
100
- export declare function identityMatrix(): Mat4x4;
101
56
  /**
102
57
  * Reads the IfcMapConversion georeferencing offset (Eastings/Northings/
103
58
  * OrthogonalHeight, scaled to mm) and true-north rotation. Returns null when
@@ -33,11 +33,11 @@ export declare class SpfReader {
33
33
  /** Uppercased IFC entity name of the instance (e.g. `IFCWALL`). */
34
34
  typeNameOf(expressId: number): string;
35
35
  getLineType(expressId: number): number;
36
- /** Builds web-ifc's internal GUID→expressId index; call before guid lookups. */
36
+ /** Builds a JS-owned index without web-ifc's unreleased per-type native vectors. */
37
37
  buildGuidMap(): void;
38
- /** expressId for a GlobalId, or undefined. Requires {@link buildGuidMap} first. */
38
+ /** expressId for a GlobalId, or undefined. Builds the index on first lookup. */
39
39
  expressIdFromGuid(guid: string): number | undefined;
40
- /** GlobalId for an express id, or undefined. Requires {@link buildGuidMap} first. */
40
+ /** GlobalId for an express id, or undefined. Builds the index on first lookup. */
41
41
  guidFromExpressId(expressId: number): string | undefined;
42
42
  /**
43
43
  * Composed world transform (column-major 16-float matrix) for a placement
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { placedSolids } from './elementFns/placedGeometry.js';
4
4
  export { bodySolids } from './types/productBody.js';
5
5
  export type { NonEmpty, ProductBody } from './types/productBody.js';
6
6
  export type { PlacedSolidsOptions } from './elementFns/placedGeometry.js';
7
- export type { FrameInput } from './import/placement.js';
7
+ export type { FrameInput } from './placementFrame.js';
8
8
  export { toIfc, toIfcValidated } from './serialize/toIfc.js';
9
9
  export type { ValidatedIfcResult } from './serialize/toIfc.js';
10
10
  export { setIfcWasmLocateFile } from './ifcRuntime.js';
@@ -1,36 +1,47 @@
1
- import { TransformOp } from 'brepjs-families';
2
- import { FrameInput, Mat4x4, Vec3, WorldPlacement } from './import/placement.js';
3
- export type Frame = Mat4x4;
4
- export declare const IDENTITY_FRAME: Frame;
5
- /** Column-major 4x4 multiply: `a . b` (apply b first, then a). */
6
- export declare function frameMul(a: Frame, b: Frame): Frame;
7
- export declare function translationFrame(v: Vec3): Frame;
8
- /**
9
- * Builds a frame from an authored `(origin, axisX, axisZ)` placement, using the
10
- * same IFC orthonormalization as `placementToMatrix`/`readAxis2Placement3D`:
11
- * z = normalize(axisZ); x = normalize(axisX projected perpendicular to z);
12
- * y = z x. Lets a civil node authored with explicit axis props enter the same
13
- * frame pipeline as a `tRotate` chain.
14
- */
15
- export declare function frameFromPlacement(f: FrameInput): Frame;
16
- /**
17
- * Rotation by `angleDeg` about `axis` (default +Z) through pivot `at` (default
18
- * origin), matching `csg.rotate` (Rodrigues; right-handed about the axis). With
19
- * a pivot the motion is `T(at) . R . T(-at)`, i.e. `p -> at + R(p - at)`.
20
- */
21
- export declare function rotationFrame(angleDeg: number, axis?: Vec3, at?: Vec3): Frame;
22
- /**
23
- * Composes an authored `TransformOp` chain into one frame, matching families'
24
- * `applyOps`: `ops[0]` is innermost (applied first). For `[A, B]` the composed
25
- * motion is `B . A`, so a point transforms as `B(A(p))`.
26
- */
27
- export declare function frameFromOps(ops: readonly TransformOp[]): Frame;
28
- /** Rigid inverse of `[R | t]`: `[R^T | -R^T t]`. */
29
- export declare function frameInverse(f: Frame): Frame;
30
- /** Decomposes a frame into origin (mm) + IFC axes (axisX, axisZ). */
31
- export declare function decomposeFrame(f: Frame): WorldPlacement;
32
- /** Translation column of a frame. */
33
- export declare function frameOrigin(f: Frame): Vec3;
34
- /** True when the rotation part is the identity (within tolerance): a pure
35
- * translation, so the existing translation-only placement path suffices. */
36
- export declare function isPureTranslation(f: Frame, eps?: number): boolean;
1
+ import { Result, MatrixTransform } from 'brepjs';
2
+ import { BimError } from './errors/bimError.js';
3
+ export type Vec3 = readonly [number, number, number];
4
+ export type Mat4x4 = readonly [
5
+ number,
6
+ number,
7
+ number,
8
+ number,
9
+ number,
10
+ number,
11
+ number,
12
+ number,
13
+ number,
14
+ number,
15
+ number,
16
+ number,
17
+ number,
18
+ number,
19
+ number,
20
+ number
21
+ ];
22
+ export interface FrameInput {
23
+ readonly origin: Vec3;
24
+ readonly axisX: Vec3;
25
+ readonly axisZ: Vec3;
26
+ }
27
+ /** Construction is private; every exposed matrix is an immutable snapshot. */
28
+ declare class RigidFrame {
29
+ #private;
30
+ private constructor();
31
+ get matrix(): Mat4x4;
32
+ static fromMatrix(input: unknown): Result<RigidFrame, BimError>;
33
+ }
34
+ export type { RigidFrame };
35
+ export declare function frameFromMatrix(input: unknown): Result<RigidFrame, BimError>;
36
+ export declare function frameFromPlacement(input: unknown): Result<RigidFrame, BimError>;
37
+ export declare function decomposeFrame(frame: RigidFrame): FrameInput;
38
+ export declare function rotationFrame(angleDeg: number, axis?: unknown, at?: unknown): Result<RigidFrame, BimError>;
39
+ export declare const IDENTITY_FRAME: RigidFrame;
40
+ export declare function translationFrame(v: unknown): Result<RigidFrame, BimError>;
41
+ /** Right operand acts first. Revalidate the result, including translation overflow. */
42
+ export declare function frameMul(a: RigidFrame, b: RigidFrame): Result<RigidFrame, BimError>;
43
+ export declare function frameInverse(frame: RigidFrame): Result<RigidFrame, BimError>;
44
+ export declare function frameOrigin(frame: RigidFrame): Vec3;
45
+ export declare function isPureTranslation(frame: RigidFrame): boolean;
46
+ /** Row-major linear transform for native geometry consumers of a validated frame. */
47
+ export declare function frameToMatrix(frame: RigidFrame): MatrixTransform;
@@ -1,4 +1,4 @@
1
1
  import { AnyShape, Dimension } from 'brepjs';
2
- import { FrameInput } from './import/placement.js';
2
+ import { RigidFrame } from './placementFrame.js';
3
3
  /** Applies a rigid placement as a location so the source BRep is not rebuilt. */
4
- export declare function locateShapeInFrame<T extends AnyShape<Dimension>>(shape: T, frame: FrameInput): T;
4
+ export declare function locateShapeInFrame<T extends AnyShape<Dimension>>(shape: T, frame: RigidFrame): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brepjs-bim",
3
- "version": "0.24.1",
3
+ "version": "0.24.2",
4
4
  "description": "BIM layer for brepjs — IFC4-aligned parametric building elements",
5
5
  "keywords": [
6
6
  "bim",
@@ -57,9 +57,9 @@
57
57
  "typescript-eslint": "*",
58
58
  "vite": "^8.0.0",
59
59
  "vite-plugin-dts": "^5.0.0",
60
- "vitest": "^4.0.0",
60
+ "vitest": "^5.0.0",
61
61
  "web-ifc": "^0.0.77",
62
- "zod": "^4.4.3"
62
+ "zod": "4.6.4"
63
63
  },
64
64
  "dependencies": {
65
65
  "brepjs-families": ">=0.1.0 <1.0.0"