Centralize the curvature component index constant
All checks were successful
/ test (pull_request) Successful in 2m25s

This commit is contained in:
Aaron Fenyes 2025-04-17 14:16:54 -07:00
parent 52d99755f9
commit 7f21e7e999

View file

@ -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");
}