Skip to content

Commit 3e5efe4

Browse files
committed
Repro bug
1 parent 23a51c9 commit 3e5efe4

12 files changed

Lines changed: 11169 additions & 12 deletions

rust/kcl-lib/src/simulation_tests.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6012,3 +6012,24 @@ mod clone_a_mirror3d {
60126012
super::execute(TEST_NAME, true).await
60136013
}
60146014
}
6015+
mod sweep_mirror {
6016+
const TEST_NAME: &str = "sweep_mirror";
6017+
6018+
/// Test parsing KCL.
6019+
#[test]
6020+
fn parse() {
6021+
super::parse(TEST_NAME)
6022+
}
6023+
6024+
/// Test that parsing and unparsing KCL produces the original KCL input.
6025+
#[tokio::test(flavor = "multi_thread")]
6026+
async fn unparse() {
6027+
super::unparse(TEST_NAME).await
6028+
}
6029+
6030+
/// Test that KCL is executed correctly.
6031+
#[tokio::test(flavor = "multi_thread")]
6032+
async fn kcl_test_execute() {
6033+
super::execute(TEST_NAME, true).await
6034+
}
6035+
}

rust/kcl-lib/src/std/extrude.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -771,19 +771,34 @@ pub(crate) async fn do_post_extrude<'a>(
771771
};
772772

773773
// If the sketch is a clone, we will use the original info to get the extrusion face info.
774-
let mut extrusion_info_edge_id = any_edge_id;
775-
if sketch.clone.is_some() && clone_id_map.is_some() {
776-
extrusion_info_edge_id = if let Some(clone_map) = clone_id_map {
777-
if let Some(new_edge_id) = clone_map.get(&extrusion_info_edge_id) {
778-
*new_edge_id
774+
// So let's find an edge of the old body.
775+
let extrusion_info_edge_id = if sketch.clone.is_some() && clone_id_map.is_some() {
776+
if let Some(clone_map) = clone_id_map {
777+
// clone_map maps old IDs -> new IDs.
778+
// If the `any_edge_id` is an ID of the OLD body
779+
// (we know this if it's a _key_ of the map)
780+
// we should use it (because that's the old body we're querying).
781+
if clone_map.contains_key(&any_edge_id) {
782+
any_edge_id
783+
// Otherwise, if the `any_edge_id` is an ID of the NEW body
784+
// (we know this if it's a _value_ of the map),
785+
// we should query the corresponding ID in the OLD body.
786+
// i.e. if it's a hashmap value, find the corresponding key.
787+
} else if let Some((old_edge_id, _)) =
788+
clone_map.iter().find(|(_, new_edge_id)| **new_edge_id == any_edge_id)
789+
{
790+
*old_edge_id
779791
} else {
780-
extrusion_info_edge_id
792+
any_edge_id
781793
}
782794
} else {
783795
any_edge_id
784-
};
785-
}
786-
796+
}
797+
// If this isn't a clone, there's no old/new body distinction.
798+
// So just use the edge.
799+
} else {
800+
any_edge_id
801+
};
787802
let mut sketch = sketch.clone();
788803
match body_type {
789804
BodyType::Solid => {
@@ -871,8 +886,8 @@ pub(crate) async fn do_post_extrude<'a>(
871886
ModelingCmdMeta::from_args(exec_state, args),
872887
ModelingCmd::from(
873888
mcmd::Solid3dGetAdjacencyInfo::builder()
874-
.object_id(sketch.id)
875-
.edge_id(any_edge_id)
889+
.object_id(sketch_id)
890+
.edge_id(extrusion_info_edge_id)
876891
.build(),
877892
),
878893
)
@@ -1033,7 +1048,7 @@ pub(crate) async fn do_post_extrude<'a>(
10331048
})
10341049
}
10351050

1036-
#[derive(Default)]
1051+
#[derive(Debug, Default)]
10371052
struct Faces {
10381053
/// Maps curve ID to face ID for each side.
10391054
sides: HashMap<Uuid, Option<Uuid>>,

0 commit comments

Comments
 (0)