@faicad/faijs 0.18.3 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/api-namespace.d.ts.map +1 -1
- package/dist/api/api-namespace.js +4 -1
- package/dist/api/api-namespace.js.map +1 -1
- package/dist/api/brep-mirror/joinery-brep.d.ts +1 -1
- package/dist/api/brep-mirror/joinery-brep.d.ts.map +1 -1
- package/dist/api/brep-mirror/joinery-brep.js +22 -20
- package/dist/api/brep-mirror/joinery-brep.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/index.d.ts +4 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/knurl.d.ts.map +1 -1
- package/dist/api/knurl.js +1 -0
- package/dist/api/knurl.js.map +1 -1
- package/dist/api/primitives.d.ts +4 -3
- package/dist/api/primitives.d.ts.map +1 -1
- package/dist/api/primitives.js +9 -3
- package/dist/api/primitives.js.map +1 -1
- package/dist/api/profile.d.ts +34 -5
- package/dist/api/profile.d.ts.map +1 -1
- package/dist/api/profile.js +168 -186
- package/dist/api/profile.js.map +1 -1
- package/dist/api/punch-hole.d.ts +77 -0
- package/dist/api/punch-hole.d.ts.map +1 -0
- package/dist/api/punch-hole.js +207 -0
- package/dist/api/punch-hole.js.map +1 -0
- package/dist/api/sketch-on-face.d.ts +85 -0
- package/dist/api/sketch-on-face.d.ts.map +1 -0
- package/dist/api/sketch-on-face.js +136 -0
- package/dist/api/sketch-on-face.js.map +1 -0
- package/dist/api/sketch-on-plane.d.ts +87 -0
- package/dist/api/sketch-on-plane.d.ts.map +1 -0
- package/dist/api/sketch-on-plane.js +106 -0
- package/dist/api/sketch-on-plane.js.map +1 -0
- 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/transform.d.ts +5 -5
- package/dist/api/transform.d.ts.map +1 -1
- package/dist/api/transform.js +12 -10
- package/dist/api/transform.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/boolean/csg-backend.d.ts +6 -6
- package/dist/boolean/csg-backend.d.ts.map +1 -1
- package/dist/boolean/csg-backend.js +9 -9
- package/dist/boolean/csg-backend.js.map +1 -1
- package/dist/boolean/csg-core.d.ts +10 -10
- package/dist/boolean/csg-core.d.ts.map +1 -1
- package/dist/boolean/csg-core.js +24 -24
- package/dist/boolean/csg-core.js.map +1 -1
- package/dist/boolean/extrude-helpers.d.ts +8 -8
- package/dist/boolean/extrude-helpers.d.ts.map +1 -1
- package/dist/boolean/extrude-helpers.js +13 -13
- package/dist/boolean/extrude-helpers.js.map +1 -1
- package/dist/brep/brep-ops.d.ts +24 -10
- package/dist/brep/brep-ops.d.ts.map +1 -1
- package/dist/brep/brep-ops.js +46 -18
- package/dist/brep/brep-ops.js.map +1 -1
- package/dist/brep/brep-topology.d.ts.map +1 -1
- package/dist/brep/brep-topology.js +3 -1
- package/dist/brep/brep-topology.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 +335 -0
- package/dist/brep/export/export-model.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/brepkit-kernel/brepkitKernel.d.ts.map +1 -1
- package/dist/brepkit-kernel/brepkitKernel.js +4 -2
- package/dist/brepkit-kernel/brepkitKernel.js.map +1 -1
- package/dist/browser-host/csg-worker-protocol.d.ts +3 -3
- package/dist/browser-host/csg-worker-protocol.d.ts.map +1 -1
- package/dist/browser-host/csg-worker-protocol.js.map +1 -1
- package/dist/browser-host/csg-worker.js +3 -3
- package/dist/browser-host/csg-worker.js.map +1 -1
- package/dist/browser-host/inline-csg-backend.d.ts +3 -3
- package/dist/browser-host/inline-csg-backend.d.ts.map +1 -1
- package/dist/browser-host/inline-csg-backend.js +3 -3
- package/dist/browser-host/inline-csg-backend.js.map +1 -1
- package/dist/browser-host/worker-csg-backend.d.ts +3 -3
- package/dist/browser-host/worker-csg-backend.d.ts.map +1 -1
- package/dist/browser-host/worker-csg-backend.js.map +1 -1
- package/dist/cad-runtime/direct-executor.d.ts +4 -0
- package/dist/cad-runtime/direct-executor.d.ts.map +1 -1
- package/dist/cad-runtime/direct-executor.js +17 -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/runtime.d.ts +24 -1
- package/dist/cad-runtime/runtime.d.ts.map +1 -1
- package/dist/cad-runtime/runtime.js +53 -3
- package/dist/cad-runtime/runtime.js.map +1 -1
- package/dist/define-op.d.ts +22 -0
- package/dist/define-op.d.ts.map +1 -1
- package/dist/define-op.js +15 -0
- 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 +46 -0
- package/dist/geometry2d/adapt.d.ts.map +1 -0
- package/dist/geometry2d/adapt.js +41 -0
- package/dist/geometry2d/adapt.js.map +1 -0
- package/dist/geometry2d/bbox2d.d.ts +82 -0
- package/dist/geometry2d/bbox2d.d.ts.map +1 -0
- package/dist/geometry2d/bbox2d.js +123 -0
- package/dist/geometry2d/bbox2d.js.map +1 -0
- package/dist/geometry2d/blueprint-sketcher.d.ts +27 -0
- package/dist/geometry2d/blueprint-sketcher.d.ts.map +1 -0
- package/dist/geometry2d/blueprint-sketcher.js +29 -0
- package/dist/geometry2d/blueprint-sketcher.js.map +1 -0
- package/dist/geometry2d/blueprint.d.ts +102 -0
- package/dist/geometry2d/blueprint.d.ts.map +1 -0
- package/dist/geometry2d/blueprint.js +225 -0
- package/dist/geometry2d/blueprint.js.map +1 -0
- package/dist/geometry2d/blueprints.d.ts +58 -0
- package/dist/geometry2d/blueprints.d.ts.map +1 -0
- package/dist/geometry2d/blueprints.js +72 -0
- package/dist/geometry2d/blueprints.js.map +1 -0
- package/dist/geometry2d/bridge/lift-on-plane.d.ts +50 -0
- package/dist/geometry2d/bridge/lift-on-plane.d.ts.map +1 -0
- package/dist/geometry2d/bridge/lift-on-plane.js +78 -0
- package/dist/geometry2d/bridge/lift-on-plane.js.map +1 -0
- package/dist/geometry2d/bridge/on-surface.d.ts +98 -0
- package/dist/geometry2d/bridge/on-surface.d.ts.map +1 -0
- package/dist/geometry2d/bridge/on-surface.js +94 -0
- package/dist/geometry2d/bridge/on-surface.js.map +1 -0
- package/dist/geometry2d/bridge/plane.d.ts +69 -0
- package/dist/geometry2d/bridge/plane.d.ts.map +1 -0
- package/dist/geometry2d/bridge/plane.js +96 -0
- package/dist/geometry2d/bridge/plane.js.map +1 -0
- package/dist/geometry2d/canned-blueprints.d.ts +44 -0
- package/dist/geometry2d/canned-blueprints.d.ts.map +1 -0
- package/dist/geometry2d/canned-blueprints.js +94 -0
- package/dist/geometry2d/canned-blueprints.js.map +1 -0
- package/dist/geometry2d/compound-blueprint.d.ts +72 -0
- package/dist/geometry2d/compound-blueprint.d.ts.map +1 -0
- package/dist/geometry2d/compound-blueprint.js +95 -0
- package/dist/geometry2d/compound-blueprint.js.map +1 -0
- package/dist/geometry2d/curve2d.d.ts +298 -0
- package/dist/geometry2d/curve2d.d.ts.map +1 -0
- package/dist/geometry2d/curve2d.js +1110 -0
- package/dist/geometry2d/curve2d.js.map +1 -0
- package/dist/geometry2d/index.d.ts +22 -0
- package/dist/geometry2d/index.d.ts.map +1 -0
- package/dist/geometry2d/index.js +21 -0
- package/dist/geometry2d/index.js.map +1 -0
- package/dist/geometry2d/organise.d.ts +28 -0
- package/dist/geometry2d/organise.d.ts.map +1 -0
- package/dist/geometry2d/organise.js +108 -0
- package/dist/geometry2d/organise.js.map +1 -0
- package/dist/geometry2d/pen-sketcher.d.ts +365 -0
- package/dist/geometry2d/pen-sketcher.d.ts.map +1 -0
- package/dist/geometry2d/pen-sketcher.js +520 -0
- package/dist/geometry2d/pen-sketcher.js.map +1 -0
- package/dist/geometry2d/point.d.ts +44 -0
- package/dist/geometry2d/point.d.ts.map +1 -0
- package/dist/geometry2d/point.js +57 -0
- package/dist/geometry2d/point.js.map +1 -0
- package/dist/geometry2d/svg-ellipse.d.ts +74 -0
- package/dist/geometry2d/svg-ellipse.d.ts.map +1 -0
- package/dist/geometry2d/svg-ellipse.js +163 -0
- package/dist/geometry2d/svg-ellipse.js.map +1 -0
- package/dist/lang/code-to-args.d.ts +29 -3
- package/dist/lang/code-to-args.d.ts.map +1 -1
- package/dist/lang/code-to-args.js +41 -2
- 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/symbol-table.generated.d.ts +3 -0
- package/dist/lang/symbol-table.generated.d.ts.map +1 -1
- package/dist/lang/symbol-table.generated.js +3 -0
- package/dist/lang/symbol-table.generated.js.map +1 -1
- package/dist/mesh/io.d.ts +62 -9
- package/dist/mesh/io.d.ts.map +1 -1
- package/dist/mesh/io.js +124 -17
- package/dist/mesh/io.js.map +1 -1
- package/dist/mesh/threemf-loader.d.ts +15 -0
- package/dist/mesh/threemf-loader.d.ts.map +1 -0
- package/dist/mesh/threemf-loader.js +163 -0
- package/dist/mesh/threemf-loader.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 +2 -2
- package/dist/mesh/types.d.ts.map +1 -1
- package/dist/mesh/types.js.map +1 -1
- package/dist/node-host/cli.d.ts.map +1 -1
- package/dist/node-host/cli.js +53 -26
- package/dist/node-host/cli.js.map +1 -1
- package/dist/occt-kernel/occtKernel.d.ts.map +1 -1
- package/dist/occt-kernel/occtKernel.js +4 -2
- package/dist/occt-kernel/occtKernel.js.map +1 -1
- package/dist/occt-kernel/topologyExt.d.ts.map +1 -1
- package/dist/occt-kernel/topologyExt.js +4 -1
- package/dist/occt-kernel/topologyExt.js.map +1 -1
- package/dist/runtime-state.d.ts +18 -0
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +23 -0
- package/dist/runtime-state.js.map +1 -1
- package/dist/sdk.d.ts +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1 -1
- package/dist/sdk.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/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/package.json +19 -2
package/dist/api/knurl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knurl.js","sourceRoot":"","sources":["../../src/api/knurl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE/C;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA+B;IAC/D,oBAAoB,CAAC,MAAM,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAA;AAC7E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;IAoBI;AACJ,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,KAAK,EAAE,KAAY,EAAE,MAA+B,EAAE,EAAE;QAC5D,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;QAC/D,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACzB,+CAA+C;QAC/C,iEAAiE;QACjE,MAAM,CAAC,SAAS,CAAC,GAAG,mBAAmB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;QAChD,OAAO,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE;YAC1B,IAAI,EAAE;gBACJ,MAAM,EAAG,MAAM,CAAC,UAA+B,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;gBAC5E,MAAM,EAAG,MAAM,CAAC,UAA+B,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;aAC7D;YACD,kBAAkB,EAAG,MAAM,CAAC,kBAAyC,IAAI,GAAG;YAC5E,uBAAuB,EAAG,MAAM,CAAC,uBAA+C,IAAI,KAAK;YACzF,iBAAiB,EAAG,MAAM,CAAC,iBAAwC,IAAI,GAAG;YAC1E,WAAW,EAAG,MAAM,CAAC,WAAkC,IAAI,IAAI;YAC/D,WAAW,EAAG,MAAM,CAAC,WAAkC,IAAI,IAAI;YAC/D,gBAAgB,EAAG,MAAM,CAAC,gBAAuC,IAAI,CAAC;SACvE,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,2CAA2C,EAAgB;CACjG,CAAC,CAAA","sourcesContent":["/**\n * stdlib knurl — 滚花库函数(mesh-only)\n *\n *\n * knurl 无 BREP 实现(mesh-only)——dispatchPath 在 brep 模式下调用前抛错。\n * part-brep-lost 事件由引擎统一发(P4,库不再 emit)。\n */\n\nimport type { Shape, Vec3 } from '../mesh/types'\nimport { cad } from '../mesh'\nimport { reconcileBrepInputs } from './reconcile'\nimport { defineOp } from '../sdk'\nimport type { Provenance } from '../topology/naming/lineage'\nimport { assertPositiveNumber } from './assert'\n\n/**\n * Validate knurl parameters: `knurlTextureHeight` must be a positive number.\n * @param params - the raw knurl operation parameters.\n */\nexport function assertKnurlParams(params: Record<string, unknown>): void {\n assertPositiveNumber(params.knurlTextureHeight, 'knurl.knurlTextureHeight')\n}\n\n/**\n * 施加滚花(顶点位移,非布尔)。mesh-only。\n * @group 特征\n * @inputs 1\n * @async true\n * @qual warn\n * @name knurl\n * @note knurl 无 BREP 实现(mesh-only),本质是顶点位移(网格操作),网格参数可接受;brep 模式下调用前抛 BrepUnsupportedError。面锚定建议用几何引用。\n * @returns Shape 滚花后的几何。\n * @param input - 目标几何。type:Shape required:true\n * @param params.knurlTextureHeight - 纹路高度(mm)。type:number 默认 0.5\n * @param params.knurlScaleU - 纹路 U 向频率。type:number 默认 0.15\n * @param params.knurlScaleV - 纹路 V 向频率。type:number 默认 0.15\n * @param params.knurlInvertDisplacement - 反向位移。type:boolean 默认 false\n * @param params.knurlRefineLength - 细分长度(mm)。type:number 默认 1.0\n * @param params.knurlMappingMode - UV 映射模式。type:number 默认 5\n * @param params.faceCenter - 面锚点中心。type:[x,y,z] 默认 bboxCenter\n * @param params.faceNormal - 面法向。type:[x,y,z] 默认 [0,0,1]\n * @example\n * const p = await cad.knurl(part0, { knurlTextureHeight: 0.5, knurlScaleU: 0.15, knurlScaleV: 0.15, knurlInvertDisplacement: false, knurlRefineLength: 1.0, knurlMappingMode: 5 })\n */\nexport const knurl = defineOp({\n mesh: async (input: Shape, params: Record<string, unknown>) => {\n if (!input) throw new Error('[stdlib/knurl] no input geometry')\n assertKnurlParams(params)\n // 断链时刻(用户点名场景):BREP 建模的模型最后做滚花 → BREP 输入必须先归约为\n // 合法 2-manifold 网格再进 mesh 路径(reconcileBrepInputs 对 mesh 侧输入原样透传)\n const [meshInput] = reconcileBrepInputs([input])\n return cad.knurl(meshInput, {\n face: {\n center: (params.faceCenter as Vec3 | undefined) ?? cad.bboxCenter(meshInput),\n normal: (params.faceNormal as Vec3 | undefined) ?? [0, 0, 1],\n },\n knurlTextureHeight: (params.knurlTextureHeight as number | undefined) ?? 0.5,\n knurlInvertDisplacement: (params.knurlInvertDisplacement as boolean | undefined) ?? false,\n knurlRefineLength: (params.knurlRefineLength as number | undefined) ?? 1.0,\n knurlScaleU: (params.knurlScaleU as number | undefined) ?? 0.15,\n knurlScaleV: (params.knurlScaleV as number | undefined) ?? 0.15,\n knurlMappingMode: (params.knurlMappingMode as number | undefined) ?? 5,\n })\n },\n naming: { kind: 'unmodeled', reason: 'knurl is mesh-only, no BREP face identity' } as Provenance,\n})\n"]}
|
|
1
|
+
{"version":3,"file":"knurl.js","sourceRoot":"","sources":["../../src/api/knurl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE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iBAAiB,EAAE,QAAQ,EAAE;IACxE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,2CAA2C,EAAgB;CACjG,CAAC,CAAA","sourcesContent":["/**\n * stdlib knurl — 滚花库函数(mesh-only)\n *\n *\n * knurl 无 BREP 实现(mesh-only)——dispatchPath 在 brep 模式下调用前抛错。\n * part-brep-lost 事件由引擎统一发(P4,库不再 emit)。\n */\n\nimport type { Shape, Vec3 } from '../mesh/types'\nimport { cad } from '../mesh'\nimport { reconcileBrepInputs } from './reconcile'\nimport { defineOp } from '../sdk'\nimport type { Provenance } from '../topology/naming/lineage'\nimport { assertPositiveNumber } from './assert'\n\n/**\n * Validate knurl parameters: `knurlTextureHeight` must be a positive number.\n * @param params - the raw knurl operation parameters.\n */\nexport function assertKnurlParams(params: Record<string, unknown>): void {\n assertPositiveNumber(params.knurlTextureHeight, 'knurl.knurlTextureHeight')\n}\n\n/**\n * 施加滚花(顶点位移,非布尔)。mesh-only。\n * @group 特征\n * @inputs 1\n * @async true\n * @qual warn\n * @name knurl\n * @note knurl 无 BREP 实现(mesh-only),本质是顶点位移(网格操作),网格参数可接受;brep 模式下调用前抛 BrepUnsupportedError。面锚定建议用几何引用。\n * @returns Shape 滚花后的几何。\n * @param input - 目标几何。type:Shape required:true\n * @param params.knurlTextureHeight - 纹路高度(mm)。type:number 默认 0.5\n * @param params.knurlScaleU - 纹路 U 向频率。type:number 默认 0.15\n * @param params.knurlScaleV - 纹路 V 向频率。type:number 默认 0.15\n * @param params.knurlInvertDisplacement - 反向位移。type:boolean 默认 false\n * @param params.knurlRefineLength - 细分长度(mm)。type:number 默认 1.0\n * @param params.knurlMappingMode - UV 映射模式。type:number 默认 5\n * @param params.faceCenter - 面锚点中心。type:[x,y,z] 默认 bboxCenter\n * @param params.faceNormal - 面法向。type:[x,y,z] 默认 [0,0,1]\n * @example\n * const p = await cad.knurl(part0, { knurlTextureHeight: 0.5, knurlScaleU: 0.15, knurlScaleV: 0.15, knurlInvertDisplacement: false, knurlRefineLength: 1.0, knurlMappingMode: 5 })\n */\nexport const knurl = defineOp({\n mesh: async (input: Shape, params: Record<string, unknown>) => {\n if (!input) throw new Error('[stdlib/knurl] no input geometry')\n assertKnurlParams(params)\n // 断链时刻(用户点名场景):BREP 建模的模型最后做滚花 → BREP 输入必须先归约为\n // 合法 2-manifold 网格再进 mesh 路径(reconcileBrepInputs 对 mesh 侧输入原样透传)\n const [meshInput] = reconcileBrepInputs([input])\n return cad.knurl(meshInput, {\n face: {\n center: (params.faceCenter as Vec3 | undefined) ?? cad.bboxCenter(meshInput),\n normal: (params.faceNormal as Vec3 | undefined) ?? [0, 0, 1],\n },\n knurlTextureHeight: (params.knurlTextureHeight as number | undefined) ?? 0.5,\n knurlInvertDisplacement: (params.knurlInvertDisplacement as boolean | undefined) ?? false,\n knurlRefineLength: (params.knurlRefineLength as number | undefined) ?? 1.0,\n knurlScaleU: (params.knurlScaleU as number | undefined) ?? 0.15,\n knurlScaleV: (params.knurlScaleV as number | undefined) ?? 0.15,\n knurlMappingMode: (params.knurlMappingMode as number | undefined) ?? 5,\n })\n },\n paramDims: { knurlTextureHeight: 'length', knurlRefineLength: 'length' },\n naming: { kind: 'unmodeled', reason: 'knurl is mesh-only, no BREP face identity' } as Provenance,\n})\n"]}
|
package/dist/api/primitives.d.ts
CHANGED
|
@@ -56,10 +56,11 @@ export declare function assertWedgeParams(params: Record<string, unknown>): void
|
|
|
56
56
|
* @param params.centered - 无 at 时是否居中到原点(type:boolean 默认 false,角点在原点)。
|
|
57
57
|
* @param params.segments - 细分度(影响三角化)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)
|
|
58
58
|
* @example
|
|
59
|
-
* const part0 = cad.box(10, 20, 30)
|
|
60
|
-
* const part1 = cad.box(30, 20, 10, { centered: true, at: [1, 2, 3], segments: 64 })
|
|
59
|
+
* const part0 = cad.box(10 * MM, 20 * MM, 30 * MM)
|
|
60
|
+
* const part1 = cad.box(30 * MM, 20 * MM, 10 * MM, { centered: true, at: [1, 2, 3], segments: 64 })
|
|
61
61
|
*
|
|
62
|
-
* 位置原生(§4.1/§6.2):`box(width, depth, height)` 与 `box(10, 20, 30, {centered:true})`
|
|
62
|
+
* 位置原生(§4.1/§6.2):`box(width, depth, height)` 与 `box(10 * MM, 20 * MM, 30 * MM, {centered:true})`
|
|
63
|
+
* 有量纲位必须写单位字面量(基准单位亦然,`10` 裸数字被 D8 R2 拒)。
|
|
63
64
|
* 归一到同一对象(D11 位置→对象 + 尾参 options 合并)。旧 `{ size }` 对象形态已废弃(裁决 3),
|
|
64
65
|
* 传入会抛 `E_ARGS_FORM`(错误提示 ≠ 兼容,§4.1)。
|
|
65
66
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/api/primitives.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAgB1C;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAUrE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAExE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAS1E;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAUtE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAKvE;AAmBD
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/api/primitives.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAgB1C;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAUrE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAExE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAS1E;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAUtE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAKvE;AAmBD;;;;;;;;;;;;;;;;;;;;;;KAsBK;AACL,eAAO,MAAM,GAAG;;CAwBd,CAAA;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM;;CAgBjB,CAAA;AAWF;;;;;;;;;;;;;;;;;;;;;;IAsBI;AACJ,eAAO,MAAM,QAAQ;;CAgBnB,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;IAsBI;AACJ,eAAO,MAAM,IAAI;;CAuBf,CAAA;AAEF;;;;;;;;;;;;;;;;IAgBI;AACJ,eAAO,MAAM,KAAK;;CAchB,CAAA"}
|
package/dist/api/primitives.js
CHANGED
|
@@ -110,10 +110,11 @@ function primitiveBrep(op, params) {
|
|
|
110
110
|
* @param params.centered - 无 at 时是否居中到原点(type:boolean 默认 false,角点在原点)。
|
|
111
111
|
* @param params.segments - 细分度(影响三角化)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)
|
|
112
112
|
* @example
|
|
113
|
-
* const part0 = cad.box(10, 20, 30)
|
|
114
|
-
* const part1 = cad.box(30, 20, 10, { centered: true, at: [1, 2, 3], segments: 64 })
|
|
113
|
+
* const part0 = cad.box(10 * MM, 20 * MM, 30 * MM)
|
|
114
|
+
* const part1 = cad.box(30 * MM, 20 * MM, 10 * MM, { centered: true, at: [1, 2, 3], segments: 64 })
|
|
115
115
|
*
|
|
116
|
-
* 位置原生(§4.1/§6.2):`box(width, depth, height)` 与 `box(10, 20, 30, {centered:true})`
|
|
116
|
+
* 位置原生(§4.1/§6.2):`box(width, depth, height)` 与 `box(10 * MM, 20 * MM, 30 * MM, {centered:true})`
|
|
117
|
+
* 有量纲位必须写单位字面量(基准单位亦然,`10` 裸数字被 D8 R2 拒)。
|
|
117
118
|
* 归一到同一对象(D11 位置→对象 + 尾参 options 合并)。旧 `{ size }` 对象形态已废弃(裁决 3),
|
|
118
119
|
* 传入会抛 `E_ARGS_FORM`(错误提示 ≠ 兼容,§4.1)。
|
|
119
120
|
*/
|
|
@@ -139,6 +140,7 @@ export const box = defineOp({
|
|
|
139
140
|
// D11 位置→对象(§4.1/§6.2):三个标量装箱成 { width, depth, height },尾参
|
|
140
141
|
// options 经 dual-form-args 的尾参合并(§6.2)并入。
|
|
141
142
|
slotMap: { keys: ['width', 'depth', 'height'] },
|
|
143
|
+
paramDims: { width: 'length', depth: 'length', height: 'length' },
|
|
142
144
|
naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'front' }, { kind: 'semantic', name: 'back' }, { kind: 'semantic', name: 'left' }, { kind: 'semantic', name: 'right' }] } },
|
|
143
145
|
});
|
|
144
146
|
/**
|
|
@@ -172,6 +174,7 @@ export const sphere = defineOp({
|
|
|
172
174
|
// D11: `sphere(10)` == `sphere({ radius: 10 })`; 尾参 options({at, segments})
|
|
173
175
|
// 经 dual-form-args 的尾参合并规则归一(裁决 4,§6.2)。
|
|
174
176
|
slotMap: { keys: ['radius'] },
|
|
177
|
+
paramDims: { radius: 'length' },
|
|
175
178
|
naming: { kind: 'unmodeled', reason: 'sphere face vocabulary pending Phase 3' },
|
|
176
179
|
});
|
|
177
180
|
/**
|
|
@@ -220,6 +223,7 @@ export const cylinder = defineOp({
|
|
|
220
223
|
// D11(§4.1/§6.2):`cylinder(5, 40)` 两个标量装箱成 { radius, height };尾参 options
|
|
221
224
|
// 经 dual-form-args 尾参合并并入。
|
|
222
225
|
slotMap: { keys: ['radius', 'height'] },
|
|
226
|
+
paramDims: { radius: 'length', height: 'length' },
|
|
223
227
|
naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'lateral' }] } },
|
|
224
228
|
});
|
|
225
229
|
/**
|
|
@@ -266,6 +270,7 @@ export const cone = defineOp({
|
|
|
266
270
|
// D11(§4.1/§6.2): `cone(10, 4, 30)` 三个标量装箱成 { radiusBottom, radiusTop, height }。
|
|
267
271
|
// 尾参 options({at, centered, segments})经 dual-form-args 尾参合并并入。
|
|
268
272
|
slotMap: { keys: ['radiusBottom', 'radiusTop', 'height'] },
|
|
273
|
+
paramDims: { radiusBottom: 'length', radiusTop: 'length', height: 'length' },
|
|
269
274
|
naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'lateral' }] } },
|
|
270
275
|
});
|
|
271
276
|
/**
|
|
@@ -297,6 +302,7 @@ export const wedge = defineOp({
|
|
|
297
302
|
},
|
|
298
303
|
// D11: `wedge(30, 20, 45, 10)` == `wedge({ width: 30, height: 20, angle: 45, length: 10 })`.
|
|
299
304
|
slotMap: { keys: ['width', 'height', 'angle', 'length'] },
|
|
305
|
+
paramDims: { width: 'length', height: 'length', angle: 'angle', length: 'length' },
|
|
300
306
|
naming: { kind: 'unmodeled', reason: 'wedge face vocabulary pending Phase 3' },
|
|
301
307
|
});
|
|
302
308
|
//# sourceMappingURL=primitives.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/api/primitives.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAExE,wDAAwD;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,MAA+B;IAC7D,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,6EAA6E;YAC7E,0EAA0E,CAC3E,CAAA;IACH,CAAC;IACD,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;IAC/C,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;IAC/C,oBAAoB,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA+B;IAChE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M,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;IAgBI;AACJ,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,CAAC,MAA+B,EAAE,EAAE;QACxC,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACzB,OAAO,GAAG,CAAC,KAAK,CAAC,MAAe,CAAC,CAAA;IACnC,CAAC;IACD,IAAI,EAAE,CAAC,MAA+B,EAAE,EAAE;QACxC,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACzB,OAAO,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;IACD,6FAA6F;IAC7F,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE;IACzD,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,uCAAuC,EAAgB;CAC7F,CAAC,CAAA","sourcesContent":["/**\n * stdlib primitives — 基本体创建库函数(box/sphere/cylinder/cone/wedge)\n *\n *\n * dispatchPath 静态判定 brep/mesh,产物经 solid()/fromBrep() 构造器创建。\n */\n\nimport type { Shape } from '../mesh/types'\nimport { clampNRad } from '../mesh/types'\nimport { cad } from '../mesh'\nimport { primitiveToBrepSolid } from '../primitives/brep-primitives'\nimport { solidToShape } from '../brep/brep-ops'\nimport { getCurrentStmt } from '../runtime-state'\nimport { getBrepApi } from '../brep/handle-bridge'\nimport { fromBrep } from '../shape'\nimport { assignRoles } from '../topology/naming/roles'\nimport type { Provenance } from '../topology/naming/lineage'\nimport { asPartName } from '../identity'\nimport { defineOp } from '../sdk'\nimport { assertPositiveNumber, assertNonNegativeNumber } from './assert'\n\n// ── per-op 参数自校验(Phase 2.2;stdlib 被直接 import 时的防御层) ──\n\n/**\n * Validate box parameters (brepjs contract, §4.1 A 决策): `width`, `depth` and\n * `height` must be positive numbers. The legacy `{ size }` object form is\n * removed — any call still passing `size` throws an explicit `E_ARGS_FORM`\n * error pointing at the new signature (error hint ≠ compatibility).\n * @param params - the raw box operation parameters.\n */\nexport function assertBoxParams(params: Record<string, unknown>): void {\n if (params.size !== undefined) {\n throw new Error(\n '[faijs/args] box: E_ARGS_FORM: the `box({ size })` object form is removed. ' +\n 'box now uses `box(width, depth, height, { at?, centered?, segments? })`.',\n )\n }\n assertPositiveNumber(params.width, 'box.width')\n assertPositiveNumber(params.depth, 'box.depth')\n assertPositiveNumber(params.height, 'box.height')\n}\n\n/**\n * Validate sphere parameters: `radius` must be a positive number.\n * @param params - the raw sphere operation parameters.\n */\nexport function assertSphereParams(params: Record<string, unknown>): void {\n assertPositiveNumber(params.radius, 'sphere.radius')\n}\n\n/**\n * Validate cylinder parameters (brepjs contract, §4.3 A 决策): `radius` and\n * `height` must be positive. The legacy `{ center }` object key is removed — any\n * call still passing `center` throws an explicit `E_ARGS_FORM` error pointing at\n * the new signature (error hint ≠ compatibility, 裁决 3).\n * @param params - the raw cylinder operation parameters.\n */\nexport function assertCylinderParams(params: Record<string, unknown>): void {\n if (params.center !== undefined || params.size !== undefined) {\n throw new Error(\n '[faijs/args] cylinder: E_ARGS_FORM: the legacy object form is removed. ' +\n 'cylinder now uses `cylinder(radius, height, { at?, centered?, segments? })`.',\n )\n }\n assertPositiveNumber(params.radius, 'cylinder.radius')\n assertPositiveNumber(params.height, 'cylinder.height')\n}\n\n/**\n * Validate cone parameters (brepjs contract, §4.1 P 决策): `radiusBottom` and\n * `height` must be positive, `radiusTop` must be non-negative. The legacy\n * `{ center }` object key is removed — any call still passing `center` throws an\n * explicit `E_ARGS_FORM` error pointing at the new signature (error hint ≠\n * compatibility, 裁决 3).\n * @param params - the raw cone operation parameters.\n */\nexport function assertConeParams(params: Record<string, unknown>): void {\n if (params.center !== undefined || params.size !== undefined) {\n throw new Error(\n '[faijs/args] cone: E_ARGS_FORM: the legacy object form is removed. ' +\n 'cone now uses `cone(bottomRadius, topRadius, height, { at?, centered?, segments? })`.',\n )\n }\n assertPositiveNumber(params.radiusBottom, 'cone.radiusBottom')\n assertNonNegativeNumber(params.radiusTop, 'cone.radiusTop')\n assertPositiveNumber(params.height, 'cone.height')\n}\n\n/**\n * Validate wedge parameters: `width`, `height`, `angle`, and `length` must be\n * positive numbers.\n * @param params - the raw wedge operation parameters.\n */\nexport function assertWedgeParams(params: Record<string, unknown>): void {\n assertPositiveNumber(params.width, 'wedge.width')\n assertPositiveNumber(params.height, 'wedge.height')\n assertPositiveNumber(params.angle, 'wedge.angle')\n assertPositiveNumber(params.length, 'wedge.length')\n}\n\n/** BREP 路径:OCCT 精确构造 + 三角化 + fromBrep 登记(基本体无面演化;链根建 roleTable)。 */\nfunction primitiveBrep(op: string, params: Record<string, unknown>): Shape {\n const kernel = getBrepApi()\n const type = op === 'box' ? 'cube' : op\n const result = primitiveToBrepSolid(kernel, type as 'cube' | 'sphere' | 'cylinder' | 'cone' | 'wedge', params as never)\n // §3.2:链根建表——语义命名器按 op 类型给面命名(semantic 'top'/'lateral' 等,\n // Phase 1.7 已删 'box:' 前缀与位置兜底)。\n // Phase 1.6:origin 用链根语句的 StmtId(当前语句 id,§2.2/§4.1)——变量名会被\n // 改名/复用,StmtId 全局唯一,保证多个同类型 primitive 不撞 origin。\n const origin = String(getCurrentStmt()?.id ?? op)\n const roles = assignRoles(kernel, result.solid, op)\n return fromBrep(\n solidToShape(kernel, result.solid, clampNRad((params.nRad ?? params.segments) as number)),\n { solid: result.solid, roleTable: new Map([[asPartName(origin), roles]]) },\n )\n}\n\n/**\n * 创建长方体(brepjs 契约,§4.1 A 决策)。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name box\n * @returns Shape 长方体几何,可作为后续 op 的输入。\n * @param params.width - X 方向边长(mm)。type:number required:true\n * @param params.depth - Y 方向边长(mm)。type:number required:true\n * @param params.height - Z 方向边长(mm)。type:number required:true\n * @param params.at - 中心点(CENTER 语义,优先于 centered)。type:[x,y,z] 可选\n * @param params.centered - 无 at 时是否居中到原点(type:boolean 默认 false,角点在原点)。\n * @param params.segments - 细分度(影响三角化)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)\n * @example\n * const part0 = cad.box(10, 20, 30)\n * const part1 = cad.box(30, 20, 10, { centered: true, at: [1, 2, 3], segments: 64 })\n *\n * 位置原生(§4.1/§6.2):`box(width, depth, height)` 与 `box(10, 20, 30, {centered:true})`\n * 归一到同一对象(D11 位置→对象 + 尾参 options 合并)。旧 `{ size }` 对象形态已废弃(裁决 3),\n * 传入会抛 `E_ARGS_FORM`(错误提示 ≠ 兼容,§4.1)。\n */\nexport const box = defineOp({\n name: 'box',\n mesh: (params: Record<string, unknown>) => {\n assertBoxParams(params)\n return cad.box(params as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertBoxParams(params)\n return primitiveBrep('box', params)\n },\n // schema feeds codegen/UI parameter panels.\n schema: {\n width: 'number',\n depth: 'number',\n height: 'number',\n at: 'vec3?',\n centered: 'boolean?',\n segments: 'number?',\n },\n // D11 位置→对象(§4.1/§6.2):三个标量装箱成 { width, depth, height },尾参\n // options 经 dual-form-args 的尾参合并(§6.2)并入。\n slotMap: { keys: ['width', 'depth', 'height'] },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'front' }, { kind: 'semantic', name: 'back' }, { kind: 'semantic', name: 'left' }, { kind: 'semantic', name: 'right' }] } } as Provenance,\n})\n\n/**\n * 创建球体。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name sphere\n * @returns Shape 球体几何,可作为后续 op 的输入。\n * @param params.radius - 半径(mm)。type:number required:true\n * @param params.segments - 细分度(影响面数)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)\n * @param params.center - 球心位置(at 的同义别名)。type:[x,y,z] 默认 [0,0,0](原点)。\n * @param params.at - 球心位置(center 的同义别名,brepjs 契约;裁决 4 双形态合法)。\n * @example\n * const r = cad.sphere({ radius: 10 })\n * const r = cad.sphere(10, { at: [0, 0, 10], segments: 64 })\n * const r = cad.sphere({ radius: 10, segments: 64, center: [0,0,10] })\n */\nexport const sphere = defineOp({\n name: 'sphere',\n mesh: (params: Record<string, unknown>) => {\n assertSphereParams(params)\n return cad.sphere(centerParams(params) as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertSphereParams(params)\n return primitiveBrep('sphere', centerParams(params))\n },\n schema: { radius: 'number', segments: 'number?', center: 'vec3?', at: 'vec3?' },\n // D11: `sphere(10)` == `sphere({ radius: 10 })`; 尾参 options({at, segments})\n // 经 dual-form-args 的尾参合并规则归一(裁决 4,§6.2)。\n slotMap: { keys: ['radius'] },\n naming: { kind: 'unmodeled', reason: 'sphere face vocabulary pending Phase 3' } as Provenance,\n})\n\n/**\n * 位置归一:把 brepjs 契约的 `at`(= faijs 的 `center`,球心语义)归一为一个\n * `center` 输入,mesh/brep 两条消费路径共用(裁决 1/4,§4.2)。\n */\nfunction centerParams(params: Record<string, unknown>): Record<string, unknown> {\n if (params.at !== undefined) return { ...params, center: params.at }\n return params\n}\n\n/**\n * 创建圆柱体(brepjs 契约,§4.3 A 决策)。\n * 锚点:`at` 是**底面轴心**(BASE 语义,默认 [0,0,0],底面在原点、+Z 延伸);`centered:true`\n * 指底面落到 −h/2(无 at 时居中到原点;与 `at` 同给时以 `at` 为中心)。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name cylinder\n * @returns Shape 圆柱体几何,可作为后续 op 的输入。\n * @param params.radius - 底面半径(mm)。type:number required:true\n * @param params.height - 高度(mm),沿 +Z 轴。type:number required:true\n * @param params.at - 底面中心(BASE 语义)。type:[x,y,z] 可选\n * @param params.centered - 是否居中(底面 −h/2;与 at 同给时以 at 为中心)。type:boolean 默认 false\n * @param params.segments - 细分度(影响三角化)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)\n * @example\n * const c = cad.cylinder(5, 40)\n * const c = cad.cylinder(5, 40, { centered: true, at: [0, 0, 20], segments: 64 })\n *\n * 位置原生(§4.1/§6.2):`cylinder(5, 40)` 与 `cylinder(5, 40, {centered:true})`\n * 归一到同一对象(D11 位置→装箱 + 尾参 options 合并)。旧 `{ center }` 对象形态已废弃\n * (裁决 3),传入会抛 `E_ARGS_FORM`(错误提示 ≠ 兼容,§4.3)。\n */\nexport const cylinder = defineOp({\n name: 'cylinder',\n mesh: (params: Record<string, unknown>) => {\n assertCylinderParams(params)\n return cad.cylinder(params as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertCylinderParams(params)\n return primitiveBrep('cylinder', params)\n },\n schema: { radius: 'number', height: 'number', at: 'vec3?', centered: 'boolean?', segments: 'number?' },\n // D11(§4.1/§6.2):`cylinder(5, 40)` 两个标量装箱成 { radius, height };尾参 options\n // 经 dual-form-args 尾参合并并入。\n slotMap: { keys: ['radius', 'height'] },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'lateral' }] } } as Provenance,\n})\n\n/**\n * 创建圆锥体(brepjs 契约,§4.1 P 决策)。radiusTop 等于 radiusBottom 时即圆柱,0 为尖锥。\n * 锚点:`at` 是**底面轴心**(BASE 语义,默认 [0,0,0],底面在原点、+Z 延伸);`centered:true`\n * 指底面落到 −h/2(无 at 时居中到原点;与 `at` 同给时以 `at` 为中心)。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name cone\n * @returns Shape 圆锥体几何,可作为后续 op 的输入。\n * @param params.radiusBottom - 底半径(mm)。type:number required:true\n * @param params.radiusTop - 顶半径(mm),0 为尖锥,非负,等于 radiusBottom 得圆柱。type:number required:true\n * @param params.height - 高度(mm),沿 +Z 轴。type:number required:true\n * @param params.at - 底面轴心(BASE 语义)。type:[x,y,z] 可选\n * @param params.centered - 是否居中(底面 −h/2;与 at 同给时以 at 为中心)。type:boolean 默认 false\n * @param params.segments - 细分度(影响三角化)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)\n * @example\n * const c = cad.cone(10, 4, 30)\n * const c = cad.cone(10, 0, 30, { centered: true, at: [0, 0, 20], segments: 64 })\n * 位置原生(§4.1/§6.2):`cone(10, 4, 30)` 与 `cone(10, 4, 30, { centered: true })`\n * 归一到同一对象(D11 位置→装箱 + 尾参 options 合并)。旧 `{ center }`/`{ size }` 对象形态\n * 已废弃(裁决 3),传入会抛 E_ARGS_FORM(错误提示 ≠ 兼容)。\n */\nexport const cone = defineOp({\n name: 'cone',\n mesh: (params: Record<string, unknown>) => {\n assertConeParams(params)\n return cad.cone(params as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertConeParams(params)\n return primitiveBrep('cone', params)\n },\n schema: {\n radiusBottom: 'number',\n radiusTop: 'number',\n height: 'number',\n at: 'vec3?',\n centered: 'boolean?',\n segments: 'number?',\n },\n // D11(§4.1/§6.2): `cone(10, 4, 30)` 三个标量装箱成 { radiusBottom, radiusTop, height }。\n // 尾参 options({at, centered, segments})经 dual-form-args 尾参合并并入。\n slotMap: { keys: ['radiusBottom', 'radiusTop', 'height'] },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'lateral' }] } } as Provenance,\n})\n\n/**\n * 创建楔形体。唯一契约是 width/height/angle/length(width/height/angle 为正数,length 沿切割方向),\n * 旧文档的 size 形态已废弃,传 { size } 会抛错。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name wedge\n * @note 曾与 UI 面板的 `size` 形态并存并写入文档,但断言层确认唯一合法契约是 width/height/angle/length;传 `{ size }` 直接抛错。已按真源收敛。\n * @returns Shape 楔形体几何,可作为后续 op 的输入。\n * @param params.width - 底面宽度(mm)。type:number required:true\n * @param params.height - 高度(mm)。type:number required:true\n * @param params.angle - 楔形角度(度)。type:number required:true\n * @param params.length - 沿切割方向的长度(mm)。type:number required:true\n * @example\n * const w = cad.wedge({ width: 30, height: 20, angle: 45, length: 10 })\n */\nexport const wedge = defineOp({\n name: 'wedge',\n mesh: (params: Record<string, unknown>) => {\n assertWedgeParams(params)\n return cad.wedge(params as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertWedgeParams(params)\n return primitiveBrep('wedge', params)\n },\n // D11: `wedge(30, 20, 45, 10)` == `wedge({ width: 30, height: 20, angle: 45, length: 10 })`.\n slotMap: { keys: ['width', 'height', 'angle', 'length'] },\n naming: { kind: 'unmodeled', reason: 'wedge face vocabulary pending Phase 3' } as Provenance,\n})\n"]}
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/api/primitives.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAExE,wDAAwD;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,MAA+B;IAC7D,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,6EAA6E;YAC7E,0EAA0E,CAC3E,CAAA;IACH,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Q,EAAE;IAClF,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,uCAAuC,EAAgB;CAC7F,CAAC,CAAA","sourcesContent":["/**\n * stdlib primitives — 基本体创建库函数(box/sphere/cylinder/cone/wedge)\n *\n *\n * dispatchPath 静态判定 brep/mesh,产物经 solid()/fromBrep() 构造器创建。\n */\n\nimport type { Shape } from '../mesh/types'\nimport { clampNRad } from '../mesh/types'\nimport { cad } from '../mesh'\nimport { primitiveToBrepSolid } from '../primitives/brep-primitives'\nimport { solidToShape } from '../brep/brep-ops'\nimport { getCurrentStmt } from '../runtime-state'\nimport { getBrepApi } from '../brep/handle-bridge'\nimport { fromBrep } from '../shape'\nimport { assignRoles } from '../topology/naming/roles'\nimport type { Provenance } from '../topology/naming/lineage'\nimport { asPartName } from '../identity'\nimport { defineOp } from '../sdk'\nimport { assertPositiveNumber, assertNonNegativeNumber } from './assert'\n\n// ── per-op 参数自校验(Phase 2.2;stdlib 被直接 import 时的防御层) ──\n\n/**\n * Validate box parameters (brepjs contract, §4.1 A 决策): `width`, `depth` and\n * `height` must be positive numbers. The legacy `{ size }` object form is\n * removed — any call still passing `size` throws an explicit `E_ARGS_FORM`\n * error pointing at the new signature (error hint ≠ compatibility).\n * @param params - the raw box operation parameters.\n */\nexport function assertBoxParams(params: Record<string, unknown>): void {\n if (params.size !== undefined) {\n throw new Error(\n '[faijs/args] box: E_ARGS_FORM: the `box({ size })` object form is removed. ' +\n 'box now uses `box(width, depth, height, { at?, centered?, segments? })`.',\n )\n }\n assertPositiveNumber(params.width, 'box.width')\n assertPositiveNumber(params.depth, 'box.depth')\n assertPositiveNumber(params.height, 'box.height')\n}\n\n/**\n * Validate sphere parameters: `radius` must be a positive number.\n * @param params - the raw sphere operation parameters.\n */\nexport function assertSphereParams(params: Record<string, unknown>): void {\n assertPositiveNumber(params.radius, 'sphere.radius')\n}\n\n/**\n * Validate cylinder parameters (brepjs contract, §4.3 A 决策): `radius` and\n * `height` must be positive. The legacy `{ center }` object key is removed — any\n * call still passing `center` throws an explicit `E_ARGS_FORM` error pointing at\n * the new signature (error hint ≠ compatibility, 裁决 3).\n * @param params - the raw cylinder operation parameters.\n */\nexport function assertCylinderParams(params: Record<string, unknown>): void {\n if (params.center !== undefined || params.size !== undefined) {\n throw new Error(\n '[faijs/args] cylinder: E_ARGS_FORM: the legacy object form is removed. ' +\n 'cylinder now uses `cylinder(radius, height, { at?, centered?, segments? })`.',\n )\n }\n assertPositiveNumber(params.radius, 'cylinder.radius')\n assertPositiveNumber(params.height, 'cylinder.height')\n}\n\n/**\n * Validate cone parameters (brepjs contract, §4.1 P 决策): `radiusBottom` and\n * `height` must be positive, `radiusTop` must be non-negative. The legacy\n * `{ center }` object key is removed — any call still passing `center` throws an\n * explicit `E_ARGS_FORM` error pointing at the new signature (error hint ≠\n * compatibility, 裁决 3).\n * @param params - the raw cone operation parameters.\n */\nexport function assertConeParams(params: Record<string, unknown>): void {\n if (params.center !== undefined || params.size !== undefined) {\n throw new Error(\n '[faijs/args] cone: E_ARGS_FORM: the legacy object form is removed. ' +\n 'cone now uses `cone(bottomRadius, topRadius, height, { at?, centered?, segments? })`.',\n )\n }\n assertPositiveNumber(params.radiusBottom, 'cone.radiusBottom')\n assertNonNegativeNumber(params.radiusTop, 'cone.radiusTop')\n assertPositiveNumber(params.height, 'cone.height')\n}\n\n/**\n * Validate wedge parameters: `width`, `height`, `angle`, and `length` must be\n * positive numbers.\n * @param params - the raw wedge operation parameters.\n */\nexport function assertWedgeParams(params: Record<string, unknown>): void {\n assertPositiveNumber(params.width, 'wedge.width')\n assertPositiveNumber(params.height, 'wedge.height')\n assertPositiveNumber(params.angle, 'wedge.angle')\n assertPositiveNumber(params.length, 'wedge.length')\n}\n\n/** BREP 路径:OCCT 精确构造 + 三角化 + fromBrep 登记(基本体无面演化;链根建 roleTable)。 */\nfunction primitiveBrep(op: string, params: Record<string, unknown>): Shape {\n const kernel = getBrepApi()\n const type = op === 'box' ? 'cube' : op\n const result = primitiveToBrepSolid(kernel, type as 'cube' | 'sphere' | 'cylinder' | 'cone' | 'wedge', params as never)\n // §3.2:链根建表——语义命名器按 op 类型给面命名(semantic 'top'/'lateral' 等,\n // Phase 1.7 已删 'box:' 前缀与位置兜底)。\n // Phase 1.6:origin 用链根语句的 StmtId(当前语句 id,§2.2/§4.1)——变量名会被\n // 改名/复用,StmtId 全局唯一,保证多个同类型 primitive 不撞 origin。\n const origin = String(getCurrentStmt()?.id ?? op)\n const roles = assignRoles(kernel, result.solid, op)\n return fromBrep(\n solidToShape(kernel, result.solid, clampNRad((params.nRad ?? params.segments) as number)),\n { solid: result.solid, roleTable: new Map([[asPartName(origin), roles]]) },\n )\n}\n\n/**\n * 创建长方体(brepjs 契约,§4.1 A 决策)。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name box\n * @returns Shape 长方体几何,可作为后续 op 的输入。\n * @param params.width - X 方向边长(mm)。type:number required:true\n * @param params.depth - Y 方向边长(mm)。type:number required:true\n * @param params.height - Z 方向边长(mm)。type:number required:true\n * @param params.at - 中心点(CENTER 语义,优先于 centered)。type:[x,y,z] 可选\n * @param params.centered - 无 at 时是否居中到原点(type:boolean 默认 false,角点在原点)。\n * @param params.segments - 细分度(影响三角化)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)\n * @example\n * const part0 = cad.box(10 * MM, 20 * MM, 30 * MM)\n * const part1 = cad.box(30 * MM, 20 * MM, 10 * MM, { centered: true, at: [1, 2, 3], segments: 64 })\n *\n * 位置原生(§4.1/§6.2):`box(width, depth, height)` 与 `box(10 * MM, 20 * MM, 30 * MM, {centered:true})`\n * 有量纲位必须写单位字面量(基准单位亦然,`10` 裸数字被 D8 R2 拒)。\n * 归一到同一对象(D11 位置→对象 + 尾参 options 合并)。旧 `{ size }` 对象形态已废弃(裁决 3),\n * 传入会抛 `E_ARGS_FORM`(错误提示 ≠ 兼容,§4.1)。\n */\nexport const box = defineOp({\n name: 'box',\n mesh: (params: Record<string, unknown>) => {\n assertBoxParams(params)\n return cad.box(params as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertBoxParams(params)\n return primitiveBrep('box', params)\n },\n // schema feeds codegen/UI parameter panels.\n schema: {\n width: 'number',\n depth: 'number',\n height: 'number',\n at: 'vec3?',\n centered: 'boolean?',\n segments: 'number?',\n },\n // D11 位置→对象(§4.1/§6.2):三个标量装箱成 { width, depth, height },尾参\n // options 经 dual-form-args 的尾参合并(§6.2)并入。\n slotMap: { keys: ['width', 'depth', 'height'] },\n paramDims: { width: 'length', depth: 'length', height: 'length' },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'front' }, { kind: 'semantic', name: 'back' }, { kind: 'semantic', name: 'left' }, { kind: 'semantic', name: 'right' }] } } as Provenance,\n})\n\n/**\n * 创建球体。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name sphere\n * @returns Shape 球体几何,可作为后续 op 的输入。\n * @param params.radius - 半径(mm)。type:number required:true\n * @param params.segments - 细分度(影响面数)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)\n * @param params.center - 球心位置(at 的同义别名)。type:[x,y,z] 默认 [0,0,0](原点)。\n * @param params.at - 球心位置(center 的同义别名,brepjs 契约;裁决 4 双形态合法)。\n * @example\n * const r = cad.sphere({ radius: 10 })\n * const r = cad.sphere(10, { at: [0, 0, 10], segments: 64 })\n * const r = cad.sphere({ radius: 10, segments: 64, center: [0,0,10] })\n */\nexport const sphere = defineOp({\n name: 'sphere',\n mesh: (params: Record<string, unknown>) => {\n assertSphereParams(params)\n return cad.sphere(centerParams(params) as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertSphereParams(params)\n return primitiveBrep('sphere', centerParams(params))\n },\n schema: { radius: 'number', segments: 'number?', center: 'vec3?', at: 'vec3?' },\n // D11: `sphere(10)` == `sphere({ radius: 10 })`; 尾参 options({at, segments})\n // 经 dual-form-args 的尾参合并规则归一(裁决 4,§6.2)。\n slotMap: { keys: ['radius'] },\n paramDims: { radius: 'length' },\n naming: { kind: 'unmodeled', reason: 'sphere face vocabulary pending Phase 3' } as Provenance,\n})\n\n/**\n * 位置归一:把 brepjs 契约的 `at`(= faijs 的 `center`,球心语义)归一为一个\n * `center` 输入,mesh/brep 两条消费路径共用(裁决 1/4,§4.2)。\n */\nfunction centerParams(params: Record<string, unknown>): Record<string, unknown> {\n if (params.at !== undefined) return { ...params, center: params.at }\n return params\n}\n\n/**\n * 创建圆柱体(brepjs 契约,§4.3 A 决策)。\n * 锚点:`at` 是**底面轴心**(BASE 语义,默认 [0,0,0],底面在原点、+Z 延伸);`centered:true`\n * 指底面落到 −h/2(无 at 时居中到原点;与 `at` 同给时以 `at` 为中心)。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name cylinder\n * @returns Shape 圆柱体几何,可作为后续 op 的输入。\n * @param params.radius - 底面半径(mm)。type:number required:true\n * @param params.height - 高度(mm),沿 +Z 轴。type:number required:true\n * @param params.at - 底面中心(BASE 语义)。type:[x,y,z] 可选\n * @param params.centered - 是否居中(底面 −h/2;与 at 同给时以 at 为中心)。type:boolean 默认 false\n * @param params.segments - 细分度(影响三角化)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)\n * @example\n * const c = cad.cylinder(5, 40)\n * const c = cad.cylinder(5, 40, { centered: true, at: [0, 0, 20], segments: 64 })\n *\n * 位置原生(§4.1/§6.2):`cylinder(5, 40)` 与 `cylinder(5, 40, {centered:true})`\n * 归一到同一对象(D11 位置→装箱 + 尾参 options 合并)。旧 `{ center }` 对象形态已废弃\n * (裁决 3),传入会抛 `E_ARGS_FORM`(错误提示 ≠ 兼容,§4.3)。\n */\nexport const cylinder = defineOp({\n name: 'cylinder',\n mesh: (params: Record<string, unknown>) => {\n assertCylinderParams(params)\n return cad.cylinder(params as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertCylinderParams(params)\n return primitiveBrep('cylinder', params)\n },\n schema: { radius: 'number', height: 'number', at: 'vec3?', centered: 'boolean?', segments: 'number?' },\n // D11(§4.1/§6.2):`cylinder(5, 40)` 两个标量装箱成 { radius, height };尾参 options\n // 经 dual-form-args 尾参合并并入。\n slotMap: { keys: ['radius', 'height'] },\n paramDims: { radius: 'length', height: 'length' },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'lateral' }] } } as Provenance,\n})\n\n/**\n * 创建圆锥体(brepjs 契约,§4.1 P 决策)。radiusTop 等于 radiusBottom 时即圆柱,0 为尖锥。\n * 锚点:`at` 是**底面轴心**(BASE 语义,默认 [0,0,0],底面在原点、+Z 延伸);`centered:true`\n * 指底面落到 −h/2(无 at 时居中到原点;与 `at` 同给时以 `at` 为中心)。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name cone\n * @returns Shape 圆锥体几何,可作为后续 op 的输入。\n * @param params.radiusBottom - 底半径(mm)。type:number required:true\n * @param params.radiusTop - 顶半径(mm),0 为尖锥,非负,等于 radiusBottom 得圆柱。type:number required:true\n * @param params.height - 高度(mm),沿 +Z 轴。type:number required:true\n * @param params.at - 底面轴心(BASE 语义)。type:[x,y,z] 可选\n * @param params.centered - 是否居中(底面 −h/2;与 at 同给时以 at 为中心)。type:boolean 默认 false\n * @param params.segments - 细分度(影响三角化)。type:number 默认 64(= brepjs standard 等效,P0 §5.0/§5.1)\n * @example\n * const c = cad.cone(10, 4, 30)\n * const c = cad.cone(10, 0, 30, { centered: true, at: [0, 0, 20], segments: 64 })\n * 位置原生(§4.1/§6.2):`cone(10, 4, 30)` 与 `cone(10, 4, 30, { centered: true })`\n * 归一到同一对象(D11 位置→装箱 + 尾参 options 合并)。旧 `{ center }`/`{ size }` 对象形态\n * 已废弃(裁决 3),传入会抛 E_ARGS_FORM(错误提示 ≠ 兼容)。\n */\nexport const cone = defineOp({\n name: 'cone',\n mesh: (params: Record<string, unknown>) => {\n assertConeParams(params)\n return cad.cone(params as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertConeParams(params)\n return primitiveBrep('cone', params)\n },\n schema: {\n radiusBottom: 'number',\n radiusTop: 'number',\n height: 'number',\n at: 'vec3?',\n centered: 'boolean?',\n segments: 'number?',\n },\n // D11(§4.1/§6.2): `cone(10, 4, 30)` 三个标量装箱成 { radiusBottom, radiusTop, height }。\n // 尾参 options({at, centered, segments})经 dual-form-args 尾参合并并入。\n slotMap: { keys: ['radiusBottom', 'radiusTop', 'height'] },\n paramDims: { radiusBottom: 'length', radiusTop: 'length', height: 'length' },\n naming: { kind: 'construct', newFaces: { via: 'explicit', vocab: [{ kind: 'semantic', name: 'top' }, { kind: 'semantic', name: 'bottom' }, { kind: 'semantic', name: 'lateral' }] } } as Provenance,\n})\n\n/**\n * 创建楔形体。唯一契约是 width/height/angle/length(width/height/angle 为正数,length 沿切割方向),\n * 旧文档的 size 形态已废弃,传 { size } 会抛错。\n * @group 创建\n * @inputs 0\n * @async false\n * @qual ok\n * @name wedge\n * @note 曾与 UI 面板的 `size` 形态并存并写入文档,但断言层确认唯一合法契约是 width/height/angle/length;传 `{ size }` 直接抛错。已按真源收敛。\n * @returns Shape 楔形体几何,可作为后续 op 的输入。\n * @param params.width - 底面宽度(mm)。type:number required:true\n * @param params.height - 高度(mm)。type:number required:true\n * @param params.angle - 楔形角度(度)。type:number required:true\n * @param params.length - 沿切割方向的长度(mm)。type:number required:true\n * @example\n * const w = cad.wedge({ width: 30, height: 20, angle: 45, length: 10 })\n */\nexport const wedge = defineOp({\n name: 'wedge',\n mesh: (params: Record<string, unknown>) => {\n assertWedgeParams(params)\n return cad.wedge(params as never)\n },\n brep: (params: Record<string, unknown>) => {\n assertWedgeParams(params)\n return primitiveBrep('wedge', params)\n },\n // D11: `wedge(30, 20, 45, 10)` == `wedge({ width: 30, height: 20, angle: 45, length: 10 })`.\n slotMap: { keys: ['width', 'height', 'angle', 'length'] },\n paramDims: { width: 'length', height: 'length', angle: 'angle', length: 'length' },\n naming: { kind: 'unmodeled', reason: 'wedge face vocabulary pending Phase 3' } as Provenance,\n})\n"]}
|
package/dist/api/profile.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* 在轮廓坐标里预先变换,或由下游特征的 Placement 承担。
|
|
16
16
|
*/
|
|
17
17
|
import type { Shape } from '../mesh/types.js';
|
|
18
|
+
import { Blueprint } from '../geometry2d/blueprint.js';
|
|
18
19
|
/** 直线段(2D,z=0;端点为绝对坐标)。 */
|
|
19
20
|
export interface ProfileLineSeg {
|
|
20
21
|
kind: 'line';
|
|
@@ -45,9 +46,26 @@ export type ProfileSeg = ProfileLineSeg | ProfileArcSeg;
|
|
|
45
46
|
export interface ProfileLoop {
|
|
46
47
|
segments: ProfileSeg[];
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* A 2D contour that is already DRAWN — i.e. `cad.draw`'s product (a
|
|
51
|
+
* `Blueprint`), or an array of them (one per contour).
|
|
52
|
+
*
|
|
53
|
+
* Why the 2D entries accept this: `cad.draw` returns a pure-data contour with no
|
|
54
|
+
* OCCT handle, and without this path NO op can turn it into a Shape. Measured
|
|
55
|
+
* 2026-09-28 — feeding a `cad.draw` product straight to `cad.extrude` fails with
|
|
56
|
+
* `E_BREP_INPUT: argument carries no BREP handle`, and to `cad.sweep` with
|
|
57
|
+
* `INVALID_SHAPE_ID`. The plan's "draw → `sketchOnPlane` → `extrude`" pipeline
|
|
58
|
+
* therefore needs this bridge; `cad.profile` takes it too, because both entries
|
|
59
|
+
* share {@link toContourBlueprints} and a split acceptance rule would be a trap.
|
|
60
|
+
*/
|
|
61
|
+
export type DrawnContours = Blueprint | Blueprint[];
|
|
48
62
|
/** `cad.profile` 参数:轮廓环集合。语义见 {@link buildProfileShape}(嵌套=孔,不相交=独立岛)。 */
|
|
49
63
|
export interface ProfileParams {
|
|
50
|
-
|
|
64
|
+
/**
|
|
65
|
+
* 轮廓来源,两种等价形态:段环数据(`{segments: […]}`)或已绘制轮廓
|
|
66
|
+
* (`cad.draw` 产物 / 其数组)。
|
|
67
|
+
*/
|
|
68
|
+
contours: ProfileLoop[] | DrawnContours;
|
|
51
69
|
/**
|
|
52
70
|
* 产物形态:'face'(默认)构面;'wire' 只交出不带面的最大岛外环 wire(1D 曲线),
|
|
53
71
|
* 供扫掠族(sweep/loft/…)直接作 spine。'wire' 形态丢弃孔环(扫掠脊柱为单闭合轮廓)。
|
|
@@ -55,8 +73,19 @@ export interface ProfileParams {
|
|
|
55
73
|
as?: 'face' | 'wire';
|
|
56
74
|
}
|
|
57
75
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
76
|
+
* Normalize a `contours` argument to `Blueprint[]`.
|
|
77
|
+
*
|
|
78
|
+
* Accepts the segment-loop data form, a single drawn contour, or an array of
|
|
79
|
+
* drawn contours. The two forms are never mixed — a mixed array is a caller bug
|
|
80
|
+
* and is rejected rather than half-interpreted.
|
|
81
|
+
*
|
|
82
|
+
* @param contours - the raw `contours` argument (`ProfileLoop[]` | `Blueprint` | `Blueprint[]`).
|
|
83
|
+
* @returns one `Blueprint` per contour, in input order.
|
|
84
|
+
*/
|
|
85
|
+
export declare function toContourBlueprints(contours: unknown): Blueprint[];
|
|
86
|
+
/**
|
|
87
|
+
* Validate profile parameters: `contours` must be a non-empty contour set —
|
|
88
|
+
* either segment loops (each with at least one segment) or drawn contours.
|
|
60
89
|
* @param params the raw profile operation parameters.
|
|
61
90
|
*/
|
|
62
91
|
export declare function assertProfileParams(params: Record<string, unknown>): void;
|
|
@@ -69,7 +98,7 @@ export declare function assertProfileParams(params: Record<string, unknown>): vo
|
|
|
69
98
|
* (7 面、volume 0)。多岛产物 = compound(每岛一面、各带自己的孔),下游
|
|
70
99
|
* `cad.extrude` 对 compound 输入逐面挤出(kernel MakePrism 收复合形状)。
|
|
71
100
|
*
|
|
72
|
-
* @param params -
|
|
101
|
+
* @param params - 轮廓来源(段环数据或 `cad.draw` 产物)与产物形态。
|
|
73
102
|
* @returns Shape(单岛为 face;多岛为 face 的 compound;`as:'wire'` 为 1D 曲线)。
|
|
74
103
|
*/
|
|
75
104
|
export declare function buildProfileShape(params: ProfileParams): Shape;
|
|
@@ -81,7 +110,7 @@ export declare function buildProfileShape(params: ProfileParams): Shape;
|
|
|
81
110
|
* @qual ok
|
|
82
111
|
* @name profile
|
|
83
112
|
* @returns Shape 平面几何(mesh 三角化 + BREP 句柄);`as:'wire'` 时返回 1D 曲线(kind:'curve')。
|
|
84
|
-
* @param params.contours - 有序 2D 轮廓(线段/圆弧;外环 +
|
|
113
|
+
* @param params.contours - 有序 2D 轮廓(线段/圆弧;外环 + 孔),或已绘制轮廓(`cad.draw` 产物:单个 Blueprint 或其数组)。type:ProfileLoop[]|Blueprint|Blueprint[] required:true
|
|
85
114
|
* @param params.as - 产物形态:'face'(默认)构面;'wire' 只交外环 wire(1D 曲线)。type:'face'|'wire' required:false
|
|
86
115
|
* @example
|
|
87
116
|
* const f = cad.profile({ contours: [{ segments: [{ kind:'line', x1:0,y1:0,x2:10,y2:0 }, ...] }] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/api/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/api/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAO1C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAQnD,2BAA2B;AAC3B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;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