Wednesday, October 19, 2011

 

Say goodbye to unsightly STL triangle misery! Forever!


I downloaded Rupert Rawnsley's OpenSCAD Horizontal Spool Holder from Thingiverse and  printed it on one of my Prusa Mendels.  Nothing unusual about that.

Except that at no point in the making-chain from Thingiverse to the finished printed object was an STL file used to do the calculations.  The spool holder was printed directly from OpenSCAD's CSG representation.

Printing directly from CSG is much more robust than using the flakey (literally) STL file format.  A CSG file can be wrong - we can all make mistakes - but, unlike STL, it always represents an unambiguous solid.

It should also be faster.  I'll do some timings and post them later.  Finally, it should allow us easily to do fancy things like filling solids with scalar and vector fields representing build parameters, so you can have an object that is flexible (and/or green) at one end and rigid (and/or blue) at the other.

I built a simple CSG modeller into the RepRap Java Host Software.  I added a parser that directly reads the CSG generated by OpenSCAD into it.  (The software still uses the STL too, but just as a bunch of triangles for display on the screen; STL takes no part in the build process.)  At the moment the supported OpenSCAD primitives are cubes, cylinders (including frustums and cones), and spheres. I will add extruded polygons, extruded imported DXFs, polyhedra, and imported STL files later (in that order, which is also the order of difficulty of doing them...). Note that the final one of those will implicitly (there's a mathematical joke there somewhere) allow any STL file to be converted to CSG.

Just like the CSG processor at the heart of OpenSCAD, the software is essentially a re-implementation of my old friend John Woodwark's DORA CSG modeller (Divided Object Ray-tracing Algorithm) from the early 1980s (see here).

For instructions on how to use all this, follow this link...

Stop Press: 

Marius has just upgraded OpenSCAD to make things even easier.  The OpenSCAD Github master now has:

$ openscad examples/example001.scad -o out.csg

..or Design->Export as CSG


Comments:
If only OpenSCAD would *export* it's CSG-solid into *any* of the common file formats used for this.
 
Well. The parser for the "Display CSG" thing that OpenSCAD does do is very simple. Point me to a format, and I might see if I can write it, then read it.
 
Great! And did the output printed object look any better? especially the outer radius?
 
Adrian - the IGES documentation, one of the two most commonly used CAD exchange formats (STEP/IGES), can be found at http://ts.nist.gov/standards/iges/

Best!
 
Marcus: Do you have any concrete suggestions for common file formats used for CSG representation? It would be interesting to add to the list of things to look into.
 
Yes - I know about IGES and STEP; but I have never found an example of their being used for direct CSG representation (as opposed to doing CSG combinations of a load of B-Rep nonsense). They should have it in there somewhere, though. If you can point me to a STEP file (preferably) that shows a complete CSG representation of something simple (say a cylinder subtracted from a cuboid), I'd be most grateful...
 
@RichRap - in this case the output was identical, because in this case the OpenSCAD STL file was solid. But the amount of code being executed to do the work is - I estimate - about 30% of the complexity, and with far fewer infelicitous approximations and heuristics.
 
Timings - it's only about 5% faster. I had expected more, but there you go...
 
Excellent! Saw this in the checkin comments the other day - glad to see it out!
 
Svlis man. Use svlis.

Direct slicing baby!
 
would someone be so kind to explain to me how to Design->Export as CSG when the version on Openscad that I have has not option for exporting a csg file. I'm a newbie at this 3D software, I apologize if this is a stupid question.
 
The version I downloaded was openscad-2011.06.win32-installer.exe
for windows, as I found downloading and installing the other programs a bit confusing.
 
This comment has been removed by the author.
 
Wow - I find the idea of running an STL through the final process meassively appealing. That's a really significant branch of processing - akin to NURBS and car show rooms perhaps?
 
First, there's a nice replacement for good old STL already standardized and it's called AMF (http://amff.wikispaces.com/). Secondly, the intended inclusion of "imported STL" in CSG format will not solve the problem of "unsightly triangle misery" unless a sophisticated reverse engineering procedure will be able to convert STL surfaces into solids defined in CSG or B-rep.
 
Adrian I am not sure if any of these help with STEP files and CSG representation but see

http://www.cmiss.org/cmgui/wiki/sphtorrectcylstep/view

Also
http://wheger.tripod.com/step/
 
Er, above link is incorrect. It should be: http://amf.wikispaces.com/
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to
Posts [Atom]