MAYBE REVERT LATER:
attempt at an ordering
This commit is contained in:
@ -209,6 +209,7 @@ pub enum SweepSubType {
|
||||
pub struct Solid2d {
|
||||
pub id: ArtifactId,
|
||||
pub path_id: ArtifactId,
|
||||
pub code_ref: CodeRef,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS)]
|
||||
@ -277,6 +278,7 @@ pub struct SweepEdge {
|
||||
pub sub_type: SweepEdgeSubType,
|
||||
pub seg_id: ArtifactId,
|
||||
pub sweep_id: ArtifactId,
|
||||
pub code_ref: CodeRef,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, ts_rs::TS)]
|
||||
@ -325,6 +327,7 @@ pub struct EdgeCutEdge {
|
||||
pub id: ArtifactId,
|
||||
pub edge_cut_id: ArtifactId,
|
||||
pub surface_id: ArtifactId,
|
||||
pub code_ref: CodeRef,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS)]
|
||||
@ -378,23 +381,23 @@ impl Artifact {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub(crate) fn code_ref(&self) -> Option<&CodeRef> {
|
||||
#[cfg_attr(not(test), expect(dead_code))]
|
||||
pub(crate) fn code_ref(&self) -> &CodeRef {
|
||||
match self {
|
||||
Artifact::CompositeSolid(a) => Some(&a.code_ref),
|
||||
Artifact::Plane(a) => Some(&a.code_ref),
|
||||
Artifact::Path(a) => Some(&a.code_ref),
|
||||
Artifact::Segment(a) => Some(&a.code_ref),
|
||||
Artifact::Solid2d(_) => None,
|
||||
Artifact::StartSketchOnFace(a) => Some(&a.code_ref),
|
||||
Artifact::StartSketchOnPlane(a) => Some(&a.code_ref),
|
||||
Artifact::Sweep(a) => Some(&a.code_ref),
|
||||
Artifact::Wall(_) => None,
|
||||
Artifact::Cap(_) => None,
|
||||
Artifact::SweepEdge(_) => None,
|
||||
Artifact::EdgeCut(a) => Some(&a.code_ref),
|
||||
Artifact::EdgeCutEdge(_) => None,
|
||||
Artifact::Helix(a) => Some(&a.code_ref),
|
||||
Artifact::CompositeSolid(a) => &a.code_ref,
|
||||
Artifact::Plane(a) => &a.code_ref,
|
||||
Artifact::Path(a) => &a.code_ref,
|
||||
Artifact::Segment(a) => &a.code_ref,
|
||||
Artifact::Solid2d(a) => &a.code_ref,
|
||||
Artifact::StartSketchOnFace(a) => &a.code_ref,
|
||||
Artifact::StartSketchOnPlane(a) => &a.code_ref,
|
||||
Artifact::Sweep(a) => &a.code_ref,
|
||||
Artifact::Wall(a) => &a.face_code_ref,
|
||||
Artifact::Cap(a) => &a.face_code_ref,
|
||||
Artifact::SweepEdge(a) => &a.code_ref,
|
||||
Artifact::EdgeCut(a) => &a.code_ref,
|
||||
Artifact::EdgeCutEdge(a) => &a.code_ref,
|
||||
Artifact::Helix(a) => &a.code_ref,
|
||||
}
|
||||
}
|
||||
|
||||
@ -791,7 +794,10 @@ fn artifacts_to_update(
|
||||
surface_id: None,
|
||||
edge_ids: Vec::new(),
|
||||
edge_cut_id: None,
|
||||
code_ref: CodeRef { range, path_to_node },
|
||||
code_ref: CodeRef {
|
||||
range,
|
||||
path_to_node: path_to_node.clone(),
|
||||
},
|
||||
}));
|
||||
let path = artifacts.get(&path_id);
|
||||
if let Some(Artifact::Path(path)) = path {
|
||||
@ -803,6 +809,10 @@ fn artifacts_to_update(
|
||||
return_arr.push(Artifact::Solid2d(Solid2d {
|
||||
id: close_path.face_id.into(),
|
||||
path_id,
|
||||
code_ref: CodeRef {
|
||||
range,
|
||||
path_to_node: path_to_node.clone(),
|
||||
},
|
||||
}));
|
||||
if let Some(Artifact::Path(path)) = path {
|
||||
let mut new_path = path.clone();
|
||||
@ -1039,6 +1049,10 @@ fn artifacts_to_update(
|
||||
sub_type,
|
||||
seg_id: edge_id,
|
||||
sweep_id: sweep.id,
|
||||
code_ref: CodeRef {
|
||||
range,
|
||||
path_to_node: path_to_node.clone(),
|
||||
},
|
||||
}));
|
||||
let mut new_segment = segment.clone();
|
||||
new_segment.edge_ids = vec![response_edge_id];
|
||||
|
@ -191,7 +191,7 @@ impl ArtifactGraph {
|
||||
|
||||
let mut next_id = 1_u32;
|
||||
let mut stable_id_map = FnvHashMap::default();
|
||||
for id in self.map.keys() {
|
||||
for id in self.sorted_keys() {
|
||||
stable_id_map.insert(*id, next_id);
|
||||
next_id = next_id.checked_add(1).unwrap();
|
||||
}
|
||||
@ -207,6 +207,18 @@ impl ArtifactGraph {
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
fn sorted_keys(&self) -> Vec<&ArtifactId> {
|
||||
let mut sorted_keys: Vec<_> = self.map.iter().collect();
|
||||
sorted_keys.sort_by_key(|(_, v)| v.code_ref().range.module_id().as_usize());
|
||||
sorted_keys.into_iter().map(|(k, _)| k).collect()
|
||||
}
|
||||
|
||||
fn sorted_values(&self) -> Vec<&Artifact> {
|
||||
let mut sorted_keys: Vec<_> = self.map.iter().collect();
|
||||
sorted_keys.sort_by_key(|(_, v)| v.code_ref().range.module_id().as_usize());
|
||||
sorted_keys.into_iter().map(|(_, v)| v).collect()
|
||||
}
|
||||
|
||||
/// Output the Mermaid flowchart nodes, one for each artifact.
|
||||
fn flowchart_nodes<W: Write>(
|
||||
&self,
|
||||
@ -219,7 +231,7 @@ impl ArtifactGraph {
|
||||
let mut groups = IndexMap::new();
|
||||
let mut ungrouped = Vec::new();
|
||||
|
||||
for artifact in self.map.values() {
|
||||
for artifact in self.sorted_values() {
|
||||
let id = artifact.id();
|
||||
|
||||
let grouped = match artifact {
|
||||
@ -416,7 +428,7 @@ impl ArtifactGraph {
|
||||
|
||||
// Collect all edges to deduplicate them.
|
||||
let mut edges = IndexMap::default();
|
||||
for artifact in self.map.values() {
|
||||
for artifact in self.sorted_values() {
|
||||
let source_id = *stable_id_map.get(&artifact.id()).unwrap();
|
||||
// In Mermaid, the textual order defines the rank, even though the
|
||||
// edge arrow can go in either direction.
|
||||
|
Reference in New Issue
Block a user