@faicad/faijs 0.19.0 → 0.29.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -28
- package/dist/api/api-namespace.d.ts +5 -5
- package/dist/api/api-namespace.d.ts.map +1 -1
- package/dist/api/api-namespace.js +4 -4
- package/dist/api/api-namespace.js.map +1 -1
- package/dist/api/assert.d.ts +2 -2
- package/dist/api/assert.js +8 -8
- package/dist/api/assert.js.map +1 -1
- package/dist/api/asset.d.ts +1 -1
- package/dist/api/asset.js +2 -2
- package/dist/api/asset.js.map +1 -1
- package/dist/api/boolean.d.ts +1 -1
- package/dist/api/boolean.d.ts.map +1 -1
- package/dist/api/boolean.js +128 -16
- package/dist/api/boolean.js.map +1 -1
- package/dist/api/brep-mirror/joinery-brep.d.ts.map +1 -1
- package/dist/api/brep-mirror/joinery-brep.js +3 -1
- package/dist/api/brep-mirror/joinery-brep.js.map +1 -1
- package/dist/api/cadquery-selectors/borrow-bridge.d.ts +14 -0
- package/dist/api/cadquery-selectors/borrow-bridge.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/borrow-bridge.js +52 -0
- package/dist/api/cadquery-selectors/borrow-bridge.js.map +1 -0
- package/dist/api/cadquery-selectors/edge.d.ts +40 -0
- package/dist/api/cadquery-selectors/edge.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/edge.js +70 -0
- package/dist/api/cadquery-selectors/edge.js.map +1 -0
- package/dist/api/cadquery-selectors/entity.d.ts +121 -0
- package/dist/api/cadquery-selectors/entity.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/entity.js +167 -0
- package/dist/api/cadquery-selectors/entity.js.map +1 -0
- package/dist/api/cadquery-selectors/face.d.ts +33 -0
- package/dist/api/cadquery-selectors/face.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/face.js +353 -0
- package/dist/api/cadquery-selectors/face.js.map +1 -0
- package/dist/api/cadquery-selectors/grammar.d.ts +50 -0
- package/dist/api/cadquery-selectors/grammar.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/grammar.js +345 -0
- package/dist/api/cadquery-selectors/grammar.js.map +1 -0
- package/dist/api/cadquery-selectors/index.d.ts +18 -0
- package/dist/api/cadquery-selectors/index.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/index.js +17 -0
- package/dist/api/cadquery-selectors/index.js.map +1 -0
- package/dist/api/cadquery-selectors/predicates.d.ts +76 -0
- package/dist/api/cadquery-selectors/predicates.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/predicates.js +85 -0
- package/dist/api/cadquery-selectors/predicates.js.map +1 -0
- package/dist/api/cadquery-selectors/resolve.d.ts +41 -0
- package/dist/api/cadquery-selectors/resolve.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/resolve.js +243 -0
- package/dist/api/cadquery-selectors/resolve.js.map +1 -0
- package/dist/api/cadquery-selectors/types.d.ts +96 -0
- package/dist/api/cadquery-selectors/types.d.ts.map +1 -0
- package/dist/api/cadquery-selectors/types.js +11 -0
- package/dist/api/cadquery-selectors/types.js.map +1 -0
- package/dist/api/chamfer.d.ts +13 -5
- package/dist/api/chamfer.d.ts.map +1 -1
- package/dist/api/chamfer.js +63 -7
- package/dist/api/chamfer.js.map +1 -1
- package/dist/api/compound-geom.d.ts +1 -1
- package/dist/api/compound-geom.js +1 -1
- package/dist/api/compound-geom.js.map +1 -1
- package/dist/api/draft.d.ts +1 -1
- package/dist/api/draft.js +1 -1
- package/dist/api/draft.js.map +1 -1
- package/dist/api/edge-ref.d.ts +1 -1
- package/dist/api/edge-ref.d.ts.map +1 -1
- package/dist/api/edge-ref.js +11 -3
- package/dist/api/edge-ref.js.map +1 -1
- package/dist/api/engrave.d.ts +1 -1
- package/dist/api/engrave.js +7 -7
- package/dist/api/engrave.js.map +1 -1
- package/dist/api/extrude.d.ts +6 -1
- package/dist/api/extrude.d.ts.map +1 -1
- package/dist/api/extrude.js +59 -5
- package/dist/api/extrude.js.map +1 -1
- package/dist/api/face-ref.d.ts +1 -1
- package/dist/api/face-ref.js +1 -1
- package/dist/api/face-ref.js.map +1 -1
- package/dist/api/feature-repair.d.ts +1 -1
- package/dist/api/feature-repair.js +1 -1
- package/dist/api/feature-repair.js.map +1 -1
- package/dist/api/fillet-variable.d.ts +1 -1
- package/dist/api/fillet-variable.js +1 -1
- package/dist/api/fillet-variable.js.map +1 -1
- package/dist/api/fillet.d.ts +28 -8
- package/dist/api/fillet.d.ts.map +1 -1
- package/dist/api/fillet.js +64 -9
- package/dist/api/fillet.js.map +1 -1
- package/dist/api/generated/script-face-manifest.d.ts +4 -0
- package/dist/api/generated/script-face-manifest.d.ts.map +1 -1
- package/dist/api/generated/script-face-manifest.js.map +1 -1
- package/dist/api/geom.d.ts +1 -1
- package/dist/api/geom.js +1 -1
- package/dist/api/geom.js.map +1 -1
- package/dist/api/helix.d.ts +1 -1
- package/dist/api/helix.js +1 -1
- package/dist/api/helix.js.map +1 -1
- package/dist/api/import-brep.d.ts +20 -2
- package/dist/api/import-brep.d.ts.map +1 -1
- package/dist/api/import-brep.js +28 -3
- package/dist/api/import-brep.js.map +1 -1
- package/dist/api/import-step.d.ts +17 -2
- package/dist/api/import-step.d.ts.map +1 -1
- package/dist/api/import-step.js +23 -3
- package/dist/api/import-step.js.map +1 -1
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +5 -2
- package/dist/api/index.js.map +1 -1
- package/dist/api/internal/compat-op.js +1 -1
- package/dist/api/internal/compat-op.js.map +1 -1
- package/dist/api/internal/mesh-solid-op.d.ts +236 -0
- package/dist/api/internal/mesh-solid-op.d.ts.map +1 -0
- package/dist/api/internal/mesh-solid-op.js +352 -0
- package/dist/api/internal/mesh-solid-op.js.map +1 -0
- package/dist/api/internal/svg-asset-resolver.d.ts +1 -1
- package/dist/api/internal/svg-asset-resolver.js +1 -1
- package/dist/api/internal/svg-asset-resolver.js.map +1 -1
- package/dist/api/knurl.d.ts +1 -1
- package/dist/api/knurl.d.ts.map +1 -1
- package/dist/api/knurl.js +3 -2
- package/dist/api/knurl.js.map +1 -1
- package/dist/api/loft.d.ts +1 -1
- package/dist/api/loft.js +1 -1
- package/dist/api/loft.js.map +1 -1
- package/dist/api/measurement/index.d.ts +9 -5
- package/dist/api/measurement/index.d.ts.map +1 -1
- package/dist/api/measurement/index.js +47 -20
- package/dist/api/measurement/index.js.map +1 -1
- package/dist/api/pattern.d.ts +5 -3
- package/dist/api/pattern.d.ts.map +1 -1
- package/dist/api/pattern.js +32 -4
- package/dist/api/pattern.js.map +1 -1
- package/dist/api/place.d.ts +1 -1
- package/dist/api/place.js +1 -1
- package/dist/api/place.js.map +1 -1
- package/dist/api/primitives.d.ts +5 -4
- package/dist/api/primitives.d.ts.map +1 -1
- package/dist/api/primitives.js +11 -5
- package/dist/api/primitives.js.map +1 -1
- package/dist/api/profile.d.ts +64 -8
- package/dist/api/profile.d.ts.map +1 -1
- package/dist/api/profile.js +61 -10
- package/dist/api/profile.js.map +1 -1
- package/dist/api/punch-hole.d.ts +3 -0
- package/dist/api/punch-hole.d.ts.map +1 -1
- package/dist/api/punch-hole.js.map +1 -1
- package/dist/api/reconcile.d.ts +1 -1
- package/dist/api/reconcile.js +1 -1
- package/dist/api/reconcile.js.map +1 -1
- package/dist/api/replicate.d.ts.map +1 -1
- package/dist/api/replicate.js +122 -1
- package/dist/api/replicate.js.map +1 -1
- package/dist/api/screw.d.ts +1 -1
- package/dist/api/screw.js +3 -3
- package/dist/api/screw.js.map +1 -1
- package/dist/api/sdf.d.ts +1 -1
- package/dist/api/sdf.js +2 -2
- package/dist/api/sdf.js.map +1 -1
- package/dist/api/section-by-plane.d.ts +1 -1
- package/dist/api/section-by-plane.d.ts.map +1 -1
- package/dist/api/section-by-plane.js +2 -1
- package/dist/api/section-by-plane.js.map +1 -1
- package/dist/api/shell.d.ts +11 -4
- package/dist/api/shell.d.ts.map +1 -1
- package/dist/api/shell.js +53 -7
- package/dist/api/shell.js.map +1 -1
- package/dist/api/sketch-on-face.d.ts +41 -0
- package/dist/api/sketch-on-face.d.ts.map +1 -1
- package/dist/api/sketch-on-face.js +100 -1
- package/dist/api/sketch-on-face.js.map +1 -1
- package/dist/api/sketch-on-plane.d.ts +17 -9
- package/dist/api/sketch-on-plane.d.ts.map +1 -1
- package/dist/api/sketch-on-plane.js +12 -10
- package/dist/api/sketch-on-plane.js.map +1 -1
- package/dist/api/split-by-plane.d.ts +1 -1
- package/dist/api/split-by-plane.d.ts.map +1 -1
- package/dist/api/split-by-plane.js +2 -1
- package/dist/api/split-by-plane.js.map +1 -1
- package/dist/api/split.d.ts +1 -1
- package/dist/api/split.js +2 -2
- package/dist/api/split.js.map +1 -1
- package/dist/api/surface/arg-spec.d.ts +8 -0
- package/dist/api/surface/arg-spec.d.ts.map +1 -1
- package/dist/api/surface/arg-spec.js.map +1 -1
- package/dist/api/sweep.d.ts +1 -1
- package/dist/api/sweep.js +1 -1
- 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/topo-resolve.d.ts +74 -1
- package/dist/api/topo-resolve.d.ts.map +1 -1
- package/dist/api/topo-resolve.js +180 -2
- package/dist/api/topo-resolve.js.map +1 -1
- package/dist/api/transform.d.ts +10 -6
- package/dist/api/transform.d.ts.map +1 -1
- package/dist/api/transform.js +74 -21
- package/dist/api/transform.js.map +1 -1
- package/dist/api/wire.d.ts +1 -1
- package/dist/api/wire.js +1 -1
- package/dist/api/wire.js.map +1 -1
- package/dist/api/xml-dom.d.ts +27 -0
- package/dist/api/xml-dom.d.ts.map +1 -0
- package/dist/api/xml-dom.js +45 -0
- package/dist/api/xml-dom.js.map +1 -0
- package/dist/brep/brep-ops.d.ts +13 -11
- package/dist/brep/brep-ops.d.ts.map +1 -1
- package/dist/brep/brep-ops.js +31 -30
- package/dist/brep/brep-ops.js.map +1 -1
- package/dist/brep/brep-topology.d.ts +5 -4
- package/dist/brep/brep-topology.d.ts.map +1 -1
- package/dist/brep/brep-topology.js +9 -6
- package/dist/brep/brep-topology.js.map +1 -1
- package/dist/brep/effective-deflection.d.ts +35 -0
- package/dist/brep/effective-deflection.d.ts.map +1 -0
- package/dist/brep/effective-deflection.js +49 -0
- package/dist/brep/effective-deflection.js.map +1 -0
- package/dist/brep/engine/adapters/brep-mock.d.ts.map +1 -1
- package/dist/brep/engine/adapters/brep-mock.js +27 -0
- package/dist/brep/engine/adapters/brep-mock.js.map +1 -1
- package/dist/brep/engine/adapters/brepkit.d.ts +18 -0
- package/dist/brep/engine/adapters/brepkit.d.ts.map +1 -1
- package/dist/brep/engine/adapters/brepkit.js +46 -1
- package/dist/brep/engine/adapters/brepkit.js.map +1 -1
- package/dist/brep/engine/adapters/occt.d.ts +1 -1
- package/dist/brep/engine/adapters/occt.d.ts.map +1 -1
- package/dist/brep/engine/adapters/occt.js +3 -1
- package/dist/brep/engine/adapters/occt.js.map +1 -1
- package/dist/brep/engine/primitives.d.ts +29 -7
- package/dist/brep/engine/primitives.d.ts.map +1 -1
- package/dist/brep/engine/primitives.js.map +1 -1
- package/dist/brep/engine/registry.d.ts +24 -1
- package/dist/brep/engine/registry.d.ts.map +1 -1
- package/dist/brep/engine/registry.js +24 -0
- package/dist/brep/engine/registry.js.map +1 -1
- package/dist/brep/engine/types.d.ts +54 -3
- package/dist/brep/engine/types.d.ts.map +1 -1
- package/dist/brep/engine/types.js +10 -0
- package/dist/brep/engine/types.js.map +1 -1
- package/dist/brep/export/export-model.d.ts +79 -0
- package/dist/brep/export/export-model.d.ts.map +1 -0
- package/dist/brep/export/export-model.js +336 -0
- package/dist/brep/export/export-model.js.map +1 -0
- package/dist/brep/face-evolution.d.ts +1 -1
- package/dist/brep/face-evolution.d.ts.map +1 -1
- package/dist/brep/face-evolution.js +20 -1
- package/dist/brep/face-evolution.js.map +1 -1
- package/dist/brep/handle-bridge.d.ts +1 -1
- package/dist/brep/handle-bridge.js +1 -1
- package/dist/brep/handle-bridge.js.map +1 -1
- package/dist/brep/mesh-solid.d.ts +218 -0
- package/dist/brep/mesh-solid.d.ts.map +1 -0
- package/dist/brep/mesh-solid.js +229 -0
- package/dist/brep/mesh-solid.js.map +1 -0
- package/dist/brep/primitives-brep.d.ts.map +1 -1
- package/dist/brep/primitives-brep.js +3 -1
- package/dist/brep/primitives-brep.js.map +1 -1
- package/dist/brep/text/fontRegistry.d.ts +32 -1
- package/dist/brep/text/fontRegistry.d.ts.map +1 -1
- package/dist/brep/text/fontRegistry.js +51 -1
- package/dist/brep/text/fontRegistry.js.map +1 -1
- package/dist/brep/text/text-to-solid.d.ts.map +1 -1
- package/dist/brep/text/text-to-solid.js +8 -3
- package/dist/brep/text/text-to-solid.js.map +1 -1
- package/dist/brepkit-kernel/brepkitKernel.d.ts +18 -2
- package/dist/brepkit-kernel/brepkitKernel.d.ts.map +1 -1
- package/dist/brepkit-kernel/brepkitKernel.js +453 -125
- package/dist/brepkit-kernel/brepkitKernel.js.map +1 -1
- package/dist/brepkit-kernel/brepkitWasm.d.ts +8 -0
- package/dist/brepkit-kernel/brepkitWasm.d.ts.map +1 -1
- package/dist/brepkit-kernel/brepkitWasm.js +10 -0
- package/dist/brepkit-kernel/brepkitWasm.js.map +1 -1
- package/dist/browser-host/browser-font-provider.d.ts +12 -0
- package/dist/browser-host/browser-font-provider.d.ts.map +1 -1
- package/dist/browser-host/browser-font-provider.js +25 -0
- package/dist/browser-host/browser-font-provider.js.map +1 -1
- package/dist/browser.d.ts +6 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +10 -3
- package/dist/browser.js.map +1 -1
- package/dist/cad-runtime/backend-dispatch.d.ts +28 -3
- package/dist/cad-runtime/backend-dispatch.d.ts.map +1 -1
- package/dist/cad-runtime/backend-dispatch.js +119 -4
- package/dist/cad-runtime/backend-dispatch.js.map +1 -1
- package/dist/cad-runtime/browser-lib-loader.js.map +1 -1
- package/dist/cad-runtime/direct-executor.d.ts +19 -3
- package/dist/cad-runtime/direct-executor.d.ts.map +1 -1
- package/dist/cad-runtime/direct-executor.js +49 -1
- package/dist/cad-runtime/direct-executor.js.map +1 -1
- package/dist/cad-runtime/ports.d.ts +3 -3
- package/dist/cad-runtime/ports.d.ts.map +1 -1
- package/dist/cad-runtime/ports.js.map +1 -1
- package/dist/cad-runtime/preview-exec.d.ts +4 -4
- package/dist/cad-runtime/preview-exec.js +2 -2
- package/dist/cad-runtime/preview-exec.js.map +1 -1
- package/dist/cad-runtime/runtime.d.ts +66 -8
- package/dist/cad-runtime/runtime.d.ts.map +1 -1
- package/dist/cad-runtime/runtime.js +121 -8
- package/dist/cad-runtime/runtime.js.map +1 -1
- package/dist/define-op.d.ts +37 -1
- package/dist/define-op.d.ts.map +1 -1
- package/dist/define-op.js +25 -1
- package/dist/define-op.js.map +1 -1
- package/dist/env-agnostic.d.ts +7 -7
- package/dist/env-agnostic.d.ts.map +1 -1
- package/dist/env-agnostic.js +3 -3
- package/dist/env-agnostic.js.map +1 -1
- package/dist/geometry2d/adapt.d.ts +39 -4
- package/dist/geometry2d/adapt.d.ts.map +1 -1
- package/dist/geometry2d/adapt.js +14 -3
- package/dist/geometry2d/adapt.js.map +1 -1
- package/dist/geometry2d/blueprint.d.ts +2 -2
- package/dist/geometry2d/blueprint.js +2 -2
- package/dist/geometry2d/blueprint.js.map +1 -1
- package/dist/geometry2d/bridge/lift-on-plane.d.ts +18 -8
- package/dist/geometry2d/bridge/lift-on-plane.d.ts.map +1 -1
- package/dist/geometry2d/bridge/lift-on-plane.js +71 -12
- package/dist/geometry2d/bridge/lift-on-plane.js.map +1 -1
- package/dist/geometry2d/bridge/plane.d.ts +17 -0
- package/dist/geometry2d/bridge/plane.d.ts.map +1 -1
- package/dist/geometry2d/bridge/plane.js +22 -0
- package/dist/geometry2d/bridge/plane.js.map +1 -1
- package/dist/geometry2d/curve2d.d.ts +25 -0
- package/dist/geometry2d/curve2d.d.ts.map +1 -1
- package/dist/geometry2d/curve2d.js +41 -5
- package/dist/geometry2d/curve2d.js.map +1 -1
- package/dist/geometry2d/pen-sketcher.d.ts +25 -0
- package/dist/geometry2d/pen-sketcher.d.ts.map +1 -1
- package/dist/geometry2d/pen-sketcher.js +43 -0
- package/dist/geometry2d/pen-sketcher.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/io/bytes-node.d.ts +11 -0
- package/dist/io/bytes-node.d.ts.map +1 -0
- package/dist/io/bytes-node.js +28 -0
- package/dist/io/bytes-node.js.map +1 -0
- package/dist/io/bytes.d.ts +33 -0
- package/dist/io/bytes.d.ts.map +1 -0
- package/dist/io/bytes.js +41 -0
- package/dist/io/bytes.js.map +1 -0
- package/dist/io/fai-zip/container-read.d.ts +102 -0
- package/dist/io/fai-zip/container-read.d.ts.map +1 -0
- package/dist/io/fai-zip/container-read.js +305 -0
- package/dist/io/fai-zip/container-read.js.map +1 -0
- package/dist/io/fai-zip/container-write.d.ts +70 -0
- package/dist/io/fai-zip/container-write.d.ts.map +1 -0
- package/dist/io/fai-zip/container-write.js +186 -0
- package/dist/io/fai-zip/container-write.js.map +1 -0
- package/dist/io/fai-zip/container.d.ts +107 -0
- package/dist/io/fai-zip/container.d.ts.map +1 -0
- package/dist/io/fai-zip/container.js +89 -0
- package/dist/io/fai-zip/container.js.map +1 -0
- package/dist/io/fai-zip/index.d.ts +18 -0
- package/dist/io/fai-zip/index.d.ts.map +1 -0
- package/dist/io/fai-zip/index.js +4 -0
- package/dist/io/fai-zip/index.js.map +1 -0
- package/dist/io/index.d.ts +10 -0
- package/dist/io/index.d.ts.map +1 -0
- package/dist/io/index.js +13 -0
- package/dist/io/index.js.map +1 -0
- package/dist/io/zip.d.ts +68 -0
- package/dist/io/zip.d.ts.map +1 -0
- package/dist/io/zip.js +147 -0
- package/dist/io/zip.js.map +1 -0
- package/dist/lang/code-to-args.d.ts +30 -4
- package/dist/lang/code-to-args.d.ts.map +1 -1
- package/dist/lang/code-to-args.js +42 -3
- package/dist/lang/code-to-args.js.map +1 -1
- package/dist/lang/codegen.d.ts +45 -1
- package/dist/lang/codegen.d.ts.map +1 -1
- package/dist/lang/codegen.js +135 -6
- package/dist/lang/codegen.js.map +1 -1
- package/dist/lang/host-arg.d.ts +6 -0
- package/dist/lang/host-arg.d.ts.map +1 -1
- package/dist/lang/host-arg.js.map +1 -1
- package/dist/lang/metadata-extractor.d.ts +25 -0
- package/dist/lang/metadata-extractor.d.ts.map +1 -1
- package/dist/lang/metadata-extractor.js +289 -25
- package/dist/lang/metadata-extractor.js.map +1 -1
- package/dist/lang/parse-error.d.ts +7 -1
- 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 +9 -1
- package/dist/lang/security-scanner.d.ts.map +1 -1
- package/dist/lang/security-scanner.js +38 -1
- package/dist/lang/security-scanner.js.map +1 -1
- package/dist/lang/statement-summary.d.ts +1 -1
- package/dist/lang/statement-summary.js +1 -1
- package/dist/lang/statement-summary.js.map +1 -1
- package/dist/lang/types.d.ts +1 -1
- package/dist/lang/types.js +1 -1
- package/dist/lang/types.js.map +1 -1
- package/dist/mesh/index.d.ts +2 -1
- package/dist/mesh/index.d.ts.map +1 -1
- package/dist/mesh/index.js +2 -1
- package/dist/mesh/index.js.map +1 -1
- package/dist/mesh/io.d.ts +69 -9
- package/dist/mesh/io.d.ts.map +1 -1
- package/dist/mesh/io.js +121 -17
- package/dist/mesh/io.js.map +1 -1
- package/dist/mesh/reconcile.d.ts +1 -1
- package/dist/mesh/reconcile.js +1 -1
- package/dist/mesh/reconcile.js.map +1 -1
- package/dist/mesh/rigid-transform.d.ts +3 -3
- package/dist/mesh/rigid-transform.js +3 -3
- package/dist/mesh/rigid-transform.js.map +1 -1
- package/dist/mesh/stl-unit.d.ts +24 -0
- package/dist/mesh/stl-unit.d.ts.map +1 -0
- package/dist/mesh/stl-unit.js +17 -0
- package/dist/mesh/stl-unit.js.map +1 -0
- package/dist/mesh/threemf-bambu.d.ts +142 -0
- package/dist/mesh/threemf-bambu.d.ts.map +1 -0
- package/dist/mesh/threemf-bambu.js +334 -0
- package/dist/mesh/threemf-bambu.js.map +1 -0
- package/dist/mesh/threemf-loader.d.ts +50 -0
- package/dist/mesh/threemf-loader.d.ts.map +1 -0
- package/dist/mesh/threemf-loader.js +628 -0
- package/dist/mesh/threemf-loader.js.map +1 -0
- package/dist/mesh/threemf-view.d.ts +71 -0
- package/dist/mesh/threemf-view.d.ts.map +1 -0
- package/dist/mesh/threemf-view.js +100 -0
- package/dist/mesh/threemf-view.js.map +1 -0
- package/dist/mesh/transform.d.ts +2 -2
- package/dist/mesh/transform.d.ts.map +1 -1
- package/dist/mesh/transform.js +3 -3
- package/dist/mesh/transform.js.map +1 -1
- package/dist/mesh/types.d.ts +1 -1
- package/dist/mesh/types.d.ts.map +1 -1
- package/dist/mesh/types.js.map +1 -1
- package/dist/node-host/cli.d.ts +44 -6
- package/dist/node-host/cli.d.ts.map +1 -1
- package/dist/node-host/cli.js +127 -50
- package/dist/node-host/cli.js.map +1 -1
- package/dist/node-host/font-family-index.d.ts +93 -0
- package/dist/node-host/font-family-index.d.ts.map +1 -0
- package/dist/node-host/font-family-index.js +273 -0
- package/dist/node-host/font-family-index.js.map +1 -0
- package/dist/node-host/fs-asset-resolver.d.ts +8 -3
- package/dist/node-host/fs-asset-resolver.d.ts.map +1 -1
- package/dist/node-host/fs-asset-resolver.js +13 -5
- package/dist/node-host/fs-asset-resolver.js.map +1 -1
- package/dist/node-host/index.d.ts +8 -0
- package/dist/node-host/index.d.ts.map +1 -1
- package/dist/node-host/index.js +1 -0
- package/dist/node-host/index.js.map +1 -1
- package/dist/node-host/node-font-provider.d.ts +28 -0
- package/dist/node-host/node-font-provider.d.ts.map +1 -1
- package/dist/node-host/node-font-provider.js +49 -0
- package/dist/node-host/node-font-provider.js.map +1 -1
- package/dist/node.d.ts +1 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +1 -0
- package/dist/node.js.map +1 -1
- package/dist/occt-kernel/occt-primitives.d.ts.map +1 -1
- package/dist/occt-kernel/occt-primitives.js +35 -2
- package/dist/occt-kernel/occt-primitives.js.map +1 -1
- package/dist/occt-kernel/occtKernel.d.ts +18 -13
- package/dist/occt-kernel/occtKernel.d.ts.map +1 -1
- package/dist/occt-kernel/occtKernel.js +20 -31
- package/dist/occt-kernel/occtKernel.js.map +1 -1
- package/dist/occt-kernel/stepColorParser.d.ts +18 -0
- package/dist/occt-kernel/stepColorParser.d.ts.map +1 -1
- package/dist/occt-kernel/stepColorParser.js +38 -0
- package/dist/occt-kernel/stepColorParser.js.map +1 -1
- package/dist/occt-kernel/topologyExt.d.ts +1 -1
- package/dist/occt-kernel/topologyExt.d.ts.map +1 -1
- package/dist/occt-kernel/topologyExt.js +8 -6
- package/dist/occt-kernel/topologyExt.js.map +1 -1
- package/dist/primitives/text/cjk-font.d.ts +2 -15
- package/dist/primitives/text/cjk-font.d.ts.map +1 -1
- package/dist/primitives/text/cjk-font.js +13 -1
- package/dist/primitives/text/cjk-font.js.map +1 -1
- package/dist/runtime-state.d.ts +103 -9
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +95 -2
- package/dist/runtime-state.js.map +1 -1
- package/dist/sdk.d.ts +4 -4
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +6 -6
- package/dist/sdk.js.map +1 -1
- package/dist/shape.d.ts +97 -2
- package/dist/shape.d.ts.map +1 -1
- package/dist/shape.js +126 -1
- package/dist/shape.js.map +1 -1
- package/dist/tolerance.d.ts +38 -0
- package/dist/tolerance.d.ts.map +1 -0
- package/dist/tolerance.js +40 -0
- package/dist/tolerance.js.map +1 -0
- package/dist/topology/naming/lineage.d.ts +6 -0
- package/dist/topology/naming/lineage.d.ts.map +1 -1
- package/dist/topology/naming/lineage.js +8 -0
- package/dist/topology/naming/lineage.js.map +1 -1
- package/dist/topology/naming/resolve-edge.d.ts +20 -1
- package/dist/topology/naming/resolve-edge.d.ts.map +1 -1
- package/dist/topology/naming/resolve-edge.js +54 -20
- package/dist/topology/naming/resolve-edge.js.map +1 -1
- package/dist/topology/naming/score.js +3 -3
- package/dist/topology/naming/score.js.map +1 -1
- package/dist/units.d.ts +248 -0
- package/dist/units.d.ts.map +1 -0
- package/dist/units.js +397 -0
- package/dist/units.js.map +1 -0
- package/dist/weapp.d.ts +6 -2
- package/dist/weapp.d.ts.map +1 -1
- package/dist/weapp.js +7 -1
- package/dist/weapp.js.map +1 -1
- package/package.json +28 -3
package/dist/api/shell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* api shell — 抽壳:按面移除生成等厚薄壁(手写中立 op,Phase 5)
|
|
3
3
|
*
|
|
4
4
|
* 中立 op:L1 `shell(solid, facesToRemove, thickness, tolerance)` 在 occt 与
|
|
5
5
|
* brepkit 两侧均有真实现(engine-method-map 实测 `dialect`)⇒ 走 `getBrepApi()`
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* 与 `fillet` 的 `EdgeTopoRef[]` / `extrude` 的 `upTo` 同族;不复刻 vendored 的
|
|
11
11
|
* `Face[]` 句柄入参。解析在 op 内一处完成(`buildEdgeResolutionContext` 现场枚举
|
|
12
12
|
* + `resolveTopoRef`)。
|
|
13
|
+
*
|
|
14
|
+
* 网格链(方案 2026-10-01 §4 Phase 4 / B3 批):`mesh:` 实现走网格后端,面按
|
|
15
|
+
* **序号或 FaceTopoRef** 解析(近似拓扑没有 role 层),产物是新的网格零件。
|
|
13
16
|
*/
|
|
14
17
|
import { solidToShape } from '../brep/brep-ops.js';
|
|
15
18
|
import { getBrepApi } from '../brep/handle-bridge.js';
|
|
@@ -17,15 +20,21 @@ import { brepOf, fromBrep } from '../shape.js';
|
|
|
17
20
|
import { defineOp } from '../sdk.js';
|
|
18
21
|
import { resolveTopoRef, TopoRefError } from '../topology/naming/index.js';
|
|
19
22
|
import { buildEdgeResolutionContext } from './topo-resolve.js';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
import { meshKernelFailure, meshSolidBasicEntry, meshSolidProduct, resolveMeshFaces } from './internal/mesh-solid-op.js';
|
|
24
|
+
/** 参数共校验(两条路径共用;`openFaces` 为空数组合法 = 全封闭薄壁)。 */
|
|
25
|
+
function assertShellParams(params) {
|
|
26
|
+
const { openFaces, thickness } = params ?? {};
|
|
23
27
|
if (!Array.isArray(openFaces)) {
|
|
24
|
-
throw new Error('E_SHELL_BAD_OPEN_FACES: shell.openFaces must be an array of FaceTopoRef');
|
|
28
|
+
throw new Error('E_SHELL_BAD_OPEN_FACES: shell.openFaces must be an array of FaceTopoRef or ordinals');
|
|
25
29
|
}
|
|
26
30
|
if (typeof thickness !== 'number' || !Number.isFinite(thickness) || thickness <= 0) {
|
|
27
31
|
throw new Error('E_SHELL_BAD_THICKNESS: shell.thickness must be a positive number');
|
|
28
32
|
}
|
|
33
|
+
}
|
|
34
|
+
/** BREP 路径:解析面引用 → L1 shell → 收养。 */
|
|
35
|
+
function shellBrep(input, params) {
|
|
36
|
+
const { openFaces, thickness, tolerance } = params;
|
|
37
|
+
assertShellParams(params);
|
|
29
38
|
const kernel = getBrepApi();
|
|
30
39
|
const solid = brepOf(input);
|
|
31
40
|
if (!solid)
|
|
@@ -34,6 +43,11 @@ function shellBrep(input, params) {
|
|
|
34
43
|
if (!ctx)
|
|
35
44
|
throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', 'shell: input has no BREP naming context');
|
|
36
45
|
const faceHandles = openFaces.map((ref) => {
|
|
46
|
+
// 精度链不开序号口子:BREP 的面身份是 `(origin, role)`,序号只是本次枚举序。
|
|
47
|
+
if (typeof ref === 'number') {
|
|
48
|
+
throw new Error('E_SHELL_BAD_OPEN_FACES: an ordinal face selector is only available on the mesh chain — ' +
|
|
49
|
+
'a precision-chain face is identified by its role line (cad.faceRef)');
|
|
50
|
+
}
|
|
37
51
|
if (!ref || ref.kind !== 'face') {
|
|
38
52
|
throw new Error('E_SHELL_BAD_OPEN_FACES: every openFaces entry must be a FaceTopoRef (cad.faceRef)');
|
|
39
53
|
}
|
|
@@ -46,6 +60,32 @@ function shellBrep(input, params) {
|
|
|
46
60
|
const result = kernel.shell(solid, faceHandles, thickness, tolerance ?? 1e-6);
|
|
47
61
|
return fromBrep(solidToShape(kernel, result), { solid: result });
|
|
48
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* 网格实体路径:按序号或几何选出要开口的面,交网格后端抽壳。
|
|
65
|
+
*
|
|
66
|
+
* 与 BREP 路径同一条 L1 契约面(`shell(solid, faces, thickness, tolerance)`),
|
|
67
|
+
* 差别只在选面方式:近似拓扑没有 role 层,面靠**序号**(拓扑 `faces` 数组下标 + 1)
|
|
68
|
+
* 或 `FaceTopoRef` 的几何匹配(法向/中心/面积)指认。产物是新网格零件,
|
|
69
|
+
* 近似拓扑由 `meshSolidProduct` 重建。
|
|
70
|
+
*
|
|
71
|
+
* @param input - the mesh-solid input.
|
|
72
|
+
* @param params - the shell parameters.
|
|
73
|
+
* @returns the shelled mesh solid as a new mesh part.
|
|
74
|
+
*/
|
|
75
|
+
function shellMeshSolid(input, params) {
|
|
76
|
+
const { openFaces, thickness, tolerance } = params;
|
|
77
|
+
assertShellParams(params);
|
|
78
|
+
const entry = meshSolidBasicEntry(input, 'shell');
|
|
79
|
+
const faceHandles = resolveMeshFaces(entry.kernel, input, openFaces, 'shell');
|
|
80
|
+
let result;
|
|
81
|
+
try {
|
|
82
|
+
result = entry.kernel.shell(entry.solid, faceHandles, thickness, tolerance ?? 1e-6);
|
|
83
|
+
}
|
|
84
|
+
catch (cause) {
|
|
85
|
+
throw meshKernelFailure('shell', 'E_SHELL_FAILED', `shell(thickness=${thickness}) removing ${faceHandles.length} face(s)`, cause);
|
|
86
|
+
}
|
|
87
|
+
return meshSolidProduct(entry, result);
|
|
88
|
+
}
|
|
49
89
|
/**
|
|
50
90
|
* 抽壳:移除指定面并把余下面偏置成等厚薄壁。
|
|
51
91
|
* @group 特征
|
|
@@ -54,17 +94,23 @@ function shellBrep(input, params) {
|
|
|
54
94
|
* @qual ok
|
|
55
95
|
* @name shell
|
|
56
96
|
* @note 中立 op:L1 shell 两引擎同实现。`openFaces` 为空数组时生成全封闭薄壁。
|
|
57
|
-
*
|
|
97
|
+
* 精度链按 role 线路选面(`cad.faceRef`);网格链按序号或几何选面——网格零件
|
|
98
|
+
* 没有 role 层,序号是唯一无歧义的指认方式。
|
|
58
99
|
* @returns Shape 抽壳后的薄壁体。
|
|
59
100
|
* @param input - 目标几何。type:Shape required:true
|
|
60
|
-
* @param params.openFaces - 要移除的面(FaceTopoRef[],cad.faceRef
|
|
101
|
+
* @param params.openFaces - 要移除的面(FaceTopoRef[],cad.faceRef 产物;网格链可用 1 起序号)。type:FaceTopoRef[] required:true
|
|
61
102
|
* @param params.thickness - 壁厚(mm,>0)。type:number required:true
|
|
62
103
|
* @param params.tolerance - 容差(mm)。type:number required:false
|
|
63
104
|
* @example
|
|
64
105
|
* const sh = await cad.shell(part0, { openFaces: [cad.faceRef(part0, 1)], thickness: 2 })
|
|
106
|
+
* const sm = await cad.shell(meshPart, { openFaces: [4], thickness: 2 })
|
|
65
107
|
*/
|
|
66
108
|
export const shell = defineOp({
|
|
67
109
|
capabilities: ['directEdit'],
|
|
110
|
+
meshEngines: ['brepkit'],
|
|
111
|
+
mesh(input, params) {
|
|
112
|
+
return shellMeshSolid(input, params);
|
|
113
|
+
},
|
|
68
114
|
brep(input, params) {
|
|
69
115
|
return shellBrep(input, params);
|
|
70
116
|
},
|
package/dist/api/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/api/shell.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/api/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;G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CAAC,CAAA;IACzB,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACjD,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IAE7E,IAAI,MAAkB,CAAA;IACtB,IAAI,CAAC;QACH,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC,CAAA;IACrF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,iBAAiB,CACrB,OAAO,EACP,gBAAgB,EAChB,mBAAmB,SAAS,cAAc,WAAW,CAAC,MAAM,UAAU,EACtE,KAAK,CACN,CAAA;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AACxC,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC;IAC5B,YAAY,EAAE,CAAC,YAAY,CAAC;IAC5B,WAAW,EAAE,CAAC,SAAS,CAAC;IACxB,IAAI,CAAC,KAAY,EAAE,MAAmB;QACpC,OAAO,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACtC,CAAC;IACD,IAAI,CAAC,KAAY,EAAE,MAAmB;QACpC,OAAO,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACjC,CAAC;IACD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,EAAgB;CAC3E,CAAC,CAAA","sourcesContent":["/**\n * api shell — 抽壳:按面移除生成等厚薄壁(手写中立 op,Phase 5)\n *\n * 中立 op:L1 `shell(solid, facesToRemove, thickness, tolerance)` 在 occt 与\n * brepkit 两侧均有真实现(engine-method-map 实测 `dialect`)⇒ 走 `getBrepApi()`\n * (D12),不声明 engines(中立 op:实现只经 L1 契约面)。相对现状是\n * 能力升级——vendored 版是 occt 平台 op(arg-spec `engines:['occt']`,skip)。\n *\n * 选面口径(设计原则 4):`openFaces: FaceTopoRef[]`(`cad.faceRef` 产物),\n * 与 `fillet` 的 `EdgeTopoRef[]` / `extrude` 的 `upTo` 同族;不复刻 vendored 的\n * `Face[]` 句柄入参。解析在 op 内一处完成(`buildEdgeResolutionContext` 现场枚举\n * + `resolveTopoRef`)。\n *\n * 网格链(方案 2026-10-01 §4 Phase 4 / B3 批):`mesh:` 实现走网格后端,面按\n * **序号或 FaceTopoRef** 解析(近似拓扑没有 role 层),产物是新的网格零件。\n */\n\nimport type { Shape } from '../mesh/types'\nimport type { BrepHandle } from '../brep/engine/types'\nimport { solidToShape } from '../brep/brep-ops'\nimport { getBrepApi } from '../brep/handle-bridge'\nimport { brepOf, fromBrep } from '../shape'\nimport { defineOp } from '../sdk'\nimport type { FaceTopoRef } from '../topology/naming'\nimport { resolveTopoRef, TopoRefError } from '../topology/naming'\nimport type { Provenance } from '../topology/naming/lineage'\nimport { buildEdgeResolutionContext } from './topo-resolve'\nimport { meshKernelFailure, meshSolidBasicEntry, meshSolidProduct, resolveMeshFaces } from './internal/mesh-solid-op'\n\n/** 抽壳时移除的面选择器:精度链用 `FaceTopoRef`;网格链也可用 1 起序号。 */\nexport type ShellFaceSelector = number | FaceTopoRef\n\n/** `cad.shell` 参数。 */\nexport interface ShellParams {\n /** 抽壳时移除的面(FaceTopoRef[],`cad.faceRef` 产物;空数组 = 全封闭薄壁)。 */\n openFaces: ShellFaceSelector[]\n /** 壁厚(mm,>0,向内偏置)。 */\n thickness: number\n /** 容差(mm,可选;默认走内核约定值)。 */\n tolerance?: number\n}\n\n/** 参数共校验(两条路径共用;`openFaces` 为空数组合法 = 全封闭薄壁)。 */\nfunction assertShellParams(params: ShellParams): void {\n const { openFaces, thickness } = params ?? ({} as ShellParams)\n if (!Array.isArray(openFaces)) {\n throw new Error('E_SHELL_BAD_OPEN_FACES: shell.openFaces must be an array of FaceTopoRef or ordinals')\n }\n if (typeof thickness !== 'number' || !Number.isFinite(thickness) || thickness <= 0) {\n throw new Error('E_SHELL_BAD_THICKNESS: shell.thickness must be a positive number')\n }\n}\n\n/** BREP 路径:解析面引用 → L1 shell → 收养。 */\nfunction shellBrep(input: Shape, params: ShellParams): Shape {\n const { openFaces, thickness, tolerance } = params\n assertShellParams(params)\n const kernel = getBrepApi()\n const solid = brepOf(input) as BrepHandle | undefined\n if (!solid) throw new Error('E_SHELL_NO_BREP: shell input is not BREP')\n\n const ctx = buildEdgeResolutionContext(kernel, input as object)\n if (!ctx) throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', 'shell: input has no BREP naming context')\n const faceHandles = openFaces.map((ref) => {\n // 精度链不开序号口子:BREP 的面身份是 `(origin, role)`,序号只是本次枚举序。\n if (typeof ref === 'number') {\n throw new Error(\n 'E_SHELL_BAD_OPEN_FACES: an ordinal face selector is only available on the mesh chain — ' +\n 'a precision-chain face is identified by its role line (cad.faceRef)',\n )\n }\n if (!ref || (ref as { kind?: unknown }).kind !== 'face') {\n throw new Error('E_SHELL_BAD_OPEN_FACES: every openFaces entry must be a FaceTopoRef (cad.faceRef)')\n }\n const r = resolveTopoRef(ref, ctx)\n if (r.handle === undefined) {\n throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', `shell: face resolved without handle (${ref.origin}/${ref.role})`)\n }\n return r.handle as BrepHandle\n })\n\n const result = kernel.shell(solid, faceHandles, thickness, tolerance ?? 1e-6)\n return fromBrep(solidToShape(kernel, result), { solid: result })\n}\n\n/**\n * 网格实体路径:按序号或几何选出要开口的面,交网格后端抽壳。\n *\n * 与 BREP 路径同一条 L1 契约面(`shell(solid, faces, thickness, tolerance)`),\n * 差别只在选面方式:近似拓扑没有 role 层,面靠**序号**(拓扑 `faces` 数组下标 + 1)\n * 或 `FaceTopoRef` 的几何匹配(法向/中心/面积)指认。产物是新网格零件,\n * 近似拓扑由 `meshSolidProduct` 重建。\n *\n * @param input - the mesh-solid input.\n * @param params - the shell parameters.\n * @returns the shelled mesh solid as a new mesh part.\n */\nfunction shellMeshSolid(input: Shape, params: ShellParams): Shape {\n const { openFaces, thickness, tolerance } = params\n assertShellParams(params)\n const entry = meshSolidBasicEntry(input, 'shell')\n const faceHandles = resolveMeshFaces(entry.kernel, input, openFaces, 'shell')\n\n let result: BrepHandle\n try {\n result = entry.kernel.shell(entry.solid, faceHandles, thickness, tolerance ?? 1e-6)\n } catch (cause) {\n throw meshKernelFailure(\n 'shell',\n 'E_SHELL_FAILED',\n `shell(thickness=${thickness}) removing ${faceHandles.length} face(s)`,\n cause,\n )\n }\n return meshSolidProduct(entry, result)\n}\n\n/**\n * 抽壳:移除指定面并把余下面偏置成等厚薄壁。\n * @group 特征\n * @inputs 1\n * @async true\n * @qual ok\n * @name shell\n * @note 中立 op:L1 shell 两引擎同实现。`openFaces` 为空数组时生成全封闭薄壁。\n * 精度链按 role 线路选面(`cad.faceRef`);网格链按序号或几何选面——网格零件\n * 没有 role 层,序号是唯一无歧义的指认方式。\n * @returns Shape 抽壳后的薄壁体。\n * @param input - 目标几何。type:Shape required:true\n * @param params.openFaces - 要移除的面(FaceTopoRef[],cad.faceRef 产物;网格链可用 1 起序号)。type:FaceTopoRef[] required:true\n * @param params.thickness - 壁厚(mm,>0)。type:number required:true\n * @param params.tolerance - 容差(mm)。type:number required:false\n * @example\n * const sh = await cad.shell(part0, { openFaces: [cad.faceRef(part0, 1)], thickness: 2 })\n * const sm = await cad.shell(meshPart, { openFaces: [4], thickness: 2 })\n */\nexport const shell = defineOp({\n capabilities: ['directEdit'],\n meshEngines: ['brepkit'],\n mesh(input: Shape, params: ShellParams) {\n return shellMeshSolid(input, params)\n },\n brep(input: Shape, params: ShellParams) {\n return shellBrep(input, params)\n },\n naming: { kind: 'kernel', newFaces: { via: 'byAdjacency' } } as Provenance,\n})\n"]}
|
|
@@ -16,6 +16,16 @@
|
|
|
16
16
|
* planar faces; embedding the wire into a genuinely curved host face
|
|
17
17
|
* (`fixWireOnFace`) is a follow-up. The op declares `engines: ['occt']`
|
|
18
18
|
* (surface sampling needs the BREP platform).
|
|
19
|
+
*
|
|
20
|
+
* **Two chains, two mechanisms** (plan 2026-10-01 §4 Phase 3). The BREP branch
|
|
21
|
+
* above maps the contour into the host face's UV domain. The **mesh branch**
|
|
22
|
+
* (`buildSketchOnFaceMesh`, `meshEngines: ['brepkit']`) works on a mesh solid's
|
|
23
|
+
* approximate topology and deliberately does NOT use UV space: a brepkit plane's
|
|
24
|
+
* domain is ±1e6 (an infinite domain), so "place the sketch in the face's UV
|
|
25
|
+
* range" is meaningless there. It places the contour in the face's own plane
|
|
26
|
+
* frame instead (origin = face bbox centre, normal = `surfaceNormal`), which
|
|
27
|
+
* matches `cad.sketchOnPlane`'s semantics. The result is a **mesh-chain face**
|
|
28
|
+
* (`ShapeSlot.meshFace`), ready for the mesh branch of `cad.extrude`.
|
|
19
29
|
* @module
|
|
20
30
|
*/
|
|
21
31
|
import type { Shape } from '../mesh/types.js';
|
|
@@ -65,8 +75,39 @@ export declare function placeContoursOnFace(kernel: BrepEngineApi, host: BrepHan
|
|
|
65
75
|
* @returns Shape on the target face (face, or the outer wire when `as:'wire'`).
|
|
66
76
|
*/
|
|
67
77
|
export declare function buildSketchOnFaceWith(kernel: BrepEngineApi, params: SketchOnFaceParams): Shape;
|
|
78
|
+
/**
|
|
79
|
+
* 网格链上的 `cad.sketchOnFace`:在**识别出的平面网格面**上铺 2D 轮廓,产出网格链面
|
|
80
|
+
* (方案 2026-10-01 §4 Phase 3-2),可交给 `cad.extrude` 的网格路径拉伸出新实体。
|
|
81
|
+
*
|
|
82
|
+
* 与 BREP 侧的三点差别,每一点都是"近似拓扑没有 UV 语义"的直接后果:
|
|
83
|
+
*
|
|
84
|
+
* 1. **不走 UV 域**。BREP 侧 `assembleWireOnFace` 把 2D 采样点映射进面的 `(u,v)` 域;
|
|
85
|
+
* 而平面在 brepkit 上的域是 ±1e6 的**无限域**(方案 §4 Phase 3-1 实测),拿它当
|
|
86
|
+
* 草图范围毫无意义。这里改用面自己的平面框(原点 = 面包围盒中心、法向 = 面法向),
|
|
87
|
+
* 2D 坐标直接落在平面坐标系里——与 `cad.sketchOnPlane` 的语义一致。
|
|
88
|
+
* 2. **`scaleMode` 只接受 `'original'`**。`'bounds'` / `'native'` 的定义是"拟合到面的
|
|
89
|
+
* UV 域",而那个域在这里要么是无限域、要么不存在。静默按 `'original'` 处理会造成
|
|
90
|
+
* "同一次调用在两条链上得到不同尺寸"的隐性分歧,所以如实拒绝。
|
|
91
|
+
* 3. **`as:'wire'` 不支持**。网格链上的一根 wire 没有身份槽(面才有),而 sketch 的
|
|
92
|
+
* 下游用途(拉伸)要的正是面。需要 wire 的场景请走 BREP 链。
|
|
93
|
+
*
|
|
94
|
+
* 另外只支持**平面面**:曲面面(STL 圆柱的侧面片)上铺草图需要曲面嵌入,属未开的能力。
|
|
95
|
+
*
|
|
96
|
+
* @param params - contour loops + target mesh solid + face selector + scale mode.
|
|
97
|
+
* @returns the mesh-chain face Shape on the target face.
|
|
98
|
+
* @throws {MeshUnsupportedError} when the target is not a mesh solid, the face is not planar,
|
|
99
|
+
* the scale mode is not `'original'`, `as:'wire'` was requested, or the sketch is multi-island.
|
|
100
|
+
*/
|
|
101
|
+
export declare function buildSketchOnFaceMesh(params: SketchOnFaceParams): Shape;
|
|
68
102
|
/**
|
|
69
103
|
* `cad.sketchOnFace`: place 2D contours on a face of a solid and construct a Shape.
|
|
104
|
+
*
|
|
105
|
+
* **网格链**(`meshEngines: ['brepkit']`,方案 2026-10-01 §4 Phase 3):`on` 是网格实体
|
|
106
|
+
* 时,轮廓按面自己的**平面框**铺放(原点 = 面包围盒中心、法向 = 面法向),产物是一张
|
|
107
|
+
* 网格链面,可直接交给 `cad.extrude` 拉伸。该分支只接受平面面、只接受默认
|
|
108
|
+
* `scaleMode`(`'bounds'`/`'native'` 相对 UV 域定义,网格链上没有 UV 域)、只接受
|
|
109
|
+
* `as:'face'`、且只接受单个轮廓岛——每一条越界都以 `E_MESH_SOLID_UNSUPPORTED` 说明原因。
|
|
110
|
+
*
|
|
70
111
|
* @group 创建
|
|
71
112
|
* @inputs 0
|
|
72
113
|
* @async false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sketch-on-face.d.ts","sourceRoot":"","sources":["../../src/api/sketch-on-face.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sketch-on-face.d.ts","sourceRoot":"","sources":["../../src/api/sketch-on-face.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAMtD,OAAO,EAAgC,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAKnF,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAGxF,OAAO,EAA4C,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AAStF,wGAAwG;AACxG,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,WAAW,CAAA;AAE/C,8DAA8D;AAC9D,MAAM,WAAW,kBAAkB;IACjC,sFAAsF;IACtF,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB,qDAAqD;IACrD,EAAE,EAAE,KAAK,CAAA;IACT,+EAA+E;IAC/E,IAAI,EAAE,YAAY,CAAA;IAClB,8GAA8G;IAC9G,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,gHAAgH;IAChH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,GAAG,UAAU,CA0BtG;AA6BD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,WAAW,EAAE,GACtB,UAAU,EAAE,CAMd;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,GAAG,KAAK,CAyB9F;AAoCD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,KAAK,CAgDvE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY;;CAavB,CAAA"}
|
|
@@ -8,8 +8,11 @@ import { Blueprint } from '../geometry2d/blueprint.js';
|
|
|
8
8
|
import { CompoundBlueprint } from '../geometry2d/compound-blueprint.js';
|
|
9
9
|
import { organiseBlueprints } from '../geometry2d/organise.js';
|
|
10
10
|
import { assembleWireOnFace } from '../geometry2d/bridge/on-surface.js';
|
|
11
|
+
import { assembleWire } from '../geometry2d/bridge/lift-on-plane.js';
|
|
11
12
|
import { profileSegToCurve } from '../geometry2d/adapt.js';
|
|
12
|
-
import { assertProfileParams } from './profile.js';
|
|
13
|
+
import { assertProfileParams, toContourBlueprints } from './profile.js';
|
|
14
|
+
import { MeshUnsupportedError, getCurrentStmt } from '../runtime-state.js';
|
|
15
|
+
import { meshBackendOrThrow, meshFacePlane, meshFaceProduct, resolveMeshFaceHandle, } from './internal/mesh-solid-op.js';
|
|
13
16
|
/**
|
|
14
17
|
* Resolve a face on `on` to its live BREP handle (1-based ordinal or `cad.faceRef`).
|
|
15
18
|
* @param kernel - the BREP engine surface.
|
|
@@ -110,8 +113,99 @@ export function buildSketchOnFaceWith(kernel, params) {
|
|
|
110
113
|
const compound = kernel.makeCompound(faces);
|
|
111
114
|
return fromBrep(solidToShape(kernel, compound), { solid: compound });
|
|
112
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* 把一张平面的法向对齐到参考方向(外部朝向)。网格链上的复制版:BREP 侧的
|
|
118
|
+
* `orientLikeHost` 存在的原因是"面朝向反了 → 由它拉出的棱柱壳反向 → 体积归零",
|
|
119
|
+
* 这里同一个道理,只是参考法向来自**平面本身**(`meshFacePlane` 的法向就是从宿主面
|
|
120
|
+
* 的 `surfaceNormal` 取的),不必再回读宿主句柄。
|
|
121
|
+
*
|
|
122
|
+
* @param kernel - the mesh backend's L1 kernel.
|
|
123
|
+
* @param reference - the outward normal the placed face must agree with.
|
|
124
|
+
* @param face - the face built on the plane.
|
|
125
|
+
* @returns a handle to the (possibly re-oriented) face.
|
|
126
|
+
*/
|
|
127
|
+
function orientFaceTo(kernel, reference, face) {
|
|
128
|
+
const uv = kernel.uvBounds(face);
|
|
129
|
+
const n = kernel.surfaceNormal(face, (uv.uMin + uv.uMax) / 2, (uv.vMin + uv.vMax) / 2);
|
|
130
|
+
const dot = reference.x * n.x + reference.y * n.y + reference.z * n.z;
|
|
131
|
+
return dot < 0 ? kernel.reverseShape(face) : face;
|
|
132
|
+
}
|
|
133
|
+
/** 一个已归类的轮廓条目(外环 + 可选孔)在平面坐标系里造一张面。 */
|
|
134
|
+
function buildFaceOnPlane(kernel, plane, outward, entry) {
|
|
135
|
+
const outerBp = entry instanceof CompoundBlueprint ? entry.blueprints[0] : entry;
|
|
136
|
+
let face = orientFaceTo(kernel, outward, kernel.makeFace(assembleWire(kernel, plane, outerBp)));
|
|
137
|
+
if (entry instanceof CompoundBlueprint) {
|
|
138
|
+
const holes = entry.blueprints.slice(1).map((h) => assembleWire(kernel, plane, h));
|
|
139
|
+
if (holes.length > 0)
|
|
140
|
+
face = kernel.addHolesInFace(face, holes);
|
|
141
|
+
}
|
|
142
|
+
return face;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 网格链上的 `cad.sketchOnFace`:在**识别出的平面网格面**上铺 2D 轮廓,产出网格链面
|
|
146
|
+
* (方案 2026-10-01 §4 Phase 3-2),可交给 `cad.extrude` 的网格路径拉伸出新实体。
|
|
147
|
+
*
|
|
148
|
+
* 与 BREP 侧的三点差别,每一点都是"近似拓扑没有 UV 语义"的直接后果:
|
|
149
|
+
*
|
|
150
|
+
* 1. **不走 UV 域**。BREP 侧 `assembleWireOnFace` 把 2D 采样点映射进面的 `(u,v)` 域;
|
|
151
|
+
* 而平面在 brepkit 上的域是 ±1e6 的**无限域**(方案 §4 Phase 3-1 实测),拿它当
|
|
152
|
+
* 草图范围毫无意义。这里改用面自己的平面框(原点 = 面包围盒中心、法向 = 面法向),
|
|
153
|
+
* 2D 坐标直接落在平面坐标系里——与 `cad.sketchOnPlane` 的语义一致。
|
|
154
|
+
* 2. **`scaleMode` 只接受 `'original'`**。`'bounds'` / `'native'` 的定义是"拟合到面的
|
|
155
|
+
* UV 域",而那个域在这里要么是无限域、要么不存在。静默按 `'original'` 处理会造成
|
|
156
|
+
* "同一次调用在两条链上得到不同尺寸"的隐性分歧,所以如实拒绝。
|
|
157
|
+
* 3. **`as:'wire'` 不支持**。网格链上的一根 wire 没有身份槽(面才有),而 sketch 的
|
|
158
|
+
* 下游用途(拉伸)要的正是面。需要 wire 的场景请走 BREP 链。
|
|
159
|
+
*
|
|
160
|
+
* 另外只支持**平面面**:曲面面(STL 圆柱的侧面片)上铺草图需要曲面嵌入,属未开的能力。
|
|
161
|
+
*
|
|
162
|
+
* @param params - contour loops + target mesh solid + face selector + scale mode.
|
|
163
|
+
* @returns the mesh-chain face Shape on the target face.
|
|
164
|
+
* @throws {MeshUnsupportedError} when the target is not a mesh solid, the face is not planar,
|
|
165
|
+
* the scale mode is not `'original'`, `as:'wire'` was requested, or the sketch is multi-island.
|
|
166
|
+
*/
|
|
167
|
+
export function buildSketchOnFaceMesh(params) {
|
|
168
|
+
const opLabel = 'sketchOnFace';
|
|
169
|
+
const backend = meshBackendOrThrow(opLabel);
|
|
170
|
+
const kernel = backend.kernel;
|
|
171
|
+
const mode = params.scaleMode ?? 'original';
|
|
172
|
+
if (mode !== 'original') {
|
|
173
|
+
throw new MeshUnsupportedError(`E_MESH_SOLID_UNSUPPORTED: ${opLabel} scaleMode '${mode}' is defined against the face's UV domain, ` +
|
|
174
|
+
'which a mesh-chain face does not have — use the default \'original\' (2D coords live in the face plane)', getCurrentStmt());
|
|
175
|
+
}
|
|
176
|
+
if (params.as === 'wire') {
|
|
177
|
+
throw new MeshUnsupportedError(`E_MESH_SOLID_UNSUPPORTED: ${opLabel} as:'wire' has no mesh-chain representation — ` +
|
|
178
|
+
'a mesh-chain wire has no identity slot; ask for the default as:\'face\' instead', getCurrentStmt());
|
|
179
|
+
}
|
|
180
|
+
const host = resolveMeshFaceHandle(kernel, params.on, params.face, opLabel);
|
|
181
|
+
const surface = kernel.surfaceType(host);
|
|
182
|
+
if (surface !== 'plane') {
|
|
183
|
+
throw new MeshUnsupportedError(`E_MESH_SOLID_UNSUPPORTED: ${opLabel} needs a planar mesh face to sketch on — this face reports ` +
|
|
184
|
+
`surfaceType '${surface}'. Sketches on curved approximate faces are not implemented ` +
|
|
185
|
+
'(an STL cylinder is 32 planar strips, each of which IS usable)', getCurrentStmt());
|
|
186
|
+
}
|
|
187
|
+
const plane = meshFacePlane(kernel, host);
|
|
188
|
+
const outward = { x: plane.zDir.x, y: plane.zDir.y, z: plane.zDir.z };
|
|
189
|
+
const organised = organiseBlueprints(toContourBlueprints(params.contours));
|
|
190
|
+
if (organised.blueprints.length === 0)
|
|
191
|
+
throw new Error('sketchOnFace: no contours to place');
|
|
192
|
+
if (organised.blueprints.length > 1) {
|
|
193
|
+
throw new MeshUnsupportedError(`E_MESH_SOLID_UNSUPPORTED: ${opLabel} produced ${organised.blueprints.length} disjoint islands — ` +
|
|
194
|
+
'the mesh backend can only extrude a single face (brepkit extrude takes one face, not a compound). ' +
|
|
195
|
+
'Sketch and extrude each island separately, then unite them with a boolean', getCurrentStmt());
|
|
196
|
+
}
|
|
197
|
+
const face = buildFaceOnPlane(kernel, plane, outward, organised.blueprints[0]);
|
|
198
|
+
return meshFaceProduct(backend, face);
|
|
199
|
+
}
|
|
113
200
|
/**
|
|
114
201
|
* `cad.sketchOnFace`: place 2D contours on a face of a solid and construct a Shape.
|
|
202
|
+
*
|
|
203
|
+
* **网格链**(`meshEngines: ['brepkit']`,方案 2026-10-01 §4 Phase 3):`on` 是网格实体
|
|
204
|
+
* 时,轮廓按面自己的**平面框**铺放(原点 = 面包围盒中心、法向 = 面法向),产物是一张
|
|
205
|
+
* 网格链面,可直接交给 `cad.extrude` 拉伸。该分支只接受平面面、只接受默认
|
|
206
|
+
* `scaleMode`(`'bounds'`/`'native'` 相对 UV 域定义,网格链上没有 UV 域)、只接受
|
|
207
|
+
* `as:'face'`、且只接受单个轮廓岛——每一条越界都以 `E_MESH_SOLID_UNSUPPORTED` 说明原因。
|
|
208
|
+
*
|
|
115
209
|
* @group 创建
|
|
116
210
|
* @inputs 0
|
|
117
211
|
* @async false
|
|
@@ -127,6 +221,11 @@ export function buildSketchOnFaceWith(kernel, params) {
|
|
|
127
221
|
export const sketchOnFace = defineOp({
|
|
128
222
|
capabilities: ['directEdit'],
|
|
129
223
|
engines: ['occt'],
|
|
224
|
+
meshEngines: ['brepkit'],
|
|
225
|
+
mesh(params) {
|
|
226
|
+
assertProfileParams(params);
|
|
227
|
+
return buildSketchOnFaceMesh(params);
|
|
228
|
+
},
|
|
130
229
|
brep(params) {
|
|
131
230
|
assertProfileParams(params);
|
|
132
231
|
return buildSketchOnFaceWith(getBrepApi(), params);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sketch-on-face.js","sourceRoot":"","sources":["../../src/api/sketch-on-face.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,Q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AA;IACtE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IAC7E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;QACnB,OAAO,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;IACxD,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;AACtE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;IACnC,YAAY,EAAE,CAAC,YAAY,CAAC;IAC5B,OAAO,EAAE,CAAC,MAAM,CAAC;IACjB,IAAI,CAAC,MAA+B;QAClC,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAC3B,OAAO,qBAAqB,CAAC,UAAU,EAAE,EAAE,MAAuC,CAAC,CAAA;IACrF,CAAC;IACD,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,EAAgB;CACtF,CAAC,CAAA","sourcesContent":["/**\n * `cad.sketchOnFace`: place 2D contours onto the UV parameter space of an\n * existing face (E3 placement).\n *\n * Unlike `sketchOnPlane` (which lifts a contour onto a whole plane *frame*),\n * `sketchOnFace` lays the contour on the surface of a specific face of a target\n * solid. Every 2D curve is sampled, the samples mapped into the face's `(u,v)`\n * domain under a scale mode (`original` / `bounds` / `native`), the surface\n * evaluated at those UVs, and a curve edge interpolated through the resulting\n * 3D points (see `geometry2d/bridge/on-surface.ts`). The placed wire then\n * becomes a face (`as:'face'`) ready to be extruded along the face normal, or\n * is returned raw (`as:'wire'`).\n *\n * v1 scope: the on-surface primitive is surface-type-independent, but the result\n * face is built with `makeFace` on the interpolated wire, so it is exact for\n * planar faces; embedding the wire into a genuinely curved host face\n * (`fixWireOnFace`) is a follow-up. The op declares `engines: ['occt']`\n * (surface sampling needs the BREP platform).\n * @module\n */\nimport type { Shape } from '../mesh/types'\nimport type { BrepEngineApi } from '../brep/engine/primitives'\nimport type { BrepHandle } from '../brep/engine/types'\nimport { getBrepApi } from '../brep/handle-bridge'\nimport { solidToShape } from '../brep/brep-ops'\nimport { fromBrep, fromBrepCurve, brepOf } from '../shape'\nimport { defineOp } from '../sdk'\nimport type { Provenance } from '../topology/naming/lineage'\nimport { TopoRefError, resolveTopoRef, type FaceTopoRef } from '../topology/naming'\nimport { buildEdgeResolutionContext } from './topo-resolve'\nimport { Blueprint } from '../geometry2d/blueprint'\nimport { CompoundBlueprint } from '../geometry2d/compound-blueprint'\nimport { organiseBlueprints } from '../geometry2d/organise'\nimport { assembleWireOnFace, type FaceScaleMode } from '../geometry2d/bridge/on-surface'\nimport { profileSegToCurve, type ProfileSegLike } from '../geometry2d/adapt'\nimport { assertProfileParams, type ProfileLoop } from './profile'\n\n/** A face selector on a target solid: a 1-based ordinal (FreeCAD `FaceN`) or a `cad.faceRef` result. */\nexport type FaceSelector = number | FaceTopoRef\n\n/** Contour loops + the target face for `cad.sketchOnFace`. */\nexport interface SketchOnFaceParams {\n /** Ordered 2D closed contours (same shape as `cad.profile` / `cad.sketchOnPlane`). */\n contours: ProfileLoop[]\n /** The target solid on which the host face lives. */\n on: Shape\n /** The host face: a 1-based face ordinal, or a `cad.faceRef(on, n)` result. */\n face: FaceSelector\n /** How 2D coords map onto the face UV space: `'original'` (identity) | `'bounds'`/`'native'` (affine-fit). */\n scaleMode?: FaceScaleMode\n /** Result shape: `'face'` (default) builds a face on the contour; `'wire'` returns the outer-loop wire only. */\n as?: 'face' | 'wire'\n}\n\n/**\n * Resolve a face on `on` to its live BREP handle (1-based ordinal or `cad.faceRef`).\n * @param kernel - the BREP engine surface.\n * @param on - the target solid shape.\n * @param selector - the face ordinal or `cad.faceRef` result.\n * @returns the live face handle.\n */\nexport function resolveFaceHandle(kernel: BrepEngineApi, on: Shape, selector: FaceSelector): BrepHandle {\n const solid = brepOf(on) as BrepHandle | undefined\n if (!solid) {\n throw new TopoRefError('E_TOPO_MESH_UNSUPPORTED', 'face', 'sketchOnFace: target `on` has no BREP solid')\n }\n if (typeof selector === 'number') {\n const faces = kernel.getSubShapes(solid, 'face')\n if (!Number.isInteger(selector) || selector < 1 || selector > faces.length) {\n throw new TopoRefError(\n 'E_TOPO_NOT_FOUND',\n 'face',\n `sketchOnFace: face ordinal ${selector} out of range [1, ${faces.length}]`,\n )\n }\n return faces[selector - 1] as BrepHandle\n }\n if (selector.kind !== 'face') {\n throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', 'sketchOnFace: selector must be a face ordinal or a face ref')\n }\n const ctx = buildEdgeResolutionContext(kernel, on as object)\n if (!ctx) throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', 'sketchOnFace: input has no naming context')\n const resolved = resolveTopoRef(selector, ctx)\n if (resolved.handle === undefined) {\n throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', 'sketchOnFace: face ref resolved to no live handle')\n }\n return resolved.handle as BrepHandle\n}\n\n/**\n * Make the placed face inherit the host face's outward orientation: surface\n * normals must point the same way, otherwise the resulting face — and any prism\n * extruded from it — carries a reversed shell whose OCCT volume collapses to ~0.\n * @param kernel - the BREP engine surface.\n * @param host - the host face handle (its normal is the reference).\n * @param face - the face built on the host surface.\n * @returns a handle to the (possibly re-oriented) face.\n */\nfunction orientLikeHost(kernel: BrepEngineApi, host: BrepHandle, face: BrepHandle): BrepHandle {\n const a = kernel.surfaceNormal(host, 0, 0)\n const b = kernel.surfaceNormal(face, 0, 0)\n const dot = a.x * b.x + a.y * b.y + a.z * b.z\n return dot < 0 ? kernel.reverseShape(face) : face\n}\n\n/** Build one face (outer + optional holes) on the host face for an organised contour entry. */\nfunction buildOnFace(kernel: BrepEngineApi, host: BrepHandle, mode: FaceScaleMode, entry: Blueprint | CompoundBlueprint): BrepHandle {\n if (entry instanceof CompoundBlueprint) {\n let face = orientLikeHost(kernel, host, kernel.makeFace(assembleWireOnFace(kernel, host, mode, entry.blueprints[0]!).wire))\n const holes = entry.blueprints.slice(1).map((h) => assembleWireOnFace(kernel, host, mode, h).wire as never)\n if (holes.length > 0) face = kernel.addHolesInFace(face, holes)\n return face\n }\n return orientLikeHost(kernel, host, kernel.makeFace(assembleWireOnFace(kernel, host, mode, entry).wire))\n}\n\n/**\n * Place `contours` onto the UV space of the host face and return one BREP face\n * per classified contour (each outer + holes folded into a single face). Shared\n * by `cad.sketchOnFace` (wrap as a Shape) and `cad.punchHole` (extrude → cut).\n * @param kernel - the BREP engine surface.\n * @param host - the resolved live host face handle.\n * @param mode - the face-scale (UV mapping) mode.\n * @param contours - ordered 2D closed contour loops to place.\n * @returns the BREP faces built on the host face (one per organised entry).\n */\nexport function placeContoursOnFace(\n kernel: BrepEngineApi,\n host: BrepHandle,\n mode: FaceScaleMode,\n contours: ProfileLoop[],\n): BrepHandle[] {\n const blueprints = contours.map(\n (loop) => new Blueprint(loop.segments.map((s) => profileSegToCurve(s as ProfileSegLike))),\n )\n const organised = organiseBlueprints(blueprints)\n return organised.blueprints.map((entry) => buildOnFace(kernel, host, mode, entry))\n}\n\n/**\n * Build a 3D Shape from closed contours placed on the host face.\n * @param kernel - the BREP engine surface.\n * @param params - contour loops + target solid + face + scale mode.\n * @returns Shape on the target face (face, or the outer wire when `as:'wire'`).\n */\nexport function buildSketchOnFaceWith(kernel: BrepEngineApi, params: SketchOnFaceParams): Shape {\n const host = resolveFaceHandle(kernel, params.on, params.face)\n const mode = params.scaleMode ?? 'original'\n const blueprints = params.contours.map(\n (loop) => new Blueprint(loop.segments.map((s) => profileSegToCurve(s as ProfileSegLike))),\n )\n const organised = organiseBlueprints(blueprints)\n\n if (params.as === 'wire') {\n const outer =\n organised.blueprints[0] instanceof CompoundBlueprint\n ? organised.blueprints[0].blueprints[0]!\n : (organised.blueprints[0] as Blueprint)\n const { wire } = assembleWireOnFace(kernel, host, mode, outer)\n return fromBrepCurve(solidToShape(kernel, wire), { solid: wire })\n }\n\n const faces = placeContoursOnFace(kernel, host, mode, params.contours)\n if (faces.length === 0) throw new Error('sketchOnFace: no contours to place')\n if (faces.length === 1) {\n const f = faces[0]!\n return fromBrep(solidToShape(kernel, f), { solid: f })\n }\n const compound = kernel.makeCompound(faces)\n return fromBrep(solidToShape(kernel, compound), { solid: compound })\n}\n\n/**\n * `cad.sketchOnFace`: place 2D contours on a face of a solid and construct a Shape.\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name sketchOnFace\n * @returns Shape on the target face (face, or a wire curve when `as:'wire'`).\n * @param params.contours - ordered 2D closed contours (same shape as `cad.profile`).type:any[] required:true\n * @param params.on - the target solid on which the face lives.type:Shape required:true\n * @param params.face - the host face: a 1-based ordinal or a `cad.faceRef(on, n)` result.type:any required:true\n * @param params.scaleMode - UV mapping: 'original' (identity) | 'bounds'/'native' (affine-fit).type:string required:false\n * @param params.as - `'face'` (default) or `'wire'` (outer loop only).type:string required:false\n */\nexport const sketchOnFace = defineOp({\n capabilities: ['directEdit'],\n engines: ['occt'],\n brep(params: Record<string, unknown>) {\n assertProfileParams(params)\n return buildSketchOnFaceWith(getBrepApi(), params as unknown as SketchOnFaceParams)\n },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [] } } as Provenance,\n})"]}
|
|
1
|
+
{"version":3,"file":"sketch-on-face.js","sourceRoot":"","sources":["../../src/api/sketch-on-face.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,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,UAAU,CAAC,MAAM,sBAAsB;YAClG,oGAAoG;YACpG,2EAA2E,EAC3E,cAAc,EAAE,CACjB,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,CAAA;IAC/E,OAAO,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACvC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;IACnC,YAAY,EAAE,CAAC,YAAY,CAAC;IAC5B,OAAO,EAAE,CAAC,MAAM,CAAC;IACjB,WAAW,EAAE,CAAC,SAAS,CAAC;IACxB,IAAI,CAAC,MAA+B;QAClC,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAC3B,OAAO,qBAAqB,CAAC,MAAuC,CAAC,CAAA;IACvE,CAAC;IACD,IAAI,CAAC,MAA+B;QAClC,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAC3B,OAAO,qBAAqB,CAAC,UAAU,EAAE,EAAE,MAAuC,CAAC,CAAA;IACrF,CAAC;IACD,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,EAAgB;CACtF,CAAC,CAAA","sourcesContent":["/**\n * `cad.sketchOnFace`: place 2D contours onto the UV parameter space of an\n * existing face (E3 placement).\n *\n * Unlike `sketchOnPlane` (which lifts a contour onto a whole plane *frame*),\n * `sketchOnFace` lays the contour on the surface of a specific face of a target\n * solid. Every 2D curve is sampled, the samples mapped into the face's `(u,v)`\n * domain under a scale mode (`original` / `bounds` / `native`), the surface\n * evaluated at those UVs, and a curve edge interpolated through the resulting\n * 3D points (see `geometry2d/bridge/on-surface.ts`). The placed wire then\n * becomes a face (`as:'face'`) ready to be extruded along the face normal, or\n * is returned raw (`as:'wire'`).\n *\n * v1 scope: the on-surface primitive is surface-type-independent, but the result\n * face is built with `makeFace` on the interpolated wire, so it is exact for\n * planar faces; embedding the wire into a genuinely curved host face\n * (`fixWireOnFace`) is a follow-up. The op declares `engines: ['occt']`\n * (surface sampling needs the BREP platform).\n *\n * **Two chains, two mechanisms** (plan 2026-10-01 §4 Phase 3). The BREP branch\n * above maps the contour into the host face's UV domain. The **mesh branch**\n * (`buildSketchOnFaceMesh`, `meshEngines: ['brepkit']`) works on a mesh solid's\n * approximate topology and deliberately does NOT use UV space: a brepkit plane's\n * domain is ±1e6 (an infinite domain), so \"place the sketch in the face's UV\n * range\" is meaningless there. It places the contour in the face's own plane\n * frame instead (origin = face bbox centre, normal = `surfaceNormal`), which\n * matches `cad.sketchOnPlane`'s semantics. The result is a **mesh-chain face**\n * (`ShapeSlot.meshFace`), ready for the mesh branch of `cad.extrude`.\n * @module\n */\nimport type { Shape } from '../mesh/types'\nimport type { BrepEngineApi } from '../brep/engine/primitives'\nimport type { BrepHandle } from '../brep/engine/types'\nimport { getBrepApi } from '../brep/handle-bridge'\nimport { solidToShape } from '../brep/brep-ops'\nimport { fromBrep, fromBrepCurve, brepOf } from '../shape'\nimport { defineOp } from '../sdk'\nimport type { Provenance } from '../topology/naming/lineage'\nimport { TopoRefError, resolveTopoRef, type FaceTopoRef } from '../topology/naming'\nimport { buildEdgeResolutionContext } from './topo-resolve'\nimport { Blueprint } from '../geometry2d/blueprint'\nimport { CompoundBlueprint } from '../geometry2d/compound-blueprint'\nimport { organiseBlueprints } from '../geometry2d/organise'\nimport { assembleWireOnFace, type FaceScaleMode } from '../geometry2d/bridge/on-surface'\nimport { assembleWire, type Plane, type Vec3 } from '../geometry2d/bridge/lift-on-plane'\nimport { profileSegToCurve, type ProfileSegLike } from '../geometry2d/adapt'\nimport { assertProfileParams, toContourBlueprints, type ProfileLoop } from './profile'\nimport { MeshUnsupportedError, getCurrentStmt } from '../runtime-state'\nimport {\n meshBackendOrThrow,\n meshFacePlane,\n meshFaceProduct,\n resolveMeshFaceHandle,\n} from './internal/mesh-solid-op'\n\n/** A face selector on a target solid: a 1-based ordinal (FreeCAD `FaceN`) or a `cad.faceRef` result. */\nexport type FaceSelector = number | FaceTopoRef\n\n/** Contour loops + the target face for `cad.sketchOnFace`. */\nexport interface SketchOnFaceParams {\n /** Ordered 2D closed contours (same shape as `cad.profile` / `cad.sketchOnPlane`). */\n contours: ProfileLoop[]\n /** The target solid on which the host face lives. */\n on: Shape\n /** The host face: a 1-based face ordinal, or a `cad.faceRef(on, n)` result. */\n face: FaceSelector\n /** How 2D coords map onto the face UV space: `'original'` (identity) | `'bounds'`/`'native'` (affine-fit). */\n scaleMode?: FaceScaleMode\n /** Result shape: `'face'` (default) builds a face on the contour; `'wire'` returns the outer-loop wire only. */\n as?: 'face' | 'wire'\n}\n\n/**\n * Resolve a face on `on` to its live BREP handle (1-based ordinal or `cad.faceRef`).\n * @param kernel - the BREP engine surface.\n * @param on - the target solid shape.\n * @param selector - the face ordinal or `cad.faceRef` result.\n * @returns the live face handle.\n */\nexport function resolveFaceHandle(kernel: BrepEngineApi, on: Shape, selector: FaceSelector): BrepHandle {\n const solid = brepOf(on) as BrepHandle | undefined\n if (!solid) {\n throw new TopoRefError('E_TOPO_MESH_UNSUPPORTED', 'face', 'sketchOnFace: target `on` has no BREP solid')\n }\n if (typeof selector === 'number') {\n const faces = kernel.getSubShapes(solid, 'face')\n if (!Number.isInteger(selector) || selector < 1 || selector > faces.length) {\n throw new TopoRefError(\n 'E_TOPO_NOT_FOUND',\n 'face',\n `sketchOnFace: face ordinal ${selector} out of range [1, ${faces.length}]`,\n )\n }\n return faces[selector - 1] as BrepHandle\n }\n if (selector.kind !== 'face') {\n throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', 'sketchOnFace: selector must be a face ordinal or a face ref')\n }\n const ctx = buildEdgeResolutionContext(kernel, on as object)\n if (!ctx) throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', 'sketchOnFace: input has no naming context')\n const resolved = resolveTopoRef(selector, ctx)\n if (resolved.handle === undefined) {\n throw new TopoRefError('E_TOPO_NOT_FOUND', 'face', 'sketchOnFace: face ref resolved to no live handle')\n }\n return resolved.handle as BrepHandle\n}\n\n/**\n * Make the placed face inherit the host face's outward orientation: surface\n * normals must point the same way, otherwise the resulting face — and any prism\n * extruded from it — carries a reversed shell whose OCCT volume collapses to ~0.\n * @param kernel - the BREP engine surface.\n * @param host - the host face handle (its normal is the reference).\n * @param face - the face built on the host surface.\n * @returns a handle to the (possibly re-oriented) face.\n */\nfunction orientLikeHost(kernel: BrepEngineApi, host: BrepHandle, face: BrepHandle): BrepHandle {\n const a = kernel.surfaceNormal(host, 0, 0)\n const b = kernel.surfaceNormal(face, 0, 0)\n const dot = a.x * b.x + a.y * b.y + a.z * b.z\n return dot < 0 ? kernel.reverseShape(face) : face\n}\n\n/** Build one face (outer + optional holes) on the host face for an organised contour entry. */\nfunction buildOnFace(kernel: BrepEngineApi, host: BrepHandle, mode: FaceScaleMode, entry: Blueprint | CompoundBlueprint): BrepHandle {\n if (entry instanceof CompoundBlueprint) {\n let face = orientLikeHost(kernel, host, kernel.makeFace(assembleWireOnFace(kernel, host, mode, entry.blueprints[0]!).wire))\n const holes = entry.blueprints.slice(1).map((h) => assembleWireOnFace(kernel, host, mode, h).wire as never)\n if (holes.length > 0) face = kernel.addHolesInFace(face, holes)\n return face\n }\n return orientLikeHost(kernel, host, kernel.makeFace(assembleWireOnFace(kernel, host, mode, entry).wire))\n}\n\n/**\n * Place `contours` onto the UV space of the host face and return one BREP face\n * per classified contour (each outer + holes folded into a single face). Shared\n * by `cad.sketchOnFace` (wrap as a Shape) and `cad.punchHole` (extrude → cut).\n * @param kernel - the BREP engine surface.\n * @param host - the resolved live host face handle.\n * @param mode - the face-scale (UV mapping) mode.\n * @param contours - ordered 2D closed contour loops to place.\n * @returns the BREP faces built on the host face (one per organised entry).\n */\nexport function placeContoursOnFace(\n kernel: BrepEngineApi,\n host: BrepHandle,\n mode: FaceScaleMode,\n contours: ProfileLoop[],\n): BrepHandle[] {\n const blueprints = contours.map(\n (loop) => new Blueprint(loop.segments.map((s) => profileSegToCurve(s as ProfileSegLike))),\n )\n const organised = organiseBlueprints(blueprints)\n return organised.blueprints.map((entry) => buildOnFace(kernel, host, mode, entry))\n}\n\n/**\n * Build a 3D Shape from closed contours placed on the host face.\n * @param kernel - the BREP engine surface.\n * @param params - contour loops + target solid + face + scale mode.\n * @returns Shape on the target face (face, or the outer wire when `as:'wire'`).\n */\nexport function buildSketchOnFaceWith(kernel: BrepEngineApi, params: SketchOnFaceParams): Shape {\n const host = resolveFaceHandle(kernel, params.on, params.face)\n const mode = params.scaleMode ?? 'original'\n const blueprints = params.contours.map(\n (loop) => new Blueprint(loop.segments.map((s) => profileSegToCurve(s as ProfileSegLike))),\n )\n const organised = organiseBlueprints(blueprints)\n\n if (params.as === 'wire') {\n const outer =\n organised.blueprints[0] instanceof CompoundBlueprint\n ? organised.blueprints[0].blueprints[0]!\n : (organised.blueprints[0] as Blueprint)\n const { wire } = assembleWireOnFace(kernel, host, mode, outer)\n return fromBrepCurve(solidToShape(kernel, wire), { solid: wire })\n }\n\n const faces = placeContoursOnFace(kernel, host, mode, params.contours)\n if (faces.length === 0) throw new Error('sketchOnFace: no contours to place')\n if (faces.length === 1) {\n const f = faces[0]!\n return fromBrep(solidToShape(kernel, f), { solid: f })\n }\n const compound = kernel.makeCompound(faces)\n return fromBrep(solidToShape(kernel, compound), { solid: compound })\n}\n\n/**\n * 把一张平面的法向对齐到参考方向(外部朝向)。网格链上的复制版:BREP 侧的\n * `orientLikeHost` 存在的原因是\"面朝向反了 → 由它拉出的棱柱壳反向 → 体积归零\",\n * 这里同一个道理,只是参考法向来自**平面本身**(`meshFacePlane` 的法向就是从宿主面\n * 的 `surfaceNormal` 取的),不必再回读宿主句柄。\n *\n * @param kernel - the mesh backend's L1 kernel.\n * @param reference - the outward normal the placed face must agree with.\n * @param face - the face built on the plane.\n * @returns a handle to the (possibly re-oriented) face.\n */\nfunction orientFaceTo(kernel: BrepEngineApi, reference: Vec3, face: BrepHandle): BrepHandle {\n const uv = kernel.uvBounds(face)\n const n = kernel.surfaceNormal(face, (uv.uMin + uv.uMax) / 2, (uv.vMin + uv.vMax) / 2)\n const dot = reference.x * n.x + reference.y * n.y + reference.z * n.z\n return dot < 0 ? kernel.reverseShape(face) : face\n}\n\n/** 一个已归类的轮廓条目(外环 + 可选孔)在平面坐标系里造一张面。 */\nfunction buildFaceOnPlane(\n kernel: BrepEngineApi,\n plane: Plane,\n outward: Vec3,\n entry: Blueprint | CompoundBlueprint,\n): BrepHandle {\n const outerBp = entry instanceof CompoundBlueprint ? entry.blueprints[0]! : entry\n let face = orientFaceTo(kernel, outward, kernel.makeFace(assembleWire(kernel, plane, outerBp)))\n if (entry instanceof CompoundBlueprint) {\n const holes = entry.blueprints.slice(1).map((h) => assembleWire(kernel, plane, h) as never)\n if (holes.length > 0) face = kernel.addHolesInFace(face, holes)\n }\n return face\n}\n\n/**\n * 网格链上的 `cad.sketchOnFace`:在**识别出的平面网格面**上铺 2D 轮廓,产出网格链面\n * (方案 2026-10-01 §4 Phase 3-2),可交给 `cad.extrude` 的网格路径拉伸出新实体。\n *\n * 与 BREP 侧的三点差别,每一点都是\"近似拓扑没有 UV 语义\"的直接后果:\n *\n * 1. **不走 UV 域**。BREP 侧 `assembleWireOnFace` 把 2D 采样点映射进面的 `(u,v)` 域;\n * 而平面在 brepkit 上的域是 ±1e6 的**无限域**(方案 §4 Phase 3-1 实测),拿它当\n * 草图范围毫无意义。这里改用面自己的平面框(原点 = 面包围盒中心、法向 = 面法向),\n * 2D 坐标直接落在平面坐标系里——与 `cad.sketchOnPlane` 的语义一致。\n * 2. **`scaleMode` 只接受 `'original'`**。`'bounds'` / `'native'` 的定义是\"拟合到面的\n * UV 域\",而那个域在这里要么是无限域、要么不存在。静默按 `'original'` 处理会造成\n * \"同一次调用在两条链上得到不同尺寸\"的隐性分歧,所以如实拒绝。\n * 3. **`as:'wire'` 不支持**。网格链上的一根 wire 没有身份槽(面才有),而 sketch 的\n * 下游用途(拉伸)要的正是面。需要 wire 的场景请走 BREP 链。\n *\n * 另外只支持**平面面**:曲面面(STL 圆柱的侧面片)上铺草图需要曲面嵌入,属未开的能力。\n *\n * @param params - contour loops + target mesh solid + face selector + scale mode.\n * @returns the mesh-chain face Shape on the target face.\n * @throws {MeshUnsupportedError} when the target is not a mesh solid, the face is not planar,\n * the scale mode is not `'original'`, `as:'wire'` was requested, or the sketch is multi-island.\n */\nexport function buildSketchOnFaceMesh(params: SketchOnFaceParams): Shape {\n const opLabel = 'sketchOnFace'\n const backend = meshBackendOrThrow(opLabel)\n const kernel = backend.kernel\n\n const mode = params.scaleMode ?? 'original'\n if (mode !== 'original') {\n throw new MeshUnsupportedError(\n `E_MESH_SOLID_UNSUPPORTED: ${opLabel} scaleMode '${mode}' is defined against the face's UV domain, ` +\n 'which a mesh-chain face does not have — use the default \\'original\\' (2D coords live in the face plane)',\n getCurrentStmt(),\n )\n }\n if (params.as === 'wire') {\n throw new MeshUnsupportedError(\n `E_MESH_SOLID_UNSUPPORTED: ${opLabel} as:'wire' has no mesh-chain representation — ` +\n 'a mesh-chain wire has no identity slot; ask for the default as:\\'face\\' instead',\n getCurrentStmt(),\n )\n }\n\n const host = resolveMeshFaceHandle(kernel, params.on, params.face, opLabel)\n const surface = kernel.surfaceType(host)\n if (surface !== 'plane') {\n throw new MeshUnsupportedError(\n `E_MESH_SOLID_UNSUPPORTED: ${opLabel} needs a planar mesh face to sketch on — this face reports ` +\n `surfaceType '${surface}'. Sketches on curved approximate faces are not implemented ` +\n '(an STL cylinder is 32 planar strips, each of which IS usable)',\n getCurrentStmt(),\n )\n }\n\n const plane = meshFacePlane(kernel, host)\n const outward: Vec3 = { x: plane.zDir.x, y: plane.zDir.y, z: plane.zDir.z }\n\n const organised = organiseBlueprints(toContourBlueprints(params.contours))\n if (organised.blueprints.length === 0) throw new Error('sketchOnFace: no contours to place')\n if (organised.blueprints.length > 1) {\n throw new MeshUnsupportedError(\n `E_MESH_SOLID_UNSUPPORTED: ${opLabel} produced ${organised.blueprints.length} disjoint islands — ` +\n 'the mesh backend can only extrude a single face (brepkit extrude takes one face, not a compound). ' +\n 'Sketch and extrude each island separately, then unite them with a boolean',\n getCurrentStmt(),\n )\n }\n\n const face = buildFaceOnPlane(kernel, plane, outward, organised.blueprints[0]!)\n return meshFaceProduct(backend, face)\n}\n\n/**\n * `cad.sketchOnFace`: place 2D contours on a face of a solid and construct a Shape.\n *\n * **网格链**(`meshEngines: ['brepkit']`,方案 2026-10-01 §4 Phase 3):`on` 是网格实体\n * 时,轮廓按面自己的**平面框**铺放(原点 = 面包围盒中心、法向 = 面法向),产物是一张\n * 网格链面,可直接交给 `cad.extrude` 拉伸。该分支只接受平面面、只接受默认\n * `scaleMode`(`'bounds'`/`'native'` 相对 UV 域定义,网格链上没有 UV 域)、只接受\n * `as:'face'`、且只接受单个轮廓岛——每一条越界都以 `E_MESH_SOLID_UNSUPPORTED` 说明原因。\n *\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name sketchOnFace\n * @returns Shape on the target face (face, or a wire curve when `as:'wire'`).\n * @param params.contours - ordered 2D closed contours (same shape as `cad.profile`).type:any[] required:true\n * @param params.on - the target solid on which the face lives.type:Shape required:true\n * @param params.face - the host face: a 1-based ordinal or a `cad.faceRef(on, n)` result.type:any required:true\n * @param params.scaleMode - UV mapping: 'original' (identity) | 'bounds'/'native' (affine-fit).type:string required:false\n * @param params.as - `'face'` (default) or `'wire'` (outer loop only).type:string required:false\n */\nexport const sketchOnFace = defineOp({\n capabilities: ['directEdit'],\n engines: ['occt'],\n meshEngines: ['brepkit'],\n mesh(params: Record<string, unknown>) {\n assertProfileParams(params)\n return buildSketchOnFaceMesh(params as unknown as SketchOnFaceParams)\n },\n brep(params: Record<string, unknown>) {\n assertProfileParams(params)\n return buildSketchOnFaceWith(getBrepApi(), params as unknown as SketchOnFaceParams)\n },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [] } } as Provenance,\n})"]}
|
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
* profile source (profile / draw / sketch) that describes contours as
|
|
6
6
|
* `ProfileLoop`s can be placed here, then extruded along the plane normal. The
|
|
7
7
|
* plane is a named plane (`'XY'` / `'XZ'` / `'top'` …) or an explicit frame
|
|
8
|
-
* `{ origin, normal, xAxis }`. The plane lift runs on the
|
|
9
|
-
*
|
|
8
|
+
* `{ origin, normal, xAxis }`. The plane lift runs on the geometry2d bridge,
|
|
9
|
+
* which builds exact analytic edges on BOTH engines: full circles via
|
|
10
|
+
* `makeCircleEdge`, arcs via `makeArcEdge` (brepkit's circumcircle defect fixed
|
|
11
|
+
* 2026-09-30). The op therefore carries no engine gate.
|
|
10
12
|
* @module
|
|
11
13
|
*/
|
|
12
14
|
import type { Shape } from '../mesh/types.js';
|
|
13
15
|
import type { BrepEngineApi } from '../brep/engine/primitives.js';
|
|
14
16
|
import { Blueprint } from '../geometry2d/blueprint.js';
|
|
15
17
|
import { type Plane, type Vec3Input } from '../geometry2d/bridge/plane.js';
|
|
16
|
-
import { type ProfileLoop } from './profile.js';
|
|
18
|
+
import { type DrawnContours, type ProfileLoop } from './profile.js';
|
|
17
19
|
/** A plane given by a named plane and/or an explicit frame (coords accept both array and `{x,y,z}`). */
|
|
18
20
|
export interface PlaneSpec {
|
|
19
21
|
/** Named plane (`'XY'` / `'XZ'` / `'YZ'` / `'front'` / `'back'` / `'left'` / …). */
|
|
@@ -27,7 +29,12 @@ export interface PlaneSpec {
|
|
|
27
29
|
}
|
|
28
30
|
/** Contour loops + a target plane (+ the result mode) for `cad.sketchOnPlane`. */
|
|
29
31
|
export interface SketchOnPlaneParams {
|
|
30
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Contour source: segment loops (`{segments: […]}`) or already-drawn contours
|
|
34
|
+
* (a `Blueprint`, or an array of them). The drawn form is what makes the
|
|
35
|
+
* "draw → place → extrude" pipeline real — see {@link DrawnContours}.
|
|
36
|
+
*/
|
|
37
|
+
contours: ProfileLoop[] | DrawnContours;
|
|
31
38
|
/** Named plane or explicit `{ origin, normal, xAxis }` frame. */
|
|
32
39
|
plane: PlaneSpec;
|
|
33
40
|
/** Result shape: 'face' (default) builds a planar face; 'wire' returns the outer-loop wire only. */
|
|
@@ -44,7 +51,7 @@ export declare function resolvePlane(planeSpec: PlaneSpec, fallbackOrigin?: Vec3
|
|
|
44
51
|
/**
|
|
45
52
|
* Build a 3D Shape (planar face, or outer-loop wire when `as:'wire'`) from a set
|
|
46
53
|
* of classified `Blueprint` contours on a plane. This is the shared placement
|
|
47
|
-
* core for every 2D profile source (`cad.profile` /
|
|
54
|
+
* core for every 2D profile source (`cad.profile` / a drawn contour / sketch): it
|
|
48
55
|
* organises the closed contours (holes vs islands), assembles edge wires on the
|
|
49
56
|
* plane via the geometry2d bridge, and wraps them as a BREP face — ready to be
|
|
50
57
|
* extruded along the plane normal.
|
|
@@ -56,10 +63,11 @@ export declare function resolvePlane(planeSpec: PlaneSpec, fallbackOrigin?: Vec3
|
|
|
56
63
|
*/
|
|
57
64
|
export declare function buildShapeFromBlueprints(kernel: BrepEngineApi, plane: Plane, blueprints: Blueprint[], as?: 'face' | 'wire'): Shape;
|
|
58
65
|
/**
|
|
59
|
-
* Build the 2D→3D placement:
|
|
60
|
-
* set, assemble a wire on the plane,
|
|
66
|
+
* Build the 2D→3D placement: normalize the contour source (segment loops or a
|
|
67
|
+
* drawn contour) to a classified Blueprint set, assemble a wire on the plane,
|
|
68
|
+
* then wrap as a face (or the outer wire).
|
|
61
69
|
* @param kernel - the BREP engine surface.
|
|
62
|
-
* @param params - contour
|
|
70
|
+
* @param params - contour source + plane + mode.
|
|
63
71
|
* @returns Shape on the target plane (face, or a wire curve when `as:'wire'`).
|
|
64
72
|
*/
|
|
65
73
|
export declare function buildSketchOnPlaneWith(kernel: BrepEngineApi, params: SketchOnPlaneParams): Shape;
|
|
@@ -71,7 +79,7 @@ export declare function buildSketchOnPlaneWith(kernel: BrepEngineApi, params: Sk
|
|
|
71
79
|
* @qual ok
|
|
72
80
|
* @name sketchOnPlane
|
|
73
81
|
* @returns Shape on the target plane (face, or a wire curve when `as:'wire'`).
|
|
74
|
-
* @param params.contours - ordered 2D contours (same shape as `cad.profile`).type:any
|
|
82
|
+
* @param params.contours - ordered 2D contours (same shape as `cad.profile`: segment loops, or a drawn `Blueprint`).type:any required:true
|
|
75
83
|
* @param params.plane - named plane (`'XY'` / `'XZ'`…) or `{ origin, normal, xAxis }`.type:any required:true
|
|
76
84
|
* @param params.as - `'face'` (default) or `'wire'` (outer loop only).type:string required:false
|
|
77
85
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sketch-on-plane.d.ts","sourceRoot":"","sources":["../../src/api/sketch-on-plane.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sketch-on-plane.d.ts","sourceRoot":"","sources":["../../src/api/sketch-on-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAM9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnD,OAAO,EAAiC,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAEtG,OAAO,EAA4C,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AAE1G,wGAAwG;AACxG,MAAM,WAAW,SAAS;IACxB,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,wEAAwE;IACxE,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,yEAAyE;IACzE,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,gFAAgF;IAChF,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED,kFAAkF;AAClF,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,EAAE,WAAW,EAAE,GAAG,aAAa,CAAA;IACvC,iEAAiE;IACjE,KAAK,EAAE,SAAS,CAAA;IAChB,oGAAoG;IACpG,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,cAAc,GAAE,SAAqB,GAAG,KAAK,CAK/F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,SAAS,EAAE,EACvB,EAAE,GAAE,MAAM,GAAG,MAAe,GAC3B,KAAK,CAgCP;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,GAAG,KAAK,CAQhG;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa;;CAQxB,CAAA"}
|
|
@@ -2,13 +2,11 @@ import { getBrepApi } from '../brep/handle-bridge.js';
|
|
|
2
2
|
import { solidToShape } from '../brep/brep-ops.js';
|
|
3
3
|
import { fromBrep, fromBrepCurve } from '../shape.js';
|
|
4
4
|
import { defineOp } from '../sdk.js';
|
|
5
|
-
import { Blueprint } from '../geometry2d/blueprint.js';
|
|
6
5
|
import { CompoundBlueprint } from '../geometry2d/compound-blueprint.js';
|
|
7
6
|
import { organiseBlueprints } from '../geometry2d/organise.js';
|
|
8
7
|
import { namedPlane, makePlane, toVec3 } from '../geometry2d/bridge/plane.js';
|
|
9
8
|
import { assembleWire } from '../geometry2d/bridge/lift-on-plane.js';
|
|
10
|
-
import {
|
|
11
|
-
import { assertProfileParams } from './profile.js';
|
|
9
|
+
import { assertProfileParams, toContourBlueprints } from './profile.js';
|
|
12
10
|
/**
|
|
13
11
|
* Resolve a `PlaneSpec` to a plane frame. A named plane wins over an explicit
|
|
14
12
|
* frame; with neither, the XY plane is used.
|
|
@@ -27,7 +25,7 @@ export function resolvePlane(planeSpec, fallbackOrigin = [0, 0, 0]) {
|
|
|
27
25
|
/**
|
|
28
26
|
* Build a 3D Shape (planar face, or outer-loop wire when `as:'wire'`) from a set
|
|
29
27
|
* of classified `Blueprint` contours on a plane. This is the shared placement
|
|
30
|
-
* core for every 2D profile source (`cad.profile` /
|
|
28
|
+
* core for every 2D profile source (`cad.profile` / a drawn contour / sketch): it
|
|
31
29
|
* organises the closed contours (holes vs islands), assembles edge wires on the
|
|
32
30
|
* plane via the geometry2d bridge, and wraps them as a BREP face — ready to be
|
|
33
31
|
* extruded along the plane normal.
|
|
@@ -68,15 +66,20 @@ export function buildShapeFromBlueprints(kernel, plane, blueprints, as = 'face')
|
|
|
68
66
|
return fromBrep(solidToShape(kernel, compound), { solid: compound });
|
|
69
67
|
}
|
|
70
68
|
/**
|
|
71
|
-
* Build the 2D→3D placement:
|
|
72
|
-
* set, assemble a wire on the plane,
|
|
69
|
+
* Build the 2D→3D placement: normalize the contour source (segment loops or a
|
|
70
|
+
* drawn contour) to a classified Blueprint set, assemble a wire on the plane,
|
|
71
|
+
* then wrap as a face (or the outer wire).
|
|
73
72
|
* @param kernel - the BREP engine surface.
|
|
74
|
-
* @param params - contour
|
|
73
|
+
* @param params - contour source + plane + mode.
|
|
75
74
|
* @returns Shape on the target plane (face, or a wire curve when `as:'wire'`).
|
|
76
75
|
*/
|
|
77
76
|
export function buildSketchOnPlaneWith(kernel, params) {
|
|
78
77
|
const plane = resolvePlane(params.plane);
|
|
79
|
-
|
|
78
|
+
// 2026-09-28:段环数据与「已绘制轮廓」(`Blueprint`)在此归一。少了这一步,
|
|
79
|
+
// 「draw → sketchOnPlane → extrude」就断了 —— 已绘制轮廓没有 OCCT 句柄,
|
|
80
|
+
// 实测喂 `cad.extrude` 报 `argument carries no BREP handle`、喂 `cad.sweep`
|
|
81
|
+
// 报 `INVALID_SHAPE_ID`,全仓没有第二个能把它变成 Shape 的通道。
|
|
82
|
+
const blueprints = toContourBlueprints(params.contours);
|
|
80
83
|
return buildShapeFromBlueprints(kernel, plane, blueprints, params.as ?? 'face');
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
@@ -87,13 +90,12 @@ export function buildSketchOnPlaneWith(kernel, params) {
|
|
|
87
90
|
* @qual ok
|
|
88
91
|
* @name sketchOnPlane
|
|
89
92
|
* @returns Shape on the target plane (face, or a wire curve when `as:'wire'`).
|
|
90
|
-
* @param params.contours - ordered 2D contours (same shape as `cad.profile`).type:any
|
|
93
|
+
* @param params.contours - ordered 2D contours (same shape as `cad.profile`: segment loops, or a drawn `Blueprint`).type:any required:true
|
|
91
94
|
* @param params.plane - named plane (`'XY'` / `'XZ'`…) or `{ origin, normal, xAxis }`.type:any required:true
|
|
92
95
|
* @param params.as - `'face'` (default) or `'wire'` (outer loop only).type:string required:false
|
|
93
96
|
*/
|
|
94
97
|
export const sketchOnPlane = defineOp({
|
|
95
98
|
capabilities: ['directEdit'],
|
|
96
|
-
engines: ['occt'],
|
|
97
99
|
brep(params) {
|
|
98
100
|
assertProfileParams(params);
|
|
99
101
|
return buildSketchOnPlaneWith(getBrepApi(), params);
|