Fix mirror2d selection by adding artifact graph support (#7178)
* Add artifact graph support for mirror2d * Update output * Disable test that can't pass
This commit is contained in:
@ -1034,6 +1034,69 @@ fn artifacts_to_update(
|
||||
}
|
||||
return Ok(return_arr);
|
||||
}
|
||||
ModelingCmd::EntityMirror(kcmc::EntityMirror {
|
||||
ids: original_path_ids, ..
|
||||
})
|
||||
| ModelingCmd::EntityMirrorAcrossEdge(kcmc::EntityMirrorAcrossEdge {
|
||||
ids: original_path_ids, ..
|
||||
}) => {
|
||||
let face_edge_infos = match response {
|
||||
OkModelingCmdResponse::EntityMirror(resp) => &resp.entity_face_edge_ids,
|
||||
OkModelingCmdResponse::EntityMirrorAcrossEdge(resp) => &resp.entity_face_edge_ids,
|
||||
_ => internal_error!(
|
||||
range,
|
||||
"Mirror response variant not handled: id={id:?}, cmd={cmd:?}, response={response:?}"
|
||||
),
|
||||
};
|
||||
if original_path_ids.len() != face_edge_infos.len() {
|
||||
internal_error!(range, "EntityMirror or EntityMirrorAcrossEdge response has different number face edge info than original mirrored paths: id={id:?}, cmd={cmd:?}, response={response:?}");
|
||||
}
|
||||
let mut return_arr = Vec::new();
|
||||
for (face_edge_info, original_path_id) in face_edge_infos.iter().zip(original_path_ids) {
|
||||
let original_path_id = ArtifactId::new(*original_path_id);
|
||||
let path_id = ArtifactId::new(face_edge_info.object_id);
|
||||
// The path may be an existing path that was extended or a new
|
||||
// path.
|
||||
let mut path = if let Some(Artifact::Path(path)) = artifacts.get(&path_id) {
|
||||
// Existing path.
|
||||
path.clone()
|
||||
} else {
|
||||
// It's a new path. We need the original path to get some
|
||||
// of its info.
|
||||
let Some(Artifact::Path(original_path)) = artifacts.get(&original_path_id) else {
|
||||
// We couldn't find the original path. This is a bug.
|
||||
internal_error!(range, "Couldn't find original path for mirror2d: original_path_id={original_path_id:?}, cmd={cmd:?}");
|
||||
};
|
||||
Path {
|
||||
id: path_id,
|
||||
plane_id: original_path.plane_id,
|
||||
seg_ids: Vec::new(),
|
||||
sweep_id: None,
|
||||
solid2d_id: None,
|
||||
code_ref: code_ref.clone(),
|
||||
composite_solid_id: None,
|
||||
}
|
||||
};
|
||||
|
||||
face_edge_info.edges.iter().for_each(|edge_id| {
|
||||
let edge_id = ArtifactId::new(*edge_id);
|
||||
return_arr.push(Artifact::Segment(Segment {
|
||||
id: edge_id,
|
||||
path_id: path.id,
|
||||
surface_id: None,
|
||||
edge_ids: Vec::new(),
|
||||
edge_cut_id: None,
|
||||
code_ref: code_ref.clone(),
|
||||
common_surface_ids: Vec::new(),
|
||||
}));
|
||||
// Add the edge ID to the path.
|
||||
path.seg_ids.push(edge_id);
|
||||
});
|
||||
|
||||
return_arr.push(Artifact::Path(path));
|
||||
}
|
||||
return Ok(return_arr);
|
||||
}
|
||||
ModelingCmd::Extrude(kcmc::Extrude { target, .. })
|
||||
| ModelingCmd::Revolve(kcmc::Revolve { target, .. })
|
||||
| ModelingCmd::RevolveAboutEdge(kcmc::RevolveAboutEdge { target, .. })
|
||||
|
Reference in New Issue
Block a user