Skip to content
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

TetGen doesn't work for triangular input surfaces? #37

Open
Kevin-Mattheus-Moerman opened this issue May 23, 2024 · 3 comments
Open

TetGen doesn't work for triangular input surfaces? #37

Kevin-Mattheus-Moerman opened this issue May 23, 2024 · 3 comments

Comments

@Kevin-Mattheus-Moerman
Copy link
Contributor

Based on the cube (quad) mesh example provided in the README, I've just tried to apply this to triangular boundary surfaces. E.g. like this:

F = TriangleFace{Cint}[TriangleFace(1, 2, 3), TriangleFace(4, 2, 1), TriangleFace(4, 3, 2), TriangleFace(4, 1, 3)]
V = Point{3, Float64}[[-0.8164965809277261, -0.47140452079103173, -0.3333333333333333], [0.8164965809277261, -0.47140452079103173, -0.3333333333333333], [0.0, 0.0, 1.0], [0.0, 0.9428090415820635, -0.3333333333333333]]
markers = Cint[-1, -2, 0, 0]

mesh = GeometryBasics.Mesh(V, meta(F, markers=markers))
result = tetrahedralize(mesh, "vpq1.414a0.1")

However, I get the following error:

ERROR: MethodError: no method matching unsafe_array_convert(::Type{Ptr{…}}, ::StructArrays.StructVector{GeometryBasics.NgonFaceMeta{…}, @NamedTuple{…}, Int64})

Closest candidates are:
  unsafe_array_convert(::Type{Ptr{T}}, ::Vector{T}) where T
   @ TetGen ~/.julia/packages/TetGen/QKVpk/src/jltetgenio.jl:251
  unsafe_array_convert(::Type{Ptr{T1}}, ::Vector{T2}) where {T1, T2}
   @ TetGen ~/.julia/packages/TetGen/QKVpk/src/jltetgenio.jl:255
  unsafe_array_convert(::Type{Ptr{TetGen.CFacet{T}}}, ::Tuple{Vector{F}, Vector{TetGen.CPolygon}, Array{TetGen.CFacet{T}, 1}}) where {F, T}
   @ TetGen ~/.julia/packages/TetGen/QKVpk/src/jltetgenio.jl:246
  ...
Stacktrace:
 [1] cconvert(CIO::Type{…}, obj::TetGen.JLTetGenIO{…})
   @ TetGen ~/.julia/packages/TetGen/QKVpk/src/jltetgenio.jl:293
 [2] tetrahedralize(input::TetGen.JLTetGenIO{Float64, 4, 0, 0, Int64, StructArrays.StructVector{…}}, command::String)
   @ TetGen ~/.julia/packages/TetGen/QKVpk/src/jltetgenio.jl:314
 [3] tetrahedralize(mesh::GeometryBasics.Mesh{3, Float64, GeometryBasics.Ngon{…}, FaceView{…}}, command::String)
   @ TetGen ~/.julia/packages/TetGen/QKVpk/src/api.jl:39
 [4] top-level scope
   @ ~/DATA/Julia/comodo_wip/wip/temp_use_TetGen.jl:37
Some type information was truncated. Use `show(err)` to see complete types.

Any help resolving this would be appreciated, thanks.

@j-fu
Copy link
Member

j-fu commented May 23, 2024

This is unfortunate. I am not that much into this part of the API as I am focused on the "raw API"

May be @SimonDanisch can have a look at this before I try to figure this out.

j-fu added a commit that referenced this issue May 23, 2024
… input

With facet markers in the mesh, this creates the wrong entry type for facets.
Fixes #37
@Kevin-Mattheus-Moerman
Copy link
Contributor Author

@j-fu thanks for the quick response. I may need the raw interface too. Is there an example you can share for using it to create a tet mesh on an input domain?

I was also wondering how to retrieve the input boundary marker data, and how to mesh multiple regions and cope with holes. Usually it requires "interior points" to define the regions/holes. (I wrote a tegen wrapper for MATLAB in the past https://www.gibboncode.org/).

Thanks again

@j-fu
Copy link
Member

j-fu commented May 24, 2024

This all should work. See examples/examples.jl (I see there is nothing with hole points though). I am mostly using TetGen via SimplexGridFactory.jl.

So perhaps it makes sense to have a more comprehensive set of examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants