From 07de5590ffb92ac391dfe483141b09fcc3255c2f Mon Sep 17 00:00:00 2001 From: Paolo Cignoni Date: Thu, 29 Nov 2018 00:32:58 +0100 Subject: [PATCH] Added support of polygonal mesh to OFF (not only bitpoly also the plain poly mesh) --- wrap/io_trimesh/export_off.h | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/wrap/io_trimesh/export_off.h b/wrap/io_trimesh/export_off.h index 26a0e019..c3a54f99 100644 --- a/wrap/io_trimesh/export_off.h +++ b/wrap/io_trimesh/export_off.h @@ -77,17 +77,9 @@ public: fprintf(fpout,"%d %d 0\n", m.vn, polynumber); // note that as edge number we simply write zero //vertices - int j; - std::vector FlagV; - VertexPointer vp; - VertexIterator vi; const int DGT = vcg::tri::io::Precision::digits(); - - for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi) + for(auto vp=m.vert.begin();vp!=m.vert.end();++vp) { - vp=&(*vi); - if (vcg::tri::HasPerVertexFlags(m)) - FlagV.push_back(vp->Flags()); // Save vertex flags if( ! vp->IsD() ) { // ***** ASCII ***** @@ -102,15 +94,9 @@ public: fprintf(fpout,"%g %g ",vp->T().u(),vp->T().v()); fprintf(fpout,"\n"); - - - vp->Flags()=j; // Trucco! Nascondi nei flags l'indice del vertice non deletato! - j++; } } - assert(j==m.vn); - if (mask &io::Mask::IOM_BITPOLYGONAL) { tri::RequireFFAdjacency(m); @@ -131,19 +117,16 @@ public: { if( ! fi->IsD() ) { + fprintf(fpout,"%i ",fi->VN()); + for(int i=0;iVN();++i) + fprintf(fpout,"%lu ",tri::Index(m,fi->V(i))); if( tri::HasPerFaceColor(m) && (mask & io::Mask::IOM_FACECOLOR) ) - fprintf(fpout,"3 %d %d %d %i %i %i\n", fi->cV(0)->Flags(), fi->cV(1)->Flags(), fi->cV(2)->Flags(), fi->C()[0],fi->C()[1],fi->C()[2] ); - else - fprintf(fpout,"3 %d %d %d\n", fi->cV(0)->Flags(), fi->cV(1)->Flags(), fi->cV(2)->Flags() ); + fprintf(fpout,"%i %i %i", fi->C()[0],fi->C()[1],fi->C()[2] ); + fprintf(fpout,"\n"); } } } - // Recupera i flag originali - j=0; - for(vi=m.vert.begin();vi!=m.vert.end();++vi) - (*vi).Flags()=FlagV[j++]; - int result = 0; if (ferror(fpout)) result = 2; fclose(fpout);