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
00025 #include<wrap/io_trimesh/import_off.h>
00026 #include<wrap/io_trimesh/export_off.h>
00027 #include<wrap/io_trimesh/export_ply.h>
00028
00029 #include<vcg/complex/algorithms/point_sampling.h>
00030 #include<vcg/complex/algorithms/create/platonic.h>
00031
00032 using namespace vcg;
00033 using namespace std;
00034
00035 class MyEdge;
00036 class MyFace;
00037 class MyVertex;
00038 struct MyUsedTypes : public UsedTypes< Use<MyVertex> ::AsVertexType,
00039 Use<MyEdge> ::AsEdgeType,
00040 Use<MyFace> ::AsFaceType>{};
00041
00042 class MyVertex : public Vertex<MyUsedTypes, vertex::Coord3f, vertex::Normal3f, vertex::VEAdj, vertex::BitFlags >{};
00043 class MyFace : public Face< MyUsedTypes, face::FFAdj, face::Normal3f, face::VertexRef, face::BitFlags > {};
00044 class MyEdge : public Edge<MyUsedTypes,edge::VertexRef, edge::VEAdj, edge::EEAdj, edge::BitFlags >{};
00045 class MyMesh : public tri::TriMesh< vector<MyVertex>, vector<MyFace> , vector<MyEdge> > {};
00046
00047
00048 int main( int argc, char **argv )
00049 {
00050 if(argc<2)
00051 {
00052 printf("Usage edgemesh_sampling <meshfilename.off> radius\n");
00053 return -1;
00054 }
00055
00056 MyMesh m,e;
00057
00058 if(tri::io::ImporterOFF<MyMesh>::Open(m,argv[1])!=0)
00059 {
00060 printf("Error reading file %s\n",argv[1]);
00061 exit(0);
00062 }
00063
00064 printf("Input mesh has %i vert %i faces\n",m.vn,m.fn);
00065
00066
00067 tri::UpdateTopology<MyMesh>::FaceFace(m);
00068 tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFaceNormalized(m);
00069
00070 tri::UpdateFlags<MyMesh>::FaceFauxSignedCrease(m,math::ToRad(-40.f),math::ToRad(40.f ),false);
00071 assert(tri::Clean<MyMesh>::IsFaceFauxConsistent(m));
00072 tri::BuildFromNonFaux(m,e);
00073 printf("Out mesh has %i vert %i edges\n",e.vn,e.en);
00074
00075 tri::UpdateTopology<MyMesh>::VertexEdge(e);
00076 tri::Clean<MyMesh>::SelectNonManifoldVertexOnEdgeMesh(e);
00077 printf("Selected vertices %i\n",tri::UpdateSelection<MyMesh>::VertexCount(e));
00078 tri::Clean<MyMesh>::SplitSelectedVertexOnEdgeMesh(e);
00079 printf("Out mesh has %i vert %i edges\n",e.vn,e.en);
00080 tri::Clean<MyMesh>::SelectCreaseVertexOnEdgeMesh(e,math::ToRad(30.f));
00081 printf("Selected vertices %i\n",tri::UpdateSelection<MyMesh>::VertexCount(e));
00082 tri::Clean<MyMesh>::SplitSelectedVertexOnEdgeMesh(e);
00083 printf("Out mesh has %i vert %i edges\n",e.vn,e.en);
00084
00085 tri::io::ExporterPLY<MyMesh>::Save(e,"out.ply", tri::io::Mask::IOM_EDGEINDEX);
00086
00087 std::vector<Point3f> sampleVec;
00088 tri::TrivialSampler<MyMesh> ps(sampleVec);
00089 tri::SurfaceSampling<MyMesh>::EdgeMeshUniform(e,ps,m.bbox.Diag()/90.0f);
00090 MyMesh sampleMesh;
00091 tri::BuildMeshFromCoordVector(sampleMesh,sampleVec);
00092 tri::io::ExporterPLY<MyMesh>::Save(sampleMesh,"sampleMesh.ply");
00093 return 0;
00094 }