generative modeling for Rhino
I have just come across the CGAL (Computational Geometry Algorithms Library) which houses a C++ library of algorithms and data structures for things like delaunay triangulations, search structures, interpolation etc etc.
For info, the website is here: http://www.cgal.org/
Some of its functionality of course is present in GH but there are some potentially powerful operations that could help in grasshopper definitions.
(the one I am particularly interested in is the "straight skeleton" for polyhedra (think of pitched roof ridgelines http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Straight_ske...), which is similar to Daniel Piker's Medial Axis / Voronoi Skeleton, but calculated differently)
Question is: has anyone attempted to 'port' over any of the CGAL library? and, for someone who has pretty minimal c++/c# skills (me, though I also have access to people who are half-decent), how would one attempt to utilise their library from GH?
Thanks for any info
It is possible to invoke methods in a C++ dll using C#. However this requires that all method calls only use very simple data types (booleans, integers, doubles, pointers or arrays of the above, not an exhaustive list). This is how RhinoCommon talks to the Rhino C++ SDK.
I haven't looked at CGAL code but it is quite likely that some sort of wrapper dll needs to be written in C++ that exposes the functionality via such simplified functions. This is both difficult and a lot of work.
Porting code over to C# may or may not be feasible depending on how CGAL was written. If it uses a lot of pointers, instances and references then it will be a cr*pload of work to port it correctly.
The problem with porting libraries like these is that functions -such as straight skeletons- often rely on many other parts of the library, so porting a small part of it is in fact impossible.
I don't fancy your chances in the short term. I think there's a lot of interest in providing a .NET version of CGAL but it doesn't seem like there's anything out there yet.
Thanks David. It looks like you are right in that functions of the CGAL library have deeply nested references etc to lower-level frameworks.
Was wondering if you/anyone has come across a GH-implementable straight-skeleton code/definition? Looking at http://twak.blogspot.com.au/2011/01/degeneracy-in-weighted-straight..., it seems its actually a pretty complex problem (and I'm not even interested in the weighted solutions)...
There does seem to be a Python binding:
No longer maintained and not really functioning, however. Also, it might not build correctly for access through IronPython (considering that the bindings are written for CPython)
I wanted to mention that these bindings appear to be in active development once again, for people who are interested.