brepjs 2.0.1 → 2.0.3

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/dist/brepjs.d.ts CHANGED
@@ -73,6 +73,12 @@ export declare function andThen<T, U, E>(result: Result<T, E>, fn: (value: T) =>
73
73
 
74
74
  export declare type AnyShape = Vertex | Edge | Wire | Face | Shell | Solid | CompSolid | Compound;
75
75
 
76
+ /**
77
+ * Applies glue optimization to a boolean operation.
78
+ *
79
+ * @param op - Boolean operation builder with SetGlue method
80
+ * @param optimisation - Optimization level: 'none', 'commonFace', or 'sameFace'
81
+ */
76
82
  export declare function applyGlue(op: {
77
83
  SetGlue(glue: OcType): void;
78
84
  }, optimisation: 'none' | 'commonFace' | 'sameFace'): void;
@@ -83,8 +89,16 @@ declare interface ApproximationOptions {
83
89
  maxSegments?: number;
84
90
  }
85
91
 
92
+ /**
93
+ * @deprecated Use toOcDir from occtBoundary.ts with Vec3 tuples instead.
94
+ * @see toOcDir
95
+ */
86
96
  export declare function asDir(coords: Point): OcType;
87
97
 
98
+ /**
99
+ * @deprecated Use toOcPnt from occtBoundary.ts with Vec3 tuples instead.
100
+ * @see toOcPnt
101
+ */
88
102
  export declare function asPnt(coords: Point): OcType;
89
103
 
90
104
  export declare const assembleWire: (listOfEdges: (Edge | Wire)[]) => Result<Wire>;
@@ -277,6 +291,24 @@ export declare interface BooleanOptions {
277
291
  strategy?: 'native' | 'pairwise';
278
292
  }
279
293
 
294
+ /**
295
+ * @deprecated Use getBounds() from shapeFns.ts which returns a Bounds3D plain object.
296
+ * @example
297
+ * // Before (legacy):
298
+ * const bbox = shape.boundingBox;
299
+ * const center = bbox.center;
300
+ *
301
+ * // After (functional):
302
+ * import { getBounds, type Bounds3D } from 'brepjs';
303
+ * const bounds: Bounds3D = getBounds(shape);
304
+ * const center = [
305
+ * (bounds.xMin + bounds.xMax) / 2,
306
+ * (bounds.yMin + bounds.yMax) / 2,
307
+ * (bounds.zMin + bounds.zMax) / 2
308
+ * ];
309
+ *
310
+ * @see getBounds, Bounds3D
311
+ */
280
312
  export declare class BoundingBox extends WrappingObj<OcType> {
281
313
  constructor(wrapped?: OcType);
282
314
  get repr(): string;
@@ -343,6 +375,9 @@ export declare interface BSplineApproximationConfig {
343
375
  */
344
376
  export declare function bug(location: string, message: string): never;
345
377
 
378
+ /**
379
+ * Builds a TopoDS_Compound from Shape3D instances.
380
+ */
346
381
  export declare function buildCompound(shapes: Shape3D[]): OcShape;
347
382
 
348
383
  /**
@@ -574,6 +609,10 @@ export declare function createDistanceQuery(referenceShape: FnAnyShape): {
574
609
  /** Create a disposable shape handle. */
575
610
  export declare function createHandle(ocShape: OcShape): ShapeHandle;
576
611
 
612
+ /**
613
+ * @deprecated Use createNamedPlane from planeOps.ts which returns a functional Plane.
614
+ * @see createNamedPlane from planeOps.ts (exported as fnCreateNamedPlane from brepjs)
615
+ */
577
616
  export declare const createNamedPlane: (plane: PlaneName, sourceOrigin?: Point | number) => Result<Plane>;
578
617
 
579
618
  /** Create a disposable handle for any OCCT object. */
@@ -1186,12 +1225,12 @@ export declare function faceFinder(): FaceFinderFn;
1186
1225
  export declare interface FaceFinderFn extends ShapeFinder<FnFace> {
1187
1226
  readonly inDirection: (dir?: 'X' | 'Y' | 'Z' | Vec3, angle?: number) => FaceFinderFn;
1188
1227
  readonly parallelTo: (dir?: 'X' | 'Y' | 'Z' | Vec3) => FaceFinderFn;
1189
- readonly ofSurfaceType: (surfaceType: SurfaceType_2) => FaceFinderFn;
1228
+ readonly ofSurfaceType: (surfaceType: SurfaceType) => FaceFinderFn;
1190
1229
  readonly atDistance: (distance: number, point?: Vec3) => FaceFinderFn;
1191
1230
  }
1192
1231
 
1193
1232
  /** Get the surface type of a face (unwrapped convenience). */
1194
- export declare function faceGeomType(face: FnFace): SurfaceType_2;
1233
+ export declare function faceGeomType(face: FnFace): SurfaceType;
1195
1234
 
1196
1235
  declare type FaceOrEdge = Face | Edge;
1197
1236
 
@@ -1239,12 +1278,6 @@ export declare interface FaceTriangulation {
1239
1278
  verticesNormals: number[];
1240
1279
  }
1241
1280
 
1242
- declare interface FaceTriangulation_2 {
1243
- vertices: number[];
1244
- trianglesIndexes: number[];
1245
- verticesNormals: number[];
1246
- }
1247
-
1248
1281
  export declare type FilletRadius = number | [number, number];
1249
1282
 
1250
1283
  export declare type FilterFcn<Type> = {
@@ -1515,17 +1548,6 @@ export declare interface FnShapeConfig {
1515
1548
  name?: string;
1516
1549
  }
1517
1550
 
1518
- export declare interface FnShapeMesh {
1519
- triangles: Uint32Array;
1520
- vertices: Float32Array;
1521
- normals: Float32Array;
1522
- faceGroups: {
1523
- start: number;
1524
- count: number;
1525
- faceId: number;
1526
- }[];
1527
- }
1528
-
1529
1551
  export declare type FnShell = ShapeHandle & {
1530
1552
  readonly [__brand]: 'shell';
1531
1553
  };
@@ -1541,7 +1563,7 @@ export declare type FnSolid = ShapeHandle & {
1541
1563
  };
1542
1564
 
1543
1565
  /** Extrude a wire with support surface. */
1544
- export declare function fnSupportExtrude(wire: FnWire, center: Vec3, normal: Vec3, support: OcType_3): Result<FnShape3D>;
1566
+ export declare function fnSupportExtrude(wire: FnWire, center: Vec3, normal: Vec3, support: OcType_4): Result<FnShape3D>;
1545
1567
 
1546
1568
  /** Extrude a wire with twist along a normal. Angle is in degrees. */
1547
1569
  export declare function fnTwistExtrude(wire: FnWire, angleDegrees: number, center: Vec3, normal: Vec3, profileShape?: ExtrusionProfile, shellMode?: boolean): Result<FnShape3D | [FnShape3D, FnWire, FnWire]>;
@@ -1558,13 +1580,13 @@ export declare type FnWire = ShapeHandle & {
1558
1580
  };
1559
1581
 
1560
1582
  /** Extract Vec3 from OCCT gp_Dir */
1561
- export declare function fromOcDir(ocDir: OcType_2): Vec3;
1583
+ export declare function fromOcDir(ocDir: OcType_3): Vec3;
1562
1584
 
1563
1585
  /** Extract Vec3 from OCCT gp_Pnt */
1564
- export declare function fromOcPnt(ocPnt: OcType_2): Vec3;
1586
+ export declare function fromOcPnt(ocPnt: OcType_3): Vec3;
1565
1587
 
1566
1588
  /** Extract Vec3 from OCCT gp_Vec */
1567
- export declare function fromOcVec(ocVec: OcType_2): Vec3;
1589
+ export declare function fromOcVec(ocVec: OcType_3): Vec3;
1568
1590
 
1569
1591
  export declare const fuse2D: (first: Shape2D, second: Shape2D) => Blueprint | Blueprints | CompoundBlueprint | null;
1570
1592
 
@@ -1886,14 +1908,10 @@ export declare function genericSweep(wire: Wire, spine: Wire, sweepConfig: Gener
1886
1908
 
1887
1909
  export declare function genericSweep(wire: Wire, spine: Wire, sweepConfig: GenericSweepConfig, shellMode?: false): Result<Shape3D>;
1888
1910
 
1889
- export declare interface GenericSweepConfig {
1890
- frenet?: boolean;
1911
+ /** Configuration for sweep operations in the OO API. */
1912
+ export declare interface GenericSweepConfig extends Omit<SweepConfig, 'auxiliarySpine'> {
1913
+ /** Auxiliary spine for twist control (Wire or Edge in OO API) */
1891
1914
  auxiliarySpine?: Wire | Edge;
1892
- law?: OcType;
1893
- transitionMode?: 'right' | 'transformed' | 'round';
1894
- withContact?: boolean;
1895
- support?: OcType;
1896
- forceProfileSpineOthogonality?: boolean;
1897
1915
  }
1898
1916
 
1899
1917
  export declare type GenericTopo = OcShape;
@@ -1922,7 +1940,7 @@ export declare function getShapeKind(shape: FnAnyShape): ShapeKind;
1922
1940
  export declare function getSingleFace(f: SingleFace, shape: AnyShape): Result<Face>;
1923
1941
 
1924
1942
  /** Get the geometric surface type of a face. */
1925
- export declare function getSurfaceType(face: FnFace): Result<SurfaceType_2>;
1943
+ export declare function getSurfaceType(face: FnFace): Result<SurfaceType>;
1926
1944
 
1927
1945
  /** Get all wires of a shape as branded Wire handles. */
1928
1946
  export declare function getWires(shape: FnAnyShape): FnWire[];
@@ -2008,10 +2026,22 @@ export declare function loftWires(wires: FnWire[], { ruled, startPoint, endPoint
2008
2026
 
2009
2027
  export declare function lookFromPlane(projectionPlane: ProjectionPlane): ProjectionCamera;
2010
2028
 
2029
+ /**
2030
+ * @deprecated Use makeOcAx1 from occtBoundary.ts with Vec3 tuples instead.
2031
+ * @see makeOcAx1
2032
+ */
2011
2033
  export declare const makeAx1: (center: Point, dir: Point) => OcType;
2012
2034
 
2035
+ /**
2036
+ * @deprecated Use makeOcAx2 from occtBoundary.ts with Vec3 tuples instead.
2037
+ * @see makeOcAx2
2038
+ */
2013
2039
  export declare const makeAx2: (center: Point, dir: Point, xDir?: Point) => OcType;
2014
2040
 
2041
+ /**
2042
+ * @deprecated Use makeOcAx3 from occtBoundary.ts with Vec3 tuples instead.
2043
+ * @see makeOcAx3
2044
+ */
2015
2045
  export declare const makeAx3: (center: Point, dir: Point, xDir?: Point) => OcType;
2016
2046
 
2017
2047
  export declare const makeBaseBox: (xLength: number, yLength: number, zLength: number) => Shape3D;
@@ -2146,7 +2176,7 @@ export declare interface MeshOptions {
2146
2176
  export declare function meshShape(shape: FnAnyShape, { tolerance, angularTolerance, skipNormals, cache, }?: MeshOptions & {
2147
2177
  skipNormals?: boolean;
2148
2178
  cache?: boolean;
2149
- }): FnShapeMesh;
2179
+ }): ShapeMesh;
2150
2180
 
2151
2181
  /** Mesh the edges of a shape as line segments for edge rendering. */
2152
2182
  export declare function meshShapeEdges(shape: FnAnyShape, { tolerance, angularTolerance, cache }?: MeshOptions & {
@@ -2179,13 +2209,19 @@ declare type OcShape = any;
2179
2209
 
2180
2210
  declare type OcType = any;
2181
2211
 
2212
+ /**
2213
+ * Shared utilities for extrusion operations.
2214
+ * Used by both class-based (extrude.ts) and functional (extrudeFns.ts) APIs.
2215
+ */
2182
2216
  declare type OcType_2 = any;
2183
2217
 
2218
+ declare type OcType_3 = any;
2219
+
2184
2220
  /**
2185
2221
  * Functional extrusion operations using Vec3 tuples and branded shape types.
2186
2222
  * Immutable: all functions return new shapes without disposing inputs.
2187
2223
  */
2188
- declare type OcType_3 = any;
2224
+ declare type OcType_4 = any;
2189
2225
 
2190
2226
  declare interface Offset2DConfig {
2191
2227
  lineJoinType?: 'miter' | 'bevel' | 'round';
@@ -2232,6 +2268,20 @@ export declare interface PhysicalProps {
2232
2268
  /** Pivot plane by rotating around an axis. */
2233
2269
  export declare function pivotPlane(plane: FnPlane, angleDeg: number, axis?: Vec3): FnPlane;
2234
2270
 
2271
+ /**
2272
+ * @deprecated Use the Plane interface from planeTypes.ts with planeOps functions instead.
2273
+ * @example
2274
+ * // Before (legacy):
2275
+ * const plane = new Plane([0, 0, 0], [1, 0, 0], [0, 0, 1]);
2276
+ * const moved = plane.translate([1, 0, 0]);
2277
+ *
2278
+ * // After (functional):
2279
+ * import { createPlane, translatePlane, type Plane as FnPlane } from 'brepjs';
2280
+ * const plane: FnPlane = createPlane([0, 0, 0], [1, 0, 0], [0, 0, 1]);
2281
+ * const moved = translatePlane(plane, [1, 0, 0]);
2282
+ *
2283
+ * @see createPlane, translatePlane, pivotPlane, rotatePlane2DAxes
2284
+ */
2235
2285
  export declare class Plane {
2236
2286
  oc: OpenCascadeInstance;
2237
2287
  xDir: Vector;
@@ -2544,7 +2594,7 @@ export declare interface ShapeHandle {
2544
2594
 
2545
2595
  export declare type ShapeKind = 'vertex' | 'edge' | 'wire' | 'face' | 'shell' | 'solid' | 'compsolid' | 'compound';
2546
2596
 
2547
- export declare interface ShapeMesh {
2597
+ declare interface ShapeMesh {
2548
2598
  triangles: Uint32Array;
2549
2599
  vertices: Float32Array;
2550
2600
  normals: Float32Array;
@@ -2554,29 +2604,25 @@ export declare interface ShapeMesh {
2554
2604
  faceId: number;
2555
2605
  }[];
2556
2606
  }
2607
+ export { ShapeMesh as FnShapeMesh }
2608
+ export { ShapeMesh }
2557
2609
 
2558
2610
  declare namespace ShapesModule {
2559
2611
  export {
2560
- registerQueryModule,
2561
- isNumber,
2562
- isChamferRadius,
2563
- isFilletRadius,
2564
2612
  isShape3D_2 as isShape3D,
2565
- buildCompoundOc,
2566
- buildCompound,
2567
- applyGlue,
2568
- fuseAll,
2569
- cutAll,
2570
2613
  CurveType,
2571
2614
  AnyShape,
2572
2615
  Shape3D,
2573
2616
  CurveLike,
2574
- ChamferRadius,
2575
- FilletRadius,
2576
- RadiusConfig,
2577
2617
  FaceTriangulation,
2578
2618
  ShapeMesh,
2579
2619
  SurfaceType,
2620
+ ChamferRadius,
2621
+ FilletRadius,
2622
+ RadiusConfig,
2623
+ isNumber,
2624
+ isChamferRadius,
2625
+ isFilletRadius,
2580
2626
  BooleanOperationOptions,
2581
2627
  Shape,
2582
2628
  Vertex,
@@ -2590,7 +2636,13 @@ declare namespace ShapesModule {
2590
2636
  Shell,
2591
2637
  Solid,
2592
2638
  CompSolid,
2593
- Compound
2639
+ Compound,
2640
+ fuseAll,
2641
+ cutAll,
2642
+ buildCompound,
2643
+ buildCompoundOc,
2644
+ applyGlue,
2645
+ registerQueryModule
2594
2646
  }
2595
2647
  }
2596
2648
 
@@ -2965,18 +3017,26 @@ export declare class SurfacePhysicalProperties extends PhysicalProperties {
2965
3017
 
2966
3018
  export declare type SurfaceType = 'PLANE' | 'CYLINDRE' | 'CONE' | 'SPHERE' | 'TORUS' | 'BEZIER_SURFACE' | 'BSPLINE_SURFACE' | 'REVOLUTION_SURFACE' | 'EXTRUSION_SURFACE' | 'OFFSET_SURFACE' | 'OTHER_SURFACE';
2967
3019
 
2968
- declare type SurfaceType_2 = 'PLANE' | 'CYLINDRE' | 'CONE' | 'SPHERE' | 'TORUS' | 'BEZIER_SURFACE' | 'BSPLINE_SURFACE' | 'REVOLUTION_SURFACE' | 'EXTRUSION_SURFACE' | 'OFFSET_SURFACE' | 'OTHER_SURFACE';
2969
-
2970
3020
  /** Sweep a wire profile along a spine. Returns a solid or shell+wires. */
2971
3021
  export declare function sweep(wire: FnWire, spine: FnWire, config?: SweepConfig, shellMode?: boolean): Result<FnShape3D | [FnShape3D, FnWire, FnWire]>;
2972
3022
 
3023
+ /** Configuration for sweep/pipe operations along a spine. */
2973
3024
  export declare interface SweepConfig {
3025
+ /** Use Frenet trihedron for profile orientation */
2974
3026
  frenet?: boolean;
2975
- auxiliarySpine?: FnWire | FnEdge;
2976
- law?: OcType_3;
3027
+ /** Auxiliary spine for twist control */
3028
+ auxiliarySpine?: {
3029
+ wrapped: OcType_2;
3030
+ };
3031
+ /** Scaling law along the path */
3032
+ law?: OcType_2;
3033
+ /** Transition mode at corners: 'right' (sharp), 'transformed', or 'round' */
2977
3034
  transitionMode?: 'right' | 'transformed' | 'round';
3035
+ /** Enable contact detection */
2978
3036
  withContact?: boolean;
2979
- support?: OcType_3;
3037
+ /** Support surface for constrained sweeps */
3038
+ support?: OcType_2;
3039
+ /** Force profile to be orthogonal to spine */
2980
3040
  forceProfileSpineOthogonality?: boolean;
2981
3041
  }
2982
3042
 
@@ -2988,7 +3048,7 @@ export declare function textBlueprints(text: string, { startX, startY, fontSize,
2988
3048
  }): Blueprints;
2989
3049
 
2990
3050
  /** Convert Vec3 to OCCT gp_Vec. Caller must call .delete() when done. */
2991
- export declare function toOcVec(v: Vec3): OcType_2;
3051
+ export declare function toOcVec(v: Vec3): OcType_3;
2992
3052
 
2993
3053
  export declare type TopoEntity = 'vertex' | 'edge' | 'wire' | 'face' | 'shell' | 'solid' | 'solidCompound' | 'compound' | 'shape';
2994
3054
 
@@ -2998,6 +3058,20 @@ export declare function toVec2(p: PointInput): Vec2;
2998
3058
  /** Normalize any point input to Vec3 */
2999
3059
  export declare function toVec3(p: PointInput): Vec3;
3000
3060
 
3061
+ /**
3062
+ * @deprecated Use standalone transform functions instead.
3063
+ * @example
3064
+ * // Before (legacy):
3065
+ * const trsf = new Transformation();
3066
+ * trsf.translate([1, 0, 0]);
3067
+ * const newShape = trsf.transform(shape.wrapped);
3068
+ *
3069
+ * // After (functional):
3070
+ * import { translateShape } from 'brepjs';
3071
+ * const newShape = translateShape(shape, [1, 0, 0]);
3072
+ *
3073
+ * @see translateShape, rotateShape, mirrorShape, scaleShape
3074
+ */
3001
3075
  export declare class Transformation extends WrappingObj<OcType> {
3002
3076
  constructor(transform?: OcType);
3003
3077
  translate(xDist: number, yDist: number, zDist: number): Transformation;
@@ -3030,7 +3104,7 @@ export declare function translateShape<T extends FnAnyShape>(shape: T, v: Vec3):
3030
3104
  * Triangulate a face. Returns triangulation data or null if unavailable.
3031
3105
  * @deprecated Use meshShape() instead for better performance via bulk C++ extraction.
3032
3106
  */
3033
- export declare function triangulateFace(face: FnFace, index0?: number, skipNormals?: boolean): FaceTriangulation_2 | null;
3107
+ export declare function triangulateFace(face: FnFace, index0?: number, skipNormals?: boolean): FaceTriangulation | null;
3034
3108
 
3035
3109
  /**
3036
3110
  * Wraps a throwing function into a Result.
@@ -3125,6 +3199,18 @@ export declare function vecScale(v: Vec3, s: number): Vec3;
3125
3199
 
3126
3200
  export declare function vecSub(a: Vec3, b: Vec3): Vec3;
3127
3201
 
3202
+ /**
3203
+ * @deprecated Use Vec3 tuples with vecOps functions instead.
3204
+ * @example
3205
+ * // Before (legacy):
3206
+ * const v = new Vector([1, 2, 3]);
3207
+ * const result = v.add(new Vector([4, 5, 6]));
3208
+ *
3209
+ * // After (functional):
3210
+ * import { vecAdd, type Vec3 } from 'brepjs';
3211
+ * const v: Vec3 = [1, 2, 3];
3212
+ * const result = vecAdd(v, [4, 5, 6]);
3213
+ */
3128
3214
  export declare class Vector extends WrappingObj<OcType> {
3129
3215
  constructor(vector?: Point);
3130
3216
  get repr(): string;
@@ -3177,13 +3263,13 @@ export declare class Wire extends _1DShape {
3177
3263
  }
3178
3264
 
3179
3265
  /** Execute fn with a temporary OCCT gp_Dir, auto-deleted after. */
3180
- export declare function withOcDir<T>(v: Vec3, fn: (ocDir: OcType_2) => T): T;
3266
+ export declare function withOcDir<T>(v: Vec3, fn: (ocDir: OcType_3) => T): T;
3181
3267
 
3182
3268
  /** Execute fn with a temporary OCCT gp_Pnt, auto-deleted after. */
3183
- export declare function withOcPnt<T>(v: Vec3, fn: (ocPnt: OcType_2) => T): T;
3269
+ export declare function withOcPnt<T>(v: Vec3, fn: (ocPnt: OcType_3) => T): T;
3184
3270
 
3185
3271
  /** Execute fn with a temporary OCCT gp_Vec, auto-deleted after. */
3186
- export declare function withOcVec<T>(v: Vec3, fn: (ocVec: OcType_2) => T): T;
3272
+ export declare function withOcVec<T>(v: Vec3, fn: (ocVec: OcType_3) => T): T;
3187
3273
 
3188
3274
  /** Execute a function with a disposal scope. Resources registered with the scope
3189
3275
  * are automatically cleaned up when the function returns. */