convert AbstractSim::sample to include a reference to the material -- not just its conductivity
This commit is contained in:
@@ -189,7 +189,7 @@ impl<'a, S: AbstractSim> RenderSteps<'a, S> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_at_px(&self, x_px: u32, y_px: u32) -> Sample {
|
||||
fn get_at_px<'b>(&'b self, x_px: u32, y_px: u32) -> Sample<'b, S::Real, S::Material> {
|
||||
let x_prop = x_px as f32 / self.im.width() as f32;
|
||||
let x_m = x_prop * (self.sim.width() as f32 * self.sim.feature_size() as f32);
|
||||
let y_prop = y_px as f32 / self.im.height() as f32;
|
||||
@@ -232,7 +232,10 @@ impl<'a, S: AbstractSim> RenderSteps<'a, S> {
|
||||
self.render_vector_field(Rgb([0xff, 0xff, 0xff]), 1.0e5 * scale, |cell| cell.m().xy().to_f32());
|
||||
}
|
||||
|
||||
fn render_vector_field<F: Fn(&Sample) -> Vec2<f32>>(&mut self, color: Rgb<u8>, typical: f32, measure: F) {
|
||||
fn render_vector_field<F>(&mut self, color: Rgb<u8>, typical: f32, measure: F)
|
||||
where
|
||||
F: Fn(&Sample<'_, S::Real, S::Material>) -> Vec2<f32>
|
||||
{
|
||||
let w = self.im.width();
|
||||
let h = self.im.height();
|
||||
let vec_spacing = 10;
|
||||
@@ -247,7 +250,10 @@ impl<'a, S: AbstractSim> RenderSteps<'a, S> {
|
||||
}
|
||||
}
|
||||
}
|
||||
fn render_scalar_field<F: Fn(&Sample) -> f32 + Sync>(&mut self, typical: f32, signed: bool, slot: u32, measure: F) {
|
||||
fn render_scalar_field<F>(&mut self, typical: f32, signed: bool, slot: u32, measure: F)
|
||||
where
|
||||
F: Fn(&Sample<'_, S::Real, S::Material>) -> f32 + Sync
|
||||
{
|
||||
// XXX: get_at_px borrows self, so we need to clone the image to operate on it mutably.
|
||||
let mut im = self.im.clone();
|
||||
let w = im.width();
|
||||
@@ -293,7 +299,10 @@ impl<'a, S: AbstractSim> RenderSteps<'a, S> {
|
||||
}
|
||||
}
|
||||
|
||||
fn field_vector<F: Fn(&Sample) -> Vec2<f32>>(&self, xidx: u32, yidx: u32, size: u32, measure: &F) -> Vec2<f32> {
|
||||
fn field_vector<F>(&self, xidx: u32, yidx: u32, size: u32, measure: &F) -> Vec2<f32>
|
||||
where
|
||||
F: Fn(&Sample<'_, S::Real, S::Material>) -> Vec2<f32>
|
||||
{
|
||||
let mut field = Vec2::default();
|
||||
let w = self.im.width();
|
||||
let h = self.im.height();
|
||||
|
Reference in New Issue
Block a user