JuliaGeometry / Triangulate.jl

Julia Wrapper for the Triangle Mesh Generator
MIT License
38 stars 11 forks source link

Handling of o2 nodes #8

Closed tduretz closed 3 years ago

tduretz commented 3 years ago

Hi everyone, I was wondering whether anyone uses the "o2" option. This adds mid-faces nodes (o2 nodes) to the list of points. I have tried this option with Triangulate.jl and it seems that using the "o2" option messes up the triangle to node numbering. The usual behaviour of Triangle is that when o2 is not parsed in, the triangle list has a size of 3n_triangles (n_triangles being the number of triangles in the mesh). If o2 is parse in then the size of the triangle list 6n_triangles as it also includes the o2 nodes. From what I see, using the o2 option with Triangulate.jl does result in having o2 nodes in the point list but the triangle list remains of size 3*n_triangles and mixes indices of vertex nodes with those of mid-face nodes. Can you please let me know if I'm doing anything wrong there? Below is a minimum example: Cheers

using Triangulate

# Without second order triangles
triin=Triangulate.TriangulateIO()
triin.pointlist=Matrix{Cdouble}([0.0 0.0 ; 1.0 0.0 ; 1.0  1.0; 0.0 1.0]')
triin.segmentlist=Matrix{Cint}([1 2 ; 2 3 ; 3 4 ; 4 1 ]')
triin.segmentmarkerlist=Vector{Int32}([1, 2, 3, 4])
(triout, vorout)=triangulate("pq", triin)  
x = triout.pointlist[1,:]
y = triout.pointlist[2,:]
display(x)
display(y)
display(triout.trianglelist)

# With second order triangles
triin=Triangulate.TriangulateIO()
triin.pointlist=Matrix{Cdouble}([0.0 0.0 ; 1.0 0.0 ; 1.0  1.0; 0.0 1.0]')
triin.segmentlist=Matrix{Cint}([1 2 ; 2 3 ; 3 4 ; 4 1 ]')
triin.segmentmarkerlist=Vector{Int32}([1, 2, 3, 4])
(triout, vorout)=triangulate("pqo2", triin)  #           <------- here o2  is parsed in as input argument
x = triout.pointlist[1,:]
y = triout.pointlist[2,:]
display(x')                                                     #           <------- correct size and point positions
display(y')                                                     #           <------- correct size and point positions
display(triout.trianglelist)                            #           <------- wrong size and mixed up numbering
j-fu commented 3 years ago

Thanks for the MWE - I assume a bug in the interface Julia code, probably will have to wait for Friday to find time for figuring out.

j-fu commented 3 years ago

Ok tagged 2.0.1 which should fix this.