From f948e80603d401bb2b98475090f8e4f8cb144ea2 Mon Sep 17 00:00:00 2001 From: Marco Callieri Date: Wed, 21 Dec 2016 12:10:27 +0100 Subject: [PATCH] corrected exporting error, when saving multiple layers MeshLabServer was iterating on the "output list", but always exporting the current layer (meshDocument.mm()). Now it exports layers following their order - TO BE TESTED - --- src/meshlabserver/mainserver.cpp | 33 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/meshlabserver/mainserver.cpp b/src/meshlabserver/mainserver.cpp index 7cafe6612..ab9a7c08e 100644 --- a/src/meshlabserver/mainserver.cpp +++ b/src/meshlabserver/mainserver.cpp @@ -896,19 +896,26 @@ int main(int argc, char *argv[]) } } - for(int ii = 0;ii < outmeshlist.size();++ii) - { - if (meshDocument.mm() != NULL) - { - bool exported = server.exportMesh(meshDocument.mm(), outmeshlist[ii].mask, outmeshlist[ii].filename,logfp); - if (exported) - fprintf(logfp,"Mesh %s saved as %s (%i vn %i fn)\n", qPrintable(meshDocument.mm()->fullName()), qPrintable(outmeshlist[ii].filename), meshDocument.mm()->cm.vn, meshDocument.mm()->cm.fn); - else - fprintf(logfp,"Output mesh %s has NOT been saved\n",qPrintable(outmeshlist[ii].filename)); - } - else - fprintf(logfp,"Invalid current mesh. Output mesh %s will not be saved\n",qPrintable(outmeshlist[ii].filename)); - } + if (meshDocument.size() < outmeshlist.size()) + fprintf(logfp, "Error: trying to save %i meshes, but only %i available in the project\n", qPrintable(outmeshlist.size()), qPrintable(meshDocument.size())); + else + { + for (int ii = 0; ii < outmeshlist.size(); ++ii) + { + if (meshDocument.meshList[ii] != NULL) + { + bool exported = server.exportMesh(meshDocument.meshList[ii], outmeshlist[ii].mask, outmeshlist[ii].filename, logfp); + if (exported) + fprintf(logfp, "Mesh %s saved as %s (%i vn %i fn)\n", qPrintable(meshDocument.mm()->fullName()), qPrintable(outmeshlist[ii].filename), meshDocument.mm()->cm.vn, meshDocument.mm()->cm.fn); + else + fprintf(logfp, "Output mesh %s has NOT been saved\n", qPrintable(outmeshlist[ii].filename)); + } + else + fprintf(logfp, "Invalid layer %i. Output mesh %s will not be saved\n", qPrintable(ii), qPrintable(outmeshlist[ii].filename)); + } + + } + if((logfp != NULL) && (logfp != stdout)) fclose(logfp);