@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blueprint.js","sourceRoot":"","sources":["../../src/geometry2d/blueprint.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACzL,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAe,MAAM,UAAU,CAAA;AAKpG,8EAA8E;AAC9E,6DAA6D;AAC7D,SAAS,SAAS,CAAC,CAAa;IAC9B,MAAM,EAAE,GAAG,YAAY,EAAE,CAAA;IACzB,cAAc,CAAC,EAAW,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;IACpC,OAAO,EAAE,CAAA;AACX,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAU,EAAE,EAA6B;IACjE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAA;AACrF,CAAC;AAED;;;;;;GAM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CAAA;IACd,CAAC;CACF;AAED,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,SAAS,QAAQ,CAAC,CAAa,EAAE,CAAS;IACxC,OAAO,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC9B,CAAC;AAED,SAAS,YAAY,CAAC,CAAa;IACjC,OAAO,eAAe,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AACjD,CAAC;AAED,SAAS,WAAW,CAAC,CAAa;IAChC,OAAO,eAAe,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAChD,CAAC;AAED,SAAS,SAAS,CAAC,CAA4B,EAAE,CAA4B,EAAE,GAAG,GAAG,IAAI;IACvF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;AACnE,CAAC","sourcesContent":["/**\n * Blueprint — ordered 2D profile of `Curve2dObj` segments (pure-data port of\n * brepjs `Blueprint`, Apache-2.0).\n *\n * Key adaptation: brepjs stores kernel-backed `Curve2D` handles that must be\n * disposed; faijs stores plain `Curve2dObj` objects (no handles, no dispose).\n * Kernel-coupling methods (sketchOnPlane / sketchOnFace / subFace / punchHole)\n * intentionally live in `geometry2d/bridge`, not here.\n *\n * @module\n */\nimport type { Curve2dObj } from './curve2d'\nimport { addCurveToBBox, evaluateCurve2d, curveBounds, intersectCurves2dFn, makeLine2d, mirrorAcrossAxis, mirrorAtPoint, rotateCurve2d, scaleCurve2d, translateCurve2d } from './curve2d'\nimport { centerOf, createBBox2d, isBBoxOut, mergeBBox, outsidePointOf, type BBox2d } from './bbox2d'\n\n/** 2D point. */\nexport type Point2 = [number, number]\n\n// `addCurveToBBox` writes xMin/yMin/xMax/yMax — same fields as BBox2d, so the\n// structural subtype is satisfied by passing a plain BBox2d.\nfunction curveBBox(c: Curve2dObj): BBox2d {\n const bb = createBBox2d()\n addCurveToBBox(bb as never, c, 1e-9)\n return bb\n}\n\nfunction containsBoxPoint(bb: BBox2d, pt: readonly [number, number]): boolean {\n return pt[0] >= bb.xMin && pt[0] <= bb.xMax && pt[1] >= bb.yMin && pt[1] <= bb.yMax\n}\n\n/**\n * True when `(x,y)` is within `tol` of curve `c`.\n * @param c - the curve to test against.\n * @param pt - the 2D point to test, `[x, y]`.\n * @param tol - the distance tolerance (default 1e-9).\n * @returns true when the point lies within `tol` of the curve.\n */\nexport function isOnCurve(c: Curve2dObj, pt: readonly [number, number], tol = 1e-9): boolean {\n const bb = curveBBox(c)\n if (!containsBoxPoint(bb, pt)) return false\n const b = curveBounds(c)\n const N = 32\n let best = Infinity\n for (let i = 0; i <= N; i++) {\n const t = b.first + ((b.last - b.first) * i) / N\n const [px, py] = evaluateCurve2d(c, t)\n const d2 = (px - pt[0]) ** 2 + (py - pt[1]) ** 2\n if (d2 < best) best = d2\n }\n return best <= tol * tol\n}\n\n/**\n * A planar 2D profile = an ordered sequence of 2D curves.\n * Shared base for `cad.profile`, `cad.draw` and (solved) `cad.sketch` outputs on\n * their way to `sketchOnPlane`/`sketchOnFace`.\n */\nexport class Blueprint {\n /** Ordered 2D curve segments composing this blueprint. */\n readonly curves: Curve2dObj[]\n\n private _bbox: BBox2d | null = null\n private _orientation: 'clockwise' | 'counterClockwise' | null = null\n private _guessedOrientation: 'clockwise' | 'counterClockwise' | null = null\n\n constructor(curves: Curve2dObj[]) {\n if (curves.length === 0) throw new Error('Blueprint requires at least one curve')\n this.curves = curves\n }\n\n /**\n * Return a shallow copy of this blueprint (new container, same curve objects).\n * @returns a new Blueprint with the same curves.\n */\n clone(): Blueprint {\n return new Blueprint([...this.curves])\n }\n\n /** Bounding box (cached). */\n get boundingBox(): BBox2d {\n if (!this._bbox) {\n const bb = createBBox2d()\n for (const c of this.curves) mergeBBox(bb, curveBBox(c))\n this._bbox = bb\n }\n return this._bbox\n }\n\n /** Winding orientation via shoelace (curve midpoints for non-lines). */\n get orientation(): 'clockwise' | 'counterClockwise' {\n if (this._orientation) return this._orientation\n if (this._guessedOrientation) return this._guessedOrientation\n const vertices: Point2[] = []\n for (const c of this.curves) {\n const b = curveBounds(c)\n vertices.push(firstPointOf(c))\n if (c.kind2d !== 'line') vertices.push(evaluate(c, (b.first + b.last) / 2) as Point2)\n }\n let area = 0\n for (let i = 0; i < vertices.length; i++) {\n const v1 = vertices[i]!\n const v2 = vertices[(i + 1) % vertices.length]!\n area += (v2[0] - v1[0]) * (v2[1] + v1[1])\n }\n this._guessedOrientation = area > 0 ? 'clockwise' : 'counterClockwise'\n return this._guessedOrientation\n }\n\n /**\n * Scale the blueprint about a center point.\n * @param factor - the scale factor to apply.\n * @param center - the scaling center `[x, y]` (defaults to the bounding-box center).\n * @returns a new Blueprint with every curve scaled about the center.\n */\n scale(factor: number, center?: Point2): Blueprint {\n const [cx, cy] = center ?? centerOf(this.boundingBox)\n return new Blueprint(this.curves.map((c) => scaleCurve2d(c, factor, cx, cy)))\n }\n\n /**\n * Translate the whole blueprint by a delta.\n * @param dxOrPoint - the x delta, or a full `[dx, dy]` offset point.\n * @param dy - the y delta (default 0, ignored when `dxOrPoint` is a point).\n * @returns a new Blueprint with every curve translated.\n */\n translate(dxOrPoint: number | Point2, dy?: number): Blueprint {\n const [dx, yy] = typeof dxOrPoint === 'number' ? [dxOrPoint, dy ?? 0] : [dxOrPoint[0], dxOrPoint[1]]\n return new Blueprint(this.curves.map((c) => translateCurve2d(c, dx, yy)))\n }\n\n /**\n * Rotate the whole blueprint about a center point.\n * @param angleDeg - the rotation angle in degrees.\n * @param center - the rotation center `[x, y]` (defaults to the origin).\n * @returns a new Blueprint with every curve rotated.\n */\n rotate(angleDeg: number, center?: Point2): Blueprint {\n const a = (angleDeg * Math.PI) / 180\n const [cx, cy] = center ?? [0, 0]\n return new Blueprint(this.curves.map((c) => rotateCurve2d(c, a, cx, cy)))\n }\n\n /**\n * Mirror the whole blueprint.\n * @param centerOrDirection - the mirror center (mode `center`) or the mirror axis direction.\n * @param origin - the axis origin `[x, y]` when mirroring across a plane (defaults to the origin).\n * @param mode - `center` mirrors about a point; `plane` mirrors across an axis.\n * @returns a new Blueprint with every curve mirrored.\n */\n mirror(centerOrDirection: Point2, origin?: Point2, mode: 'center' | 'plane' = 'center'): Blueprint {\n if (mode === 'plane') {\n const [ox, oy] = origin ?? [0, 0]\n const [dx, dy] = centerOrDirection\n return new Blueprint(this.curves.map((c) => mirrorAcrossAxis(c, ox, oy, dx, dy)))\n }\n const [cx, cy] = centerOrDirection\n return new Blueprint(this.curves.map((c) => mirrorAtPoint(c, cx, cy)))\n }\n\n /**\n * The starting point of the first curve.\n * @returns the 2D point where this blueprint begins.\n */\n get firstPoint(): Point2 {\n return firstPointOf(this.curves[0]!)\n }\n\n /**\n * The ending point of the last curve.\n * @returns the 2D point where this blueprint ends.\n */\n get lastPoint(): Point2 {\n return lastPointOf(this.curves[this.curves.length - 1]!)\n }\n\n /**\n * True when the profile closes back on itself.\n * @returns true when the first and last points coincide.\n */\n isClosed(): boolean {\n const fp = this.firstPoint\n const lp = this.lastPoint\n return Math.abs(fp[0] - lp[0]) < 1e-9 && Math.abs(fp[1] - lp[1]) < 1e-9\n }\n\n /**\n * True when a point is strictly inside (ray-cast); false on the boundary.\n * @param point - the 2D point to test, `[x, y]`.\n * @returns true when the point is strictly inside, false on/outside the boundary.\n */\n isInside(point: readonly [number, number]): boolean {\n const bbox = this.boundingBox\n const p: Point2 = [point[0], point[1]]\n if (!containsBoxPoint(bbox, p)) return false\n if (this.curves.some((c) => isOnCurve(c, p))) return false\n const outside = outsidePointOf(bbox)\n const segment = makeLine2d(p[0], p[1], outside[0], outside[1])\n const seen: Point2[] = []\n let crossCount = 0\n for (const c of this.curves) {\n if (isBBoxOut(curveBBox(segment), curveBBox(c))) continue\n const r = intersectCurves2dFn(segment, c, 1e-9)\n for (const pt of r.points) {\n if (!seen.some((s) => samePoint(s, pt))) {\n seen.push(pt)\n crossCount++\n }\n }\n }\n return crossCount % 2 === 1\n }\n\n /**\n * True when any curve of `this` intersects any curve of `other`.\n * @param other - the blueprint to test for intersections against.\n * @returns true when any pair of curves intersects.\n */\n intersects(other: Blueprint): boolean {\n if (isBBoxOut(this.boundingBox, other.boundingBox)) return false\n for (const a of this.curves) {\n for (const b of other.curves) {\n if (isBBoxOut(curveBBox(a), curveBBox(b))) continue\n const r = intersectCurves2dFn(a, b, 1e-9)\n if (r.points.length || r.segments.length) return true\n }\n }\n return false\n }\n}\n\n// ---------------------------------------------------------------------------\n// Pure helpers\n// ---------------------------------------------------------------------------\n\nfunction evaluate(c: Curve2dObj, t: number): [number, number] {\n return evaluateCurve2d(c, t)\n}\n\nfunction firstPointOf(c: Curve2dObj): Point2 {\n return evaluateCurve2d(c, curveBounds(c).first)\n}\n\nfunction lastPointOf(c: Curve2dObj): Point2 {\n return evaluateCurve2d(c, curveBounds(c).last)\n}\n\nfunction samePoint(a: readonly [number, number], b: readonly [number, number], tol = 1e-9): boolean {\n return Math.abs(a[0] - b[0]) < tol && Math.abs(a[1] - b[1]) < tol\n}"]}
|
|
1
|
+
{"version":3,"file":"blueprint.js","sourceRoot":"","sources":["../../src/geometry2d/blueprint.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACzL,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAe,MAAM,UAAU,CAAA;AAKpG,8EAA8E;AAC9E,6DAA6D;AAC7D,SAAS,SAAS,CAAC,CAAa;IAC9B,MAAM,EAAE,GAAG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brepjs stores kernel-backed `Curve2D` handles that must be\n * disposed; faijs stores plain `Curve2dObj` objects (no handles, no dispose).\n * Kernel-coupling methods (sketchOnPlane / sketchOnFace / subFace / punchHole)\n * intentionally live in `geometry2d/bridge`, not here.\n *\n * @module\n */\nimport type { Curve2dObj } from './curve2d'\nimport { addCurveToBBox, evaluateCurve2d, curveBounds, intersectCurves2dFn, makeLine2d, mirrorAcrossAxis, mirrorAtPoint, rotateCurve2d, scaleCurve2d, translateCurve2d } from './curve2d'\nimport { centerOf, createBBox2d, isBBoxOut, mergeBBox, outsidePointOf, type BBox2d } from './bbox2d'\n\n/** 2D point. */\nexport type Point2 = [number, number]\n\n// `addCurveToBBox` writes xMin/yMin/xMax/yMax — same fields as BBox2d, so the\n// structural subtype is satisfied by passing a plain BBox2d.\nfunction curveBBox(c: Curve2dObj): BBox2d {\n const bb = createBBox2d()\n addCurveToBBox(bb as never, c, 1e-9)\n return bb\n}\n\nfunction containsBoxPoint(bb: BBox2d, pt: readonly [number, number]): boolean {\n return pt[0] >= bb.xMin && pt[0] <= bb.xMax && pt[1] >= bb.yMin && pt[1] <= bb.yMax\n}\n\n/**\n * True when `(x,y)` is within `tol` of curve `c`.\n * @param c - the curve to test against.\n * @param pt - the 2D point to test, `[x, y]`.\n * @param tol - the distance tolerance (default 1e-9).\n * @returns true when the point lies within `tol` of the curve.\n */\nexport function isOnCurve(c: Curve2dObj, pt: readonly [number, number], tol = 1e-9): boolean {\n const bb = curveBBox(c)\n if (!containsBoxPoint(bb, pt)) return false\n const b = curveBounds(c)\n const N = 32\n let best = Infinity\n for (let i = 0; i <= N; i++) {\n const t = b.first + ((b.last - b.first) * i) / N\n const [px, py] = evaluateCurve2d(c, t)\n const d2 = (px - pt[0]) ** 2 + (py - pt[1]) ** 2\n if (d2 < best) best = d2\n }\n return best <= tol * tol\n}\n\n/**\n * A planar 2D profile = an ordered sequence of 2D curves.\n * Shared base for `cad.profile`, drawn contours and (solved) `cad.sketch` outputs\n * on their way to `sketchOnPlane`/`sketchOnFace`.\n */\nexport class Blueprint {\n /** Ordered 2D curve segments composing this blueprint. */\n readonly curves: Curve2dObj[]\n\n private _bbox: BBox2d | null = null\n private _orientation: 'clockwise' | 'counterClockwise' | null = null\n private _guessedOrientation: 'clockwise' | 'counterClockwise' | null = null\n\n constructor(curves: Curve2dObj[]) {\n if (curves.length === 0) throw new Error('Blueprint requires at least one curve')\n this.curves = curves\n }\n\n /**\n * Return a shallow copy of this blueprint (new container, same curve objects).\n * @returns a new Blueprint with the same curves.\n */\n clone(): Blueprint {\n return new Blueprint([...this.curves])\n }\n\n /** Bounding box (cached). */\n get boundingBox(): BBox2d {\n if (!this._bbox) {\n const bb = createBBox2d()\n for (const c of this.curves) mergeBBox(bb, curveBBox(c))\n this._bbox = bb\n }\n return this._bbox\n }\n\n /** Winding orientation via shoelace (curve midpoints for non-lines). */\n get orientation(): 'clockwise' | 'counterClockwise' {\n if (this._orientation) return this._orientation\n if (this._guessedOrientation) return this._guessedOrientation\n const vertices: Point2[] = []\n for (const c of this.curves) {\n const b = curveBounds(c)\n vertices.push(firstPointOf(c))\n if (c.kind2d !== 'line') vertices.push(evaluate(c, (b.first + b.last) / 2) as Point2)\n }\n let area = 0\n for (let i = 0; i < vertices.length; i++) {\n const v1 = vertices[i]!\n const v2 = vertices[(i + 1) % vertices.length]!\n area += (v2[0] - v1[0]) * (v2[1] + v1[1])\n }\n this._guessedOrientation = area > 0 ? 'clockwise' : 'counterClockwise'\n return this._guessedOrientation\n }\n\n /**\n * Scale the blueprint about a center point.\n * @param factor - the scale factor to apply.\n * @param center - the scaling center `[x, y]` (defaults to the bounding-box center).\n * @returns a new Blueprint with every curve scaled about the center.\n */\n scale(factor: number, center?: Point2): Blueprint {\n const [cx, cy] = center ?? centerOf(this.boundingBox)\n return new Blueprint(this.curves.map((c) => scaleCurve2d(c, factor, cx, cy)))\n }\n\n /**\n * Translate the whole blueprint by a delta.\n * @param dxOrPoint - the x delta, or a full `[dx, dy]` offset point.\n * @param dy - the y delta (default 0, ignored when `dxOrPoint` is a point).\n * @returns a new Blueprint with every curve translated.\n */\n translate(dxOrPoint: number | Point2, dy?: number): Blueprint {\n const [dx, yy] = typeof dxOrPoint === 'number' ? [dxOrPoint, dy ?? 0] : [dxOrPoint[0], dxOrPoint[1]]\n return new Blueprint(this.curves.map((c) => translateCurve2d(c, dx, yy)))\n }\n\n /**\n * Rotate the whole blueprint about a center point.\n * @param angleDeg - the rotation angle in degrees.\n * @param center - the rotation center `[x, y]` (defaults to the origin).\n * @returns a new Blueprint with every curve rotated.\n */\n rotate(angleDeg: number, center?: Point2): Blueprint {\n const a = (angleDeg * Math.PI) / 180\n const [cx, cy] = center ?? [0, 0]\n return new Blueprint(this.curves.map((c) => rotateCurve2d(c, a, cx, cy)))\n }\n\n /**\n * Mirror the whole blueprint.\n * @param centerOrDirection - the mirror center (mode `center`) or the mirror axis direction.\n * @param origin - the axis origin `[x, y]` when mirroring across a plane (defaults to the origin).\n * @param mode - `center` mirrors about a point; `plane` mirrors across an axis.\n * @returns a new Blueprint with every curve mirrored.\n */\n mirror(centerOrDirection: Point2, origin?: Point2, mode: 'center' | 'plane' = 'center'): Blueprint {\n if (mode === 'plane') {\n const [ox, oy] = origin ?? [0, 0]\n const [dx, dy] = centerOrDirection\n return new Blueprint(this.curves.map((c) => mirrorAcrossAxis(c, ox, oy, dx, dy)))\n }\n const [cx, cy] = centerOrDirection\n return new Blueprint(this.curves.map((c) => mirrorAtPoint(c, cx, cy)))\n }\n\n /**\n * The starting point of the first curve.\n * @returns the 2D point where this blueprint begins.\n */\n get firstPoint(): Point2 {\n return firstPointOf(this.curves[0]!)\n }\n\n /**\n * The ending point of the last curve.\n * @returns the 2D point where this blueprint ends.\n */\n get lastPoint(): Point2 {\n return lastPointOf(this.curves[this.curves.length - 1]!)\n }\n\n /**\n * True when the profile closes back on itself.\n * @returns true when the first and last points coincide.\n */\n isClosed(): boolean {\n const fp = this.firstPoint\n const lp = this.lastPoint\n return Math.abs(fp[0] - lp[0]) < 1e-9 && Math.abs(fp[1] - lp[1]) < 1e-9\n }\n\n /**\n * True when a point is strictly inside (ray-cast); false on the boundary.\n * @param point - the 2D point to test, `[x, y]`.\n * @returns true when the point is strictly inside, false on/outside the boundary.\n */\n isInside(point: readonly [number, number]): boolean {\n const bbox = this.boundingBox\n const p: Point2 = [point[0], point[1]]\n if (!containsBoxPoint(bbox, p)) return false\n if (this.curves.some((c) => isOnCurve(c, p))) return false\n const outside = outsidePointOf(bbox)\n const segment = makeLine2d(p[0], p[1], outside[0], outside[1])\n const seen: Point2[] = []\n let crossCount = 0\n for (const c of this.curves) {\n if (isBBoxOut(curveBBox(segment), curveBBox(c))) continue\n const r = intersectCurves2dFn(segment, c, 1e-9)\n for (const pt of r.points) {\n if (!seen.some((s) => samePoint(s, pt))) {\n seen.push(pt)\n crossCount++\n }\n }\n }\n return crossCount % 2 === 1\n }\n\n /**\n * True when any curve of `this` intersects any curve of `other`.\n * @param other - the blueprint to test for intersections against.\n * @returns true when any pair of curves intersects.\n */\n intersects(other: Blueprint): boolean {\n if (isBBoxOut(this.boundingBox, other.boundingBox)) return false\n for (const a of this.curves) {\n for (const b of other.curves) {\n if (isBBoxOut(curveBBox(a), curveBBox(b))) continue\n const r = intersectCurves2dFn(a, b, 1e-9)\n if (r.points.length || r.segments.length) return true\n }\n }\n return false\n }\n}\n\n// ---------------------------------------------------------------------------\n// Pure helpers\n// ---------------------------------------------------------------------------\n\nfunction evaluate(c: Curve2dObj, t: number): [number, number] {\n return evaluateCurve2d(c, t)\n}\n\nfunction firstPointOf(c: Curve2dObj): Point2 {\n return evaluateCurve2d(c, curveBounds(c).first)\n}\n\nfunction lastPointOf(c: Curve2dObj): Point2 {\n return evaluateCurve2d(c, curveBounds(c).last)\n}\n\nfunction samePoint(a: readonly [number, number], b: readonly [number, number], tol = 1e-9): boolean {\n return Math.abs(a[0] - b[0]) < tol && Math.abs(a[1] - b[1]) < tol\n}"]}
|
|
@@ -14,14 +14,24 @@ import type { BrepHandle } from '../../brep/engine/types.js';
|
|
|
14
14
|
import type { Curve2dObj } from '../curve2d.js';
|
|
15
15
|
import type { Blueprint } from '../blueprint.js';
|
|
16
16
|
import { type Plane } from './plane.js';
|
|
17
|
-
/** Minimal kernel edge/wire surface needed for planar placement. */
|
|
18
|
-
export type PlaneWireKernel = Pick<BrepEngineApi, 'makeLineEdge' | 'makeArcEdge' | 'makeBezierEdge' | 'makeWire'>;
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
* Minimal kernel edge/wire surface needed for planar placement (plus the
|
|
19
|
+
* NURBS/curve primitives the spline segments need: an exact parametric edge
|
|
20
|
+
* cannot be built or trimmed without them).
|
|
21
|
+
*/
|
|
22
|
+
export type PlaneWireKernel = Pick<BrepEngineApi, 'makeLineEdge' | 'makeArcEdge' | 'makeBezierEdge' | 'makeBSplineEdge' | 'makeCircleEdge' | 'curveSplit' | 'curveParameters' | 'makeWire'>;
|
|
23
|
+
/**
|
|
24
|
+
* Build the 3D edge(s) for a single 2D curve lifted onto a plane. Line, bezier
|
|
25
|
+
* and bspline build exact analytic edges; a full circle becomes one closed
|
|
26
|
+
* kernel circle edge and a trimmed circle a true arc edge from three on-plane
|
|
27
|
+
* lift points; ellipse falls back to a dense sampled polyline (no exact
|
|
28
|
+
* ellipse-edge primitive on the contract yet).
|
|
29
|
+
*
|
|
30
|
+
* GOTCHA (brepkit, 2026-09-30 实证): a closed wire built from exactly TWO
|
|
31
|
+
* half-arcs (`makeArcEdge`) makes brepkit's `makeFaceFromWire` produce a face
|
|
32
|
+
* covering only 1/3 of the disc (measured extrude volume 523.6 vs πr²·5 = 1570.8),
|
|
33
|
+
* while 3- or 4-arc wires and a single closed `makeCircleEdge` are exact. The
|
|
34
|
+
* full-circle case therefore emits one `makeCircleEdge` rather than two arcs.
|
|
25
35
|
* @param kernel - the kernel edge primitives.
|
|
26
36
|
* @param plane - the target plane frame.
|
|
27
37
|
* @param c - the ordered 2D curve to lift.
|
|
@@ -45,6 +55,6 @@ export declare function curvesAsEdgesOnPlane(kernel: PlaneWireKernel, plane: Pla
|
|
|
45
55
|
* @returns the assembled 3D wire.
|
|
46
56
|
*/
|
|
47
57
|
export declare function assembleWire(kernel: PlaneWireKernel, planeOrName: Plane | string, bp: Blueprint): BrepHandle;
|
|
48
|
-
export { liftPointToPlane, namedPlane, makePlane, toVec3 } from './plane.js';
|
|
58
|
+
export { liftPointToPlane, worldToPlane, namedPlane, makePlane, toVec3 } from './plane.js';
|
|
49
59
|
export type { Plane, Vec3, Vec3Input } from './plane.js';
|
|
50
60
|
//# sourceMappingURL=lift-on-plane.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lift-on-plane.d.ts","sourceRoot":"","sources":["../../../src/geometry2d/bridge/lift-on-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"lift-on-plane.d.ts","sourceRoot":"","sources":["../../../src/geometry2d/bridge/lift-on-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,YAAY,CAAA;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAgC,KAAK,KAAK,EAAa,MAAM,SAAS,CAAA;AAE7E;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,aAAa,EACX,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,iBAAiB,GACjB,gBAAgB,GAChB,YAAY,GACZ,iBAAiB,GACjB,UAAU,CACb,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CA0CrG;AA8CD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,EAAE,CAIvH;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,GAAG,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,UAAU,CAG5G;AAED,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACvF,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { evaluateCurve2d } from '../curve2d.js';
|
|
2
2
|
import { namedPlane, liftPointToPlane } from './plane.js';
|
|
3
3
|
/**
|
|
4
|
-
* Build the 3D edge(s) for a single 2D curve lifted onto a plane. Line
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Build the 3D edge(s) for a single 2D curve lifted onto a plane. Line, bezier
|
|
5
|
+
* and bspline build exact analytic edges; a full circle becomes one closed
|
|
6
|
+
* kernel circle edge and a trimmed circle a true arc edge from three on-plane
|
|
7
|
+
* lift points; ellipse falls back to a dense sampled polyline (no exact
|
|
8
|
+
* ellipse-edge primitive on the contract yet).
|
|
9
|
+
*
|
|
10
|
+
* GOTCHA (brepkit, 2026-09-30 实证): a closed wire built from exactly TWO
|
|
11
|
+
* half-arcs (`makeArcEdge`) makes brepkit's `makeFaceFromWire` produce a face
|
|
12
|
+
* covering only 1/3 of the disc (measured extrude volume 523.6 vs πr²·5 = 1570.8),
|
|
13
|
+
* while 3- or 4-arc wires and a single closed `makeCircleEdge` are exact. The
|
|
14
|
+
* full-circle case therefore emits one `makeCircleEdge` rather than two arcs.
|
|
9
15
|
* @param kernel - the kernel edge primitives.
|
|
10
16
|
* @param plane - the target plane frame.
|
|
11
17
|
* @param c - the ordered 2D curve to lift.
|
|
@@ -15,24 +21,77 @@ export function liftCurve2dToPlane(kernel, plane, c) {
|
|
|
15
21
|
const on = (c2, t) => liftPointToPlane(plane, ...evaluateCurve2d(c2, t));
|
|
16
22
|
switch (c.kind2d) {
|
|
17
23
|
case 'line':
|
|
24
|
+
// P2 (2026-09-28, ArchDetail class): a fully-trimmed sketch can carry a
|
|
25
|
+
// ZERO-LENGTH line; makeLineEdge(start, start) is rejected by the OCCT
|
|
26
|
+
// kernel and killed the whole sketchOnPlane call. A zero-length segment
|
|
27
|
+
// contributes nothing to the wire — skip it.
|
|
28
|
+
if (c.len === 0)
|
|
29
|
+
return [];
|
|
18
30
|
return [
|
|
19
31
|
kernel.makeLineEdge(liftPointToPlane(plane, c.ox, c.oy), liftPointToPlane(plane, c.ox + c.dx * c.len, c.oy + c.dy * c.len)),
|
|
20
32
|
];
|
|
21
33
|
case 'bezier':
|
|
22
34
|
return [kernel.makeBezierEdge(c.poles.map(([x, y]) => liftPointToPlane(plane, x, y)))];
|
|
23
|
-
case '
|
|
24
|
-
return [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
case 'bspline':
|
|
36
|
+
return [buildBSplineEdge(kernel, plane, c)];
|
|
37
|
+
case 'circle': {
|
|
38
|
+
// Whole circle → one closed kernel circle edge. The winding sense picks
|
|
39
|
+
// the axis sign so the seam/parametrisation follows the 2D curve.
|
|
40
|
+
const normal = c.sense ? plane.zDir : { x: -plane.zDir.x, y: -plane.zDir.y, z: -plane.zDir.z };
|
|
41
|
+
return [kernel.makeCircleEdge(liftPointToPlane(plane, c.cx, c.cy), normal, c.radius)];
|
|
42
|
+
}
|
|
43
|
+
case 'trimmed': {
|
|
29
44
|
if (c.basis.kind2d === 'circle')
|
|
30
45
|
return [kernel.makeArcEdge(on(c, 0), on(c, 0.5), on(c, 1))];
|
|
46
|
+
// A trimmed spline is built WHOLE and then cut by the kernel, so the
|
|
47
|
+
// sub-curve is the kernel's own exact subdivision rather than a
|
|
48
|
+
// re-derived control polygon here.
|
|
49
|
+
const full = c.basis.kind2d === 'bspline'
|
|
50
|
+
? buildBSplineEdge(kernel, plane, c.basis)
|
|
51
|
+
: c.basis.kind2d === 'bezier'
|
|
52
|
+
? kernel.makeBezierEdge(c.basis.poles.map(([x, y]) => liftPointToPlane(plane, x, y)))
|
|
53
|
+
: undefined;
|
|
54
|
+
if (full !== undefined)
|
|
55
|
+
return [trimEdge(kernel, full, c.tStart, c.tEnd)];
|
|
31
56
|
return sampledEdges(kernel, plane, c);
|
|
57
|
+
}
|
|
32
58
|
default:
|
|
33
59
|
return sampledEdges(kernel, plane, c);
|
|
34
60
|
}
|
|
35
61
|
}
|
|
62
|
+
/** Lift a 2D B-spline onto the plane as one exact NURBS edge (rational included). */
|
|
63
|
+
function buildBSplineEdge(kernel, plane, c) {
|
|
64
|
+
const poles = [];
|
|
65
|
+
for (const [x, y] of c.poles) {
|
|
66
|
+
const v = liftPointToPlane(plane, x, y);
|
|
67
|
+
poles.push(v.x, v.y, v.z);
|
|
68
|
+
}
|
|
69
|
+
return kernel.makeBSplineEdge(poles, c.weights ? [...c.weights] : [], c.knots, c.multiplicities, c.degree, c.isPeriodic);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Cut an edge down to `[first, last]` on its own parameter axis.
|
|
73
|
+
*
|
|
74
|
+
* `curveSplit` requires a STRICTLY interior parameter and rejects a domain end
|
|
75
|
+
* (`curveSplit: parameter out of range`), so each side is only cut when it is
|
|
76
|
+
* actually trimmed — an edge trimmed on one side alone would otherwise throw.
|
|
77
|
+
*
|
|
78
|
+
* @param kernel - the kernel edge primitives.
|
|
79
|
+
* @param edge - the whole basis edge.
|
|
80
|
+
* @param first - trim start on the edge's parameter axis.
|
|
81
|
+
* @param last - trim end on the edge's parameter axis.
|
|
82
|
+
* @returns the sub-edge (the same handle when no trim applies).
|
|
83
|
+
*/
|
|
84
|
+
function trimEdge(kernel, edge, first, last) {
|
|
85
|
+
const b = kernel.curveParameters(edge);
|
|
86
|
+
const eps = 1e-9 * Math.max(1, Math.abs(b.last - b.first));
|
|
87
|
+
let cur = edge;
|
|
88
|
+
if (last < b.last - eps)
|
|
89
|
+
cur = kernel.curveSplit(cur, last)[0];
|
|
90
|
+
const b2 = kernel.curveParameters(cur);
|
|
91
|
+
if (first > b2.first + eps)
|
|
92
|
+
cur = kernel.curveSplit(cur, first)[1];
|
|
93
|
+
return cur;
|
|
94
|
+
}
|
|
36
95
|
/** Sample a non-analytic curve into a polyline of `makeLineEdge`s on the plane. */
|
|
37
96
|
function sampledEdges(kernel, plane, c) {
|
|
38
97
|
const out = [];
|
|
@@ -68,5 +127,5 @@ export function assembleWire(kernel, planeOrName, bp) {
|
|
|
68
127
|
const plane = typeof planeOrName === 'string' ? namedPlane(planeOrName) : planeOrName;
|
|
69
128
|
return kernel.makeWire(curvesAsEdgesOnPlane(kernel, plane, bp.curves));
|
|
70
129
|
}
|
|
71
|
-
export { liftPointToPlane, namedPlane, makePlane, toVec3 } from './plane.js';
|
|
130
|
+
export { liftPointToPlane, worldToPlane, namedPlane, makePlane, toVec3 } from './plane.js';
|
|
72
131
|
//# sourceMappingURL=lift-on-plane.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lift-on-plane.js","sourceRoot":"","sources":["../../../src/geometry2d/bridge/lift-on-plane.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,OAA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G,GAAiB,EAAE,CAAA;IAC5B,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,GAAG,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACzE,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,MAAuB,EAAE,WAA2B,EAAE,EAAa;IAC9F,MAAM,KAAK,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;IACrF,OAAO,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;AACxE,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA","sourcesContent":["/**\n * 2D curve → 3D plane placement primitives (E2, occt-only bridge layer).\n *\n * This is the \"lift\" half of `sketchOnPlane`: it maps a pure-2D `Curve2dObj[]`\n * (or `Blueprint`) onto an arbitrary plane and assembles the resulting 3D edges\n * into a wire. `curvesAsEdgesOnPlane` / `assembleWire` mirror the plan's E2 work\n * items. The kernel edge/wire primitives are accepted as `Pick<BrepEngineApi, …>`\n * (the bridge may import the kernel contract, only `api/` is off-limits) so\n * callers pass `getBrepApi()` directly with no casts.\n * @module\n */\nimport type { BrepEngineApi } from '../../brep/engine/primitives'\nimport type { BrepHandle } from '../../brep/engine/types'\nimport type { Curve2dObj } from '../curve2d'\nimport { evaluateCurve2d } from '../curve2d'\nimport type { Blueprint } from '../blueprint'\nimport { namedPlane, liftPointToPlane, type Plane, type Vec3 } from './plane'\n\n/** Minimal kernel edge/wire surface needed for planar placement. */\nexport type PlaneWireKernel = Pick<BrepEngineApi, 'makeLineEdge' | 'makeArcEdge' | 'makeBezierEdge' | 'makeWire'>\n\n/**\n * Build the 3D edge(s) for a single 2D curve lifted onto a plane. Line and\n * bezier build exact analytic edges; circle / trimmed-circle build a true arc\n * edge from three on-plane lift points (a full circle is split into two arcs to\n * keep `makeArcEdge` well-formed); ellipse / bspline fall back to a dense\n * sampled polyline.\n * @param kernel - the kernel edge primitives.\n * @param plane - the target plane frame.\n * @param c - the ordered 2D curve to lift.\n * @returns the lifted 3D edge handle(s), in curve order.\n */\nexport function liftCurve2dToPlane(kernel: PlaneWireKernel, plane: Plane, c: Curve2dObj): BrepHandle[] {\n const on = (c2: Curve2dObj, t: number): Vec3 => liftPointToPlane(plane, ...evaluateCurve2d(c2, t))\n switch (c.kind2d) {\n case 'line':\n return [\n kernel.makeLineEdge(\n liftPointToPlane(plane, c.ox, c.oy),\n liftPointToPlane(plane, c.ox + c.dx * c.len, c.oy + c.dy * c.len),\n ),\n ]\n case 'bezier':\n return [kernel.makeBezierEdge(c.poles.map(([x, y]) => liftPointToPlane(plane, x, y)))]\n case 'circle':\n return [\n kernel.makeArcEdge(on(c, 0), on(c, Math.PI / 2), on(c, Math.PI)),\n kernel.makeArcEdge(on(c, Math.PI), on(c, (3 * Math.PI) / 2), on(c, 2 * Math.PI)),\n ]\n case 'trimmed':\n if (c.basis.kind2d === 'circle') return [kernel.makeArcEdge(on(c, 0), on(c, 0.5), on(c, 1))]\n return sampledEdges(kernel, plane, c)\n default:\n return sampledEdges(kernel, plane, c)\n }\n}\n\n/** Sample a non-analytic curve into a polyline of `makeLineEdge`s on the plane. */\nfunction sampledEdges(kernel: PlaneWireKernel, plane: Plane, c: Curve2dObj): BrepHandle[] {\n const out: BrepHandle[] = []\n for (let k = 0; k < 32; k++) {\n const t0 = k / 32\n const t1 = (k + 1) / 32\n out.push(kernel.makeLineEdge(liftPointToPlane(plane, ...evaluateCurve2d(c, t0)), liftPointToPlane(plane, ...evaluateCurve2d(c, t1))))\n }\n return out\n}\n\n/**\n * Lift an ordered list of 2D curves to edges on a plane frame.\n * @param kernel - the kernel edge/wire primitives.\n * @param plane - the target plane.\n * @param curves - the ordered 2D curves (a closed loop stays closed).\n * @returns the lifted 3D edge handles in the same order.\n */\nexport function curvesAsEdgesOnPlane(kernel: PlaneWireKernel, plane: Plane, curves: readonly Curve2dObj[]): BrepHandle[] {\n const out: BrepHandle[] = []\n for (const c of curves) out.push(...liftCurve2dToPlane(kernel, plane, c))\n return out\n}\n\n/**\n * Assemble a Blueprint's curves into a 3D wire on a plane — the shared placement\n * step for all of the profile / draw / sketch sources.\n * @param kernel - the curve kernel/wire primitives.\n * @param planeOrName - a plane frame or a named plane string (`'XY'` / `'XZ'` / …).\n * @param bp - the blueprint whose ordered curves become the wire.\n * @returns the assembled 3D wire.\n */\nexport function assembleWire(kernel: PlaneWireKernel, planeOrName: Plane | string, bp: Blueprint): BrepHandle {\n const plane = typeof planeOrName === 'string' ? namedPlane(planeOrName) : planeOrName\n return kernel.makeWire(curvesAsEdgesOnPlane(kernel, plane, bp.curves))\n}\n\nexport { liftPointToPlane, namedPlane, makePlane, toVec3 } from './plane'\nexport type { Plane, Vec3, Vec3Input } from './plane'"]}
|
|
1
|
+
{"version":3,"file":"lift-on-plane.js","sourceRoot":"","sources":["../../../src/geometry2d/bridge/lift-on-plane.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAyB,MAAM,SAAS,CAAA;AAmB7E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAuB,EAAE,KAAY,EAAE,CAAa;IACrF,MAAM,EAAE,GAAG,CAAC,EAAc,EAAE,CAAS,EAAQ,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IAClG,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;QACjB,KAAK,MAAM;YACT,wEAAwE;YACxE,uEAAuE;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CAAC,CAAA;AACxE,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA","sourcesContent":["/**\n * 2D curve → 3D plane placement primitives (E2, occt-only bridge layer).\n *\n * This is the \"lift\" half of `sketchOnPlane`: it maps a pure-2D `Curve2dObj[]`\n * (or `Blueprint`) onto an arbitrary plane and assembles the resulting 3D edges\n * into a wire. `curvesAsEdgesOnPlane` / `assembleWire` mirror the plan's E2 work\n * items. The kernel edge/wire primitives are accepted as `Pick<BrepEngineApi, …>`\n * (the bridge may import the kernel contract, only `api/` is off-limits) so\n * callers pass `getBrepApi()` directly with no casts.\n * @module\n */\nimport type { BrepEngineApi } from '../../brep/engine/primitives'\nimport type { BrepHandle } from '../../brep/engine/types'\nimport type { Curve2dObj, BSpline2d } from '../curve2d'\nimport { evaluateCurve2d } from '../curve2d'\nimport type { Blueprint } from '../blueprint'\nimport { namedPlane, liftPointToPlane, type Plane, type Vec3 } from './plane'\n\n/**\n * Minimal kernel edge/wire surface needed for planar placement (plus the\n * NURBS/curve primitives the spline segments need: an exact parametric edge\n * cannot be built or trimmed without them).\n */\nexport type PlaneWireKernel = Pick<\n BrepEngineApi,\n | 'makeLineEdge'\n | 'makeArcEdge'\n | 'makeBezierEdge'\n | 'makeBSplineEdge'\n | 'makeCircleEdge'\n | 'curveSplit'\n | 'curveParameters'\n | 'makeWire'\n>\n\n/**\n * Build the 3D edge(s) for a single 2D curve lifted onto a plane. Line, bezier\n * and bspline build exact analytic edges; a full circle becomes one closed\n * kernel circle edge and a trimmed circle a true arc edge from three on-plane\n * lift points; ellipse falls back to a dense sampled polyline (no exact\n * ellipse-edge primitive on the contract yet).\n *\n * GOTCHA (brepkit, 2026-09-30 实证): a closed wire built from exactly TWO\n * half-arcs (`makeArcEdge`) makes brepkit's `makeFaceFromWire` produce a face\n * covering only 1/3 of the disc (measured extrude volume 523.6 vs πr²·5 = 1570.8),\n * while 3- or 4-arc wires and a single closed `makeCircleEdge` are exact. The\n * full-circle case therefore emits one `makeCircleEdge` rather than two arcs.\n * @param kernel - the kernel edge primitives.\n * @param plane - the target plane frame.\n * @param c - the ordered 2D curve to lift.\n * @returns the lifted 3D edge handle(s), in curve order.\n */\nexport function liftCurve2dToPlane(kernel: PlaneWireKernel, plane: Plane, c: Curve2dObj): BrepHandle[] {\n const on = (c2: Curve2dObj, t: number): Vec3 => liftPointToPlane(plane, ...evaluateCurve2d(c2, t))\n switch (c.kind2d) {\n case 'line':\n // P2 (2026-09-28, ArchDetail class): a fully-trimmed sketch can carry a\n // ZERO-LENGTH line; makeLineEdge(start, start) is rejected by the OCCT\n // kernel and killed the whole sketchOnPlane call. A zero-length segment\n // contributes nothing to the wire — skip it.\n if (c.len === 0) return []\n return [\n kernel.makeLineEdge(\n liftPointToPlane(plane, c.ox, c.oy),\n liftPointToPlane(plane, c.ox + c.dx * c.len, c.oy + c.dy * c.len),\n ),\n ]\n case 'bezier':\n return [kernel.makeBezierEdge(c.poles.map(([x, y]) => liftPointToPlane(plane, x, y)))]\n case 'bspline':\n return [buildBSplineEdge(kernel, plane, c)]\n case 'circle': {\n // Whole circle → one closed kernel circle edge. The winding sense picks\n // the axis sign so the seam/parametrisation follows the 2D curve.\n const normal = c.sense ? plane.zDir : { x: -plane.zDir.x, y: -plane.zDir.y, z: -plane.zDir.z }\n return [kernel.makeCircleEdge(liftPointToPlane(plane, c.cx, c.cy), normal, c.radius)]\n }\n case 'trimmed': {\n if (c.basis.kind2d === 'circle') return [kernel.makeArcEdge(on(c, 0), on(c, 0.5), on(c, 1))]\n // A trimmed spline is built WHOLE and then cut by the kernel, so the\n // sub-curve is the kernel's own exact subdivision rather than a\n // re-derived control polygon here.\n const full =\n c.basis.kind2d === 'bspline'\n ? buildBSplineEdge(kernel, plane, c.basis)\n : c.basis.kind2d === 'bezier'\n ? kernel.makeBezierEdge(c.basis.poles.map(([x, y]) => liftPointToPlane(plane, x, y)))\n : undefined\n if (full !== undefined) return [trimEdge(kernel, full, c.tStart, c.tEnd)]\n return sampledEdges(kernel, plane, c)\n }\n default:\n return sampledEdges(kernel, plane, c)\n }\n}\n\n/** Lift a 2D B-spline onto the plane as one exact NURBS edge (rational included). */\nfunction buildBSplineEdge(kernel: PlaneWireKernel, plane: Plane, c: BSpline2d): BrepHandle {\n const poles: number[] = []\n for (const [x, y] of c.poles) {\n const v = liftPointToPlane(plane, x, y)\n poles.push(v.x, v.y, v.z)\n }\n return kernel.makeBSplineEdge(poles, c.weights ? [...c.weights] : [], c.knots, c.multiplicities, c.degree, c.isPeriodic)\n}\n\n/**\n * Cut an edge down to `[first, last]` on its own parameter axis.\n *\n * `curveSplit` requires a STRICTLY interior parameter and rejects a domain end\n * (`curveSplit: parameter out of range`), so each side is only cut when it is\n * actually trimmed — an edge trimmed on one side alone would otherwise throw.\n *\n * @param kernel - the kernel edge primitives.\n * @param edge - the whole basis edge.\n * @param first - trim start on the edge's parameter axis.\n * @param last - trim end on the edge's parameter axis.\n * @returns the sub-edge (the same handle when no trim applies).\n */\nfunction trimEdge(kernel: PlaneWireKernel, edge: BrepHandle, first: number, last: number): BrepHandle {\n const b = kernel.curveParameters(edge)\n const eps = 1e-9 * Math.max(1, Math.abs(b.last - b.first))\n let cur = edge\n if (last < b.last - eps) cur = kernel.curveSplit(cur, last)[0]\n const b2 = kernel.curveParameters(cur)\n if (first > b2.first + eps) cur = kernel.curveSplit(cur, first)[1]\n return cur\n}\n\n/** Sample a non-analytic curve into a polyline of `makeLineEdge`s on the plane. */\nfunction sampledEdges(kernel: PlaneWireKernel, plane: Plane, c: Curve2dObj): BrepHandle[] {\n const out: BrepHandle[] = []\n for (let k = 0; k < 32; k++) {\n const t0 = k / 32\n const t1 = (k + 1) / 32\n out.push(kernel.makeLineEdge(liftPointToPlane(plane, ...evaluateCurve2d(c, t0)), liftPointToPlane(plane, ...evaluateCurve2d(c, t1))))\n }\n return out\n}\n\n/**\n * Lift an ordered list of 2D curves to edges on a plane frame.\n * @param kernel - the kernel edge/wire primitives.\n * @param plane - the target plane.\n * @param curves - the ordered 2D curves (a closed loop stays closed).\n * @returns the lifted 3D edge handles in the same order.\n */\nexport function curvesAsEdgesOnPlane(kernel: PlaneWireKernel, plane: Plane, curves: readonly Curve2dObj[]): BrepHandle[] {\n const out: BrepHandle[] = []\n for (const c of curves) out.push(...liftCurve2dToPlane(kernel, plane, c))\n return out\n}\n\n/**\n * Assemble a Blueprint's curves into a 3D wire on a plane — the shared placement\n * step for all of the profile / draw / sketch sources.\n * @param kernel - the curve kernel/wire primitives.\n * @param planeOrName - a plane frame or a named plane string (`'XY'` / `'XZ'` / …).\n * @param bp - the blueprint whose ordered curves become the wire.\n * @returns the assembled 3D wire.\n */\nexport function assembleWire(kernel: PlaneWireKernel, planeOrName: Plane | string, bp: Blueprint): BrepHandle {\n const plane = typeof planeOrName === 'string' ? namedPlane(planeOrName) : planeOrName\n return kernel.makeWire(curvesAsEdgesOnPlane(kernel, plane, bp.curves))\n}\n\nexport { liftPointToPlane, worldToPlane, namedPlane, makePlane, toVec3 } from './plane'\nexport type { Plane, Vec3, Vec3Input } from './plane'\n"]}
|
|
@@ -66,4 +66,21 @@ export declare function namedPlane(name: string, origin?: Vec3Input): Plane;
|
|
|
66
66
|
* @returns the 3D point on the plane.
|
|
67
67
|
*/
|
|
68
68
|
export declare function liftPointToPlane(plane: Plane, x: number, y: number): Vec3;
|
|
69
|
+
/**
|
|
70
|
+
* Project a 3D point onto a plane's 2D coordinates — the inverse of
|
|
71
|
+
* {@link liftPointToPlane}. Computes `d = p − origin` and returns
|
|
72
|
+
* `(u, v) = (d·xDir, d·yDir)`. Because `xDir`/`yDir` are orthonormal this is the
|
|
73
|
+
* orthogonal projection: the component of `d` along `zDir` (the plane normal) is
|
|
74
|
+
* dropped. A point already on the plane round-trips losslessly
|
|
75
|
+
* (`worldToPlane(plane, liftPointToPlane(plane, u, v)) === {u, v}`); a point off
|
|
76
|
+
* the plane projects to the foot of the perpendicular — the same behaviour as
|
|
77
|
+
* dropping a sketch point onto its supporting face.
|
|
78
|
+
* @param plane - the supporting plane frame.
|
|
79
|
+
* @param p - the 3D point to project.
|
|
80
|
+
* @returns the 2D `{ u, v }` coordinates on the plane.
|
|
81
|
+
*/
|
|
82
|
+
export declare function worldToPlane(plane: Plane, p: Vec3Input): {
|
|
83
|
+
u: number;
|
|
84
|
+
v: number;
|
|
85
|
+
};
|
|
69
86
|
//# sourceMappingURL=plane.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plane.d.ts","sourceRoot":"","sources":["../../../src/geometry2d/bridge/plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,sEAAsE;AACtE,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,mFAAmF;AACnF,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAEhE;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAIzC;AAED;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAA;IACrB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CACpB;
|
|
1
|
+
{"version":3,"file":"plane.d.ts","sourceRoot":"","sources":["../../../src/geometry2d/bridge/plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,sEAAsE;AACtE,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EA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|
+
function dot(a, b) {
|
|
29
|
+
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
30
|
+
}
|
|
28
31
|
function norm(v) {
|
|
29
32
|
return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
|
30
33
|
}
|
|
@@ -93,4 +96,23 @@ export function liftPointToPlane(plane, x, y) {
|
|
|
93
96
|
const { origin: o, xDir: u, yDir: v } = plane;
|
|
94
97
|
return { x: o.x + x * u.x + y * v.x, y: o.y + x * u.y + y * v.y, z: o.z + x * u.z + y * v.z };
|
|
95
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Project a 3D point onto a plane's 2D coordinates — the inverse of
|
|
101
|
+
* {@link liftPointToPlane}. Computes `d = p − origin` and returns
|
|
102
|
+
* `(u, v) = (d·xDir, d·yDir)`. Because `xDir`/`yDir` are orthonormal this is the
|
|
103
|
+
* orthogonal projection: the component of `d` along `zDir` (the plane normal) is
|
|
104
|
+
* dropped. A point already on the plane round-trips losslessly
|
|
105
|
+
* (`worldToPlane(plane, liftPointToPlane(plane, u, v)) === {u, v}`); a point off
|
|
106
|
+
* the plane projects to the foot of the perpendicular — the same behaviour as
|
|
107
|
+
* dropping a sketch point onto its supporting face.
|
|
108
|
+
* @param plane - the supporting plane frame.
|
|
109
|
+
* @param p - the 3D point to project.
|
|
110
|
+
* @returns the 2D `{ u, v }` coordinates on the plane.
|
|
111
|
+
*/
|
|
112
|
+
export function worldToPlane(plane, p) {
|
|
113
|
+
const { origin: o, xDir: u, yDir: v } = plane;
|
|
114
|
+
const q = toVec3(p);
|
|
115
|
+
const d = { x: q.x - o.x, y: q.y - o.y, z: q.z - o.z };
|
|
116
|
+
return { u: dot(d, u), v: dot(d, v) };
|
|
117
|
+
}
|
|
96
118
|
//# sourceMappingURL=plane.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plane.js","sourceRoot":"","sources":["../../../src/geometry2d/bridge/plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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AM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;IAC9B,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,8DAA8D,CAAC,CAAA;IAC/G,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;AACtD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAY,EAAE,CAAS,EAAE,CAAS;IACjE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,CAAA;IAC7C,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;AAC/F,CAAC","sourcesContent":["/**\n * Plane frame helpers for 2D→3D placement (pure TS, no kernel, no `api/` import).\n *\n * A {@link Plane} carries an origin plus a right-handed, orthonormal frame\n * `xDir / yDir / zDir` where `zDir` is the plane normal — the same semantic as\n * the kernel `gp_Ax3` frame and the `createPlane` helper in `api/brepjs-compat`.\n * The bridge may **not** import `api/` (plan rule against a cycle), so this\n * module re-derives the framing math self-containedly. Points use the\n * `{ x, y, z }` shape compatible with the BREP engine's neutral `BrepVec3`.\n * @module\n */\n\n/** A 3D point / vector (neutral {x,y,z} shape, kernel-compatible). */\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\n/** User-facing 3D input: `{x,y,z}` object or `[x,y,z]` array (the script form). */\nexport type Vec3Input = Vec3 | readonly [number, number, number]\n\n/**\n * Normalize a raw script- or API-facing 3D input to the canonical `{x,y,z}`.\n * Accepts both the array form (`[1,0,0]`, as produced by `.fai.js` literals)\n * and the object form (`{x,y,z}`, used by the bridge internals).\n * @param v - the input 3D value.\n * @returns the canonical vector.\n */\nexport function toVec3(v: Vec3Input): Vec3 {\n if (Array.isArray(v)) return { x: v[0]!, y: v[1]!, z: v[2]! }\n const o = v as Vec3\n return { x: o.x, y: o.y, z: o.z }\n}\n\n/**\n * A right-handed, orthonormal plane frame: an origin plus `xDir`/`yDir` (in-plane\n * axes) and `zDir` (the normal). 2D `(x, y)` maps to `origin + x*xDir + y*yDir`.\n */\nexport interface Plane {\n /** The plane's anchor point (the 2D origin maps here). */\n readonly origin: Vec3\n /** The in-plane X axis (maps the 2D +X). */\n readonly xDir: Vec3\n /** The in-plane Y axis (maps the 2D +Y). */\n readonly yDir: Vec3\n /** The plane normal (2D +Z after placement). */\n readonly zDir: Vec3\n}\n\nfunction cross(a: Vec3, b: Vec3): Vec3 {\n return { x: a.y * b.z - a.z * b.y, y: a.z * b.x - a.x * b.z, z: a.x * b.y - a.y * b.x }\n}\n\nfunction norm(v: Vec3): number {\n return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)\n}\n\nfunction normalize(v: Vec3): Vec3 {\n const len = norm(v)\n return len > 1e-14 ? { x: v.x / len, y: v.y / len, z: v.z / len } : { x: 1, y: 0, z: 0 }\n}\n\n/**\n * Build a right-handed plane frame from an origin, a normal, and an optional\n * in-plane X direction. The X direction is auto-derived (least-aligned-axis\n * cross product) when omitted, mirroring the kernel `gp_Ax3` convention.\n * @param origin - the plane origin (2D origin maps here).\n * @param normal - the plane normal (becomes the zDir); must be non-zero.\n * @param xDir - optional explicit in-plane X; auto-derived when omitted.\n * @returns the orthonormal plane frame.\n */\nexport function makePlane(origin: Vec3Input, normal: Vec3Input, xDir?: Vec3Input): Plane {\n const o = toVec3(origin)\n const z = normalize(toVec3(normal))\n let x: Vec3\n if (xDir) {\n x = normalize(toVec3(xDir))\n } else {\n const ax = Math.abs(z.x), ay = Math.abs(z.y), az = Math.abs(z.z)\n const cand: Vec3 =\n ax <= ay && ax <= az ? { x: 1, y: 0, z: 0 } : ay <= az ? { x: 0, y: 1, z: 0 } : { x: 0, y: 0, z: 1 }\n x = normalize(cross(cand, z))\n }\n const y = normalize(cross(z, x))\n return { origin: o, xDir: x, yDir: y, zDir: z }\n}\n\n/** Named CAD planes with their canonical frames (origin defaults to [0,0,0]). */\nconst NAMED_PLANES: Record<string, { xDir: Vec3; zDir: Vec3 }> = {\n XY: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: 0, z: 1 } },\n XZ: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: -1, z: 0 } },\n YZ: { xDir: { x: 0, y: 1, z: 0 }, zDir: { x: 1, y: 0, z: 0 } },\n front: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: 0, z: 1 } },\n back: { xDir: { x: -1, y: 0, z: 0 }, zDir: { x: 0, y: 0, z: -1 } },\n left: { xDir: { x: 0, y: 0, z: 1 }, zDir: { x: -1, y: 0, z: 0 } },\n right: { xDir: { x: 0, y: 0, z: -1 }, zDir: { x: 1, y: 0, z: 0 } },\n top: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: 1, z: 0 } },\n bottom: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: -1, z: 0 } },\n}\n\n/**\n * Resolve a named plane (e.g. `'XY'` / `'XZ'` / `'top'`) to a frame at a given\n * origin. Unknown names throw.\n * @param name - the canonical plane name.\n * @param origin - the plane origin (default [0,0,0]).\n * @returns the plane frame.\n */\nexport function namedPlane(name: string, origin: Vec3Input = { x: 0, y: 0, z: 0 }): Plane {\n const cfg = NAMED_PLANES[name]\n if (!cfg) throw new Error(`unknown plane '${name}' (expected XY | XZ | YZ | front/back/left/right/top/bottom)`)\n return makePlane(toVec3(origin), cfg.zDir, cfg.xDir)\n}\n\n/**\n * Map a 2D point `(x, y)` into 3D on a plane frame:\n * `origin + x*xDir + y*yDir`. This is the per-point lift used by curve lifting.\n * @param plane - the target plane.\n * @param x - the 2D `x` coordinate.\n * @param y - the 2D `y` coordinate.\n * @returns the 3D point on the plane.\n */\nexport function liftPointToPlane(plane: Plane, x: number, y: number): Vec3 {\n const { origin: o, xDir: u, yDir: v } = plane\n return { x: o.x + x * u.x + y * v.x, y: o.y + x * u.y + y * v.y, z: o.z + x * u.z + y * v.z }\n}"]}
|
|
1
|
+
{"version":3,"file":"plane.js","sourceRoot":"","sources":["../../../src/geometry2d/bridge/plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAYH;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,CAAY;IACjC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAA;IAC7D,MAAM,CAAC,GAAG,CAAS,CAAA;IACnB,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACnC,CAAC;AAiBD,SAAS,KAAK,CAAC,CAAO,EAAE,CAAO;IAC7B,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAA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C,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;AAC/F,CAAC;AACD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,KAAY,EAAE,CAAY;IACrD,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,CAAA;IAC7C,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACnB,MAAM,CAAC,GAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAC5D,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;AACvC,CAAC","sourcesContent":["/**\n * Plane frame helpers for 2D→3D placement (pure TS, no kernel, no `api/` import).\n *\n * A {@link Plane} carries an origin plus a right-handed, orthonormal frame\n * `xDir / yDir / zDir` where `zDir` is the plane normal — the same semantic as\n * the kernel `gp_Ax3` frame and the `createPlane` helper in `api/brepjs-compat`.\n * The bridge may **not** import `api/` (plan rule against a cycle), so this\n * module re-derives the framing math self-containedly. Points use the\n * `{ x, y, z }` shape compatible with the BREP engine's neutral `BrepVec3`.\n * @module\n */\n\n/** A 3D point / vector (neutral {x,y,z} shape, kernel-compatible). */\nexport interface Vec3 {\n x: number\n y: number\n z: number\n}\n\n/** User-facing 3D input: `{x,y,z}` object or `[x,y,z]` array (the script form). */\nexport type Vec3Input = Vec3 | readonly [number, number, number]\n\n/**\n * Normalize a raw script- or API-facing 3D input to the canonical `{x,y,z}`.\n * Accepts both the array form (`[1,0,0]`, as produced by `.fai.js` literals)\n * and the object form (`{x,y,z}`, used by the bridge internals).\n * @param v - the input 3D value.\n * @returns the canonical vector.\n */\nexport function toVec3(v: Vec3Input): Vec3 {\n if (Array.isArray(v)) return { x: v[0]!, y: v[1]!, z: v[2]! }\n const o = v as Vec3\n return { x: o.x, y: o.y, z: o.z }\n}\n\n/**\n * A right-handed, orthonormal plane frame: an origin plus `xDir`/`yDir` (in-plane\n * axes) and `zDir` (the normal). 2D `(x, y)` maps to `origin + x*xDir + y*yDir`.\n */\nexport interface Plane {\n /** The plane's anchor point (the 2D origin maps here). */\n readonly origin: Vec3\n /** The in-plane X axis (maps the 2D +X). */\n readonly xDir: Vec3\n /** The in-plane Y axis (maps the 2D +Y). */\n readonly yDir: Vec3\n /** The plane normal (2D +Z after placement). */\n readonly zDir: Vec3\n}\n\nfunction cross(a: Vec3, b: Vec3): Vec3 {\n return { x: a.y * b.z - a.z * b.y, y: a.z * b.x - a.x * b.z, z: a.x * b.y - a.y * b.x }\n}\n\nfunction dot(a: Vec3, b: Vec3): number {\n return a.x * b.x + a.y * b.y + a.z * b.z\n}\n\nfunction norm(v: Vec3): number {\n return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)\n}\n\nfunction normalize(v: Vec3): Vec3 {\n const len = norm(v)\n return len > 1e-14 ? { x: v.x / len, y: v.y / len, z: v.z / len } : { x: 1, y: 0, z: 0 }\n}\n\n/**\n * Build a right-handed plane frame from an origin, a normal, and an optional\n * in-plane X direction. The X direction is auto-derived (least-aligned-axis\n * cross product) when omitted, mirroring the kernel `gp_Ax3` convention.\n * @param origin - the plane origin (2D origin maps here).\n * @param normal - the plane normal (becomes the zDir); must be non-zero.\n * @param xDir - optional explicit in-plane X; auto-derived when omitted.\n * @returns the orthonormal plane frame.\n */\nexport function makePlane(origin: Vec3Input, normal: Vec3Input, xDir?: Vec3Input): Plane {\n const o = toVec3(origin)\n const z = normalize(toVec3(normal))\n let x: Vec3\n if (xDir) {\n x = normalize(toVec3(xDir))\n } else {\n const ax = Math.abs(z.x), ay = Math.abs(z.y), az = Math.abs(z.z)\n const cand: Vec3 =\n ax <= ay && ax <= az ? { x: 1, y: 0, z: 0 } : ay <= az ? { x: 0, y: 1, z: 0 } : { x: 0, y: 0, z: 1 }\n x = normalize(cross(cand, z))\n }\n const y = normalize(cross(z, x))\n return { origin: o, xDir: x, yDir: y, zDir: z }\n}\n\n/** Named CAD planes with their canonical frames (origin defaults to [0,0,0]). */\nconst NAMED_PLANES: Record<string, { xDir: Vec3; zDir: Vec3 }> = {\n XY: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: 0, z: 1 } },\n XZ: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: -1, z: 0 } },\n YZ: { xDir: { x: 0, y: 1, z: 0 }, zDir: { x: 1, y: 0, z: 0 } },\n front: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: 0, z: 1 } },\n back: { xDir: { x: -1, y: 0, z: 0 }, zDir: { x: 0, y: 0, z: -1 } },\n left: { xDir: { x: 0, y: 0, z: 1 }, zDir: { x: -1, y: 0, z: 0 } },\n right: { xDir: { x: 0, y: 0, z: -1 }, zDir: { x: 1, y: 0, z: 0 } },\n top: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: 1, z: 0 } },\n bottom: { xDir: { x: 1, y: 0, z: 0 }, zDir: { x: 0, y: -1, z: 0 } },\n}\n\n/**\n * Resolve a named plane (e.g. `'XY'` / `'XZ'` / `'top'`) to a frame at a given\n * origin. Unknown names throw.\n * @param name - the canonical plane name.\n * @param origin - the plane origin (default [0,0,0]).\n * @returns the plane frame.\n */\nexport function namedPlane(name: string, origin: Vec3Input = { x: 0, y: 0, z: 0 }): Plane {\n const cfg = NAMED_PLANES[name]\n if (!cfg) throw new Error(`unknown plane '${name}' (expected XY | XZ | YZ | front/back/left/right/top/bottom)`)\n return makePlane(toVec3(origin), cfg.zDir, cfg.xDir)\n}\n\n/**\n * Map a 2D point `(x, y)` into 3D on a plane frame:\n * `origin + x*xDir + y*yDir`. This is the per-point lift used by curve lifting.\n * @param plane - the target plane.\n * @param x - the 2D `x` coordinate.\n * @param y - the 2D `y` coordinate.\n * @returns the 3D point on the plane.\n */\nexport function liftPointToPlane(plane: Plane, x: number, y: number): Vec3 {\n const { origin: o, xDir: u, yDir: v } = plane\n return { x: o.x + x * u.x + y * v.x, y: o.y + x * u.y + y * v.y, z: o.z + x * u.z + y * v.z }\n}\n/**\n * Project a 3D point onto a plane's 2D coordinates — the inverse of\n * {@link liftPointToPlane}. Computes `d = p − origin` and returns\n * `(u, v) = (d·xDir, d·yDir)`. Because `xDir`/`yDir` are orthonormal this is the\n * orthogonal projection: the component of `d` along `zDir` (the plane normal) is\n * dropped. A point already on the plane round-trips losslessly\n * (`worldToPlane(plane, liftPointToPlane(plane, u, v)) === {u, v}`); a point off\n * the plane projects to the foot of the perpendicular — the same behaviour as\n * dropping a sketch point onto its supporting face.\n * @param plane - the supporting plane frame.\n * @param p - the 3D point to project.\n * @returns the 2D `{ u, v }` coordinates on the plane.\n */\nexport function worldToPlane(plane: Plane, p: Vec3Input): { u: number; v: number } {\n const { origin: o, xDir: u, yDir: v } = plane\n const q = toVec3(p)\n const d: Vec3 = { x: q.x - o.x, y: q.y - o.y, z: q.z - o.z }\n return { u: dot(d, u), v: dot(d, v) }\n}"]}
|
|
@@ -56,6 +56,13 @@ export interface BSpline2d {
|
|
|
56
56
|
readonly multiplicities: number[];
|
|
57
57
|
readonly degree: number;
|
|
58
58
|
readonly isPeriodic: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* One weight per pole. Absent (or all 1) for a non-rational curve. Rational
|
|
61
|
+
* B-splines are exactly what a kernel hands back for a conic-approximating or
|
|
62
|
+
* spline edge (`BrepNurbsCurveData.rational`), and dropping the weights turns
|
|
63
|
+
* the curve into a different one — so they travel with the poles.
|
|
64
|
+
*/
|
|
65
|
+
readonly weights?: number[];
|
|
59
66
|
}
|
|
60
67
|
/** Trimmed wrapper over another curve. */
|
|
61
68
|
export interface TrimmedCurve2d {
|
|
@@ -167,6 +174,24 @@ export declare function makeEllipse2d(cx: number, cy: number, majorRadius: numbe
|
|
|
167
174
|
* @returns a Bezier2d holding a copy of the poles.
|
|
168
175
|
*/
|
|
169
176
|
export declare function makeBezier2d(poles: [number, number][]): Bezier2d;
|
|
177
|
+
/**
|
|
178
|
+
* B-spline from raw NURBS data (the write-side counterpart of a kernel's
|
|
179
|
+
* `getNurbsCurveData`, so an exact edge survives as data instead of a
|
|
180
|
+
* tessellation).
|
|
181
|
+
*
|
|
182
|
+
* The knot vector is NOT expanded here: `knots`/`multiplicities` stay the two
|
|
183
|
+
* parallel arrays the kernel reports, and every evaluator expands them the same
|
|
184
|
+
* way (`evaluateBSpline2d`).
|
|
185
|
+
*
|
|
186
|
+
* @param poles - control points `[x, y]`, one per weight in `weights`.
|
|
187
|
+
* @param knots - distinct knot values.
|
|
188
|
+
* @param multiplicities - multiplicity of each entry in `knots`.
|
|
189
|
+
* @param degree - polynomial degree.
|
|
190
|
+
* @param isPeriodic - true for a periodic (wrap-around) curve.
|
|
191
|
+
* @param weights - optional per-pole weights; omit for a non-rational curve.
|
|
192
|
+
* @returns a BSpline2d holding copies of the control data.
|
|
193
|
+
*/
|
|
194
|
+
export declare function makeBSpline2d(poles: [number, number][], knots: number[], multiplicities: number[], degree: number, isPeriodic: boolean, weights?: number[]): BSpline2d;
|
|
170
195
|
/**
|
|
171
196
|
* Translate a curve by an offset.
|
|
172
197
|
* @param c - the curve to translate.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curve2d.d.ts","sourceRoot":"","sources":["../../src/geometry2d/curve2d.ts"],"names":[],"mappings":"AAAA;;;;;;;;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B,mBAAmB,CACjC,EAAE,EAAE,UAAU,EACd,EAAE,EAAE,UAAU,EACd,SAAS,EAAE,MAAM,GAChB;IAAE,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAE,CAqBxD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAEtD;AACD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAE3D;AAMD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAgEnF;AAkDD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,SAAM,GAAG,MAAM,GAAG,IAAI,CAkCrG;AAeD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAEjF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,IAAI,CAKtF"}
|
|
@@ -306,6 +306,34 @@ export function makeEllipse2d(cx, cy, majorRadius, minorRadius, xDirX = 1, xDirY
|
|
|
306
306
|
export function makeBezier2d(poles) {
|
|
307
307
|
return { kind2d: 'bezier', poles: [...poles] };
|
|
308
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* B-spline from raw NURBS data (the write-side counterpart of a kernel's
|
|
311
|
+
* `getNurbsCurveData`, so an exact edge survives as data instead of a
|
|
312
|
+
* tessellation).
|
|
313
|
+
*
|
|
314
|
+
* The knot vector is NOT expanded here: `knots`/`multiplicities` stay the two
|
|
315
|
+
* parallel arrays the kernel reports, and every evaluator expands them the same
|
|
316
|
+
* way (`evaluateBSpline2d`).
|
|
317
|
+
*
|
|
318
|
+
* @param poles - control points `[x, y]`, one per weight in `weights`.
|
|
319
|
+
* @param knots - distinct knot values.
|
|
320
|
+
* @param multiplicities - multiplicity of each entry in `knots`.
|
|
321
|
+
* @param degree - polynomial degree.
|
|
322
|
+
* @param isPeriodic - true for a periodic (wrap-around) curve.
|
|
323
|
+
* @param weights - optional per-pole weights; omit for a non-rational curve.
|
|
324
|
+
* @returns a BSpline2d holding copies of the control data.
|
|
325
|
+
*/
|
|
326
|
+
export function makeBSpline2d(poles, knots, multiplicities, degree, isPeriodic, weights) {
|
|
327
|
+
return {
|
|
328
|
+
kind2d: 'bspline',
|
|
329
|
+
poles: poles.map(([x, y]) => [x, y]),
|
|
330
|
+
knots: [...knots],
|
|
331
|
+
multiplicities: [...multiplicities],
|
|
332
|
+
degree,
|
|
333
|
+
isPeriodic,
|
|
334
|
+
...(weights ? { weights: [...weights] } : {}),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
309
337
|
// ---------------------------------------------------------------------------
|
|
310
338
|
// Transform helpers
|
|
311
339
|
// ---------------------------------------------------------------------------
|
|
@@ -1084,12 +1112,17 @@ function evaluateBSpline2d(c, t) {
|
|
|
1084
1112
|
}
|
|
1085
1113
|
if (tClamped >= fullKnots[k - p - 1])
|
|
1086
1114
|
span = k - p - 2;
|
|
1087
|
-
//
|
|
1115
|
+
// Relevant control points in HOMOGENEOUS form [w·x, w·y, w]. De Boor is linear,
|
|
1116
|
+
// so running it on the homogeneous values and dividing at the end is exactly
|
|
1117
|
+
// the rational (NURBS) evaluation; with every weight 1 the third component
|
|
1118
|
+
// stays 1 and this reduces to the non-rational case bit for bit.
|
|
1119
|
+
const weights = c.weights;
|
|
1088
1120
|
const d = [];
|
|
1089
1121
|
for (let j = 0; j <= p; j++) {
|
|
1090
|
-
const idx = Math.min(span - p + j, n - 1);
|
|
1091
|
-
const pole = c.poles[
|
|
1092
|
-
|
|
1122
|
+
const idx = Math.max(0, Math.min(span - p + j, n - 1));
|
|
1123
|
+
const pole = c.poles[idx];
|
|
1124
|
+
const wi = weights ? (weights[idx] ?? 1) : 1;
|
|
1125
|
+
d.push([pole[0] * wi, pole[1] * wi, wi]);
|
|
1093
1126
|
}
|
|
1094
1127
|
// De Boor recursion
|
|
1095
1128
|
for (let r = 1; r <= p; r++) {
|
|
@@ -1103,8 +1136,11 @@ function evaluateBSpline2d(c, t) {
|
|
|
1103
1136
|
const djPrev = d[j - 1];
|
|
1104
1137
|
dj[0] = (1 - alpha) * djPrev[0] + alpha * dj[0];
|
|
1105
1138
|
dj[1] = (1 - alpha) * djPrev[1] + alpha * dj[1];
|
|
1139
|
+
dj[2] = (1 - alpha) * djPrev[2] + alpha * dj[2];
|
|
1106
1140
|
}
|
|
1107
1141
|
}
|
|
1108
|
-
|
|
1142
|
+
const res = d[p];
|
|
1143
|
+
const w = res[2];
|
|
1144
|
+
return w !== 0 ? [res[0] / w, res[1] / w] : [res[0], res[1]];
|
|
1109
1145
|
}
|
|
1110
1146
|
//# sourceMappingURL=curve2d.js.map
|