• Prusa Mendel Visual Instructions
  • RepRap Developer Bookshelf
  • Wade’s Geared Extruder Visual Instructions

Thoughts on Fill Algorithms

Whenever I’m watching a print (because it can be hypnotising after all) I usually become acutely aware of any superfluous aspects of the design and how inefficient the fill patterns can sometimes be.  The fact that the model is sliced into layers leads quite naturally to filling each of these layers with a 2D pattern. The line and grid patterns from Skeinforge produce stable, solid objects from as little as 30% infill, and for the most part this is sufficient. I wonder though if we can find a better filling strategy? One that utilises the 3D nature of the model.

If the fill is to provide internal strength to an object and support any internal overhangs (ceilings), but also use minimal material, then I guess the ideal algorithm would analyze the model and identify where best to position struts, columns, butresses and such.  Taking into account the printers ability to bridge gaps and so on.

spacer

Mockup of model with "ideal" fill of struts, etc.

Even if such an intelligent algorithm is possible it would no doubt be so computationally intensive as to break another constraint we should define: that the fill pattern should be determined in a reasonable amount of time.

This is why the line algorithm works very well – it fits almost any organic or non-organic form, and can be computed relatively quickly. This is also demonstrated by the alternative fill patterns that Alessandro Ranellucci has implemented in Slic3r: hilbertcurve, archimedeanchords and the octagramspiral patterns are marked as “slow” and indeed can take a long time to generate for non-trivial models.

spacer

X-end-motor.gcode, Slic3r, Line Algorithm, @32s

spacer

X-end-motor.gcode, Slic3r, Hilbertcurve Algorithm, @7m 20s

As a sidenote, this highlights another observation I have made: that the current delineation between 3D model (usually STL format) and Gcode seems skewed, and some information that should belong in the model (e.g. fill structure) is delegated to the runtime process. I’ll hopefully expand on this in another post, but it’s worth mentioning here because perhaps our view of what a reasonable computation time is, would change if it is moved back along the workflow to model generation.

So the question: Is there a fill pattern, that provides the same strength and can be computed in the same order of magnitude as the line approach, but which uses less material?

Some Ideas

Some initial thoughts involve ways of packing other, simpler, 3D forms within the model, which leads to such things as the sphere packing problem.  In this case we would ideally find a solution that has a dense, irregular packing of unequal spheres, where each sphere is the largest possible size for the containing form. Here is where my woeful lack of mathematics causes a real problem. I suspect, but can’t be sure, that there is no way of determining such an ideal packing arrangement within the timescale constraints we have set (i.e. minutes, if not quicker).

This also highlights another aspect of the problem: the 3D model we are attempting to fill can be any arbitrary form. If the target model was always a cube, or even always a regular solid, we could potentially pull some tricks (lookup precalculated values perhaps?) in order to use a sphere packing approach. With the prospect of packing non-regular, and potentially very organic, models the problem becomes ever more difficult!

 

spacer

Sphere-Packed Model Example

spacer

Sphere-Packed Model, Slice Through

 

Another avenue of investigation is whether an arbitrary model can be divided into simpler shapes?  The assumption being that working on several simple solids would be easier and quicker than working on a simple complex shape.

Another idea involves using the vertices of the target model as a basis for generating internal edges, perhaps utilising Delaunay triangulation or something similar, but in three dimensions. This would have the benefit of being tailored for each model, but would it guarantee structural strength? How would such an algorithm work in three dimensions?

spacer

Mockup of slice with example triangulation between nearest vertices

spacer

Mockup of slice with example Delaunay triangulation (but not actually correct, only to give an indication)

Then something dawned on me: do we have to constrain the fill pattern to the boundaries of the target model? What if we had a pre-defined 3D fill pattern, say a honeycomb, which we intersect with the model to produce the fill pattern?

The pattern could potentially derive from a 3D Tessellation.

spacer

3D tessellation with truncated octahedron (via Wikipedia)

