Skip to content
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
22 changes: 22 additions & 0 deletions src/delaunay_core/bulk_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1469,4 +1469,26 @@ mod test {

Ok(())
}

#[test]
fn test_bulk_load_with_flat_triangle() -> Result<(), InsertionError> {
let dt = DelaunayTriangulation::<Point2<f64>>::bulk_load(vec![
Point2::new(-0.4583333333333335, 0.0035353982507333875),
Point2::new(-0.44401041666666685, 0.09000381880347848),
Point2::new(-0.4296875000000002, 0.17647223935622358),
Point2::new(-0.4153645833333336, 0.26294065990896864),
Point2::new(-0.40104166666666696, 0.34940908046171376),
Point2::new(-0.34375, 0.4242340611633537),
Point2::new(-0.2864583333333335, 0.48354314550173816),
Point2::new(-0.22916666666666696, 0.5220359027883882),
Point2::new(-0.171875, 0.5605286600750382),
Point2::new(-0.11458333333333348, 0.5743482879175245),
Point2::new(-0.05729166666666696, 0.5864208547026089),
])?;
dt.sanity_check();
let tri = dt.inner_faces().nth(4).unwrap();
let [p0, p1, p2] = tri.positions();
assert!(crate::delaunay_core::math::side_query(p0, p1, p2).is_on_left_side());
Ok(())
}
}
68 changes: 34 additions & 34 deletions src/delaunay_core/handles/handle_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use core::hash::{Hash, Hasher};
use num_traits::{Float, One};

// Debug implementations
impl<'a, V, DE, UE, F> Debug for VertexHandle<'a, V, DE, UE, F> {
impl<V, DE, UE, F> Debug for VertexHandle<'_, V, DE, UE, F> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "VertexHandle({:?})", self.handle.index())
}
}

