#include #include #include #include #include #include using namespace vcg; using namespace std; class MyEdge; class MyFace; class MyVertex; struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, Use ::AsEdgeType, Use ::AsFaceType>{}; class MyVertex : public Vertex{}; class MyFace : public Face< MyUsedTypes, face::VFAdj, face::FFAdj, face::VertexRef, face::Normal3f, face::BitFlags, vertex::Qualityf> {}; class MyEdge : public Edge{}; class MyMesh : public tri::TriMesh< vector, vector , vector > {}; int main( int argc, char **argv ) { if(argc<2) { printf("Usage trimesh_geodesic \n"); return -1; } float param_m = 1.0; if (argc>2){ param_m = atof(argv[2]); } MyMesh m; if(tri::io::Importer::Open(m, argv[1])!=0) { printf("Error reading file %s\n",argv[1]); exit(0); } Point3f c = m.bbox.Center(); MyVertex* closest = &*m.vert.begin(); float minDist = Distance(closest->P(),c); for(MyMesh::VertexIterator vi=m.vert.begin();vi!=m.vert.end(); ++vi){ if(Distance(vi->P(),c)P(),c); closest = &*vi; } } vector seedVec; seedVec.push_back(closest); tri::Clean::RemoveUnreferencedVertex(m); bool success; success = tri::GeodesicHeat::Compute(m, seedVec, param_m); if (!success){ printf("computation of HeatGeodesic has failed! %d", success); exit(0); } pair minmax = tri::Stat::ComputePerVertexQualityMinMax(m); tri::UpdateColor::PerVertexQualityRamp(m); printf("min %f max %f\n",minmax.first, minmax.second); tri::io::ExporterPLY::Save(m,"base.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY); int t0=clock(); tri::GeodesicHeat::GeodesicHeatCache cache = tri::GeodesicHeat::BuildCache(m, 1.0); tri::GeodesicHeat::ComputeFromCache(m, seedVec, cache); int t1=clock(); tri::GeodesicHeat::ComputeFromCache(m, seedVec, cache); int t2=clock(); printf("Non-Cached Time: %6.3f\n",float(t1-t0)/CLOCKS_PER_SEC); printf("Cached Time : %6.3f\n",float(t2-t1)/CLOCKS_PER_SEC); tri::io::ExporterPLY::Save(m,"base_m1.ply",tri::io::Mask::IOM_VERTCOLOR | tri::io::Mask::IOM_VERTQUALITY); return 0; }