Marching Cubes

Marching Cubes
created: May 2000, updated: November 2001

Using the Open Inventor libraries I created a subclass of SoEnginefor computing an isosurface using Marching Cubes: A High Resolution 3D Surface Construction Algorithm, byWilliam Lorensen and Harvey E. Cline. This implementation isVERY different from a previous version posted on this site. This version properly subclasses Open Inventor and efficiently creates an isosurface. The tables provided in the code found at Paul Bourke's page Polygonising a scalar field were used in this implementation. 

The engine takes as input a scalar field and an isovalue. Then as output are the points, normals, and indexes into the points array used to create the triangles. The engine can easily be connected to other Inventor nodes to create an SoIndexedFaceSet. Below is an example of connecting the engine into a scene graph.
// create MarchingCubes object and connect fields
MarchingCubes *mcubes = new MarchingCubes();
mcubes->ref();
mcubes->data.setValue(dims, data);
mcubes->isoValue = 1.0;

// MarchingCubes gives the triangles with the
// vertices ordered clockwise
SoShapeHints *hints = new SoShapeHints();
hints->vertexOrdering.
  setValue(SoShapeHints::CLOCKWISE);
root->addChild(hints);

// connect the MarchingCubes points and
// normals to an SoVertexProperty node
SoVertexProperty *vprop = new SoVertexProperty();
vprop->ref();
vprop->vertex.connectFrom(&mcubes->points);
vprop->normal.connectFrom(&mcubes->normals);

// connect the indexes from MarchingCubes
SoIndexedFaceSet *faceSet = new SoIndexedFaceSet();
faceSet->vertexProperty = vprop;
faceSet->coordIndex.connectFrom(&mcubes->indexes);
root->addChild(faceSet);
Thanks to Gokhan Kisacikoglu, a vertex blending technique was added. The blending is nothing but a simple test to the closest voxel corner based on a percentage from the corner. Below is an example with the blending and without. Also a gif animation showing the blending can be found here

Without Blending
 
With Blending
The blending reduces the number of triangles of a surface by 40% in some cases. When tested with the MRI data to produce the brain surface, the triangles were reduced from 1,065,244 to 636,702 without loss to the mesh structure. An interactive example of the blending technique can be found by downloading the 3D Grapher Open Inventor application. 

The MarchingCubes engine was used to create all the images on this page. Below are links to the MarchingCubes source code as well as an example which creates a sphere dataset and displays it with the engine node. (TheSFScalarField class is needed by MarchingCubes.)
http://www.wheatchex.com/projects/mcubes/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值