Further browsing online leads to Hyperbolic Planar Tesselations. I have no idea whether something like this could be utilised, but the fractal nature of how the pattern interacts with the boundary could yield ideas for resolving how to give strength to irregular, organic shapes.

spacer

Hyperbolic Planar Tesselations (via www.plunk.org/~hatch/HyperbolicTesselations)

 

Mock Print

In order to get a feel for the problem I decided to mock up such a pattern to print. This led to an interesting realisation, that the various tools available will each work with this solution to varying extents. I played with OpenSCAD, Google Sketchup, Skeinforge and Slic3r whilst trying to manually generate an example structure. I found that concept of internal structure in these tools is rather foreign, and I had to hack a bit to get some results. Most 3D modelling tools I have tried concern themselves with solids, the skin of the model, and not the skeleton. Perhaps there exist CAD programs geared towards engineering which use a skeleton + skin paradigm? Perhaps this is also worth investigating further?

In the end I used OpenSCAD to generate a cube filled with a set of sphere-spaces, and used Skeinforge to slice two models, one with zero infill and one with 30% infill.

It is worth mentioning that I attempted creating a similar structure in Sketchup, but using a real model (Mendel X Motor Mount) and a lattice of spheres (as shown a few paragraphs earlier).  Attempting to intersect the spheres with the model caused Sketchup to hang (or rather take an unacceptable amount of time to respond). This perhaps hints at the potential performance problems such a solution may have?

The printed model shows that, for a very basic target shape, the packed sphere approach yields a reasonably rigid object. It is certainly not comparable to a cube filled with 30% line pattern infill, but printing the mock gave me confidence that it is at least worth continuing to research such techniques.

Where Next?

The goal of writing this post was to collect some thoughts on the subject which I could refer people to for discussion.  It would be cool if someone more mathematically-minded could comment on the feasibility of such 3D space filling algorithms. Or if others have had similar ideas on the subject at all!

To summarise:

  1.  I think it is worthwhile looking for more efficient fill patterns that take advantage of the 3D nature of the model it is filling.
  2. The main obstacles are computational intensity and ensuring the resulting model has sufficient strength, regardless of its form.
  3. It is worth reviewing whether current 3D modelling tools are suitable for defining such things as internal structure.  There is potentially an opportunity to develop something interesting here.

I’m going to try and find time to play further and try and throw together perhaps a script to preprocess a model, or perhaps implement a fill algorithm directly.  I will also look a bit more at existing tools to see if there is already something out there which allows the definition of internal support structures.

Any feedback would be very welcome!

Posted on January 3, 2012 by Gary Hodgson. This entry was posted in 3D Modelling. Bookmark the permalink.

