meshpro / pygalmesh

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

Calculate Union on meshes from meshio #191

Closed gatoniel closed 2 years ago

gatoniel commented 2 years ago

Hi, I hope it is okay to ask for help here. Additionally, I am unsure if this is a replicate of #131

I want to calculate the union of two 3d closed objects defined by triangles. With meshio.Mesh it is super straight forward to create the meshes of these objects. But I cannot pass them to pygalmesh.Union. Is there a way to use pygalmesh.Union on these meshes or how would you proceed? Or is pygalmesh.Union only available for primitive objects like Spheres, etc. (i.e., things that can be represented with _pygalmesh.DomainBase)?

I would like to use this pseudo code:

# verts1, verts2= ...
# faces = ...
mesh1 = meshio.Mesh(
        verts1, [("triangle", faces)]
)
mesh2 = meshio.Mesh(
        verts2, [("triangle", faces)]
)

# do some intermediate stuff to transform mesh1 and mesh2 to correct format, i.e., _pygalmesh.DomainBase

union = pygalmesh.Union([mesh1, mesh2])

This code results in this error message:

TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. _pygalmesh.Union(arg0: List[_pygalmesh.DomainBase])

Invoked with: [<meshio mesh object>
  Number of points: 96
  Number of cells:
    triangle: 188, <meshio mesh object>
  Number of points: 96
  Number of cells:
    triangle: 188]

If pygalmesh is not the correct choice for this, do you know any other package that can do something like this?