bool CTempFile::MoveTo(CFSTR name, bool deleteDestBefore) { if (deleteDestBefore) if (NFind::DoesFileExist(name)) if (!DeleteFileAlways(name)) return false; DisableDeleting(); return MyMoveFile(_path, name); }
int main(int argc, char** argv) { //OpenMesh::IO::Options r_options, w_options; //string tmeshfile = "C:\\Users\\duan_qi\\Desktop\\Reconstruction\\PhotoSynthToolkit11\\templeRing\\pmvs\\models\\pmvs_options.txt.ply"; //string fmeshfile = "C:\\Users\\duan_qi\\Desktop\\Reconstruction\\PhotoSynthToolkit11\\templeRing\\pmvs\\models\\pmvs_options.txt.filtered.off"; //r_options.set(OpenMesh::IO::Options::VertexColor); w_options.set(OpenMesh::IO::Options::VertexColor); //OpenMesh::IO::read_mesh(ObjTriMesh, tmeshfile, r_options); //if ( !r_options.check( OpenMesh::IO::Options::VertexColor ) ) { // cout << "Color is not loaded.." << endl; //} //int rcount = 0; //for (MyMesh::VertexIter v_it = ObjTriMesh.vertices_begin(); v_it != ObjTriMesh.vertices_end(); ++ v_it) { // OpenMesh::Vec3f tColor; // tColor[0] = ObjTriMesh.color(v_it).data()[0]; // tColor[1] = ObjTriMesh.color(v_it).data()[1]; // tColor[2] = ObjTriMesh.color(v_it).data()[2]; // if (tColor.norm() < 40) { // ObjTriMesh.delete_vertex(v_it, false); // rcount ++; // } //} //ObjTriMesh.garbage_collection(); //OpenMesh::IO::write_mesh(ObjTriMesh, fmeshfile, w_options); ParseParam(argc,argv, MOptions); ScaleDelta = MOptions.ScaleDelta; AnisotropicLaplace = MOptions.AnisotropicLaplace; RecordColor = MOptions.RecordColor; if (MOptions.UseMatlabSolver) { cout << "Use matlab solver for linear equations." << endl; if (!(m_ep = engOpen("\0"))) { std::cout << "Can not start Matlab engine" << std::endl; return false; } engSetVisible(m_ep, false); } ScaleDelta?cout<<"Scale delta P each time. ":cout<<" "; AnisotropicLaplace?cout<<"Using anisotropic laplacian term.":cout<<" "; RecordColor?cout<<"Record vertex color to mesh. ":cout<<" "; cout << endl; path = MOptions.DirName; printf("Number of threads %d\n",omp_get_num_procs()); omp_set_num_threads(omp_get_num_procs()); omp_set_num_threads(8); double timer_start = (double)cv::getTickCount(); if (!FileExisted( (MOptions.DirName + "InitialPoissonModel.ply").c_str() )) { if (!LoadMVSResult()) { readMiddleBuryData2(MOptions.DirName); chooseStereoPairs(); stereoMatching(); printf("\nTime = %lfs\n",((double)cv::getTickCount()-timer_start)/cv::getTickFrequency()); buildTracks(); printf("\nTime = %lfs\n",((double)cv::getTickCount()-timer_start)/cv::getTickFrequency()); //writeToOBJ(); //printf("\nTime = %lfs\n",((double)getTickCount()-timer_start)/getTickFrequency()); calNormals(); printf("\nTime = %lfs\n",((double)cv::getTickCount()-timer_start)/cv::getTickFrequency()); verifyTracks(); printf("\nTime = %lfs\n",((double)cv::getTickCount()-timer_start)/cv::getTickFrequency()); SaveMVSResult(); } writeToNPTS2(tracks,(MOptions.DirName + "PointInfo.npts")); //outputVerticesWithNormals(tracks,(MOptions.DirName + "PointModel.ply")); printf("\nTime = %lfs\n",((double)cv::getTickCount()-timer_start)/cv::getTickFrequency()); //printf("\nTime = %lfs\n",((double)cv::getTickCount()-timer_start)w/cv::getTickFrequency()); string PlyModelName = MOptions.DirName + "PoissonModel"; PoissonReconstruction((MOptions.DirName + "PointInfo.npts"), PlyModelName); MyCopyFile(PlyModelName, (MOptions.DirName + "InitialPoissonModel.ply")); } readMiddleBuryData2(MOptions.DirName); //read the initial generated Poisson object model OpenMesh::IO::Options read_options, write_options; string ObjName = MOptions.DirName; if (ObjName.find_last_of("\\") == ObjName.length()-1) { ObjName.erase(ObjName.end()-1); } ObjName = ObjName.substr(ObjName.find_last_of("\\")+1, ObjName.length()); MOptions.meshname = ObjName; string meshfile = (MOptions.DirName + ObjName +"-remeshed.off"); if (!FileExisted(meshfile.c_str())) { string cmd = "meshfix.exe "; cmd += MOptions.DirName + "InitialPoissonModel.ply"; WinExec(cmd.c_str(),0); ::Sleep(5000); MyMoveFile(MOptions.DirName + "InitialPoissonModel_fixed.off", MOptions.DirName + "temp.off"); for (int i = 0; i < 5; ++ i) { cmd = "meshfix.exe "; cmd += MOptions.DirName + "temp.off"; WinExec(cmd.c_str(),0); ::Sleep(5000); MyMoveFile(MOptions.DirName + "temp_fixed.off", MOptions.DirName + "temp.off"); } MyMoveFile(MOptions.DirName + "temp.off", meshfile); } fstream fin(meshfile,ios::in); string tag, temp_str; fin>>tag; fin>>temp_str; if (temp_str[0] == '#') { // need to load and rewrite the off file char buffer[100]; fin.getline(buffer, 100); fin.getline(buffer, 100); fstream fout(meshfile+"tmp",ios::out); int vnum, trinum, flag; double x, y, z; int a1, v0, v1, v2; fout<<tag<<endl; fin>>vnum>>trinum>>flag; fout<<vnum<<" "<<trinum<<" "<<flag<<endl; for (int i = 0; i < vnum; ++ i) { fin>>x>>y>>z; fout<<x<<" "<<y<<" "<<z<<endl; } for (int i = 0; i < trinum; ++i) { fin>>a1>>v0>>v1>>v2; fout<<a1<<" "<<v0<<" "<<v1<<" "<<v2<<endl; } fout.close(); MyMoveFile(meshfile+"tmp", meshfile); } fin.close();