复用分离流程已选批次节点
让批次校验和应用使用同一份已选节点,避免重复选择造成目标漂移。
This commit is contained in:
@@ -259,9 +259,14 @@ mod tests {
|
||||
let paths = HashMap::new();
|
||||
|
||||
for note in ["第一次意见", "第二次意见", "最后一次意见"] {
|
||||
let batch_nodes = next_image_batch(&separation, &separation.trees[0])
|
||||
.into_iter()
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
apply_batch_patch(
|
||||
&mut separation,
|
||||
0,
|
||||
&batch_nodes,
|
||||
&[BindingDecision::NeedRework {
|
||||
to_node: id.clone(),
|
||||
advice: note.to_string(),
|
||||
@@ -343,7 +348,11 @@ mod tests {
|
||||
},
|
||||
}];
|
||||
let paths = HashMap::from([(id.clone(), "ui/.sidecar/cut.png".to_string())]);
|
||||
apply_batch_patch(&mut state, 0, &decisions, &paths, (1, 1)).unwrap();
|
||||
let batch_nodes = next_image_batch(&state, &state.trees[0])
|
||||
.into_iter()
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
apply_batch_patch(&mut state, 0, &batch_nodes, &decisions, &paths, (1, 1)).unwrap();
|
||||
assert_eq!(state.bound[0].node_id, id);
|
||||
assert_eq!(state.trees[0].root.children.len(), 1);
|
||||
}
|
||||
|
||||
@@ -243,6 +243,7 @@ pub(crate) async fn separate_ui_impl(
|
||||
patch::apply_batch_patch(
|
||||
&mut separation,
|
||||
tree_index,
|
||||
&batch_nodes,
|
||||
&binding.decisions,
|
||||
&cut_paths,
|
||||
processed_dimensions,
|
||||
|
||||
+4
-11
@@ -1,4 +1,3 @@
|
||||
use super::batch::next_image_batch;
|
||||
use crate::ui_editor::commands::separation::{
|
||||
validate_binding_response, BindingDecision, BindingResp, BoundNode, ProblematicNode,
|
||||
SeparationNode, SeparationState, MAX_REWORK_COUNT,
|
||||
@@ -9,6 +8,7 @@ use std::collections::HashMap;
|
||||
pub fn apply_batch_patch(
|
||||
state: &mut SeparationState,
|
||||
tree_index: usize,
|
||||
batch_nodes: &[SeparationNode],
|
||||
decisions: &[BindingDecision],
|
||||
cut_paths: &HashMap<NodeId, String>,
|
||||
processed_dimensions: (u32, u32),
|
||||
@@ -19,16 +19,9 @@ pub fn apply_batch_patch(
|
||||
decisions.len(),
|
||||
cut_paths.len()
|
||||
);
|
||||
let batch_nodes = {
|
||||
let tree = state
|
||||
.trees
|
||||
.get(tree_index)
|
||||
.ok_or_else(|| "separation tree 索引无效".to_string())?;
|
||||
next_image_batch(state, tree)
|
||||
.into_iter()
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
if state.trees.get(tree_index).is_none() {
|
||||
return Err("separation tree 索引无效".to_string());
|
||||
}
|
||||
let batch = batch_nodes.iter().collect::<Vec<_>>();
|
||||
validate_binding_response(
|
||||
&BindingResp {
|
||||
|
||||
Reference in New Issue
Block a user