hpgem / nanomesh

Python workflow tool for generating meshes from 2D and 3D image data
http://nanomesh.readthedocs.org
Apache License 2.0
32 stars 6 forks source link

region marker issue when I use nanomesh generate_contour. #294

Closed hamiddhg closed 11 months ago

hamiddhg commented 11 months ago

I use nanomesh to create a mesh from a binary image attached here. I frequently get Segmentation fault but I have successfully created mesh for much larger images/files. Sometimes it succeeds but sometimes not! It seems that there is an issue with region markers as it shows only "background". The marker on the top left should be "background" instead of "X". Could you please help me solving this issue?

''' plane = Image(Im_binary) mesher = Mesher2D(plane) mesher.generate_contour(max_edge_dist=5) mesher.plot_contour() plt.show() mesh = mesher.triangulate(opts='q30a100') '''

RVE2_size10_UD_5 40_slice00327_Periodic_resized40

Screenshot 2023-11-22 at 15 39 41
stefsmeets commented 11 months ago

Hi @hamiddhg Thanks for the feedback. This is a known limitation of these algorithms. These need special treatment, because the 2 regions are not connected. The algorithm cannot know if they belong together or not.

The labels are just entries in a dictionary that you can modify through the field data attribute: https://nanomesh.readthedocs.io/en/latest/examples/examples_generate_a_2d_triangular_mesh.html#Field-data

hamiddhg commented 11 months ago

Thank you @stefsmeets, I made the changes and now the regions are OK. However, still I get segmentation fault: 11 when I run triangulation. I suspect this is related to RAM but, as you see, the job is very small for 32 GB of RAM!

Best,

Hamid,

stefsmeets commented 11 months ago

I have had these random crashes as well sometimes, it seems to be an issue with the triangulizer (https://pypi.org/project/triangle/). Maybe how the data are specified, but I wasn't able to find a work-around for it.

I'm going to close this issue now, but feel free to re-open or nake a new one if you run into something else!