Only remove node when collision is detected during placement

As the node is inserted into the R-tree only afterwards.
This commit is contained in:
Mikolaj Wielgus 2023-08-31 22:45:51 +02:00
parent cd5365c26f
commit 1ac8dd2828
1 changed files with 3 additions and 3 deletions

View File

@ -1,10 +1,10 @@
use geo::Point; use geo::Point;
use petgraph::stable_graph::{StableDiGraph}; use petgraph::stable_graph::StableDiGraph;
use petgraph::visit::EdgeRef; use petgraph::visit::EdgeRef;
use petgraph::Direction::Incoming; use petgraph::Direction::Incoming;
use rstar::primitives::GeomWithData; use rstar::primitives::GeomWithData;
use rstar::RTree; use rstar::RTree;
use spade::{Triangulation}; use spade::Triangulation;
use crate::bow::Bow; use crate::bow::Bow;
use crate::graph::{ use crate::graph::{
@ -233,7 +233,7 @@ impl Layout {
except: &[TaggedIndex], except: &[TaggedIndex],
) -> Result<(), ()> { ) -> Result<(), ()> {
if let Some(..) = self.detect_collision_except(index, except) { if let Some(..) = self.detect_collision_except(index, except) {
self.remove(index); self.graph.remove_node(index.index);
return Err(()); return Err(());
} }
Ok(()) Ok(())