2009-11-03 19:34:46 UTC
Hello, i'm new to vgc.
I'm trying to use the marching cubes algorithm, i'm experimenting a bit by generating simple ellipsoids. I don't understand how the vcg algorithm figures out if a voxel belongs to the object or not.
I do the following:
typedef vcg::tri::TrivialWalker<MyMesh,MyVolume> MyWalker;
typedef vcg::tri::MarchingCubes<MyMesh, MyWalker> MarchingCubes;
typedef SimpleVolume<SimpleVoxel> MyVolume;
MyWalker walker;
MyVolume volume;
volume.Init(Point3i(m_size,m_size,m_size));
Point3i ff = volume.ISize();
for(int i=0;i<m_size;i++)
for(int j=0;j<m_size;j++)
for(int k=0;k<m_size;k++) {
volume.Val(i,j,k) = ((i-(m_size/2))*(i-(m_size/2)))/2 +
((j-(m_size/2))*(j-(m_size/2)))/2 +
((k-(m_size/2))*(k-(m_size/2)))/4 - 1;
}
MyMesh mc_mesh;
printf("[MARCHING CUBES] Building mesh...");
MyMarchingCubes mc(mc_mesh, walker);
walker.BuildMesh<MyMarchingCubes>(mc_mesh, volume, mc, thr);
vcg::tri::io::ExporterPLY<MyMesh>::Save(mc_mesh, s.c_str(), false);
Before making a couple of questions i try to give the idea about my doubts. I just modified the code of vcg samples, where a cylinder is generated. If i have volumetric data i understand how to use the threshold needed by the marching cube algorithm, usually it is done by the density estimation of the object, supposing that the object has uniform density we have the threshold and we understand what it is inside or outside the object.
For cylinder and spheres it's ok, we have the radius, but for ellipsoids?
How does the algorithm use the threshold?
Does the algorithm use the sign of volume.Val(i,j,k) to understand if the vertex(i,j,k) is outside the surface?
Finally, how do i set the threshold? it seems to modify the resolution of the final mesh, no matter about the dimension of the grid.
Maybe i don't really understand the Marching Cubes algorithm :( but i red the original paper and i red only about a "user-specified" value used to distinguish inner and outer vertices.
Help me to get out this hole!
thanks in advance