start of revolve (#1897)
* start of revolve Signed-off-by: Jess Frazelle <github@jessfraz.com> * revolve Signed-off-by: Jess Frazelle <github@jessfraz.com> * more tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * tagged edge Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * bump lib Signed-off-by: Jess Frazelle <github@jessfraz.com> * custom axis Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * add getEdge Signed-off-by: Jess Frazelle <github@jessfraz.com> * bigger Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updatres Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@ -1487,3 +1487,337 @@ async fn serial_test_big_number_angle_to_match_length_y() {
|
||||
1.0,
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_simple_revolve() {
|
||||
let code = r#"const part001 = startSketchOn('XY')
|
||||
|> startProfileAt([4, 12], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([4, -6], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([-3.75, -4.5], %)
|
||||
|> line([0, -5.5], %)
|
||||
|> line([-2, 0], %)
|
||||
|> close(%)
|
||||
|> revolve({axis: 'y'}, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_simple_revolve_uppercase() {
|
||||
let code = r#"const part001 = startSketchOn('XY')
|
||||
|> startProfileAt([4, 12], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([4, -6], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([-3.75, -4.5], %)
|
||||
|> line([0, -5.5], %)
|
||||
|> line([-2, 0], %)
|
||||
|> close(%)
|
||||
|> revolve({axis: 'Y'}, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_uppercase.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_simple_revolve_negative() {
|
||||
let code = r#"const part001 = startSketchOn('XY')
|
||||
|> startProfileAt([4, 12], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([4, -6], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([-3.75, -4.5], %)
|
||||
|> line([0, -5.5], %)
|
||||
|> line([-2, 0], %)
|
||||
|> close(%)
|
||||
|> revolve({axis: '-Y', angle: 180}, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_negative.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_revolve_bad_angle_low() {
|
||||
let code = r#"const part001 = startSketchOn('XY')
|
||||
|> startProfileAt([4, 12], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([4, -6], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([-3.75, -4.5], %)
|
||||
|> line([0, -5.5], %)
|
||||
|> line([-2, 0], %)
|
||||
|> close(%)
|
||||
|> revolve({axis: 'y', angle: -455}, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm).await;
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([278, 314])], message: "Expected angle to be between -360 and 360, found `-455`" }"#
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_revolve_bad_angle_high() {
|
||||
let code = r#"const part001 = startSketchOn('XY')
|
||||
|> startProfileAt([4, 12], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([4, -6], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([-3.75, -4.5], %)
|
||||
|> line([0, -5.5], %)
|
||||
|> line([-2, 0], %)
|
||||
|> close(%)
|
||||
|> revolve({axis: 'y', angle: 455}, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm).await;
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([278, 313])], message: "Expected angle to be between -360 and 360, found `455`" }"#
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_simple_revolve_custom_angle() {
|
||||
let code = r#"const part001 = startSketchOn('XY')
|
||||
|> startProfileAt([4, 12], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([4, -6], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([-3.75, -4.5], %)
|
||||
|> line([0, -5.5], %)
|
||||
|> line([-2, 0], %)
|
||||
|> close(%)
|
||||
|> revolve({axis: 'y', angle: 180}, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_custom_angle.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_simple_revolve_custom_axis() {
|
||||
let code = r#"const part001 = startSketchOn('XY')
|
||||
|> startProfileAt([4, 12], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([4, -6], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([-3.75, -4.5], %)
|
||||
|> line([0, -5.5], %)
|
||||
|> line([-2, 0], %)
|
||||
|> close(%)
|
||||
|> revolve({axis: {custom: {axis: [0, -1, 0], origin: [0,0,0]}}, angle: 180}, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_custom_axis.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_revolve_on_edge() {
|
||||
let code = r#"const box = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, 10], %)
|
||||
|> line([10, 0], %)
|
||||
|> line([0, -10], %, 'revolveAxis')
|
||||
|> close(%)
|
||||
|> extrude(10, %)
|
||||
|
||||
const sketch001 = startSketchOn(box, "end")
|
||||
|> startProfileAt([5, 10], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, 10], %)
|
||||
|> close(%)
|
||||
|> revolve({ axis: getOppositeEdge('revolveAxis', box), angle: 90 }, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_edge.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_revolve_on_edge_get_edge() {
|
||||
let code = r#"const box = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, 10], %)
|
||||
|> line([10, 0], %)
|
||||
|> line([0, -10], %, 'revolveAxis')
|
||||
|> close(%)
|
||||
|> extrude(10, %)
|
||||
|
||||
const sketch001 = startSketchOn(box, "revolveAxis")
|
||||
|> startProfileAt([5, 10], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, 10], %)
|
||||
|> close(%)
|
||||
|> revolve({ axis: getEdge('revolveAxis', box), angle: 90 }, %)
|
||||
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_edge_get_edge.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_revolve_on_face_circle_edge() {
|
||||
let code = r#"const box = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, 20], %)
|
||||
|> line([20, 0], %)
|
||||
|> line([0, -20], %, 'revolveAxis')
|
||||
|> close(%)
|
||||
|> extrude(20, %)
|
||||
|
||||
const sketch001 = startSketchOn(box, "END")
|
||||
|> circle([10,10], 4, %)
|
||||
|> revolve({
|
||||
angle: 90,
|
||||
axis: getOppositeEdge('revolveAxis', box)
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_face_circle_edge.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_revolve_on_face_circle() {
|
||||
let code = r#"const box = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, 20], %)
|
||||
|> line([20, 0], %, 'revolveAxis')
|
||||
|> line([0, -20], %)
|
||||
|> close(%)
|
||||
|> extrude(20, %)
|
||||
|
||||
const sketch001 = startSketchOn(box, "END")
|
||||
|> circle([10,10], 4, %)
|
||||
|> revolve({
|
||||
angle: -90,
|
||||
axis: 'y'
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_face_circle.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_revolve_on_face() {
|
||||
let code = r#"const box = startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([0, 10], %)
|
||||
|> line([10, 0], %)
|
||||
|> line([0, -10], %)
|
||||
|> close(%, 'revolveAxis')
|
||||
|> extrude(10, %)
|
||||
|
||||
const sketch001 = startSketchOn(box, "end")
|
||||
|> startProfileAt([5, 10], %)
|
||||
|> line([0, -10], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, 10], %)
|
||||
|> close(%)
|
||||
|> revolve({
|
||||
axis: 'y',
|
||||
angle: -90,
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/revolve_on_face.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_basic_revolve_circle() {
|
||||
let code = r#"const sketch001 = startSketchOn('XY')
|
||||
|> circle([15, 0], 5, %)
|
||||
|> revolve({
|
||||
angle: 360,
|
||||
axis: 'y'
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/basic_revolve_circle.png", &result, 1.0);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[ignore] // Ignore this test until https://github.com/KittyCAD/engine/pull/1930 is fixed
|
||||
async fn serial_test_simple_revolve_sketch_on_edge() {
|
||||
let code = r#"const part001 = startSketchOn('XY')
|
||||
|> startProfileAt([4, 12], %)
|
||||
|> line([2, 0], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([4, -6], %)
|
||||
|> line([0, -6], %)
|
||||
|> line([-3.75, -4.5], %)
|
||||
|> line([0, -5.5], %)
|
||||
|> line([-2, 0], %)
|
||||
|> close(%)
|
||||
|> revolve({axis: 'y', angle: 180}, %)
|
||||
|
||||
const part002 = startSketchOn(part001, 'end')
|
||||
|> startProfileAt([4.5, -5], %)
|
||||
|> line([0, 5], %)
|
||||
|> line([5, 0], %)
|
||||
|> line([0, -5], %)
|
||||
|> close(%)
|
||||
|> extrude(5, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kittycad::types::UnitLength::Mm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/simple_revolve_sketch_on_edge.png", &result, 1.0);
|
||||
}
|
||||
|
BIN
src/wasm-lib/tests/executor/outputs/basic_revolve_circle.png
Normal file
After Width: | Height: | Size: 149 KiB |
BIN
src/wasm-lib/tests/executor/outputs/revolve_on_edge.png
Normal file
After Width: | Height: | Size: 100 KiB |
BIN
src/wasm-lib/tests/executor/outputs/revolve_on_edge_get_edge.png
Normal file
After Width: | Height: | Size: 105 KiB |
BIN
src/wasm-lib/tests/executor/outputs/revolve_on_face.png
Normal file
After Width: | Height: | Size: 101 KiB |
BIN
src/wasm-lib/tests/executor/outputs/revolve_on_face_circle.png
Normal file
After Width: | Height: | Size: 119 KiB |
After Width: | Height: | Size: 117 KiB |
BIN
src/wasm-lib/tests/executor/outputs/simple_revolve.png
Normal file
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 108 KiB |
BIN
src/wasm-lib/tests/executor/outputs/simple_revolve_negative.png
Normal file
After Width: | Height: | Size: 108 KiB |
After Width: | Height: | Size: 107 KiB |
BIN
src/wasm-lib/tests/executor/outputs/simple_revolve_uppercase.png
Normal file
After Width: | Height: | Size: 114 KiB |