Print the vertex coordinates

This commit is contained in:
Aaron Fenyes 2025-09-22 12:30:38 -07:00
parent cc2da3406b
commit 1054f4e85b
2 changed files with 19 additions and 5 deletions

View file

@ -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();

View file

@ -134,11 +134,13 @@ fn DistortionGauge() -> View {
}
#[component]
fn DistortionPrintButton() -> View {
fn PrintButton() -> View {
view! {
button(
on:click = |_| {
let state = use_context::<AppState>();
// 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 {}
}
}
}