diff --git a/src/meshlabserver/mainserver.cpp b/src/meshlabserver/mainserver.cpp index a39bab83f..b5fa90420 100644 --- a/src/meshlabserver/mainserver.cpp +++ b/src/meshlabserver/mainserver.cpp @@ -203,7 +203,7 @@ public: return true; } - bool exportMesh(MeshModel *mm, const int mask, const QString& fileName,FILE* fp = stdout) + bool exportMesh(MeshModel *mm, const int mask, const QString& fileName,bool writebinary,FILE* fp = stdout) { QFileInfo fi(fileName); // this change of dir is needed for subsequent textures/materials loading @@ -226,6 +226,10 @@ public: // optional saving parameters (like ascii/binary encoding) RichParameterSet savePar; pCurrentIOPlugin->initSaveParameter(extension, *mm, savePar); + if(savePar.hasParameter("Binary")){ + savePar.setValue("Binary",BoolValue(writebinary)); + } + int formatmask = 0; int defbits = 0; pCurrentIOPlugin->GetExportMaskCapability(extension,formatmask,defbits); @@ -296,7 +300,7 @@ public: m->setFileName(outfilename); QFileInfo of(outfilename); m->setLabel(of.fileName()); - exportMesh(m,m->dataMask(),outfilename); + exportMesh(m,m->dataMask(),outfilename,true); } } @@ -605,6 +609,8 @@ namespace commandline const char log('l'); const char dump('d'); const char script('s'); + const char saveparam('s'); + const char ascii('a'); void usage() { @@ -635,7 +641,7 @@ namespace commandline QString outputmeshExpression() { - QString options("(" + QString(vertex) + "|" + QString(face) + "|" + QString(wedge) + "|" + QString(mesh) + ")(" + QString(color) + "|" + QString(quality) + "|" + QString(flags) + "|" + QString(normal) + "|" + QString(radius) + "|" + QString(texture) + "|" + QString(polygon) + ")"); + QString options("(" + QString(vertex) + "|" + QString(face) + "|" + QString(wedge) + "|" + QString(mesh) + "|" +QString(saveparam) + ")(" + QString(color) + "|" + QString(quality) + "|" + QString(flags) + "|" + QString(normal) + "|" + QString(radius) + "|" + QString(texture) + "|" + QString(polygon) + "|" + QString(ascii) + ")"); QString optionslist(options + "(\\s+" + options + ")*"); QString savingmask("-" + QString(mask) + "\\s+" + optionslist); QString layernumber("\\d+"); @@ -665,9 +671,10 @@ namespace commandline struct OutFileMesh { + OutFileMesh() : writebinary(true) {} QString filename; int mask; - + bool writebinary; /*WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ /*we need these two constant values because when we parse the command line we don't know yet how many layers will have the current document and which will be the current one. Opening a project and/or importing a file happens after the parsing of the commandline is completed*/ static const int lastlayerconst = -2; @@ -755,7 +762,7 @@ int main(int argc, char *argv[]) MeshLabServer server(&shared); server.loadPlugins(); - + bool writebinary = true; int i = 1; while(i < argc) { @@ -922,6 +929,19 @@ int main(int argc, char *argv[]) break; } + case commandline::saveparam : + { + switch( argv[i][1]) + { + case commandline::ascii: + { + writebinary = false; + i++; + break; + } + } + break; + } case commandline::mesh : { switch (argv[i][1]) @@ -938,6 +958,7 @@ int main(int argc, char *argv[]) else ++i; outfl.mask = mask; + outfl.writebinary = writebinary; outmeshlist << outfl; break; } @@ -1035,7 +1056,7 @@ int main(int argc, char *argv[]) { MeshModel* meshmod = meshDocument.meshList[layertobesaved]; if (meshmod != NULL) - exported = server.exportMesh(meshDocument.meshList[layertobesaved], outmeshlist[ii].mask, outmeshlist[ii].filename, logfp); + exported = server.exportMesh(meshDocument.meshList[layertobesaved], outmeshlist[ii].mask, outmeshlist[ii].filename, outmeshlist[ii].writebinary, logfp); if (exported) fprintf(logfp, "Mesh %s saved as %s (%i vn %i fn)\n", qUtf8Printable(meshmod->fullName()), qUtf8Printable(outmeshlist[ii].filename), meshmod->cm.vn, meshmod->cm.fn); else @@ -1046,7 +1067,7 @@ int main(int argc, char *argv[]) } else fprintf(logfp, "Invalid layer number %i. Last layer in the current document is the number %i. Output mesh %s will not be saved\n", outmeshlist[ii].layerposition, meshDocument.meshList.size() - 1, qUtf8Printable(outmeshlist[ii].filename)); - } + }//for(int ii if((logfp != NULL) && (logfp != stdout)) diff --git a/src/meshlabserver/meshlabserver.txt b/src/meshlabserver/meshlabserver.txt index 16f0df27e..083d72aa9 100644 --- a/src/meshlabserver/meshlabserver.txt +++ b/src/meshlabserver/meshlabserver.txt @@ -52,7 +52,8 @@ meshlabserver [logargs] [args] wn-> wedge normals, wt -> wedge texture coords, mp -> polygonal mesh info - + sa -> save in ascii format + -s filename the script to be applied