pmneila/PyMCubes

≈EVERY vertex is duplicated?

j6k4m8 opened this issue · 4 comments

On a simple example, with iso=0., we're seeing a new vertex listed in verts for almost every time that coordinate is used in faces:

This is the vertex list that is generated, with example annotations (mine)

[array([[ 0.,  0.,  0.],
      [ 1.,  1.,  0.],                      <-- A
      [ 1.,  0.,  1.],                      <-- B
      [ 1.,  6.,  1.],
      [ 0.,  5.,  1.],
      ...
      [ 0.,  7.,  0.],
      [ 0.,  8.,  1.],
      [ 0.,  7.,  0.],
      [ 2.,  1.,  0.],                      <-- C 
      [ 1.,  1.,  0.],                      <-- A
      [ 1.,  0.,  1.],                      <-- B 
      [ 2.,  0.,  1.],
      [ 2.,  2.,  1.],
      [ 2.,  1.,  0.],                      <-- C
      [ 1.,  2.,  0.],
      ...
      [ 3.,  8.,  0.],
      [ 3.,  8.,  0.],
      [ 4.,  9.,  0.]], dtype=float32)]

Hi, @j6k4m8

It definitely looks like a bug. However, I cannot reproduce it. Could you give some example code that leads to duplicated vertices?

So this seems like a corner case, but here's a small example:

from mcubes import marching_cubes
from numpy.random import randint

test = randint(0, 10, (5, 10, 2)) == 0
vert, tri = marching_cubes(test, 0)
print(vert.shape)
print(tri.shape)

One instantiation of this yields 48 vertices and 29 triangles for me.

This problem is fixed now. It took two years, but better late than never. 😅

Thank you for letting me know!

Awesome! Thank you for addressing :)