Refactored selection face from vertices algorithms and added requiremnts for triangular mesh for the algorithm selecting vertices starting from face border flag

This commit is contained in:
Paolo Cignoni 2014-02-19 14:38:54 +00:00
parent 85c5274965
commit 18c0ac1681
1 changed files with 91 additions and 95 deletions

View File

@ -303,16 +303,15 @@ static size_t VertexFromFaceStrict(MeshType &m)
static size_t FaceFromVertexStrict(MeshType &m)
{
size_t selCnt=0;
int i=0;
FaceClear(m);
FaceIterator fi;
for(fi = m.face.begin(); fi != m.face.end(); ++fi)
for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
if( !(*fi).IsD())
{
for(i = 0; i < (*fi).VN(); ++i)
bool selFlag=true;
for(int i = 0; i < (*fi).VN(); ++i)
if(!(*fi).V(i)->IsS())
break;
if(i == (*fi).VN())
selFlag =false;
if(selFlag)
{
(*fi).SetS();
++selCnt;
@ -325,17 +324,15 @@ static size_t FaceFromVertexStrict(MeshType &m)
static size_t FaceFromVertexLoose(MeshType &m)
{
size_t selCnt=0;
int i=0;
FaceClear(m);
FaceIterator fi;
for(fi = m.face.begin(); fi != m.face.end(); ++fi)
if( !(*fi).IsD() && !(*fi).IsS())
for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
if( !(*fi).IsD())
{
bool selVert=false;
for(int i = 0; i < (*fi).VN(); ++i)
if((*fi).V(i)->IsS())
break;
if(i < (*fi).VN())
{
if((*fi).V(i)->IsS()) selVert=true;
if(selVert) {
(*fi).SetS();
++selCnt;
}
@ -363,17 +360,16 @@ static size_t VertexFromBorderFlag(MeshType &m)
static size_t FaceFromBorderFlag(MeshType &m)
{
tri::RequireTriangularMesh(m);
size_t selCnt=0;
int i=0;
FaceClear(m);
FaceIterator fi;
for(fi = m.face.begin(); fi != m.face.end(); ++fi)
for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
if( !(*fi).IsD() )
{
for(int i = 0; i < (*fi).VN(); ++i)
if((*fi).IsB(i))
break;
if(i < (*fi).VN())
bool bordFlag=false;
for(int i = 0; i < 3; ++i)
if((*fi).IsB(i)) bordFlag=true;
if(bordFlag)
{
(*fi).SetS();
++selCnt;