add edges to Artifact Graph (Fillet UI related) (#3675)

* add edges to artifact graph

* update graph snapshot sizes (too cluttered

* fix adjencent reverse issue

* add comments

* remove log

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

* remove log

* remove silly debug

* make wasm-prep windows friendly

* don't swallow error

* more rust tweaks

* Increase test timeout

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
This commit is contained in:
Kurt Hutten
2024-08-30 19:46:48 +10:00
committed by GitHub
parent 1739f3dafe
commit 50259aa052
8 changed files with 267 additions and 35 deletions

View File

@ -9,6 +9,7 @@ import { useModelingContext } from './useModelingContext'
import { getEventForSelectWithPoint } from 'lib/selections'
import {
getCapCodeRef,
getExtrudeEdgeCodeRef,
getExtrusionFromSuspectedExtrudeSurface,
getSolid2dCodeRef,
getWallCodeRef,
@ -60,6 +61,13 @@ export function useEngineConnectionSubscriptions() {
? [codeRef.range]
: [codeRef.range, extrusion.codeRef.range]
)
} else if (artifact?.type === 'extrudeEdge') {
const codeRef = getExtrudeEdgeCodeRef(
artifact,
engineCommandManager.artifactGraph
)
if (err(codeRef)) return
editorManager.setHighlightRange([codeRef.range])
} else if (artifact?.type === 'segment') {
editorManager.setHighlightRange([
artifact?.codeRef?.range || [0, 0],

View File

@ -58,7 +58,10 @@ Map {
92,
],
},
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceId": "UUID",
"type": "segment",
@ -77,7 +80,10 @@ Map {
],
},
"edgeCutId": "UUID",
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceId": "UUID",
"type": "segment",
@ -95,7 +101,10 @@ Map {
156,
],
},
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceId": "UUID",
"type": "segment",
@ -113,7 +122,10 @@ Map {
209,
],
},
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceId": "UUID",
"type": "segment",
@ -152,7 +164,16 @@ Map {
266,
],
},
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
"UUID",
"UUID",
"UUID",
"UUID",
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceIds": [
"UUID",
@ -209,6 +230,54 @@ Map {
"type": "cap",
},
"UUID-15" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "opposite",
"type": "extrudeEdge",
},
"UUID-16" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "adjacent",
"type": "extrudeEdge",
},
"UUID-17" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "opposite",
"type": "extrudeEdge",
},
"UUID-18" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "adjacent",
"type": "extrudeEdge",
},
"UUID-19" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "opposite",
"type": "extrudeEdge",
},
"UUID-20" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "adjacent",
"type": "extrudeEdge",
},
"UUID-21" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "opposite",
"type": "extrudeEdge",
},
"UUID-22" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "adjacent",
"type": "extrudeEdge",
},
"UUID-23" => {
"codeRef": {
"pathToNode": [
[
@ -226,7 +295,7 @@ Map {
"subType": "fillet",
"type": "edgeCut",
},
"UUID-16" => {
"UUID-24" => {
"codeRef": {
"pathToNode": [
[
@ -250,7 +319,7 @@ Map {
"solid2dId": "UUID",
"type": "path",
},
"UUID-17" => {
"UUID-25" => {
"codeRef": {
"pathToNode": [
[
@ -263,12 +332,15 @@ Map {
416,
],
},
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceId": "UUID",
"type": "segment",
},
"UUID-18" => {
"UUID-26" => {
"codeRef": {
"pathToNode": [
[
@ -281,12 +353,15 @@ Map {
438,
],
},
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceId": "UUID",
"type": "segment",
},
"UUID-19" => {
"UUID-27" => {
"codeRef": {
"pathToNode": [
[
@ -299,12 +374,15 @@ Map {
491,
],
},
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceId": "UUID",
"type": "segment",
},
"UUID-20" => {
"UUID-28" => {
"codeRef": {
"pathToNode": [
[
@ -321,11 +399,11 @@ Map {
"pathId": "UUID",
"type": "segment",
},
"UUID-21" => {
"UUID-29" => {
"pathId": "UUID",
"type": "solid2D",
},
"UUID-22" => {
"UUID-30" => {
"codeRef": {
"pathToNode": [
[
@ -338,7 +416,14 @@ Map {
546,
],
},
"edgeIds": [],
"edgeIds": [
"UUID",
"UUID",
"UUID",
"UUID",
"UUID",
"UUID",
],
"pathId": "UUID",
"surfaceIds": [
"UUID",
@ -349,40 +434,76 @@ Map {
],
"type": "extrusion",
},
"UUID-23" => {
"UUID-31" => {
"edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [],
"segId": "UUID",
"type": "wall",
},
"UUID-24" => {
"UUID-32" => {
"edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [],
"segId": "UUID",
"type": "wall",
},
"UUID-25" => {
"UUID-33" => {
"edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [],
"segId": "UUID",
"type": "wall",
},
"UUID-26" => {
"UUID-34" => {
"edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [],
"subType": "start",
"type": "cap",
},
"UUID-27" => {
"UUID-35" => {
"edgeCutEdgeIds": [],
"extrusionId": "UUID",
"pathIds": [],
"subType": "end",
"type": "cap",
},
"UUID-36" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "opposite",
"type": "extrudeEdge",
},
"UUID-37" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "adjacent",
"type": "extrudeEdge",
},
"UUID-38" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "opposite",
"type": "extrudeEdge",
},
"UUID-39" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "adjacent",
"type": "extrudeEdge",
},
"UUID-40" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "opposite",
"type": "extrudeEdge",
},
"UUID-41" => {
"extrusionId": "UUID",
"segId": "UUID",
"subType": "adjacent",
"type": "extrudeEdge",
},
}
`;

View File

@ -247,7 +247,7 @@ describe('testing createArtifactGraph', () => {
// of the edges refers to a non-existent node, the graph will throw.
// further more we can check that each edge is bi-directional, if it's not
// by checking the arrow heads going both ways, on the graph.
await GraphTheGraph(theMap, 1400, 1400, 'exampleCode1.png')
await GraphTheGraph(theMap, 2000, 2000, 'exampleCode1.png')
}, 20000)
})
})
@ -271,7 +271,7 @@ describe('capture graph of sketchOnFaceOnFace...', () => {
// of the edges refers to a non-existent node, the graph will throw.
// further more we can check that each edge is bi-directional, if it's not
// by checking the arrow heads going both ways, on the graph.
await GraphTheGraph(theMap, 2500, 2500, 'sketchOnFaceOnFaceEtc.png')
await GraphTheGraph(theMap, 3000, 3000, 'sketchOnFaceOnFaceEtc.png')
}, 20000)
})
})
@ -603,7 +603,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'segment',
pathId: expect.any(String),
surfaceId: expect.any(String),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [98, 125],
pathToNode: [['body', '']],
@ -623,7 +623,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'segment',
pathId: expect.any(String),
surfaceId: expect.any(String),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [162, 209],
pathToNode: [['body', '']],
@ -633,7 +633,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'extrusion',
pathId: expect.any(String),
surfaceIds: expect.any(Array),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [243, 266],
pathToNode: [['body', '']],
@ -650,7 +650,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'segment',
pathId: expect.any(String),
surfaceId: expect.any(String),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [131, 156],
pathToNode: [['body', '']],
@ -660,7 +660,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'extrusion',
pathId: expect.any(String),
surfaceIds: expect.any(Array),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [243, 266],
pathToNode: [['body', '']],
@ -677,7 +677,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'segment',
pathId: expect.any(String),
surfaceId: expect.any(String),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [98, 125],
pathToNode: [['body', '']],
@ -688,7 +688,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'extrusion',
pathId: expect.any(String),
surfaceIds: expect.any(Array),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [243, 266],
pathToNode: [['body', '']],
@ -705,7 +705,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'segment',
pathId: expect.any(String),
surfaceId: expect.any(String),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [76, 92],
pathToNode: [['body', '']],
@ -715,7 +715,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'extrusion',
pathId: expect.any(String),
surfaceIds: expect.any(Array),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [243, 266],
pathToNode: [['body', '']],
@ -732,7 +732,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'extrusion',
pathId: expect.any(String),
surfaceIds: expect.any(Array),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [243, 266],
pathToNode: [['body', '']],
@ -749,7 +749,7 @@ describe('testing getArtifactsToUpdate', () => {
type: 'extrusion',
pathId: expect.any(String),
surfaceIds: expect.any(Array),
edgeIds: [],
edgeIds: expect.any(Array),
codeRef: {
range: [243, 266],
pathToNode: [['body', '']],

View File

@ -91,7 +91,7 @@ interface ExtrudeEdge {
type: 'extrudeEdge'
segId: string
extrusionId: string
edgeId: string
subType: 'opposite' | 'adjacent'
}
/** A edgeCut is a more generic term for both fillet or chamfer */
@ -422,6 +422,56 @@ export function getArtifactsToUpdate({
}
})
return returnArr
} else if (
// is opposite edge
(cmd.type === 'solid3d_get_opposite_edge' &&
response.type === 'modeling' &&
response.data.modeling_response.type === 'solid3d_get_opposite_edge' &&
response.data.modeling_response.data.edge) ||
// or is adjacent edge
(cmd.type === 'solid3d_get_prev_adjacent_edge' &&
response.type === 'modeling' &&
response.data.modeling_response.type ===
'solid3d_get_prev_adjacent_edge' &&
response.data.modeling_response.data.edge)
) {
const wall = getArtifact(cmd.face_id)
if (wall?.type !== 'wall') return returnArr
const extrusion = getArtifact(wall.extrusionId)
if (extrusion?.type !== 'extrusion') return returnArr
const path = getArtifact(extrusion.pathId)
if (path?.type !== 'path') return returnArr
const segment = getArtifact(cmd.edge_id)
if (segment?.type !== 'segment') return returnArr
return [
{
id: response.data.modeling_response.data.edge,
artifact: {
type: 'extrudeEdge',
subType:
cmd.type === 'solid3d_get_prev_adjacent_edge'
? 'adjacent'
: 'opposite',
segId: cmd.edge_id,
extrusionId: path.extrusionId,
},
},
{
id: cmd.edge_id,
artifact: {
...segment,
edgeIds: [response.data.modeling_response.data.edge],
},
},
{
id: path.extrusionId,
artifact: {
...extrusion,
edgeIds: [response.data.modeling_response.data.edge],
},
},
]
} else if (cmd.type === 'solid3d_fillet_edge') {
returnArr.push({
id,
@ -655,6 +705,18 @@ export function getWallCodeRef(
return seg.codeRef
}
export function getExtrudeEdgeCodeRef(
edge: ExtrudeEdge,
artifactGraph: ArtifactGraph
): CommonCommandProperties | Error {
const seg = getArtifactOfTypes(
{ key: edge.segId, types: ['segment'] },
artifactGraph
)
if (err(seg)) return seg
return seg.codeRef
}
export function getExtrusionFromSuspectedExtrudeSurface(
id: string,
artifactGraph: ArtifactGraph

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 380 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 KiB

After

Width:  |  Height:  |  Size: 617 KiB

View File

@ -33,6 +33,7 @@ import {
getArtifactOfTypes,
getArtifactsOfTypes,
getCapCodeRef,
getExtrudeEdgeCodeRef,
getSolid2dCodeRef,
getWallCodeRef,
} from 'lang/std/artifactGraph'
@ -141,6 +142,20 @@ export async function getEventForSelectWithPoint({
},
}
}
if (_artifact.type === 'extrudeEdge') {
const codeRef = getExtrudeEdgeCodeRef(
_artifact,
engineCommandManager.artifactGraph
)
if (err(codeRef)) return null
return {
type: 'Set selection',
data: {
selectionType: 'singleCodeCursor',
selection: { range: codeRef.range, type: 'edge' },
},
}
}
return null
}

View File

@ -181,6 +181,32 @@ pub(crate) async fn do_post_extrude(
vec![]
};
for face_info in face_infos.iter() {
if face_info.cap == kittycad::types::ExtrusionFaceCapType::None {
if let (Some(curve_id), Some(face_id)) = (face_info.curve_id, face_info.face_id) {
args.batch_modeling_cmd(
uuid::Uuid::new_v4(),
kittycad::types::ModelingCmd::Solid3DGetOppositeEdge {
edge_id: curve_id,
object_id: sketch_group.id,
face_id,
},
)
.await?;
args.batch_modeling_cmd(
uuid::Uuid::new_v4(),
kittycad::types::ModelingCmd::Solid3DGetPrevAdjacentEdge {
edge_id: curve_id,
object_id: sketch_group.id,
face_id,
},
)
.await?;
}
}
}
// Create a hashmap for quick id lookup
let mut face_id_map = std::collections::HashMap::new();
// creating fake ids for start and end caps is to make extrudes mock-execute safe