From 1054f4e85b5c3957f095da0f3b29d2ccba691b17 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Mon, 22 Sep 2025 12:30:38 -0700 Subject: [PATCH] Print the vertex coordinates --- app-proto/src/assembly.rs | 6 +++--- app-proto/src/components/diagnostics.rs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index 9cd4533..bacc63b 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -125,7 +125,7 @@ pub trait Element: Serial + ProblemPoser + DisplayItem { fn set_column_index(&self, index: usize); /* KLUDGE */ - fn has_distortion(&self) -> bool { + fn is_point(&self) -> bool { false } } @@ -341,7 +341,7 @@ impl Element for Point { self.column_index.set(Some(index)); } - fn has_distortion(&self) -> bool { + fn is_point(&self) -> bool { true } } @@ -422,7 +422,7 @@ impl InversiveDistanceRegulator { }); let set_point = create_signal(SpecifiedValue::from_empty_spec()); - let distortion = if subjects.iter().all(|subj| subj.has_distortion()) { + let distortion = if subjects.iter().all(|subj| subj.is_point()) { Some(create_memo(move || { let set_point_opt = set_point.with(|set_pt| set_pt.value); let measurement_val = measurement.get(); diff --git a/app-proto/src/components/diagnostics.rs b/app-proto/src/components/diagnostics.rs index 52e7ffa..bab6f35 100644 --- a/app-proto/src/components/diagnostics.rs +++ b/app-proto/src/components/diagnostics.rs @@ -134,11 +134,13 @@ fn DistortionGauge() -> View { } #[component] -fn DistortionPrintButton() -> View { +fn PrintButton() -> View { view! { button( on:click = |_| { let state = use_context::(); + + // print the edge length distortions let mut hard_distortion_table = String::new(); let mut soft_distortion_table = String::new(); let mut highest_distortion = f64::NEG_INFINITY; @@ -180,6 +182,18 @@ fn DistortionPrintButton() -> View { Largest absolute: {largest_hard_distortion}\n\n\ --- Table ---\n\n{hard_distortion_table}\ "); + + // print the vertex coordinates + let mut coords_table = String::new(); + state.assembly.elements.with_untracked(|elts| { + for elt in elts.iter().filter(|elt| elt.is_point()) { + let (x, y, z) = elt.representation().with( + |rep| (rep[0], rep[1], rep[2]) + ); + coords_table += &format!("{}: {x}, {y}, {z}\n", elt.id()); + } + }); + console_log!("=== Vertex coordinates ===\n\n{coords_table}"); }, ) { "Print" } } @@ -391,7 +405,7 @@ pub fn Diagnostics() -> View { DiagnosticsPanel(name = "spectrum") { SpectrumHistory {} } div(id = "distortion-bar") { DistortionGauge {} - DistortionPrintButton {} + PrintButton {} } } }