impl<'a, V, DE, UE, F> Debug for DirectedEdgeHandle<'a, V, DE, UE, F> {
impl<V, DE, UE, F> Debug for DirectedEdgeHandle<'_, V, DE, UE, F> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(
f,
Expand All @@ -30,7 +30,7 @@ impl<'a, V, DE, UE, F> Debug for DirectedEdgeHandle<'a, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> Debug for UndirectedEdgeHandle<'a, V, DE, UE, F> {
impl<V, DE, UE, F> Debug for UndirectedEdgeHandle<'_, V, DE, UE, F> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
let [v0, v1] = self.vertices();
write!(
Expand All @@ -43,7 +43,7 @@ impl<'a, V, DE, UE, F> Debug for UndirectedEdgeHandle<'a, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> Debug for FaceHandle<'a, PossiblyOuterTag, V, DE, UE, F> {
impl<V, DE, UE, F> Debug for FaceHandle<'_, PossiblyOuterTag, V, DE, UE, F> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
if let Some(inner) = self.as_inner() {
inner.fmt(f)
Expand All @@ -53,7 +53,7 @@ impl<'a, V, DE, UE, F> Debug for FaceHandle<'a, PossiblyOuterTag, V, DE, UE, F>
}
}

impl<'a, V, DE, UE, F> Debug for FaceHandle<'a, InnerTag, V, DE, UE, F> {
impl<V, DE, UE, F> Debug for FaceHandle<'_, InnerTag, V, DE, UE, F> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
let [v0, v1, v2] = self.vertices();
write!(
Expand Down Expand Up @@ -107,58 +107,58 @@ impl FixedDirectedEdgeHandle {
}
}

impl<'a, V, DE, UE, F, Type: Copy, InnerOuter: InnerOuterMarker> Clone
for DynamicHandleImpl<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type: Copy, InnerOuter: InnerOuterMarker> Clone
for DynamicHandleImpl<'_, V, DE, UE, F, Type, InnerOuter>
{
fn clone(&self) -> Self {
*self
}
}

impl<'a, V, DE, UE, F, Type: Copy, InnerOuter: InnerOuterMarker> Copy
for DynamicHandleImpl<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type: Copy, InnerOuter: InnerOuterMarker> Copy
for DynamicHandleImpl<'_, V, DE, UE, F, Type, InnerOuter>
{
}

impl<'a, V, DE, UE, F, Type: PartialEq, InnerOuter: InnerOuterMarker> PartialEq
for DynamicHandleImpl<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type: PartialEq, InnerOuter: InnerOuterMarker> PartialEq
for DynamicHandleImpl<'_, V, DE, UE, F, Type, InnerOuter>
{
fn eq(&self, other: &Self) -> bool {
self.handle == other.handle
}
}

impl<'a, V, DE, UE, F, Type: Eq, InnerOuter: InnerOuterMarker> Eq
for DynamicHandleImpl<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type: Eq, InnerOuter: InnerOuterMarker> Eq
for DynamicHandleImpl<'_, V, DE, UE, F, Type, InnerOuter>
{
}

impl<'a, V, DE, UE, F, Type: Hash, InnerOuter: InnerOuterMarker> Hash
for DynamicHandleImpl<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type: Hash, InnerOuter: InnerOuterMarker> Hash
for DynamicHandleImpl<'_, V, DE, UE, F, Type, InnerOuter>
{
fn hash<HA: Hasher>(&self, state: &mut HA) {
self.handle.hash(state);
}
}

impl<'a, V, DE, UE, F, Type: Ord, InnerOuter: InnerOuterMarker> Ord
for DynamicHandleImpl<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type: Ord, InnerOuter: InnerOuterMarker> Ord
for DynamicHandleImpl<'_, V, DE, UE, F, Type, InnerOuter>
{
fn cmp(&self, other: &Self) -> Ordering {
self.handle.cmp(&other.handle)
}
}

impl<'a, V, DE, UE, F, Type: PartialOrd, InnerOuter: InnerOuterMarker> PartialOrd
for DynamicHandleImpl<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type: PartialOrd, InnerOuter: InnerOuterMarker> PartialOrd
for DynamicHandleImpl<'_, V, DE, UE, F, Type, InnerOuter>
{
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.handle.partial_cmp(&other.handle)
}
}

impl<'a, V, DE, UE, F, Type: Copy + Default, InnerOuter: InnerOuterMarker>
DynamicHandleImpl<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type: Copy + Default, InnerOuter: InnerOuterMarker>
DynamicHandleImpl<'_, V, DE, UE, F, Type, InnerOuter>
{
/// Converts this dynamic handle to its fixed variant.
///
Expand Down Expand Up @@ -201,7 +201,7 @@ impl FixedFaceHandle<PossiblyOuterTag> {
}
}

impl<'a, V, DE, UE, F> AsRef<DE> for DirectedEdgeHandle<'a, V, DE, UE, F> {
impl<V, DE, UE, F> AsRef<DE> for DirectedEdgeHandle<'_, V, DE, UE, F> {
fn as_ref(&self) -> &DE {
self.data()
}
Expand Down Expand Up @@ -328,7 +328,7 @@ impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F>
impl<V, DE, UE, F> DirectedEdgeHandle<'_, V, DE, UE, F>
where
V: HasPosition,
{
Expand Down Expand Up @@ -432,7 +432,7 @@ where
}
}

impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, CdtEdge<UE>, F> {
impl<V, DE, UE, F> DirectedEdgeHandle<'_, V, DE, CdtEdge<UE>, F> {
/// Returns `true` if this edge is a constraint edge.
pub fn is_constraint_edge(self) -> bool {
self.as_undirected().is_constraint_edge()
Expand Down Expand Up @@ -488,7 +488,7 @@ impl<'a, V, DE, UE, F> UndirectedVoronoiEdge<'a, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> AsRef<UE> for UndirectedEdgeHandle<'a, V, DE, UE, F> {
impl<V, DE, UE, F> AsRef<UE> for UndirectedEdgeHandle<'_, V, DE, UE, F> {
fn as_ref(&self) -> &UE {
self.data()
}
Expand Down Expand Up @@ -527,7 +527,7 @@ impl<'a, V, DE, UE, F> UndirectedEdgeHandle<'a, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> UndirectedEdgeHandle<'a, V, DE, UE, F>
impl<V, DE, UE, F> UndirectedEdgeHandle<'_, V, DE, UE, F>
where
V: HasPosition,
{
Expand All @@ -546,7 +546,7 @@ where
}
}

impl<'a, V, DE, UE, F> UndirectedEdgeHandle<'a, V, DE, UE, F>
impl<V, DE, UE, F> UndirectedEdgeHandle<'_, V, DE, UE, F>
where
V: HasPosition,
V::Scalar: Float,
Expand All @@ -570,14 +570,14 @@ where
}
}

