Implementing the marching cube algorithm?

From my last question: Cube Release Question

However, I am still unclear how in:

  • how to create an imaginary cube / voxel to check if the vertex is below the isosurface?
  • How do you know which vertex is below the isosurface?
  • How does each cube / voxel determine which cubinex / surface to use?
  • how to draw a surface using data in triTable?

Say I have cloud data from an apple.
how can i proceed?

Can someone familiar with Marching Cube help me?
I only know C ++ and opengl. (c a little bit out of my hand)

+6
c ++ rendering 3d opengl
source share
3 answers

First of all, isosurface can be represented in two ways. One way is to create isovalue and per-point scalars as a dataset from an external source. This is how MRI works. 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(vx*vx + vy*vy + vz*vz); } 

To calculate the distance from a point to the origin for each point of your scalar field. If isovalue is a radius, you simply specified a way to represent the sphere. This is due to the fact that | v | <= R is true for all points inside the sphere or lives on its inner surface. Just find out which vertices are inside the sphere and which of them are outside. You want to use operators with fewer or more numbers because volume divides the space into two. When you know which points in your cube are classified both internally and externally, you also know which edges intersect the isosurface. You can get everything from triangles to five triangles. The position of the vertices of the grid can be calculated by interpolating along intersecting edges to find the actual intersection point.


If you want to imagine, say, an apple with scalar fields, you will need to either install the original dataset to connect to your application, or use a rather complicated implicit function. I recommend that you first get simple geometric primitives, such as spheres and tori, and then expand from there.

+2
source share

1) It depends on yoru implementation. You will need a data structure in which you can search for values ​​in each corner (top) of a voxel or cube. It can be a three-dimensional image (i.e. a 3D texture in OpenGL), or it can be a customized array data structure or any other format you want.

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

3) Most (fast) algorithms create a bitmask for use as a lookup table in a static set of parameters. There are so many options.

4) After you made triangles from triTable, you can use OpenGL to render them.

Say I have apple cloud point data. how can i proceed?

This will not work with marching cubes. Marching cubes require voxel data, so you will need to use some algorithm to put a point cloud on a cubic volume. Gaussian Splatting is an option here.

Usually, if you are working from a point cloud and want to see the surface, you should look for surface restoration algorithms instead of marching cubes.

If you want to know more, I highly recommend reading some books on visualization techniques. Good - From People Kitware - Visualization Tool .

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

+1
source share

In accordance with the request, an example of code that implements the marching cubes algorithm (using JavaScript / Three.js for graphics) is provided:

http://stemkoski.github.com/Three.js/Marching-Cubes.html

For more on theory, you should check out the article on

http://paulbourke.net/geometry/polygonise/

+1
source share

All Articles