Fix artifact types to be more accurate (#5022)
This commit is contained in:
@ -705,7 +705,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
segIds: [],
|
segIds: [],
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
planeId: 'UUID-1',
|
planeId: 'UUID-1',
|
||||||
sweepId: '',
|
sweepId: undefined,
|
||||||
codeRef: {
|
codeRef: {
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
range: [37, 64, true],
|
range: [37, 64, true],
|
||||||
@ -743,7 +743,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
type: 'segment',
|
type: 'segment',
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
pathId: expect.any(String),
|
pathId: expect.any(String),
|
||||||
surfaceId: '',
|
surfaceId: undefined,
|
||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [70, 86, true],
|
range: [70, 86, true],
|
||||||
@ -770,7 +770,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
consumedEdgeId: expect.any(String),
|
consumedEdgeId: expect.any(String),
|
||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
surfaceId: '',
|
surfaceId: undefined,
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [260, 299, true],
|
range: [260, 299, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
|
@ -37,7 +37,7 @@ export interface PathArtifact extends BaseArtifact {
|
|||||||
type: 'path'
|
type: 'path'
|
||||||
planeId: ArtifactId
|
planeId: ArtifactId
|
||||||
segIds: Array<ArtifactId>
|
segIds: Array<ArtifactId>
|
||||||
sweepId: ArtifactId
|
sweepId?: ArtifactId
|
||||||
solid2dId?: ArtifactId
|
solid2dId?: ArtifactId
|
||||||
codeRef: CodeRef
|
codeRef: CodeRef
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ export interface PathArtifactRich extends BaseArtifact {
|
|||||||
export interface SegmentArtifact extends BaseArtifact {
|
export interface SegmentArtifact extends BaseArtifact {
|
||||||
type: 'segment'
|
type: 'segment'
|
||||||
pathId: ArtifactId
|
pathId: ArtifactId
|
||||||
surfaceId: ArtifactId
|
surfaceId?: ArtifactId
|
||||||
edgeIds: Array<ArtifactId>
|
edgeIds: Array<ArtifactId>
|
||||||
edgeCutId?: ArtifactId
|
edgeCutId?: ArtifactId
|
||||||
codeRef: CodeRef
|
codeRef: CodeRef
|
||||||
@ -68,7 +68,7 @@ export interface SegmentArtifact extends BaseArtifact {
|
|||||||
interface SegmentArtifactRich extends BaseArtifact {
|
interface SegmentArtifactRich extends BaseArtifact {
|
||||||
type: 'segment'
|
type: 'segment'
|
||||||
path: PathArtifact
|
path: PathArtifact
|
||||||
surf: WallArtifact
|
surf?: WallArtifact
|
||||||
edges: Array<SweepEdge>
|
edges: Array<SweepEdge>
|
||||||
edgeCut?: EdgeCut
|
edgeCut?: EdgeCut
|
||||||
codeRef: CodeRef
|
codeRef: CodeRef
|
||||||
@ -120,7 +120,7 @@ interface EdgeCut extends BaseArtifact {
|
|||||||
subType: 'fillet' | 'chamfer'
|
subType: 'fillet' | 'chamfer'
|
||||||
consumedEdgeId: ArtifactId
|
consumedEdgeId: ArtifactId
|
||||||
edgeIds: Array<ArtifactId>
|
edgeIds: Array<ArtifactId>
|
||||||
surfaceId: ArtifactId
|
surfaceId?: ArtifactId
|
||||||
codeRef: CodeRef
|
codeRef: CodeRef
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ export function getArtifactsToUpdate({
|
|||||||
id,
|
id,
|
||||||
segIds: [],
|
segIds: [],
|
||||||
planeId: currentPlaneId,
|
planeId: currentPlaneId,
|
||||||
sweepId: '',
|
sweepId: undefined,
|
||||||
codeRef: { range, pathToNode },
|
codeRef: { range, pathToNode },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -343,7 +343,7 @@ export function getArtifactsToUpdate({
|
|||||||
type: 'segment',
|
type: 'segment',
|
||||||
id,
|
id,
|
||||||
pathId,
|
pathId,
|
||||||
surfaceId: '',
|
surfaceId: undefined,
|
||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
codeRef: { range, pathToNode },
|
codeRef: { range, pathToNode },
|
||||||
},
|
},
|
||||||
@ -450,7 +450,8 @@ export function getArtifactsToUpdate({
|
|||||||
id: face_id,
|
id: face_id,
|
||||||
segId: curve_id,
|
segId: curve_id,
|
||||||
edgeCutEdgeIds: [],
|
edgeCutEdgeIds: [],
|
||||||
sweepId: path.sweepId,
|
// TODO: Add explicit check for sweepId. Should never use ''
|
||||||
|
sweepId: path.sweepId ?? '',
|
||||||
pathIds: [],
|
pathIds: [],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -458,15 +459,17 @@ export function getArtifactsToUpdate({
|
|||||||
id: curve_id,
|
id: curve_id,
|
||||||
artifact: { ...seg, surfaceId: face_id },
|
artifact: { ...seg, surfaceId: face_id },
|
||||||
})
|
})
|
||||||
const sweep = getArtifact(path.sweepId)
|
if (path.sweepId) {
|
||||||
if (sweep?.type === 'sweep') {
|
const sweep = getArtifact(path.sweepId)
|
||||||
returnArr.push({
|
if (sweep?.type === 'sweep') {
|
||||||
id: path.sweepId,
|
returnArr.push({
|
||||||
artifact: {
|
id: path.sweepId,
|
||||||
...sweep,
|
artifact: {
|
||||||
surfaceIds: [face_id],
|
...sweep,
|
||||||
},
|
surfaceIds: [face_id],
|
||||||
})
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -483,19 +486,22 @@ export function getArtifactsToUpdate({
|
|||||||
id: face_id,
|
id: face_id,
|
||||||
subType: cap === 'bottom' ? 'start' : 'end',
|
subType: cap === 'bottom' ? 'start' : 'end',
|
||||||
edgeCutEdgeIds: [],
|
edgeCutEdgeIds: [],
|
||||||
sweepId: path.sweepId,
|
// TODO: Add explicit check for sweepId. Should never use ''
|
||||||
|
sweepId: path.sweepId ?? '',
|
||||||
pathIds: [],
|
pathIds: [],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const sweep = getArtifact(path.sweepId)
|
if (path.sweepId) {
|
||||||
if (sweep?.type !== 'sweep') return
|
const sweep = getArtifact(path.sweepId)
|
||||||
returnArr.push({
|
if (sweep?.type !== 'sweep') return
|
||||||
id: path.sweepId,
|
returnArr.push({
|
||||||
artifact: {
|
id: path.sweepId,
|
||||||
...sweep,
|
artifact: {
|
||||||
surfaceIds: [face_id],
|
...sweep,
|
||||||
},
|
surfaceIds: [face_id],
|
||||||
})
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -533,7 +539,8 @@ export function getArtifactsToUpdate({
|
|||||||
? 'adjacent'
|
? 'adjacent'
|
||||||
: 'opposite',
|
: 'opposite',
|
||||||
segId: cmd.edge_id,
|
segId: cmd.edge_id,
|
||||||
sweepId: path.sweepId,
|
// TODO: Add explicit check for sweepId. Should never use ''
|
||||||
|
sweepId: path.sweepId ?? '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -544,7 +551,7 @@ export function getArtifactsToUpdate({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: path.sweepId,
|
id: sweep.id,
|
||||||
artifact: {
|
artifact: {
|
||||||
...sweep,
|
...sweep,
|
||||||
edgeIds: [response.data.modeling_response.data.edge],
|
edgeIds: [response.data.modeling_response.data.edge],
|
||||||
@ -560,7 +567,7 @@ export function getArtifactsToUpdate({
|
|||||||
subType: cmd.cut_type,
|
subType: cmd.cut_type,
|
||||||
consumedEdgeId: cmd.edge_id,
|
consumedEdgeId: cmd.edge_id,
|
||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
surfaceId: '',
|
surfaceId: undefined,
|
||||||
codeRef: { range, pathToNode },
|
codeRef: { range, pathToNode },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -722,10 +729,12 @@ export function expandSegment(
|
|||||||
{ key: segment.pathId, types: ['path'] },
|
{ key: segment.pathId, types: ['path'] },
|
||||||
artifactGraph
|
artifactGraph
|
||||||
)
|
)
|
||||||
const surf = getArtifactOfTypes(
|
const surf = segment.surfaceId
|
||||||
{ key: segment.surfaceId, types: ['wall'] },
|
? getArtifactOfTypes(
|
||||||
artifactGraph
|
{ key: segment.surfaceId, types: ['wall'] },
|
||||||
)
|
artifactGraph
|
||||||
|
)
|
||||||
|
: undefined
|
||||||
const edges = getArtifactsOfTypes(
|
const edges = getArtifactsOfTypes(
|
||||||
{ keys: segment.edgeIds, types: ['sweepEdge'] },
|
{ keys: segment.edgeIds, types: ['sweepEdge'] },
|
||||||
artifactGraph
|
artifactGraph
|
||||||
@ -842,6 +851,7 @@ export function getSweepFromSuspectedSweepSurface(
|
|||||||
artifactGraph
|
artifactGraph
|
||||||
)
|
)
|
||||||
if (err(path)) return path
|
if (err(path)) return path
|
||||||
|
if (!path.sweepId) return new Error('Path does not have a sweepId')
|
||||||
return getArtifactOfTypes(
|
return getArtifactOfTypes(
|
||||||
{ key: path.sweepId, types: ['sweep'] },
|
{ key: path.sweepId, types: ['sweep'] },
|
||||||
artifactGraph
|
artifactGraph
|
||||||
@ -859,6 +869,7 @@ export function getSweepFromSuspectedPath(
|
|||||||
): SweepArtifact | Error {
|
): SweepArtifact | Error {
|
||||||
const path = getArtifactOfTypes({ key: id, types: ['path'] }, artifactGraph)
|
const path = getArtifactOfTypes({ key: id, types: ['path'] }, artifactGraph)
|
||||||
if (err(path)) return path
|
if (err(path)) return path
|
||||||
|
if (!path.sweepId) return new Error('Path does not have a sweepId')
|
||||||
return getArtifactOfTypes(
|
return getArtifactOfTypes(
|
||||||
{ key: path.sweepId, types: ['sweep'] },
|
{ key: path.sweepId, types: ['sweep'] },
|
||||||
artifactGraph
|
artifactGraph
|
||||||
|
@ -137,7 +137,7 @@ See later source ranges for more context. about the sweep`,
|
|||||||
{ key: artifact.pathId, types: ['path'] },
|
{ key: artifact.pathId, types: ['path'] },
|
||||||
artifactGraph
|
artifactGraph
|
||||||
)
|
)
|
||||||
if (!err(path)) {
|
if (!err(path) && path.sweepId) {
|
||||||
const sweep = getArtifactOfTypes(
|
const sweep = getArtifactOfTypes(
|
||||||
{ key: path.sweepId, types: ['sweep'] },
|
{ key: path.sweepId, types: ['sweep'] },
|
||||||
artifactGraph
|
artifactGraph
|
||||||
|
@ -670,6 +670,7 @@ export function codeToIdSelections(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === 'extrude-wall' && entry.artifact.type === 'segment') {
|
if (type === 'extrude-wall' && entry.artifact.type === 'segment') {
|
||||||
|
if (!entry.artifact.surfaceId) return
|
||||||
const wall = engineCommandManager.artifactGraph.get(
|
const wall = engineCommandManager.artifactGraph.get(
|
||||||
entry.artifact.surfaceId
|
entry.artifact.surfaceId
|
||||||
)
|
)
|
||||||
@ -714,6 +715,7 @@ export function codeToIdSelections(
|
|||||||
(type === 'end-cap' || type === 'start-cap') &&
|
(type === 'end-cap' || type === 'start-cap') &&
|
||||||
entry.artifact.type === 'path'
|
entry.artifact.type === 'path'
|
||||||
) {
|
) {
|
||||||
|
if (!entry.artifact.sweepId) return
|
||||||
const extrusion = getArtifactOfTypes(
|
const extrusion = getArtifactOfTypes(
|
||||||
{
|
{
|
||||||
key: entry.artifact.sweepId,
|
key: entry.artifact.sweepId,
|
||||||
|
Reference in New Issue
Block a user