diff --git a/app-proto/Cargo.lock b/app-proto/Cargo.lock index 731dd84..4f75c45 100644 --- a/app-proto/Cargo.lock +++ b/app-proto/Cargo.lock @@ -255,7 +255,6 @@ dependencies = [ "charming", "console_error_panic_hook", "dyna3", - "enum-iterator", "itertools", "js-sys", "lazy_static", @@ -272,26 +271,6 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" -[[package]] -name = "enum-iterator" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4549325971814bda7a44061bf3fe7e487d447cba01e4220a4b454d630d7a016" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685adfa4d6f3d765a26bc5dbc936577de9abf756c1feeb3089b01dd395034842" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "equivalent" version = "1.0.1" diff --git a/app-proto/Cargo.toml b/app-proto/Cargo.toml index d5221a1..1230b47 100644 --- a/app-proto/Cargo.toml +++ b/app-proto/Cargo.toml @@ -10,7 +10,6 @@ default = ["console_error_panic_hook"] dev = [] [dependencies] -enum-iterator = "2.3.0" itertools = "0.13.0" js-sys = "0.3.70" lazy_static = "1.5.0" diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index c263692..669c0d0 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -1,4 +1,3 @@ -use enum_iterator::{all, Sequence}; use nalgebra::{DMatrix, DVector, DVectorView}; use std::{ cell::Cell, @@ -27,7 +26,6 @@ use crate::{ ConfigSubspace, ConstraintProblem, DescentHistory, - MatrixEntry, Realization, }, specified::SpecifiedValue, @@ -271,7 +269,6 @@ pub struct Point { impl Point { const WEIGHT_COMPONENT: usize = 3; - const NORM_COMPONENT: usize = 4; pub fn new( id: String, @@ -305,15 +302,6 @@ impl Element for Point { point(0.0, 0.0, 0.0), ) } - - fn default_regulators(self: Rc) -> Vec> { - all::() - .map(|axis| { - Rc::new(PointCoordinateRegulator::new(self.clone(), axis)) - as Rc:: - }) - .collect() - } fn id(&self) -> &String { &self.id @@ -458,14 +446,14 @@ impl ProblemPoser for InversiveDistanceRegulator { } pub struct HalfCurvatureRegulator { - pub subject: Rc, + pub subject: Rc, pub measurement: ReadSignal, pub set_point: Signal, serial: u64, } impl HalfCurvatureRegulator { - pub fn new(subject: Rc) -> Self { + pub fn new(subject: Rc) -> Self { let measurement = subject.representation().map( |rep| rep[Sphere::CURVATURE_COMPONENT] ); @@ -510,69 +498,6 @@ impl ProblemPoser for HalfCurvatureRegulator { } } -#[derive(Clone, Copy, Sequence)] -pub enum Axis {X = 0, Y = 1, Z = 2} - -impl Axis { - pub const N_AXIS: usize = (Axis::Z as usize) + 1; - pub const NAME: [&str; Axis::N_AXIS] = ["X", "Y", "Z"]; -} - -pub struct PointCoordinateRegulator { - pub subject: Rc, - pub axis: Axis, - pub measurement: ReadSignal, - pub set_point: Signal, - serial: u64 -} - -impl PointCoordinateRegulator { - pub fn new(subject: Rc, axis: Axis) -> Self { - let measurement = subject.representation().map( - move |rep| rep[axis as usize] - ); - let set_point = create_signal(SpecifiedValue::from_empty_spec()); - Self { subject, axis, measurement, set_point, serial: Self::next_serial() } - } -} - -impl Serial for PointCoordinateRegulator { - fn serial(&self) -> u64 { self.serial } -} - -impl Regulator for PointCoordinateRegulator { - fn subjects(&self) -> Vec> { vec![self.subject.clone()] } - fn measurement(&self) -> ReadSignal { self.measurement } - fn set_point(&self) -> Signal { self.set_point } -} - -impl ProblemPoser for PointCoordinateRegulator { - fn pose(&self, problem: &mut ConstraintProblem) { - self.set_point.with_untracked(|set_pt| { - if let Some(val) = set_pt.value { - let col = self.subject.column_index().expect( - "Subject must be indexed before point-coordinate regulator poses."); - problem.frozen.push(self.axis as usize, col, val); - // Check if all three coordinates have been frozen, and if so, - // freeze the coradius as well - let mut coords = [0.0; Axis::N_AXIS]; - let mut nset: usize = 0; - for &MatrixEntry {index, value} in &(problem.frozen) { - if index.1 == col && index.0 < Axis::N_AXIS { - nset += 1; - coords[index.0] = value - } - } - if nset == Axis::N_AXIS { - let [x, y, z] = coords; - problem.frozen.push( - Point::NORM_COMPONENT, col, point(x,y,z)[Point::NORM_COMPONENT]); - } - } - }); - } -} - // the velocity is expressed in uniform coordinates pub struct ElementMotion<'a> { pub element: Rc, diff --git a/app-proto/src/components/outline.rs b/app-proto/src/components/outline.rs index 79781fa..5355042 100644 --- a/app-proto/src/components/outline.rs +++ b/app-proto/src/components/outline.rs @@ -6,11 +6,9 @@ use web_sys::{KeyboardEvent, MouseEvent, wasm_bindgen::JsCast}; use crate::{ AppState, assembly::{ - Axis, Element, HalfCurvatureRegulator, InversiveDistanceRegulator, - PointCoordinateRegulator, Regulator, }, specified::SpecifiedValue @@ -121,19 +119,6 @@ impl OutlineItem for HalfCurvatureRegulator { } } -impl OutlineItem for PointCoordinateRegulator { - fn outline_item(self: Rc, _element: &Rc) -> View { - view! { - li(class = "regulator") { - div(class = "regulator-label") { (Axis::NAME[self.axis as usize]) } - div(class = "regulator-type") { "Coordinate" } - RegulatorInput(regulator = self) - div(class = "status") - } - } - } -} - // a list item that shows an element in an outline view of an assembly #[component(inline_props)] fn ElementOutlineItem(element: Rc) -> View { diff --git a/app-proto/src/engine.rs b/app-proto/src/engine.rs index feb23cf..ef150a0 100644 --- a/app-proto/src/engine.rs +++ b/app-proto/src/engine.rs @@ -46,14 +46,14 @@ pub fn project_sphere_to_normalized(rep: &mut DVector) { // normalize a point's representation vector by scaling pub fn project_point_to_normalized(rep: &mut DVector) { - rep.scale_mut(0.5 / rep[3]); //FIXME: This 3 should be Point::WEIGHT_COMPONENT + rep.scale_mut(0.5 / rep[3]); } // --- partial matrices --- pub struct MatrixEntry { - pub index: (usize, usize), - pub value: f64, + index: (usize, usize), + value: f64, } pub struct PartialMatrix(Vec);