#include #include #include #include "igl/MCTables.hh" typedef float ScalarType; typedef unsigned IndexType; int main(int argc, char * argv[]) { Eigen::Matrix bb_min, bb_max; bb_min<<0.,0.,0.; bb_max<<1.,1.,1.; //diagonal Eigen::Matrix diff = bb_max - bb_min; //center of the sphere Eigen::Matrix center = 0.5 * (bb_min + bb_max); IndexType xres, yres, zres; xres = yres = zres = 10; ScalarType radius = 0.42; //steps in x,y,z direction ScalarType dx = diff[0] / (ScalarType)(xres-1); ScalarType dy = diff[1] / (ScalarType)(yres-1); ScalarType dz = diff[2] / (ScalarType)(zres-1); Eigen::Matrix points(xres*yres*zres,3); Eigen::Matrix values(xres*yres*zres,1); Eigen::Matrix vertices; Eigen::Matrix faces; std::cerr<<"Sphere -- construct grid"<(dx,0.,0.) + ScalarType(y)*Eigen::Matrix(0.,dy,0.) + ScalarType(z)*Eigen::Matrix(0.,0.,dz); values[index] = (points.row(index) - center).squaredNorm() - radius*radius; } std::cerr<<"Sphere -- marching cubes"<