Added support of polygonal mesh to OFF

(not only bitpoly also the plain poly mesh)
This commit is contained in:
Paolo Cignoni 2018-11-29 00:32:58 +01:00
parent 280ea2dd42
commit 07de5590ff
1 changed files with 6 additions and 23 deletions
wrap/io_trimesh

View File

@ -77,17 +77,9 @@ public:
fprintf(fpout,"%d %d 0\n", m.vn, polynumber); // note that as edge number we simply write zero fprintf(fpout,"%d %d 0\n", m.vn, polynumber); // note that as edge number we simply write zero
//vertices //vertices
int j;
std::vector<int> FlagV;
VertexPointer vp;
VertexIterator vi;
const int DGT = vcg::tri::io::Precision<ScalarType>::digits(); const int DGT = vcg::tri::io::Precision<ScalarType>::digits();
for(auto vp=m.vert.begin();vp!=m.vert.end();++vp)
for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi)
{ {
vp=&(*vi);
if (vcg::tri::HasPerVertexFlags(m))
FlagV.push_back(vp->Flags()); // Save vertex flags
if( ! vp->IsD() ) if( ! vp->IsD() )
{ // ***** ASCII ***** { // ***** ASCII *****
@ -102,15 +94,9 @@ public:
fprintf(fpout,"%g %g ",vp->T().u(),vp->T().v()); fprintf(fpout,"%g %g ",vp->T().u(),vp->T().v());
fprintf(fpout,"\n"); 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) { if (mask &io::Mask::IOM_BITPOLYGONAL) {
tri::RequireFFAdjacency(m); tri::RequireFFAdjacency(m);
@ -131,19 +117,16 @@ public:
{ {
if( ! fi->IsD() ) if( ! fi->IsD() )
{ {
fprintf(fpout,"%i ",fi->VN());
for(int i=0;i<fi->VN();++i)
fprintf(fpout,"%lu ",tri::Index(m,fi->V(i)));
if( tri::HasPerFaceColor(m) && (mask & io::Mask::IOM_FACECOLOR) ) 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] ); fprintf(fpout,"%i %i %i", fi->C()[0],fi->C()[1],fi->C()[2] );
else fprintf(fpout,"\n");
fprintf(fpout,"3 %d %d %d\n", fi->cV(0)->Flags(), fi->cV(1)->Flags(), fi->cV(2)->Flags() );
} }
} }
} }
// Recupera i flag originali
j=0;
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
(*vi).Flags()=FlagV[j++];
int result = 0; int result = 0;
if (ferror(fpout)) result = 2; if (ferror(fpout)) result = 2;
fclose(fpout); fclose(fpout);