QUIMICOMP

C and C++ libraries of Marching Cubes 33

Facyt - UC

This page contains information about the Marching Cubes 33 library in C language, developed in our laboratory, and its adaptation to C++ language. The libraries has been compiled with GCC in macOS and Linux, with MinGW / MinGW-w64 and Microsoft Visual C++ in Windows.
The MC33 and MC33++ libraries can be used and distributed under the terms of the MIT license, described in the "LICENSE.txt" file that is included in the compressed folder of the source code.

Download latest versions:
C++ language
MC33++ v3.0
C language
MC33 v 4


August 2020
This new version corrects the appearance of repeated vertices on the isosurfaces, which arise when the isovalue is equal to some of the values of the points on the grid. Special care was taken to treat the edges of the grid. The code was extensively tested. I appreciate the help of Julien Hess (Consultant of MATHICSE – Group) for reporting library defects and providing the grids where those defects occurred. Due to suggestions from Julien Hess, the new version of the MC33++ library has additional functions belonging to the grid3d class, which allow the modification and filling of the grid3d object (the grid) without the need to read the data from a file. And the discrepancy of the numeric type of the members of the grid3d and MC33 classes was corrected (Now you can use double type for members of MC33 class).

July 2020
I had decided not to release another version of the MC33 library in C language, but due to a mistake in final 2 version, I had to release final 3 version. I used some tricks to increase the speed in calculating the isosurface.

March 2020
Two new versions were added: MC33++ v2.0 and MC33 v final 2. The processing time of these versions is a bit greater than that of MC33 paper. The great advantage of these new versions is that the format of the surface structure was changed. A single array / vector is used for each type of data: indices, coordinates, normals and colors. It is now possible to use the OpenGL glDrawElements function. The efficiency of drawing the surface increased significantly. The routines that display the surface are included in the MC33.h file in the include folder of the C++ version, and also in the testMC33.cpp file in the example folder of the C version


Download links

Li braryDescriptionRe lease dateSource code
MC33 ++ v3.0Major modification of the Marching Cubes 33 library in C++ language. The isosurface no longer contains duplicate vertices. The numeric type of the MC33 class members can be chosen (between float or double) before compiling the library. There are new functions in the grid3d class to assign the data and parameters of the grids.Aug 2020source forge. net
MC33 v 4Major modification of the Marching Cubes 33 library in C language. The isosurface no longer contains duplicate vertices.Aug 2020source forge. net
MC33 ++ v2.1Minor modification of the second version of the Marching Cubes 33 library in C++ language.
Unused #define have been removed. The speed in the calculation of the isosurfaces was slightly increased.
Jul 2020source forge. net
MC33 v final 3Another final version of the Marching Cubes 33 library in C language.
This version fixes a big mistake in version 2: In the free _surface _memory function the memory occupied by the vertex array is not freed. The speed in the calculation of the isosurfaces was also slightly increased.
Jul 2020source forge. net
MC33 ++ v2.0Second version of the Marching Cubes 33 library in C++ language.
The structure surface of this library now uses vectors to store the data. It is less efficient in calculating the isosurface, but it is much more efficient in drawing it.
Feb 2020source forge. net
MC33 v final 2Another final version of the Marching Cubes 33 library in C language.
The structure surface of this library now uses single arrays to store the data, and all global variables were moved to a structure. See README.TXT file for more details. It is less efficient in calculating the isosurface, but it is much more efficient in drawing it.
Feb 2020source forge. net
MC33 ++ v1.0First version of the Marching Cubes 33 library in C++ language, adapted from the library MC33 v final.
The Solution File to compile the library with Visual Studio community 2017, and an example that uses this library, are included.
This library still uses malloc and realloc for memory allocation of the isosurface and the 3D grid.
Aug 2019source forge. net
MC33 v finalFinal version of the Marching Cubes 33 library in C language.
The code of this library is more efficient and was obtained by slightly modifying the library code described in the paper:
A Fast and Memory-Saving Marching Cubes 33 Implementation with the correct interior test
This C library compiled with visual C++ did not behave correctly. Compiling it as a C++ code (/TP option) fixed the problem.
An example in C++ that uses this library was added.
Aug 2019source forge. net
MC33 paperVersion described in the paper mentioned aboveJun 2018jcgt.org
source forge. net
Old versionFirst version published on the Internet of the Marching Cubes 33 library in C language. This is an outdated version, with some bugs.Sep 2012facyt. uc. edu. ve
source forge. net

