@faicad/faijs 0.29.5 → 0.30.9
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/NOTICE +6 -5
- package/dist/api/api-namespace.d.ts +1 -1
- package/dist/api/api-namespace.d.ts.map +1 -1
- package/dist/api/api-namespace.js +53 -1
- package/dist/api/api-namespace.js.map +1 -1
- package/dist/api/appearance.d.ts +0 -2
- package/dist/api/appearance.d.ts.map +1 -1
- package/dist/api/appearance.js +0 -2
- package/dist/api/appearance.js.map +1 -1
- package/dist/api/assembly/entities.d.ts +1 -1
- package/dist/api/assembly/entities.js +1 -1
- package/dist/api/assembly/entities.js.map +1 -1
- package/dist/api/assembly/index.d.ts +1 -1
- package/dist/api/assembly/index.js +1 -1
- package/dist/api/assembly/index.js.map +1 -1
- package/dist/api/assembly/joints.d.ts +33 -15
- package/dist/api/assembly/joints.d.ts.map +1 -1
- package/dist/api/assembly/joints.js +31 -13
- package/dist/api/assembly/joints.js.map +1 -1
- package/dist/api/assembly/preview.d.ts +1 -1
- package/dist/api/assembly/preview.js +1 -1
- package/dist/api/assembly/preview.js.map +1 -1
- package/dist/api/assembly/solve.d.ts +1 -1
- package/dist/api/assembly/solve.js +1 -1
- package/dist/api/assembly/solve.js.map +1 -1
- package/dist/api/assembly/solvers/assembly-tree.d.ts +1 -1
- package/dist/api/assembly/solvers/assembly-tree.js +1 -1
- package/dist/api/assembly/solvers/assembly-tree.js.map +1 -1
- package/dist/api/assembly/solvers/chain-solver.d.ts +2 -2
- package/dist/api/assembly/solvers/chain-solver.js.map +1 -1
- package/dist/api/assembly/solvers/global-solver.d.ts +1 -2
- package/dist/api/assembly/solvers/global-solver.d.ts.map +1 -1
- package/dist/api/assembly/solvers/global-solver.js +3 -4
- package/dist/api/assembly/solvers/global-solver.js.map +1 -1
- package/dist/api/assembly/solvers/joints-kinematics.js +1 -1
- package/dist/api/assembly/solvers/joints-kinematics.js.map +1 -1
- package/dist/api/assembly/solvers/linalg.d.ts +2 -2
- package/dist/api/assembly/solvers/linalg.js +2 -2
- package/dist/api/assembly/solvers/linalg.js.map +1 -1
- package/dist/api/assembly/solvers/types.d.ts +2 -5
- package/dist/api/assembly/solvers/types.d.ts.map +1 -1
- package/dist/api/assembly/solvers/types.js +1 -4
- package/dist/api/assembly/solvers/types.js.map +1 -1
- package/dist/api/boolean.d.ts.map +1 -1
- package/dist/api/boolean.js +7 -6
- package/dist/api/boolean.js.map +1 -1
- package/dist/api/brep-mirror/booleanFns.d.ts +3 -3
- package/dist/api/brep-mirror/booleanFns.js +5 -5
- package/dist/api/brep-mirror/booleanFns.js.map +1 -1
- package/dist/api/brep-mirror/compoundFns.d.ts +1 -1
- package/dist/api/brep-mirror/compoundFns.js +4 -4
- package/dist/api/brep-mirror/compoundFns.js.map +1 -1
- package/dist/api/brep-mirror/healingFns.d.ts +4 -4
- package/dist/api/brep-mirror/healingFns.js +4 -4
- package/dist/api/brep-mirror/healingFns.js.map +1 -1
- package/dist/api/brep-mirror/hullFns.d.ts +2 -2
- package/dist/api/brep-mirror/hullFns.js +2 -2
- package/dist/api/brep-mirror/hullFns.js.map +1 -1
- package/dist/api/brep-mirror/patternFns.d.ts +5 -5
- package/dist/api/brep-mirror/patternFns.js +10 -10
- package/dist/api/brep-mirror/patternFns.js.map +1 -1
- package/dist/api/brep-mirror/primitiveFns.d.ts +4 -4
- package/dist/api/brep-mirror/primitiveFns.js +4 -4
- package/dist/api/brep-mirror/primitiveFns.js.map +1 -1
- package/dist/api/brep-mirror/roofFns.d.ts +3 -3
- package/dist/api/brep-mirror/roofFns.js +7 -7
- package/dist/api/brep-mirror/roofFns.js.map +1 -1
- package/dist/api/brep-mirror/sweepFns.d.ts +7 -7
- package/dist/api/brep-mirror/sweepFns.js +14 -14
- package/dist/api/brep-mirror/sweepFns.js.map +1 -1
- package/dist/api/brep-mirror/threadFns.d.ts +1 -1
- package/dist/api/brep-mirror/threadFns.js +1 -1
- package/dist/api/brep-mirror/threadFns.js.map +1 -1
- package/dist/api/brep-mirror/topologyFns.d.ts +5 -5
- package/dist/api/brep-mirror/topologyFns.js +8 -8
- package/dist/api/brep-mirror/topologyFns.js.map +1 -1
- package/dist/api/brep-operations/booleanFns.d.ts +40 -0
- package/dist/api/brep-operations/booleanFns.d.ts.map +1 -0
- package/dist/api/brep-operations/booleanFns.js +104 -0
- package/dist/api/brep-operations/booleanFns.js.map +1 -0
- package/dist/api/brep-operations/brepHelpers.d.ts +55 -0
- package/dist/api/brep-operations/brepHelpers.d.ts.map +1 -0
- package/dist/api/brep-operations/brepHelpers.js +131 -0
- package/dist/api/brep-operations/brepHelpers.js.map +1 -0
- package/dist/api/brep-operations/compoundFns.d.ts +46 -0
- package/dist/api/brep-operations/compoundFns.d.ts.map +1 -0
- package/dist/api/brep-operations/compoundFns.js +299 -0
- package/dist/api/brep-operations/compoundFns.js.map +1 -0
- package/dist/api/brep-operations/healingFns.d.ts +78 -0
- package/dist/api/brep-operations/healingFns.d.ts.map +1 -0
- package/dist/api/brep-operations/healingFns.js +294 -0
- package/dist/api/brep-operations/healingFns.js.map +1 -0
- package/dist/api/brep-operations/hullFns.d.ts +20 -0
- package/dist/api/brep-operations/hullFns.d.ts.map +1 -0
- package/dist/api/brep-operations/hullFns.js +46 -0
- package/dist/api/brep-operations/hullFns.js.map +1 -0
- package/dist/api/brep-operations/joinery-brep.d.ts +172 -0
- package/dist/api/brep-operations/joinery-brep.d.ts.map +1 -0
- package/dist/api/brep-operations/joinery-brep.js +463 -0
- package/dist/api/brep-operations/joinery-brep.js.map +1 -0
- package/dist/api/brep-operations/patternFns.d.ts +43 -0
- package/dist/api/brep-operations/patternFns.d.ts.map +1 -0
- package/dist/api/brep-operations/patternFns.js +178 -0
- package/dist/api/brep-operations/patternFns.js.map +1 -0
- package/dist/api/brep-operations/primitiveFns.d.ts +42 -0
- package/dist/api/brep-operations/primitiveFns.d.ts.map +1 -0
- package/dist/api/brep-operations/primitiveFns.js +104 -0
- package/dist/api/brep-operations/primitiveFns.js.map +1 -0
- package/dist/api/brep-operations/roofFns.d.ts +24 -0
- package/dist/api/brep-operations/roofFns.d.ts.map +1 -0
- package/dist/api/brep-operations/roofFns.js +229 -0
- package/dist/api/brep-operations/roofFns.js.map +1 -0
- package/dist/api/brep-operations/straightSkeleton.d.ts +36 -0
- package/dist/api/brep-operations/straightSkeleton.d.ts.map +1 -0
- package/dist/api/brep-operations/straightSkeleton.js +431 -0
- package/dist/api/brep-operations/straightSkeleton.js.map +1 -0
- package/dist/api/brep-operations/sweepFns.d.ts +60 -0
- package/dist/api/brep-operations/sweepFns.d.ts.map +1 -0
- package/dist/api/brep-operations/sweepFns.js +323 -0
- package/dist/api/brep-operations/sweepFns.js.map +1 -0
- package/dist/api/brep-operations/threadFns.d.ts +83 -0
- package/dist/api/brep-operations/threadFns.d.ts.map +1 -0
- package/dist/api/brep-operations/threadFns.js +138 -0
- package/dist/api/brep-operations/threadFns.js.map +1 -0
- package/dist/api/brep-operations/topologyFns.d.ts +90 -0
- package/dist/api/brep-operations/topologyFns.d.ts.map +1 -0
- package/dist/api/brep-operations/topologyFns.js +276 -0
- package/dist/api/brep-operations/topologyFns.js.map +1 -0
- package/dist/api/brep-topology.d.ts +1 -1
- package/dist/api/brep-topology.d.ts.map +1 -1
- package/dist/api/brep-topology.js +1 -1
- package/dist/api/brep-topology.js.map +1 -1
- package/dist/api/brepjs-compat/index.d.ts +1 -1
- package/dist/api/brepjs-compat/index.js +3 -3
- package/dist/api/brepjs-compat/index.js.map +1 -1
- package/dist/api/cadquery-selectors/borrow-bridge.d.ts.map +1 -1
- package/dist/api/cadquery-selectors/borrow-bridge.js +3 -4
- package/dist/api/cadquery-selectors/borrow-bridge.js.map +1 -1
- package/dist/api/curve-sketch/index.d.ts +235 -0
- package/dist/api/curve-sketch/index.d.ts.map +1 -0
- package/dist/api/curve-sketch/index.js +487 -0
- package/dist/api/curve-sketch/index.js.map +1 -0
- package/dist/api/engrave.d.ts.map +1 -1
- package/dist/api/engrave.js +3 -2
- package/dist/api/engrave.js.map +1 -1
- package/dist/api/export-brep.d.ts +41 -0
- package/dist/api/export-brep.d.ts.map +1 -0
- package/dist/api/export-brep.js +58 -0
- package/dist/api/export-brep.js.map +1 -0
- package/dist/api/export-stl.d.ts +50 -0
- package/dist/api/export-stl.d.ts.map +1 -0
- package/dist/api/export-stl.js +99 -0
- package/dist/api/export-stl.js.map +1 -0
- package/dist/api/extrude.d.ts +8 -11
- package/dist/api/extrude.d.ts.map +1 -1
- package/dist/api/extrude.js +11 -14
- package/dist/api/extrude.js.map +1 -1
- package/dist/api/fillet-variable.d.ts +2 -2
- package/dist/api/fillet-variable.js +2 -2
- package/dist/api/fillet-variable.js.map +1 -1
- package/dist/api/fillet.d.ts +2 -4
- package/dist/api/fillet.d.ts.map +1 -1
- package/dist/api/fillet.js +2 -4
- package/dist/api/fillet.js.map +1 -1
- package/dist/api/generated/2d.d.ts +4 -0
- package/dist/api/generated/2d.d.ts.map +1 -1
- package/dist/api/generated/2d.js +4 -0
- package/dist/api/generated/2d.js.map +1 -1
- package/dist/api/generated/core.d.ts +4 -0
- package/dist/api/generated/core.d.ts.map +1 -1
- package/dist/api/generated/core.js +4 -0
- package/dist/api/generated/core.js.map +1 -1
- package/dist/api/generated/gear.d.ts +4 -0
- package/dist/api/generated/gear.d.ts.map +1 -1
- package/dist/api/generated/gear.js +4 -0
- package/dist/api/generated/gear.js.map +1 -1
- package/dist/api/generated/io.d.ts +4 -0
- package/dist/api/generated/io.d.ts.map +1 -1
- package/dist/api/generated/io.js +4 -0
- package/dist/api/generated/io.js.map +1 -1
- package/dist/api/generated/kernel.d.ts +4 -0
- package/dist/api/generated/kernel.d.ts.map +1 -1
- package/dist/api/generated/kernel.js +4 -0
- package/dist/api/generated/kernel.js.map +1 -1
- package/dist/api/generated/measurement.d.ts +21 -21
- package/dist/api/generated/measurement.d.ts.map +1 -1
- package/dist/api/generated/measurement.js +25 -21
- package/dist/api/generated/measurement.js.map +1 -1
- package/dist/api/generated/ns.d.ts +4 -0
- package/dist/api/generated/ns.d.ts.map +1 -1
- package/dist/api/generated/ns.js +4 -0
- package/dist/api/generated/ns.js.map +1 -1
- package/dist/api/generated/operations.d.ts +32 -32
- package/dist/api/generated/operations.d.ts.map +1 -1
- package/dist/api/generated/operations.js +52 -48
- package/dist/api/generated/operations.js.map +1 -1
- package/dist/api/generated/projection.d.ts +4 -0
- package/dist/api/generated/projection.d.ts.map +1 -1
- package/dist/api/generated/projection.js +4 -0
- package/dist/api/generated/projection.js.map +1 -1
- package/dist/api/generated/query.d.ts +4 -0
- package/dist/api/generated/query.d.ts.map +1 -1
- package/dist/api/generated/query.js +4 -0
- package/dist/api/generated/query.js.map +1 -1
- package/dist/api/generated/sketching.d.ts +2 -2
- package/dist/api/generated/sketching.d.ts.map +1 -1
- package/dist/api/generated/sketching.js +7 -3
- package/dist/api/generated/sketching.js.map +1 -1
- package/dist/api/generated/text.d.ts +4 -0
- package/dist/api/generated/text.d.ts.map +1 -1
- package/dist/api/generated/text.js +4 -0
- package/dist/api/generated/text.js.map +1 -1
- package/dist/api/generated/topology.d.ts +45 -45
- package/dist/api/generated/topology.d.ts.map +1 -1
- package/dist/api/generated/topology.js +67 -63
- package/dist/api/generated/topology.js.map +1 -1
- package/dist/api/generated/view.d.ts +4 -0
- package/dist/api/generated/view.d.ts.map +1 -1
- package/dist/api/generated/view.js +4 -0
- package/dist/api/generated/view.js.map +1 -1
- package/dist/api/geom-types/constants.d.ts +11 -0
- package/dist/api/geom-types/constants.d.ts.map +1 -0
- package/dist/api/geom-types/constants.js +11 -0
- package/dist/api/geom-types/constants.js.map +1 -0
- package/dist/api/geom-types/index.d.ts +21 -0
- package/dist/api/geom-types/index.d.ts.map +1 -0
- package/dist/api/geom-types/index.js +22 -0
- package/dist/api/geom-types/index.js.map +1 -0
- package/dist/api/geom-types/planeOps.d.ts +98 -0
- package/dist/api/geom-types/planeOps.d.ts.map +1 -0
- package/dist/api/geom-types/planeOps.js +170 -0
- package/dist/api/geom-types/planeOps.js.map +1 -0
- package/dist/api/geom-types/planeTypes.d.ts +24 -0
- package/dist/api/geom-types/planeTypes.d.ts.map +1 -0
- package/dist/api/geom-types/planeTypes.js +8 -0
- package/dist/api/geom-types/planeTypes.js.map +1 -0
- package/dist/api/geom-types/types.d.ts +64 -0
- package/dist/api/geom-types/types.d.ts.map +1 -0
- package/dist/api/geom-types/types.js +48 -0
- package/dist/api/geom-types/types.js.map +1 -0
- package/dist/api/geom-types/vecOps.d.ts +124 -0
- package/dist/api/geom-types/vecOps.d.ts.map +1 -0
- package/dist/api/geom-types/vecOps.js +202 -0
- package/dist/api/geom-types/vecOps.js.map +1 -0
- package/dist/api/geom.d.ts.map +1 -1
- package/dist/api/geom.js +6 -5
- package/dist/api/geom.js.map +1 -1
- package/dist/api/half-space.d.ts +56 -0
- package/dist/api/half-space.d.ts.map +1 -0
- package/dist/api/half-space.js +82 -0
- package/dist/api/half-space.js.map +1 -0
- package/dist/api/helix.d.ts +10 -1
- package/dist/api/helix.d.ts.map +1 -1
- package/dist/api/helix.js +19 -3
- package/dist/api/helix.js.map +1 -1
- package/dist/api/index.d.ts +15 -6
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +29 -8
- package/dist/api/index.js.map +1 -1
- package/dist/api/internal/compat-op.d.ts +4 -30
- package/dist/api/internal/compat-op.d.ts.map +1 -1
- package/dist/api/internal/compat-op.js +10 -42
- package/dist/api/internal/compat-op.js.map +1 -1
- package/dist/api/internal/compat-projection.d.ts +5 -5
- package/dist/api/internal/compat-projection.js +5 -5
- package/dist/api/internal/compat-projection.js.map +1 -1
- package/dist/api/internal/dual-form-args.d.ts +0 -2
- package/dist/api/internal/dual-form-args.d.ts.map +1 -1
- package/dist/api/internal/dual-form-args.js +1 -3
- package/dist/api/internal/dual-form-args.js.map +1 -1
- package/dist/api/internal/l3-bridge.d.ts +5 -37
- package/dist/api/internal/l3-bridge.d.ts.map +1 -1
- package/dist/api/internal/l3-bridge.js +7 -76
- package/dist/api/internal/l3-bridge.js.map +1 -1
- package/dist/api/internal/profile-wire.d.ts +1 -1
- package/dist/api/internal/profile-wire.js +1 -1
- package/dist/api/internal/profile-wire.js.map +1 -1
- package/dist/api/internal/result-unwrap.d.ts +4 -6
- package/dist/api/internal/result-unwrap.d.ts.map +1 -1
- package/dist/api/internal/result-unwrap.js +4 -6
- package/dist/api/internal/result-unwrap.js.map +1 -1
- package/dist/api/knurl.d.ts.map +1 -1
- package/dist/api/knurl.js +5 -3
- package/dist/api/knurl.js.map +1 -1
- package/dist/api/loft.d.ts +2 -2
- package/dist/api/loft.d.ts.map +1 -1
- package/dist/api/loft.js +2 -2
- package/dist/api/loft.js.map +1 -1
- package/dist/api/measurement/index.d.ts +3 -3
- package/dist/api/measurement/index.js +3 -3
- package/dist/api/measurement/index.js.map +1 -1
- package/dist/api/meta.d.ts +0 -2
- package/dist/api/meta.d.ts.map +1 -1
- package/dist/api/meta.js +0 -2
- package/dist/api/meta.js.map +1 -1
- package/dist/api/offset2d.d.ts +49 -0
- package/dist/api/offset2d.d.ts.map +1 -0
- package/dist/api/offset2d.js +86 -0
- package/dist/api/offset2d.js.map +1 -0
- package/dist/api/pattern.js +3 -3
- package/dist/api/pattern.js.map +1 -1
- package/dist/api/primitives.d.ts.map +1 -1
- package/dist/api/primitives.js +7 -6
- package/dist/api/primitives.js.map +1 -1
- package/dist/api/replicate.d.ts +2 -2
- package/dist/api/replicate.d.ts.map +1 -1
- package/dist/api/replicate.js +12 -12
- package/dist/api/replicate.js.map +1 -1
- package/dist/api/result.d.ts +1 -1
- package/dist/api/result.js +1 -1
- package/dist/api/result.js.map +1 -1
- package/dist/api/revolve.d.ts +2 -2
- package/dist/api/revolve.js +3 -3
- package/dist/api/revolve.js.map +1 -1
- package/dist/api/screw.d.ts +1 -1
- package/dist/api/screw.d.ts.map +1 -1
- package/dist/api/screw.js +5 -4
- package/dist/api/screw.js.map +1 -1
- package/dist/api/sdf.d.ts.map +1 -1
- package/dist/api/sdf.js +3 -2
- package/dist/api/sdf.js.map +1 -1
- package/dist/api/shape-type/index.d.ts +141 -0
- package/dist/api/shape-type/index.d.ts.map +1 -0
- package/dist/api/shape-type/index.js +182 -0
- package/dist/api/shape-type/index.js.map +1 -0
- package/dist/api/shell.d.ts +2 -2
- package/dist/api/shell.js +2 -2
- package/dist/api/shell.js.map +1 -1
- package/dist/api/solid-from-faces.d.ts +45 -0
- package/dist/api/solid-from-faces.d.ts.map +1 -0
- package/dist/api/solid-from-faces.js +72 -0
- package/dist/api/solid-from-faces.js.map +1 -0
- package/dist/api/solid-offset/index.d.ts +67 -0
- package/dist/api/solid-offset/index.d.ts.map +1 -0
- package/dist/api/solid-offset/index.js +132 -0
- package/dist/api/solid-offset/index.js.map +1 -0
- package/dist/api/surface/arg-spec.d.ts +35 -33
- package/dist/api/surface/arg-spec.d.ts.map +1 -1
- package/dist/api/surface/arg-spec.js +222 -224
- package/dist/api/surface/arg-spec.js.map +1 -1
- package/dist/api/surface-face/index.d.ts +104 -0
- package/dist/api/surface-face/index.d.ts.map +1 -0
- package/dist/api/surface-face/index.js +217 -0
- package/dist/api/surface-face/index.js.map +1 -0
- package/dist/api/surface.d.ts +44 -0
- package/dist/api/surface.d.ts.map +1 -0
- package/dist/api/surface.js +66 -0
- package/dist/api/surface.js.map +1 -0
- package/dist/api/sweep.d.ts +59 -9
- package/dist/api/sweep.d.ts.map +1 -1
- package/dist/api/sweep.js +11 -6
- package/dist/api/sweep.js.map +1 -1
- package/dist/api/thicken.d.ts +1 -1
- package/dist/api/thicken.js +1 -1
- package/dist/api/thicken.js.map +1 -1
- package/dist/api/transform.d.ts +5 -5
- package/dist/api/transform.d.ts.map +1 -1
- package/dist/api/transform.js +11 -10
- package/dist/api/transform.js.map +1 -1
- package/dist/api/view/cameraFns.d.ts +1 -1
- package/dist/api/view/cameraFns.d.ts.map +1 -1
- package/dist/api/view/cameraFns.js +1 -1
- package/dist/api/view/cameraFns.js.map +1 -1
- package/dist/api/view/index.d.ts +0 -2
- package/dist/api/view/index.d.ts.map +1 -1
- package/dist/api/view/index.js +0 -2
- package/dist/api/view/index.js.map +1 -1
- package/dist/api/view/projectionPlanes.d.ts +1 -1
- package/dist/api/view/projectionPlanes.d.ts.map +1 -1
- package/dist/api/view/projectionPlanes.js.map +1 -1
- package/dist/api/view/view-camera.d.ts +7 -9
- package/dist/api/view/view-camera.d.ts.map +1 -1
- package/dist/api/view/view-camera.js +4 -6
- package/dist/api/view/view-camera.js.map +1 -1
- package/dist/api/view/view-projection.d.ts +0 -2
- package/dist/api/view/view-projection.d.ts.map +1 -1
- package/dist/api/view/view-projection.js +0 -2
- package/dist/api/view/view-projection.js.map +1 -1
- package/dist/api/view/view-sheet.d.ts +0 -2
- package/dist/api/view/view-sheet.d.ts.map +1 -1
- package/dist/api/view/view-sheet.js +0 -2
- package/dist/api/view/view-sheet.js.map +1 -1
- package/dist/api/view-export/index.d.ts +97 -0
- package/dist/api/view-export/index.d.ts.map +1 -0
- package/dist/api/view-export/index.js +118 -0
- package/dist/api/view-export/index.js.map +1 -0
- package/dist/brep/brep-ops.d.ts +89 -1
- package/dist/brep/brep-ops.d.ts.map +1 -1
- package/dist/brep/brep-ops.js +176 -10
- package/dist/brep/brep-ops.js.map +1 -1
- package/dist/brep/brep-topology.d.ts +20 -0
- package/dist/brep/brep-topology.d.ts.map +1 -1
- package/dist/brep/brep-topology.js +46 -0
- package/dist/brep/brep-topology.js.map +1 -1
- package/dist/brep/engine/adapters/occt.d.ts +1 -1
- package/dist/brep/engine/adapters/occt.js +7 -7
- package/dist/brep/engine/adapters/occt.js.map +1 -1
- package/dist/brep/engine/primitives.d.ts +2 -3
- package/dist/brep/engine/primitives.d.ts.map +1 -1
- package/dist/brep/engine/primitives.js +1 -2
- package/dist/brep/engine/primitives.js.map +1 -1
- package/dist/brep/engine/registry.d.ts +1 -1
- package/dist/brep/engine/registry.js +1 -1
- package/dist/brep/engine/registry.js.map +1 -1
- package/dist/brep/engine/types.d.ts +2 -2
- package/dist/brep/engine/types.js.map +1 -1
- package/dist/brep/handle-bridge.d.ts +2 -2
- package/dist/brep/handle-bridge.js +2 -2
- package/dist/brep/handle-bridge.js.map +1 -1
- package/dist/brep/index.d.ts +6 -3
- package/dist/brep/index.d.ts.map +1 -1
- package/dist/brep/index.js +6 -3
- package/dist/brep/index.js.map +1 -1
- package/dist/brepkit-kernel/brepkitKernel.d.ts +1 -1
- package/dist/brepkit-kernel/brepkitKernel.js +2 -2
- package/dist/brepkit-kernel/brepkitKernel.js.map +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +5 -4
- package/dist/browser.js.map +1 -1
- package/dist/cad-runtime/admit-compat-lib.d.ts +3 -10
- package/dist/cad-runtime/admit-compat-lib.d.ts.map +1 -1
- package/dist/cad-runtime/admit-compat-lib.js +3 -9
- package/dist/cad-runtime/admit-compat-lib.js.map +1 -1
- package/dist/cad-runtime/backend-dispatch.js +12 -3
- package/dist/cad-runtime/backend-dispatch.js.map +1 -1
- package/dist/cad-runtime/direct-executor.d.ts +6 -3
- package/dist/cad-runtime/direct-executor.d.ts.map +1 -1
- package/dist/cad-runtime/direct-executor.js +31 -9
- package/dist/cad-runtime/direct-executor.js.map +1 -1
- package/dist/cad-runtime/interp/env.d.ts +1 -1
- package/dist/cad-runtime/interp/env.js.map +1 -1
- package/dist/cad-runtime/lib-id.d.ts +0 -2
- package/dist/cad-runtime/lib-id.d.ts.map +1 -1
- package/dist/cad-runtime/lib-id.js +0 -2
- package/dist/cad-runtime/lib-id.js.map +1 -1
- package/dist/cad-runtime/live-shapes.d.ts +3 -5
- package/dist/cad-runtime/live-shapes.d.ts.map +1 -1
- package/dist/cad-runtime/live-shapes.js +8 -10
- package/dist/cad-runtime/live-shapes.js.map +1 -1
- package/dist/cad-runtime/ports.d.ts +3 -3
- package/dist/cad-runtime/ports.js.map +1 -1
- package/dist/cad-runtime/runtime.d.ts +21 -7
- package/dist/cad-runtime/runtime.d.ts.map +1 -1
- package/dist/cad-runtime/runtime.js +45 -6
- package/dist/cad-runtime/runtime.js.map +1 -1
- package/dist/define-op.d.ts +4 -3
- package/dist/define-op.d.ts.map +1 -1
- package/dist/define-op.js +2 -2
- package/dist/define-op.js.map +1 -1
- package/dist/geometry2d/bridge/plane.d.ts +1 -1
- package/dist/geometry2d/bridge/plane.js +1 -1
- package/dist/geometry2d/bridge/plane.js.map +1 -1
- package/dist/geometry2d/curve2d.d.ts +1 -1
- package/dist/geometry2d/curve2d.js +1 -1
- package/dist/geometry2d/curve2d.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/io/fai-zip/container-read.d.ts +16 -0
- package/dist/io/fai-zip/container-read.d.ts.map +1 -1
- package/dist/io/fai-zip/container-read.js +22 -0
- package/dist/io/fai-zip/container-read.js.map +1 -1
- package/dist/io/fai-zip/index.d.ts +1 -1
- package/dist/io/fai-zip/index.d.ts.map +1 -1
- package/dist/io/fai-zip/index.js +1 -1
- package/dist/io/fai-zip/index.js.map +1 -1
- package/dist/lang/code-to-args.d.ts.map +1 -1
- package/dist/lang/code-to-args.js +10 -1
- package/dist/lang/code-to-args.js.map +1 -1
- package/dist/lang/determinism-scanner.d.ts.map +1 -1
- package/dist/lang/determinism-scanner.js +22 -9
- package/dist/lang/determinism-scanner.js.map +1 -1
- package/dist/lang/metadata-extractor.d.ts +27 -6
- package/dist/lang/metadata-extractor.d.ts.map +1 -1
- package/dist/lang/metadata-extractor.js +88 -8
- package/dist/lang/metadata-extractor.js.map +1 -1
- package/dist/lang/parse-error.d.ts +4 -0
- package/dist/lang/parse-error.d.ts.map +1 -1
- package/dist/lang/parse-error.js.map +1 -1
- package/dist/lang/security-scanner.d.ts +27 -2
- package/dist/lang/security-scanner.d.ts.map +1 -1
- package/dist/lang/security-scanner.js +29 -2
- package/dist/lang/security-scanner.js.map +1 -1
- package/dist/lang/source-edit.d.ts +2 -2
- package/dist/lang/source-edit.js.map +1 -1
- package/dist/lang/symbol-table.generated.d.ts +36 -0
- package/dist/lang/symbol-table.generated.d.ts.map +1 -1
- package/dist/lang/symbol-table.generated.js +36 -0
- package/dist/lang/symbol-table.generated.js.map +1 -1
- package/dist/mesh/import-model.d.ts +94 -0
- package/dist/mesh/import-model.d.ts.map +1 -0
- package/dist/mesh/import-model.js +15 -0
- package/dist/mesh/import-model.js.map +1 -0
- package/dist/mesh/index.d.ts +19 -58
- package/dist/mesh/index.d.ts.map +1 -1
- package/dist/mesh/index.js +19 -70
- package/dist/mesh/index.js.map +1 -1
- package/dist/mesh/io.d.ts +33 -16
- package/dist/mesh/io.d.ts.map +1 -1
- package/dist/mesh/io.js +144 -39
- package/dist/mesh/io.js.map +1 -1
- package/dist/mesh/primitives.js +1 -1
- package/dist/mesh/primitives.js.map +1 -1
- package/dist/mesh/threemf-bambu.d.ts +12 -1
- package/dist/mesh/threemf-bambu.d.ts.map +1 -1
- package/dist/mesh/threemf-bambu.js +68 -16
- package/dist/mesh/threemf-bambu.js.map +1 -1
- package/dist/mesh/threemf-loader.d.ts +14 -1
- package/dist/mesh/threemf-loader.d.ts.map +1 -1
- package/dist/mesh/threemf-loader.js +24 -7
- package/dist/mesh/threemf-loader.js.map +1 -1
- package/dist/mesh/transform.d.ts +1 -1
- package/dist/mesh/transform.js +1 -1
- package/dist/mesh/transform.js.map +1 -1
- package/dist/mesh/types.d.ts +5 -5
- package/dist/mesh/types.d.ts.map +1 -1
- package/dist/mesh/types.js.map +1 -1
- package/dist/node-host/cli.d.ts +49 -1
- package/dist/node-host/cli.d.ts.map +1 -1
- package/dist/node-host/cli.js +125 -19
- package/dist/node-host/cli.js.map +1 -1
- package/dist/node-host/execute-script.d.ts +55 -0
- package/dist/node-host/execute-script.d.ts.map +1 -0
- package/dist/node-host/execute-script.js +46 -0
- package/dist/node-host/execute-script.js.map +1 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -1
- package/dist/occt-kernel/generated/occtPlatform.generated.d.ts +260 -0
- package/dist/occt-kernel/generated/occtPlatform.generated.d.ts.map +1 -0
- package/dist/occt-kernel/generated/occtPlatform.generated.js +875 -0
- package/dist/occt-kernel/generated/occtPlatform.generated.js.map +1 -0
- package/dist/occt-kernel/hullGeometry.d.ts +2 -2
- package/dist/occt-kernel/hullGeometry.js +2 -3
- package/dist/occt-kernel/hullGeometry.js.map +1 -1
- package/dist/occt-kernel/hullOps.d.ts +3 -3
- package/dist/occt-kernel/hullOps.js +4 -4
- package/dist/occt-kernel/hullOps.js.map +1 -1
- package/dist/occt-kernel/occt-primitives.d.ts.map +1 -1
- package/dist/occt-kernel/occt-primitives.js +31 -4
- package/dist/occt-kernel/occt-primitives.js.map +1 -1
- package/dist/occt-kernel/occtKernel.d.ts.map +1 -1
- package/dist/occt-kernel/occtKernel.js +18 -0
- package/dist/occt-kernel/occtKernel.js.map +1 -1
- package/dist/occt-scan/recognize.d.ts +58 -0
- package/dist/occt-scan/recognize.d.ts.map +1 -0
- package/dist/occt-scan/recognize.js +216 -0
- package/dist/occt-scan/recognize.js.map +1 -0
- package/dist/primitives/brep-primitives.js +7 -7
- package/dist/primitives/brep-primitives.js.map +1 -1
- package/dist/result/bug.d.ts +1 -1
- package/dist/result/bug.js +1 -1
- package/dist/result/bug.js.map +1 -1
- package/dist/result/errors.d.ts +2 -2
- package/dist/result/errors.d.ts.map +1 -1
- package/dist/result/errors.js +1 -1
- package/dist/result/errors.js.map +1 -1
- package/dist/result/vec3.d.ts +1 -1
- package/dist/result/vec3.js +1 -1
- package/dist/result/vec3.js.map +1 -1
- package/dist/runtime-state.d.ts +16 -0
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +27 -0
- package/dist/runtime-state.js.map +1 -1
- package/dist/script-globals.d.ts +24 -0
- package/dist/script-globals.d.ts.map +1 -0
- package/dist/script-globals.js +24 -0
- package/dist/script-globals.js.map +1 -0
- package/dist/shape.d.ts +24 -0
- package/dist/shape.d.ts.map +1 -1
- package/dist/shape.js +40 -0
- package/dist/shape.js.map +1 -1
- package/dist/topology/naming/lineage.d.ts +3 -2
- package/dist/topology/naming/lineage.d.ts.map +1 -1
- package/dist/topology/naming/lineage.js.map +1 -1
- package/dist/weapp.d.ts +1 -1
- package/dist/weapp.js +1 -1
- package/dist/weapp.js.map +1 -1
- package/package.json +8 -10
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-hosted compat-op implementations — extrude/revolve/sweep family
|
|
3
|
+
* (core-decouple Phase 3, §5.4; G3).
|
|
4
|
+
*
|
|
5
|
+
* @platform occt
|
|
6
|
+
*
|
|
7
|
+
* Semantics mirror brepjs `operations/{api,extrudeFns,sweepFns}.ts`:
|
|
8
|
+
* - `extrudeBrep` — height: number → [0,0,h]; Vec3 → as-is. EXTRUDE_ZERO_VECTOR guard.
|
|
9
|
+
* - `revolveBrep` — options { at, axis, angle(radians, default 2π) }; REVOLUTION_NOT_3D.
|
|
10
|
+
* - `sweepBrep` — config.mode 'simple' → simplePipe; default → sweepPipeShell(frenet).
|
|
11
|
+
* shellMode / law / auxiliarySpine / support / correction configs are not
|
|
12
|
+
* supported after core migration (cad 面取手写 api/sweep.ts,shell 元组不暴露 §2.4①).
|
|
13
|
+
* - `complexExtrudeBrep` / `twistExtrudeBrep` — linear / helix spine built on
|
|
14
|
+
* occt-wasm makeLineEdge+makeWire / makeHelixWire, then sweepPipeShell.
|
|
15
|
+
* ExtrusionProfile scaling law is not supported (brepjs buildLawFromProfile
|
|
16
|
+
* has no L1 equivalent); non-undefined profile → LAW_UNSUPPORTED error.
|
|
17
|
+
*/
|
|
18
|
+
import { getBrepApi } from '../../brep/handle-bridge.js';
|
|
19
|
+
import { ok, err } from '../../result/result.js';
|
|
20
|
+
import { kernelError, validationError } from '../../result/errors.js';
|
|
21
|
+
import { resolveArgs } from '../internal/dual-form-args.js';
|
|
22
|
+
import { brepHandleOf } from './brepHelpers.js';
|
|
23
|
+
import { getOcctKernel } from '../../occt-kernel/occtKernel.js';
|
|
24
|
+
const EXTRUDE_PARAMS = { name: 'extrude', params: ['face', 'height'], formClass: 'A' };
|
|
25
|
+
const REVOLVE_PARAMS = { name: 'revolve', params: ['face', 'options'], formClass: 'A' };
|
|
26
|
+
const SWEEP_PARAMS = { name: 'sweep', params: ['wire', 'spine', 'config', 'shellMode'], formClass: 'A' };
|
|
27
|
+
const COMPLEX_EXTRUDE_PARAMS = { name: 'complexExtrude', params: ['wire', 'center', 'normal', 'profile'], formClass: 'A' };
|
|
28
|
+
const TWIST_EXTRUDE_PARAMS = { name: 'twistExtrude', params: ['wire', 'angleDegrees', 'center', 'normal', 'profile'], formClass: 'A' };
|
|
29
|
+
function vecLength(v) {
|
|
30
|
+
return Math.hypot(v[0], v[1], v[2]);
|
|
31
|
+
}
|
|
32
|
+
/** 构造直线 spine wire(brepjs makeSpineWire)。 */
|
|
33
|
+
function makeSpineWire(kernel, start, end) {
|
|
34
|
+
const e = kernel.makeLineEdge({ x: start[0], y: start[1], z: start[2] }, { x: end[0], y: end[1], z: end[2] });
|
|
35
|
+
const w = kernel.makeWire([e]);
|
|
36
|
+
kernel.release(e);
|
|
37
|
+
return w;
|
|
38
|
+
}
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// extrude — face 沿向量/高度拉伸(brepjs api.js#extrude + extrudeFns.ts#extrude)
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
/**
|
|
43
|
+
* Extrude a face along a vector/height (brepjs api.js#extrude + extrudeFns.ts#extrude).
|
|
44
|
+
*
|
|
45
|
+
* @param args - Resolved arguments (face, height or extrusion vector).
|
|
46
|
+
* @returns The extruded solid as a `BrepHandle`.
|
|
47
|
+
*/
|
|
48
|
+
export function extrudeBrep(...args) {
|
|
49
|
+
const [face, height] = resolveArgs(args, EXTRUDE_PARAMS);
|
|
50
|
+
const kernel = getBrepApi();
|
|
51
|
+
const f = brepHandleOf(face);
|
|
52
|
+
const vec = typeof height === 'number' ? [0, 0, height] : height;
|
|
53
|
+
if (vecLength(vec) < 1e-10) {
|
|
54
|
+
return err(validationError('EXTRUDE_ZERO_VECTOR', 'extrude: extrusion vector has zero length'));
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return ok(kernel.extrude(f, vec[0], vec[1], vec[2]));
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
const raw = e instanceof Error ? e.message : String(e);
|
|
61
|
+
return err(kernelError('EXTRUDE_FAILED', `Extrusion operation failed: ${raw}`, e));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// revolve — face 绕轴旋转(brepjs api.js#revolve;angle 单位弧度,默认 2π)
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
/**
|
|
68
|
+
* Revolve a face around an axis (brepjs api.js#revolve; angle in radians, default 2π).
|
|
69
|
+
*
|
|
70
|
+
* @param args - Resolved arguments (face, revolve options).
|
|
71
|
+
* @returns The revolved solid as a `BrepHandle`.
|
|
72
|
+
*/
|
|
73
|
+
export function revolveBrep(...args) {
|
|
74
|
+
const [face, options] = resolveArgs(args, REVOLVE_PARAMS);
|
|
75
|
+
const kernel = getBrepApi();
|
|
76
|
+
const f = brepHandleOf(face);
|
|
77
|
+
const { at = [0, 0, 0], axis = [0, 0, 1], angle = 2 * Math.PI } = (options ?? {});
|
|
78
|
+
try {
|
|
79
|
+
const h = kernel.revolveVec(f, { x: at[0], y: at[1], z: at[2] }, { x: axis[0], y: axis[1], z: axis[2] }, (angle * 180) / Math.PI);
|
|
80
|
+
return ok(h);
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
const raw = e instanceof Error ? e.message : String(e);
|
|
84
|
+
return err(kernelError('REVOLVE_FAILED', `Revolution operation failed: ${raw}`, e));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// sweep — 截面沿脊柱扫掠(brepjs sweepFns.ts#sweep)
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
/**
|
|
91
|
+
* `sweep` 的完整控制面(S3,方案 §3.4.3):给出下列任一字段即改走 occt 原生
|
|
92
|
+
* `sweepFull`(`sweepAdvanced`/`sweepOriented` 的能力是其子集,由同一选项对象承载)。
|
|
93
|
+
* 未给出任何字段时保持旧路径(`simplePipe` / `sweepPipeShell`)**逐字节不变**。
|
|
94
|
+
*/
|
|
95
|
+
const SWEEP_FULL_KEYS = [
|
|
96
|
+
'orientation',
|
|
97
|
+
'up',
|
|
98
|
+
'auxSpine',
|
|
99
|
+
'curvilinearEquivalence',
|
|
100
|
+
'guideContact',
|
|
101
|
+
'withContact',
|
|
102
|
+
'withCorrection',
|
|
103
|
+
'support',
|
|
104
|
+
'maxDegree',
|
|
105
|
+
'maxSegments',
|
|
106
|
+
'law',
|
|
107
|
+
'lawLength',
|
|
108
|
+
'lawEndFactor',
|
|
109
|
+
'tol3d',
|
|
110
|
+
'boundTol',
|
|
111
|
+
'tolAngular',
|
|
112
|
+
];
|
|
113
|
+
/** SweepMode 名字 → occt 枚举值(Fixed=0 / Frenet=1 / FixedUp=2 / Auxiliary=3)。 */
|
|
114
|
+
const SWEEP_MODE_CODE = {
|
|
115
|
+
fixed: 0,
|
|
116
|
+
frenet: 1,
|
|
117
|
+
fixedUp: 2,
|
|
118
|
+
auxiliary: 3,
|
|
119
|
+
};
|
|
120
|
+
/** TransitionMode 名字 → occt 枚举值(Transformed=0 / RightCorner=1 / RoundCorner=2)。 */
|
|
121
|
+
const SWEEP_TRANSITION_CODE = {
|
|
122
|
+
transformed: 0,
|
|
123
|
+
rightCorner: 1,
|
|
124
|
+
roundCorner: 2,
|
|
125
|
+
};
|
|
126
|
+
/** SweepContact 名字 → occt 枚举值(None=0 / Contact=1 / ContactOnBorder=2)。 */
|
|
127
|
+
const SWEEP_CONTACT_CODE = {
|
|
128
|
+
none: 0,
|
|
129
|
+
contact: 1,
|
|
130
|
+
contactOnBorder: 2,
|
|
131
|
+
};
|
|
132
|
+
/** SweepLaw 名字 → occt 枚举值(None=0 / Linear=1 / SCurve=2)。 */
|
|
133
|
+
const SWEEP_LAW_CODE = {
|
|
134
|
+
none: 0,
|
|
135
|
+
linear: 1,
|
|
136
|
+
sCurve: 2,
|
|
137
|
+
};
|
|
138
|
+
/** 是否给出 sweepFull 专有字段(或 transitionMode 的新语义名)。 */
|
|
139
|
+
function wantsSweepFull(cfg) {
|
|
140
|
+
if (SWEEP_FULL_KEYS.some((k) => cfg[k] !== undefined))
|
|
141
|
+
return true;
|
|
142
|
+
return cfg.transitionMode !== undefined && SWEEP_TRANSITION_CODE[cfg.transitionMode] !== undefined;
|
|
143
|
+
}
|
|
144
|
+
/** 选项对象 → occt sweepFull 的 options(只放已给出的键,其余走内核缺省)。 */
|
|
145
|
+
function toSweepFullOptions(cfg) {
|
|
146
|
+
const opts = {};
|
|
147
|
+
const pickEnum = (key, field, table) => {
|
|
148
|
+
const v = cfg[key];
|
|
149
|
+
if (v === undefined)
|
|
150
|
+
return;
|
|
151
|
+
const code = table[String(v)];
|
|
152
|
+
if (code === undefined) {
|
|
153
|
+
throw validationError(`E_SWEEP_BAD_${field.toUpperCase()}`, `sweep ${field} '${String(v)}' is invalid (allowed: ${Object.keys(table).join(' / ')})`);
|
|
154
|
+
}
|
|
155
|
+
opts[field === 'orientation' ? 'mode' : field] = code;
|
|
156
|
+
};
|
|
157
|
+
try {
|
|
158
|
+
pickEnum('orientation', 'orientation', SWEEP_MODE_CODE);
|
|
159
|
+
const transition = cfg['transitionMode'];
|
|
160
|
+
if (transition !== undefined) {
|
|
161
|
+
// 只要走到这里(wantsSweepFull 为真),transitionMode 必是新语义名之一。
|
|
162
|
+
opts.transitionMode = SWEEP_TRANSITION_CODE[transition];
|
|
163
|
+
}
|
|
164
|
+
pickEnum('guideContact', 'guideContact', SWEEP_CONTACT_CODE);
|
|
165
|
+
pickEnum('law', 'law', SWEEP_LAW_CODE);
|
|
166
|
+
const up = cfg['up'];
|
|
167
|
+
if (up !== undefined) {
|
|
168
|
+
if (!Array.isArray(up) || up.length !== 3) {
|
|
169
|
+
throw validationError('E_SWEEP_BAD_UP', 'sweep up must be [x,y,z]');
|
|
170
|
+
}
|
|
171
|
+
opts.up = { x: up[0], y: up[1], z: up[2] };
|
|
172
|
+
}
|
|
173
|
+
const auxSpine = cfg['auxSpine'];
|
|
174
|
+
if (auxSpine !== undefined)
|
|
175
|
+
opts.auxSpine = brepHandleOf(auxSpine);
|
|
176
|
+
const support = cfg['support'];
|
|
177
|
+
if (support !== undefined)
|
|
178
|
+
opts.support = brepHandleOf(support);
|
|
179
|
+
for (const k of ['curvilinearEquivalence', 'withContact', 'withCorrection']) {
|
|
180
|
+
if (cfg[k] !== undefined)
|
|
181
|
+
opts[k] = cfg[k];
|
|
182
|
+
}
|
|
183
|
+
for (const k of ['maxDegree', 'maxSegments', 'lawLength', 'lawEndFactor', 'tol3d', 'boundTol', 'tolAngular']) {
|
|
184
|
+
if (cfg[k] !== undefined)
|
|
185
|
+
opts[k] = cfg[k];
|
|
186
|
+
}
|
|
187
|
+
// 内核硬前置:law 非 none 时 lawLength 必给(occt-wasm 自己也会抛;此处前置给清楚的错误码)。
|
|
188
|
+
const lawCode = opts.law;
|
|
189
|
+
if (lawCode !== undefined && lawCode !== SWEEP_LAW_CODE.none && opts.lawLength === undefined) {
|
|
190
|
+
throw validationError('E_SWEEP_LAW_NEEDS_LENGTH', 'sweep law requires lawLength (the spine length the law spans)');
|
|
191
|
+
}
|
|
192
|
+
return ok(opts);
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
return err(e);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Sweep a profile along a spine (brepjs sweepFns.ts#sweep).
|
|
200
|
+
*
|
|
201
|
+
* 两条路径(S3):
|
|
202
|
+
* - 无 sweepFull 专有字段 → 旧路径(`mode:'simple'` → `simplePipe`;否则 `sweepPipeShell`);
|
|
203
|
+
* - 给出任一 sweepFull 字段 → occt 原生 `sweepFull`(完整控制面:朝向模式 / 转角过渡 /
|
|
204
|
+
* 引导线关系 / 支持面 / 逼近预算 / 缩放律)。`mode:'simple'` 与 sweepFull 字段互斥。
|
|
205
|
+
*
|
|
206
|
+
* @param args - Resolved arguments (wire, spine, config, shellMode).
|
|
207
|
+
* @returns The swept solid as a `BrepHandle`.
|
|
208
|
+
*/
|
|
209
|
+
export function sweepBrep(...args) {
|
|
210
|
+
const [wire, spine, config, shellMode] = resolveArgs(args, SWEEP_PARAMS);
|
|
211
|
+
const w = brepHandleOf(wire);
|
|
212
|
+
const sp = brepHandleOf(spine);
|
|
213
|
+
const cfg = (config ?? {});
|
|
214
|
+
if (shellMode === true) {
|
|
215
|
+
return err(validationError('SWEEP_SHELL_MODE_UNSUPPORTED', 'sweep shellMode is not supported after core migration (cad 面不暴露壳元组 §2.4①)'));
|
|
216
|
+
}
|
|
217
|
+
const useFull = wantsSweepFull(cfg);
|
|
218
|
+
if (!useFull && cfg.transitionMode !== undefined && cfg.transitionMode !== 'right') {
|
|
219
|
+
return err(validationError('E_SWEEP_TRANSITION_UNSUPPORTED', `sweep transitionMode '${cfg.transitionMode}' is not supported (allowed: 'right' legacy alias, or 'transformed' / 'rightCorner' / 'roundCorner')`));
|
|
220
|
+
}
|
|
221
|
+
if (useFull && cfg.mode === 'simple') {
|
|
222
|
+
return err(validationError('E_SWEEP_MODE_CONFLICT', "sweep mode:'simple' cannot be combined with sweepFull options (orientation / law / transition / support / auxSpine / tolerances)"));
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
if (useFull) {
|
|
226
|
+
const built = toSweepFullOptions(cfg);
|
|
227
|
+
if (!built.ok)
|
|
228
|
+
return err(built.error);
|
|
229
|
+
return ok(getOcctKernel().sweepFull(w, sp, built.value));
|
|
230
|
+
}
|
|
231
|
+
if (cfg.mode === 'simple') {
|
|
232
|
+
return ok(getOcctKernel().simplePipe(w, sp));
|
|
233
|
+
}
|
|
234
|
+
return ok(getOcctKernel().sweepPipeShell(w, sp, cfg.frenet === true, false));
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
const raw = e instanceof Error ? e.message : String(e);
|
|
238
|
+
return err(kernelError('SWEEP_FAILED', `Sweep operation failed: ${raw}`, e));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// ---------------------------------------------------------------------------
|
|
242
|
+
// complexExtrude — wire 沿 normal 挤出(brepjs sweepFns.ts#complexExtrude)
|
|
243
|
+
// ---------------------------------------------------------------------------
|
|
244
|
+
/**
|
|
245
|
+
* Extrude a wire along a normal (brepjs sweepFns.ts#complexExtrude).
|
|
246
|
+
*
|
|
247
|
+
* @param args - Resolved arguments (wire, center, normal, profile).
|
|
248
|
+
* @returns The extruded solid as a `BrepHandle`.
|
|
249
|
+
*/
|
|
250
|
+
export function complexExtrudeBrep(...args) {
|
|
251
|
+
const [wire, center, normal, profile] = resolveArgs(args, COMPLEX_EXTRUDE_PARAMS);
|
|
252
|
+
const kernel = getBrepApi();
|
|
253
|
+
const w = brepHandleOf(wire);
|
|
254
|
+
const c = (center ?? [0, 0, 0]);
|
|
255
|
+
const n = (normal ?? [0, 0, 0]);
|
|
256
|
+
if (vecLength(n) < 1e-10) {
|
|
257
|
+
return err(validationError('ZERO_LENGTH_EXTRUSION', 'Extrusion vector cannot have zero length'));
|
|
258
|
+
}
|
|
259
|
+
if (profile !== undefined && profile !== null) {
|
|
260
|
+
return err(validationError('COMPLEX_EXTRUDE_LAW_UNSUPPORTED', 'complexExtrude ExtrusionProfile scaling law is not supported after core migration'));
|
|
261
|
+
}
|
|
262
|
+
const endPoint = [c[0] + n[0], c[1] + n[1], c[2] + n[2]];
|
|
263
|
+
const spine = makeSpineWire(kernel, c, endPoint);
|
|
264
|
+
try {
|
|
265
|
+
const h = getOcctKernel().sweepPipeShell(w, spine, false, false);
|
|
266
|
+
return ok(h);
|
|
267
|
+
}
|
|
268
|
+
catch (e) {
|
|
269
|
+
const raw = e instanceof Error ? e.message : String(e);
|
|
270
|
+
return err(kernelError('SWEEP_FAILED', `complexExtrude sweep failed: ${raw}`, e));
|
|
271
|
+
}
|
|
272
|
+
finally {
|
|
273
|
+
kernel.release(spine);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// ---------------------------------------------------------------------------
|
|
277
|
+
// twistExtrude — wire 沿螺旋挤出(brepjs sweepFns.ts#twistExtrude)
|
|
278
|
+
// ---------------------------------------------------------------------------
|
|
279
|
+
/**
|
|
280
|
+
* Extrude a wire along a helical path (brepjs sweepFns.ts#twistExtrude).
|
|
281
|
+
*
|
|
282
|
+
* @param args - Resolved arguments (wire, angleDegrees, center, normal, profile).
|
|
283
|
+
* @returns The twisted extrusion as a `BrepHandle`.
|
|
284
|
+
*/
|
|
285
|
+
export function twistExtrudeBrep(...args) {
|
|
286
|
+
const [wire, angleDegrees, center, normal, profile] = resolveArgs(args, TWIST_EXTRUDE_PARAMS);
|
|
287
|
+
const kernel = getBrepApi();
|
|
288
|
+
const w = brepHandleOf(wire);
|
|
289
|
+
const angle = Number(angleDegrees);
|
|
290
|
+
const c = (center ?? [0, 0, 0]);
|
|
291
|
+
const n = (normal ?? [0, 0, 0]);
|
|
292
|
+
if (Math.abs(angle) < 1e-10) {
|
|
293
|
+
return err(validationError('ZERO_TWIST_ANGLE', 'Twist angle cannot be zero'));
|
|
294
|
+
}
|
|
295
|
+
if (angle < 0) {
|
|
296
|
+
return err(validationError('TWIST_NEGATIVE_ANGLE_UNSUPPORTED', 'twistExtrude negative angle (left-handed helix) is not supported after core migration (occt-wasm makeHelixWire has no handedness param)'));
|
|
297
|
+
}
|
|
298
|
+
if (vecLength(n) < 1e-10) {
|
|
299
|
+
return err(validationError('ZERO_LENGTH_EXTRUSION', 'Extrusion vector cannot have zero length'));
|
|
300
|
+
}
|
|
301
|
+
if (profile !== undefined && profile !== null) {
|
|
302
|
+
return err(validationError('TWIST_EXTRUDE_LAW_UNSUPPORTED', 'twistExtrude ExtrusionProfile scaling law is not supported after core migration'));
|
|
303
|
+
}
|
|
304
|
+
const extrusionLength = vecLength(n);
|
|
305
|
+
const pitch = (360.0 / Math.abs(angle)) * extrusionLength;
|
|
306
|
+
// brepjs 语义:主 spine=直线、auxiliary=helix,sweepPipeShell 传对象参数
|
|
307
|
+
// (occt-wasm 运行时接受 auxiliary 键;d.ts 窄签名用 as never 绕过)
|
|
308
|
+
const endPointTwist = [c[0] + n[0], c[1] + n[1], c[2] + n[2]];
|
|
309
|
+
const spine = makeSpineWire(kernel, c, endPointTwist);
|
|
310
|
+
const axisDir = vecLength(n) > 1e-12 ? [n[0] / vecLength(n), n[1] / vecLength(n), n[2] / vecLength(n)] : [0, 0, 1];
|
|
311
|
+
try {
|
|
312
|
+
const helix = getOcctKernel().makeHelixWire({ x: c[0], y: c[1], z: c[2] }, { x: axisDir[0], y: axisDir[1], z: axisDir[2] }, pitch, extrusionLength, 1);
|
|
313
|
+
const h = getOcctKernel().sweepPipeShell(w, spine, { auxiliary: helix });
|
|
314
|
+
getOcctKernel().release(helix);
|
|
315
|
+
kernel.release(spine);
|
|
316
|
+
return ok(h);
|
|
317
|
+
}
|
|
318
|
+
catch (e) {
|
|
319
|
+
const raw = e instanceof Error ? e.message : String(e);
|
|
320
|
+
return err(kernelError('SWEEP_FAILED', `twistExtrude sweep failed: ${raw}`, e));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=sweepFns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweepFns.js","sourceRoot":"","sources":["../../../src/api/brep-operations/sweepFns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,EAAE,EAAE,GAAG,EAAe,MAA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CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAC/C,KAAK,EACL,eAAe,EACf,CAAC,CACF,CAAA;QACD,MAAM,CAAC,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,CAAU,EAAE,KAAc,EAAE,EAAE,SAAS,EAAE,KAAK,EAAW,CAA0B,CAAA;QAC5H,aAAa,EAAE,CAAC,OAAO,CAAC,KAAc,CAAC,CAAA;QACvC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACrB,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QACtD,OAAO,GAAG,CAAC,WAAW,CAAC,cAAc,EAAE,8BAA8B,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IACjF,CAAC;AACH,CAAC","sourcesContent":["/**\n * Self-hosted compat-op implementations — extrude/revolve/sweep family\n * (core-decouple Phase 3, §5.4; G3).\n *\n * @platform occt\n *\n * Semantics mirror brepjs `operations/{api,extrudeFns,sweepFns}.ts`:\n * - `extrudeBrep` — height: number → [0,0,h]; Vec3 → as-is. EXTRUDE_ZERO_VECTOR guard.\n * - `revolveBrep` — options { at, axis, angle(radians, default 2π) }; REVOLUTION_NOT_3D.\n * - `sweepBrep` — config.mode 'simple' → simplePipe; default → sweepPipeShell(frenet).\n * shellMode / law / auxiliarySpine / support / correction configs are not\n * supported after core migration (cad 面取手写 api/sweep.ts,shell 元组不暴露 §2.4①).\n * - `complexExtrudeBrep` / `twistExtrudeBrep` — linear / helix spine built on\n * occt-wasm makeLineEdge+makeWire / makeHelixWire, then sweepPipeShell.\n * ExtrusionProfile scaling law is not supported (brepjs buildLawFromProfile\n * has no L1 equivalent); non-undefined profile → LAW_UNSUPPORTED error.\n */\n\nimport type { BrepHandle } from '../../brep/engine/types'\nimport { getBrepApi } from '../../brep/handle-bridge'\nimport { ok, err, type Result } from '../../result/result'\nimport { kernelError, validationError } from '../../result/errors'\nimport type { FormClass } from '../internal/dual-form-args'\nimport { resolveArgs } from '../internal/dual-form-args'\nimport type { Vec3 } from '../geom-types/types'\nimport { brepHandleOf } from './brepHelpers'\nimport { getOcctKernel } from '../../occt-kernel/occtKernel'\n\nconst EXTRUDE_PARAMS = { name: 'extrude', params: ['face', 'height'], formClass: 'A' as FormClass }\nconst REVOLVE_PARAMS = { name: 'revolve', params: ['face', 'options'], formClass: 'A' as FormClass }\nconst SWEEP_PARAMS = { name: 'sweep', params: ['wire', 'spine', 'config', 'shellMode'], formClass: 'A' as FormClass }\nconst COMPLEX_EXTRUDE_PARAMS = { name: 'complexExtrude', params: ['wire', 'center', 'normal', 'profile'], formClass: 'A' as FormClass }\nconst TWIST_EXTRUDE_PARAMS = { name: 'twistExtrude', params: ['wire', 'angleDegrees', 'center', 'normal', 'profile'], formClass: 'A' as FormClass }\n\nfunction vecLength(v: readonly number[]): number {\n return Math.hypot(v[0], v[1], v[2])\n}\n\n/** 构造直线 spine wire(brepjs makeSpineWire)。 */\nfunction makeSpineWire(kernel: ReturnType<typeof getBrepApi>, start: Vec3, end: Vec3): BrepHandle {\n const e = kernel.makeLineEdge({ x: start[0], y: start[1], z: start[2] }, { x: end[0], y: end[1], z: end[2] })\n const w = kernel.makeWire([e])\n kernel.release(e)\n return w\n}\n\n// ---------------------------------------------------------------------------\n// extrude — face 沿向量/高度拉伸(brepjs api.js#extrude + extrudeFns.ts#extrude)\n// ---------------------------------------------------------------------------\n\n/**\n * Extrude a face along a vector/height (brepjs api.js#extrude + extrudeFns.ts#extrude).\n *\n * @param args - Resolved arguments (face, height or extrusion vector).\n * @returns The extruded solid as a `BrepHandle`.\n */\nexport function extrudeBrep(...args: unknown[]): Result<BrepHandle> {\n const [face, height] = resolveArgs(args, EXTRUDE_PARAMS)\n const kernel = getBrepApi()\n const f = brepHandleOf(face)\n const vec: Vec3 = typeof height === 'number' ? [0, 0, height] : (height as Vec3)\n if (vecLength(vec) < 1e-10) {\n return err(validationError('EXTRUDE_ZERO_VECTOR', 'extrude: extrusion vector has zero length'))\n }\n try {\n return ok(kernel.extrude(f, vec[0], vec[1], vec[2]))\n } catch (e) {\n const raw = e instanceof Error ? e.message : String(e)\n return err(kernelError('EXTRUDE_FAILED', `Extrusion operation failed: ${raw}`, e))\n }\n}\n\n// ---------------------------------------------------------------------------\n// revolve — face 绕轴旋转(brepjs api.js#revolve;angle 单位弧度,默认 2π)\n// ---------------------------------------------------------------------------\n\n/**\n * Revolve a face around an axis (brepjs api.js#revolve; angle in radians, default 2π).\n *\n * @param args - Resolved arguments (face, revolve options).\n * @returns The revolved solid as a `BrepHandle`.\n */\nexport function revolveBrep(...args: unknown[]): Result<BrepHandle> {\n const [face, options] = resolveArgs(args, REVOLVE_PARAMS)\n const kernel = getBrepApi()\n const f = brepHandleOf(face)\n const { at = [0, 0, 0], axis = [0, 0, 1], angle = 2 * Math.PI } = (options ?? {}) as {\n at?: Vec3\n axis?: Vec3\n angle?: number\n }\n try {\n const h = kernel.revolveVec(\n f,\n { x: at[0], y: at[1], z: at[2] },\n { x: axis[0], y: axis[1], z: axis[2] },\n (angle * 180) / Math.PI,\n )\n return ok(h)\n } catch (e) {\n const raw = e instanceof Error ? e.message : String(e)\n return err(kernelError('REVOLVE_FAILED', `Revolution operation failed: ${raw}`, e))\n }\n}\n\n// ---------------------------------------------------------------------------\n// sweep — 截面沿脊柱扫掠(brepjs sweepFns.ts#sweep)\n// ---------------------------------------------------------------------------\n\n/**\n * `sweep` 的完整控制面(S3,方案 §3.4.3):给出下列任一字段即改走 occt 原生\n * `sweepFull`(`sweepAdvanced`/`sweepOriented` 的能力是其子集,由同一选项对象承载)。\n * 未给出任何字段时保持旧路径(`simplePipe` / `sweepPipeShell`)**逐字节不变**。\n */\nconst SWEEP_FULL_KEYS = [\n 'orientation',\n 'up',\n 'auxSpine',\n 'curvilinearEquivalence',\n 'guideContact',\n 'withContact',\n 'withCorrection',\n 'support',\n 'maxDegree',\n 'maxSegments',\n 'law',\n 'lawLength',\n 'lawEndFactor',\n 'tol3d',\n 'boundTol',\n 'tolAngular',\n] as const\n\n/** SweepMode 名字 → occt 枚举值(Fixed=0 / Frenet=1 / FixedUp=2 / Auxiliary=3)。 */\nconst SWEEP_MODE_CODE: Record<string, number> = {\n fixed: 0,\n frenet: 1,\n fixedUp: 2,\n auxiliary: 3,\n}\n/** TransitionMode 名字 → occt 枚举值(Transformed=0 / RightCorner=1 / RoundCorner=2)。 */\nconst SWEEP_TRANSITION_CODE: Record<string, number> = {\n transformed: 0,\n rightCorner: 1,\n roundCorner: 2,\n}\n/** SweepContact 名字 → occt 枚举值(None=0 / Contact=1 / ContactOnBorder=2)。 */\nconst SWEEP_CONTACT_CODE: Record<string, number> = {\n none: 0,\n contact: 1,\n contactOnBorder: 2,\n}\n/** SweepLaw 名字 → occt 枚举值(None=0 / Linear=1 / SCurve=2)。 */\nconst SWEEP_LAW_CODE: Record<string, number> = {\n none: 0,\n linear: 1,\n sCurve: 2,\n}\n\n/** sweep 配置(`sweepFns` 侧形态;faijs 面 = api/sweep.ts 的 SweepOptions)。 */\ninterface SweepConfig {\n mode?: string\n frenet?: boolean\n transitionMode?: string\n [k: string]: unknown\n}\n\n/** 是否给出 sweepFull 专有字段(或 transitionMode 的新语义名)。 */\nfunction wantsSweepFull(cfg: SweepConfig): boolean {\n if (SWEEP_FULL_KEYS.some((k) => cfg[k] !== undefined)) return true\n return cfg.transitionMode !== undefined && SWEEP_TRANSITION_CODE[cfg.transitionMode] !== undefined\n}\n\n/** 选项对象 → occt sweepFull 的 options(只放已给出的键,其余走内核缺省)。 */\nfunction toSweepFullOptions(\n cfg: SweepConfig,\n): Result<Record<string, unknown>, ReturnType<typeof validationError>> {\n const opts: Record<string, unknown> = {}\n const pickEnum = (key: string, field: string, table: Record<string, number>): void => {\n const v = cfg[key]\n if (v === undefined) return\n const code = table[String(v)]\n if (code === undefined) {\n throw validationError(\n `E_SWEEP_BAD_${field.toUpperCase()}`,\n `sweep ${field} '${String(v)}' is invalid (allowed: ${Object.keys(table).join(' / ')})`,\n )\n }\n opts[field === 'orientation' ? 'mode' : field] = code\n }\n try {\n pickEnum('orientation', 'orientation', SWEEP_MODE_CODE)\n const transition = cfg['transitionMode']\n if (transition !== undefined) {\n // 只要走到这里(wantsSweepFull 为真),transitionMode 必是新语义名之一。\n opts.transitionMode = SWEEP_TRANSITION_CODE[transition]\n }\n pickEnum('guideContact', 'guideContact', SWEEP_CONTACT_CODE)\n pickEnum('law', 'law', SWEEP_LAW_CODE)\n\n const up = cfg['up'] as readonly number[] | undefined\n if (up !== undefined) {\n if (!Array.isArray(up) || up.length !== 3) {\n throw validationError('E_SWEEP_BAD_UP', 'sweep up must be [x,y,z]')\n }\n opts.up = { x: up[0], y: up[1], z: up[2] }\n }\n const auxSpine = cfg['auxSpine']\n if (auxSpine !== undefined) opts.auxSpine = brepHandleOf(auxSpine)\n const support = cfg['support']\n if (support !== undefined) opts.support = brepHandleOf(support)\n for (const k of ['curvilinearEquivalence', 'withContact', 'withCorrection'] as const) {\n if (cfg[k] !== undefined) opts[k] = cfg[k]\n }\n for (const k of ['maxDegree', 'maxSegments', 'lawLength', 'lawEndFactor', 'tol3d', 'boundTol', 'tolAngular'] as const) {\n if (cfg[k] !== undefined) opts[k] = cfg[k]\n }\n // 内核硬前置:law 非 none 时 lawLength 必给(occt-wasm 自己也会抛;此处前置给清楚的错误码)。\n const lawCode = opts.law as number | undefined\n if (lawCode !== undefined && lawCode !== SWEEP_LAW_CODE.none && opts.lawLength === undefined) {\n throw validationError(\n 'E_SWEEP_LAW_NEEDS_LENGTH',\n 'sweep law requires lawLength (the spine length the law spans)',\n )\n }\n return ok(opts)\n } catch (e) {\n return err(e as ReturnType<typeof validationError>)\n }\n}\n\n/**\n * Sweep a profile along a spine (brepjs sweepFns.ts#sweep).\n *\n * 两条路径(S3):\n * - 无 sweepFull 专有字段 → 旧路径(`mode:'simple'` → `simplePipe`;否则 `sweepPipeShell`);\n * - 给出任一 sweepFull 字段 → occt 原生 `sweepFull`(完整控制面:朝向模式 / 转角过渡 /\n * 引导线关系 / 支持面 / 逼近预算 / 缩放律)。`mode:'simple'` 与 sweepFull 字段互斥。\n *\n * @param args - Resolved arguments (wire, spine, config, shellMode).\n * @returns The swept solid as a `BrepHandle`.\n */\nexport function sweepBrep(...args: unknown[]): Result<BrepHandle> {\n const [wire, spine, config, shellMode] = resolveArgs(args, SWEEP_PARAMS)\n const w = brepHandleOf(wire)\n const sp = brepHandleOf(spine)\n const cfg = (config ?? {}) as SweepConfig\n if (shellMode === true) {\n return err(\n validationError(\n 'SWEEP_SHELL_MODE_UNSUPPORTED',\n 'sweep shellMode is not supported after core migration (cad 面不暴露壳元组 §2.4①)',\n ),\n )\n }\n const useFull = wantsSweepFull(cfg)\n if (!useFull && cfg.transitionMode !== undefined && cfg.transitionMode !== 'right') {\n return err(\n validationError(\n 'E_SWEEP_TRANSITION_UNSUPPORTED',\n `sweep transitionMode '${cfg.transitionMode}' is not supported (allowed: 'right' legacy alias, or 'transformed' / 'rightCorner' / 'roundCorner')`,\n ),\n )\n }\n if (useFull && cfg.mode === 'simple') {\n return err(\n validationError(\n 'E_SWEEP_MODE_CONFLICT',\n \"sweep mode:'simple' cannot be combined with sweepFull options (orientation / law / transition / support / auxSpine / tolerances)\",\n ),\n )\n }\n try {\n if (useFull) {\n const built = toSweepFullOptions(cfg)\n if (!built.ok) return err(built.error)\n return ok(getOcctKernel().sweepFull(w as never, sp as never, built.value as never) as unknown as BrepHandle)\n }\n if (cfg.mode === 'simple') {\n return ok(getOcctKernel().simplePipe(w as never, sp as never) as unknown as BrepHandle)\n }\n return ok(getOcctKernel().sweepPipeShell(w as never, sp as never, cfg.frenet === true, false) as unknown as BrepHandle)\n } catch (e) {\n const raw = e instanceof Error ? e.message : String(e)\n return err(kernelError('SWEEP_FAILED', `Sweep operation failed: ${raw}`, e))\n }\n}\n\n// ---------------------------------------------------------------------------\n// complexExtrude — wire 沿 normal 挤出(brepjs sweepFns.ts#complexExtrude)\n// ---------------------------------------------------------------------------\n\n/**\n * Extrude a wire along a normal (brepjs sweepFns.ts#complexExtrude).\n *\n * @param args - Resolved arguments (wire, center, normal, profile).\n * @returns The extruded solid as a `BrepHandle`.\n */\nexport function complexExtrudeBrep(...args: unknown[]): Result<BrepHandle> {\n const [wire, center, normal, profile] = resolveArgs(args, COMPLEX_EXTRUDE_PARAMS)\n const kernel = getBrepApi()\n const w = brepHandleOf(wire)\n const c = (center ?? [0, 0, 0]) as Vec3\n const n = (normal ?? [0, 0, 0]) as Vec3\n\n if (vecLength(n) < 1e-10) {\n return err(validationError('ZERO_LENGTH_EXTRUSION', 'Extrusion vector cannot have zero length'))\n }\n if (profile !== undefined && profile !== null) {\n return err(\n validationError(\n 'COMPLEX_EXTRUDE_LAW_UNSUPPORTED',\n 'complexExtrude ExtrusionProfile scaling law is not supported after core migration',\n ),\n )\n }\n const endPoint: Vec3 = [c[0] + n[0], c[1] + n[1], c[2] + n[2]]\n const spine = makeSpineWire(kernel, c, endPoint)\n try {\n const h = getOcctKernel().sweepPipeShell(w as never, spine as never, false, false) as unknown as BrepHandle\n return ok(h)\n } catch (e) {\n const raw = e instanceof Error ? e.message : String(e)\n return err(kernelError('SWEEP_FAILED', `complexExtrude sweep failed: ${raw}`, e))\n } finally {\n kernel.release(spine)\n }\n}\n\n// ---------------------------------------------------------------------------\n// twistExtrude — wire 沿螺旋挤出(brepjs sweepFns.ts#twistExtrude)\n// ---------------------------------------------------------------------------\n\n/**\n * Extrude a wire along a helical path (brepjs sweepFns.ts#twistExtrude).\n *\n * @param args - Resolved arguments (wire, angleDegrees, center, normal, profile).\n * @returns The twisted extrusion as a `BrepHandle`.\n */\nexport function twistExtrudeBrep(...args: unknown[]): Result<BrepHandle> {\n const [wire, angleDegrees, center, normal, profile] = resolveArgs(args, TWIST_EXTRUDE_PARAMS)\n const kernel = getBrepApi()\n const w = brepHandleOf(wire)\n const angle = Number(angleDegrees)\n const c = (center ?? [0, 0, 0]) as Vec3\n const n = (normal ?? [0, 0, 0]) as Vec3\n\n if (Math.abs(angle) < 1e-10) {\n return err(validationError('ZERO_TWIST_ANGLE', 'Twist angle cannot be zero'))\n }\n if (angle < 0) {\n return err(\n validationError(\n 'TWIST_NEGATIVE_ANGLE_UNSUPPORTED',\n 'twistExtrude negative angle (left-handed helix) is not supported after core migration (occt-wasm makeHelixWire has no handedness param)',\n ),\n )\n }\n if (vecLength(n) < 1e-10) {\n return err(validationError('ZERO_LENGTH_EXTRUSION', 'Extrusion vector cannot have zero length'))\n }\n if (profile !== undefined && profile !== null) {\n return err(\n validationError(\n 'TWIST_EXTRUDE_LAW_UNSUPPORTED',\n 'twistExtrude ExtrusionProfile scaling law is not supported after core migration',\n ),\n )\n }\n const extrusionLength = vecLength(n)\n const pitch = (360.0 / Math.abs(angle)) * extrusionLength\n // brepjs 语义:主 spine=直线、auxiliary=helix,sweepPipeShell 传对象参数\n // (occt-wasm 运行时接受 auxiliary 键;d.ts 窄签名用 as never 绕过)\n const endPointTwist: Vec3 = [c[0] + n[0], c[1] + n[1], c[2] + n[2]]\n const spine = makeSpineWire(kernel, c, endPointTwist)\n const axisDir = vecLength(n) > 1e-12 ? [n[0] / vecLength(n), n[1] / vecLength(n), n[2] / vecLength(n)] : [0, 0, 1]\n try {\n const helix = getOcctKernel().makeHelixWire(\n { x: c[0], y: c[1], z: c[2] },\n { x: axisDir[0], y: axisDir[1], z: axisDir[2] },\n pitch,\n extrusionLength,\n 1,\n )\n const h = getOcctKernel().sweepPipeShell(w as never, spine as never, { auxiliary: helix } as never) as unknown as BrepHandle\n getOcctKernel().release(helix as never)\n kernel.release(spine)\n return ok(h)\n } catch (e) {\n const raw = e instanceof Error ? e.message : String(e)\n return err(kernelError('SWEEP_FAILED', `twistExtrude sweep failed: ${raw}`, e))\n }\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functional thread operation — builds a helical screw thread.
|
|
3
|
+
*
|
|
4
|
+
* @platform occt — 本文件 import occt-kernel:螺纹用 `loft`
|
|
5
|
+
* (BRepOffsetAPI_ThruSections)构造,loft 是 occt-only(L1 无,engine-method-map
|
|
6
|
+
* `loft` → occt-only)。守卫①要求平台 import 自证身份;调用方 op(screw)声明
|
|
7
|
+
* `engines: ['occt']`(D11)。
|
|
8
|
+
*
|
|
9
|
+
* 适配自 brepjs `src/operations/threadFns.ts`。
|
|
10
|
+
* 保留文件名和核心算法,适配本项目的 occt-wasm API。
|
|
11
|
+
*
|
|
12
|
+
* occt-wasm 的 `BRepOffsetAPI_MakePipeShell` (sweep) 无法可靠地沿螺旋线扫掠截面,
|
|
13
|
+
* 因此螺纹用 loft(`BRepOffsetAPI_ThruSections`)穿过一系列旋转的齿截面构造。
|
|
14
|
+
* 结果是螺旋螺纹的 *ridge* — 外螺纹 fuse 到螺杆,内螺纹 cut 从孔中减去。
|
|
15
|
+
*
|
|
16
|
+
* 与 brepjs 的差异:
|
|
17
|
+
* - brepjs 用 BlueprintSketcher + line() + wire() 构造截面 → 本项目直接用 kernel.makeLineEdge + kernel.makeWire
|
|
18
|
+
* - brepjs 用 loft() 函数 → 本项目直接用 kernel.loft(wires, isSolid, ruled)
|
|
19
|
+
* - brepjs 用 DisposalScope 管理中间句柄 → 本项目手动 kernel.release
|
|
20
|
+
* - brepjs 用 Result 类型 → 本项目抛出异常
|
|
21
|
+
*/
|
|
22
|
+
import type { BrepHandle } from '../../brep/engine/types.js';
|
|
23
|
+
import type { BrepEngineApi } from '../../brep/engine/primitives.js';
|
|
24
|
+
/** 螺纹配置参数。单位 mm,角度由螺距推导。 */
|
|
25
|
+
export interface ThreadOptions {
|
|
26
|
+
/** 核心半径(外螺纹)或名义孔半径(内螺纹),在螺纹根部 */
|
|
27
|
+
radius: number;
|
|
28
|
+
/** 每圈轴向距离(螺距) */
|
|
29
|
+
pitch: number;
|
|
30
|
+
/** 螺纹总长(沿轴)。圈数 = height / pitch */
|
|
31
|
+
height: number;
|
|
32
|
+
/** 径向螺纹高度(齿顶 - 齿根)。默认 0.6 * pitch(≈ISO 60° V 型) */
|
|
33
|
+
depth?: number;
|
|
34
|
+
/** 齿根处轴向半宽。默认 0.42 * pitch */
|
|
35
|
+
toothHalfWidth?: number;
|
|
36
|
+
/**
|
|
37
|
+
* flat 顶宽,给出梯形齿而非尖 V 型。
|
|
38
|
+
* 0(默认)= 尖 V(ISO/UN);正值 = 梯形齿(Acme/square)。
|
|
39
|
+
* 必须 < toothHalfWidth。
|
|
40
|
+
*/
|
|
41
|
+
crest?: number;
|
|
42
|
+
/** 每圈截面数 — 越高越平滑但越慢。默认 20 */
|
|
43
|
+
sectionsPerTurn?: number;
|
|
44
|
+
/** 左旋。默认 false(右旋) */
|
|
45
|
+
lefthand?: boolean;
|
|
46
|
+
/** 齿尖朝向轴心(内螺纹用 cut 从孔中减去时) */
|
|
47
|
+
inward?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 通过 loft 旋转齿截面构建螺旋螺纹 ridge。
|
|
51
|
+
*
|
|
52
|
+
* @param kernel OCCT 内核
|
|
53
|
+
* @param options 螺纹配置
|
|
54
|
+
* @returns 螺纹 ridge solid(BrepHandle)
|
|
55
|
+
*
|
|
56
|
+
* @example 外螺纹(Ø12 螺杆,2.5mm 螺距):
|
|
57
|
+
* ```ts
|
|
58
|
+
* const ridge = threadBrep(kernel, { radius: 6, pitch: 2.5, height: 7.5 })
|
|
59
|
+
* const rod = kernel.makeCylinder(6.15, 7.5)
|
|
60
|
+
* const result = kernel.fuse(rod, ridge)
|
|
61
|
+
* kernel.release(rod)
|
|
62
|
+
* kernel.release(ridge)
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example 内螺纹(攻丝 Ø6 孔):
|
|
66
|
+
* ```ts
|
|
67
|
+
* const ridge = threadBrep(kernel, { radius: 3, pitch: 1, height: 6, inward: true })
|
|
68
|
+
* const result = kernel.cut(boredBlock, ridge)
|
|
69
|
+
* kernel.release(ridge)
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function threadBrep(kernel: BrepEngineApi, options: ThreadOptions): BrepHandle;
|
|
73
|
+
import { type Result } from '../../result/result.js';
|
|
74
|
+
/**
|
|
75
|
+
* compat-op wrapper: thread(options) → Result<BrepHandle>.
|
|
76
|
+
* Converges on core threadBrep (§5.4: brepjs compat op and core version merged into one).
|
|
77
|
+
* threadBrep internal validation throws are caught as Result err (codes THREAD_INVALID_ARGS / THREAD_FAILED).
|
|
78
|
+
*
|
|
79
|
+
* @param args - Resolved arguments (thread options).
|
|
80
|
+
* @returns The generated thread solid as a `BrepHandle`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function threadBrepOp(...args: unknown[]): Result<BrepHandle>;
|
|
83
|
+
//# sourceMappingURL=threadFns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threadFns.d.ts","sourceRoot":"","sources":["../../../src/api/brep-operations/threadFns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAIjE,4BAA4B;AAC5B,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6BAA6B;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,aAAa,GACrB,UAAU,CA8EZ;AAWD,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAK1D;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAanE"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functional thread operation — builds a helical screw thread.
|
|
3
|
+
*
|
|
4
|
+
* @platform occt — 本文件 import occt-kernel:螺纹用 `loft`
|
|
5
|
+
* (BRepOffsetAPI_ThruSections)构造,loft 是 occt-only(L1 无,engine-method-map
|
|
6
|
+
* `loft` → occt-only)。守卫①要求平台 import 自证身份;调用方 op(screw)声明
|
|
7
|
+
* `engines: ['occt']`(D11)。
|
|
8
|
+
*
|
|
9
|
+
* 适配自 brepjs `src/operations/threadFns.ts`。
|
|
10
|
+
* 保留文件名和核心算法,适配本项目的 occt-wasm API。
|
|
11
|
+
*
|
|
12
|
+
* occt-wasm 的 `BRepOffsetAPI_MakePipeShell` (sweep) 无法可靠地沿螺旋线扫掠截面,
|
|
13
|
+
* 因此螺纹用 loft(`BRepOffsetAPI_ThruSections`)穿过一系列旋转的齿截面构造。
|
|
14
|
+
* 结果是螺旋螺纹的 *ridge* — 外螺纹 fuse 到螺杆,内螺纹 cut 从孔中减去。
|
|
15
|
+
*
|
|
16
|
+
* 与 brepjs 的差异:
|
|
17
|
+
* - brepjs 用 BlueprintSketcher + line() + wire() 构造截面 → 本项目直接用 kernel.makeLineEdge + kernel.makeWire
|
|
18
|
+
* - brepjs 用 loft() 函数 → 本项目直接用 kernel.loft(wires, isSolid, ruled)
|
|
19
|
+
* - brepjs 用 DisposalScope 管理中间句柄 → 本项目手动 kernel.release
|
|
20
|
+
* - brepjs 用 Result 类型 → 本项目抛出异常
|
|
21
|
+
*/
|
|
22
|
+
import { getOcctKernel } from '../../occt-kernel/occtKernel.js';
|
|
23
|
+
import { getBrepApi } from '../../brep/handle-bridge.js';
|
|
24
|
+
/**
|
|
25
|
+
* 通过 loft 旋转齿截面构建螺旋螺纹 ridge。
|
|
26
|
+
*
|
|
27
|
+
* @param kernel OCCT 内核
|
|
28
|
+
* @param options 螺纹配置
|
|
29
|
+
* @returns 螺纹 ridge solid(BrepHandle)
|
|
30
|
+
*
|
|
31
|
+
* @example 外螺纹(Ø12 螺杆,2.5mm 螺距):
|
|
32
|
+
* ```ts
|
|
33
|
+
* const ridge = threadBrep(kernel, { radius: 6, pitch: 2.5, height: 7.5 })
|
|
34
|
+
* const rod = kernel.makeCylinder(6.15, 7.5)
|
|
35
|
+
* const result = kernel.fuse(rod, ridge)
|
|
36
|
+
* kernel.release(rod)
|
|
37
|
+
* kernel.release(ridge)
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example 内螺纹(攻丝 Ø6 孔):
|
|
41
|
+
* ```ts
|
|
42
|
+
* const ridge = threadBrep(kernel, { radius: 3, pitch: 1, height: 6, inward: true })
|
|
43
|
+
* const result = kernel.cut(boredBlock, ridge)
|
|
44
|
+
* kernel.release(ridge)
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function threadBrep(kernel, options) {
|
|
48
|
+
const { radius, pitch, height, depth = 0.6 * pitch, toothHalfWidth = 0.42 * pitch, crest = 0, sectionsPerTurn = 12, lefthand = false, inward = false, } = options;
|
|
49
|
+
// 参数校验
|
|
50
|
+
if (!(radius > 0))
|
|
51
|
+
throw new Error('[threadBrep] radius must be > 0');
|
|
52
|
+
if (!(pitch > 0))
|
|
53
|
+
throw new Error('[threadBrep] pitch must be > 0');
|
|
54
|
+
if (!(height > 0))
|
|
55
|
+
throw new Error('[threadBrep] height must be > 0');
|
|
56
|
+
if (!(depth > 0))
|
|
57
|
+
throw new Error('[threadBrep] depth must be > 0');
|
|
58
|
+
if (crest < 0 || crest >= toothHalfWidth) {
|
|
59
|
+
throw new Error('[threadBrep] crest must be >= 0 and < toothHalfWidth');
|
|
60
|
+
}
|
|
61
|
+
if (sectionsPerTurn < 3) {
|
|
62
|
+
throw new Error('[threadBrep] sectionsPerTurn must be >= 3');
|
|
63
|
+
}
|
|
64
|
+
const turns = height / pitch;
|
|
65
|
+
const nSec = Math.max(2, Math.round(turns * sectionsPerTurn));
|
|
66
|
+
const sign = lefthand ? -1 : 1;
|
|
67
|
+
const apexU = inward ? -depth : depth; // 齿顶:外螺纹朝外,内螺纹朝内
|
|
68
|
+
const baseU = inward ? 0.3 : -0.3; // 齿根:略微嵌入配合实体以保证布尔干净
|
|
69
|
+
const a = toothHalfWidth;
|
|
70
|
+
// 构建截面序列
|
|
71
|
+
const sections = [];
|
|
72
|
+
const intermediateEdges = [];
|
|
73
|
+
for (let i = 0; i <= nSec; i++) {
|
|
74
|
+
const th = (sign * i * 2 * Math.PI) / sectionsPerTurn;
|
|
75
|
+
const z = (pitch * Math.abs(th)) / (2 * Math.PI);
|
|
76
|
+
const cx = radius * Math.cos(th);
|
|
77
|
+
const cy = radius * Math.sin(th);
|
|
78
|
+
const rx = Math.cos(th);
|
|
79
|
+
const ry = Math.sin(th);
|
|
80
|
+
// 点生成函数:u = 径向偏移,v = 轴向偏移
|
|
81
|
+
const pt = (u, v) => ({
|
|
82
|
+
x: cx + u * rx,
|
|
83
|
+
y: cy + u * ry,
|
|
84
|
+
z: z + v,
|
|
85
|
+
});
|
|
86
|
+
// V 型齿(crest=0)通过单个顶点闭合;梯形齿(crest>0)给出平顶
|
|
87
|
+
const profile = crest > 0
|
|
88
|
+
? [pt(baseU, -a), pt(apexU, -crest), pt(apexU, crest), pt(baseU, a)]
|
|
89
|
+
: [pt(baseU, -a), pt(apexU, 0), pt(baseU, a)];
|
|
90
|
+
// 构建边
|
|
91
|
+
const edges = [];
|
|
92
|
+
for (let k = 0; k < profile.length; k++) {
|
|
93
|
+
const edge = kernel.makeLineEdge(profile[k], profile[(k + 1) % profile.length]);
|
|
94
|
+
edges.push(edge);
|
|
95
|
+
intermediateEdges.push(edge);
|
|
96
|
+
}
|
|
97
|
+
// 构建 wire
|
|
98
|
+
const wire = kernel.makeWire(edges);
|
|
99
|
+
sections.push(wire);
|
|
100
|
+
}
|
|
101
|
+
// Loft(occt-only 平台面,D3)。BrepHandle(branded number)与 occt-wasm
|
|
102
|
+
// ShapeHandle 运行时同构,品牌转换只发生在平台边界。
|
|
103
|
+
const thread = getOcctKernel().loft(sections, true, true);
|
|
104
|
+
// 释放中间句柄
|
|
105
|
+
for (const w of sections)
|
|
106
|
+
kernel.release(w);
|
|
107
|
+
for (const e of intermediateEdges)
|
|
108
|
+
kernel.release(e);
|
|
109
|
+
return thread;
|
|
110
|
+
}
|
|
111
|
+
import { resolveArgs } from '../internal/dual-form-args.js';
|
|
112
|
+
import { ok, err } from '../../result/result.js';
|
|
113
|
+
import { validationError, kernelError } from '../../result/errors.js';
|
|
114
|
+
const THREAD_PARAMS = { name: 'thread', params: ['options'], formClass: 'B1' };
|
|
115
|
+
/**
|
|
116
|
+
* compat-op wrapper: thread(options) → Result<BrepHandle>.
|
|
117
|
+
* Converges on core threadBrep (§5.4: brepjs compat op and core version merged into one).
|
|
118
|
+
* threadBrep internal validation throws are caught as Result err (codes THREAD_INVALID_ARGS / THREAD_FAILED).
|
|
119
|
+
*
|
|
120
|
+
* @param args - Resolved arguments (thread options).
|
|
121
|
+
* @returns The generated thread solid as a `BrepHandle`.
|
|
122
|
+
*/
|
|
123
|
+
export function threadBrepOp(...args) {
|
|
124
|
+
const [options] = resolveArgs(args, THREAD_PARAMS);
|
|
125
|
+
const kernel = getBrepApi();
|
|
126
|
+
try {
|
|
127
|
+
const h = threadBrep(kernel, options);
|
|
128
|
+
return ok(h);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
const raw = e instanceof Error ? e.message : String(e);
|
|
132
|
+
if (raw.startsWith('[threadBrep]')) {
|
|
133
|
+
return err(validationError('THREAD_INVALID_ARGS', raw));
|
|
134
|
+
}
|
|
135
|
+
return err(kernelError('THREAD_FAILED', `Thread generation failed: ${raw}`, e));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=threadFns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threadFns.js","sourceRoot":"","sources":["../../../src/api/brep-operations/threadFns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAE,aAAa,EAAoB,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AA4BrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,UAAU,CACxB,MAAqB,EACrB,OAAsB;IAEtB,MAAM,EACJ,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,GAAG,GAAG,GAAG,KAAK,EACnB,cAAc,GAAG,IAAI,GAAG,KAAK,EAC7B,KAAK,GAAG,CAAC,EACT,eAAe,GAAG,EAAE,EACpB,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,KAAK,GACf,GAAG,OAAO,CAAA;IAEX,OAAO;IACP,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;IACrE,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACnE,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK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MAAM,EAAE,OAAwB,CAAC,CAAA;QACtD,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QACtD,IAAI,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;YACnC,OAAO,GAAG,CAAC,eAAe,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC,CAAA;QACzD,CAAC;QACD,OAAO,GAAG,CAAC,WAAW,CAAC,eAAe,EAAE,6BAA6B,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IACjF,CAAC;AACH,CAAC","sourcesContent":["/**\n * Functional thread operation — builds a helical screw thread.\n *\n * @platform occt — 本文件 import occt-kernel:螺纹用 `loft`\n * (BRepOffsetAPI_ThruSections)构造,loft 是 occt-only(L1 无,engine-method-map\n * `loft` → occt-only)。守卫①要求平台 import 自证身份;调用方 op(screw)声明\n * `engines: ['occt']`(D11)。\n *\n * 适配自 brepjs `src/operations/threadFns.ts`。\n * 保留文件名和核心算法,适配本项目的 occt-wasm API。\n *\n * occt-wasm 的 `BRepOffsetAPI_MakePipeShell` (sweep) 无法可靠地沿螺旋线扫掠截面,\n * 因此螺纹用 loft(`BRepOffsetAPI_ThruSections`)穿过一系列旋转的齿截面构造。\n * 结果是螺旋螺纹的 *ridge* — 外螺纹 fuse 到螺杆,内螺纹 cut 从孔中减去。\n *\n * 与 brepjs 的差异:\n * - brepjs 用 BlueprintSketcher + line() + wire() 构造截面 → 本项目直接用 kernel.makeLineEdge + kernel.makeWire\n * - brepjs 用 loft() 函数 → 本项目直接用 kernel.loft(wires, isSolid, ruled)\n * - brepjs 用 DisposalScope 管理中间句柄 → 本项目手动 kernel.release\n * - brepjs 用 Result 类型 → 本项目抛出异常\n */\n\nimport type { BrepHandle } from '../../brep/engine/types'\nimport type { BrepEngineApi } from '../../brep/engine/primitives'\nimport { getOcctKernel, type ShapeHandle } from '../../occt-kernel/occtKernel'\nimport { getBrepApi } from '../../brep/handle-bridge'\n\n/** 螺纹配置参数。单位 mm,角度由螺距推导。 */\nexport interface ThreadOptions {\n /** 核心半径(外螺纹)或名义孔半径(内螺纹),在螺纹根部 */\n radius: number\n /** 每圈轴向距离(螺距) */\n pitch: number\n /** 螺纹总长(沿轴)。圈数 = height / pitch */\n height: number\n /** 径向螺纹高度(齿顶 - 齿根)。默认 0.6 * pitch(≈ISO 60° V 型) */\n depth?: number\n /** 齿根处轴向半宽。默认 0.42 * pitch */\n toothHalfWidth?: number\n /**\n * flat 顶宽,给出梯形齿而非尖 V 型。\n * 0(默认)= 尖 V(ISO/UN);正值 = 梯形齿(Acme/square)。\n * 必须 < toothHalfWidth。\n */\n crest?: number\n /** 每圈截面数 — 越高越平滑但越慢。默认 20 */\n sectionsPerTurn?: number\n /** 左旋。默认 false(右旋) */\n lefthand?: boolean\n /** 齿尖朝向轴心(内螺纹用 cut 从孔中减去时) */\n inward?: boolean\n}\n\n/**\n * 通过 loft 旋转齿截面构建螺旋螺纹 ridge。\n *\n * @param kernel OCCT 内核\n * @param options 螺纹配置\n * @returns 螺纹 ridge solid(BrepHandle)\n *\n * @example 外螺纹(Ø12 螺杆,2.5mm 螺距):\n * ```ts\n * const ridge = threadBrep(kernel, { radius: 6, pitch: 2.5, height: 7.5 })\n * const rod = kernel.makeCylinder(6.15, 7.5)\n * const result = kernel.fuse(rod, ridge)\n * kernel.release(rod)\n * kernel.release(ridge)\n * ```\n *\n * @example 内螺纹(攻丝 Ø6 孔):\n * ```ts\n * const ridge = threadBrep(kernel, { radius: 3, pitch: 1, height: 6, inward: true })\n * const result = kernel.cut(boredBlock, ridge)\n * kernel.release(ridge)\n * ```\n */\nexport function threadBrep(\n kernel: BrepEngineApi,\n options: ThreadOptions,\n): BrepHandle {\n const {\n radius,\n pitch,\n height,\n depth = 0.6 * pitch,\n toothHalfWidth = 0.42 * pitch,\n crest = 0,\n sectionsPerTurn = 12,\n lefthand = false,\n inward = false,\n } = options\n\n // 参数校验\n if (!(radius > 0)) throw new Error('[threadBrep] radius must be > 0')\n if (!(pitch > 0)) throw new Error('[threadBrep] pitch must be > 0')\n if (!(height > 0)) throw new Error('[threadBrep] height must be > 0')\n if (!(depth > 0)) throw new Error('[threadBrep] depth must be > 0')\n if (crest < 0 || crest >= toothHalfWidth) {\n throw new Error('[threadBrep] crest must be >= 0 and < toothHalfWidth')\n }\n if (sectionsPerTurn < 3) {\n throw new Error('[threadBrep] sectionsPerTurn must be >= 3')\n }\n\n const turns = height / pitch\n const nSec = Math.max(2, Math.round(turns * sectionsPerTurn))\n const sign = lefthand ? -1 : 1\n const apexU = inward ? -depth : depth // 齿顶:外螺纹朝外,内螺纹朝内\n const baseU = inward ? 0.3 : -0.3 // 齿根:略微嵌入配合实体以保证布尔干净\n const a = toothHalfWidth\n\n // 构建截面序列\n const sections: BrepHandle[] = []\n const intermediateEdges: BrepHandle[] = []\n\n for (let i = 0; i <= nSec; i++) {\n const th = (sign * i * 2 * Math.PI) / sectionsPerTurn\n const z = (pitch * Math.abs(th)) / (2 * Math.PI)\n const cx = radius * Math.cos(th)\n const cy = radius * Math.sin(th)\n const rx = Math.cos(th)\n const ry = Math.sin(th)\n\n // 点生成函数:u = 径向偏移,v = 轴向偏移\n const pt = (u: number, v: number) => ({\n x: cx + u * rx,\n y: cy + u * ry,\n z: z + v,\n })\n\n // V 型齿(crest=0)通过单个顶点闭合;梯形齿(crest>0)给出平顶\n const profile = crest > 0\n ? [pt(baseU, -a), pt(apexU, -crest), pt(apexU, crest), pt(baseU, a)]\n : [pt(baseU, -a), pt(apexU, 0), pt(baseU, a)]\n\n // 构建边\n const edges: BrepHandle[] = []\n for (let k = 0; k < profile.length; k++) {\n const edge = kernel.makeLineEdge(profile[k], profile[(k + 1) % profile.length])\n edges.push(edge)\n intermediateEdges.push(edge)\n }\n\n // 构建 wire\n const wire = kernel.makeWire(edges)\n sections.push(wire)\n }\n\n // Loft(occt-only 平台面,D3)。BrepHandle(branded number)与 occt-wasm\n // ShapeHandle 运行时同构,品牌转换只发生在平台边界。\n const thread = getOcctKernel().loft(sections as unknown as ShapeHandle[], true, true)\n\n // 释放中间句柄\n for (const w of sections) kernel.release(w)\n for (const e of intermediateEdges) kernel.release(e)\n\n return thread as unknown as BrepHandle\n}\n\n\n/**\n * compat-op 包装:thread(options) → Result<BrepHandle>。\n * 收敛以 core threadBrep 为准(§5.4:brepjs compat op 与 core 版两份收敛为一处)。\n * threadBrep 内部校验抛异常 → 捕获为 Result err(错误码 THREAD_INVALID_ARGS / THREAD_FAILED)。\n */\n\nimport type { FormClass } from '../internal/dual-form-args'\nimport { resolveArgs } from '../internal/dual-form-args'\nimport { ok, err, type Result } from '../../result/result'\nimport { validationError, kernelError } from '../../result/errors'\n\nconst THREAD_PARAMS = { name: 'thread', params: ['options'], formClass: 'B1' as FormClass }\n\n/**\n * compat-op wrapper: thread(options) → Result<BrepHandle>.\n * Converges on core threadBrep (§5.4: brepjs compat op and core version merged into one).\n * threadBrep internal validation throws are caught as Result err (codes THREAD_INVALID_ARGS / THREAD_FAILED).\n *\n * @param args - Resolved arguments (thread options).\n * @returns The generated thread solid as a `BrepHandle`.\n */\nexport function threadBrepOp(...args: unknown[]): Result<BrepHandle> {\n const [options] = resolveArgs(args, THREAD_PARAMS)\n const kernel = getBrepApi()\n try {\n const h = threadBrep(kernel, options as ThreadOptions)\n return ok(h)\n } catch (e) {\n const raw = e instanceof Error ? e.message : String(e)\n if (raw.startsWith('[threadBrep]')) {\n return err(validationError('THREAD_INVALID_ARGS', raw))\n }\n return err(kernelError('THREAD_FAILED', `Thread generation failed: ${raw}`, e))\n }\n}\n"]}
|