feat: prepare FreeCAD private naming worker linkage
This commit is contained in:
@@ -1324,9 +1324,12 @@ export class BitbybitGeometryRuntime {
|
||||
const stageTransport = input.stages?.length ? {
|
||||
inputs: input.inputs.map((source, index) => ({
|
||||
inputId: source.inputId ?? `${input.operationId}:input:${index}`,
|
||||
objectId: source.objectId,
|
||||
role: source.role,
|
||||
stageId: source.stageId,
|
||||
step: stepByObjectId.get(source.objectId)!.text,
|
||||
objectTag: source.objectTag,
|
||||
namingEvidence: source.namingEvidence,
|
||||
})),
|
||||
stages: input.stages.map((stage) => ({
|
||||
stageId: stage.stageId,
|
||||
@@ -1339,12 +1342,12 @@ export class BitbybitGeometryRuntime {
|
||||
ordinal: stage.ordinal,
|
||||
})),
|
||||
} : {}
|
||||
const captureHistory = (request: Parameters<NativeOcctHistoryCoordinator['capture']>[1]) => nativeHistory.coordinator.capture(nativeHistory.provider, { ...request, ...stageTransport })
|
||||
const mapHistoryRecords = (response: Parameters<typeof mapNativeOcctHistoryRecords>[0], sourceIds: { object: string; tool: string } | Record<string, string>) => mapNativeOcctHistoryRecords(response, sourceIds, input)
|
||||
type NativeStageRequest = Pick<NativeOcctHistoryRequest, 'objectStep'> & Partial<Pick<NativeOcctHistoryRequest, 'toolStep' | 'direction' | 'axisOrigin' | 'angle'>>
|
||||
const finalResultObjectId = () => input.stages?.length
|
||||
? input.stages[input.stages.length - 1].resultObjectId ?? `${input.operationId}:result`
|
||||
: `${input.operationId}:result`
|
||||
const captureHistory = (request: Parameters<NativeOcctHistoryCoordinator['capture']>[1]) => nativeHistory.coordinator.capture(nativeHistory.provider, { ...request, ...stageTransport, resultObjectId: finalResultObjectId(), resultObjectTag: input.resultObjectTag })
|
||||
const mapHistoryRecords = (response: Parameters<typeof mapNativeOcctHistoryRecords>[0], sourceIds: { object: string; tool: string } | Record<string, string>) => mapNativeOcctHistoryRecords(response, sourceIds, input)
|
||||
type NativeStageRequest = Pick<NativeOcctHistoryRequest, 'objectStep'> & Partial<Pick<NativeOcctHistoryRequest, 'toolStep' | 'direction' | 'axisOrigin' | 'angle'>>
|
||||
const namingEvidenceForResponse = (response: NativeOcctHistoryResponse, stageId: string, resultObjectId: string) => response.namingEvidence
|
||||
? assertNativeNamingEvidence({ ...response.namingEvidence, stageId, resultObjectId })
|
||||
: createFinalShapeOnlyNamingEvidence(stageId, resultObjectId)
|
||||
@@ -1358,11 +1361,24 @@ export class BitbybitGeometryRuntime {
|
||||
inputs: NativeTopologyHistoryInput['inputs']
|
||||
request: NativeStageRequest
|
||||
}) => {
|
||||
const transportInputs = stage.inputs.map((source, index) => ({
|
||||
inputId: `${stage.stageId}:input:${index}`,
|
||||
objectId: source.objectId,
|
||||
role: index === 0 ? 'object' : 'tool',
|
||||
stageId: source.stageId,
|
||||
step: index === 0 ? stage.request.objectStep : stage.request.toolStep ?? stage.request.objectStep,
|
||||
objectTag: source.objectTag,
|
||||
namingEvidence: source.namingEvidence,
|
||||
}))
|
||||
const execution = await nativeHistory.coordinator.capture(nativeHistory.provider, {
|
||||
documentId: input.documentId,
|
||||
documentVersion: input.documentVersion,
|
||||
operationId: stage.stageId,
|
||||
operation: stage.operation,
|
||||
resultObjectId: stage.resultObjectId,
|
||||
...(stage.resultObjectId === finalResultObjectId() && input.resultObjectTag !== undefined ? { resultObjectTag: input.resultObjectTag } : {}),
|
||||
inputs: transportInputs,
|
||||
stages: [{ stageId: stage.stageId, operation: stage.operation, inputIds: transportInputs.map(({ inputId }) => inputId), ordinal: stage.ordinal }],
|
||||
...stage.request,
|
||||
})
|
||||
if (execution.status !== 'completed' || !execution.response) throw new Error(`Native OCCT ${stage.operation} stage history ${execution.status}.`)
|
||||
@@ -1445,8 +1461,8 @@ export class BitbybitGeometryRuntime {
|
||||
ordinal: 2,
|
||||
sourceIds: { object: firstObjectId, tool: secondObjectId },
|
||||
inputs: [
|
||||
{ objectId: firstObjectId, shape: profileInput.shape, stageId: firstStageId },
|
||||
{ objectId: secondObjectId, shape: profileInput.shape, stageId: secondStageId },
|
||||
{ objectId: firstObjectId, shape: profileInput.shape, stageId: firstStageId, namingEvidence: first.capture.namingEvidence },
|
||||
{ objectId: secondObjectId, shape: profileInput.shape, stageId: secondStageId, namingEvidence: second.capture.namingEvidence },
|
||||
],
|
||||
request: { objectStep: first.resultStep, toolStep: second.resultStep },
|
||||
})
|
||||
@@ -1498,8 +1514,8 @@ export class BitbybitGeometryRuntime {
|
||||
ordinal: 2,
|
||||
sourceIds: { object: toolOneObjectId, tool: toolTwoObjectId },
|
||||
inputs: [
|
||||
{ objectId: toolOneObjectId, shape: profileInput.shape, stageId: toolOneStageId },
|
||||
{ objectId: toolTwoObjectId, shape: profileInput.shape, stageId: toolTwoStageId },
|
||||
{ objectId: toolOneObjectId, shape: profileInput.shape, stageId: toolOneStageId, namingEvidence: toolOne.capture.namingEvidence },
|
||||
{ objectId: toolTwoObjectId, shape: profileInput.shape, stageId: toolTwoStageId, namingEvidence: toolTwo.capture.namingEvidence },
|
||||
],
|
||||
request: { objectStep: toolOne.resultStep, toolStep: toolTwo.resultStep },
|
||||
})
|
||||
@@ -1512,7 +1528,7 @@ export class BitbybitGeometryRuntime {
|
||||
sourceIds: { object: baseInput.objectId, tool: fusedToolObjectId },
|
||||
inputs: [
|
||||
baseInput,
|
||||
{ objectId: fusedToolObjectId, shape: profileInput.shape, stageId: fuseStageId },
|
||||
{ objectId: fusedToolObjectId, shape: profileInput.shape, stageId: fuseStageId, namingEvidence: fusedTool.capture.namingEvidence },
|
||||
],
|
||||
request: { objectStep: baseStep, toolStep: fusedTool.resultStep },
|
||||
})
|
||||
@@ -1554,7 +1570,7 @@ export class BitbybitGeometryRuntime {
|
||||
resultObjectId: finalResultObjectId(),
|
||||
ordinal: 1,
|
||||
sourceIds: { object: rotatedProfileObjectId, tool: rotatedProfileObjectId },
|
||||
inputs: [{ objectId: rotatedProfileObjectId, shape: profileInput.shape, stageId: rotateStageId }],
|
||||
inputs: [{ objectId: rotatedProfileObjectId, shape: profileInput.shape, stageId: rotateStageId, namingEvidence: rotated.capture.namingEvidence }],
|
||||
request: { objectStep: rotated.resultStep, axisOrigin, direction: parameters.direction, angle: parameters.totalAngle },
|
||||
})
|
||||
return withStageCaptures([rotated.capture, revolution.capture])
|
||||
@@ -1592,7 +1608,7 @@ export class BitbybitGeometryRuntime {
|
||||
resultObjectId: revolutionToolObjectId,
|
||||
ordinal: 1,
|
||||
sourceIds: { object: rotatedProfileObjectId, tool: rotatedProfileObjectId },
|
||||
inputs: [{ objectId: rotatedProfileObjectId, shape: profileInput.shape, stageId: rotateStageId }],
|
||||
inputs: [{ objectId: rotatedProfileObjectId, shape: profileInput.shape, stageId: rotateStageId, namingEvidence: rotated.capture.namingEvidence }],
|
||||
request: { objectStep: rotated.resultStep, axisOrigin, direction: parameters.direction, angle: parameters.totalAngle },
|
||||
})
|
||||
const cut = await captureStage({
|
||||
@@ -1602,7 +1618,7 @@ export class BitbybitGeometryRuntime {
|
||||
resultObjectId: finalResultObjectId(),
|
||||
ordinal: 2,
|
||||
sourceIds: { object: baseInput.objectId, tool: revolutionToolObjectId },
|
||||
inputs: [baseInput, { objectId: revolutionToolObjectId, shape: profileInput.shape, stageId: revolutionStageId }],
|
||||
inputs: [baseInput, { objectId: revolutionToolObjectId, shape: profileInput.shape, stageId: revolutionStageId, namingEvidence: revolution.capture.namingEvidence }],
|
||||
request: { objectStep: baseStep, toolStep: revolution.resultStep },
|
||||
})
|
||||
return withStageCaptures([rotated.capture, revolution.capture, cut.capture])
|
||||
@@ -1639,6 +1655,9 @@ export class BitbybitGeometryRuntime {
|
||||
documentVersion: input.documentVersion,
|
||||
operationId: toolStageId,
|
||||
operation: 'pad',
|
||||
resultObjectId: toolObjectId,
|
||||
inputs: [{ inputId: `${toolStageId}:input:0`, objectId: profileInput.objectId, role: 'object', step: profileStep.text, objectTag: profileInput.objectTag, namingEvidence: profileInput.namingEvidence }],
|
||||
stages: [{ stageId: toolStageId, operation: 'pad', inputIds: [`${toolStageId}:input:0`], ordinal: 0 }],
|
||||
objectStep: profileStep.text,
|
||||
direction: sides[0].direction,
|
||||
})
|
||||
@@ -1661,6 +1680,13 @@ export class BitbybitGeometryRuntime {
|
||||
documentVersion: input.documentVersion,
|
||||
operationId: cutStageId,
|
||||
operation: 'cut',
|
||||
resultObjectId,
|
||||
...(input.resultObjectTag === undefined ? {} : { resultObjectTag: input.resultObjectTag }),
|
||||
inputs: [
|
||||
{ inputId: `${cutStageId}:input:0`, objectId: baseInput.objectId, role: 'object', step: baseStep.text, objectTag: baseInput.objectTag, namingEvidence: baseInput.namingEvidence },
|
||||
{ inputId: `${cutStageId}:input:1`, objectId: toolObjectId, role: 'tool', stageId: toolStageId, step: toolResponse.resultStep, namingEvidence: toolResponse.namingEvidence },
|
||||
],
|
||||
stages: [{ stageId: cutStageId, operation: 'cut', inputIds: [`${cutStageId}:input:0`, `${cutStageId}:input:1`], ordinal: 1 }],
|
||||
objectStep: baseStep.text,
|
||||
toolStep: toolResponse.resultStep,
|
||||
})
|
||||
@@ -1745,6 +1771,9 @@ export class BitbybitGeometryRuntime {
|
||||
documentVersion: input.documentVersion,
|
||||
operationId: toolStageId,
|
||||
operation: 'revolution',
|
||||
resultObjectId: toolObjectId,
|
||||
inputs: [{ inputId: `${toolStageId}:input:0`, objectId: profileInput.objectId, role: 'object', step: profileStep.text, objectTag: profileInput.objectTag, namingEvidence: profileInput.namingEvidence }],
|
||||
stages: [{ stageId: toolStageId, operation: 'revolution', inputIds: [`${toolStageId}:input:0`], ordinal: 0 }],
|
||||
objectStep: profileStep.text,
|
||||
axisOrigin,
|
||||
direction: sides[0].direction,
|
||||
@@ -1769,6 +1798,13 @@ export class BitbybitGeometryRuntime {
|
||||
documentVersion: input.documentVersion,
|
||||
operationId: cutStageId,
|
||||
operation: 'cut',
|
||||
resultObjectId,
|
||||
...(input.resultObjectTag === undefined ? {} : { resultObjectTag: input.resultObjectTag }),
|
||||
inputs: [
|
||||
{ inputId: `${cutStageId}:input:0`, objectId: baseInput.objectId, role: 'object', step: baseStep.text, objectTag: baseInput.objectTag, namingEvidence: baseInput.namingEvidence },
|
||||
{ inputId: `${cutStageId}:input:1`, objectId: toolObjectId, role: 'tool', stageId: toolStageId, step: toolResponse.resultStep, namingEvidence: toolResponse.namingEvidence },
|
||||
],
|
||||
stages: [{ stageId: cutStageId, operation: 'cut', inputIds: [`${cutStageId}:input:0`, `${cutStageId}:input:1`], ordinal: 1 }],
|
||||
objectStep: baseStep.text,
|
||||
toolStep: toolResponse.resultStep,
|
||||
})
|
||||
@@ -1909,6 +1945,13 @@ export class BitbybitGeometryRuntime {
|
||||
documentVersion: input.documentVersion,
|
||||
operationId: cutStageId,
|
||||
operation: 'cut',
|
||||
resultObjectId,
|
||||
...(input.resultObjectTag === undefined ? {} : { resultObjectTag: input.resultObjectTag }),
|
||||
inputs: [
|
||||
{ inputId: `${cutStageId}:input:0`, objectId: baseInput.objectId, role: 'object', step: baseStep.text, objectTag: baseInput.objectTag, namingEvidence: baseInput.namingEvidence },
|
||||
{ inputId: `${cutStageId}:input:1`, objectId: toolObjectId, role: 'tool', stageId: toolStageId, step: toolStep.text, namingEvidence: createFinalShapeOnlyNamingEvidence(toolStageId, toolObjectId, 'Hole tool was synthesized by the geometry runtime; provider did not capture its builder naming evidence.') },
|
||||
],
|
||||
stages: [{ stageId: cutStageId, operation: 'cut', inputIds: [`${cutStageId}:input:0`, `${cutStageId}:input:1`], ordinal: 1 }],
|
||||
objectStep: baseStep.text,
|
||||
toolStep: toolStep.text,
|
||||
})
|
||||
@@ -2050,6 +2093,7 @@ export class BitbybitGeometryRuntime {
|
||||
let previousStep = baseStep.text
|
||||
let previousObjectId = baseInput.objectId
|
||||
let previousStageId: string | undefined
|
||||
let previousNamingEvidence = baseInput.namingEvidence
|
||||
const declaredResultObjectId = input.stages?.length ? input.stages[input.stages.length - 1].resultObjectId : undefined
|
||||
for (let index = 0; index < input.transforms.length; index += 1) {
|
||||
const step = input.transforms[index]
|
||||
@@ -2062,6 +2106,10 @@ export class BitbybitGeometryRuntime {
|
||||
documentVersion: input.documentVersion,
|
||||
operationId: `${input.operationId}:native-stage:${index}`,
|
||||
operation,
|
||||
resultObjectId,
|
||||
...(index === input.transforms.length - 1 && input.resultObjectTag !== undefined ? { resultObjectTag: input.resultObjectTag } : {}),
|
||||
inputs: [{ inputId: `${stageId}:input:0`, objectId: previousObjectId, role: 'object', stageId: previousStageId, step: previousStep, ...(index === 0 && baseInput.objectTag !== undefined ? { objectTag: baseInput.objectTag } : {}), namingEvidence: previousNamingEvidence }],
|
||||
stages: [{ stageId, operation, inputIds: [`${stageId}:input:0`], ordinal: index }],
|
||||
objectStep: previousStep,
|
||||
...(step.type === 'linear' ? { direction: step.direction } : {}),
|
||||
...(step.type === 'polar' ? { axisOrigin: step.axisOrigin, direction: step.direction, angle: step.angle } : {}),
|
||||
@@ -2085,6 +2133,7 @@ export class BitbybitGeometryRuntime {
|
||||
previousStep = response.resultStep
|
||||
previousObjectId = resultObjectId
|
||||
previousStageId = stageId
|
||||
previousNamingEvidence = namingEvidenceForResponse(response, stageId, resultObjectId)
|
||||
}
|
||||
const records = captures[captures.length - 1].records as NativeTopologyHistoryRecords
|
||||
Object.defineProperty(records, 'stageCaptures', { value: captures, enumerable: false, configurable: false, writable: false })
|
||||
|
||||
Reference in New Issue
Block a user