⨳ The example also needs the FLTK library.



The following table compares the processing speed of the libraries, using 4 datasets. The tests were performed on a laptop with an Intel® Core™ i3-2350M CPU @ 2.30 GHz (4 GiB RAM). The test codes were compiled with g++ of MinGW-w64 GCC in Windows 7 64-bit operating system. Aggressive optimization compiler options -Ofast and -funroll-loops were used. The calculation time of the MC33 paper version was taken as a reference.

Performance comparison

Li braryDataset
bunnyCT headstag beetlepre sent
MC33 ++ v3.00.991
V: 1705393
T: 3403472
0.916
V: 271473
T: 543293
0.982
V: 3774434
T: 7558326
0.958
V: 3261696
T: 6486287
MC33 v 41.035
V: 1705393
T: 3403472
0.933
V: 271473
T: 543293
1.039
V: 3774434
T: 7558326
0.990
V: 3261696
T: 6486287
MC33 ++ v2.11.001
V: 1705560
T: 3403806
0.935
V: 271554
T: 543444
0.995
V: 3777215
T: 7563816
0.979
V: 3263395
T: 6489335
MC33 v final 31.065
V: 1705560
T: 3403806
0.959
V: 271554
T: 543444
1.077
V: 3777215
T: 7563816
1.023
V: 3263395
T: 6489335
MC33 ++ v2.00.975
V: 1705560
T: 3403806
0.920
V: 271554
T: 543444
0.982
V: 3777215
T: 7563816
0.960
V: 3263395
T: 6489335
MC33 v final 20.957
V: 1705560
T: 3403806
0.901
V: 271554
T: 543444
0.978
V: 3777215
T: 7563816
0.891
V: 3263395
T: 6489335
MC33 ++ v1.01.093
V: 1705560
T: 3403806
1.058
V: 271553
T: 543438
1.061
V: 3777215
T: 7563816
1.040
V: 3263382
T: 6489250
MC33 v final1.128
V: 1705560
T: 3403806
1.087
V: 271553
T: 543438
1.091
V: 3777215
T: 7563816
1.063
V: 3263382
T: 6489250
MC33 paper1.000
V: 1705560
T: 3403806
1.000
V: 271553
T: 543438
1.000
V: 3777215
T: 7563816
1.000
V: 3263382
T: 6489250
Old version0.688
V: 1705560
T: 3403806
0.634
V: 333004
T: 666523
0.638
V: 3777215
T: 7563924
0.706
V: 3263380
T: 6489535

The bunny (512×512×361) and CThead (256×256×113) datasets were read using the read_scanfiles function and the isovalue used in the tests was 1500. The stagbeetle (832×832×494) and present (492×492×442) datasets were read using the read_dat_file function and the isovalue used in the tests was 500.

The comparison of the processing speed with other libraries not developed in our laboratory is found in the paper:
Vega, D., Abache, J., Coll, D., A Fast and Memory-Saving Marching Cubes 33 Implementation with the correct interior test, Journal of Computer Graphics Techniques (JCGT), vol. 8, no. 3, 1-18, 2019



The Solution File to compile the library with Visual Studio and the Makefile to compile with GCC (on Linux, macOS or msys2/MinGW) were included in the source code for most versions of both libraries. A C++ example of the use of each library was also included. To compile this example, it is necessary install the FLTK library. The Makefiles are also included to compile the example with msys2/MinGW and Debian/GCC. Screen shots of the example compiled in Windows are shown below.

bunny dataset present dataset

CTHead dataset stagbeetle dataset

bonsai raw dataset engine raw dataset

If you find any error in the codes or have difficulty compiling the library and the example, please write to:
dvega@uc.edu.ve or dvega68@yahoo.com