From feb77d945adab35eb9d03753c2e38b84f75abc96 Mon Sep 17 00:00:00 2001 From: cignoni Date: Sat, 10 Nov 2012 16:53:10 +0000 Subject: [PATCH] Significant changes of interface of VFOrderedStarFF (that substitute two very similar VFOrderedStarFF_VF) Added EFStarFF --- vcg/simplex/face/topology.h | 157 +++++++++++++----------------------- 1 file changed, 58 insertions(+), 99 deletions(-) diff --git a/vcg/simplex/face/topology.h b/vcg/simplex/face/topology.h index e65aa2bb..14746b7c 100644 --- a/vcg/simplex/face/topology.h +++ b/vcg/simplex/face/topology.h @@ -582,7 +582,8 @@ void VFAppend(FaceType* & f, int z) } /*! -* Compute the set of vertices adjacent to a given vertex using VF adjacency. +* \brief Compute the set of vertices adjacent to a given vertex using VF adjacency +* * \param vp pointer to the vertex whose star has to be computed. * \param starVec a std::vector of Vertex pointer that is filled with the adjacent vertices. * @@ -606,27 +607,10 @@ void VVStarVF( typename FaceType::VertexType* vp, std::vector -void VFStarVF( typename FaceType::VertexType* vp, std::vector &faceVec) -{ - typedef typename FaceType::VertexType* VertexPointer; - faceVec.clear(); - face::VFIterator vfi(vp); - while(!vfi.End()) - { - faceVec.push_back(vfi.F()); - ++vfi; - } -} /*! -* Compute the set of faces adjacent to a given vertex using VF adjacency. +* \brief Compute the set of faces adjacent to a given vertex using VF adjacency. +* * \param vp pointer to the vertex whose star has to be computed. * \param faceVec a std::vector of Face pointer that is filled with the adjacent faces. * \param indexes a std::vector of integer of the vertex as it is seen from the faces @@ -638,6 +622,7 @@ void VFStarVF( typename FaceType::VertexType* vp, { typedef typename FaceType::VertexType* VertexPointer; faceVec.clear(); + indexes.clear(); face::VFIterator vfi(vp); while(!vfi.End()) { @@ -648,6 +633,36 @@ void VFStarVF( typename FaceType::VertexType* vp, } +/*! +* \brief Compute the set of faces incident onto a given edge using FF adjacency. +* +* \param fp pointer to the face whose star has to be computed +* \param ei the index of the edge +* \param faceVec a std::vector of Face pointer that is filled with the faces incident on that edge. +* \param indexes a std::vector of integer of the edge position as it is seen from the faces +*/ +template +void EFStarFF( FaceType* fp, int ei, + std::vector &faceVec, + std::vector &indVed) +{ + assert(fp->FFp(ei)!=0); + faceVec.clear(); + indVed.clear(); + FaceType* fpit=fp; + int eit=ei; + do + { + faceVec.push_back(fpit); + indVed.push_back(eit); + FaceType *new_fpit = fpit->FFp(eit); + int new_eit = fpit->FFi(eit); + fpit=new_fpit; + eit=new_eit; + } while(fpit != fp); +} + + /*! * Compute the set of faces adjacent to a given vertex using VF adjacency. * The set is faces is extended of a given number of step @@ -687,91 +702,35 @@ static void VFExtendedStarVF(typename FaceType::VertexType* vp, } /*! -* Compute the ordered set of faces adjacent to a given vertex using VF adjacency.and FF adiacency -* \param vp pointer to the vertex whose star has to be computed. +* Compute the ordered set of faces adjacent to a given vertex using FF adiacency +* \param startPos a Pos indicating the vertex whose star has to be computed. * \param faceVec a std::vector of Face pointer that is filled with the adjacent faces. +* \param edgeVec a std::vector of indexes filled with the indexes of the corresponding edges shared between the faces. * */ template -static void VFOrderedStarVF_FF(const typename FaceType::VertexType &vp, - std::vector &faceVec) +static void VFOrderedStarFF(Pos &startPos, + std::vector &faceVec, + std::vector &edgeVec) { + bool foundBorder=false; + Pos curPos=startPos; + do + { + assert(curPos.IsManifold()); + if(curPos.IsBorder()) foundBorder=true; - ///check that is not on border.. - assert (!vp.IsB()); - - ///get first face sharing the edge - FaceType *f_init=vp.cVFp(); - int edge_init=vp.cVFi(); - - ///and initialize the pos - vcg::face::Pos VFI(f_init,edge_init); - bool complete_turn=false; - do - { - FaceType *curr_f=VFI.F(); - faceVec.push_back(curr_f); - - int curr_edge=VFI.E(); - - ///assert that is not a border edge - assert(curr_f->FFp(curr_edge)!=curr_f); - - ///continue moving - VFI.FlipF(); - VFI.FlipE(); - - FaceType *next_f=VFI.F(); - - ///test if I've finiseh with the face exploration - complete_turn=(next_f==f_init); - /// or if I've just crossed a mismatch - }while (!complete_turn); -} - - -/*! -* Compute the ordered set of faces adjacent to a given vertex using VF adjacency.and FF adiacency -* \param vp pointer to the vertex whose star has to be computed. -* \param faceVec a std::vector of Face pointer that is filled with the adjacent faces. -* -*/ -template -static void VFOrderedStarVF_FF(const typename FaceType::VertexType &vp, - std::vector &faceVec, - std::vector &edgeVec) -{ - - ///check that is not on border.. - assert (!vp.IsB()); - - ///get first face sharing the edge - FaceType *f_init=vp.cVFp(); - int edge_init=vp.cVFi(); - - ///and initialize the pos - vcg::face::Pos VFI(f_init,edge_init); - bool complete_turn=false; - do - { - FaceType *curr_f=VFI.F(); - faceVec.push_back(curr_f); - - int curr_edge=VFI.E(); - edgeVec.push_back(curr_edge); - ///assert that is not a border edge - assert(curr_f->FFp(curr_edge)!=curr_f); - - ///continue moving - VFI.FlipF(); - VFI.FlipE(); - - FaceType *next_f=VFI.F(); - - ///test if I've finiseh with the face exploration - complete_turn=(next_f==f_init); - /// or if I've just crossed a mismatch - }while (!complete_turn); + faceVec.push_back(curPos.F()); + edgeVec.push_back(curPos.E()); + curPos.FlipF(); + curPos.FlipE(); + } while(curPos!=startPos); + if(foundBorder) + { + assert((faceVec.size()%2)==0); // if we found a border we visited each face exactly twice. + faceVec.resize(faceVec.size()/2); + edgeVec.resize(edgeVec.size()/2); + } } /*!