impl<'a, V, DE, UE, F> UndirectedEdgeHandle<'a, V, DE, CdtEdge<UE>, F> {
impl<V, DE, UE, F> UndirectedEdgeHandle<'_, V, DE, CdtEdge<UE>, F> {
/// Returns `true` if this edge is a constraint edge.
pub fn is_constraint_edge(self) -> bool {
self.data().is_constraint_edge()
}
}

impl<'a, V, DE, UE, InnerOuter, F> AsRef<F> for FaceHandle<'a, InnerOuter, V, DE, UE, F>
impl<V, DE, UE, InnerOuter, F> AsRef<F> for FaceHandle<'_, InnerOuter, V, DE, UE, F>
where
InnerOuter: InnerOuterMarker,
{
Expand Down Expand Up @@ -617,7 +617,7 @@ impl<'a, V, DE, UE, F> FaceHandle<'a, InnerTag, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> FaceHandle<'a, InnerTag, V, DE, UE, F>
impl<V, DE, UE, F> FaceHandle<'_, InnerTag, V, DE, UE, F>
where
V: HasPosition,
{
Expand Down Expand Up @@ -700,13 +700,13 @@ where
}
}

impl<'a, V, DE, UE, F> AsRef<V> for VertexHandle<'a, V, DE, UE, F> {
impl<V, DE, UE, F> AsRef<V> for VertexHandle<'_, V, DE, UE, F> {
fn as_ref(&self) -> &V {
self.data()
}
}

impl<'a, V, DE, UE, F> VertexHandle<'a, V, DE, UE, F>
impl<V, DE, UE, F> VertexHandle<'_, V, DE, UE, F>
where
V: HasPosition,
{
Expand Down Expand Up @@ -775,7 +775,7 @@ impl<'a, V, DE, UE, F> VertexHandle<'a, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F>
impl<V, DE, UE, F> DirectedEdgeHandle<'_, V, DE, UE, F>
where
V: HasPosition,
V::Scalar: Float,
Expand All @@ -796,7 +796,7 @@ where
}
}

impl<'a, V, DE, UE, F, InnerOuter: InnerOuterMarker> FaceHandle<'a, InnerOuter, V, DE, UE, F> {
impl<V, DE, UE, F, InnerOuter: InnerOuterMarker> FaceHandle<'_, InnerOuter, V, DE, UE, F> {
/// Returns a reference to the data associated with this face.
pub fn data(&self) -> &F {
self.dcel.face_data(self.handle)
Expand Down
8 changes: 4 additions & 4 deletions src/delaunay_core/handles/iterators/fixed_iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ where
}
}

impl<'a, V, DE, UE, F, Type, InnerOuter> DoubleEndedIterator
for DynamicHandleIterator<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type, InnerOuter> DoubleEndedIterator
for DynamicHandleIterator<'_, V, DE, UE, F, Type, InnerOuter>
where
Type: DelaunayElementType,
InnerOuter: InnerOuterMarker,
Expand All @@ -120,8 +120,8 @@ where
}
}

