Skip to content

Failing tests with lower max_error #6

@kylebarron

Description

@kylebarron

When trying to add more tests to compare against Martini output, I'm getting slightly smaller vertices and triangles arrays (on the order of 25 fewer elements for vertices) for smaller max_error values. Specifically, running on the fuji.png tile with max_error=20, I get 25 fewer vertices elements in the array.

I tested the pre-cython code and got the same results.

I think isolated to the issue to how many times the upper branch of an if block is called. Specifically, here

if (abs(ax - cx) + abs(ay - cy) > 1) and (self.errors_view[my * size + mx] > self.max_error):
self.countElements(cx, cy, ax, ay, mx, my)
self.countElements(bx, by, cx, cy, mx, my)
else:
if not self.indices_view[ay * size + ax]:
self.num_vertices += 1
self.indices_view[ay * size + ax] = self.num_vertices
if not self.indices_view[by * size + bx]:
self.num_vertices += 1
self.indices_view[by * size + bx] = self.num_vertices
if not self.indices_view[cy * size + cx]:
self.num_vertices += 1
self.indices_view[cy * size + cx] = self.num_vertices
self.num_triangles += 1

For get_mesh(50) (which is equivalent to the Martini.js output) the number of upper branches is the same, but for get_mesh(20), there are 25 fewer times when the upper branch is taken.

            if (Math.abs(ax - cx) + Math.abs(ay - cy) > 1 && errors[my * size + mx] > maxError) {
                numUpperLoop++
                countElements(cx, cy, ax, ay, mx, my);
                countElements(bx, by, cx, cy, mx, my);
  var out = tile.getMesh(20);
  out.numUpperLoop // 35107
  var out = tile.getMesh(50);
  out.numUpperLoop // 8255
        if (abs(ax - cx) + abs(ay - cy) > 1) and (self.errors_view[my * size + mx] > self.max_error):
            self.num_upper_loop += 1
            self.countElements(cx, cy, ax, ay, mx, my)
            self.countElements(bx, by, cx, cy, mx, my)
    test = tile.get_mesh(20)
    tile.num_upper_loop # 35082
    test = tile.get_mesh(50)
    tile.num_upper_loop # 8255

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions