Meshes.jl icon indicating copy to clipboard operation
Meshes.jl copied to clipboard

Generating meshes from point clouds

Open ElOceanografo opened this issue 5 years ago • 18 comments

Apologies if this is already possible and I just couldn't find it. It would be excellent to have methods for generating meshes from randomly ordered point clouds. Likewise, methods for refining them so they are "nice" (angles not too acute, etc.).

ElOceanografo avatar Nov 16 '20 18:11 ElOceanografo

You are not missing anything, we still need to implement such methods. I am trying to finish something first before jumping into the tesselation problem from point clouds. It would be nice to understand how you are using the package? Also, more than welcome to contribute with code too :+1:

juliohm avatar Nov 16 '20 20:11 juliohm

Good to hear! I'm interested in generating meshes for Markov random spatial fields, to use in spatio-temporal statistical models. My use case is to take a set of geographical boundaries (e.g. coastlines) and a set of irregularly-spaced observations and generate a triangulated mesh that follows the boundaries and is higher-resolution in areas with more observations. A simple example is on the Readme for this WIP package; see also this issue.

ElOceanografo avatar Nov 16 '20 22:11 ElOceanografo

It would be nice to interface with GeoStats.jl at some point, that is create a solver that is compatible with the project so that it can be easily plugged with other types and features there.

Meshes.jl is being developed with spatial modeling in mind, it is nice to see projects like yours in this context. :)

juliohm avatar Nov 16 '20 23:11 juliohm

@juliohm would delaunay triangulation be a good candidate to answer this issue?

ucalyptus2 avatar Feb 07 '21 07:02 ucalyptus2

@forkbabu yes, Delaunay is a valid approach. I've finished the FIST algorithm for triangulation of polygonal areas, and the next step is to add some Delaunay/Voronoi functionality. If you have experience in the subject, please feel free to contribute. There is also other open issues that could be addressed more quickly like test coverage.

juliohm avatar Feb 07 '21 10:02 juliohm

I was recently looking at the method in this paper, which is what VoronoiDelaunay.jl uses and seems like a fast and robust approach. I don't think it would be that hard to implement using the interface in this package. While I'm tempted, I unfortunately don't think I have the time to do it myself right now.

Whatever approach is used, having some way to refine the triangulation is important. That might be a separate issue, though, since it'll be applicable to all triangulations (polygons, point clouds, combinations, whatever).

ElOceanografo avatar Feb 08 '21 22:02 ElOceanografo

FWIW, there's a first work-in-progress attempt at wrapping startin over at StarTIN.jl, so you would have at least the Delaunay Triangulation part covered.

evetion avatar Mar 08 '21 20:03 evetion

Thanks @evetion there is also VoronoiDelaunay.jl in pure Julia right? We would like to have an implementation inside Meshes.jl to avoid the fragmentation we currently have in JuliaGeometry. Also we would like to use a consistent set of geometry and point types that has been extensively tested as we are doing here. VoronoiDelaunay.jl uses raw Julia vectors for points and from what I quickly scanned StarTIN.jl uses matrices. Ideally we will create an implementation that uses Point for the vertices and Triangle for the triangles and Mesh for the result.

juliohm avatar Mar 08 '21 20:03 juliohm

VoronoiDelaunay.jl only accepts coordinates between 1.0 and 2.0 I believe. StarTIN.jl should use a trait based interface to accept points and return meshes, while the underlying C interface just are vectors.

Btw, do you have a star struct already in Meshes? See Blandford et al. (2003). https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.9.6823

evetion avatar Mar 08 '21 20:03 evetion

Em seg., 8 de mar. de 2021 às 17:49, Maarten Pronk [email protected] escreveu:

VoronoiDelaunay.jl only accepts coordinates between 1.0 and 2.0 I believe. StarTIN.jl should use a trait based interface to accept points and return meshes, while the underlying C interface just are vectors.

It would be nice to try to reuse some of the work in VoronoiDelaunay.jl and provide a scaling of the result (pre and post) processing the results.

Btw, do you have a star struct already in Meshes? ☺️

As in the star generator right? The region of a polygon from which all other points are seen... I have to remember the exact definition, but we don't have a type for it yet nor an algorithm if there exists one. :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JuliaGeometry/Meshes.jl/issues/18#issuecomment-793066194, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZQW3PQBEAUCFRE673PDX3TCUZ4DANCNFSM4TXRF5EA .

juliohm avatar Mar 08 '21 20:03 juliohm

Unfortunately, VoronoiDelaunay.jl is very buggy and is not user-friendly. I checked StarTIN.jl but couldn't find an easy method to get the connectivity list. Is there a method already exposed?

Fortunately, I could use MiniQHull.jl in some of my current research assignments. It is simple and to the point.

juliohm avatar Mar 30 '21 21:03 juliohm

I checked StarTIN.jl but couldn't find an easy method to get the connectivity list. Is there a method already exposed?

Not yet. Is there a preferred way of getting such a list? The structure in StarTIN is a star, so from a vertex to all other vertices. Or do you want the actual triangles like [a, b, c]?

evetion avatar Mar 31 '21 19:03 evetion

The connectivities of the triangle would be ideal. It will be nice to compare all these different well-established implementations as we evolve our own pure Julia implementations in Meshes.jl.

juliohm avatar Mar 31 '21 19:03 juliohm

Update. We can now sample points homogeneously on an initial mesh with blue noise. That means that we can enforce a minimum distance between points and consequently produce good triangles during tesselation.

Next step consists of introducing a tesselate(pointset, method) function and adding methods. We can introduce a separate package to integrate existing tesselation libraries written in other languages while we gradually implement some methods in pure Julia.

juliohm avatar Jul 27 '21 10:07 juliohm

We have two pure Julia tessellation packages nowadays:

  • https://github.com/DanielVandH/DelaunayTriangulation.jl
  • https://github.com/JuliaGeometry/Delaunator.jl

If the authors are willing to slim down their dependencies to Base Julia types we can add one of the packages as a dependency here and wrap the functionality into a high-level interface.

juliohm avatar Mar 30 '23 17:03 juliohm

Delaunator.jl already only depends on base Julia, though DelaunayTriangulation.jl seems to be more fully-featured and actively developed at the moment. If you're hesitant to include it as a direct dependency here, how would you feel about a package extension with the (trivial) code to convert a DelaunayTriangulation.Triangulation into a Meshes.SimpleMesh?

ElOceanografo avatar Mar 27 '24 00:03 ElOceanografo

Me and @DanielVandH will schedule a meeting in the following months to absorb the data structures in DelaunayTriangulation.jl in a way that we can benefit from other features he developed. The conversion script between DelaunayTriangulation.Triangulation and Meshes.SimpleMesh is useful anyways, and could be shared in this issue as a helper function in the meantime.

We want to do much more with triangulations than just tesselation of areas. But before we can jump into this effort, we will refactor Meshes.jl to accommodate CoordRefSystems.jl

juliohm avatar Mar 27 '24 09:03 juliohm

Sure, that sounds good. Assuming both packages are loaded, this is all it takes:

function SimpleMesh(tri::Triangulation)
    points = Point2.(eachcol(tri.points))
    triangles = connect.(tri.triangles, Triangle)
    return SimpleMesh(points, triangles)
end

ElOceanografo avatar Mar 27 '24 10:03 ElOceanografo