Tuesday, September 3, 2013

Voronoi-tesselated Klein Bottle

OK, I admit I've caught the bug of messing around with Math objects and making pretty printable objects from them.

This is my take on the Klein Bottle, inspired in large part by Dizingof's perforated bottle. Mine, however, uses the Voronoi tesselation to perforate the bottle. The various files are available on Thingiverse if you'd like to mess with it.


It was made by using ViaCad and MeshLab, as follows:

* In Viacad, I created 3 surfaces: the bottle body, the neck, and a patch that covers the intersection of the bottle and the neck. The bottle and neck were exported as very fine meshes, the patch as a regular resolution mesh.

* In MeshLab, I imported the bottle and the patch.

* Filters > Color... > Disk Vertex Coloring to color the Bottle using the points in the patch, adjusting the parameter until the patch was fully colored.

* Render > Color > None and then Filters > Selection > Select Faces by Color. Select RGB mode, set the sliders all to 1, turn on Preview, and then tune down the R value until you get everything selected but the patch area.

* Filters > Selection > Invert Selection, then Filters > Selection > Delete Selected Faces and Vertices to make the hole. It will be a bit bigger than the patch, but this is what you want, it makes for a nice effect.

* This is a good point to save your work. MeshLab gets crashy if you do too much, so make a lot of checkpoints. As a general rule, if something is crashing MeshLab -- or not giving proper results -- get things to the point just before the crash, save, then restart MeshLab and import the saved mesh.

* Turn off display of the patch, then Import the Neck. If the neck has a different shade from the bottle, then Filters > Normals > Invert Faces... to change the normals.

* Filters > Mesh > Flatten... to combine the two meshes.

