JuhaHeiskala / DirectQhull.jl

MIT License
11 stars 5 forks source link

3D `Voronoi` lacks a `qh_order_vertexneighbors` implementation #2

Closed thchr closed 1 year ago

thchr commented 1 year ago
julia> Voronoi(rand(4,8))
ERROR: Unimplemented
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] qh_order_vertexneighbors_nd(qh_ptr::Ptr{DirectQhull.qhT}, vertex::DirectQhull.QHvertexT{5})
   @ DirectQhull C:\Users\tchr\.julia\dev\DirectQhull\src\DirectQhull.jl:1481
 [3] qh_get_voronoi_diagram(qh_ptr::Ptr{DirectQhull.qhT}, num_input_pnts::Int64, #unused#::Val{5})
   @ DirectQhull C:\Users\tchr\.julia\dev\DirectQhull\src\DirectQhull.jl:1395
 [4] Voronoi(pnts::Matrix{Float64}, qhull_options::Vector{String})
   @ DirectQhull C:\Users\tchr\.julia\dev\DirectQhull\src\DirectQhull.jl:526
 [5] Voronoi(pnts::Matrix{Float64})
   @ DirectQhull C:\Users\tchr\.julia\dev\DirectQhull\src\DirectQhull.jl:506
 [6] top-level scope
   @ REPL[17]:1

Which hits this line in qh_order_vertexneighbors_nd: https://github.com/JuhaHeiskala/DirectQhull.jl/blob/e3bca5dbe79613421709841ff50f99d5a1f3aeec/src/DirectQhull.jl#L1484-L1487

JuhaHeiskala commented 1 year ago

I left the implemention on the table for some reason I can't recall now. Need to check how Scipy handled this, might have been just a bit of work to implement.

JuhaHeiskala commented 1 year ago

Actually it needs imitating this piece of code from qhull's io_r.c

qsort(SETaddr_(vertex->neighbors, facetT), (size_t)numneighbors,
             sizeof(facetT *), qh_compare_facetvisit);

The commented out sort was apparently some non-functioning try...

JuhaHeiskala commented 1 year ago

Hmm, seems that I have overlooked the implementation of qh_order_vertexneighbors in io_r.c. It actually supports >3-dimensions, so I should be able to just remove the unimplemented error.