-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meaning of input? #2
Comments
The input are xyz voxel coordinates which is effectively the same as a sparse matrix in COOrdinate format. A quick example in 2D to keep things easy: Consider this 4 x 4 dense matrix with two "filled" voxels
The sparse COO version of this would be
(using Python indexing) In my use case, I'm starting with the x/y/z voxel coordinates but if you have a dense 3d matrix, you can use |
Thank you for your quick reply. But I still can not imagine the relationship between input and output.
Could you explain why gives this output? And I am also wondering how could you do marching sparse cubes only given sparse coordinates? |
Your input has two voxels which is why you get a mesh consisting of two cubes. Hard to say from the still but the second one looks distorted. The voxel xyz coordinates are the indices of the filled voxels in a dense matrix, and as such should be integers - the integer thing is not actively enforced but I suspect your As to the implementation: in a nutshell, it uses some fast sorting to find left, right, top, bottom, front and back surface voxels and then reconstructs a mesh from it. Please see the code for details - it's fairly small. |
So, the |
As advertised, Check out this toy example: >>> import numpy as np
>>> # A dense, fully filled 2 x 2 x 2 matrix
>>> dense = np.ones((2, 2, 2))
>>> # Turn the dense matrix into indices of filled voxels
>>> voxels = np.vstack(np.where(dense)).T
>>> voxels.shape
(8, 3)
>>> mesh = sc.marching_cubes(voxels) If you plot/inspect the resulting mesh, you will find that there are no internal faces. |
Yeah, I found that there are no internal faces. What I mean is it looks like |
What is a "sdf sparse volume"? Signed-distance? |
Yes. By "sdf sparse volume", I mean a sparse data structure saving signed-distance of each sparse coordinates. |
What data structure are you using? Scipy sparse matrices/arrays are 2d only, right? |
I don't use scipy sparse matrices. Since I want to do marching cubes in 3d space. So I define an array of shape (N, 4) and each line of it specify a 3d points and its sdf value. |
In that case, you should be able to just pass the x/y/z component of your array to >>> # Find a sensible threshold
>>> th = 10
>>> # `arr` is your (x, y, z, value) array
>>> voxels_xyz = arr[arr[:, 3] >= th, :3].astype('uint32')
>>> mesh = sc.marching_cubes(voxels_xyz) This really should work unless I'm misunderstanding your data. If you don't mind sharing some example array (perhaps as |
I am fully aware of how marching cubes works including the cube configurations but thanks for the reminder. As mentioned in the README, I have no clue what that psychedelic second screenshot is supposed to show but I stand by my earlier statement that you can produce a perfectly decent surface mesh (with a bit of smoothing after meshing). Without you sharing an examaple of your data though, I feel like we're at an impasse and I can't help you. |
Hello, could you give more detailed documentation about sc.marching_cubes.
I am wondering the meaning of the input to sc.marching_cubes. The array of shape (N, 3) is something's 3d coordinates or something else?
The text was updated successfully, but these errors were encountered: