cargo fmt

This commit is contained in:
Henry Schimke
2023-04-23 14:36:51 -05:00
parent cb7050a5dd
commit a811b56fbb
12 changed files with 78 additions and 63 deletions

View File

@@ -221,9 +221,12 @@ pub fn CenterOfRing(
n += 1;
// find out if we come full circle around the center. 8 bits have to be set in the end.
neighbourMask |= (1
<< (4.0 + Point::dot(Point::round(Point::bresenhamDirection(cur.p() - center)), point(1.0, 3.0)))
as u32);
neighbourMask |= 1
<< (4.0
+ Point::dot(
Point::round(Point::bresenhamDirection(cur.p() - center)),
point(1.0, 3.0),
)) as u32;
if !cur.stepAlongEdge(edgeDir, None) {
return None;
@@ -325,8 +328,11 @@ pub fn CollectRingPoints(
// find out if we come full circle around the center. 8 bits have to be set in the end.
neighbourMask |= 1
<< (4.0 + Point::dot(Point::bresenhamDirection(cur.p - centerI), point(1.0, 3.0)))
as u32;
<< (4.0
+ Point::dot(
Point::round(Point::bresenhamDirection(cur.p - centerI)),
point(1.0, 3.0),
)) as u32;
if !cur.stepAlongEdge(edgeDir, None) {
return Vec::default();
@@ -423,8 +429,7 @@ pub fn FitQadrilateralToPoints(center: Point, points: &mut [Point]) -> Option<Qu
}
pub fn QuadrilateralIsPlausibleSquare(q: &Quadrilateral, lineIndex: usize) -> bool {
let mut m = f64::default();
// let mut M = f64::default();
let mut m;
m = Point::distance(q[0], q[3]) as f64; //M = distance(q[0], q[3]);
let mut M = m;

View File

@@ -11,13 +11,14 @@ pub struct FastEdgeToEdgeCounter<'a> {
stepsToBorder: i32, // = 0;
//arr: BitArray,
_arr: isize,
under_arry: &'a BitMatrix//,Vec<bool>
under_arry: &'a BitMatrix, //,Vec<bool>
}
impl<'a> FastEdgeToEdgeCounter<'a> {
pub fn new<T: BitMatrixCursorTrait>(cur: &T) -> FastEdgeToEdgeCounter {
let stride = cur.d().y as isize * cur.img().width() as isize + cur.d().x as isize;
let p = ((cur.p().y as isize * cur.img().width() as isize).abs() as i32 + cur.p().x as i32) as u32; // P IS SET WRONG IN REVERSE
let p = ((cur.p().y as isize * cur.img().width() as isize).abs() as i32 + cur.p().x as i32)
as u32; // P IS SET WRONG IN REVERSE
let maxStepsX = if cur.d().x != 0.0 {
if cur.d().x > 0.0 {
@@ -44,7 +45,7 @@ impl<'a> FastEdgeToEdgeCounter<'a> {
stride,
stepsToBorder,
_arr: cur.p().y as isize * stride as isize, //cur.img().getRow(cur.p().y as u32),
under_arry: cur.img()//.into(),
under_arry: cur.img(), //.into(),
}
}
@@ -65,11 +66,10 @@ impl<'a> FastEdgeToEdgeCounter<'a> {
// if !(self.under_arry[idx_pt]
// == self.under_arry[self.p as usize])
if !(self.under_arry.get_index(idx_pt) == self.under_arry.get_index(self.p as usize))
{
if !(self.under_arry.get_index(idx_pt) == self.under_arry.get_index(self.p as usize)) {
break true;
}
}; // while (p[steps * stride] == p[0]);
} // while (p[steps * stride] == p[0]);
self.p = (self.p as isize + (steps as isize * self.stride)).abs() as u32;
self.stepsToBorder -= steps;
@@ -81,4 +81,4 @@ impl<'a> FastEdgeToEdgeCounter<'a> {
fn get_array_check_index(&self, steps: i32) -> usize {
(self.p as isize + (steps as isize * self.stride)) as usize
}
}
}

View File

@@ -23,7 +23,7 @@ impl<T: Default + Clone + Copy> Matrix<T> {
}
pub fn new(width: usize, height: usize) -> Result<Matrix<T>> {
if (width != 0 && height != 0) {
if (width != 0 && (width * height) / width as usize != height as usize) {
return Err(Exceptions::illegal_argument_with(
"invalid size: width * height is too big",
));
@@ -64,7 +64,7 @@ impl<T: Default + Clone + Copy> Matrix<T> {
}
pub fn get(&self, x: usize, y: usize) -> Option<T> {
if x >= 0 && x < self.width && y >= 0 && y < self.height {
if x >= self.width || y >= self.height {
None
} else {
Some(self.data[Self::get_offset(x, y, self.width)])

View File

@@ -75,7 +75,11 @@ impl<'a> Iterator for PatternViewIterator<'_> {
self.current_position += 1;
Some(*self.pattern_view.data.0.get(self.current_position - 1 + self.pattern_view.start + self.pattern_view.current)?)
Some(
*self.pattern_view.data.0.get(
self.current_position - 1 + self.pattern_view.start + self.pattern_view.current,
)?,
)
}
}
@@ -147,7 +151,10 @@ impl<'a> PatternView<'a> {
}
pub fn iter(&'a self) -> PatternViewIterator<'a> {
PatternViewIterator { pattern_view: self, current_position: 0 }
PatternViewIterator {
pattern_view: self,
current_position: 0,
}
}
pub fn size(&self) -> usize {
@@ -273,7 +280,7 @@ impl<'a> PatternView<'a> {
}
if index >= 0 {
let fetch_spot = ((self.start + self.current) as isize + index) as usize;
return Some(self.data.0[fetch_spot])
return Some(self.data.0[fetch_spot]);
}
if index.abs() > (self.start + self.current) as isize {
return None;
@@ -288,7 +295,7 @@ impl<'a> std::ops::Index<isize> for PatternView<'_> {
fn index(&self, index: isize) -> &Self::Output {
if self.count == self.data.len() {
return &self.data[index.abs() as usize]
return &self.data[index.abs() as usize];
}
if index > self.data.0.len() as isize {
@@ -296,7 +303,7 @@ impl<'a> std::ops::Index<isize> for PatternView<'_> {
}
if index >= 0 {
let fetch_spot = ((self.start + self.current) as isize + index) as usize;
return &self.data.0[fetch_spot]
return &self.data.0[fetch_spot];
}
if index.abs() > self.start as isize {
panic!("array index out of bounds")
@@ -311,7 +318,7 @@ impl<'a> std::ops::Index<usize> for PatternView<'_> {
fn index(&self, index: usize) -> &Self::Output {
if self.count == self.data.len() {
return &self.data[index]
return &self.data[index];
}
if index > self.data.0.len() {