renaming extrude to sweep to generalize the command (#3773)

* fix: just a one liner? forcing a revolve to be an extrude artifact

* fix: first step in renaming ExtrusionArtifact to SweepArtifact

* fix: renaming extrusion to sweep for a few things? need to do another pass

* fix: cleaning up comments, fixing unit tests for new key names

* fix: unit test update

* fix: removing TODO comments that are not needed

* fix: renaming more extrude/extrusion values to sweep

* fix: test:nowatch -u to update the vitests

* Look at this (photo)Graph *in the voice of Nickelback*

* fix: removing TODOs

* fix: forgot to update the extrudeEdge string in other files

* chore: adding e2e test to see if users can sketch on revolved face

* fix: removing garbage string

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Kevin Nadro
2024-09-17 13:22:53 -05:00
committed by GitHub
parent 8c5b146c94
commit f828c36e58
9 changed files with 230 additions and 153 deletions

View File

@ -954,4 +954,68 @@ const sketch002 = startSketchOn(extrude001, 'END')
await u.getGreatestPixDiff(XYPlanePoint, noPlanesColor) await u.getGreatestPixDiff(XYPlanePoint, noPlanesColor)
).toBeLessThan(3) ).toBeLessThan(3)
}) })
test('Can attempt to sketch on revolved face', async ({
page,
browserName,
}) => {
test.skip(
browserName === 'webkit',
'Skip on Safari until `window.tearDown` is working there'
)
const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 })
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const lugHeadLength = 0.25
const lugDiameter = 0.5
const lugLength = 2
fn lug = (origin, length, diameter, plane) => {
const lugSketch = startSketchOn(plane)
|> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %)
|> angledLineOfYLength({ angle: 60, length: lugHeadLength }, %)
|> xLineTo(0 + .001, %)
|> yLineTo(0, %)
|> close(%)
|> revolve({ axis: "Y" }, %)
return lugSketch
}
lug([0, 0], 10, .5, "XY")`
)
})
await u.waitForAuthSkipAppStart()
await u.openDebugPanel()
await u.expectCmdLog('[data-message-type="execution-done"]')
await u.closeDebugPanel()
/***
* Test Plan
* Start the sketch mode
* Click the middle of the screen which should click the top face that is revolved
* Wait till you see the line tool be enabled
* Wait till you see the exit sketch enabled
*
* This is supposed to test that you are allowed to go into sketch mode to sketch on a revolved face
*/
await page.getByRole('button', { name: 'Start Sketch' }).click()
await expect(async () => {
await page.mouse.click(600, 250)
await page.waitForTimeout(1000)
await expect(
page.getByRole('button', { name: 'Exit Sketch' })
).toBeVisible()
await expect(
page.getByRole('button', { name: 'line Line', exact: true })
).toHaveAttribute('aria-pressed', 'true')
}).toPass({ timeout: 40_000, intervals: [1_000] })
})
}) })

View File

@ -9,8 +9,8 @@ import { useModelingContext } from './useModelingContext'
import { getEventForSelectWithPoint } from 'lib/selections' import { getEventForSelectWithPoint } from 'lib/selections'
import { import {
getCapCodeRef, getCapCodeRef,
getExtrudeEdgeCodeRef, getSweepEdgeCodeRef,
getExtrusionFromSuspectedExtrudeSurface, getSweepFromSuspectedSweepSurface,
getSolid2dCodeRef, getSolid2dCodeRef,
getWallCodeRef, getWallCodeRef,
} from 'lang/std/artifactGraph' } from 'lang/std/artifactGraph'
@ -47,7 +47,7 @@ export function useEngineConnectionSubscriptions() {
if (err(codeRef)) return if (err(codeRef)) return
editorManager.setHighlightRange([codeRef.range]) editorManager.setHighlightRange([codeRef.range])
} else if (artifact?.type === 'wall') { } else if (artifact?.type === 'wall') {
const extrusion = getExtrusionFromSuspectedExtrudeSurface( const extrusion = getSweepFromSuspectedSweepSurface(
data.entity_id, data.entity_id,
engineCommandManager.artifactGraph engineCommandManager.artifactGraph
) )
@ -61,8 +61,8 @@ export function useEngineConnectionSubscriptions() {
? [codeRef.range] ? [codeRef.range]
: [codeRef.range, extrusion.codeRef.range] : [codeRef.range, extrusion.codeRef.range]
) )
} else if (artifact?.type === 'extrudeEdge') { } else if (artifact?.type === 'sweepEdge') {
const codeRef = getExtrudeEdgeCodeRef( const codeRef = getSweepEdgeCodeRef(
artifact, artifact,
engineCommandManager.artifactGraph engineCommandManager.artifactGraph
) )
@ -172,7 +172,7 @@ export function useEngineConnectionSubscriptions() {
} }
const faceId = planeOrFaceId const faceId = planeOrFaceId
const artifact = engineCommandManager.artifactGraph.get(faceId) const artifact = engineCommandManager.artifactGraph.get(faceId)
const extrusion = getExtrusionFromSuspectedExtrudeSurface( const extrusion = getSweepFromSuspectedSweepSurface(
faceId, faceId,
engineCommandManager.artifactGraph engineCommandManager.artifactGraph
) )

View File

@ -35,7 +35,7 @@ import { Selections, canFilletSelection } from 'lib/selections'
import { KclCommandValue } from 'lib/commandTypes' import { KclCommandValue } from 'lib/commandTypes'
import { import {
ArtifactGraph, ArtifactGraph,
getExtrusionFromSuspectedPath, getSweepFromSuspectedPath,
} from 'lang/std/artifactGraph' } from 'lang/std/artifactGraph'
import { kclManager, engineCommandManager, editorManager } from 'lib/singletons' import { kclManager, engineCommandManager, editorManager } from 'lib/singletons'
@ -152,7 +152,7 @@ export function getPathToExtrudeForSegmentSelection(
) )
if (trap(sketchGroup)) return sketchGroup if (trap(sketchGroup)) return sketchGroup
const extrusion = getExtrusionFromSuspectedPath(sketchGroup.id, artifactGraph) const extrusion = getSweepFromSuspectedPath(sketchGroup.id, artifactGraph)
if (err(extrusion)) return extrusion if (err(extrusion)) return extrusion
const pathToExtrudeNode = getNodePathFromSourceRange( const pathToExtrudeNode = getNodePathFromSourceRange(

View File

@ -33,7 +33,6 @@ Map {
70, 70,
], ],
}, },
"extrusionId": "UUID",
"planeId": "UUID", "planeId": "UUID",
"segIds": [ "segIds": [
"UUID", "UUID",
@ -43,6 +42,7 @@ Map {
"UUID", "UUID",
], ],
"solid2dId": "UUID", "solid2dId": "UUID",
"sweepId": "UUID",
"type": "path", "type": "path",
}, },
"UUID-2" => { "UUID-2" => {
@ -175,6 +175,7 @@ Map {
"UUID", "UUID",
], ],
"pathId": "UUID", "pathId": "UUID",
"subType": "extrusion",
"surfaceIds": [ "surfaceIds": [
"UUID", "UUID",
"UUID", "UUID",
@ -183,99 +184,99 @@ Map {
"UUID", "UUID",
"UUID", "UUID",
], ],
"type": "extrusion", "type": "sweep",
}, },
"UUID-9" => { "UUID-9" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"segId": "UUID", "segId": "UUID",
"sweepId": "UUID",
"type": "wall", "type": "wall",
}, },
"UUID-10" => { "UUID-10" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [ "pathIds": [
"UUID", "UUID",
], ],
"segId": "UUID", "segId": "UUID",
"sweepId": "UUID",
"type": "wall", "type": "wall",
}, },
"UUID-11" => { "UUID-11" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"segId": "UUID", "segId": "UUID",
"sweepId": "UUID",
"type": "wall", "type": "wall",
}, },
"UUID-12" => { "UUID-12" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"segId": "UUID", "segId": "UUID",
"sweepId": "UUID",
"type": "wall", "type": "wall",
}, },
"UUID-13" => { "UUID-13" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"subType": "start", "subType": "start",
"sweepId": "UUID",
"type": "cap", "type": "cap",
}, },
"UUID-14" => { "UUID-14" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"subType": "end", "subType": "end",
"sweepId": "UUID",
"type": "cap", "type": "cap",
}, },
"UUID-15" => { "UUID-15" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "opposite", "subType": "opposite",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-16" => { "UUID-16" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "adjacent", "subType": "adjacent",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-17" => { "UUID-17" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "opposite", "subType": "opposite",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-18" => { "UUID-18" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "adjacent", "subType": "adjacent",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-19" => { "UUID-19" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "opposite", "subType": "opposite",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-20" => { "UUID-20" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "adjacent", "subType": "adjacent",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-21" => { "UUID-21" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "opposite", "subType": "opposite",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-22" => { "UUID-22" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "adjacent", "subType": "adjacent",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-23" => { "UUID-23" => {
"codeRef": { "codeRef": {
@ -308,7 +309,6 @@ Map {
395, 395,
], ],
}, },
"extrusionId": "UUID",
"planeId": "UUID", "planeId": "UUID",
"segIds": [ "segIds": [
"UUID", "UUID",
@ -317,6 +317,7 @@ Map {
"UUID", "UUID",
], ],
"solid2dId": "UUID", "solid2dId": "UUID",
"sweepId": "UUID",
"type": "path", "type": "path",
}, },
"UUID-25" => { "UUID-25" => {
@ -425,6 +426,7 @@ Map {
"UUID", "UUID",
], ],
"pathId": "UUID", "pathId": "UUID",
"subType": "extrusion",
"surfaceIds": [ "surfaceIds": [
"UUID", "UUID",
"UUID", "UUID",
@ -432,78 +434,78 @@ Map {
"UUID", "UUID",
"UUID", "UUID",
], ],
"type": "extrusion", "type": "sweep",
}, },
"UUID-31" => { "UUID-31" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"segId": "UUID", "segId": "UUID",
"sweepId": "UUID",
"type": "wall", "type": "wall",
}, },
"UUID-32" => { "UUID-32" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"segId": "UUID", "segId": "UUID",
"sweepId": "UUID",
"type": "wall", "type": "wall",
}, },
"UUID-33" => { "UUID-33" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"segId": "UUID", "segId": "UUID",
"sweepId": "UUID",
"type": "wall", "type": "wall",
}, },
"UUID-34" => { "UUID-34" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"subType": "start", "subType": "start",
"sweepId": "UUID",
"type": "cap", "type": "cap",
}, },
"UUID-35" => { "UUID-35" => {
"edgeCutEdgeIds": [], "edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [], "pathIds": [],
"subType": "end", "subType": "end",
"sweepId": "UUID",
"type": "cap", "type": "cap",
}, },
"UUID-36" => { "UUID-36" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "opposite", "subType": "opposite",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-37" => { "UUID-37" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "adjacent", "subType": "adjacent",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-38" => { "UUID-38" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "opposite", "subType": "opposite",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-39" => { "UUID-39" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "adjacent", "subType": "adjacent",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-40" => { "UUID-40" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "opposite", "subType": "opposite",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
"UUID-41" => { "UUID-41" => {
"extrusionId": "UUID",
"segId": "UUID", "segId": "UUID",
"subType": "adjacent", "subType": "adjacent",
"type": "extrudeEdge", "sweepId": "UUID",
"type": "sweepEdge",
}, },
} }
`; `;

View File

@ -7,7 +7,7 @@ import {
filterArtifacts, filterArtifacts,
expandPlane, expandPlane,
expandPath, expandPath,
expandExtrusion, expandSweep,
ArtifactGraph, ArtifactGraph,
expandSegment, expandSegment,
getArtifactsToUpdate, getArtifactsToUpdate,
@ -194,13 +194,13 @@ describe('testing createArtifactGraph', () => {
}) })
it('there should be two extrusions, for the original and the sketchOnFace, the first extrusion should have 6 sides of the cube', () => { it('there should be two extrusions, for the original and the sketchOnFace, the first extrusion should have 6 sides of the cube', () => {
const extrusions = [ const extrusions = [...filterArtifacts({ types: ['sweep'] }, theMap)].map(
...filterArtifacts({ types: ['extrusion'] }, theMap), (extrusion) => expandSweep(extrusion[1], theMap)
].map((extrusion) => expandExtrusion(extrusion[1], theMap)) )
expect(extrusions).toHaveLength(2) expect(extrusions).toHaveLength(2)
extrusions.forEach((extrusion, index) => { extrusions.forEach((extrusion, index) => {
if (err(extrusion)) throw extrusion if (err(extrusion)) throw extrusion
expect(extrusion.type).toBe('extrusion') expect(extrusion.type).toBe('sweep')
const firstExtrusionIsACubeIE6Sides = 6 const firstExtrusionIsACubeIE6Sides = 6
const secondExtrusionIsATriangularPrismIE5Sides = 5 const secondExtrusionIsATriangularPrismIE5Sides = 5
expect(extrusion.surfaces.length).toBe( expect(extrusion.surfaces.length).toBe(
@ -535,7 +535,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'path', type: 'path',
segIds: [], segIds: [],
planeId: 'UUID-1', planeId: 'UUID-1',
extrusionId: '', sweepId: '',
codeRef: { codeRef: {
pathToNode: [['body', '']], pathToNode: [['body', '']],
range: [43, 70], range: [43, 70],
@ -544,7 +544,8 @@ describe('testing getArtifactsToUpdate', () => {
]) ])
expect(getUpdateObjects('extrude')).toEqual([ expect(getUpdateObjects('extrude')).toEqual([
{ {
type: 'extrusion', type: 'sweep',
subType: 'extrusion',
pathId: expect.any(String), pathId: expect.any(String),
surfaceIds: [], surfaceIds: [],
edgeIds: [], edgeIds: [],
@ -557,7 +558,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'path', type: 'path',
segIds: expect.any(Array), segIds: expect.any(Array),
planeId: expect.any(String), planeId: expect.any(String),
extrusionId: expect.any(String), sweepId: expect.any(String),
codeRef: { codeRef: {
range: [43, 70], range: [43, 70],
pathToNode: [['body', '']], pathToNode: [['body', '']],
@ -580,7 +581,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'path', type: 'path',
segIds: expect.any(Array), segIds: expect.any(Array),
planeId: expect.any(String), planeId: expect.any(String),
extrusionId: expect.any(String), sweepId: expect.any(String),
codeRef: { codeRef: {
range: [43, 70], range: [43, 70],
pathToNode: [['body', '']], pathToNode: [['body', '']],
@ -617,7 +618,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'wall', type: 'wall',
segId: expect.any(String), segId: expect.any(String),
edgeCutEdgeIds: [], edgeCutEdgeIds: [],
extrusionId: expect.any(String), sweepId: expect.any(String),
pathIds: [], pathIds: [],
}, },
{ {
@ -631,7 +632,8 @@ describe('testing getArtifactsToUpdate', () => {
}, },
}, },
{ {
type: 'extrusion', type: 'sweep',
subType: 'extrusion',
pathId: expect.any(String), pathId: expect.any(String),
surfaceIds: expect.any(Array), surfaceIds: expect.any(Array),
edgeIds: expect.any(Array), edgeIds: expect.any(Array),
@ -644,7 +646,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'wall', type: 'wall',
segId: expect.any(String), segId: expect.any(String),
edgeCutEdgeIds: [], edgeCutEdgeIds: [],
extrusionId: expect.any(String), sweepId: expect.any(String),
pathIds: [], pathIds: [],
}, },
{ {
@ -658,7 +660,8 @@ describe('testing getArtifactsToUpdate', () => {
}, },
}, },
{ {
type: 'extrusion', type: 'sweep',
subType: 'extrusion',
pathId: expect.any(String), pathId: expect.any(String),
surfaceIds: expect.any(Array), surfaceIds: expect.any(Array),
edgeIds: expect.any(Array), edgeIds: expect.any(Array),
@ -671,7 +674,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'wall', type: 'wall',
segId: expect.any(String), segId: expect.any(String),
edgeCutEdgeIds: [], edgeCutEdgeIds: [],
extrusionId: expect.any(String), sweepId: expect.any(String),
pathIds: [], pathIds: [],
}, },
{ {
@ -686,7 +689,8 @@ describe('testing getArtifactsToUpdate', () => {
edgeCutId: expect.any(String), edgeCutId: expect.any(String),
}, },
{ {
type: 'extrusion', type: 'sweep',
subType: 'extrusion',
pathId: expect.any(String), pathId: expect.any(String),
surfaceIds: expect.any(Array), surfaceIds: expect.any(Array),
edgeIds: expect.any(Array), edgeIds: expect.any(Array),
@ -699,7 +703,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'wall', type: 'wall',
segId: expect.any(String), segId: expect.any(String),
edgeCutEdgeIds: [], edgeCutEdgeIds: [],
extrusionId: expect.any(String), sweepId: expect.any(String),
pathIds: [], pathIds: [],
}, },
{ {
@ -713,7 +717,8 @@ describe('testing getArtifactsToUpdate', () => {
}, },
}, },
{ {
type: 'extrusion', type: 'sweep',
subType: 'extrusion',
pathId: expect.any(String), pathId: expect.any(String),
surfaceIds: expect.any(Array), surfaceIds: expect.any(Array),
edgeIds: expect.any(Array), edgeIds: expect.any(Array),
@ -726,11 +731,12 @@ describe('testing getArtifactsToUpdate', () => {
type: 'cap', type: 'cap',
subType: 'start', subType: 'start',
edgeCutEdgeIds: [], edgeCutEdgeIds: [],
extrusionId: expect.any(String), sweepId: expect.any(String),
pathIds: [], pathIds: [],
}, },
{ {
type: 'extrusion', type: 'sweep',
subType: 'extrusion',
pathId: expect.any(String), pathId: expect.any(String),
surfaceIds: expect.any(Array), surfaceIds: expect.any(Array),
edgeIds: expect.any(Array), edgeIds: expect.any(Array),
@ -743,11 +749,12 @@ describe('testing getArtifactsToUpdate', () => {
type: 'cap', type: 'cap',
subType: 'end', subType: 'end',
edgeCutEdgeIds: [], edgeCutEdgeIds: [],
extrusionId: expect.any(String), sweepId: expect.any(String),
pathIds: [], pathIds: [],
}, },
{ {
type: 'extrusion', type: 'sweep',
subType: 'extrusion',
pathId: expect.any(String), pathId: expect.any(String),
surfaceIds: expect.any(Array), surfaceIds: expect.any(Array),
edgeIds: expect.any(Array), edgeIds: expect.any(Array),

View File

@ -25,7 +25,7 @@ export interface PathArtifact {
type: 'path' type: 'path'
planeId: ArtifactId planeId: ArtifactId
segIds: Array<ArtifactId> segIds: Array<ArtifactId>
extrusionId: ArtifactId sweepId: ArtifactId
solid2dId?: ArtifactId solid2dId?: ArtifactId
codeRef: CommonCommandProperties codeRef: CommonCommandProperties
} }
@ -38,7 +38,7 @@ export interface PathArtifactRich {
type: 'path' type: 'path'
plane: PlaneArtifact | WallArtifact plane: PlaneArtifact | WallArtifact
segments: Array<SegmentArtifact> segments: Array<SegmentArtifact>
extrusion: ExtrusionArtifact sweep: SweepArtifact
codeRef: CommonCommandProperties codeRef: CommonCommandProperties
} }
@ -54,23 +54,26 @@ interface SegmentArtifactRich {
type: 'segment' type: 'segment'
path: PathArtifact path: PathArtifact
surf: WallArtifact surf: WallArtifact
edges: Array<ExtrudeEdge> edges: Array<SweepEdge>
edgeCut?: EdgeCut edgeCut?: EdgeCut
codeRef: CommonCommandProperties codeRef: CommonCommandProperties
} }
interface ExtrusionArtifact { /** A Sweep is a more generic term for extrude, revolve, loft and sweep*/
type: 'extrusion' interface SweepArtifact {
pathId: ArtifactId type: 'sweep'
surfaceIds: Array<ArtifactId> subType: 'extrusion' | 'revolve'
edgeIds: Array<ArtifactId> pathId: string
surfaceIds: Array<string>
edgeIds: Array<string>
codeRef: CommonCommandProperties codeRef: CommonCommandProperties
} }
interface ExtrusionArtifactRich { interface SweepArtifactRich {
type: 'extrusion' type: 'sweep'
subType: 'extrusion' | 'revolve'
path: PathArtifact path: PathArtifact
surfaces: Array<WallArtifact | CapArtifact> surfaces: Array<WallArtifact | CapArtifact>
edges: Array<ExtrudeEdge> edges: Array<SweepEdge>
codeRef: CommonCommandProperties codeRef: CommonCommandProperties
} }
@ -78,21 +81,21 @@ interface WallArtifact {
type: 'wall' type: 'wall'
segId: ArtifactId segId: ArtifactId
edgeCutEdgeIds: Array<ArtifactId> edgeCutEdgeIds: Array<ArtifactId>
extrusionId: ArtifactId sweepId: ArtifactId
pathIds: Array<ArtifactId> pathIds: Array<ArtifactId>
} }
interface CapArtifact { interface CapArtifact {
type: 'cap' type: 'cap'
subType: 'start' | 'end' subType: 'start' | 'end'
edgeCutEdgeIds: Array<ArtifactId> edgeCutEdgeIds: Array<ArtifactId>
extrusionId: ArtifactId sweepId: ArtifactId
pathIds: Array<ArtifactId> pathIds: Array<ArtifactId>
} }
interface ExtrudeEdge { interface SweepEdge {
type: 'extrudeEdge' type: 'sweepEdge'
segId: ArtifactId segId: ArtifactId
extrusionId: ArtifactId sweepId: ArtifactId
subType: 'opposite' | 'adjacent' subType: 'opposite' | 'adjacent'
} }
@ -116,10 +119,10 @@ export type Artifact =
| PlaneArtifact | PlaneArtifact
| PathArtifact | PathArtifact
| SegmentArtifact | SegmentArtifact
| ExtrusionArtifact | SweepArtifact
| WallArtifact | WallArtifact
| CapArtifact | CapArtifact
| ExtrudeEdge | SweepEdge
| EdgeCut | EdgeCut
| EdgeCutEdge | EdgeCutEdge
| solid2D | solid2D
@ -257,7 +260,7 @@ export function getArtifactsToUpdate({
type: 'wall', type: 'wall',
segId: existingPlane.segId, segId: existingPlane.segId,
edgeCutEdgeIds: existingPlane.edgeCutEdgeIds, edgeCutEdgeIds: existingPlane.edgeCutEdgeIds,
extrusionId: existingPlane.extrusionId, sweepId: existingPlane.sweepId,
pathIds: existingPlane.pathIds, pathIds: existingPlane.pathIds,
}, },
}, },
@ -274,7 +277,7 @@ export function getArtifactsToUpdate({
type: 'path', type: 'path',
segIds: [], segIds: [],
planeId: currentPlaneId, planeId: currentPlaneId,
extrusionId: '', sweepId: '',
codeRef: { range, pathToNode }, codeRef: { range, pathToNode },
}, },
}) })
@ -294,7 +297,7 @@ export function getArtifactsToUpdate({
type: 'wall', type: 'wall',
segId: plane.segId, segId: plane.segId,
edgeCutEdgeIds: plane.edgeCutEdgeIds, edgeCutEdgeIds: plane.edgeCutEdgeIds,
extrusionId: plane.extrusionId, sweepId: plane.sweepId,
pathIds: [id], pathIds: [id],
}, },
}) })
@ -337,11 +340,13 @@ export function getArtifactsToUpdate({
}) })
} }
return returnArr return returnArr
} else if (cmd.type === 'extrude') { } else if (cmd.type === 'extrude' || cmd.type === 'revolve') {
const subType = cmd.type === 'extrude' ? 'extrusion' : cmd.type
returnArr.push({ returnArr.push({
id, id,
artifact: { artifact: {
type: 'extrusion', type: 'sweep',
subType: subType,
pathId: cmd.target, pathId: cmd.target,
surfaceIds: [], surfaceIds: [],
edgeIds: [], edgeIds: [],
@ -352,7 +357,7 @@ export function getArtifactsToUpdate({
if (path?.type === 'path') if (path?.type === 'path')
returnArr.push({ returnArr.push({
id: cmd.target, id: cmd.target,
artifact: { ...path, extrusionId: id }, artifact: { ...path, sweepId: id },
}) })
return returnArr return returnArr
} else if ( } else if (
@ -375,7 +380,7 @@ export function getArtifactsToUpdate({
type: 'wall', type: 'wall',
segId: curve_id, segId: curve_id,
edgeCutEdgeIds: [], edgeCutEdgeIds: [],
extrusionId: path.extrusionId, sweepId: path.sweepId,
pathIds: [], pathIds: [],
}, },
}) })
@ -383,12 +388,12 @@ export function getArtifactsToUpdate({
id: curve_id, id: curve_id,
artifact: { ...seg, surfaceId: face_id }, artifact: { ...seg, surfaceId: face_id },
}) })
const extrusion = getArtifact(path.extrusionId) const sweep = getArtifact(path.sweepId)
if (extrusion?.type === 'extrusion') { if (sweep?.type === 'sweep') {
returnArr.push({ returnArr.push({
id: path.extrusionId, id: path.sweepId,
artifact: { artifact: {
...extrusion, ...sweep,
surfaceIds: [face_id], surfaceIds: [face_id],
}, },
}) })
@ -407,16 +412,16 @@ export function getArtifactsToUpdate({
type: 'cap', type: 'cap',
subType: cap === 'bottom' ? 'start' : 'end', subType: cap === 'bottom' ? 'start' : 'end',
edgeCutEdgeIds: [], edgeCutEdgeIds: [],
extrusionId: path.extrusionId, sweepId: path.sweepId,
pathIds: [], pathIds: [],
}, },
}) })
const extrusion = getArtifact(path.extrusionId) const sweep = getArtifact(path.sweepId)
if (extrusion?.type !== 'extrusion') return if (sweep?.type !== 'sweep') return
returnArr.push({ returnArr.push({
id: path.extrusionId, id: path.sweepId,
artifact: { artifact: {
...extrusion, ...sweep,
surfaceIds: [face_id], surfaceIds: [face_id],
}, },
}) })
@ -439,9 +444,9 @@ export function getArtifactsToUpdate({
) { ) {
const wall = getArtifact(cmd.face_id) const wall = getArtifact(cmd.face_id)
if (wall?.type !== 'wall') return returnArr if (wall?.type !== 'wall') return returnArr
const extrusion = getArtifact(wall.extrusionId) const sweep = getArtifact(wall.sweepId)
if (extrusion?.type !== 'extrusion') return returnArr if (sweep?.type !== 'sweep') return returnArr
const path = getArtifact(extrusion.pathId) const path = getArtifact(sweep.pathId)
if (path?.type !== 'path') return returnArr if (path?.type !== 'path') return returnArr
const segment = getArtifact(cmd.edge_id) const segment = getArtifact(cmd.edge_id)
if (segment?.type !== 'segment') return returnArr if (segment?.type !== 'segment') return returnArr
@ -450,13 +455,13 @@ export function getArtifactsToUpdate({
{ {
id: response.data.modeling_response.data.edge, id: response.data.modeling_response.data.edge,
artifact: { artifact: {
type: 'extrudeEdge', type: 'sweepEdge',
subType: subType:
cmd.type === 'solid3d_get_prev_adjacent_edge' cmd.type === 'solid3d_get_prev_adjacent_edge'
? 'adjacent' ? 'adjacent'
: 'opposite', : 'opposite',
segId: cmd.edge_id, segId: cmd.edge_id,
extrusionId: path.extrusionId, sweepId: path.sweepId,
}, },
}, },
{ {
@ -467,9 +472,9 @@ export function getArtifactsToUpdate({
}, },
}, },
{ {
id: path.extrusionId, id: path.sweepId,
artifact: { artifact: {
...extrusion, ...sweep,
edgeIds: [response.data.modeling_response.data.edge], edgeIds: [response.data.modeling_response.data.edge],
}, },
}, },
@ -582,10 +587,10 @@ export function expandPath(
{ keys: path.segIds, types: ['segment'] }, { keys: path.segIds, types: ['segment'] },
artifactGraph artifactGraph
) )
const extrusion = getArtifactOfTypes( const sweep = getArtifactOfTypes(
{ {
key: path.extrusionId, key: path.sweepId,
types: ['extrusion'], types: ['sweep'],
}, },
artifactGraph artifactGraph
) )
@ -593,40 +598,41 @@ export function expandPath(
{ key: path.planeId, types: ['plane', 'wall'] }, { key: path.planeId, types: ['plane', 'wall'] },
artifactGraph artifactGraph
) )
if (err(extrusion)) return extrusion if (err(sweep)) return sweep
if (err(plane)) return plane if (err(plane)) return plane
return { return {
type: 'path', type: 'path',
segments: Array.from(segs.values()), segments: Array.from(segs.values()),
extrusion, sweep,
plane, plane,
codeRef: path.codeRef, codeRef: path.codeRef,
} }
} }
export function expandExtrusion( export function expandSweep(
extrusion: ExtrusionArtifact, sweep: SweepArtifact,
artifactGraph: ArtifactGraph artifactGraph: ArtifactGraph
): ExtrusionArtifactRich | Error { ): SweepArtifactRich | Error {
const surfs = getArtifactsOfTypes( const surfs = getArtifactsOfTypes(
{ keys: extrusion.surfaceIds, types: ['wall', 'cap'] }, { keys: sweep.surfaceIds, types: ['wall', 'cap'] },
artifactGraph artifactGraph
) )
const edges = getArtifactsOfTypes( const edges = getArtifactsOfTypes(
{ keys: extrusion.edgeIds, types: ['extrudeEdge'] }, { keys: sweep.edgeIds, types: ['sweepEdge'] },
artifactGraph artifactGraph
) )
const path = getArtifactOfTypes( const path = getArtifactOfTypes(
{ key: extrusion.pathId, types: ['path'] }, { key: sweep.pathId, types: ['path'] },
artifactGraph artifactGraph
) )
if (err(path)) return path if (err(path)) return path
return { return {
type: 'extrusion', type: 'sweep',
subType: 'extrusion',
surfaces: Array.from(surfs.values()), surfaces: Array.from(surfs.values()),
edges: Array.from(edges.values()), edges: Array.from(edges.values()),
path, path,
codeRef: extrusion.codeRef, codeRef: sweep.codeRef,
} }
} }
@ -643,7 +649,7 @@ export function expandSegment(
artifactGraph artifactGraph
) )
const edges = getArtifactsOfTypes( const edges = getArtifactsOfTypes(
{ keys: segment.edgeIds, types: ['extrudeEdge'] }, { keys: segment.edgeIds, types: ['sweepEdge'] },
artifactGraph artifactGraph
) )
const edgeCut = segment.edgeCutId const edgeCut = segment.edgeCutId
@ -670,13 +676,13 @@ export function getCapCodeRef(
cap: CapArtifact, cap: CapArtifact,
artifactGraph: ArtifactGraph artifactGraph: ArtifactGraph
): CommonCommandProperties | Error { ): CommonCommandProperties | Error {
const extrusion = getArtifactOfTypes( const sweep = getArtifactOfTypes(
{ key: cap.extrusionId, types: ['extrusion'] }, { key: cap.sweepId, types: ['sweep'] },
artifactGraph artifactGraph
) )
if (err(extrusion)) return extrusion if (err(sweep)) return sweep
const path = getArtifactOfTypes( const path = getArtifactOfTypes(
{ key: extrusion.pathId, types: ['path'] }, { key: sweep.pathId, types: ['path'] },
artifactGraph artifactGraph
) )
if (err(path)) return path if (err(path)) return path
@ -707,8 +713,8 @@ export function getWallCodeRef(
return seg.codeRef return seg.codeRef
} }
export function getExtrudeEdgeCodeRef( export function getSweepEdgeCodeRef(
edge: ExtrudeEdge, edge: SweepEdge,
artifactGraph: ArtifactGraph artifactGraph: ArtifactGraph
): CommonCommandProperties | Error { ): CommonCommandProperties | Error {
const seg = getArtifactOfTypes( const seg = getArtifactOfTypes(
@ -719,29 +725,29 @@ export function getExtrudeEdgeCodeRef(
return seg.codeRef return seg.codeRef
} }
export function getExtrusionFromSuspectedExtrudeSurface( export function getSweepFromSuspectedSweepSurface(
id: ArtifactId, id: ArtifactId,
artifactGraph: ArtifactGraph artifactGraph: ArtifactGraph
): ExtrusionArtifact | Error { ): SweepArtifact | Error {
const artifact = getArtifactOfTypes( const artifact = getArtifactOfTypes(
{ key: id, types: ['wall', 'cap'] }, { key: id, types: ['wall', 'cap'] },
artifactGraph artifactGraph
) )
if (err(artifact)) return artifact if (err(artifact)) return artifact
return getArtifactOfTypes( return getArtifactOfTypes(
{ key: artifact.extrusionId, types: ['extrusion'] }, { key: artifact.sweepId, types: ['sweep'] },
artifactGraph artifactGraph
) )
} }
export function getExtrusionFromSuspectedPath( export function getSweepFromSuspectedPath(
id: ArtifactId, id: ArtifactId,
artifactGraph: ArtifactGraph artifactGraph: ArtifactGraph
): ExtrusionArtifact | 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
return getArtifactOfTypes( return getArtifactOfTypes(
{ key: path.extrusionId, types: ['extrusion'] }, { key: path.sweepId, types: ['sweep'] },
artifactGraph artifactGraph
) )
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 KiB

After

Width:  |  Height:  |  Size: 378 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 617 KiB

After

Width:  |  Height:  |  Size: 613 KiB

View File

@ -31,7 +31,7 @@ import {
getArtifactOfTypes, getArtifactOfTypes,
getArtifactsOfTypes, getArtifactsOfTypes,
getCapCodeRef, getCapCodeRef,
getExtrudeEdgeCodeRef, getSweepEdgeCodeRef,
getSolid2dCodeRef, getSolid2dCodeRef,
getWallCodeRef, getWallCodeRef,
} from 'lang/std/artifactGraph' } from 'lang/std/artifactGraph'
@ -141,8 +141,8 @@ export async function getEventForSelectWithPoint({
}, },
} }
} }
if (_artifact.type === 'extrudeEdge') { if (_artifact.type === 'sweepEdge') {
const codeRef = getExtrudeEdgeCodeRef( const codeRef = getSweepEdgeCodeRef(
_artifact, _artifact,
engineCommandManager.artifactGraph engineCommandManager.artifactGraph
) )
@ -575,12 +575,10 @@ function codeToIdSelections(
} }
if (type === 'edge' && entry.artifact.type === 'segment') { if (type === 'edge' && entry.artifact.type === 'segment') {
const edges = getArtifactsOfTypes( const edges = getArtifactsOfTypes(
{ keys: entry.artifact.edgeIds, types: ['extrudeEdge'] }, { keys: entry.artifact.edgeIds, types: ['sweepEdge'] },
engineCommandManager.artifactGraph engineCommandManager.artifactGraph
) )
const edge = [...edges].find( const edge = [...edges].find(([_, edge]) => edge.type === 'sweepEdge')
([_, edge]) => edge.type === 'extrudeEdge'
)
if (!edge) return if (!edge) return
bestCandidate = { bestCandidate = {
artifact: edge[1], artifact: edge[1],
@ -590,12 +588,12 @@ function codeToIdSelections(
} }
if (type === 'adjacent-edge' && entry.artifact.type === 'segment') { if (type === 'adjacent-edge' && entry.artifact.type === 'segment') {
const edges = getArtifactsOfTypes( const edges = getArtifactsOfTypes(
{ keys: entry.artifact.edgeIds, types: ['extrudeEdge'] }, { keys: entry.artifact.edgeIds, types: ['sweepEdge'] },
engineCommandManager.artifactGraph engineCommandManager.artifactGraph
) )
const edge = [...edges].find( const edge = [...edges].find(
([_, edge]) => ([_, edge]) =>
edge.type === 'extrudeEdge' && edge.subType === 'adjacent' edge.type === 'sweepEdge' && edge.subType === 'adjacent'
) )
if (!edge) return if (!edge) return
bestCandidate = { bestCandidate = {
@ -610,8 +608,8 @@ function codeToIdSelections(
) { ) {
const extrusion = getArtifactOfTypes( const extrusion = getArtifactOfTypes(
{ {
key: entry.artifact.extrusionId, key: entry.artifact.sweepId,
types: ['extrusion'], types: ['sweep'],
}, },
engineCommandManager.artifactGraph engineCommandManager.artifactGraph
) )