remove crash when all vertices and faces have been marked as deleted but the are still in the vert/face vectors

This commit is contained in:
granzuglia 2011-04-15 08:46:43 +00:00
parent 017323e803
commit f3969b8774
1 changed files with 7 additions and 3 deletions

View File

@ -438,8 +438,8 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi){ for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi){
vp=&(*vi); vp=&(*vi);
indices[vi] = j; indices[vi] = j;
//((m.vn+m.fn) != 0) all vertices and faces have been marked as deleted but the are still in the vert/face vectors
if(cb && ((j%1000)==0))(*cb)( (100*j)/(m.vn+m.fn), "Saving Vertices"); if(cb && ((j%1000)==0) && ((m.vn+m.fn) != 0) )(*cb)( (100*j)/(m.vn+m.fn), "Saving Vertices");
if( !HasPerVertexFlags(m) || !vp->IsD() ) if( !HasPerVertexFlags(m) || !vp->IsD() )
{ {
@ -533,6 +533,7 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
j++; j++;
} }
} }
/*vcg::tri::*/
// this assert triggers when the vn != number of vertexes in vert that are not deleted. // this assert triggers when the vn != number of vertexes in vert that are not deleted.
assert(j==m.vn); assert(j==m.vn);
@ -545,7 +546,9 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
int fcnt=0; int fcnt=0;
for(j=0,fi=m.face.begin();fi!=m.face.end();++fi) for(j=0,fi=m.face.begin();fi!=m.face.end();++fi)
{ {
if(cb && ((j%1000)==0) ) (*cb)( 100*(m.vn+j)/(m.vn+m.fn), "Saving Vertices"); //((m.vn+m.fn) != 0) all vertices and faces have been marked as deleted but the are still in the vert/face vectors
if(cb && ((j%1000)==0) && ((m.vn+m.fn) != 0))
(*cb)( 100*(m.vn+j)/(m.vn+m.fn), "Saving Vertices");
fp=&(*fi); fp=&(*fi);
if( ! fp->IsD() ) if( ! fp->IsD() )
@ -760,6 +763,7 @@ static const char *ErrorMsg(int error)
capability |= vcg::tri::io::Mask::IOM_WEDGTEXMULTI ; capability |= vcg::tri::io::Mask::IOM_WEDGTEXMULTI ;
capability |= vcg::tri::io::Mask::IOM_WEDGNORMAL ; capability |= vcg::tri::io::Mask::IOM_WEDGNORMAL ;
capability |= vcg::tri::io::Mask::IOM_CAMERA ; capability |= vcg::tri::io::Mask::IOM_CAMERA ;
capability |= vcg::tri::io::Mask::IOM_BITPOLYGONAL;
return capability; return capability;
} }