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++)
fprintf(fpout,"property %s %s\n",pi.FaceData[i].stotypename(),pi.FaceData[i].propname);
// Saving of edges
if(m.en>0)
// 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;
}