Skip to content

Commit

Permalink
some checks on self interctin
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed Aug 17, 2024
1 parent 82cfac9 commit 675fab0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion geo/src/algorithm/relate/geomgraph/geometry_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
(self.tree.as_ref().unwrap(), edges)
}

fn update_tree(&mut self) {
pub(crate) fn update_tree(&mut self) {
if self.tree.is_none() {
self.tree = Some(self.build_tree());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ mod conversions {
impl<'a, F: GeoFloat> From<GeometryCow<'a, F>> for PreparedGeometry<'a, F> {
fn from(geometry: GeometryCow<'a, F>) -> Self {
let mut geometry_graph = GeometryGraph::new(0, geometry);
geometry_graph.update_tree(); // TODO: maybe unecessary

// TODO: don't pass in line intersector here - in theory we'll want pluggable line intersectors
// and the type (Robust) shouldn't be hard coded here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ impl<F: GeoFloat> EdgeSetIntersector<F> for SimpleEdgeSetIntersector {
segment_intersector: &mut SegmentIntersector<F>,
) {
let edges = graph.edges_mut();
let mut checks = 0;
for i in 0..edges.len() {
let (e0, e1) = edges.split_at_mut(i + 1);
let (e0, edge0) = e0.split_at_mut(i);
assert_eq!(edge0.len(), 1);
let edge0 = &mut edge0[0];

if check_for_self_intersecting_edges {
Expand All @@ -61,8 +63,12 @@ impl<F: GeoFloat> EdgeSetIntersector<F> for SimpleEdgeSetIntersector {

for edge1 in e0.iter_mut().chain(e1) {
self.compute_intersects(edge0, edge1, segment_intersector);
checks += 1;
}
}

println!("checks: {}", checks);
assert_eq!(checks, edges.len()*edges.len());
}

fn compute_intersections_between_sets<'a>(
Expand Down

0 comments on commit 675fab0

Please sign in to comment.