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
When trying to add more tests to compare against Martini output, I'm getting slightly smaller
verticesandtrianglesarrays (on the order of 25 fewer elements forvertices) for smallermax_errorvalues. Specifically, running on thefuji.pngtile withmax_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
pymartini/pymartini/martini.pyx
Lines 217 to 231 in 7d5bdf7
For
get_mesh(50)(which is equivalent to the Martini.js output) the number of upper branches is the same, but forget_mesh(20), there are 25 fewer times when the upper branch is taken.