@juliohm thanks a lot for your answer.
Is it possible that triangulate
works only for 2D grids? That is what I understand from the documentation. I tried creating the following 3D grid:
using Meshes, MeshViz
grid = CartesianGrid(Point(1,0,0), Point(10,5,5), dims = (10,6,6))
10×6×6 CartesianGrid{3,Float64}
minimum: Point(1.0, 0.0, 0.0)
maximum: Point(10.0, 5.0, 5.0)
spacing: (0.9, 0.8333333333333334, 0.8333333333333334)
import GLMakie as Mke
viz(grid, showfacets = true)
This is what I get, as expected:
However, if I try to triangulate it:
mesh = triangulate(grid)
ERROR: MethodError: no method matching triangulate(::Hexahedron{3, Float64, Vector{Point3}})
Closest candidates are:
triangulate(::Box{2}) at C:\Users\JM\.julia\packages\Meshes\mqr1d\src\discretization.jl:104
triangulate(::Triangle{Dim, T} where {Dim, T}) at C:\Users\JM\.julia\packages\Meshes\mqr1d\src\discretization.jl:106
triangulate(::Quadrangle{Dim, T} where {Dim, T}) at C:\Users\JM\.julia\packages\Meshes\mqr1d\src\discretization.jl:108
...
Stacktrace:
[1] triangulate(mesh::CartesianGrid{3, Float64})
@ Meshes C:\Users\JM\.julia\packages\Meshes\mqr1d\src\discretization.jl:128
[2] top-level scope
@ none:1
I don’t know if the package does not compute Delaunay triangulations for higher dimensions, or if I’m using the function in a wrong way. By the error message, it seems as if the code interprets the CartesianGrid as an Hexahedron (which is not the case).
So I would need to create a 3-D or even 4-D Delaunay triangulations and use the KNearestSearch
function you suggested (or other).
I appreciate your help.
Regards,