JuliaGeometry / Triangulate.jl

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

Julia-style kwargs? #12

Open fonsp opened 2 years ago

fonsp commented 2 years ago

Really cool! I'm using this package to play around with generative art for my pen plotter 😎

One thing that I was thinking: I have not used the original CLI program before, so this API:

triangulate(triin; planar_straight_graph=true, maxarea=maxarea, quiet=true)

would be more natural than the current API (example from docs):

area=@sprintf("%.15f",maxarea) # Don't use exponential format!
triangulate("pa$(area)Q", triin)

What do you think?

More generally, a more high-level API (without IO, with GeometryBasics or Vector{SVector{Float64,2}} input/output instead of Matrix) would be nice to make this package slightly easier to use for my purposes (very small number of points, sunday afternoon entertainment). I already wrote some functions that I can turn into a PR if you like!

fonsp commented 2 years ago

https://user-images.githubusercontent.com/6933510/153762393-7f08f3f7-dfc0-48d9-9687-bf9b6c7b76a6.mov

j-fu commented 2 years ago

Really cool! I'm using this package to play around with generative art for my pen plotter sunglasses

Nice!

One thing that I was thinking: I have not used the original CLI program before, so this API:

triangulate(triin; planar_straight_graph=true, maxarea=maxarea, quiet=true)

would be more natural than the current API (example from docs):

area=@sprintf("%.15f",maxarea) # Don't use exponential format!
triangulate("pa$(area)Q", triin)

What do you think?

I agree. Essentially I had no time to think about a better API, OTOH I wanted to be able to expose the full functionality of Triangle. For higher level focused on PDE triangulations I created SimplexGridFactory.jl

More generally, a more high-level API (without IO, with GeometryBasics or Vector{SVector{Float64,2}} input/output instead of Matrix) would be nice to make this package slightly easier to use for my purposes (very small number of points, sunday afternoon entertainment). I already wrote some functions that I can turn into a PR if you like!

I would hesitate to draw in GeometryBasics here (IMHO it is not very well documented, in particular for meshes, and I didn't really get the design), so I would vote for Vector{SVector{Float64,2}} which can be created from the Matrix structures with essentially zero overhead. via reinterpret. I suppose however it should be Cdouble instead of Float64, because the C standard doesn't fix the size of double...

The authors of Triangle.jl and TriangleMesh.jl (I am mentioning these in the README) have higher level APIs, which don't cover the full functionality of Triangle though . Also, they don't use the jll (just noticed them about the existence...). I contacted them before I created this package, but we didn't went very far in our conversation, and I needed functionality for the lecture (you remember...) which they didn't cover...