Corrected a bug in the RemoveUnreferencedVertex. It considered only faces and removed vertices referenced by edges

This commit is contained in:
Paolo Cignoni 2012-03-14 16:01:30 +00:00
parent f58551601a
commit c4e116a42a
1 changed files with 10 additions and 3 deletions

View File

@ -335,6 +335,7 @@ private:
static int RemoveUnreferencedVertex( MeshType& m, bool DeleteVertexFlag=true) // V1.0 static int RemoveUnreferencedVertex( MeshType& m, bool DeleteVertexFlag=true) // V1.0
{ {
FaceIterator fi; FaceIterator fi;
EdgeIterator ei;
VertexIterator vi; VertexIterator vi;
int referredBit = VertexType::NewBitFlag(); int referredBit = VertexType::NewBitFlag();
@ -349,14 +350,20 @@ private:
for(j=0;j<3;++j) for(j=0;j<3;++j)
(*fi).V(j)->SetUserBit(referredBit); (*fi).V(j)->SetUserBit(referredBit);
for(ei=m.edge.begin();ei!=m.edge.end();++ei)
if( !(*ei).IsD() ){
(*ei).V(0)->SetUserBit(referredBit);
(*ei).V(1)->SetUserBit(referredBit);
}
for(vi=m.vert.begin();vi!=m.vert.end();++vi) for(vi=m.vert.begin();vi!=m.vert.end();++vi)
if( (!(*vi).IsD()) && (!(*vi).IsUserBit(referredBit))) if( (!(*vi).IsD()) && (!(*vi).IsUserBit(referredBit)))
{ {
if(DeleteVertexFlag) Allocator<MeshType>::DeleteVertex(m,*vi); if(DeleteVertexFlag) Allocator<MeshType>::DeleteVertex(m,*vi);
++deleted; ++deleted;
} }
VertexType::DeleteBitFlag(referredBit); VertexType::DeleteBitFlag(referredBit);
return deleted; return deleted;
} }
/** /**