use argmin::core::ArgminFloat;
use nalgebra::U3;
use crate::prelude::Intersects;
use crate::{
curve::NurbsCurve, misc::FloatingPoint, prelude::CurveIntersectionSolverOptions,
region::CompoundCurve,
};
use super::clip::{clip, Clip};
use super::operation::BooleanOperation;
use super::Boolean;
impl<'a, T: FloatingPoint + ArgminFloat> Boolean<&'a NurbsCurve<T, U3>> for CompoundCurve<T, U3> {
type Output = anyhow::Result<Clip<T>>;
type Option = Option<CurveIntersectionSolverOptions<T>>;
fn boolean(
&self,
operation: BooleanOperation,
other: &'a NurbsCurve<T, U3>,
option: Self::Option,
) -> Self::Output {
let intersections = self.find_intersection(other, option.clone())?;
clip(self, other, operation, option, intersections)
}
}
impl<'a, T: FloatingPoint + ArgminFloat> Boolean<&'a CompoundCurve<T, U3>>
for CompoundCurve<T, U3>
{
type Output = anyhow::Result<Clip<T>>;
type Option = Option<CurveIntersectionSolverOptions<T>>;
fn boolean(
&self,
operation: BooleanOperation,
other: &'a CompoundCurve<T, U3>,
option: Self::Option,
) -> Self::Output {
let intersections = self.find_intersection(other, option.clone())?;
clip(self, other, operation, option, intersections)
}
}