impl<'a, V, DE, UE, F, Type, InnerOuter> ExactSizeIterator
for DynamicHandleIterator<'a, V, DE, UE, F, Type, InnerOuter>
impl<V, DE, UE, F, Type, InnerOuter> ExactSizeIterator
for DynamicHandleIterator<'_, V, DE, UE, F, Type, InnerOuter>
where
Type: DelaunayElementType,
InnerOuter: InnerOuterMarker,
Expand Down
2 changes: 1 addition & 1 deletion src/delaunay_core/handles/iterators/hull_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'a, V, DE, UE, F> Iterator for HullIterator<'a, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> DoubleEndedIterator for HullIterator<'a, V, DE, UE, F> {
impl<V, DE, UE, F> DoubleEndedIterator for HullIterator<'_, V, DE, UE, F> {
fn next_back(&mut self) -> Option<Self::Item> {
self.inner_iterator.next_back()
}
Expand Down
2 changes: 1 addition & 1 deletion src/delaunay_core/handles/public_handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl<'a, V, DE, UE, F> DirectedVoronoiEdge<'a, V, DE, UE, F> {
}
}

impl<'a, V, DE, UE, F> DirectedVoronoiEdge<'a, V, DE, UE, F>
impl<V, DE, UE, F> DirectedVoronoiEdge<'_, V, DE, UE, F>
where
V: HasPosition,
{
Expand Down
3 changes: 1 addition & 2 deletions src/delaunay_core/hint_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ impl<S: SpadeNum, const BRANCH_FACTOR: u32> HintGenerator<S>
}

let prev_num_vertices = last_layer_size as u32;
// Divide by BRANCH_FACTOR and round up
let max_num_vertices = (prev_num_vertices + BRANCH_FACTOR - 1) / BRANCH_FACTOR;
let max_num_vertices = prev_num_vertices.div_ceil(BRANCH_FACTOR);
if triangulation.num_vertices() as u32 > max_num_vertices {
// The layer contains too many elements. Remove the last.
let vertex_to_pop = FixedVertexHandle::new(triangulation.num_vertices() - 1);
Expand Down
1 change: 0 additions & 1 deletion src/delaunay_core/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ impl std::error::Error for InsertionError {}
///
/// *See also [validate_coordinate], [validate_vertex], [MAX_ALLOWED_VALUE],
/// [crate::Triangulation::insert], [mitigate_underflow]*

// Implementation note: These numbers come from the paper of Jonathan Richard Shewchuk:
// "The four predicates implemented for this report will not overflow nor underflow if
// their inputs have exponents in the range -[142, 201] and IEEE-745 double precision
Expand Down
2 changes: 1 addition & 1 deletion src/delaunay_core/refinement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ where
let [is_left_side_excluded, is_right_side_excluded] =
[segment.face(), segment.rev().face()].map(|face| {
face.as_inner()
.map_or(false, |face| excluded_faces.contains(&face.fix()))
.is_some_and(|face| excluded_faces.contains(&face.fix()))
});

let is_constraint_edge = segment.is_constraint_edge();
Expand Down
8 changes: 4 additions & 4 deletions src/intersection_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where
EdgeOverlap(DirectedEdgeHandle<'a, V, DE, UE, F>),
}

impl<'a, V, DE, UE, F> core::fmt::Debug for Intersection<'a, V, DE, UE, F>
impl<V, DE, UE, F> core::fmt::Debug for Intersection<'_, V, DE, UE, F>
where
V: HasPosition,
{
Expand All @@ -103,7 +103,7 @@ where
}
}

impl<'a, V, DE, UE, F> PartialEq for Intersection<'a, V, DE, UE, F>
impl<V, DE, UE, F> PartialEq for Intersection<'_, V, DE, UE, F>
where
V: HasPosition,
{
Expand All @@ -118,9 +118,9 @@ where
}
}

impl<'a, V, DE, UE, F> Copy for Intersection<'a, V, DE, UE, F> where V: HasPosition {}
impl<V, DE, UE, F> Copy for Intersection<'_, V, DE, UE, F> where V: HasPosition {}

impl<'a, V, DE, UE, F> Clone for Intersection<'a, V, DE, UE, F>
impl<V, DE, UE, F> Clone for Intersection<'_, V, DE, UE, F>
where
V: HasPosition,
{
Expand Down
Loading