views:

1284

answers:

2

From My last question: Marching Cube Question
AndreasT has explained to me how the triTable and edgeTable works.
I really can't thank him enough.

However, i am still unclear as in:

  1. how to create imaginary cube/voxel to check if a vertex is below the isosurface?
  2. how do i know which vertex is below the isosurface?
  3. how does each cube/voxel determines which cubeindex/surface to use?
  4. how draw surface using the data in triTable?

Let's say i have a point cloud data of an apple.
how do i proceed?

can anybody that are familiar with Marching Cube help me?
i only know C++ and opengl.(c is a little bit out of my hand)

i'd much appreciate if you have any useful link or sample codes to share.
many thanks in advance!

+1  A: 

1) It depends on yoru implementation. You'll need to have a data structure where you can lookup the values at each corner (vertex) of the voxel or cube. This can be a 3d image (ie: an 3D texture in OpenGL), or it can be a customized array data structure, or any other format you wish.

2) You need to check the vertices of the cube. There are different optimizations on this, but in general, start with the first corner, and just check the values of all 8 corners of the cube.

3) Most (fast) algorithms create a bitmask to use as a lookup table into a static array of options. There are only so many possible options for this.

4) Once you've made the triangles from the triTable, you can use OpenGL to render them.

Let's say i have a point cloud data of an apple. how do i proceed?

This isn't going to work with marching cubes. Marching cubes requires voxel data, so you'd need to use some algorithm to put the point cloud of data into a cubic volume. Gaussian Splatting is an option here.

Normally, if you are working from a point cloud, and want to see the surface, you should look at surface reconstruction algorithms instead of marching cubes.

If you want to learn more, I'd highly recommend reading some books on visualization techniques. A good one is from the Kitware folks - The Visualization Toolkit.

You might want to take a look at VTK. It has a C++ implementation of Marching Cubes, and is fully open sourced.

Reed Copsey
can a 6 glQuads equal to a voxel? if so, how is the voxel build reletive to? does my point being the center of the cube?
noob88
@noob88: No, not really. Your "cube" would need to be some object comprised of 8 pionts. The 6 glQuads could be the faces of the cube/voxel, and the vertices you're using could be your 8 points. I'd make a different data structure to hold this, though. Something as simple as a multidimensional array works.
Reed Copsey
i see.. i think i need time to test it out 1st, can i have your contact? should i have further problems i hope i can get your help..
noob88
Easiest way is to just ask it here ;) I am pretty active on SO... If you add a comment, it'll show up in my profile, and I'll answer. I do highly recommend checking out VTK, though - it's very stable, very mature, and does this well.
Reed Copsey
ok! thanks very much!
noob88
+2  A: 

First of all, the isosurface can be represented in two ways. One way is to have the isovalue and per-point scalars as a dataset from an external source. That's how MRI scans work. The second approach is to make an implicit function F() which takes a point/vertex as its parameter and returns a new scalar. Consider this function:

float computeScalar(const Vector3<float>& v)
{
    return std::sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
}

Which would compute the distance from the point and to the origin for every point in your scalar field. If the isovalue is the radius, you just figured a way to represent a sphere. This is because |v| <= R is true for all points inside a sphere, or which lives on its interior. Just figure out which vertices are inside the sphere and which ones are on the outside. You want to use the less or greater-than operators because a volume divides the space in two. When you know which points in your cube are classified as inside and outside, you also know which edges the isosurface intersects. You can end up with everything from no triangles to five triangles. The position of the mesh vertices can be computed by interpolating across the intersected edges to find the actual intersection point.


If you want to represent say an apple with scalar fields, you would either need to get the source data set to plug in to your application, or use a pretty complex implicit function. I recommend getting simple geometric primitives like spheres and tori to work first, and then expand from there.

Mads Elvheim