Added saving of edges only if requested in the mask (or if there are no face)

This commit is contained in:
Paolo Cignoni 2012-11-08 18:48:07 +00:00
parent d4cf2019bf
commit 63faedbb88
1 changed files with 21 additions and 18 deletions

View File

@ -362,8 +362,8 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
for(i=0;i<pi.fdn;i++) for(i=0;i<pi.fdn;i++)
fprintf(fpout,"property %s %s\n",pi.FaceData[i].stotypename(),pi.FaceData[i].propname); fprintf(fpout,"property %s %s\n",pi.FaceData[i].stotypename(),pi.FaceData[i].propname);
// Saving of edges // Saving of edges is enabled if requested
if(m.en>0) if( m.en>0 && (pi.mask & Mask::IOM_EDGEINDEX) )
fprintf(fpout, fprintf(fpout,
"element edge %d\n" "element edge %d\n"
"property int vertex1\n" "property int vertex1\n"
@ -715,23 +715,26 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
} }
assert(fcnt==m.fn); assert(fcnt==m.fn);
int eauxvv[2]; int eauxvv[2];
int ecnt=0; if( pi.mask & Mask::IOM_EDGEINDEX )
for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei) {
int ecnt=0;
for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei)
{
if( ! ei->IsD() )
{ {
if( ! ei->IsD() ) ++ecnt;
{ if(binary)
++ecnt; {
if(binary) eauxvv[0]=indices[ei->cV(0)];
{ eauxvv[1]=indices[ei->cV(1)];
eauxvv[0]=indices[ei->cV(0)]; fwrite(vv,sizeof(int),2,fpout);
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)]);
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; return 0;
} }