use super::PcurveNurbsPoles;
use crate::math::Point2;
use crate::units::FinitePoint2;
#[derive(Debug)]
pub struct PcurveEvaluatorLanes {
points: Vec<Point2>,
weights: Option<Vec<f64>>,
}
impl PcurveEvaluatorLanes {
pub fn new(poles: &PcurveNurbsPoles<FinitePoint2>) -> Self {
let mut points = Vec::new();
let mut weights = None;
match poles {
PcurveNurbsPoles::Polynomial { points: source } => {
for point in source {
points.push(point.get());
}
}
PcurveNurbsPoles::Rational { points: source } => {
for pole in source {
points.push(pole.point.get());
}
let mut copied = Vec::new();
for pole in source {
copied.push(pole.weight.get());
}
weights = Some(copied);
}
}
Self { points, weights }
}
pub fn points(&self) -> &[Point2] {
&self.points
}
pub fn weights(&self) -> Option<&[f64]> {
self.weights.as_deref()
}
}
#[cfg(test)]
mod tests;