From aaec7445c55cd13458a2ba3160a1e9d55e7c2af9 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Fri, 19 Feb 2010 16:13:40 +0000 Subject: [PATCH] Significant improvment of plymc filter. Now works with multiple meshes (use all the visible layers) and honors the Tr matrix. --- .../filter_plymc/filter_plymc.cpp | 33 ++++++++++------- src/meshlabplugins/filter_plymc/plymc.h | 2 +- .../filter_plymc/plymc_main.cpp | 2 +- .../filter_plymc/simplemeshprovider.h | 36 ++++++++++--------- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/meshlabplugins/filter_plymc/filter_plymc.cpp b/src/meshlabplugins/filter_plymc/filter_plymc.cpp index e9c9090cf..0cd0f7a4e 100644 --- a/src/meshlabplugins/filter_plymc/filter_plymc.cpp +++ b/src/meshlabplugins/filter_plymc/filter_plymc.cpp @@ -117,19 +117,26 @@ bool PlyMCPlugin::applyFilter(QAction */*filter*/, MeshDocument &md, RichParamet foreach(MeshModel*mm, md.meshList) { - SMesh sm; - mm->updateDataMask(MeshModel::MM_FACEQUALITY); - tri::Append::Mesh(sm,mm->cm); - QString mshTmpPath=QDir::tempPath()+QString("/")+QString(mm->shortName()); - qDebug("Saving tmp file %s",qPrintable(mshTmpPath)); - int retVal = tri::io::ExporterVMI::Save(sm,qPrintable(mshTmpPath) ); - if(retVal!=0) + if(mm->visible) { - qDebug("Failed to write vmi temp file %s",qPrintable(mshTmpPath)); - return false; + SMesh sm; + mm->updateDataMask(MeshModel::MM_FACEQUALITY); + tri::Append::Mesh(sm, mm->cm); + tri::UpdatePosition::Matrix(sm, mm->cm.Tr,true); + tri::UpdateBounding::Box(sm); + //QString mshTmpPath=QDir::tempPath()+QString("/")+QString(mm->shortName())+QString(".vmi"); + QString mshTmpPath=QString("__TMP")+QString(mm->shortName())+QString(".vmi"); + qDebug("Saving tmp file %s",qPrintable(mshTmpPath)); + int retVal = tri::io::ExporterVMI::Save(sm,qPrintable(mshTmpPath) ); + if(retVal!=0) + { + qDebug("Failed to write vmi temp file %s",qPrintable(mshTmpPath)); + return false; + } + pmc.MP.AddSingleMesh(qPrintable(mshTmpPath)); } - pmc.MP.AddSingleMesh(qPrintable(mshTmpPath)); } + pmc.Process(); if(par.getBool("openResult")) @@ -142,9 +149,9 @@ bool PlyMCPlugin::applyFilter(QAction */*filter*/, MeshDocument &md, RichParamet tri::UpdateNormals::PerVertexPerFace(mp->cm); } } - - for(int i=0;i ALNParser::ParseALN(rmaps, alnName); for(int i=0; i fullBBox.SetNull(); for(int i=0;i::FileExtension(meshnames[i],"PLY")) { - if(!(TrV[i]==Id)) - ret=ply::ScanBBox(meshnames[i].c_str(),BBV[i],mt,true,0); - else - ret=vcg::ply::ScanBBox(meshnames[i].c_str(),BBV[i]); - if( ! ret) - { - printf("\n\nwarning:\n file '%s' not found\n",meshnames[i].c_str()); - continue; - } - } - else - { + if(!(TrV[i]==Id)) + ret=ply::ScanBBox(meshnames[i].c_str(),BBV[i],mt,true,0); + else + ret=vcg::ply::ScanBBox(meshnames[i].c_str(),BBV[i]); + + } + else + { printf("Trying to import a non-ply file %s\n",meshnames[i].c_str());fflush(stdout); TriMeshType m; - tri::io::Importer::Open(m,meshnames[i].c_str()); + int retVal=tri::io::Importer::Open(m,meshnames[i].c_str()); + ret = (retVal==0); tri::UpdateBounding::Box(m); BBV[i].Import(m.bbox); } - fullBBox.Add(BBV[i]); + if( ! ret) + { + printf("\n\nwarning:\n file '%s' not found\n",meshnames[i].c_str());fflush(stdout); + continue; + } + fullBBox.Add(BBV[i]); } return true; }