Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworks locate algorithm. #108

Merged
merged 5 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.10.0] - 2024-07-25

### Added

- Added basic `mint` support via the `mint` feature
- Implements `Triangulation::get_vertex(FixedVertexHandle)` (See #106)

### Fix

- Fixes potential crash when inserting / locating vertices (See #107)

## [2.9.0] - 2024-06-14

### Added
Expand Down Expand Up @@ -436,7 +447,9 @@ A lot has changed for the 1.0. release, only larger changes are shown.

Initial commit

[2.8.0]: https://github.com/Stoeoef/spade/compare/v2.8.0...v2.9.0
[2.10.0]: https://github.com/Stoeoef/spade/compare/v2.9.0...v2.10.0

[2.9.0]: https://github.com/Stoeoef/spade/compare/v2.8.0...v2.9.0

[2.8.0]: https://github.com/Stoeoef/spade/compare/v2.7.0...v2.8.0

Expand Down
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ version = "1.0.0"
default-features = false
features = ["derive", "alloc"]

[dependencies.mint]
package = "mint"
optional = true
default-features = false
version = "0.5.9"

[workspace]
members = ["delaunay_compare"]

Expand All @@ -50,3 +56,6 @@ shapefile = "0.6.0"
[[bench]]
name = "benchmarks"
harness = false

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
31 changes: 31 additions & 0 deletions src/cdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,37 @@ mod test {
Ok(())
}

#[test]
pub fn infinite_loop_2() -> Result<(), InsertionError> {
let lines = [
[
Point2::new(0.9296344883099084, 0.03071359966930065),
Point2::new(0.26031306872107085, 0.34491289915959455),
],
[
Point2::new(0.7384289920396423, 0.4981747664368982),
Point2::new(0.06543525273452533, 0.34139896206401854),
],
[
Point2::new(0.9535295221136963, 0.9114305148801416),
Point2::new(0.8306091165247367, 0.08959389670590667),
],
];

let mut cdt = ConstrainedDelaunayTriangulation::<Point2<f64>>::new();

for [a, b] in lines {
let a = cdt.insert(a)?;
let b = cdt.insert(b)?;

cdt.add_constraint_and_split(a, b, |v| v);
}

// This insertion used to fail as the position could not be located
cdt.insert(Point2::new(0.5138795569454557, 0.3186272217036502))?;
Ok(())
}

fn get_cdt_for_try_add_constraint() -> Result<Cdt, InsertionError> {
let vertices = vec![
Point2::new(0.0, -10.0),
Expand Down
2 changes: 1 addition & 1 deletion src/delaunay_core/bulk_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ where
None
}

pub struct PointWithIndex<V> {
pub(crate) struct PointWithIndex<V> {
data: V,
index: usize,
}
Expand Down
4 changes: 4 additions & 0 deletions src/delaunay_core/dcel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ impl<V, DE, UE, F> Dcel<V, DE, UE, F> {
self.faces.truncate(1); // Keep outer face
}

pub fn get_vertex(&self, handle: FixedVertexHandle) -> Option<VertexHandle<V, DE, UE, F>> {
(handle.index() < self.vertices.len()).then(|| self.vertex(handle))
}

pub fn map_vertices<M, V2>(self, f: M) -> Dcel<V2, DE, UE, F>
where
M: Fn(V) -> V2,
Expand Down
Loading
Loading