Merge branch 'main' into lf94/kurt-bring-back-multi-profile

This commit is contained in:
49lf
2025-01-15 14:07:47 -05:00
69 changed files with 2388 additions and 1033 deletions

View File

@ -39,7 +39,7 @@ export interface PathArtifact extends BaseArtifact {
type: 'path'
planeId: ArtifactId
segIds: Array<ArtifactId>
sweepId: ArtifactId
sweepId?: ArtifactId
solid2dId?: ArtifactId
codeRef: CodeRef
}
@ -62,7 +62,7 @@ export interface PathArtifactRich extends BaseArtifact {
export interface SegmentArtifact extends BaseArtifact {
type: 'segment'
pathId: ArtifactId
surfaceId: ArtifactId
surfaceId?: ArtifactId
edgeIds: Array<ArtifactId>
edgeCutId?: ArtifactId
codeRef: CodeRef
@ -79,7 +79,7 @@ interface SegmentArtifactRich extends BaseArtifact {
/** A Sweep is a more generic term for extrude, revolve, loft and sweep*/
interface SweepArtifact extends BaseArtifact {
type: 'sweep'
subType: 'extrusion' | 'revolve'
subType: 'extrusion' | 'revolve' | 'loft' | 'sweep'
pathId: string
surfaceIds: Array<string>
edgeIds: Array<string>
@ -87,7 +87,7 @@ interface SweepArtifact extends BaseArtifact {
}
interface SweepArtifactRich extends BaseArtifact {
type: 'sweep'
subType: 'extrusion' | 'revolve'
subType: 'extrusion' | 'revolve' | 'loft' | 'sweep'
path: PathArtifact
surfaces: Array<WallArtifact | CapArtifact>
edges: Array<SweepEdgeArtifact>
@ -128,7 +128,7 @@ interface EdgeCut extends BaseArtifact {
subType: 'fillet' | 'chamfer'
consumedEdgeId: ArtifactId
edgeIds: Array<ArtifactId>
surfaceId: ArtifactId
surfaceId?: ArtifactId
codeRef: CodeRef
}
@ -332,7 +332,7 @@ export function getArtifactsToUpdate({
id,
segIds: [],
planeId: currentPlaneId,
sweepId: '',
sweepId: undefined,
codeRef: { range, pathToNode },
},
})
@ -379,7 +379,7 @@ export function getArtifactsToUpdate({
type: 'segment',
id,
pathId,
surfaceId: '',
surfaceId: undefined,
edgeIds: [],
codeRef: { range, pathToNode },
},
@ -413,7 +413,11 @@ export function getArtifactsToUpdate({
})
}
return returnArr
} else if (cmd.type === 'extrude' || cmd.type === 'revolve') {
} else if (
cmd.type === 'extrude' ||
cmd.type === 'revolve' ||
cmd.type === 'sweep'
) {
const subType = cmd.type === 'extrude' ? 'extrusion' : cmd.type
returnArr.push({
id,
@ -434,6 +438,33 @@ export function getArtifactsToUpdate({
artifact: { ...path, sweepId: id },
})
return returnArr
} else if (
cmd.type === 'loft' &&
response.type === 'modeling' &&
response.data.modeling_response.type === 'loft'
) {
returnArr.push({
id,
artifact: {
type: 'sweep',
subType: 'loft',
id,
// TODO: make sure to revisit this choice, don't think it matters for now
pathId: cmd.section_ids[0],
surfaceIds: [],
edgeIds: [],
codeRef: { range, pathToNode },
},
})
for (const sectionId of cmd.section_ids) {
const path = getArtifact(sectionId)
if (path?.type === 'path')
returnArr.push({
id: sectionId,
artifact: { ...path, sweepId: id },
})
}
return returnArr
} else if (
cmd.type === 'solid3d_get_extrusion_face_info' &&
response?.type === 'modeling' &&
@ -457,7 +488,8 @@ export function getArtifactsToUpdate({
id: face_id,
segId: curve_id,
edgeCutEdgeIds: [],
sweepId: path.sweepId,
// TODO: Add explicit check for sweepId. Should never use ''
sweepId: path.sweepId ?? '',
pathIds: [],
}
@ -475,20 +507,23 @@ export function getArtifactsToUpdate({
returnArr.push({
id: face_id,
artifact: wallArtifact,
})
returnArr.push({
id: curve_id,
artifact: { ...seg, surfaceId: face_id },
})
const sweep = getArtifact(path.sweepId)
if (sweep?.type === 'sweep') {
returnArr.push({
id: path.sweepId,
artifact: {
...sweep,
surfaceIds: [face_id],
},
})
if (path.sweepId) {
const sweep = getArtifact(path.sweepId)
if (sweep?.type === 'sweep') {
returnArr.push({
id: path.sweepId,
artifact: {
...sweep,
surfaceIds: [face_id],
},
})
}
}
}
}
@ -507,7 +542,8 @@ export function getArtifactsToUpdate({
id: face_id,
subType: cap === 'bottom' ? 'start' : 'end',
edgeCutEdgeIds: [],
sweepId: path.sweepId,
// TODO: Add explicit check for sweepId. Should never use ''
sweepId: path.sweepId ?? '',
pathIds: [],
}
if (sketchOnFaceSourceRange) {
@ -526,15 +562,17 @@ export function getArtifactsToUpdate({
id: face_id,
artifact: capArtifact,
})
const sweep = getArtifact(path.sweepId)
if (sweep?.type !== 'sweep') return
returnArr.push({
id: path.sweepId,
artifact: {
...sweep,
surfaceIds: [face_id],
},
})
if (path.sweepId) {
const sweep = getArtifact(path.sweepId)
if (sweep?.type !== 'sweep') return
returnArr.push({
id: path.sweepId,
artifact: {
...sweep,
surfaceIds: [face_id],
},
})
}
}
}
})
@ -572,7 +610,8 @@ export function getArtifactsToUpdate({
? 'adjacent'
: 'opposite',
segId: cmd.edge_id,
sweepId: path.sweepId,
// TODO: Add explicit check for sweepId. Should never use ''
sweepId: path.sweepId ?? '',
},
},
{
@ -583,7 +622,7 @@ export function getArtifactsToUpdate({
},
},
{
id: path.sweepId,
id: sweep.id,
artifact: {
...sweep,
edgeIds: [response.data.modeling_response.data.edge],
@ -599,7 +638,7 @@ export function getArtifactsToUpdate({
subType: cmd.cut_type,
consumedEdgeId: cmd.edge_id,
edgeIds: [],
surfaceId: '',
surfaceId: undefined,
codeRef: { range, pathToNode },
},
})
@ -761,10 +800,12 @@ export function expandSegment(
{ key: segment.pathId, types: ['path'] },
artifactGraph
)
const surf = getArtifactOfTypes(
{ key: segment.surfaceId, types: ['wall'] },
artifactGraph
)
const surf = segment.surfaceId
? getArtifactOfTypes(
{ key: segment.surfaceId, types: ['wall'] },
artifactGraph
)
: undefined
const edges = getArtifactsOfTypes(
{ keys: segment.edgeIds, types: ['sweepEdge'] },
artifactGraph
@ -881,6 +922,7 @@ export function getSweepFromSuspectedSweepSurface(
artifactGraph
)
if (err(path)) return path
if (!path.sweepId) return new Error('Path does not have a sweepId')
return getArtifactOfTypes(
{ key: path.sweepId, types: ['sweep'] },
artifactGraph
@ -898,6 +940,7 @@ export function getSweepFromSuspectedPath(
): SweepArtifact | Error {
const path = getArtifactOfTypes({ key: id, types: ['path'] }, artifactGraph)
if (err(path)) return path
if (!path.sweepId) return new Error('Path does not have a sweepId')
return getArtifactOfTypes(
{ key: path.sweepId, types: ['sweep'] },
artifactGraph