Integrate engine into application prototype #15

Merged
glen merged 24 commits from engine-integration into main 2024-11-12 00:46:16 +00:00
4 changed files with 22 additions and 20 deletions
Showing only changes of commit da008fd090 - Show all commits

View File

@ -11,7 +11,7 @@ fn load_gen_assemb(assembly: &Assembly) {
id: String::from("gemini_a"), id: String::from("gemini_a"),
label: String::from("Castor"), label: String::from("Castor"),
color: [1.00_f32, 0.25_f32, 0.00_f32], color: [1.00_f32, 0.25_f32, 0.00_f32],
rep: engine::sphere(0.5, 0.5, 0.0, 1.0), representation: engine::sphere(0.5, 0.5, 0.0, 1.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -21,7 +21,7 @@ fn load_gen_assemb(assembly: &Assembly) {
id: String::from("gemini_b"), id: String::from("gemini_b"),
label: String::from("Pollux"), label: String::from("Pollux"),
color: [0.00_f32, 0.25_f32, 1.00_f32], color: [0.00_f32, 0.25_f32, 1.00_f32],
rep: engine::sphere(-0.5, -0.5, 0.0, 1.0), representation: engine::sphere(-0.5, -0.5, 0.0, 1.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -31,7 +31,7 @@ fn load_gen_assemb(assembly: &Assembly) {
id: String::from("ursa_major"), id: String::from("ursa_major"),
label: String::from("Ursa major"), label: String::from("Ursa major"),
color: [0.25_f32, 0.00_f32, 1.00_f32], color: [0.25_f32, 0.00_f32, 1.00_f32],
rep: engine::sphere(-0.5, 0.5, 0.0, 0.75), representation: engine::sphere(-0.5, 0.5, 0.0, 0.75),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -41,7 +41,7 @@ fn load_gen_assemb(assembly: &Assembly) {
id: String::from("ursa_minor"), id: String::from("ursa_minor"),
label: String::from("Ursa minor"), label: String::from("Ursa minor"),
color: [0.25_f32, 1.00_f32, 0.00_f32], color: [0.25_f32, 1.00_f32, 0.00_f32],
rep: engine::sphere(0.5, -0.5, 0.0, 0.5), representation: engine::sphere(0.5, -0.5, 0.0, 0.5),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -51,7 +51,7 @@ fn load_gen_assemb(assembly: &Assembly) {
id: String::from("moon_deimos"), id: String::from("moon_deimos"),
label: String::from("Deimos"), label: String::from("Deimos"),
color: [0.75_f32, 0.75_f32, 0.00_f32], color: [0.75_f32, 0.75_f32, 0.00_f32],
rep: engine::sphere(0.0, 0.15, 1.0, 0.25), representation: engine::sphere(0.0, 0.15, 1.0, 0.25),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -61,7 +61,7 @@ fn load_gen_assemb(assembly: &Assembly) {
id: String::from("moon_phobos"), id: String::from("moon_phobos"),
label: String::from("Phobos"), label: String::from("Phobos"),
color: [0.00_f32, 0.75_f32, 0.50_f32], color: [0.00_f32, 0.75_f32, 0.50_f32],
rep: engine::sphere(0.0, -0.15, -1.0, 0.25), representation: engine::sphere(0.0, -0.15, -1.0, 0.25),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -76,7 +76,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
id: "central".to_string(), id: "central".to_string(),
label: "Central".to_string(), label: "Central".to_string(),
color: [0.75_f32, 0.75_f32, 0.75_f32], color: [0.75_f32, 0.75_f32, 0.75_f32],
rep: engine::sphere(0.0, 0.0, 0.0, 1.0), representation: engine::sphere(0.0, 0.0, 0.0, 1.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -86,7 +86,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
id: "assemb_plane".to_string(), id: "assemb_plane".to_string(),
label: "Assembly plane".to_string(), label: "Assembly plane".to_string(),
color: [0.75_f32, 0.75_f32, 0.75_f32], color: [0.75_f32, 0.75_f32, 0.75_f32],
rep: engine::sphere_with_offset(0.0, 0.0, 1.0, 0.0, 0.0), representation: engine::sphere_with_offset(0.0, 0.0, 1.0, 0.0, 0.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -96,7 +96,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
id: "side1".to_string(), id: "side1".to_string(),
label: "Side 1".to_string(), label: "Side 1".to_string(),
color: [1.00_f32, 0.00_f32, 0.25_f32], color: [1.00_f32, 0.00_f32, 0.25_f32],
rep: engine::sphere_with_offset(1.0, 0.0, 0.0, 1.0, 0.0), representation: engine::sphere_with_offset(1.0, 0.0, 0.0, 1.0, 0.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -106,7 +106,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
id: "side2".to_string(), id: "side2".to_string(),
label: "Side 2".to_string(), label: "Side 2".to_string(),
color: [0.25_f32, 1.00_f32, 0.00_f32], color: [0.25_f32, 1.00_f32, 0.00_f32],
rep: engine::sphere_with_offset(-0.5, a, 0.0, 1.0, 0.0), representation: engine::sphere_with_offset(-0.5, a, 0.0, 1.0, 0.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -116,7 +116,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
id: "side3".to_string(), id: "side3".to_string(),
label: "Side 3".to_string(), label: "Side 3".to_string(),
color: [0.00_f32, 0.25_f32, 1.00_f32], color: [0.00_f32, 0.25_f32, 1.00_f32],
rep: engine::sphere_with_offset(-0.5, -a, 0.0, 1.0, 0.0), representation: engine::sphere_with_offset(-0.5, -a, 0.0, 1.0, 0.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -126,7 +126,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
id: "corner1".to_string(), id: "corner1".to_string(),
label: "Corner 1".to_string(), label: "Corner 1".to_string(),
color: [0.75_f32, 0.75_f32, 0.75_f32], color: [0.75_f32, 0.75_f32, 0.75_f32],
rep: engine::sphere(-4.0/3.0, 0.0, 0.0, 1.0/3.0), representation: engine::sphere(-4.0/3.0, 0.0, 0.0, 1.0/3.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -136,7 +136,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
id: "corner2".to_string(), id: "corner2".to_string(),
label: "Corner 2".to_string(), label: "Corner 2".to_string(),
color: [0.75_f32, 0.75_f32, 0.75_f32], color: [0.75_f32, 0.75_f32, 0.75_f32],
rep: engine::sphere(2.0/3.0, -4.0/3.0 * a, 0.0, 1.0/3.0), representation: engine::sphere(2.0/3.0, -4.0/3.0 * a, 0.0, 1.0/3.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -146,7 +146,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
id: String::from("corner3"), id: String::from("corner3"),
label: String::from("Corner 3"), label: String::from("Corner 3"),
color: [0.75_f32, 0.75_f32, 0.75_f32], color: [0.75_f32, 0.75_f32, 0.75_f32],
rep: engine::sphere(2.0/3.0, 4.0/3.0 * a, 0.0, 1.0/3.0), representation: engine::sphere(2.0/3.0, 4.0/3.0 * a, 0.0, 1.0/3.0),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }

View File

@ -12,7 +12,7 @@ pub struct Element {
pub id: String, pub id: String,
pub label: String, pub label: String,
pub color: [f32; 3], pub color: [f32; 3],
pub rep: DVector<f64>, pub representation: DVector<f64>,
pub constraints: BTreeSet<usize>, pub constraints: BTreeSet<usize>,
// internal properties, not reflected in any view // internal properties, not reflected in any view
@ -86,7 +86,7 @@ impl Assembly {
id: id, id: id,
label: format!("Sphere {}", id_num), label: format!("Sphere {}", id_num),
color: [0.75_f32, 0.75_f32, 0.75_f32], color: [0.75_f32, 0.75_f32, 0.75_f32],
rep: DVector::<f64>::from_column_slice(&[0.0, 0.0, 0.0, 0.5, -0.5]), representation: DVector::<f64>::from_column_slice(&[0.0, 0.0, 0.0, 0.5, -0.5]),
constraints: BTreeSet::default(), constraints: BTreeSet::default(),
index: 0 index: 0
} }
@ -133,7 +133,7 @@ impl Assembly {
for (_, elt) in elts { for (_, elt) in elts {
let index = elt.index; let index = elt.index;
gram_to_be.push_sym(index, index, 1.0); gram_to_be.push_sym(index, index, 1.0);
guess_to_be.set_column(index, &elt.rep); guess_to_be.set_column(index, &elt.representation);
} }
(gram_to_be, guess_to_be) (gram_to_be, guess_to_be)
@ -177,7 +177,7 @@ impl Assembly {
// read out the solution // read out the solution
self.elements.update(|elts| { self.elements.update(|elts| {
for (_, elt) in elts.iter_mut() { for (_, elt) in elts.iter_mut() {
elt.rep.set_column(0, &config.column(elt.index)); elt.representation.set_column(0, &config.column(elt.index));
} }
}); });
} }

View File

@ -297,7 +297,9 @@ pub fn Display() -> View {
// get the assembly // get the assembly
let elements = state.assembly.elements.get_clone(); let elements = state.assembly.elements.get_clone();
let element_iter = (&elements).into_iter(); let element_iter = (&elements).into_iter();
let reps_world: Vec<_> = element_iter.clone().map(|(_, elt)| &assembly_to_world * &elt.rep).collect(); let reps_world: Vec<_> = element_iter.clone().map(
|(_, elt)| &assembly_to_world * &elt.representation
).collect();
let colors: Vec<_> = element_iter.clone().map(|(key, elt)| let colors: Vec<_> = element_iter.clone().map(|(key, elt)|
if state.selection.with(|sel| sel.contains(&key)) { if state.selection.with(|sel| sel.contains(&key)) {
elt.color.map(|ch| 0.2 + 0.8*ch) elt.color.map(|ch| 0.2 + 0.8*ch)

View File

@ -72,7 +72,7 @@ pub fn Outline() -> View {
} }
}); });
let label = elt.label.clone(); let label = elt.label.clone();
let rep_components = elt.rep.iter().map(|u| { let rep_components = elt.representation.iter().map(|u| {
let u_coord = u.to_string().replace("-", "\u{2212}"); let u_coord = u.to_string().replace("-", "\u{2212}");
View::from(div().children(u_coord)) View::from(div().children(u_coord))
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();