//vMarchingCubes iterates over the entire dataset, calling vMarchCube on each cube GLvoid vMarchingCubes() { GLint iX, iY, iZ; for(iX = 0; iX < iDataSetSize; iX++) for(iY = 0; iY < iDataSetSize; iY++) for(iZ = 0; iZ < iDataSetSize; iZ++) { vMarchCube(iX*fStepSize, iY*fStepSize, iZ*fStepSize, fStepSize); } }
void SaveMesh(std::string filename, const BoundedVolume<T,TargetHost> vol, const BoundedVolume<TColor,TargetHost> volColor ) { std::vector<aiVector3D> verts; std::vector<aiVector3D> norms; std::vector<aiFace> faces; std::vector<aiColor4D> colors; for(GLint iX = 0; iX < vol.Voxels().x-1; iX++) { for(GLint iY = 0; iY < vol.Voxels().y-1; iY++) { for(GLint iZ = 0; iZ < vol.Voxels().z-1; iZ++) { vMarchCube(vol, volColor, iX,iY,iZ, verts, norms, faces, colors); } } } aiMesh* mesh = MeshFromLists(verts,norms,faces,colors); SaveMesh(filename, mesh); }
//vMarchingCubes iterates over the entire dataset, calling vMarchCube on each cube void vMarchingCubes() { int iX, iY, iZ; iNTotalTriangles = 0; /* printf("Entered here\n"); */ if (iUseGridPointers) { /* printf("Using grid pointers\n"); */ if ((fSourceXPointer == NULL) && (fSourceXPointer == NULL) && (fSourceXPointer == NULL)) { printf("Grid pointers not initialized\n"); return; } } else { /* printf("Not using grid pointers\n"); */ if (fSourceDataVerticesPointer == NULL) { printf("Data vertices not initialized\n"); return; } } /* printf("Going to start loop\n"); */ for(iX = 0; iX < iXDataSetSize; iX+=iXStep) for(iY = 0; iY < iYDataSetSize; iY+=iYStep) for(iZ = 0; iZ < iZDataSetSize; iZ+=iZStep) { /* Here I have to check if the point or any of its neighbours is above the isosurface value */ vMarchCube(iX, iY, iZ); } printf("Total triangles = %d", iNTotalTriangles); }