1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use crate::geometry::{Ball, Cuboid};
#[cfg(feature = "dim3")]
use crate::geometry::{Cone, Cylinder};
use crate::math::{Point, Real, Vector};
use std::any::TypeId;
use std::collections::HashMap;
#[cfg(feature = "dim2")]
pub fn instances(nsubdivs: u32) -> HashMap<TypeId, Vec<Point<Real>>> {
let mut result = HashMap::new();
result.insert(
TypeId::of::<Cuboid>(),
Cuboid::new(Vector::repeat(0.5)).to_polyline(),
);
result.insert(TypeId::of::<Ball>(), Ball::new(0.5).to_polyline(nsubdivs));
result
}
#[cfg(feature = "dim3")]
#[allow(clippy::type_complexity)]
pub fn instances(nsubdivs: u32) -> HashMap<TypeId, (Vec<Point<Real>>, Vec<[u32; 2]>)> {
let mut result = HashMap::new();
result.insert(
TypeId::of::<Cuboid>(),
Cuboid::new(Vector::repeat(0.5)).to_outline(),
);
result.insert(TypeId::of::<Ball>(), Ball::new(0.5).to_outline(nsubdivs));
result.insert(
TypeId::of::<Cone>(),
Cone::new(0.5, 0.5).to_outline(nsubdivs),
);
result.insert(
TypeId::of::<Cylinder>(),
Cylinder::new(0.5, 0.5).to_outline(nsubdivs),
);
result
}
|