pmneila / PyMCubes

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

Multimaterial Capability? #25

Closed jonathanhestroffer closed 4 years ago

jonathanhestroffer commented 4 years ago

Hi,

I have volume data consisting of different materials with different Feature Ids.

Will PyMCubes work for this type of multimaterial data? For example I would like the isosurface for each Feature Id.

Many thanks, Jonathan

pmneila commented 4 years ago

Hi @jonathanhestroffer

Not sure if I understand what you need. How is exactly your volume data? You have an array indicating different regions of your the volume and need to assign indices to the vertices? You need to extract multiple isosurfaces, one per feature id? What are these feature ids?

Do you have a minimal piece of code that exemplifies your problem?

jonathanhestroffer commented 4 years ago

Hi,

[image: image.png]

This is the type of volumetric data I am working with. Each color represents a Feature with a certain ID. I would like to perform the marching cubes algorithm and extract an isosurface for each Feature. Feature IDs are simply unique integer numbers from 1 to the total number of Features. For example, let's say the red Feature (bottom of the example volume) has an ID of 1, then I would like to extract the isosurface for value 1.

I hope this helps clarify

On Thu, Apr 9, 2020 at 5:02 PM pmneila notifications@github.com wrote:

Hi @jonathanhestroffer https://github.com/jonathanhestroffer

Not sure if I understand what you need. How is exactly your volume data? You have an array indicating different regions of your the volume and need to assign indices to the vertices? You need to extract multiple isosurfaces, one per feature id? What are these feature ids?

Do you have a minimal piece of code that exemplifies your problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pmneila/PyMCubes/issues/25#issuecomment-611809337, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANK6HDT5XMDCI2A742EIFHDRLZOX7ANCNFSM4MERW3UQ .

pmneila commented 4 years ago

Hi,

I cannot see the image. Do you have a link?

In any case, if I understood correctly, cannot you just run marching cubes once per isosurface? Something like this:

meshes = [mcubes.marching_cubes(volume, fid) for fid in feature_ids]

Would that solve your problem?

jonathanhestroffer commented 4 years ago

image

Here is the image.

I forgot to mention that I haven't yet tried your code :)

I will try this. Thank you!

pmneila commented 4 years ago

I see. After seeing your image I realize that my first impression was not correct. What you want is to extract the mesh surrounding each feature id? In that case, the code you want might be like this:

meshes = [mcubes.marching_cubes(volume == fid, 0.5) for fid in feature_ids]

Let me know if that works.