3D printing a working Rubik’s cube

Starting from principles…

Soon after getting a 3D printer capable of doing quality ABS plastic, I wondered if I could print a Rubik’s cube that would come out of the printer already assembled and working. I was able to do it, and made several cubes.
Here is how I attacked it in Mathematica:

Of course, you might have taken apart different cubes, and seen the generic solution, but I wanted to visualize what the constrains where. Here is a graphic that shows that everyface needs to be able to rotate:

for a face to be able to rotate, it needs to be held by a surface which has rotational symmetry. if you need to be able to do it for each orthogonal axis, it is probably a sphere…

Building the core piece

As you probably know, if you have ever tried to build some 3D model, it is crucial to build a water tight model.
So as you but surfaces together, they need to be built from the same vertices, so that they are properly sawn together…

Below is just made of 2 cylinders. Notice the outside of polygons is blue, the inside is red.

Then with just rotations, we get the 6 pieces assembled together.

Each of the cylinder is captured in a cavity in the piece in the middle of each face. The cavity is just a little bigger than the head of the piece above. It looks like this:

If we simply add the edges of that piece, which come from a sphere, and planar surfaces…

Here is a section to show the details:

The center piece, with one center face in position

Now we are building the edge pieces. I was getting lost in the code, so I did a visualization with colors so I could find myself again…

And here is the edge piece complete

The corner piece is built the same way, and you see below a corner piece and an edge piece together, separated by a parametric gap.

here are the 8 corner pieces shown together in the proper relative positions

The center piece with all the center face pieces

And finally the whole cube together. I can then just export as STL and print on a 3D printer. I used a stratasys printer with 2 components: the ABS, and the support was in sugar, which is removed by dipping the piece in acid for a few hours. Then it rotates fine, although it remains fragile.

Other ideas on doing this:
I would like to rebuild this using computational geometry since all the surfaces come from 2 spheres, 3 cylinders, a cube, and 3×4 separation planes.
I also wanted to build a metal version of this, which would require flow channels that could be cut after the piece is finished.