#include #include #include #include #include #include #include #include #include #include #include #include "simple_volume.h" #include "trivial_walker.h" using namespace std; using namespace vcg; typedef float ScalarType; class MyEdge; class MyFace; class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f>{}; class MyFace : public FaceSimp2< MyVertex, MyEdge, MyFace, face::VertexRef, face::BitFlags> {}; //class MyVertex : public vcg::Vertex< ScalarType, MyEdge, MyFace > {}; //class MyFace : public vcg::Face< MyVertex, MyEdge, MyFace> {}; class MyMesh : public vcg::tri::TriMesh< std::vector< MyVertex>, std::vector< MyFace > > {}; typedef SimpleVolume MyVolume; int main(int /*argc*/ , char /**argv[]*/) { MyVolume volume; typedef vcg::tri::TrivialWalker MyWalker; typedef vcg::tri::MarchingCubes MyMarchingCubes; MyWalker walker; // Simple initialization of the volume with some cool perlin noise volume.Init(Point3i(64,64,64)); for(int i=0;i<64;i++) for(int j=0;j<64;j++) for(int k=0;k<64;k++) volume.Val(i,j,k)=(j-32)*(j-32)+(k-32)*(k-32) + i*10*(float)math::Perlin::Noise(i*.2,j*.2,k*.2); // MARCHING CUBES MyMesh mc_mesh; printf("[MARCHING CUBES] Building mesh..."); MyMarchingCubes mc(mc_mesh, walker); walker.BuildMesh(mc_mesh, volume, mc, 20*20); vcg::tri::io::ExporterPLY::Save( mc_mesh, "marching_cubes.ply"); printf("OK!\n"); };