Skip to content

Commit

Permalink
Select just one dimension of the staggered grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchef365 committed Jun 11, 2024
1 parent fe9345c commit 561e284
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct DemoApp {
draw_grid: bool,
draw_centers: bool,
draw_staggered: bool,
draw_staggered_dim: usize,
}

impl Default for DemoApp {
Expand Down Expand Up @@ -50,6 +51,7 @@ impl DemoApp {
let cfg = Default::default();

Self {
draw_staggered_dim: 0,
draw_grid: true,
draw_centers: true,
draw_staggered: true,
Expand Down Expand Up @@ -120,6 +122,7 @@ impl eframe::App for DemoApp {
ui.checkbox(&mut self.draw_grid, "Draw grid");
ui.checkbox(&mut self.draw_staggered, "Draw storage");
ui.checkbox(&mut self.draw_centers, "Draw centers");
ui.add(DragValue::new(&mut self.draw_staggered_dim).clamp_range(0..=self.sim.dims()));

if resp_dims.changed() || resp_width.changed() || regen {
*self = Self::from_dims(dims, width);
Expand Down Expand Up @@ -157,7 +160,9 @@ impl eframe::App for DemoApp {
}

if self.draw_staggered {
draw_flowfield_staggered(paint, &self.proj, self.sim.get_flow(), 3.);
let sel = (self.draw_staggered_dim != 0).then(|| self.draw_staggered_dim - 1);

draw_flowfield_staggered(paint, &self.proj, self.sim.get_flow(), 3., sel);
}

draw_pcld(&self.pcld, &self.proj, paint, 1., Color32::from_gray(180));
Expand Down
6 changes: 6 additions & 0 deletions src/visualization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ pub fn draw_flowfield_staggered(
proj: &dyn Projection,
ff: &FlowField,
scale: f32,
sel_dim: Option<usize>,
) {
for (dim, axis) in ff.get_axes().iter().enumerate() {
if let Some(sel) = sel_dim {
if dim != sel {
continue;
}
}
for (idx, value) in axis.indexed_iter() {
let mut pos: Vec<f32> = idx.as_array_view().iter().map(|c| *c as f32).collect();

Expand Down

0 comments on commit 561e284

Please sign in to comment.