Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include<vcg/complex/complex.h>
00024 #include<vcg/complex/algorithms/create/platonic.h>
00025
00026 #include<wrap/io_trimesh/import_ply.h>
00027 #include<wrap/io_trimesh/export_ply.h>
00028 #include<vcg/complex/algorithms/parametrization/voronoi_atlas.h>
00029 #include<vcg/space/outline2_packer.h>
00030
00031 using namespace vcg;
00032 using namespace std;
00033
00034 class MyEdge;
00035 class MyFace;
00036 class MyVertex;
00037 struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
00038 Use<MyEdge> ::AsEdgeType,
00039 Use<MyFace> ::AsFaceType>{};
00040
00041 class MyVertex : public Vertex<MyUsedTypes, vertex::InfoOcf, vertex::Coord3f, vertex::Normal3f, vertex::TexCoord2f, vertex::VFAdj , vertex::Qualityf, vertex::Color4b, vertex::BitFlags >{};
00042 class MyFace : public Face< MyUsedTypes, face::InfoOcf, face::VertexRef, face::CurvatureDirf, face::BitFlags, face::FFAdjOcf ,face::VFAdj , face::WedgeTexCoord2f> {};
00043 class MyEdge : public Edge< MyUsedTypes>{};
00044 class MyMesh : public tri::TriMesh< vertex::vector_ocf<MyVertex>, face::vector_ocf<MyFace> , vector<MyEdge> > {};
00045
00046
00047
00048 int main( int argc, char **argv )
00049 {
00050 MyMesh startMesh;
00051 if(argc < 3 )
00052 {
00053 printf("Usage trimesh_voro mesh region_num\n");
00054 return -1;
00055 }
00056 int sampleNum =atoi(argv[2]);
00057 printf("Reading %s and sampling %i \n",argv[1],sampleNum);
00058 int ret= tri::io::ImporterPLY<MyMesh>::Open(startMesh,argv[1]);
00059 if(ret!=0)
00060 {
00061 printf("Unable to open %s for '%s'\n",argv[1],tri::io::ImporterPLY<MyMesh>::ErrorMsg(ret));
00062 return -1;
00063 }
00064
00065 MyMesh paraMesh;
00066 tri::VoronoiAtlas<MyMesh>::VoronoiAtlasParam pp;
00067 pp.sampleNum =sampleNum;
00068 pp.overlap=false;
00069
00070 tri::VoronoiAtlas<MyMesh>::Build(startMesh,paraMesh,pp);
00071
00072 tri::io::ExporterPLY<MyMesh>::Save(paraMesh,"Full.ply",tri::io::Mask::IOM_VERTCOLOR|tri::io::Mask::IOM_WEDGTEXCOORD );
00073 return 0;
00074 }