What would be the best route for me to call the C++ library CGAL (https://www.cgal.org/) from Julia? Does anyone have experience calling this specific library? I know there are a few different packages to call C++ from Julia but I am not sure which is best? Suggestions of which packages to use for this would be great.
It also looks like there is a Python way of calling CGAL so I could get to this through PyCall? I would prefer calling C++ straight from Julia if possible.
CGAL is a very big library, what specific part(s) are you interested in? I would certainly recommend calling C++ directly, the parts they wrap in Python should also be easy to wrap using CxxWrap.jl or Cxx.jl.
Great, sounds good. I am interested in the Advancing front surface reconstruction algorithm (used it before in a package and its amazing) and some of the mesh simplification/resampling algorithms.
If you’re interested in a relatively small number of functions, you might want to consider writing a thin C wrapper around those functions (using extern "C" in your C/C++ code). This has the disadvantage of requiring some manual work, vut the benefit that calling a C shared library from Julia is extremely easy (using the built-in ccall) and works everywhere.
did you read issue #390 and tried the solutions discussed in the comments? at least the binary-build solution should work fine on macOS and any Linux distributions that Julia is running on.
I looked briefly at the interface for the Advancing front reconstruction, and I think it would be quite doable using CxxWrap and a custom C++ class to encapsulate the point set (e.g. adding iterators to a Julia array containing the points). Possibly a nicer way would be to store the points as an array of tuples or even fixed size arrays in Julia, but converting that without copying would take some adjustments in CxxWrap (which I am willing to do).
Either way, I think your final decision on how to wrap this will probably depend on how you want to store the input data on the Julia side.
OK, thanks for the comments, it looks like I have a number of options. Currently my input data in Julia is just a 3*n array of the points (X,Y,Z) locations. e.g.
Instead of the toy print_points function, the PointList class needs a C++ iterator function, so its begin and end iterator can be passed to the first two arguments of CGAL::advancing_front_surface_reconstruction. The advantage of this approach is that the points are not copied, the downside is that writing iterators in C++ is quite painful.
A simpler but more wasteful option would be to just copy the points from an ArrayRef to a std::vector<Point_3>.