A question to the community .

A question to the community. I am developing a C++ library to model 3D things, maybe some of you already know it. It is called OOML (Object Oriented Mechanics Library). http://iearobotics.com/oomlwiki/doku.php

Up to now the OOML generated OpenSCAD code for rendering and STL generation. I would like to make the OOML renders and generates STL by itself.

Questions:

  1. Which c++ libraries are available for generating STL beginning from semantic 3D models?
  2. Apart from OpenGL, what would you use for rendering?

Thanks!!

What’s the motivation for moving to your own STL and rendering code? User experience? rendering speed? issues with the current output?

Is it possible to turn some of the OpenSCAD code into a library for doing this sort of thing (I haven’t had a chance to take a look at the source yet).

@Steve_Lynch reusing OpenSCAD code would be great … the final goal is that I do not want to output OpenSCAD code but render and generate directly, the the more code I can reuse the better.

for rendering, take a look at VTK
http://vtk.org/
or maybe openinventor / coin3d
https://bitbucket.org/Coin3D/coin/wiki/Home

The one which is popular with CAD efforts is OpenCascade, but beware of its special (not GPL compatible) license!

OpenSCAD uses OpenCSG. http://www.opencsg.org/ from their site. OpenCSG is a library that does image-based CSG rendering using OpenGL.

Always OpenGL for rendering. There’s really only 1 other option, and that’s DirectX - and many of us will not use Windows. Do it in Direct X, and watch your project be abandoned.

And OpenCSG is an already very nice library for this kind of thing; what advantages does OOML have over OpenCSG?

I do not know OpenCSG, but it seems a good choice. @ThantiK , OOML is a modelling library for physical things. That is, is thought for fabrication… it is the same than OpenSCAD or CoffeeScad but using C++ and Object Oriented Programming.

@ThantiK , yes of course OpenGL, the question is if there is anybody knowing a library on top of OpenGL that already deals with intersections, unions, etc. for rendering.

Will this library have a C interface? If so, most any language can use it – if C++ interface only, then only C++, and since C++ doesn’t have a binary api… I think composition of functions is the primary desirable language feature for CSG modeling, object oriented stuff, not so much. Closures would be nice too, so I could have a way to write a function like:

distribute_something_around_a_circle(something, 10);

to for example, evenly distribute 10 of “something” around a circle without regard to what “something” was or how many parameters it might take.

In any case, I did a really hacky C/openscad library here just as some “recreational computer programming”:
http://smcameron.github.com/opencscad/ Yours will no doubt be superior since you plan to get away from outputting openSCAD code.

In my little openSCAD C library, I considered implementing a form of “closures” by simply redirecting the openscad code into a temporary buffer, to be replayed by whatever needed the “closure”, so I could do something like this:

buffer = closure(make_some_complicated_object(whatever, params)); /* closure() just dumps the openscad code into a buffer which it returns. */

distribute_closure_around_circle(buffer, 10);

and distribute_closure_around_circle could be written without knowledge of what it was distributing, since what it would be distributing is just a text buffer containing arbitrary openscad code.

I never really tried that out to see if it would work though.

Thanks @Stephen_Cameron , those are great hints. OOML is already C++, and in fact, that was the goal, making in Object Oriented.

As for the enclosure, if I have understood well that could already be done using the Links and Attach or MoveToLink functions, which moves whatever Component to the defined Links of another Component. This is not yet documented on the wiki. TODO for this week-end :slight_smile:

something like:

Componet mySphere = Sphere(30);
for(int i=0;i<360;i++)
mySphere.addLink(RefSys(30,0,0).rotate(0,0,i))
for(int i=0;i<360;i++)
mySphere.attach(i,Cube(2,2,2)); //attach a cube to Link i of mySphere

I have written the code as I “remember” it might not work, but that’s the idea.

@Alberto_Valero_Gomez , you’re basically recreating OpenCSG. OpenCSG is already an object oriented library for this stuff, except much further developed.

@ThantiK as far as I can read OpenCSG is for rendering, in fact it has many rendering functions, textures, etc. OOML is for modeling mechanichal things, it has joints, links, etc… I think they are quite related, but OpenCSG seems to me closer to OpenGL than to OOML (to the best of my knowledge)

OpenCSG isn’t really for rendering so much as solid geometry manipulation. It’s what provides things like union, difference, translate, etc found in OpenSCAD; openscad is basically just an easier scripting language wrapped around it. You said:

“the final goal is that I do not want to output OpenSCAD code but render and generate directly” and “it is the same than OpenSCAD or CoffeeScad but using C++ and Object Oriented Programming.” and " the question is if there is anybody knowing a library on top of OpenGL that already deals with intersections, unions, etc. for rendering."

That’s exactly what OpenCSG does. It generates the 3D models based on an OO hierarchy and is written in C++…

mmm… good hint. Can it generate STL ? I have not seen anything developed in Thingiverse using OpenCSG.

@Alberto_Valero_Gomez check out the cgal library too. The two are commonly paired together.