Skip to content

Commit

Permalink
add another example w/ image and timing
Browse files Browse the repository at this point in the history
  • Loading branch information
moehriegitt committed Oct 30, 2018
1 parent 8e1cd1c commit d1bd8c8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
60 changes: 41 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Preparing a 3D model in CSG format (e.g., when using
[OpenSCAD](http://www.openscad.org/)) for
printing may take a long time and is often computationally instable.

So `hob3l` wants to replace a workflow 'apply 3D CSG, then slice, then print':
So Hob3l wants to replace a workflow 'apply 3D CSG, then slice, then print':
![3D CSG](img/csg1-old.png)

by a workflow 'slice, then apply 2D CSG, then print':
Expand Down Expand Up @@ -59,11 +59,11 @@ your CSG, then do use OpenSCAD's CGAL based rendering.

## SCAD Input Format

The `hob3l` tool reads a subset of the SCAD format used by OpenSCAD --
The Hob3l tool reads a subset of the SCAD format used by OpenSCAD --
I did not want to invent another format.

Please check [the SCAD format documentation](doc/scadformat.md) for a
definition of the subset of SCAD that is supported by `hob3l`.
definition of the subset of SCAD that is supported by Hob3l.

## Algorithmic Improvements

Expand Down Expand Up @@ -99,7 +99,7 @@ OTOH, the basic workflow is implemented and tested, i.e., the tool can
read the specified subset of SCAD (e.g. from OpenSCAD's CSG output),
it can slice the input object, it can apply the 2D boolean operations
(AKA polygon clipping), and it can triangulate the resulting
polgygons, and write STL. Slic3r can read the STL files `hob3l`
polgygons, and write STL. Slic3r can read the STL files Hob3l
produces.

Corner cases in the algorithms have been dealt with (except for
Expand All @@ -123,7 +123,7 @@ slic3r, you'll get hundreds of separate layer objects -- which is not
useful.

Memory management has leaks. I admit I don't care enough, because
`hob3l` basically starts, allocates, exits, i.e., it does not run for
Hob3l basically starts, allocates, exits, i.e., it does not run for
long, so the memory leaks do not build up. The goal is to have a
proper, fast pool based allocation. This is prepared, but incomplete.

Expand Down Expand Up @@ -269,7 +269,7 @@ For better package separation, the `install` target is split into

Unfortunately, there is no `install-doc` yet. FIXME.

The package name `hob3l` can be changed during installation using the
The package name Hob3l can be changed during installation using the
`package_name` variable, but this only changes the executable name and
the library name, but not the include subdirectory, because this would
not work as the name is explicitly used in the header files.
Expand All @@ -278,15 +278,15 @@ not work as the name is explicitly used in the header files.

In general, use `hob3l --help`.

To convert a normal scad file into the subset this `hob3l` can read,
To convert a normal scad file into the subset this Hob3l can read,
start by using OpenSCAD to convert to a flat 3D CSG structure with all
the syntactic sugar removed. This conversion is fast.

```
openscad thing.scad -o thing.csg
```

You can now use `hob3l` to slice this directly instead of applying
You can now use Hob3l to slice this directly instead of applying
3D CSG:

```
Expand All @@ -301,10 +301,10 @@ This can then be used in your favorite tool for computing print paths.

### Tweaking Command Line Settings

The underlying technique of `hob3l` is computationally difficult,
The underlying technique of Hob3l is computationally difficult,
because it relies on floating point operations. The goal was
stability, but it turned out to be really difficult to achieve, so
`hob3l` might still occasionally fail. If this happens, the following
Hob3l might still occasionally fail. If this happens, the following
command line options change internal settings that might push the tool
back on track:

Expand All @@ -326,15 +326,15 @@ let `eps2` be about the square of `eps`.

## Speed comparison

Depending on the complexity of the model, `hob3l` may be much faster
Depending on the complexity of the model, Hob3l may be much faster
than using OpenSCAD with CGAL rendering.

Some examples:

The x-carriage.scad part of my [Prusa](https://www.prusa3d.com/) i3
MK3 printer from the Prusa github repository: let's first convert it
to `.csg`. This conversion is quickly done with OpenSCAD, and the
resulting flat SCAD format is what `hob3l` can read:
resulting flat SCAD format is what Hob3l can read:

```
time openscad x-carriage.scad -o x-carriage.csg
Expand All @@ -348,7 +348,7 @@ To convert to STL using openscad 3D CSG takes a while:
0m45.208s
```

Doing the same with `hob3l` in 0.2mm layers is about 50 times faster:
Doing the same with Hob3l in 0.2mm layers is about 50 times faster:

```
time hob3l x-carriage.csg -o x-carriage.stl
Expand All @@ -357,7 +357,7 @@ Doing the same with `hob3l` in 0.2mm layers is about 50 times faster:

The most complex part of the i3 MK3 printer, the `extruder-body.scad`,
before it was reimplemented as `step` file, takes 2m42s in openscad to
convert to STL, while `hob3l` takes 1.24s, again with 0.2mm layers.
convert to STL, while Hob3l takes 1.24s, again with 0.2mm layers.
That is 130 times faster.

For one of my own parts `useless-box+body`, which is less complex, but
Expand All @@ -376,14 +376,36 @@ This is 85 times faster. Over half of the time is spent on writing
the STL file, which is 23MB -- STL is huge. Loading and converting
only takes 0.23s.

If you push it, the differences are even more pronounced: the test31b.scad
example uses `$fn=99` for a few ellipsoids, causing openscad to slow down:

```
time openscad scad-test/test31b.scad -o test31b.stl
4m16.270s
```

In contrast, the different algorithms used by Hob3l do not slow down
much:

```
time ./hob3l.exe scad-test/test31b.scad -o test31b.stl
0m1.011s
```

This is 250 times faster. The difference is of course that with
Hob3l, the result is sliced into layers, as the following image
demonstrates.

![Hob3l output](img/test31b.jpg)

## Supported Output Formats

`STL`: The output format of `hob3l` for which it was first developed, is
`STL`: The output format of Hob3l for which it was first developed, is
STL. This way, the input SCAD files can be converted and directly
used in the slicer for 3D printing.

`PS`: For debugging and documentation, including algorithm
visualisation, `hob3l` can output in PostScript. This is how the
visualisation, Hob3l can output in PostScript. This is how the
overview images on this page where generated: by using single-page PS
output, converted to `PNG` using `GraphicsMagick`. For debugging,
mainly multi-page debug PS output was used, which allows easy browsing
Expand All @@ -395,8 +417,8 @@ of command line options to customise the output.
`JS/WEBGL`: For prototyping SCAD files, a web browser can be used as a
3D model viewer by using the JavaScript/WebGL output format. The SCAD
file can be edited in your favourite editor, then for visualisation,
`hob3l` can generate WebGL data (possibly with an intermediate step to
let `OpenSCAD` simplify the input file using its .csg output), and a
Hob3l can generate WebGL data (possibly with an intermediate step to
let OpenSCAD simplify the input file using its .csg output), and a
reload in the web browser will show the new model. This package
contains auxiliary files to make it immediately usable, e.g. the
surrounding .html file with the WebGL viewer that loads the generated
Expand Down Expand Up @@ -452,6 +474,6 @@ different -- but the result is really the same):

## Name

The name `hob3l` derives from the German word 'Hobel', which is a
The name Hob3l derives from the German word 'Hobel', which is a
'planer' (as in 'wood planer') in English. The 'e' was turned to `3`
in recognition of the `slic3r' program.
Binary file added img/test31b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/test31b.xcf
Binary file not shown.

0 comments on commit d1bd8c8

Please sign in to comment.