optional parallel processing
This commit is contained in:
parent
e912c7b414
commit
a56705383f
2 changed files with 24 additions and 13 deletions
|
|
@ -44,7 +44,9 @@ fn main() {
|
||||||
println!("Generated Delaunay triangulation");
|
println!("Generated Delaunay triangulation");
|
||||||
|
|
||||||
// Pre-process triangles
|
// Pre-process triangles
|
||||||
xeno.preprocess(0);
|
// 1 - attractors, 2 - voids, 0 - both
|
||||||
|
// true/false - parallel processing
|
||||||
|
xeno.preprocess(0, false);
|
||||||
|
|
||||||
// Execute delfin function with the generated GeometryData
|
// Execute delfin function with the generated GeometryData
|
||||||
let min_area: f32 = 1000.0; // threshold for voidness
|
let min_area: f32 = 1000.0; // threshold for voidness
|
||||||
|
|
|
||||||
11
src/lib.rs
11
src/lib.rs
|
|
@ -258,7 +258,9 @@ impl Xenobalanus {
|
||||||
self.triangulation = result.triangles
|
self.triangulation = result.triangles
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn preprocess(&mut self, types: usize) {
|
pub fn preprocess(&mut self, types: usize, parallel: bool) {
|
||||||
|
if parallel {
|
||||||
|
|
||||||
let geometry_data = Arc::new(Mutex::new(GeometryData::new()));
|
let geometry_data = Arc::new(Mutex::new(GeometryData::new()));
|
||||||
|
|
||||||
self.triangulation.par_chunks(3).enumerate().for_each(|(index, tri_idx)| {
|
self.triangulation.par_chunks(3).enumerate().for_each(|(index, tri_idx)| {
|
||||||
|
|
@ -270,6 +272,13 @@ impl Xenobalanus {
|
||||||
});
|
});
|
||||||
|
|
||||||
self.geometry_data = Arc::try_unwrap(geometry_data).unwrap().into_inner().unwrap();
|
self.geometry_data = Arc::try_unwrap(geometry_data).unwrap().into_inner().unwrap();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
self.triangulation.chunks(3).enumerate().for_each(|(index, tri_idx)| {
|
||||||
|
self.geometry_data.add_triangle(index, &self.points, tri_idx, types);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delfin(
|
pub fn delfin(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue