meshpro / pygalmesh

:spider_web: A Python interface to CGAL's meshing tools
GNU General Public License v3.0
597 stars 57 forks source link

Can not read file when generating surface mesh #72

Closed jadyndev closed 4 years ago

jadyndev commented 4 years ago

When trying to generate a volume mesh from another mesh the following error occurs:

Traceback (most recent call last):
  File "3dmcV3.py", line 49, in <module>
    mesh = pygalmesh.generate_volume_mesh_from_surface_mesh(
  File "/usr/local/lib/python3.8/dist-packages/pygalmesh/main.py", line 197, in generate_volume_mesh_from_surface_mesh
    _generate_from_off(
RuntimeError: Cannot read input file "/tmp/tmpb0f2y371.off"

The file exists and the permissions are valid (-rw-…). The error occurs regardless of the input file (size). I’m running an Debian 10 Container on a Debian based Server.

nschloe commented 4 years ago

Cannot reproduce. How about attaching a minimal file?

jadyndev commented 4 years ago

There's not much code involved: temp.stl is a normal binary stl. Download

import pygalmesh
import meshio

mesh = pygalmesh.generate_volume_mesh_from_surface_mesh(
                "temp.stl",
                facet_angle=25.0,
                facet_size=0.15,
                facet_distance=0.008,
                cell_radius_edge_ratio=3.0,
                verbose=True
            )
print("Saving new file")
meshio.write("output.stl",mesh)

The off file (/tmp/tmp...off):

OFF
# Created by meshio

12 24 0

195.0 235.0 620.0
195.0 245.0 620.0
195.0 235.0 630.0
195.0 245.0 630.0
185.0 235.0 620.0
185.0 235.0 630.0
185.0 245.0 620.0
185.0 245.0 630.0
195.0 255.0 620.0
195.0 255.0 630.0
185.0 255.0 620.0
185.0 255.0 630.0
3 0 1 2
3 2 1 3
3 4 0 5
3 5 0 2
3 6 4 7
3 7 4 5
3 1 6 3
3 3 6 7
3 3 7 2
3 2 7 5
3 6 1 4
3 4 1 0
3 1 8 3
3 3 8 9
3 6 1 7
3 7 1 3
3 10 6 11
3 11 6 7
3 8 10 9
3 9 10 11
3 9 11 3
3 3 11 7
3 10 8 6
3 6 8 1
jadyndev commented 4 years ago

I just found that i works with your example file (elephant.vtu) but when i convert my stl to vtu it stops working again.

nschloe commented 4 years ago

I can reproduce the error. Seems an issue in CGAL, see the linked issue.

nschloe commented 4 years ago

As noted by the CGAL devs, such meshes are not supported.