/** * OcctKernel – the primary public class of occt-kernel-wasm. * * Wraps the native OCCT WASM module behind a clean, high-level TypeScript API. * All shapes are referenced by opaque {@link ShapeHandle} objects. No OCCT types * are ever exposed to the caller. * * Usage: * ```ts * import { createKernel } from 'occt-kernel-wasm'; * * const kernel = await createKernel(); * const box = kernel.createBox({ dx: 10, dy: 10, dz: 10 }); * const mesh = kernel.tessellate({ shape: box }); * const step = kernel.exportStep({ shape: box }); * kernel.disposeShape({ shape: box }); * ``` */ import type { BooleanParams, BlendOperationResult, BoxParams, ChamferFeatureParams, ChamferParams, ClosestPointOnShapeParams, ClosestPointOnShapeResult, CreateCheckpointParams, CylinderParams, DisposeParams, EdgeCurveResult, EdgeEvaluationParams, EdgeEvaluationResult, EdgeRef, EdgeSampleResult, EntityRevisionMapResult, ExportStepParams, ExtrudeCutProfileFeatureParams, ExtrudeParams, ExtrudeProfileFeatureParams, FaceEvaluationParams, FaceEvaluationResult, FeaturePreviewParams, FeaturePreviewResult, FilletFeatureParams, FilletParams, ImportStepDetailedResult, ImportStepParams, ImportStepPackageParams, ImportStepPackageResult, KernelCapabilities, KernelVersionInfo, HydrateCheckpointParams, LoftFeatureParams, MapEntitiesAcrossRevisionsParams, PlanarFaceWiresParams, PlanarFaceWiresResult, PointContainmentParams, PointContainmentResult, ReleaseRevisionParams, ResolveStableEntityParams, RetainRevisionParams, RevolveCutProfileFeatureParams, RevolveParams, RevolveProfileFeatureParams, RevisionCheckpoint, RevisionInfo, SampleEdgeParams, ShapeHandle, ShapeAnalysisParams, ShapeAnalysisResult, ShapeDistanceParams, ShapeDistanceResult, ShapeIntersectionParams, ShapeIntersectionResult, SphereParams, StableEntityResolution, SweepProfileFeatureParams, TessellateParams, TessellationResult, TopologyResult, TransformParams, OperationSchema } from './types'; /** * Interface of the native OcctKernel C++ class as exposed via Emscripten embind. * @internal */ export interface NativeKernel { createBox(dx: number, dy: number, dz: number): number; createCylinder(radius: number, height: number): number; createSphere(radius: number): number; extrudeProfile(profileJson: string, optionsJson: string): number; extrudeProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number; extrudeCutProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number; revolveProfile(profileJson: string, optionsJson: string): number; revolveProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number; revolveCutProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number; sweepProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number; loftWithSpec?: (id: number, sectionsJson: string, specJson: string) => number; booleanUnion(id1: number, id2: number): number; booleanSubtract(id1: number, id2: number): number; booleanIntersect(id1: number, id2: number): number; filletEdges(id: number, radius: number): number; chamferEdges(id: number, distance: number): number; filletEdgesWithSpec?: (id: number, specJson: string) => string; chamferEdgesWithSpec?: (id: number, specJson: string) => string; getLastError?: () => string; clearLastError?: () => void; transformShape(id: number, transformJson: string): number; getTopology(id: number): string; getRevisionInfo?: (id: number) => string; resolveStableEntity?: (id: number, stableHash: string) => string; mapEntitiesAcrossRevisions?: (fromRevisionId: string, toRevisionId: string, stableHashesJson: string) => string; evaluateEdge?: (id: number, edgeRefJson: string, t: number) => string; sampleEdge?: (id: number, edgeRefJson: string, optionsJson: string) => string; getEdgeCurve?: (id: number, edgeRefJson: string) => string; evaluateFace?: (id: number, faceRefJson: string, u: number, v: number) => string; getPlanarFaceWires?: (id: number, faceRefJson: string) => string; getOperationSchema?: () => string; getCapabilities?: () => string; getKernelVersionInfo?: () => string; analyzeShape?: (id: number) => string; classifyPointContainment?: (id: number, pointJson: string, tolerance: number) => string; intersectShapes?: (id1: number, id2: number) => string; findClosestPointOnShape?: (id: number, pointJson: string, tolerance: number) => string; measureShapeDistance?: (id1: number, id2: number, tolerance: number) => string; checkValidity(id: number): boolean; tessellate(id: number, linearDeflection: number, angularDeflection: number): string; tessellateWithOptions?: (id: number, linearDeflection: number, angularDeflection: number, optionsJson: string) => string; importStep(content: string): number; importStepDetailed(content: string, heal: boolean, sew: boolean, fixSameParameter: boolean, fixSolid: boolean, sewingTolerance: number): string; importStepPackage?(content: string, heal: boolean, sew: boolean, fixSameParameter: boolean, fixSolid: boolean, sewingTolerance: number, linearDeflection: number, angularDeflection: number): string; exportStep(id: number): string; createCheckpoint?: (id: number) => string; hydrateCheckpoint?: (checkpointJson: string) => number; disposeShape(id: number): void; retainRevision?: (id: number) => void; releaseRevision?: (id: number) => boolean; } export interface WasmModule { OcctKernel: new () => NativeKernel; } /** * High-level CAD kernel wrapper around the OCCT WASM module. * * Obtain an instance via {@link createKernel}. */ export declare class OcctKernel { private readonly _native; private readonly _sessionId; /** @internal – use {@link createKernel} instead. */ constructor(wasmModule: WasmModule); private makeHandle; private shapeId; /** Create a solid box aligned with the world axes, with one corner at the origin. */ createBox(params: BoxParams): ShapeHandle; /** Create a solid cylinder with its axis along +Z, base centred at the origin. */ createCylinder(params: CylinderParams): ShapeHandle; /** Create a solid sphere centred at the origin. */ createSphere(params: SphereParams): ShapeHandle; /** * Extrude a closed 2-D profile using either a local-plane height or an explicit vector. */ extrudeProfile(params: ExtrudeParams): ShapeHandle; /** Apply a versioned additive profile extrusion feature spec to a resident shape. */ extrudeProfileWithSpec(params: ExtrudeProfileFeatureParams): ShapeHandle; /** Apply a versioned subtractive profile extrusion feature spec to a resident shape. */ extrudeCutProfileWithSpec(params: ExtrudeCutProfileFeatureParams): ShapeHandle; /** * Revolve a closed 2-D profile about an arbitrary world-space axis. */ revolveProfile(params: RevolveParams): ShapeHandle; /** Apply a versioned additive profile revolve feature spec to a resident shape. */ revolveProfileWithSpec(params: RevolveProfileFeatureParams): ShapeHandle; /** Apply a versioned subtractive profile revolve feature spec to a resident shape. */ revolveCutProfileWithSpec(params: RevolveCutProfileFeatureParams): ShapeHandle; /** Apply a versioned sweep feature spec to a resident shape. */ sweepProfileWithSpec(params: SweepProfileFeatureParams): ShapeHandle; /** Apply a versioned loft feature spec to a resident shape. */ loftWithSpec(params: LoftFeatureParams): ShapeHandle; /** Compute the union of two shapes. Returns a new shape handle. */ booleanUnion(params: BooleanParams): ShapeHandle; /** Subtract `tool` from `base`. Returns a new shape handle. */ booleanSubtract(params: BooleanParams): ShapeHandle; /** Compute the intersection of two shapes. Returns a new shape handle. */ booleanIntersect(params: BooleanParams): ShapeHandle; /** * Apply a constant-radius fillet to all edges of a shape. * Returns a new shape handle (original is unchanged). */ filletEdges(params: FilletParams): ShapeHandle; /** * Apply a constant-distance chamfer to all edges of a shape. * Returns a new shape handle (original is unchanged). */ chamferEdges(params: ChamferParams): ShapeHandle; /** Apply a versioned native OCCT fillet spec and return exact blend lineage. */ filletEdgesWithSpec(params: FilletFeatureParams): BlendOperationResult; /** Apply a versioned native OCCT chamfer spec and return exact blend lineage. */ chamferEdgesWithSpec(params: ChamferFeatureParams): BlendOperationResult; /** * Evaluate an exact feature as a temporary live preview. * * The source model is not mutated. By default the exact preview result is * tessellated with lightweight metadata and then released immediately. */ previewFeature(params: FeaturePreviewParams): FeaturePreviewResult; private executePreviewFeature; /** * Apply a world-space transform to a resident shape and return a new handle. * When both are provided, rotation is applied before translation. */ transformShape(params: TransformParams): ShapeHandle; /** Return additive contract flags supported by the loaded native module. */ getCapabilities(): KernelCapabilities; /** Return the wrapper and native version contract for this kernel session. */ getVersionInfo(): KernelVersionInfo; /** Return face, edge, vertex counts, bounding box, and validity flag. */ getTopology(shape: ShapeHandle): TopologyResult; /** Return immutable revision metadata for a resident shape handle. */ getRevisionInfo(shape: ShapeHandle): RevisionInfo; /** Resolve a stable face/edge/vertex hash in the current resident revision. */ resolveStableEntity(params: ResolveStableEntityParams): StableEntityResolution; /** Map stable hashes between two resident revisions without JS mesh inference. */ mapEntitiesAcrossRevisions(params: MapEntitiesAcrossRevisionsParams): EntityRevisionMapResult; /** Evaluate an exact edge point/tangent without tessellation. */ evaluateEdge(params: EdgeEvaluationParams): EdgeEvaluationResult; /** Return exact OCCT analysis properties for a resident shape. */ analyzeShape(params: ShapeAnalysisParams): ShapeAnalysisResult; /** Classify a world-space point against the exact resident solid model. */ classifyPointContainment(params: PointContainmentParams): PointContainmentResult; /** Return the exact section edges and vertices between two resident shapes. */ intersectShapes(params: ShapeIntersectionParams): ShapeIntersectionResult; /** Return the closest point on the exact resident shape to a world-space query point. */ findClosestPointOnShape(params: ClosestPointOnShapeParams): ClosestPointOnShapeResult; /** Return the exact minimum distance / clearance between two resident shapes. */ measureShapeDistance(params: ShapeDistanceParams): ShapeDistanceResult; /** Sample an exact edge curve without tessellation. */ sampleEdge(params: SampleEdgeParams): EdgeSampleResult; /** Return exact curve metadata for an edge. */ getEdgeCurve(params: { readonly shape: ShapeHandle; readonly edge: EdgeRef; }): EdgeCurveResult; /** Evaluate an exact face point/normal without tessellation. */ evaluateFace(params: FaceEvaluationParams): FaceEvaluationResult; /** Return the exact trimmed wires of a planar face in both local 2-D and world 3-D form. */ getPlanarFaceWires(params: PlanarFaceWiresParams): PlanarFaceWiresResult; /** Return the versioned operation schema advertised by the native kernel. */ getOperationSchema(): OperationSchema; /** Return true when the shape is geometrically and topologically valid. */ checkValidity(shape: ShapeHandle): boolean; /** * Triangulate a shape for WebGL / Three.js rendering. * * @param params.linearDeflection – chord-height tolerance (default 0.1). * @param params.angularDeflection – angular tolerance in radians (default 0.5). */ tessellate(params: TessellateParams): TessellationResult; /** * Import a STEP file from a UTF-8 string. Returns a handle to the imported shape. * Throws {@link KernelError} with code `IMPORT_FAILED` on parse errors. */ importStep(params: ImportStepParams): ShapeHandle; /** * Import a STEP file and return reader, transfer, and validity diagnostics. * * Unlike {@link importStep}, this method does not throw on STEP parse or * transfer failures; those are returned in the structured result. */ importStepDetailed(params: ImportStepParams): ImportStepDetailedResult; /** * Import a STEP file and return a fully fused result package. */ importStepPackage(params: ImportStepPackageParams): ImportStepPackageResult; /** * Export a shape to STEP format. Returns the STEP file content as a UTF-8 string. * Throws {@link KernelError} with code `EXPORT_FAILED` on failure. */ exportStep(params: ExportStepParams): string; /** Create a JSON checkpoint containing CBREP plus revision/history metadata. */ createCheckpoint(params: CreateCheckpointParams): RevisionCheckpoint; /** Hydrate a checkpoint created by {@link createCheckpoint}. */ hydrateCheckpoint(params: HydrateCheckpointParams): ShapeHandle; /** * Release the native memory held by the given shape handle. * * After calling this method the handle must not be used again. */ disposeShape(params: DisposeParams): void; /** Increment the native reference count for a resident immutable revision. */ retainRevision(params: RetainRevisionParams): void; /** Decrement the native reference count and return true when the revision was evicted. */ releaseRevision(params: ReleaseRevisionParams): boolean; }