-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copied the "SimpleEdgeSetIntersector" into a new struct. I'll add the actual RTree implementation in a follow up, and hopefully this way it'll be easier to compare the two implementations.
- Loading branch information
1 parent
4a5b457
commit 3ec60bf
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
mod edge_set_intersector; | ||
mod rstar_edge_set_intersector; | ||
mod segment_intersector; | ||
mod simple_edge_set_intersector; | ||
|
||
pub(crate) use edge_set_intersector::EdgeSetIntersector; | ||
pub(crate) use rstar_edge_set_intersector::RstarEdgeSetIntersector; | ||
pub(crate) use segment_intersector::SegmentIntersector; | ||
pub(crate) use simple_edge_set_intersector::SimpleEdgeSetIntersector; |
59 changes: 59 additions & 0 deletions
59
geo/src/algorithm/relate/geomgraph/index/rstar_edge_set_intersector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use super::super::Edge; | ||
use super::{EdgeSetIntersector, SegmentIntersector}; | ||
use crate::GeoFloat; | ||
|
||
use std::cell::RefCell; | ||
use std::rc::Rc; | ||
|
||
pub(crate) struct RstarEdgeSetIntersector; | ||
|
||
impl RstarEdgeSetIntersector { | ||
pub fn new() -> Self { | ||
RstarEdgeSetIntersector | ||
} | ||
|
||
fn compute_intersects<F: GeoFloat>( | ||
&mut self, | ||
edge0: &Rc<RefCell<Edge<F>>>, | ||
edge1: &Rc<RefCell<Edge<F>>>, | ||
segment_intersector: &mut SegmentIntersector<F>, | ||
) { | ||
let edge0_coords_len = edge0.borrow().coords().len() - 1; | ||
let edge1_coords_len = edge1.borrow().coords().len() - 1; | ||
for i0 in 0..edge0_coords_len { | ||
for i1 in 0..edge1_coords_len { | ||
segment_intersector.add_intersections(edge0, i0, edge1, i1); | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl<F: GeoFloat> EdgeSetIntersector<F> for RstarEdgeSetIntersector { | ||
fn compute_intersections_within_set( | ||
&mut self, | ||
edges: &[Rc<RefCell<Edge<F>>>], | ||
check_for_self_intersecting_edges: bool, | ||
segment_intersector: &mut SegmentIntersector<F>, | ||
) { | ||
for edge0 in edges.iter() { | ||
for edge1 in edges.iter() { | ||
if check_for_self_intersecting_edges || edge0.as_ptr() != edge1.as_ptr() { | ||
self.compute_intersects(edge0, edge1, segment_intersector); | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn compute_intersections_between_sets( | ||
&mut self, | ||
edges0: &[Rc<RefCell<Edge<F>>>], | ||
edges1: &[Rc<RefCell<Edge<F>>>], | ||
segment_intersector: &mut SegmentIntersector<F>, | ||
) { | ||
for edge0 in edges0 { | ||
for edge1 in edges1 { | ||
self.compute_intersects(edge0, edge1, segment_intersector); | ||
} | ||
} | ||
} | ||
} |