Skip to content

Commit

Permalink
Add building the artifact graph in sketch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jtran committed Jan 27, 2025
1 parent 648b37c commit 44da971
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/wasm-lib/kcl/src/execution/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,7 @@ fn artifacts_to_update(
let uuid = artifact_command.cmd_id;
let id = ArtifactId::new(uuid);

let Some(response) = responses.get(&uuid) else {
// Response not found or not successful.
return Ok(Vec::new());
};
let response = responses.get(&uuid);

let cmd = &artifact_command.command;

Expand Down Expand Up @@ -679,7 +676,7 @@ fn artifacts_to_update(
new_path.seg_ids = vec![id];
return_arr.push(Artifact::Path(new_path));
}
if let OkModelingCmdResponse::ClosePath(close_path) = response {
if let Some(OkModelingCmdResponse::ClosePath(close_path)) = response {
return_arr.push(Artifact::Solid2d(Solid2d {
id: close_path.face_id.into(),
path_id,
Expand Down Expand Up @@ -720,7 +717,7 @@ fn artifacts_to_update(
return Ok(return_arr);
}
ModelingCmd::Loft(loft_cmd) => {
let OkModelingCmdResponse::Loft(_) = response else {
let Some(OkModelingCmdResponse::Loft(_)) = response else {
return Ok(Vec::new());
};
let mut return_arr = Vec::new();
Expand Down Expand Up @@ -749,7 +746,7 @@ fn artifacts_to_update(
return Ok(return_arr);
}
ModelingCmd::Solid3dGetExtrusionFaceInfo(_) => {
let OkModelingCmdResponse::Solid3dGetExtrusionFaceInfo(face_info) = response else {
let Some(OkModelingCmdResponse::Solid3dGetExtrusionFaceInfo(face_info)) = response else {
return Ok(Vec::new());
};
let mut return_arr = Vec::new();
Expand Down Expand Up @@ -831,6 +828,10 @@ fn artifacts_to_update(
ModelingCmd::Solid3dGetOppositeEdge(_) => SweepEdgeSubType::Opposite,
_ => unreachable!(),
};
// We need a response to continue.
if response.is_none() {
return Ok(Vec::new());
}
let face_id = ArtifactId::new(*face_id);
let edge_id = ArtifactId::new(*edge_id);
let Some(Artifact::Wall(wall)) = artifacts.get(&face_id) else {
Expand All @@ -846,15 +847,15 @@ fn artifacts_to_update(
return Ok(Vec::new());
};
let response_edge_id = match response {
OkModelingCmdResponse::Solid3dGetNextAdjacentEdge(r) => {
Some(OkModelingCmdResponse::Solid3dGetNextAdjacentEdge(r)) => {
let Some(edge_id) = r.edge else {
return Err(KclError::internal(format!(
"Expected Solid3dGetNextAdjacentEdge response to have an edge ID, but found none: id={id:?}, {response:?}"
)));
};
edge_id.into()
}
OkModelingCmdResponse::Solid3dGetOppositeEdge(r) => r.edge.into(),
Some(OkModelingCmdResponse::Solid3dGetOppositeEdge(r)) => r.edge.into(),
_ => {
return Err(KclError::internal(format!(
"Expected Solid3dGetNextAdjacentEdge or Solid3dGetOppositeEdge response, but got: id={id:?}, {response:?}"
Expand Down

0 comments on commit 44da971

Please sign in to comment.