Skip to content

Commit 17053d2

Browse files
committed
Increase variable width in isoringbuilder.rs and contourbuilder.rs to support larger inputs
Signed-off-by: netthier <[email protected]>
1 parent 08c1d83 commit 17053d2

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/contourbuilder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use rustc_hash::FxHashMap;
1212
/// [`contour_rings`]: fn.contour_rings.html
1313
pub struct ContourBuilder {
1414
/// The number of columns in the grid
15-
dx: u32,
15+
dx: usize,
1616
/// The number of rows in the grid
17-
dy: u32,
17+
dy: usize,
1818
/// Whether to smooth the contours
1919
smooth: bool,
2020
/// The horizontal coordinate for the origin of the grid.
@@ -38,7 +38,7 @@ impl ContourBuilder {
3838
/// * `dx` - The number of columns in the grid.
3939
/// * `dy` - The number of rows in the grid.
4040
/// * `smooth` - Whether or not the generated rings will be smoothed using linear interpolation.
41-
pub fn new(dx: u32, dy: u32, smooth: bool) -> Self {
41+
pub fn new(dx: usize, dy: usize, smooth: bool) -> Self {
4242
ContourBuilder {
4343
dx,
4444
dy,
@@ -83,8 +83,8 @@ impl ContourBuilder {
8383
.map(|point| {
8484
let x = point.x;
8585
let y = point.y;
86-
let xt = x.trunc() as u32;
87-
let yt = y.trunc() as u32;
86+
let xt = x.trunc() as usize;
87+
let yt = y.trunc() as usize;
8888
let mut v0;
8989
let ix = (yt * dx + xt) as usize;
9090
if ix < len_values {
@@ -112,7 +112,7 @@ impl ContourBuilder {
112112
/// * `values` - The slice of values to be used.
113113
/// * `thresholds` - The slice of thresholds values to be used.
114114
pub fn lines(&self, values: &[Float], thresholds: &[Float]) -> Result<Vec<Line>> {
115-
if values.len() as u32 != self.dx * self.dy {
115+
if values.len() != self.dx * self.dy {
116116
return Err(new_error(ErrorKind::BadDimension));
117117
}
118118
let mut isoring = IsoRingBuilder::new(self.dx, self.dy);
@@ -163,7 +163,7 @@ impl ContourBuilder {
163163
/// * `values` - The slice of values to be used.
164164
/// * `thresholds` - The slice of thresholds values to be used.
165165
pub fn contours(&self, values: &[Float], thresholds: &[Float]) -> Result<Vec<Contour>> {
166-
if values.len() as u32 != self.dx * self.dy {
166+
if values.len() != self.dx * self.dy {
167167
return Err(new_error(ErrorKind::BadDimension));
168168
}
169169
let mut isoring = IsoRingBuilder::new(self.dx, self.dy);
@@ -232,7 +232,7 @@ impl ContourBuilder {
232232
// We will compute rings as previously, but we will
233233
// iterate over the contours in pairs and use the paths from the lower threshold
234234
// and the path from the upper threshold to create the isoband.
235-
if values.len() as u32 != self.dx * self.dy {
235+
if values.len() != self.dx * self.dy {
236236
return Err(new_error(ErrorKind::BadDimension));
237237
}
238238
if thresholds.len() < 2 {

src/isoringbuilder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct Fragment {
4949
/// * `threshold` - The threshold value.
5050
/// * `dx` - The number of columns in the grid.
5151
/// * `dy` - The number of rows in the grid.
52-
pub fn contour_rings(values: &[Float], threshold: Float, dx: u32, dy: u32) -> Result<Vec<Ring>> {
52+
pub fn contour_rings(values: &[Float], threshold: Float, dx: usize, dy: usize) -> Result<Vec<Ring>> {
5353
let mut isoring = IsoRingBuilder::new(dx, dy);
5454
isoring.compute(values, threshold)
5555
}
@@ -59,8 +59,8 @@ pub struct IsoRingBuilder {
5959
fragment_by_start: FxHashMap<usize, usize>,
6060
fragment_by_end: FxHashMap<usize, usize>,
6161
f: Slab<Fragment>,
62-
dx: u32,
63-
dy: u32,
62+
dx: usize,
63+
dy: usize,
6464
is_empty: bool,
6565
}
6666

@@ -70,7 +70,7 @@ impl IsoRingBuilder {
7070
///
7171
/// * `dx` - The number of columns in the grid.
7272
/// * `dy` - The number of rows in the grid.
73-
pub fn new(dx: u32, dy: u32) -> Self {
73+
pub fn new(dx: usize, dy: usize) -> Self {
7474
IsoRingBuilder {
7575
fragment_by_start: FxHashMap::default(),
7676
fragment_by_end: FxHashMap::default(),
@@ -103,8 +103,8 @@ impl IsoRingBuilder {
103103
self.clear();
104104
}
105105
let mut result = Vec::new();
106-
let dx = self.dx as i32;
107-
let dy = self.dy as i32;
106+
let dx = self.dx as i64;
107+
let dy = self.dy as i64;
108108
let mut x = -1;
109109
let mut y = -1;
110110
let mut t0;
@@ -173,8 +173,8 @@ impl IsoRingBuilder {
173173
fn stitch(
174174
&mut self,
175175
line: &[Vec<Float>],
176-
x: i32,
177-
y: i32,
176+
x: i64,
177+
y: i64,
178178
result: &mut Vec<Ring>,
179179
) -> Result<()> {
180180
let start = Pt {

0 commit comments

Comments
 (0)