diff --git a/_typos.toml b/_typos.toml index 2677ece60..1b2e6286b 100644 --- a/_typos.toml +++ b/_typos.toml @@ -21,7 +21,7 @@ extend-exclude = [ ] [default.extend-words] -metalness = "metalness" # appearance API +metalness = "metalness" # appearance API Hom = "Hom" # short for homogenous typ = "typ" # used to declare a variable named 'type' which is a reserved keyword in Rust ue = "ue" # short for UnaryExpression @@ -29,6 +29,7 @@ THRE = "THRE" # Weird bug that wrongly detects THREEjs as a typo nwo = "nwo" # don't know what this is about tbh "ot" = "ot" # some abbreviation, idk what "oe" = "oe" # some abbreviation, idk what +"colinear" = "colinear" # some engine shit, kidding [default] extend-ignore-identifiers-re = [ diff --git a/rust/Cargo.lock b/rust/Cargo.lock index a2f999b25..cdb6deaf5 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1935,6 +1935,7 @@ dependencies = [ "measurements", "miette", "mime_guess", + "nalgebra-glm", "parse-display 0.10.0", "pretty_assertions", "pyo3", @@ -2254,6 +2255,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "matrixmultiply" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08" +dependencies = [ + "autocfg", + "rawpointer", +] + [[package]] name = "measurements" version = "0.11.0" @@ -2374,6 +2385,33 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "nalgebra" +version = "0.33.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26aecdf64b707efd1310e3544d709c5c0ac61c13756046aaaba41be5c4f66a3b" +dependencies = [ + "approx 0.5.1", + "matrixmultiply", + "num-complex", + "num-rational", + "num-traits 0.2.19", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-glm" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e441f43bccdf40cb6bd4294321e6983c5bc7b9886112d19fd4c9813976b117e4" +dependencies = [ + "approx 0.5.1", + "nalgebra", + "num-traits 0.2.19", + "simba", +] + [[package]] name = "newline-converter" version = "0.3.0" @@ -2413,6 +2451,15 @@ dependencies = [ "num-traits 0.2.19", ] +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits 0.2.19", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -2443,6 +2490,17 @@ dependencies = [ "num-modular", ] +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits 0.2.19", +] + [[package]] name = "num-traits" version = "0.1.43" @@ -2596,6 +2654,12 @@ dependencies = [ "syn 2.0.100", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pbkdf2" version = "0.12.2" @@ -3094,6 +3158,12 @@ dependencies = [ "getrandom 0.3.1", ] +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + [[package]] name = "rayon" version = "1.10.0" @@ -3377,6 +3447,15 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +[[package]] +name = "safe_arch" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323" +dependencies = [ + "bytemuck", +] + [[package]] name = "same-file" version = "1.0.6" @@ -3632,6 +3711,19 @@ dependencies = [ "libc", ] +[[package]] +name = "simba" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a386a501cd104797982c15ae17aafe8b9261315b5d07e3ec803f2ea26be0fa" +dependencies = [ + "approx 0.5.1", + "num-complex", + "num-traits 0.2.19", + "paste", + "wide", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -4732,6 +4824,16 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "wide" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b5576b9a81633f3e8df296ce0063042a73507636cbe956c61133dd7034ab22" +dependencies = [ + "bytemuck", + "safe_arch", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/rust/kcl-lib/Cargo.toml b/rust/kcl-lib/Cargo.toml index 69159aeb7..310aef0c9 100644 --- a/rust/kcl-lib/Cargo.toml +++ b/rust/kcl-lib/Cargo.toml @@ -50,6 +50,7 @@ lazy_static = { workspace = true } measurements = "0.11.0" miette = { workspace = true } mime_guess = "2.0.5" +nalgebra-glm = "0.19.0" parse-display = "0.10.0" pyo3 = { workspace = true, optional = true } regex = "1.11.1" diff --git a/rust/kcl-lib/src/simulation_tests.rs b/rust/kcl-lib/src/simulation_tests.rs index 83d4c70b0..36bb77a64 100644 --- a/rust/kcl-lib/src/simulation_tests.rs +++ b/rust/kcl-lib/src/simulation_tests.rs @@ -3107,6 +3107,28 @@ mod sketch_on_face_union { super::execute(TEST_NAME, true).await } } +mod revolve_colinear { + const TEST_NAME: &str = "revolve-colinear"; + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[tokio::test(flavor = "multi_thread")] + async fn unparse() { + super::unparse(TEST_NAME).await + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + #[ignore] // until https://github.com/KittyCAD/engine/pull/3417 lands + async fn kcl_test_execute() { + super::execute(TEST_NAME, true).await + } +} mod subtract_regression07 { const TEST_NAME: &str = "subtract_regression07"; diff --git a/rust/kcl-lib/src/std/clone.rs b/rust/kcl-lib/src/std/clone.rs index ae7c4725c..57651eaa0 100644 --- a/rust/kcl-lib/src/std/clone.rs +++ b/rust/kcl-lib/src/std/clone.rs @@ -161,6 +161,7 @@ async fn fix_tags_and_references( }, exec_state, args, + None, ) .await?; diff --git a/rust/kcl-lib/src/std/extrude.rs b/rust/kcl-lib/src/std/extrude.rs index e450be2f2..d06d787df 100644 --- a/rust/kcl-lib/src/std/extrude.rs +++ b/rust/kcl-lib/src/std/extrude.rs @@ -220,6 +220,7 @@ async fn inner_extrude( }, exec_state, &args, + None, ) .await?, ); @@ -234,6 +235,7 @@ pub(crate) struct NamedCapTags<'a> { pub end: Option<&'a TagNode>, } +#[allow(clippy::too_many_arguments)] pub(crate) async fn do_post_extrude<'a>( sketch: &Sketch, #[cfg(feature = "artifact-graph")] solid_id: ArtifactId, @@ -242,6 +244,7 @@ pub(crate) async fn do_post_extrude<'a>( named_cap_tags: &'a NamedCapTags<'a>, exec_state: &mut ExecState, args: &Args, + edge_id: Option, ) -> Result { // Bring the object to the front of the scene. // See: https://github.com/KittyCAD/modeling-app/issues/806 @@ -251,7 +254,9 @@ pub(crate) async fn do_post_extrude<'a>( ) .await?; - let any_edge_id = if let Some(edge_id) = sketch.mirror { + let any_edge_id = if let Some(id) = edge_id { + id + } else if let Some(edge_id) = sketch.mirror { edge_id } else { // The "get extrusion face info" API call requires *any* edge on the sketch being extruded. diff --git a/rust/kcl-lib/src/std/loft.rs b/rust/kcl-lib/src/std/loft.rs index 2a5b8485a..a4237d3ae 100644 --- a/rust/kcl-lib/src/std/loft.rs +++ b/rust/kcl-lib/src/std/loft.rs @@ -187,6 +187,7 @@ async fn inner_loft( }, exec_state, &args, + None, ) .await?, )) diff --git a/rust/kcl-lib/src/std/revolve.rs b/rust/kcl-lib/src/std/revolve.rs index 1413186b2..16bdca022 100644 --- a/rust/kcl-lib/src/std/revolve.rs +++ b/rust/kcl-lib/src/std/revolve.rs @@ -20,6 +20,8 @@ use crate::{ std::{axis_or_reference::Axis2dOrEdgeReference, extrude::do_post_extrude, Args}, }; +extern crate nalgebra_glm as glm; + /// Revolve a sketch or set of sketches around an axis. pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result { let sketches = args.get_unlabeled_kw_arg_typed("sketches", &RuntimeType::sketches(), exec_state)?; @@ -131,8 +133,9 @@ async fn inner_revolve( let mut solids = Vec::new(); for sketch in &sketches { let id = exec_state.next_uuid(); + let tolerance = tolerance.as_ref().map(|t| t.to_mm()).unwrap_or(DEFAULT_TOLERANCE); - match &axis { + let direction = match &axis { Axis2dOrEdgeReference::Axis { direction, origin } => { args.batch_modeling_cmd( id, @@ -149,12 +152,13 @@ async fn inner_revolve( y: LengthUnit(origin[1].to_mm()), z: LengthUnit(0.0), }, - tolerance: LengthUnit(tolerance.as_ref().map(|t| t.to_mm()).unwrap_or(DEFAULT_TOLERANCE)), + tolerance: LengthUnit(tolerance), axis_is_2d: true, opposite: opposite.clone(), }), ) .await?; + glm::DVec2::new(direction[0].to_mm(), direction[1].to_mm()) } Axis2dOrEdgeReference::Edge(edge) => { let edge_id = edge.get_engine_id(exec_state, &args)?; @@ -164,12 +168,29 @@ async fn inner_revolve( angle, target: sketch.id.into(), edge_id, - tolerance: LengthUnit(tolerance.as_ref().map(|t| t.to_mm()).unwrap_or(DEFAULT_TOLERANCE)), + tolerance: LengthUnit(tolerance), opposite: opposite.clone(), }), ) .await?; + //TODO: fix me! Need to be able to calculate this to ensure the path isn't colinear + glm::DVec2::new(0.0, 1.0) } + }; + + let mut edge_id = None; + // If an edge lies on the axis of revolution it will not exist after the revolve, so + // it cannot be used to retrieve data about the solid + for path in sketch.paths.clone() { + let from = path.get_from(); + let to = path.get_to(); + + let dir = glm::DVec2::new(to[0].n - from[0].n, to[1].n - from[1].n); + if glm::are_collinear2d(&dir, &direction, tolerance) { + continue; + } + edge_id = Some(path.get_id()); + break; } solids.push( @@ -185,6 +206,7 @@ async fn inner_revolve( }, exec_state, &args, + edge_id, ) .await?, ); diff --git a/rust/kcl-lib/src/std/sweep.rs b/rust/kcl-lib/src/std/sweep.rs index 0bfbc0267..732c8fd77 100644 --- a/rust/kcl-lib/src/std/sweep.rs +++ b/rust/kcl-lib/src/std/sweep.rs @@ -228,6 +228,7 @@ async fn inner_sweep( }, exec_state, &args, + None, ) .await?, ); diff --git a/rust/kcl-lib/tests/revolve-colinear/artifact_commands.snap b/rust/kcl-lib/tests/revolve-colinear/artifact_commands.snap new file mode 100644 index 000000000..9c91526e9 --- /dev/null +++ b/rust/kcl-lib/tests/revolve-colinear/artifact_commands.snap @@ -0,0 +1,210 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Artifact commands revolve-colinear.kcl +--- +[ + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "edge_lines_visible", + "hidden": false + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [], + "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": [], + "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": [], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.0, + "y": 2.0, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.0, + "y": -2.0, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "revolve", + "target": "[uuid]", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "axis": { + "x": 0.0, + "y": 1.0, + "z": 0.0 + }, + "axis_is_2d": true, + "angle": { + "unit": "degrees", + "value": 360.0 + }, + "tolerance": 0.0000001, + "opposite": "None" + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "solid3d_get_adjacency_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + } +] diff --git a/rust/kcl-lib/tests/revolve-colinear/artifact_graph_flowchart.snap b/rust/kcl-lib/tests/revolve-colinear/artifact_graph_flowchart.snap new file mode 100644 index 000000000..88364e6e3 --- /dev/null +++ b/rust/kcl-lib/tests/revolve-colinear/artifact_graph_flowchart.snap @@ -0,0 +1,6 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Artifact graph flowchart revolve-colinear.kcl +extension: md +snapshot_kind: binary +--- diff --git a/rust/kcl-lib/tests/revolve-colinear/artifact_graph_flowchart.snap.md b/rust/kcl-lib/tests/revolve-colinear/artifact_graph_flowchart.snap.md new file mode 100644 index 000000000..12800ed18 --- /dev/null +++ b/rust/kcl-lib/tests/revolve-colinear/artifact_graph_flowchart.snap.md @@ -0,0 +1,52 @@ +```mermaid +flowchart LR + subgraph path2 [Path] + 2["Path
[29, 54, 0]"] + %% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 1 }] + 3["Segment
[60, 77, 0]"] + %% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 2 }] + 4["Segment
[83, 100, 0]"] + %% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 3 }] + 5["Segment
[106, 124, 0]"] + %% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 4 }] + 6["Segment
[130, 137, 0]"] + %% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 5 }] + 7[Solid2d] + end + 1["Plane
[6, 23, 0]"] + %% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 0 }] + 8["Sweep Revolve
[143, 160, 0]"] + %% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 6 }] + 9[Wall] + %% face_code_ref=Missing NodePath + 10[Wall] + %% face_code_ref=Missing NodePath + 11[Wall] + %% face_code_ref=Missing NodePath + 12["SweepEdge Adjacent"] + 13["SweepEdge Adjacent"] + 1 --- 2 + 2 --- 3 + 2 --- 4 + 2 --- 5 + 2 --- 6 + 2 --- 7 + 2 ---- 8 + 8 <--x 4 + 4 --- 10 + 4 --- 12 + 8 <--x 5 + 5 --- 9 + 5 --- 13 + 8 <--x 6 + 6 --- 11 + 8 --- 9 + 8 --- 10 + 8 --- 11 + 8 --- 12 + 8 --- 13 + 12 <--x 9 + 9 --- 13 + 10 --- 12 + 13 <--x 11 +``` diff --git a/rust/kcl-lib/tests/revolve-colinear/ast.snap b/rust/kcl-lib/tests/revolve-colinear/ast.snap new file mode 100644 index 000000000..08b0103ee --- /dev/null +++ b/rust/kcl-lib/tests/revolve-colinear/ast.snap @@ -0,0 +1,372 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Result of parsing revolve-colinear.kcl +--- +{ + "Ok": { + "body": [ + { + "commentStart": 0, + "declaration": { + "commentStart": 0, + "end": 0, + "id": { + "commentStart": 0, + "end": 0, + "name": "sk0", + "start": 0, + "type": "Identifier" + }, + "init": { + "body": [ + { + "callee": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "startSketchOn", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name" + }, + "commentStart": 0, + "end": 0, + "start": 0, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "XZ", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name", + "type": "Name" + } + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "at", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "elements": [ + { + "commentStart": 0, + "end": 0, + "raw": "0", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "commentStart": 0, + "end": 0, + "raw": "0", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 0, + "start": 0, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "startProfile", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name" + }, + "commentStart": 0, + "end": 0, + "start": 0, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "length", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "2", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + } + } + ], + "callee": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "yLine", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name" + }, + "commentStart": 0, + "end": 0, + "start": 0, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "length", + "start": 0, + "type": "Identifier" + }, + "arg": { + "commentStart": 0, + "end": 0, + "raw": "1", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 1.0, + "suffix": "None" + } + } + } + ], + "callee": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "xLine", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name" + }, + "commentStart": 0, + "end": 0, + "start": 0, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "length", + "start": 0, + "type": "Identifier" + }, + "arg": { + "argument": { + "commentStart": 0, + "end": 0, + "raw": "2", + "start": 0, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "commentStart": 0, + "end": 0, + "operator": "-", + "start": 0, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + } + ], + "callee": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "yLine", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name" + }, + "commentStart": 0, + "end": 0, + "start": 0, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "callee": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "close", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name" + }, + "commentStart": 0, + "end": 0, + "start": 0, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "commentStart": 0, + "end": 0, + "name": "axis", + "start": 0, + "type": "Identifier" + }, + "arg": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "Y", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name", + "type": "Name" + } + } + ], + "callee": { + "abs_path": false, + "commentStart": 0, + "end": 0, + "name": { + "commentStart": 0, + "end": 0, + "name": "revolve", + "start": 0, + "type": "Identifier" + }, + "path": [], + "start": 0, + "type": "Name" + }, + "commentStart": 0, + "end": 0, + "start": 0, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "commentStart": 0, + "end": 0, + "start": 0, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 0, + "type": "VariableDeclarator" + }, + "end": 0, + "kind": "const", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + } + ], + "commentStart": 0, + "end": 0, + "start": 0 + } +} diff --git a/rust/kcl-lib/tests/revolve-colinear/input.kcl b/rust/kcl-lib/tests/revolve-colinear/input.kcl new file mode 100644 index 000000000..6fe44bfc8 --- /dev/null +++ b/rust/kcl-lib/tests/revolve-colinear/input.kcl @@ -0,0 +1,7 @@ +sk0 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> yLine(length = 2) + |> xLine(length = 1) + |> yLine(length = -2) + |> close() + |> revolve(axis = Y) diff --git a/rust/kcl-lib/tests/revolve-colinear/ops.snap b/rust/kcl-lib/tests/revolve-colinear/ops.snap new file mode 100644 index 000000000..814edd5ca --- /dev/null +++ b/rust/kcl-lib/tests/revolve-colinear/ops.snap @@ -0,0 +1,105 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Operations executed revolve-colinear.kcl +--- +[ + { + "labeledArgs": {}, + "name": "startSketchOn", + "sourceRange": [], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Plane", + "artifact_id": "[uuid]" + }, + "sourceRange": [] + } + }, + { + "type": "KclStdLibCall", + "name": "revolve", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [] + }, + "labeledArgs": { + "axis": { + "value": { + "type": "Object", + "value": { + "direction": { + "type": "Array", + "value": [ + { + "type": "Number", + "value": 0.0, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + { + "type": "Number", + "value": 1.0, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + } + ] + }, + "origin": { + "type": "Array", + "value": [ + { + "type": "Number", + "value": 0.0, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + { + "type": "Number", + "value": 0.0, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + } + ] + } + } + }, + "sourceRange": [] + } + }, + "sourceRange": [] + } +] diff --git a/rust/kcl-lib/tests/revolve-colinear/program_memory.snap b/rust/kcl-lib/tests/revolve-colinear/program_memory.snap new file mode 100644 index 000000000..324a5c58c --- /dev/null +++ b/rust/kcl-lib/tests/revolve-colinear/program_memory.snap @@ -0,0 +1,179 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Variables in memory after executing revolve-colinear.kcl +--- +{ + "sk0": { + "type": "Solid", + "value": { + "type": "Solid", + "id": "[uuid]", + "artifactId": "[uuid]", + "value": [ + { + "faceId": "[uuid]", + "id": "[uuid]", + "sourceRange": [], + "tag": null, + "type": "extrudePlane" + }, + { + "faceId": "[uuid]", + "id": "[uuid]", + "sourceRange": [], + "tag": null, + "type": "extrudePlane" + }, + { + "faceId": "[uuid]", + "id": "[uuid]", + "sourceRange": [], + "tag": null, + "type": "extrudePlane" + } + ], + "sketch": { + "type": "Sketch", + "id": "[uuid]", + "paths": [ + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [] + }, + "from": [ + 0.0, + 0.0 + ], + "tag": null, + "to": [ + 0.0, + 2.0 + ], + "type": "ToPoint", + "units": { + "type": "Mm" + } + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [] + }, + "from": [ + 0.0, + 2.0 + ], + "tag": null, + "to": [ + 1.0, + 2.0 + ], + "type": "ToPoint", + "units": { + "type": "Mm" + } + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [] + }, + "from": [ + 1.0, + 2.0 + ], + "tag": null, + "to": [ + 1.0, + 0.0 + ], + "type": "ToPoint", + "units": { + "type": "Mm" + } + }, + { + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [] + }, + "from": [ + 1.0, + 0.0 + ], + "tag": null, + "to": [ + 0.0, + 0.0 + ], + "type": "ToPoint", + "units": { + "type": "Mm" + } + } + ], + "on": { + "artifactId": "[uuid]", + "id": "[uuid]", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "units": { + "type": "Mm" + } + }, + "type": "plane", + "value": "XZ", + "xAxis": { + "x": 1.0, + "y": 0.0, + "z": 0.0, + "units": { + "type": "Unknown" + } + }, + "yAxis": { + "x": 0.0, + "y": 0.0, + "z": 1.0, + "units": { + "type": "Unknown" + } + } + }, + "start": { + "from": [ + 0.0, + 0.0 + ], + "to": [ + 0.0, + 0.0 + ], + "units": { + "type": "Mm" + }, + "tag": null, + "__geoMeta": { + "id": "[uuid]", + "sourceRange": [] + } + }, + "artifactId": "[uuid]", + "originalId": "[uuid]", + "units": { + "type": "Mm" + } + }, + "height": 0.0, + "startCapId": null, + "endCapId": null, + "units": { + "type": "Mm" + }, + "sectional": false + } + } +} diff --git a/rust/kcl-lib/tests/revolve-colinear/rendered_model.png b/rust/kcl-lib/tests/revolve-colinear/rendered_model.png new file mode 100644 index 000000000..eb8ac95b2 Binary files /dev/null and b/rust/kcl-lib/tests/revolve-colinear/rendered_model.png differ diff --git a/rust/kcl-lib/tests/revolve-colinear/unparsed.snap b/rust/kcl-lib/tests/revolve-colinear/unparsed.snap new file mode 100644 index 000000000..bf876898a --- /dev/null +++ b/rust/kcl-lib/tests/revolve-colinear/unparsed.snap @@ -0,0 +1,11 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Result of unparsing revolve-colinear.kcl +--- +sk0 = startSketchOn(XZ) + |> startProfile(at = [0, 0]) + |> yLine(length = 2) + |> xLine(length = 1) + |> yLine(length = -2) + |> close() + |> revolve(axis = Y)