In the past, some people have asked for code or help with applying a smoothing algorithm to the meshes they get from the Marching Cubes algorithm (see: 'Polygonising a scalar field' by P. Bourke).

I've attached some sample C++ code to perform Taubin smoothing (see: 'Geometric Signal Processing on Polygonal Meshes' by G. Taubin and 'Implicit Fairing of Irregular Meshes using Diffusion and Curvature Flow' by M. Desbrun, et al.) on a Stereo Lithography (STL) file. The code assumes that the mesh is closed --
**mc_smooth2.zip** **8.27KB**
201 downloads

The code also eliminates the __cracks in the mesh that are unfailingly generated by the standard, original Marching Cubes algorithm__ (Google for 'marching cubes cracks' to see that it is a common problem).

__The cracks must be eliminated before smoothing occurs, otherwise the cracks will become holes, and the mesh will be ruined.__

Attached is a sample mesh (including cracks) --
**fractal.zip** **826.28KB**
109 downloads

Here is an image of the sample mesh as generated by Marching Cubes, rendered using flat shading -- very blocky:

Here is an image of the cracks highlighted in red, rendered using flat shading:

Here is an image of the sample mesh after 10 iterations of Taubin smoothing, rendered using flat shading -- the cracks have now become holes, thanks to the smoothing. This is bad:

Here is an image of the vertex pairs (highlighted in blue, and connected by green lines) that should have been merged -- in order to fix the cracks -- before the smoothing was applied, rendered using flat shading:

Here is an image of the crackless mesh after 10 iterations of Taubin smoothing, rendered using flat shading -- no holes, looks less blocky:

Here is an image of the crackless mesh after 10 iterations of Taubin smoothing, rendered using Gouraud shading -- no holes, looks much less blocky:

Good luck.

P.S. The sample mesh is an isosurface of the escape value (where isovalue = 4.0) for the quaternion Julia set generated by Z' = Z^2 + C where C = {0.3, 0.5, 0.4, 0.2} and the maximum number of iterations is 8. (see: 'Quaternion Julia Fractals' by P. Bourke). The code to generate this mesh can be found at: http://code.google.com/p/qjs-isosurface/downloads/detail?name=qjs-isosurface-v2.0.2.1.zip

**Edited by taby, 23 April 2013 - 08:40 PM.**