From 63faedbb88225707228a49a4bf7d5309fb7f5574 Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 8 Nov 2012 18:48:07 +0000 Subject: [PATCH] Added saving of edges only if requested in the mask (or if there are no face) --- wrap/io_trimesh/export_ply.h | 39 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/wrap/io_trimesh/export_ply.h b/wrap/io_trimesh/export_ply.h index c48ba21d..00955b33 100644 --- a/wrap/io_trimesh/export_ply.h +++ b/wrap/io_trimesh/export_ply.h @@ -362,8 +362,8 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p for(i=0;i0) + // Saving of edges is enabled if requested + if( m.en>0 && (pi.mask & Mask::IOM_EDGEINDEX) ) fprintf(fpout, "element edge %d\n" "property int vertex1\n" @@ -715,24 +715,27 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p } assert(fcnt==m.fn); int eauxvv[2]; - int ecnt=0; - for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei) + if( pi.mask & Mask::IOM_EDGEINDEX ) + { + int ecnt=0; + for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei) + { + if( ! ei->IsD() ) { - if( ! ei->IsD() ) - { - ++ecnt; - if(binary) - { - eauxvv[0]=indices[ei->cV(0)]; - eauxvv[1]=indices[ei->cV(1)]; - fwrite(vv,sizeof(int),2,fpout); - } - else // ***** ASCII ***** - fprintf(fpout,"%d %d \n", indices[ei->cV(0)], indices[ei->cV(1)]); - } + ++ecnt; + if(binary) + { + eauxvv[0]=indices[ei->cV(0)]; + eauxvv[1]=indices[ei->cV(1)]; + fwrite(vv,sizeof(int),2,fpout); + } + else // ***** ASCII ***** + fprintf(fpout,"%d %d \n", indices[ei->cV(0)], indices[ei->cV(1)]); + } + } + assert(ecnt==m.en); } - assert(ecnt==m.en); - fclose(fpout); + fclose(fpout); return 0; }