use super::ray_cast::*;
use super::super::path::*;
use super::super::graph_path::*;
use super::super::super::super::geo::*;
impl<Point: Coordinate+Coordinate2D> GraphPath<Point, PathLabel> {
pub fn set_exterior_by_intersecting(&mut self) {
self.set_edge_kinds_by_ray_casting(|path_crossings| (path_crossings[0]&1) != 0 && (path_crossings[1]&1) != 0);
}
}
pub fn path_intersect<POut>(path1: &Vec<impl BezierPath<Point=POut::Point>>, path2: &Vec<impl BezierPath<Point=POut::Point>>, accuracy: f64) -> Vec<POut>
where
POut: BezierPathFactory,
POut::Point: Coordinate+Coordinate2D
{
if path1.is_empty() {
return path2.iter()
.map(|path| POut::from_path(path))
.collect();
} else if path2.is_empty() {
return path1.iter()
.map(|path| POut::from_path(path))
.collect();
}
let mut merged_path = GraphPath::new();
merged_path = merged_path.merge(GraphPath::from_merged_paths(path1.iter().map(|path| (path, PathLabel(0)))));
merged_path = merged_path.collide(GraphPath::from_merged_paths(path2.iter().map(|path| (path, PathLabel(1)))), accuracy);
merged_path.round(accuracy);
merged_path.set_exterior_by_intersecting();
merged_path.heal_exterior_gaps();
merged_path.exterior_paths()
}