pmneila / PyMCubes

Marching cubes (and related tools) for Python
BSD 3-Clause "New" or "Revised" License
709 stars 89 forks source link

≈EVERY vertex is duplicated? #13

Closed j6k4m8 closed 5 years ago

j6k4m8 commented 6 years ago

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)]
pmneila commented 6 years ago

Hi, @j6k4m8

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

jtpdowns commented 6 years ago

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.

pmneila commented 5 years ago

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

Thank you for letting me know!

j6k4m8 commented 5 years ago

Awesome! Thank you for addressing :)