22 Comments

  • spacer
    Dale Dunn
    January 3, 2012 - 9:10 pm | Permalink

    An interesting post. I definitely like the idea of a fill pattern that uses less material and by implication takes less time to build. To some extent, users have been addressing this issue by designing structural parts with thin walls rather than simple block shapes. Example

    For a show part like Yoda’s head, the volume to be filled can be reduced by creating a spherical void approximately at the centroid of the model, but that all needs to be done by hand.

    CAD modeling systems don’t really deal with whatever the interior of a solid is. The faces are simply a boundary between “inside” and “outside”. However, FEA analysis of a solid model involves creating a volumetric mesh similar to the 3D tessellation you mentioned. Algorithms exist for generating meshes of different elements such as cubes of various proportions (generally called “bricks”), tetrahedrons (“tets”), octahedrons, and maybe more. Vertices of each element are called nodes, and they may be useful too.

    There are interactive tools used to increase or decrease the mesh density in areas where this is useful to the simulation. (There are algorithmic methods for determining where mesh density should vary from default, but I think they’re all dependent on iterations of the FEA solution. Anyhow, it would be useless to us because the density of FEA meshes does not correspond to where we would want mesh density to change.) There are even some meshers that can use elements of different shapes. Surely there is literature available describing at least the less sophisticated forms of these meshers. I know there must be at least one open source mesher, though I don’t know its name. I’m sure it’s documented somewhere at caelinux.com.

    I said all that to say this: The elements of a mesh could determine walls of infill (or support structure), or the interior nodes (nodes not not on a model face) of a tetrahedral mesh could define the centers of spherical voids in the fill. Perhaps some fill elements based on existing FEA mesher elements could be developed to reduce warping as well as reducing the amount of fill.

    Perhaps it would even be possible to have the mesher automatically decrease mesh density as some function of distance from the model’s faces. This would give strong faces with very little fill of the deep interior.

    Reply
    • spacer
      Gary Hodgson
      January 3, 2012 - 10:06 pm | Permalink

      Hi Dale, thanks for the comment! I would never have come across Finite Element Analysis otherwise. From what you describe, and what I can glean from Wikipedia, it sounds like it’s worth investigating. As you say, the algorithms used could have an application here – another avenue to explore. The comment about a varying mesher density in relation to the walls coud perhaps produce a pattern similar to the Hyperbolic Planar Tesselation shown above.

      What you say about people designing hollow models is spot on. I love the idea behind the Hollow Mini-Mendel for example. As I was pondering alternatives I kept coming back how useful it would be to manually define internal supports to existing model files, i.e. opening an STL file in an editor and saying “ok, a strut should go here, and a joist here”, etc. I guess it can be seen as a design technique to create a model which uses the minimum material (I know I always try and cut off unecessary corners and such), but it would be nice to be able to create the (solid) model, and then go into it afterwards adding supports etc. I really think the original designer should at least have the ability to say how the model should be supported, with the next best thing an intelligent algorithm of some sort.

      Lots to read and lots to play with!

      Reply
    • spacer
      Thomix
      January 4, 2012 - 8:43 pm | Permalink

      I imagine this would work great with topology optimization software: the way of working I saw was to load an object, mesh it finely and define areas that will bear loads, need a certain thickness or stiffnesses for instance. The software then takes your meshed object and deletes any element that does not contribute to the boundary conditions enough.
      I assume this way you can eliminate elements (ie, increase the percentage of infill) without compromising the function of the part.
      The only topology optimization software I am aware of is part of HyperX which is commercial (and very expensive) but I can imagine the algorithm isn’t that complicated.

      Reply
  • spacer
    RichRap
    January 3, 2012 - 9:59 pm | Permalink

    Great blog post and really nice ideas Gary.

    It would be really interesting to test build Speed v Strength of fill and level of infill,I really like the idea of using the vertices of the target model for generating internal edges, this should be fast to print and give strength to the model.

    One thing I have always wanted to try is to print a model hollow for say 3-4mm high then place the extruder at regular points in the hollow voids and just purge a set amount of plastic into the void, move the extruder on a regular distance and maybe on a slight regular angle and then purge again, with some experimentation you could get to a level where the purged points just join together and also against the walls of the hollow object,then print a loose mesh over it and build another hollow section, repeat with the same all the way up the object.
    It should be fast as you can purge quickly with most hot-ends and strong if the balls are placed well, but may use slightly more plastic?

    I did consider making some manual gcode to test the idea of a ‘blob-filled-object’ but have not tried yet.

    If you also had two extruders, you could also have one with a bigger nozzle and low grade plastic for the blob-infill and fine quality plastic on the other for the hollow outline.

    Reply
    • spacer
      Gary Hodgson
      January 3, 2012 - 10:23 pm | Permalink

      Hi Rich, The purge idea would be really interesting to try, and could open up new ways of filling. I’ll look forward to reading your writeup if you get around to trying it out! I can imagine solid columns rising within the model, or an algorithm choosing to purge-fill a thin part of the model (e.g. the motor wall in the examples above).

      One further consideration I had, about making the internal walls faster to print, is that they could be curved to maximise acceleration. (This is probably the reason I used spheres in my example rather than octohedrons I guess.) I can imagine a series of continuous loops flowing within the model making up the support. One of the challenges I can foresee is how to efficiently connect the support vertices to maximise nozzle speed and reduce retractions and changes in direction. Yet another maths problem! spacer

      Reply
  • spacer
    Regulus
    January 3, 2012 - 10:36 pm | Permalink

    This reminds me of the Rhombic Dodecahedron Infill by Griffin_Nicoll, a similar idea and the same implementation in OpenSCAD to generate a “preview” of what the model might be like, filled in.
    I printed a few of those tests, and they were really strong!
    I really like your speculation on the tessellation, essentially making the space-filling pattern become a fractal as it gets closer to the edges of the object it fills.

    You could generate that by overlapping the pattern with the object, finding locations where the pattern intersects the walls, and subdividing them, then repeat. Large gaps will be filled with whatever size you start with, small or irregular spaces with a sponge of mixed-size shapes down to whatever you specify as maximum resolution.

    However, you also have to specify a minimum thickness on the walls, or you will get internal shapes coming up flush with the outer mesh, creating a very thin (but not intersecting) wall, useless as a structural element.

    Reply
    • spacer
      Gary Hodgson
      January 4, 2012 - 10:01 pm | Permalink

      Hi Regulus, Sorry your comment took a while to appear – it went to my spam folder because the link was somehow malformed.

      I was searching ages for this link! I knew I had seen something very similar before but my web searches came up empty – I had thought it was a blog post about Skeinforge, and so I got the keywords wrong. In fact it seems I was the first to “like” this Thing! spacer

      Looking at it again it’s obvious that this is the thing that got me thinking about the whole subject in the first place. It must have really stuck in my subconscious because the model I printed is so similar to this one!

      I like your idea of breaking down the model into banded zones in order to vary the fill density – I’ll certainly keep it in mind when trying to put together the algorithm!

      Reply
    • spacer
      Andy Jackson
      February 7, 2012 - 1:11 am | Permalink

      If the goal is a fractal, just have your outer shell shrunk and supports (at some frequency) from an outer-shell point to it’s shrunk point. Then repeat this to the middle. For circles it’s great, but irregular shapes would need to redefine the “shrunk” object to not be a simple scale, but a deflation perpendicular to the outer wall so that a shrunk “3d long rectangle” would be a skinnier rectangle and not a scaled-smaller one with diagonal braces.

      Although this would only help crush-strength, not shear strength, it could make an easy basis to then make touching-oval or cross bracing between the layer & it’s shrunk form that will always perfectly fit.

      Reply
  • spacer
    Martin Price
    January 4, 2012 - 4:42 pm | Permalink

    Gary

    Great blog very interesting. I posted on reprap forums, but another thought occured to me. You might have a look at producing the internal structures by raster scanning the head back and forth rather than producing the internal structure by complex paths. It would be a case of just switching the extruder off and on, or using a simple valved nozzle (I think Adrian Bowyer did some work on this) . It would open up the possibility of multiple nozzle heads etc. Doing it this way might throw up some alternative fill patterns you havent yet considered.

    By the way if you are struggling with your CAD and need a few test cubes knocked up drop me an email. I have Catia V5 here so should be able to do a few fill patterns quite easily for you to save some time.

    Reply
    • spacer
      Gary Hodgson
      January 4, 2012 - 7:08 pm | Permalink

      Thanks Martin, when I make some progress I’ll get in touch.

      I believe this is the valve nozzle that Adrian built that you refer to. Your idea hints at InkJet-type technology, but at a slightly larger scale and more mechanically oriented of course. As you describe , if one had a reservoir of molten material, under pressure, behind a set of “doors” (valve nozzles) would it be possible to squirt the plastic under controlled circumstances I wonder?

      Interesting options!

      Reply
  • gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.