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
00032 #include<vcg/complex/complex.h>
00033 #include <vcg/complex/algorithms/update/topology.h>
00034 #include <vcg/complex/algorithms/update/normal.h>
00035
00036 #include<vcg/complex/algorithms/clean.h>
00037 #include<vcg/complex/algorithms/smooth.h>
00038
00039
00040 #include <wrap/io_trimesh/import.h>
00041 #include <wrap/io_trimesh/export_ply.h>
00042
00043
00044 using namespace vcg;
00045 using namespace std;
00046
00047
00048 class MyFace;
00049 class MyVertex;
00050
00051 struct MyUsedTypes : public UsedTypes< Use<MyVertex>::AsVertexType, Use<MyFace>::AsFaceType>{};
00052 class MyVertex : public Vertex< MyUsedTypes, vertex::VFAdj, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{};
00053 class MyFace : public Face < MyUsedTypes, face::VFAdj, face::Normal3f, face::VertexRef, face::BitFlags > {};
00054 class MyMesh : public vcg::tri::TriMesh<vector<MyVertex>, vector<MyFace> > {};
00055
00056 int main(int argc,char ** argv)
00057 {
00058 if(argc<4)
00059 {
00060 printf("Usage: trimesh_smooth <filename> <steps> <sigma> <fitstep>\n");
00061 return 0;
00062 }
00063
00064 int Step= atoi(argv[2]);
00065
00066 MyMesh m;
00067
00068
00069 int err = tri::io::Importer<MyMesh>::Open(m,argv[1]);
00070 if(err) {
00071 printf("Error in reading %s: '%s'\n",argv[1], tri::io::Importer<MyMesh>::ErrorMsg(err));
00072 exit(-1);
00073 }
00074
00075
00076 int dup = tri::Clean<MyMesh>::RemoveDuplicateVertex(m);
00077 int unref = tri::Clean<MyMesh>::RemoveUnreferencedVertex(m);
00078 printf("Removed %i duplicate and %i unreferenced vertices from mesh %s\n",dup,unref,argv[1]);
00079
00080 tri::UpdateTopology<MyMesh>::VertexFace(m);
00081
00082 for(int i=0;i<Step;++i)
00083 {
00084 tri::UpdateNormal<MyMesh>::PerFaceNormalized(m);
00085 tri::Smooth<MyMesh>::VertexCoordPasoDoble(m,atoi(argv[3]),atof(argv[4]),atoi(argv[5]));
00086 }
00087
00088
00089 tri::io::ExporterPLY<MyMesh>::Save(m,"out.ply");
00090
00091 return 0;
00092 }
00093