diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 071b9f7c9..ccd2bfee0 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -3,7 +3,6 @@ on: push: branches: [ main ] pull_request: - branches: [ main ] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-2d-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-2d-1-Google-Chrome-linux.png index ad531712f..e528e2e14 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-2d-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-2d-1-Google-Chrome-linux.png differ diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png index 0f78b3e42..266886d69 100644 Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png differ diff --git a/src/components/Stream.tsx b/src/components/Stream.tsx index 3ab1f7bd0..b465c847c 100644 --- a/src/components/Stream.tsx +++ b/src/components/Stream.tsx @@ -302,7 +302,7 @@ export const Stream = () => { return } const path = getArtifactOfTypes( - { key: entity_id, types: ['path', 'solid2d', 'segment'] }, + { key: entity_id, types: ['path', 'solid2d', 'segment', 'helix'] }, engineCommandManager.artifactGraph ) if (err(path)) { diff --git a/src/lang/modifyAst.ts b/src/lang/modifyAst.ts index 81a49f3c5..3eb8e2aeb 100644 --- a/src/lang/modifyAst.ts +++ b/src/lang/modifyAst.ts @@ -1375,6 +1375,7 @@ export async function deleteFromSelection( varDec.node.init.type === 'PipeExpression') || selection.artifact?.type === 'sweep' || selection.artifact?.type === 'plane' || + selection.artifact?.type === 'helix' || !selection.artifact // aka expected to be a shell at this point ) { let extrudeNameToDelete = '' @@ -1382,7 +1383,8 @@ export async function deleteFromSelection( if ( selection.artifact && selection.artifact.type !== 'sweep' && - selection.artifact.type !== 'plane' + selection.artifact.type !== 'plane' && + selection.artifact.type !== 'helix' ) { const varDecName = varDec.node.id.name traverse(astClone, { @@ -1421,13 +1423,17 @@ export async function deleteFromSelection( if (!pathToNode) return new Error('Could not find extrude variable') } else { pathToNode = selection.codeRef.pathToNode - const extrudeVarDec = getNodeFromPath( - astClone, - pathToNode, - 'VariableDeclarator' - ) - if (err(extrudeVarDec)) return extrudeVarDec - extrudeNameToDelete = extrudeVarDec.node.id.name + if (varDec.node.type !== 'VariableDeclarator') { + const callExp = getNodeFromPath( + astClone, + pathToNode, + 'CallExpression' + ) + if (err(callExp)) return callExp + extrudeNameToDelete = callExp.node.callee.name + } else { + extrudeNameToDelete = varDec.node.id.name + } } const expressionIndex = pathToNode[1][0] as number diff --git a/src/wasm-lib/kcl/src/execution/artifact.rs b/src/wasm-lib/kcl/src/execution/artifact.rs index 90d04be5e..c17054097 100644 --- a/src/wasm-lib/kcl/src/execution/artifact.rs +++ b/src/wasm-lib/kcl/src/execution/artifact.rs @@ -269,6 +269,17 @@ pub struct EdgeCutEdge { pub surface_id: ArtifactId, } +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS)] +#[ts(export_to = "Artifact.ts")] +#[serde(rename_all = "camelCase")] +pub struct Helix { + pub id: ArtifactId, + /// The axis of the helix. Currently this is always an edge ID, but we may + /// add axes to the graph. + pub axis_id: Option, + pub code_ref: CodeRef, +} + #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS)] #[ts(export_to = "Artifact.ts")] #[serde(tag = "type", rename_all = "camelCase")] @@ -295,6 +306,7 @@ pub enum Artifact { SweepEdge(SweepEdge), EdgeCut(EdgeCut), EdgeCutEdge(EdgeCutEdge), + Helix(Helix), } impl Artifact { @@ -312,6 +324,7 @@ impl Artifact { Artifact::SweepEdge(a) => a.id, Artifact::EdgeCut(a) => a.id, Artifact::EdgeCutEdge(a) => a.id, + Artifact::Helix(a) => a.id, } } @@ -331,6 +344,7 @@ impl Artifact { Artifact::SweepEdge(_) => None, Artifact::EdgeCut(a) => Some(&a.code_ref), Artifact::EdgeCutEdge(_) => None, + Artifact::Helix(a) => Some(&a.code_ref), } } @@ -350,6 +364,7 @@ impl Artifact { Artifact::SweepEdge(_) => Some(new), Artifact::EdgeCut(a) => a.merge(new), Artifact::EdgeCutEdge(_) => Some(new), + Artifact::Helix(_) => Some(new), } } } @@ -924,6 +939,25 @@ fn artifacts_to_update( } return Ok(return_arr); } + ModelingCmd::EntityMakeHelixFromParams(_) => { + let return_arr = vec![Artifact::Helix(Helix { + id, + axis_id: None, + code_ref: CodeRef { range, path_to_node }, + })]; + return Ok(return_arr); + } + ModelingCmd::EntityMakeHelixFromEdge(helix) => { + let edge_id = ArtifactId::new(helix.edge_id); + let return_arr = vec![Artifact::Helix(Helix { + id, + axis_id: Some(edge_id), + code_ref: CodeRef { range, path_to_node }, + })]; + // We could add the reverse graph edge connecting from the edge to + // the helix here, but it's not useful right now. + return Ok(return_arr); + } _ => {} } diff --git a/src/wasm-lib/kcl/src/execution/artifact/mermaid_tests.rs b/src/wasm-lib/kcl/src/execution/artifact/mermaid_tests.rs index 608501f89..cadd9934e 100644 --- a/src/wasm-lib/kcl/src/execution/artifact/mermaid_tests.rs +++ b/src/wasm-lib/kcl/src/execution/artifact/mermaid_tests.rs @@ -79,6 +79,7 @@ impl Artifact { Artifact::SweepEdge(a) => vec![a.seg_id, a.sweep_id], Artifact::EdgeCut(a) => vec![a.consumed_edge_id], Artifact::EdgeCutEdge(a) => vec![a.edge_cut_id], + Artifact::Helix(a) => a.axis_id.map(|id| vec![id]).unwrap_or_default(), } } @@ -157,6 +158,10 @@ impl Artifact { // Note: Don't include these since they're parents: edge_cut_id. vec![a.surface_id] } + Artifact::Helix(_) => { + // Note: Don't include these since they're parents: axis_id. + Vec::new() + } } } } @@ -224,7 +229,8 @@ impl ArtifactGraph { | Artifact::Cap(_) | Artifact::SweepEdge(_) | Artifact::EdgeCut(_) - | Artifact::EdgeCutEdge(_) => false, + | Artifact::EdgeCutEdge(_) + | Artifact::Helix(_) => false, }; if !grouped { ungrouped.push(id); @@ -341,6 +347,14 @@ impl ArtifactGraph { Artifact::EdgeCutEdge(_edge_cut_edge) => { writeln!(output, "{prefix}{}[EdgeCutEdge]", id)?; } + Artifact::Helix(helix) => { + writeln!( + output, + "{prefix}{}[\"Helix
{:?}\"]", + id, + code_ref_display(&helix.code_ref) + )?; + } } Ok(()) } @@ -522,6 +536,9 @@ impl ArtifactGraph { Artifact::EdgeCutEdge(_edge_cut_edge) => { writeln!(output, "{prefix}EdgeCutEdge")?; } + Artifact::Helix(_) => { + writeln!(output, "{prefix}Helix")?; + } } if ids_seen.contains(&artifact.id()) { diff --git a/src/wasm-lib/kcl/src/simulation_tests.rs b/src/wasm-lib/kcl/src/simulation_tests.rs index b968a6ea1..6ed3d276d 100644 --- a/src/wasm-lib/kcl/src/simulation_tests.rs +++ b/src/wasm-lib/kcl/src/simulation_tests.rs @@ -1943,3 +1943,24 @@ mod array_elem_pop_fail { super::execute(TEST_NAME, false).await } } +mod helix_simple { + const TEST_NAME: &str = "helix_simple"; + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[test] + fn unparse() { + super::unparse(TEST_NAME) + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, true).await + } +} diff --git a/src/wasm-lib/kcl/tests/helix_simple/artifact_commands.snap b/src/wasm-lib/kcl/tests/helix_simple/artifact_commands.snap new file mode 100644 index 000000000..adab25f88 --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/artifact_commands.snap @@ -0,0 +1,402 @@ +--- +source: kcl/src/simulation_tests.rs +description: Artifact commands helix_simple.kcl +--- +[ + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 1.0, + "z": 0.0 + }, + "size": 100.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "plane_set_color", + "plane_id": "[uuid]", + "color": { + "r": 0.7, + "g": 0.28, + "b": 0.28, + "a": 0.4 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": 0.0, + "y": 1.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "size": 100.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "plane_set_color", + "plane_id": "[uuid]", + "color": { + "r": 0.28, + "g": 0.7, + "b": 0.28, + "a": 0.4 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "size": 100.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "plane_set_color", + "plane_id": "[uuid]", + "color": { + "r": 0.28, + "g": 0.28, + "b": 0.7, + "a": 0.4 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": -1.0, + "y": 0.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 1.0, + "z": 0.0 + }, + "size": 100.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "size": 100.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": -1.0, + "y": 0.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "size": 100.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "edge_lines_visible", + "hidden": false + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "set_scene_units", + "unit": "mm" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 46, + 65, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "size": 60.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 71, + 96, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 71, + 96, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 71, + 96, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 102, + 137, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.0, + "y": 10.0, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 151, + 242, + 0 + ], + "command": { + "type": "entity_make_helix_from_edge", + "radius": 5.0, + "length": 10.0, + "revolutions": 5.0, + "start_angle": { + "unit": "degrees", + "value": 0.0 + }, + "is_clockwise": false, + "edge_id": "[uuid]" + } + } +] diff --git a/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_flowchart.snap b/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_flowchart.snap new file mode 100644 index 000000000..e36842492 --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_flowchart.snap @@ -0,0 +1,6 @@ +--- +source: kcl/src/simulation_tests.rs +description: Artifact graph flowchart helix_simple.kcl +extension: md +snapshot_kind: binary +--- diff --git a/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_flowchart.snap.md b/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_flowchart.snap.md new file mode 100644 index 000000000..5ca288d88 --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_flowchart.snap.md @@ -0,0 +1,12 @@ +```mermaid +flowchart LR + subgraph path2 [Path] + 2["Path
[71, 96, 0]"] + 3["Segment
[102, 137, 0]"] + end + 1["Plane
[46, 65, 0]"] + 4["Helix
[151, 242, 0]"] + 1 --- 2 + 2 --- 3 + 3 <--x 4 +``` diff --git a/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_mind_map.snap b/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_mind_map.snap new file mode 100644 index 000000000..e108172e2 --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_mind_map.snap @@ -0,0 +1,6 @@ +--- +source: kcl/src/simulation_tests.rs +description: Artifact graph mind map helix_simple.kcl +extension: md +snapshot_kind: binary +--- diff --git a/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_mind_map.snap.md b/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_mind_map.snap.md new file mode 100644 index 000000000..9e2c190e8 --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/artifact_graph_mind_map.snap.md @@ -0,0 +1,7 @@ +```mermaid +mindmap + root + Plane + Path + Segment +``` diff --git a/src/wasm-lib/kcl/tests/helix_simple/ast.snap b/src/wasm-lib/kcl/tests/helix_simple/ast.snap new file mode 100644 index 000000000..8009aab8a --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/ast.snap @@ -0,0 +1,336 @@ +--- +source: kcl/src/simulation_tests.rs +description: Result of parsing helix_simple.kcl +--- +{ + "Ok": { + "body": [ + { + "declaration": { + "end": 137, + "id": { + "end": 43, + "name": "helper001", + "start": 34, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 64, + "raw": "'XZ'", + "start": 60, + "type": "Literal", + "type": "Literal", + "value": "XZ" + } + ], + "callee": { + "end": 59, + "name": "startSketchOn", + "start": 46, + "type": "Identifier" + }, + "end": 65, + "start": 46, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 88, + "raw": "0", + "start": 87, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 91, + "raw": "0", + "start": 90, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 92, + "start": 86, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 95, + "start": 94, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 85, + "name": "startProfileAt", + "start": 71, + "type": "Identifier" + }, + "end": 96, + "start": 71, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "elements": [ + { + "end": 115, + "raw": "0", + "start": 114, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 119, + "raw": "10", + "start": 117, + "type": "Literal", + "type": "Literal", + "value": { + "value": 10.0, + "suffix": "None" + } + } + ], + "end": 120, + "start": 113, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "tag" + }, + "arg": { + "end": 136, + "start": 128, + "type": "TagDeclarator", + "type": "TagDeclarator", + "value": "edge001" + } + } + ], + "callee": { + "end": 106, + "name": "line", + "start": 102, + "type": "Identifier" + }, + "end": 137, + "start": 102, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 137, + "start": 46, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 34, + "type": "VariableDeclarator" + }, + "end": 137, + "kind": "const", + "start": 34, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declaration": { + "end": 242, + "id": { + "end": 148, + "name": "helixPath", + "start": 139, + "type": "Identifier" + }, + "init": { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "angleStart" + }, + "arg": { + "end": 171, + "raw": "0", + "start": 170, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "ccw" + }, + "arg": { + "end": 183, + "raw": "true", + "start": 179, + "type": "Literal", + "type": "Literal", + "value": true + } + }, + { + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "revolutions" + }, + "arg": { + "end": 200, + "raw": "5", + "start": 199, + "type": "Literal", + "type": "Literal", + "value": { + "value": 5.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "length" + }, + "arg": { + "end": 213, + "raw": "10", + "start": 211, + "type": "Literal", + "type": "Literal", + "value": { + "value": 10.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "radius" + }, + "arg": { + "end": 225, + "raw": "5", + "start": 224, + "type": "Literal", + "type": "Literal", + "value": { + "value": 5.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "axis" + }, + "arg": { + "end": 241, + "name": "edge001", + "start": 234, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "callee": { + "end": 156, + "name": "helix", + "start": 151, + "type": "Identifier" + }, + "end": 242, + "start": 151, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + "start": 139, + "type": "VariableDeclarator" + }, + "end": 242, + "kind": "const", + "start": 139, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + } + ], + "end": 243, + "nonCodeMeta": { + "nonCodeNodes": { + "0": [ + { + "end": 139, + "start": 137, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [ + { + "end": 33, + "start": 0, + "type": "NonCodeNode", + "value": { + "type": "blockComment", + "value": "Create a helix around an edge.", + "style": "line" + } + } + ] + }, + "start": 0 + } +} diff --git a/src/wasm-lib/kcl/tests/helix_simple/input.kcl b/src/wasm-lib/kcl/tests/helix_simple/input.kcl new file mode 100644 index 000000000..f732df7a0 --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/input.kcl @@ -0,0 +1,6 @@ +// Create a helix around an edge. +helper001 = startSketchOn('XZ') + |> startProfileAt([0, 0], %) + |> line(end = [0, 10], tag = $edge001) + +helixPath = helix(angleStart = 0, ccw = true, revolutions = 5, length = 10, radius = 5, axis = edge001) diff --git a/src/wasm-lib/kcl/tests/helix_simple/ops.snap b/src/wasm-lib/kcl/tests/helix_simple/ops.snap new file mode 100644 index 000000000..9ac61969f --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/ops.snap @@ -0,0 +1,79 @@ +--- +source: kcl/src/simulation_tests.rs +description: Operations executed helix_simple.kcl +--- +[ + { + "labeledArgs": { + "data": { + "sourceRange": [ + 60, + 64, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 46, + 65, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "angleStart": { + "sourceRange": [ + 170, + 171, + 0 + ] + }, + "axis": { + "sourceRange": [ + 234, + 241, + 0 + ] + }, + "ccw": { + "sourceRange": [ + 179, + 183, + 0 + ] + }, + "length": { + "sourceRange": [ + 211, + 213, + 0 + ] + }, + "radius": { + "sourceRange": [ + 224, + 225, + 0 + ] + }, + "revolutions": { + "sourceRange": [ + 199, + 200, + 0 + ] + } + }, + "name": "helix", + "sourceRange": [ + 151, + 242, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + } +] diff --git a/src/wasm-lib/kcl/tests/helix_simple/program_memory.snap b/src/wasm-lib/kcl/tests/helix_simple/program_memory.snap new file mode 100644 index 000000000..1ab17c067 --- /dev/null +++ b/src/wasm-lib/kcl/tests/helix_simple/program_memory.snap @@ -0,0 +1,245 @@ +--- +source: kcl/src/simulation_tests.rs +description: Program memory after executing helix_simple.kcl +--- +{ + "environments": [ + { + "bindings": { + "HALF_TURN": { + "type": "Number", + "value": 180.0, + "__meta": [] + }, + "QUARTER_TURN": { + "type": "Number", + "value": 90.0, + "__meta": [] + }, + "THREE_QUARTER_TURN": { + "type": "Number", + "value": 270.0, + "__meta": [] + }, + "ZERO": { + "type": "Number", + "value": 0.0, + "__meta": [] + }, + "edge001": { + "type": "TagIdentifier", + "type": "TagIdentifier", + "value": "edge001", + "info": { + "type": "TagEngineInfo", + "id": "[uuid]", + "sketch": "[uuid]", + "path": { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 102, + 137, + 0 + ] + }, + "from": [ + 0.0, + 0.0 + ], + "tag": { + "end": 136, + "start": 128, + "type": "TagDeclarator", + "value": "edge001" + }, + "to": [ + 0.0, + 10.0 + ], + "type": "ToPoint" + }, + "surface": null + }, + "__meta": [ + { + "sourceRange": [ + 128, + 136, + 0 + ] + } + ] + }, + "helixPath": { + "type": "Helix", + "value": { + "value": "[uuid]", + "artifactId": "[uuid]", + "revolutions": 5.0, + "angleStart": 0.0, + "ccw": true, + "units": { + "type": "Mm" + }, + "__meta": [ + { + "sourceRange": [ + 151, + 242, + 0 + ] + } + ] + } + }, + "helper001": { + "type": "Sketch", + "value": { + "type": "Sketch", + "id": "[uuid]", + "paths": [ + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 102, + 137, + 0 + ] + }, + "from": [ + 0.0, + 0.0 + ], + "tag": { + "end": 136, + "start": 128, + "type": "TagDeclarator", + "value": "edge001" + }, + "to": [ + 0.0, + 10.0 + ], + "type": "ToPoint" + } + ], + "on": { + "type": "plane", + "id": "[uuid]", + "artifactId": "[uuid]", + "value": "XZ", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "xAxis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "yAxis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "zAxis": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + }, + "units": { + "type": "Mm" + }, + "__meta": [] + }, + "start": { + "from": [ + 0.0, + 0.0 + ], + "to": [ + 0.0, + 0.0 + ], + "tag": null, + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 71, + 96, + 0 + ] + } + }, + "tags": { + "edge001": { + "type": "TagIdentifier", + "value": "edge001", + "info": { + "type": "TagEngineInfo", + "id": "[uuid]", + "sketch": "[uuid]", + "path": { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [ + 102, + 137, + 0 + ] + }, + "from": [ + 0.0, + 0.0 + ], + "tag": { + "end": 136, + "start": 128, + "type": "TagDeclarator", + "value": "edge001" + }, + "to": [ + 0.0, + 10.0 + ], + "type": "ToPoint" + }, + "surface": null + }, + "__meta": [ + { + "sourceRange": [ + 128, + 136, + 0 + ] + } + ] + } + }, + "artifactId": "[uuid]", + "originalId": "[uuid]", + "units": { + "type": "Mm" + }, + "__meta": [ + { + "sourceRange": [ + 71, + 96, + 0 + ] + } + ] + } + } + }, + "parent": null + } + ], + "currentEnv": 0, + "return": null +} diff --git a/src/wasm-lib/kcl/tests/helix_simple/rendered_model.png b/src/wasm-lib/kcl/tests/helix_simple/rendered_model.png new file mode 100644 index 000000000..afa159705 Binary files /dev/null and b/src/wasm-lib/kcl/tests/helix_simple/rendered_model.png differ