From 7f21e7e999c965c793491afe5e1a67cfe8cbc4ea Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Thu, 17 Apr 2025 14:16:54 -0700 Subject: [PATCH] Centralize the curvature component index constant --- app-proto/src/assembly.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index 0eb3e64..f14f0c4 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -58,6 +58,8 @@ pub struct Element { } impl Element { + const CURVATURE_COMPONENT: usize = 3; + pub fn new( id: String, label: String, @@ -217,9 +219,10 @@ pub struct HalfCurvatureRegulator { impl HalfCurvatureRegulator { pub fn new(subject: ElementKey, assembly: &Assembly) -> HalfCurvatureRegulator { - const CURVATURE_COMPONENT: usize = 3; let measurement = assembly.elements.map( - move |elts| elts[subject].representation.with(|rep| rep[CURVATURE_COMPONENT]) + move |elts| elts[subject].representation.with( + |rep| rep[Element::CURVATURE_COMPONENT] + ) ); let set_point = create_signal(SpecifiedValue::from_empty_spec()); @@ -262,8 +265,7 @@ impl ProblemPoser for HalfCurvatureRegulator { self.set_point.with_untracked(|set_pt| { if let Some(val) = set_pt.value { if let Some(col) = elts[self.subject].column_index { - const CURVATURE_COMPONENT: usize = 3; - problem.frozen.push(CURVATURE_COMPONENT, col, val); + problem.frozen.push(Element::CURVATURE_COMPONENT, col, val); } else { panic!("Tried to write problem data from a regulator with an unindexed subject"); }