Category Archives: Slicer

Preform not (yet) fully compatible with JewelCAD

The challenge

I’ve done some test prints for someone in the jewel industry. They wanted to see the Form1 quality output to maybe use it as a quick prototyping desktop station and get faster development cycles. We discovered that in some conditions JewelCAD is only capable of exporting to STL the positive geometries OR the negative geometries (holes / notch) but not the fused triangle mesh.

The only way to merge both negative and positive geometry is apparently to slice the object and export it as SLC file. This file format was created in 1994 by 3D systems and is now at the second revision. The evolution was mainly to store the data as binary to save space but the content of the file was not changed much.

Preform is unfortunately not capable of reading SLC files nor importing positive and negative bodies to form a finite model. That’s another instance where it would be handy to have the Printer protocol open or at least an API to build our own slicer for the Form1.

Workaround proposals

I can see two ways to solve this challenge:

  1. Use a 3D modeling software to apply the boolean operation
  2. Re-constuct the STL triangle mesh from the SLC slices data

The first option can be done using the free software Blender (see this video tutorial for example). Boolean operations on complex triangles mesh are some time not possible to apply. It’s especially true if the original geometries are not completely clean (holes / inverted triangles…). In the case of my test print, Blender and Netfabb were not able to apply the subtraction.

The picture under is showing that even in a very simple case, subtracting a sphere from a cube in Blender creates a lot of extra triangles. The whole difficulty is to generate precisely the cut/intersection line as explained in this paper by Biermann and Al.

simpleBoolExample

So if the Boolean operation is not possible, we can only regenerate the STL triangles from the SLC data. Provided the original geometry slice thickness was at least the desired print configuration, it should not affect the output quality. Commercial software like SLC2STL or Netfabb seems to be able to perform the conversion but the licenses are expensive for a casual usage (in the $k range).

As the triangle geometry is an interesting algorithm development, I have no option but add it to my TODO list! The first step of this un-slicer is of course to read the SLC data.

Matlab SLC file reader

The SLC format is a simple collection of slices composed of a collection of boundaries. You can read the format specification [here]. Each boundary is a closed polygon (poly-line) defined by a series of [X,Y] vertices with the first point duplicated at the end to close the loop.

I’ve built an viewer in Matlab to explore the content of SLC v2 files. The archive contains 2 example ring slices SLC file. After extracting all the information, the viewer displays a 2 plot window were the user can click on any point in the 3D plot on the right to display the full slice on the left pane.

SLC_view_Ring1

SLC_view_Ring2

The second picture is showing that external (blue) and internal (red) boundaries are drawn in 2 colors. In the SLC format, internal boundaries are stored clockwise while external boundaries are anti-clockwise. Detect reliably the orientation of a poly-line curve is tricky as it must work for concave polygon. The easiest method is to find one point of the convex hull and use a determinant to get the local convexity…

convexPolygonOrientation

concavePolygonOrientation

What’s next?

So while we could dream to have Preform reading the slice directly, it’s probably easier to get one of these software to convert the SLC to STL. This operation is definitely not obvious with many steps to get it working is all circumstances so I probably won’t tackle it anytime soon…

[<<Prev. – Episode 2 : Form1 calibration]    [3D Printer articles]   [Precision VS Accuracy – Next>>]

3D printing: your friend the Slicer

Modeling your shape is only the first step of 3D printing. You need to process the resulting mesh with a slicer program that will cut your solid into thin slice and decide how to print them. The output of a slicer program is a G-code file that contain the instructions to move the printer and extrude the filament. They are multiple slicers programs available but I will only mention three that were evaluated by Reprap magazine (in no particular order):

  • Cura and Slic3r are very effective open source packages
  • KISSlicer is a commercial product, but the free version let you print single object with most of the options available.

As you can discover in the Reprap magazine, there is no one solution to the slicing problem. It’s an optimization task and each program is solving the paths differently. Each of these package offers different options to reduce problems like strings / seams on the edges and increase overall printing quality.

slicerJob

In the previous picture you can see how KISSlicer is splitting this “gear”. The path colors on the right represent the type of extrusion the printer will do. Like you want to have a lower speed and more precision for the output shell, but for the inner shells, the printer can go faster.

As I was looking at the subject I found these vase pictures from 3DPrinterGear user on KISSlicer forum where you can see that depending on the printing mode, you can end-up with a very visible seam on one side, or more like a “chicken-pox” effect  when the slicer starts each profile at a different point each time.

seamOnVase

The ‘obvious’ solution was to extrude the plastic in one path, think of it as a spiral and avoid completely the issue. I found later that Cura slicer has an option called “Joris mode” to exactly do that for single wall objects. That seems like an interesting challenge to take and see how hard it would be to build a slicer and generate some G-code to print a continuous extrusion profile. As this is only considering the outer shell profiles it’s a nice subset to experiment and develop algorithm for. So let’s dig in the slicer, algorithm!

Note: all the graph on this post are generated using Matlab. The code is available at the end of the post. The gear shape is coming from this thing on Thingiverse made by Emmett.

Slicer Step 1: Find Intersecting triangles

The first step once the tessellation is read is to find for each Z plan the section of the geometry.

gearSlice

The geometry of a STL file is a tessellation of triangles in space. So the brute force method to do it is to test if each triangle is intersecting the current plan. This is obviously not optimal and we have to weed out most of the candidates otherwise we’ll spend ages processing the file.

Let’s simplify the problem and display it in 2 dimensions (only X and Z), now for each triangle we can find the lower Z vertex and the higher Z vertex. Example in triangle A the lower is at Z=2 and the higher Z=13. Then we have to sort all the minimum and the maximum in 2 lists of increasing Z values.2dSlice

Now we can have a tool to figure out which triangles are in any Z plans in 2 steps by doing:

</code>
for currentZ = 0:N
    1/ Add any triangle from the bottom list
       with bottomZ value smaller or equal than currentZ
    2/ Remove any triangle from the top list
       with topZ value smaller than currentZ
<code> 

So for example if the plan you want to test is Z = 8.5 you will have:

  1. Add in list triangles : [C A D B]
  2. Remove from list triangle C

=> the answer is only triangle [A D B] have to be tested for the section.

For a real implementation you would keep the list from one Z plane to the next and the location in the list were your stopped the search because triangle that are already under will never be used again. Also to keep the R/W low it’s probably more efficient to use a linked list in C.

Slicer Step 2 : projection of Intersecting triangle on current plan

For each of the intersecting triangle we have to check how many vertex are already in the plan as no extra computation are required in this case.

vertexInPlan

For every remaining segment of the triangle with vertex on both side, the “segment to plan” intersection is easy to compute:

segmentProjection

And here are example of the result for the gear section. The left picture is the bottom plan of the object so all the faces are in the plan and displayed as triangles of various colors. The right picture is a plane over were all the intersecting faces are represented as segment.

sliceResult

That’s all for today, the graph are generated using this Matlab package, and all code are copyrighted, only usable for non-commercial purpose and provided as is with no guaranty of any sort! The package includes a Matlab STL reader that can open TXT and binary files.

[<<Prev. – STL Matlab Writer]    [3D Printer articles]   [TBD – Next>>]