Does someone feel fit to adjust CGAL for usage out of ruby?
-
it would have been great having these processing algoritmhs available from within ruby scripts, does someone feel like preparing this workpath? is it possible?
The Computational Geometry Algorithms Library (CGAL), offers data structures and algorithms like triangulations (2D constrained triangulations and Delaunay triangulations in 2D and 3D), Voronoi diagrams (for 2D and 3D points, 2D additively weighted Voronoi diagrams, and segment Voronoi diagrams), Boolean operations on polygons and polyhedra, arrangements of curves and their applications (2D and 3D envelopes, Minkowski sums), mesh generation (2D Delaunay mesh generation and 3D surface mesh generation, skin surfaces), geometry processing (surface mesh simplification, subdivision and parameterization, as well as estimation of local differential properties, and approximation of ridges and umbilics), alpha shapes, convex hull algorithms (in 2D, 3D and dD), operations on polygons (straight skeleton and offset polygon), search structures (kd trees for nearest neighbor search, and range and segment trees), interpolation (natural neighbor interpolation and placement of streamlines), shape analysis, fitting, and distances (smallest enclosing sphere of points or spheres, smallest enclosing ellipsoid of points, principal component analysis), and kinetic data structures.
-
FOUR YEARS LATER!
I have something in this direction working. Let me know if you're still interested.
-
Dude, we all are interested. Just post it!
-
I'll publish it when I have a moment. Its still in development and no documentation. A couple more months should do the trick. These are the classes I've wrapped so far.
rb_Offset_polygon_2
rb_Point_2
rb_Iso_cuboid_3
rb_Nef_polyhedron_3
rb_Polygon_with_holes_2
rb_Polygon_2
rb_Halffacet
rb_X_monotone_curve_2
rb_Offset_polygon_with_holes_2
rb_SVertex
rb_Aff_transformation_3
rb_SHalfedge
rb_Polygon_set_2
rb_Lazy_exact_nt
rb_Vertex
rb_Point_3To compile it you'll need ruby, cgal and rice installed on your system. I'm on linux but if you get a windows or mac version compiled I'll post it too.
If you can't wait, checkout my first shot at it (http://code.google.com/p/rgal/). Don't get used to the structure, though. I've changed most of how it works
-
That sounds good!!!
As for compiling, I haven't yet tried much with Ruby C extensions.
Since SketchUp on Linux runs in Wine (= Windows-like environment), wouldn't we need to compile it for Windows in any case? (Except that I have some plugins that bridge over and call faster native Linux tools.)
Did you just do it for use in Ruby, or specifically for SketchUp? -
Shame on you! . The rb_ prefix belongs to the Ruby Core !!
Choose your own prefix, like cgal_
-
@Aerilius Yes, I believe you do need to compile it under windows/mac. I think though that once someone has done that, the dll can then be used on other similar operating systems. The project I am working on doesn't interact with Sketchup directly. I have a Sketchup plugin that reads the Sketchup model and uploads it to a server. It is on the server that I have this library performing various geometric tasks. The result is then fed back into the Sketchup model. The library is indeed Sketchup independant. CGAL won't know what to do with a Sketchup::Point You'd have to do something like...
p = Sketchup::Point3d(1,2,3) CGAL::Point_3::build(p.to_a)
@Dan Those aren't the class names. Just a list of my cpp files that I copied and pasted. Rice takes care of creating the classes for me. I don't know what it does "under the hood" though.
-
@noelwarr said:
@Dan Those aren't the class names. Just a list of my cpp files that I copied and pasted. Rice takes care of creating the classes for me. I don't know what it does "under the hood" though.
Really? then I think you should edit your first post, as you clearly said:
@noel said:These are the classes I've wrapped so far.
However I was really referring to the C/C++-side function name prefixes.
Use your own prefixes, please not the ones the Ruby Core uses.
Or tell Rice to use "cgal_" as your function name prefixes.And I am glad to see the Ruby exposed methods are all wrapped in a
CGAL
module ! -
Compiled fine and works fine in irb!
Tomorrow I'll try if I can cross-compile it.Once you upload the latest version, can you update the requirements (saves a little research and time):
%(#000000)[sudo apt-get install **libcgal-dev libgmp-dev libmpfr-dev geom-view ruby-dev rubygems** sudo gem install **json rice**]
I had to modify dev.rb a little (json files were in additional quotes and evaled to string instead of hash): dev.rb
-
@dan rathbun said:
However I was really referring to the C/C++-side function name prefixes.
Use your own prefixes, please not the ones the Ruby Core uses.
Or tell Rice to use "cgal_" as your function name prefixes.If it's just the internal C functions then it would make no difference what their name are. It's only the publicly exposed functions that matter.
-
I guess the starting point on a mac is instal cgal + depenencies...
Homebrew to the rescuecgal version 3.8 for OS X
The formula for cgal was recently updated to version 3.8.To install cgal on your Mac, open your Terminal application and run the following commands;
brew update
brew install cgalThis package, cgal, depends on;
cmake
boost
gmp
mpfrjohn
-
Here is is. Bare in mind it is work in progress. I've been working on it for months and spend a good few hours on it everyday. If anyone wants to contribute please let me know as there are a number of things that should be made clear before you get stuck in. I've made a lame attempt at documenting it. If anyone is seriously interested in using this they are gonna have to plough their way through cpp code. While the're doing this they might as well add to the documentation. I'm using comments and rdoc to automatically generate the docs. Have a look at ruby/Aff_transformation_3.rb to see how it works.
As far as dependencies go: cgal, gmp, mpfr, boost, qt3 and rice are necessary (I no longer use geomview)
DISCLAIMER: There is another project http://code.google.com/p/cgal-bindings/ that is writing language agnostic wrappers for CGAL using SWIG. The geometry factory is actively involved in this project, but I have too say it's rate of growth leaves much to be desired. It makes more sense to go in that direction but I found SWIG too complex to use.
-
I've been toying around on AWS today and I realised something. One of the RGAL's dependencies is Qt3. The precompiled CGAL library in the Ubuntu repository is NOT compiled with Qt3. This means that you have to compile CGAL yourself which is always a hassle. I don't know about other platforms though. It's possible that mac's precompiled CGAL works a charm
If bootstrap fails at rb_Nef_polyhedron_3.cpp because it can't find qapplication.h, you have two options.
*Either comment out the show method in the cpp file (dont forget to comment out the rice refference to it at the bottom of the file) and the two lines (qapplication and Qt_widget) in the rb_Nef_polyhedron_3.h file
*Or get your act together and compile CGAL from scratch remembering to set the Qt3 flag to true.Ideally, it would be nice to have the Nef_polyhedron return a qt_widget object that ruby can then put in its own qt application. I have the feeling that that just isn't possible though.
Advertisement