Simplify the pentagon test (#2474)
* plumbus fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * Simplify the pentagon test * Fix up triangle png * Triangle plumbuses now face the camera --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -1121,7 +1121,7 @@ impl ExecutorContext {
|
||||
&self,
|
||||
program: crate::ast::types::Program,
|
||||
memory: &mut ProgramMemory,
|
||||
_body_type: BodyType,
|
||||
body_type: BodyType,
|
||||
) -> Result<ProgramMemory, KclError> {
|
||||
let pipe_info = PipeInfo::default();
|
||||
|
||||
@ -1328,8 +1328,10 @@ impl ExecutorContext {
|
||||
}
|
||||
}
|
||||
|
||||
// Flush the batch queue.
|
||||
self.engine.flush_batch(SourceRange([program.end, program.end])).await?;
|
||||
if BodyType::Root == body_type {
|
||||
// Flush the batch queue.
|
||||
self.engine.flush_batch(SourceRange([program.end, program.end])).await?;
|
||||
}
|
||||
|
||||
Ok(memory.clone())
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
fn make_circle = (face, tag, pos, radius) => {
|
||||
const sg0 = startSketchOn(face, tag)
|
||||
const sg1 = startProfileAt([pos[0] + radius, pos[1]], sg0)
|
||||
const sg2 = arc({
|
||||
angle_end: 360,
|
||||
angle_start: 0,
|
||||
radius: radius
|
||||
}, sg1, 'arc-' + tag)
|
||||
return close(sg2)
|
||||
}
|
||||
|
||||
fn pentagon = (len) => {
|
||||
const sg3 = startSketchOn('XY')
|
||||
const sg4 = startProfileAt([-len / 2, -len / 2], sg3)
|
||||
const sg5 = angledLine({ angle: 0, length: len }, sg4, 'a')
|
||||
const sg6 = angledLine({
|
||||
angle: segAng('a', sg5) + 180 - 108,
|
||||
length: len
|
||||
},sg5, 'b')
|
||||
const sg7 = angledLine({
|
||||
angle: segAng('b', sg6) + 180 - 108,
|
||||
length: len
|
||||
}, sg6, 'c')
|
||||
const sg8 = angledLine({
|
||||
angle: segAng('c', sg7) + 180 - 108,
|
||||
length: len
|
||||
}, sg7, 'd')
|
||||
return angledLine({
|
||||
angle: segAng('d', sg8) + 180 - 108,
|
||||
length: len
|
||||
}, sg8)
|
||||
}
|
||||
|
||||
const p = pentagon(48)
|
||||
const pe = extrude(30, p)
|
||||
|
||||
const plumbus0 = make_circle(pe, 'a', [0, 0], 9)
|
||||
const plumbus1 = extrude(18, plumbus0)
|
||||
const plumbus2 = fillet({
|
||||
radius: 0.5,
|
||||
tags: ['arc-a', getOppositeEdge('arc-a', plumbus1)]
|
||||
}, plumbus1)
|
@ -1,46 +1,41 @@
|
||||
fn make_circle = (face, tag, pos, radius) => {
|
||||
const sg = startSketchOn(face, tag)
|
||||
|> startProfileAt([pos[0] + radius, pos[1]], %)
|
||||
|> arc({
|
||||
angle_end: 360,
|
||||
angle_start: 0,
|
||||
radius: radius
|
||||
}, %, 'arc-' + tag)
|
||||
|> close(%)
|
||||
|
||||
return sg
|
||||
fn triangle = (len) => {
|
||||
return startSketchOn('XY')
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> angledLine({angle: 60, length: len}, %, 'a')
|
||||
|> angledLine({angle: 180, length: len}, %, 'b')
|
||||
|> angledLine({angle: 300, length: len}, %, 'c')
|
||||
}
|
||||
|
||||
fn pentagon = (len) => {
|
||||
const sg = startSketchOn('XY')
|
||||
|> startProfileAt([-len / 2, -len / 2], %)
|
||||
|> angledLine({ angle: 0, length: len }, %, 'a')
|
||||
|> angledLine({
|
||||
angle: segAng('a', %) + 180 - 108,
|
||||
length: len
|
||||
}, %, 'b')
|
||||
|> angledLine({
|
||||
angle: segAng('b', %) + 180 - 108,
|
||||
length: len
|
||||
}, %, 'c')
|
||||
|> angledLine({
|
||||
angle: segAng('c', %) + 180 - 108,
|
||||
length: len
|
||||
}, %, 'd')
|
||||
|> angledLine({
|
||||
angle: segAng('d', %) + 180 - 108,
|
||||
length: len
|
||||
let triangleHeight = 200
|
||||
let plumbusLen = 100
|
||||
let radius = 80
|
||||
let circ = {angle_start: 0, angle_end: 360, radius: radius}
|
||||
|
||||
let triangleLen = 500
|
||||
const p = triangle(triangleLen)
|
||||
|> extrude(triangleHeight, %)
|
||||
|
||||
fn circl = (x, tag) => {
|
||||
return startSketchOn(p, tag)
|
||||
|> startProfileAt([x + radius, triangleHeight/2], %)
|
||||
|> arc(circ, %, 'arc-' + tag)
|
||||
|> close(%)
|
||||
}
|
||||
|
||||
const plumbus1 =
|
||||
circl(-200, 'c')
|
||||
|> extrude(plumbusLen, %)
|
||||
|> fillet({
|
||||
radius: 5,
|
||||
tags: ['arc-c', getOppositeEdge('arc-c', %)]
|
||||
}, %)
|
||||
|
||||
return sg
|
||||
}
|
||||
|
||||
const p = pentagon(48)
|
||||
|> extrude(30, %)
|
||||
|
||||
const plumbus0 = make_circle(p, 'a', [0, 0], 9)
|
||||
|> extrude(18, %)
|
||||
const plumbus0 =
|
||||
circl(200, 'a')
|
||||
|> extrude(plumbusLen, %)
|
||||
|> fillet({
|
||||
radius: 0.5,
|
||||
radius: 5,
|
||||
tags: ['arc-a', getOppositeEdge('arc-a', %)]
|
||||
}, %)
|
||||
|
||||
|
||||
|
@ -128,15 +128,6 @@ async fn serial_test_lego() {
|
||||
twenty_twenty::assert_image("tests/executor/outputs/lego.png", &result, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_pentagon_fillet_desugar() {
|
||||
let code = include_str!("inputs/pentagon_fillet_desugar.kcl");
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Cm)
|
||||
.await
|
||||
.unwrap();
|
||||
twenty_twenty::assert_image("tests/executor/outputs/pentagon_fillet_desugar.png", &result, 0.999);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn serial_test_pentagon_fillet_sugar() {
|
||||
let code = include_str!("inputs/pentagon_fillet_sugar.kcl");
|
||||
@ -1955,12 +1946,12 @@ const plumbus0 = make_circle(p, 'a', [0, 0], 2.5)
|
||||
tags: ['arc-a', getOppositeEdge('arc-a', %)]
|
||||
}, %)
|
||||
|
||||
// const plumbus1 = make_circle(p, 'b', [0, 0], 2.5)
|
||||
// |> extrude(10, %)
|
||||
// |> fillet({
|
||||
// radius: 0.5,
|
||||
// tags: ['arc-b', getOppositeEdge('arc-b', %)]
|
||||
// }, %)
|
||||
const plumbus1 = make_circle(p, 'b', [0, 0], 2.5)
|
||||
|> extrude(10, %)
|
||||
|> fillet({
|
||||
radius: 0.5,
|
||||
tags: ['arc-b', getOppositeEdge('arc-b', %)]
|
||||
}, %)
|
||||
"#;
|
||||
|
||||
let result = execute_and_snapshot(code, kcl_lib::settings::types::UnitLength::Mm)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 100 KiB |
Binary file not shown.
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 95 KiB |
Binary file not shown.
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 133 KiB |
Reference in New Issue
Block a user