* One problem you may run into is that the Voronoi Tesselation seems to mess up at the join between the neck and the bottle. To avoid this, use Filters > Cleaning > Merge Close... and set a pct of 8-10 (Try 8, if it doesn't work, backtrack and try bigger numbers.

* Save the results and then do the Voronoi tesselation. See my Voronoi Tetrahedron for the details on how to do that.

Monday, August 26, 2013

Voronoi-tesselated Tetrahedron

I'm enjoying playing with mathematical objects and printing them. Yesterday I created a Voronoi-tesselated tetrahedron. Halfway through the print I dropped some bells into the central cavity to make a baby-rattle. The object is now on Thingiverse if you want to make one.



My starting point was a blog post showing how to do Voronoi Tesselations in MeshlabHowever, Meshlab is a bit crashy, so I had to do some experimentation. Here is the general procedure I came up with -- hope it helps you create some nice objects.

Launch Meshlab

Make sure Selected Face Rendering is on.. It's the icon with red in it to the right of the light bulb icon.

File > Import Mesh to import your nice fine WATERTIGHT mesh (otherwise, expect bad things to happen), or Filters > Create Mesh Layer > ... to start with a primitive (like the Tetrahedron)

Before you go further, you need to make sure that your object is properly aligned to the XY plane. Click the Wireframe icon (next to the dots icon, then rotate the model (left-click drag it) until there are 3 points that you want to be on the base of your model located where you can drag a marquee over just those points, then click the Select Points icon (next to the Rabbit icon) and do just that.  Then use Filters > Normals... > Transform: Rotate to fit on a plane, check both options and apply.

If you don't have enough vertexes (100-300k is good), use Filters > Remeshing > Subdivision: Midpoint (for primitives) or Filters > Remeshing > Sudivision: Butterfly (for more complex objects) to add triangles. Always set Iterations to 1, you don't want to get too many triangles. Also Edge Threshold to 0.

Click Layers icon (looks like a stack of paper) to show layers.

Filters > Sampling > Poisson-disk Sampling. Number of Samples = 50 to 60. Click Apply, and a new layer will appear in the layers list.

Click on your mesh object in the Layers list so that it is hilighted in yellow. After the sampling, it won't be.

Filters > Color Creation > Voroni Vertex Coloring. Check BackDistance. Click Apply. Your object will get nicely colored with Voroni cells.

Render > Color > None. The colors will disappear. You do this so that the next step is easier to see.

Filters > Selection > Select Faces by Vertex Quality. Check Preview. Slide Max Quality all the way to the right. Slide Min Quality left until you get nice thin borders -- but not too thin. Click Apply.

If the lines are not GREY, use Filters > Selection > Invert Selection. Click Apply. Lines will go grey, areas between them will be red.

Filters > Selection > Delete selected Faces. Now you have a holed, but flat, object.

Filters > Smoothing > Laplacian Smooth with Iterations = 3 to 5 will give you much smoother lines.

This is good place to save a checkpoint. File > Export Mesh AS... NOT File > Export Mesh, which will copy over your old file!!! Save it as a .stl.

Filters > Remeshing > Uniform Mesh Resampling. Precision 1%, Offset 53%, check Absolute Distance. Now wait a bit, and you'll get your thick version of the object. If Meshlab crashes, you probably had a bad initial mesh, it's quirky -- and you're screwed.

In the Layers panel, click on the eyes next to your original object and your Poisson samples to turn them off. You'll only see your new offset mesh.

Filters > Remeshing > Quadric Edge Collapse Decimation. Set the target to be .75 of the original number of vertexes. This smooths things out.

Repeatedly apply Filters > Remeshing > Curvature Flipping Optimization until the object is not getting any better (it may settle down to toggling between two states).

Now you want to increase the number of triangles and make them smooth. Alternate between these two:

Filters > Remeshing > Subdivision: Butterfly, Iterations = 1, Edge Threshold = 0.

then,

Filters > Smoothing > Taubin Smooth

When you get to the number of vertices you think you need, Export As... and save your STL.

Oh, in the case of primitives, they will only be 1mm in size, so use Filters > Normals... > Transform: Scale to make them bigger before saving. The limit is 10x, so maybe do a 10x and a 2x = 20x.



Friday, April 19, 2013

Embossing of Text and Graphics for 3D printing

So I have a new toy, an Ultimaker 3D printer, and I'm climbing the learning curve of how to use the printer and related software.

As some of you may know, I'm a 3-term member of the EVE Online Council of Stellar Management, and as it happens I'm about to go to Iceland for EVE's yearly FanFest. So I thought it would be an interesting project to make some embossed cards for my fellow CSM delegates.

The task at hand is this: take this image, a bitmap...


...and use it to create an embossed 3D model of the card itself. The CSM logo is a parody of the CCP Games logo, and shows the progression of a CSM delegate from blissfully elected (2-o'clock) to veteran interstellar policitian (center).

Our first step is to change the bitmap into a vector representation. A little websearching found an excellent tool, Online-Convert.com, that will do just this. The result is a SVG vector version of the bitmap.

Next, I have to import it into my 3D CAD program. I am using ViaCAD 2D/3D from PunchCad. It's $99 but there is a free trial.

Unfortunately, ViaCAD can't import SVG! But one of the formats it can import is Adobe Illustrator 8, and a free trial of Adobe Illustrator is available. So converting is easy: Open the SVG in Illustrator, then Save As... an Illustrator .ai file, making sure to save it as an Illustrator 8 file. ProTip: You can also use Illustrator to create some text, turn it into a path, and export it for embossing!

Now for the fun part! I'm not going to go into a huge amount of tutorial detail about how ViaCAD works, I'm still learning it and I'm lazy. But here are the steps.

ViaCAD has 2D and 3D modes. Get into 2D mode, and Import the Illustrator file. I found I had to uncheck all the Import Options in order to just get the raw curves and line segments. I needed to do this because the little stick-out-the-tongue face was too small to vectorize during the first step, so it came out as a circle -- by keeping everything separate, I was able to select and delete it. Also at this point, you want to measure your drawing and use the Scale tool to get it to the size you really want.

Go into 3D mode, go into Isometric view (or rotate the viewpoint) and use the Extrude Solid tool to create an extruded object. With nothing selected, click on the tool, then click-drag a rectangle around the stuff you want to extrude, wait for it to select, click on one of the lines, and then wiggle the mouse until you see that it'll be extruding in Z. Click again, and what do you know...


Now back to 2D mode. The next step is to add the perimeter of the card, and also the small hole where a lanyard clip might attach.


Then we extrude them as well. The one thing to be careful about is to extrude the base plate only 1.5 mm -- the thickness of your card. The initial thickness is set by how far you move the mouse when selecting the axis of extrusion, but there's a modeless dialog you can use to set it.


Next, we use the translate tool to move the logo and hole in Z. We move the logo up 0.05 mm so that the bottom of the logo is 2/3rds embedded in the card, and the lanyard hole down 1 mm so that it fully  intersects.

Finally, we use the Subtract Solid tool to subtract the two solids from the card, and we have our finished 3D model.


Now we can export a STL file and load it into our slicing software. In the Mesh Parameters dialog that appears after you select a file name, I checked STL Facets but I have no idea if that's needed.

I am using Cura to do my slicing for me. So far, the best results come from using a raft (to prevent warping), the thinnest possible wall thickness, and 100% fill density.


Here's the final result.


My next task is to find some sort of infill material I can put into the emboss to give it a different color. There are many possibilities, like this.