Skip to content

Commit f4a2961

Browse files
committed
fmt
1 parent e665ef9 commit f4a2961

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+293
-213
lines changed

iTriangle/src/advanced/bitset.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub struct IndexBitSet {
66
}
77

88
impl IndexBitSet {
9-
109
#[inline]
1110
pub fn with_size(count: usize) -> Self {
1211
let len = count >> 6;
@@ -43,7 +42,11 @@ impl IndexBitSet {
4342

4443
#[inline]
4544
pub fn read_and_clean(&mut self, indices: &mut Vec<usize>) {
46-
let count = self.chunks.iter().map(|ch| ch.count_ones() as usize).sum::<usize>();
45+
let count = self
46+
.chunks
47+
.iter()
48+
.map(|ch| ch.count_ones() as usize)
49+
.sum::<usize>();
4750
indices.clear();
4851
if count == 0 {
4952
return;
@@ -70,28 +73,25 @@ impl IndexBitSet {
7073

7174
#[inline]
7275
pub fn is_empty(&self) -> bool {
73-
!self.chunks.iter().any(|&ch|ch != 0)
76+
!self.chunks.iter().any(|&ch| ch != 0)
7477
}
75-
7678
}
7779

7880
impl Default for IndexBitSet {
7981
fn default() -> Self {
80-
Self {
81-
chunks: vec![0; 8],
82-
}
82+
Self { chunks: vec![0; 8] }
8383
}
8484
}
8585

8686
#[cfg(test)]
8787
mod tests {
8888
extern crate std;
8989

90-
use alloc::vec;
9190
use super::*;
92-
use std::collections::HashSet;
93-
use rand::{Rng, SeedableRng};
91+
use alloc::vec;
9492
use rand::rngs::StdRng;
93+
use rand::{Rng, SeedableRng};
94+
use std::collections::HashSet;
9595

9696
#[test]
9797
fn test_empty() {

iTriangle/src/advanced/buffer.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
use alloc::vec::Vec;
21
use crate::advanced::bitset::IndexBitSet;
2+
use alloc::vec::Vec;
33

44
#[derive(Default)]
55
pub struct DelaunayBuffer {
66
pub(crate) bitset: Option<IndexBitSet>,
7-
pub(crate) indices: Option<Vec<usize>>
7+
pub(crate) indices: Option<Vec<usize>>,
88
}
99

1010
impl DelaunayBuffer {
1111
#[inline]
1212
pub fn new() -> Self {
13-
Self { bitset: None, indices: None }
13+
Self {
14+
bitset: None,
15+
indices: None,
16+
}
1417
}
15-
}
18+
}

iTriangle/src/advanced/centroid.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
use alloc::vec;
2-
use alloc::vec::Vec;
31
use crate::advanced::delaunay::IntDelaunay;
42
use crate::geom::triangle::IntTriangle;
3+
use alloc::vec;
4+
use alloc::vec::Vec;
55
use i_overlay::i_float::int::point::IntPoint;
66
use i_overlay::i_shape::int::area::Area;
77
use i_overlay::i_shape::int::shape::IntContour;
88

99
impl IntDelaunay {
10-
1110
/// Constructs a centroid-based polygonal net from the Delaunay triangulation.
1211
/// Each polygon surrounds a vertex using adjacent triangle centers and edge midpoints.
1312
///
@@ -146,9 +145,9 @@ fn middle(a: IntPoint, b: IntPoint) -> IntPoint {
146145

147146
#[cfg(test)]
148147
mod tests {
148+
use crate::int::triangulatable::IntTriangulatable;
149149
use alloc::vec;
150150
use i_overlay::i_float::int::point::IntPoint;
151-
use crate::int::triangulatable::IntTriangulatable;
152151

153152
#[test]
154153
fn test_0() {
@@ -159,8 +158,10 @@ mod tests {
159158
IntPoint::new(0, 10),
160159
];
161160

162-
let centroids = contour.triangulate_with_steiner_points(&[IntPoint::new(5, 5)])
163-
.into_delaunay().centroid_net(0);
161+
let centroids = contour
162+
.triangulate_with_steiner_points(&[IntPoint::new(5, 5)])
163+
.into_delaunay()
164+
.centroid_net(0);
164165
assert_eq!(centroids.len(), 5);
165166
}
166-
}
167+
}

iTriangle/src/advanced/convex.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use alloc::vec;
2-
use alloc::vec::Vec;
31
use crate::advanced::delaunay::IntDelaunay;
42
use crate::geom::triangle::IntTriangle;
53
use crate::index::Index;
4+
use alloc::vec;
5+
use alloc::vec::Vec;
66
use i_overlay::i_float::int::point::IntPoint;
77
use i_overlay::i_shape::int::shape::IntContour;
88
use i_overlay::i_shape::int::simple::Simplify;
@@ -47,7 +47,7 @@ impl ConvexPolygonBuilder {
4747
}
4848

4949
contour.simplify_contour();
50-
50+
5151
contour
5252
}
5353

iTriangle/src/advanced/delaunay.rs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
use crate::advanced::bitset::IndexBitSet;
12
use crate::advanced::buffer::DelaunayBuffer;
2-
use alloc::vec::Vec;
33
use crate::geom::triangle::IntTriangle;
44
use crate::int::triangulation::RawIntTriangulation;
5+
use alloc::vec::Vec;
56
use i_overlay::i_float::int::point::IntPoint;
67
use i_overlay::i_float::u128::UInt128;
7-
use crate::advanced::bitset::IndexBitSet;
88

99
/// A 2D integer-based Delaunay triangulation.
1010
/// Each triangle satisfies the Delaunay condition.
@@ -19,7 +19,6 @@ pub struct IntDelaunay {
1919
}
2020

2121
impl RawIntTriangulation {
22-
2322
/// Converts an int triangle mesh into a Delaunay triangulation by applying edge flips.
2423
///
2524
/// The mesh is refined in-place by checking local angle conditions and
@@ -50,7 +49,6 @@ pub trait DelaunayRefine {
5049
}
5150

5251
impl DelaunayRefine for [IntTriangle] {
53-
5452
#[inline]
5553
fn build(&mut self) {
5654
let mut buffer = DelaunayBuffer::new();
@@ -92,7 +90,7 @@ impl DelaunayRefine for [IntTriangle] {
9290
fn fix_triangle(&mut self, abc_index: usize, unchecked: &mut IndexBitSet) {
9391
// loop by same triangle increase cache locality
9492
let mut skip = usize::MAX;
95-
let mut perfect= false;
93+
let mut perfect = false;
9694
while !perfect {
9795
perfect = true;
9896
let neighbors = unsafe { self.get_unchecked(abc_index) }.neighbors;
@@ -276,14 +274,14 @@ impl IntDelaunay {
276274

277275
#[cfg(test)]
278276
mod tests {
279-
use crate::advanced::delaunay::Vec;
280-
use alloc::vec;
281-
use crate::advanced::delaunay::DelaunayCondition;
282-
use crate::advanced::delaunay::DelaunayRefine;
277+
use crate::advanced::delaunay::DelaunayCondition;
278+
use crate::advanced::delaunay::DelaunayRefine;
283279
use crate::advanced::delaunay::IntDelaunay;
280+
use crate::advanced::delaunay::Vec;
284281
use crate::geom::point::IndexPoint;
285282
use crate::geom::triangle::IntTriangle;
286283
use crate::int::triangulatable::IntTriangulatable;
284+
use alloc::vec;
287285
use i_overlay::core::fill_rule::FillRule;
288286
use i_overlay::core::overlay::IntOverlayOptions;
289287
use i_overlay::core::simplify::Simplify;
@@ -429,10 +427,7 @@ use crate::advanced::delaunay::DelaunayRefine;
429427
let shape = vec![random(8, 5)];
430428

431429
if let Some(first) = shape
432-
.simplify(
433-
FillRule::NonZero,
434-
IntOverlayOptions::keep_all_points(),
435-
)
430+
.simplify(FillRule::NonZero, IntOverlayOptions::keep_all_points())
436431
.first()
437432
{
438433
let shape_area = first.area_two();
@@ -451,10 +446,7 @@ use crate::advanced::delaunay::DelaunayRefine;
451446
let shape = vec![random(8, 12)];
452447

453448
if let Some(first) = shape
454-
.simplify(
455-
FillRule::NonZero,
456-
IntOverlayOptions::keep_all_points(),
457-
)
449+
.simplify(FillRule::NonZero, IntOverlayOptions::keep_all_points())
458450
.first()
459451
{
460452
let shape_area = first.area_two();
@@ -477,10 +469,7 @@ use crate::advanced::delaunay::DelaunayRefine;
477469
}
478470

479471
if let Some(first) = shape
480-
.simplify(
481-
FillRule::NonZero,
482-
IntOverlayOptions::keep_all_points(),
483-
)
472+
.simplify(FillRule::NonZero, IntOverlayOptions::keep_all_points())
484473
.first()
485474
{
486475
let shape_area = first.area_two();

iTriangle/src/advanced/triangulation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use alloc::vec::Vec;
2-
use i_overlay::i_float::int::point::IntPoint;
31
use crate::advanced::delaunay::IntDelaunay;
42
use crate::int::triangulation::{IndexType, IntTriangulation};
3+
use alloc::vec::Vec;
4+
use i_overlay::i_float::int::point::IntPoint;
55

66
impl IntDelaunay {
77
#[inline]
@@ -17,7 +17,7 @@ impl IntDelaunay {
1717
let i0 = I::try_from(v[0].index).unwrap_or(I::ZERO);
1818
let i1 = I::try_from(v[1].index).unwrap_or(I::ZERO);
1919
let i2 = I::try_from(v[2].index).unwrap_or(I::ZERO);
20-
20+
2121
result.extend_from_slice(&[i0, i1, i2]);
2222
}
2323
result
@@ -30,4 +30,4 @@ impl IntDelaunay {
3030
points: self.points,
3131
}
3232
}
33-
}
33+
}

iTriangle/src/float/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use alloc::vec::Vec;
21
use crate::float::triangulation::Triangulation;
32
use crate::int::triangulation::IndexType;
3+
use alloc::vec::Vec;
44

55
pub struct TriangulationBuilder<P, I> {
66
points: Vec<P>,
@@ -21,11 +21,11 @@ impl<P, I: IndexType> TriangulationBuilder<P, I> {
2121
points_count
2222
);
2323
}
24-
24+
2525
let offset = I::try_from(self.points.len()).unwrap_or(I::ZERO);
2626
self.points.extend(triangulation.points);
2727
self.indices
28-
.extend(triangulation.indices.iter().map(|&i|i.add(offset)));
28+
.extend(triangulation.indices.iter().map(|&i| i.add(offset)));
2929
self
3030
}
3131

iTriangle/src/float/centroid_net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use alloc::vec::Vec;
21
use crate::float::delaunay::Delaunay;
2+
use alloc::vec::Vec;
33
use i_overlay::i_float::float::compatible::FloatPointCompatible;
44
use i_overlay::i_float::float::number::FloatNumber;
55
use i_overlay::i_shape::base::data::Contour;

iTriangle/src/float/circumcenter.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ impl<P: FloatPointCompatible<T>, T: FloatNumber> Delaunay<P, T> {
2424
#[inline]
2525
pub fn refine_with_circumcenters_by_obtuse_angle_mut(&mut self, min_area: T) {
2626
let int_area = self.adapter.sqr_float_to_int(min_area);
27-
self.delaunay.refine_with_circumcenters_by_obtuse_angle_mut(int_area);
27+
self.delaunay
28+
.refine_with_circumcenters_by_obtuse_angle_mut(int_area);
2829
}
29-
}
30+
}

iTriangle/src/float/convex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use alloc::vec::Vec;
21
use crate::float::delaunay::Delaunay;
2+
use alloc::vec::Vec;
33
use i_overlay::i_float::float::compatible::FloatPointCompatible;
44
use i_overlay::i_float::float::number::FloatNumber;
55
use i_overlay::i_shape::base::data::Contour;

0 commit comments

Comments
 (0)