rename helper methods

This commit is contained in:
Vukašin Stepanović
2023-02-15 12:52:59 +00:00
parent bfcdb397ad
commit 935519ced5
133 changed files with 858 additions and 1044 deletions

View File

@@ -53,7 +53,7 @@ impl<'a> Detector<'_> {
if let Some(point) = self.correctTopRight(&points) {
points[3] = point;
} else {
return Err(Exceptions::notFound("point 4 unfound"));
return Err(Exceptions::notFoundWith("point 4 unfound"));
}
// points[3] = self.correctTopRight(&points);
// if points[3] == null {

View File

@@ -254,7 +254,7 @@ fn Scan(
));
}
Err(Exceptions::notFoundEmpty())
Err(Exceptions::notFound)
}
pub fn detect(
@@ -359,6 +359,6 @@ pub fn detect(
}
// #ifndef __cpp_impl_coroutine
Err(Exceptions::notFoundEmpty())
Err(Exceptions::notFound)
// #endif
}

View File

@@ -76,7 +76,7 @@ impl RegressionLine for DMRegressionLine {
fn add(&mut self, p: &RXingResultPoint) -> Result<(), Exceptions> {
if self.direction_inward == RXingResultPoint::default() {
return Err(Exceptions::illegalStateEmpty());
return Err(Exceptions::illegalState);
}
self.points.push(*p);
if self.points.len() == 1 {
@@ -241,7 +241,7 @@ impl DMRegressionLine {
end: &RXingResultPoint,
) -> Result<f64, Exceptions> {
if self.points.len() <= 3 {
return Err(Exceptions::illegalStateEmpty());
return Err(Exceptions::illegalState);
}
// re-evaluate and filter out all points too far away. required for the gapSizes calculation.
@@ -264,14 +264,8 @@ impl DMRegressionLine {
// calculate the (expected average) distance of two adjacent pixels
let unitPixelDist = RXingResultPoint::length(RXingResultPoint::bresenhamDirection(
&(*self
.points
.last()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?
- *self
.points
.first()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?),
&(*self.points.last().ok_or(Exceptions::indexOutOfBounds)?
- *self.points.first().ok_or(Exceptions::indexOutOfBounds)?),
)) as f64;
// calculate the width of 2 modules (first black pixel to first black pixel)
@@ -294,11 +288,7 @@ impl DMRegressionLine {
sumFront
+ self.distance(
end,
&self.project(
self.points
.last()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?,
),
&self.project(self.points.last().ok_or(Exceptions::indexOutOfBounds)?),
) as f64,
);
modSizes[0] = 0.0; // the first element is an invalid sumBack value, would be pop_front() if vector supported this

View File

@@ -199,7 +199,7 @@ impl<'a> EdgeTracer<'_> {
if self.whiteAt(&pEdge) {
// if we are not making any progress, we still have another endless loop bug
if self.p == RXingResultPoint::centered(&pEdge) {
return Err(Exceptions::illegalStateEmpty());
return Err(Exceptions::illegalState);
}
self.p = RXingResultPoint::centered(&pEdge);
@@ -277,7 +277,7 @@ impl<'a> EdgeTracer<'_> {
.points()
.first()
.as_ref()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?),
.ok_or(Exceptions::indexOutOfBounds)?),
) {
return Ok(false);
}
@@ -307,9 +307,9 @@ impl<'a> EdgeTracer<'_> {
.points()
.last()
.as_ref()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?)
.ok_or(Exceptions::indexOutOfBounds)?)
{
return Err(Exceptions::illegalStateEmpty());
return Err(Exceptions::illegalState);
}
if !line.points().is_empty()
&& &&self.p
@@ -317,7 +317,7 @@ impl<'a> EdgeTracer<'_> {
.points()
.last()
.as_ref()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?
.ok_or(Exceptions::indexOutOfBounds)?
{
return Ok(false);
}
@@ -363,7 +363,7 @@ impl<'a> EdgeTracer<'_> {
line.points()
.last()
.as_ref()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?,
.ok_or(Exceptions::indexOutOfBounds)?,
),
) < 1.0
{
@@ -376,11 +376,7 @@ impl<'a> EdgeTracer<'_> {
} else {
RXingResultPoint::dot(
RXingResultPoint::mainDirection(self.d),
self.p
- line
.points()
.last()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?,
self.p - line.points().last().ok_or(Exceptions::indexOutOfBounds)?,
)
};
line.add(&self.p)?;
@@ -393,10 +389,7 @@ impl<'a> EdgeTracer<'_> {
}
if !self.updateDirectionFromOrigin(
&(self.p - line.project(&self.p)
+ *line
.points()
.first()
.ok_or(Exceptions::indexOutOfBoundsEmpty())?),
+ *line.points().first().ok_or(Exceptions::indexOutOfBounds)?),
) {
return Ok(false);
}

View File

@@ -26,7 +26,7 @@ pub fn intersect(
l2: &DMRegressionLine,
) -> Result<RXingResultPoint, Exceptions> {
if !(l1.isValid() && l2.isValid()) {
return Err(Exceptions::illegalStateEmpty());
return Err(Exceptions::illegalState);
}
let d = l1.a * l2.b - l1.b * l2.a;
let x = (l1.c * l2.b - l1.b * l2.c) / d;