better uniform naming for detach attach functions (now there is FFAttach, FFAttachManifold, FFDetach, etc)
changed SharedVertex into FindSharedVertex added FindSharedEdge
This commit is contained in:
parent
500a478e14
commit
2aa57698ad
|
|
@ -238,7 +238,7 @@ void FFDetach(FaceType & f, const int e)
|
||||||
@param z2 The edge of the face f2
|
@param z2 The edge of the face f2
|
||||||
*/
|
*/
|
||||||
template <class FaceType>
|
template <class FaceType>
|
||||||
void Attach(FaceType * &f, int z1, FaceType *&f2, int z2)
|
void FFAttach(FaceType * &f, int z1, FaceType *&f2, int z2)
|
||||||
{
|
{
|
||||||
//typedef FEdgePosB< FACE_TYPE > ETYPE;
|
//typedef FEdgePosB< FACE_TYPE > ETYPE;
|
||||||
Pos< FaceType > EPB(f2,z2);
|
Pos< FaceType > EPB(f2,z2);
|
||||||
|
|
@ -261,6 +261,35 @@ void Attach(FaceType * &f, int z1, FaceType *&f2, int z2)
|
||||||
TEPB.f->FFi(TEPB.z) = z1prec;
|
TEPB.f->FFi(TEPB.z) = z1prec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** This function attach the face (via the edge z1) to another face (via the edge z2).
|
||||||
|
It is not possible to use it also in non-two manifold situation.
|
||||||
|
The function cannot be applicated if the adjacencies among faces aren't define.
|
||||||
|
@param z1 Index of the edge
|
||||||
|
@param f2 Pointer to the face
|
||||||
|
@param z2 The edge of the face f2
|
||||||
|
*/
|
||||||
|
template <class FaceType>
|
||||||
|
void FFAttachManifold(FaceType * &f1, int z1, FaceType *&f2, int z2)
|
||||||
|
{
|
||||||
|
assert(IsBorder<FaceType>(*f1,z1));
|
||||||
|
assert(IsBorder<FaceType>(*f2,z2));
|
||||||
|
assert(f1->V0(z1) == f2->V0(z2) || f1->V0(z1) == f2->V1(z2));
|
||||||
|
assert(f1->V1(z1) == f2->V0(z2) || f1->V1(z1) == f2->V1(z2));
|
||||||
|
f1->FFp(z1) = f2;
|
||||||
|
f1->FFi(z1) = z2;
|
||||||
|
f2->FFp(z2) = f1;
|
||||||
|
f2->FFi(z2) = z1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This one should be called only on uniitialized faces.
|
||||||
|
template <class FaceType>
|
||||||
|
void FFSetBorder(FaceType * &f1, int z1)
|
||||||
|
{
|
||||||
|
assert(f1->FFp(z1)==0 || IsBorder(*f1,z1));
|
||||||
|
|
||||||
|
f1->FFp(z1)=f1;
|
||||||
|
f1->FFi(z1)=z1;
|
||||||
|
}
|
||||||
|
|
||||||
template <class FaceType>
|
template <class FaceType>
|
||||||
void AssertAdj(FaceType & f)
|
void AssertAdj(FaceType & f)
|
||||||
|
|
@ -273,15 +302,6 @@ void AssertAdj(FaceType & f)
|
||||||
assert(f.FFp(1)->FFi(f.FFi(1))==1);
|
assert(f.FFp(1)->FFi(f.FFi(1))==1);
|
||||||
assert(f.FFp(2)->FFi(f.FFi(2))==2);
|
assert(f.FFp(2)->FFi(f.FFi(2))==2);
|
||||||
}
|
}
|
||||||
// Funzione di supporto usata da swap?
|
|
||||||
//template <class FaceType>
|
|
||||||
//inline void Nexts( *&f, int &z )
|
|
||||||
//{
|
|
||||||
// int t;
|
|
||||||
// t = z;
|
|
||||||
// z = (*f).Z(z);
|
|
||||||
// f = (*f).F(t);
|
|
||||||
//}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given face is oriented as the one adjacent to the specified edge.
|
* Check if the given face is oriented as the one adjacent to the specified edge.
|
||||||
|
|
@ -611,42 +631,42 @@ void VFStarVF( typename FaceType::VertexType* vp, std::vector<FaceType *> &faceV
|
||||||
* \param faceVec a std::vector of Face pointer that is filled with the adjacent faces.
|
* \param faceVec a std::vector of Face pointer that is filled with the adjacent faces.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template <class FaceType>
|
template <class FaceType>
|
||||||
static void VFOrderedStarVF_FF(typename FaceType::VertexType &vp,
|
static void VFOrderedStarVF_FF(typename FaceType::VertexType &vp,
|
||||||
std::vector<FaceType*> &faceVec)
|
std::vector<FaceType*> &faceVec)
|
||||||
{
|
{
|
||||||
|
|
||||||
///check that is not on border..
|
///check that is not on border..
|
||||||
assert (!vp.IsB());
|
assert (!vp.IsB());
|
||||||
|
|
||||||
///get first face sharing the edge
|
///get first face sharing the edge
|
||||||
FaceType *f_init=vp.VFp();
|
FaceType *f_init=vp.VFp();
|
||||||
int edge_init=vp.VFi();
|
int edge_init=vp.VFi();
|
||||||
|
|
||||||
///and initialize the pos
|
///and initialize the pos
|
||||||
vcg::face::Pos<FaceType> VFI(f_init,edge_init);
|
vcg::face::Pos<FaceType> VFI(f_init,edge_init);
|
||||||
bool complete_turn=false;
|
bool complete_turn=false;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
FaceType *curr_f=VFI.F();
|
FaceType *curr_f=VFI.F();
|
||||||
faceVec.push_back(curr_f);
|
faceVec.push_back(curr_f);
|
||||||
|
|
||||||
int curr_edge=VFI.E();
|
int curr_edge=VFI.E();
|
||||||
|
|
||||||
///assert that is not a border edge
|
///assert that is not a border edge
|
||||||
assert(curr_f->FFp(curr_edge)!=curr_f);
|
assert(curr_f->FFp(curr_edge)!=curr_f);
|
||||||
|
|
||||||
///continue moving
|
///continue moving
|
||||||
VFI.FlipF();
|
VFI.FlipF();
|
||||||
VFI.FlipE();
|
VFI.FlipE();
|
||||||
|
|
||||||
FaceType *next_f=VFI.F();
|
FaceType *next_f=VFI.F();
|
||||||
|
|
||||||
///test if I've finiseh with the face exploration
|
///test if I've finiseh with the face exploration
|
||||||
complete_turn=(next_f==f_init);
|
complete_turn=(next_f==f_init);
|
||||||
/// or if I've just crossed a mismatch
|
/// or if I've just crossed a mismatch
|
||||||
}while (!complete_turn);
|
}while (!complete_turn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -695,15 +715,33 @@ int CountSharedVertex(FaceType *f0,FaceType *f1)
|
||||||
* ;
|
* ;
|
||||||
*/
|
*/
|
||||||
template <class FaceType>
|
template <class FaceType>
|
||||||
bool SharedVertex(FaceType *f0,FaceType *f1, int &i, int &j)
|
bool FindSharedVertex(FaceType *f0,FaceType *f1, int &i, int &j)
|
||||||
{
|
{
|
||||||
for (i=0;i<3;i++)
|
for (i=0;i<3;i++)
|
||||||
for (j=0;j<3;j++)
|
for (j=0;j<3;j++)
|
||||||
if (f0->V(i)==f1->V(j)) return true;
|
if (f0->V(i)==f1->V(j)) return true;
|
||||||
|
|
||||||
|
i=-1;j=-1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* find the first shared edge between two faces.
|
||||||
|
* \param f0,f1 the two face to be checked
|
||||||
|
* \param i,j the indexes of the shared edge in the two faces. Meaningful only if there is a shared edge
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
template <class FaceType>
|
||||||
|
bool FindSharedEdge(FaceType *f0,FaceType *f1, int &i, int &j)
|
||||||
|
{
|
||||||
|
for (i=0;i<3;i++)
|
||||||
|
for (j=0;j<3;j++)
|
||||||
|
if( ( f0->V0(i)==f1->V0(j) || f0->V0(i)==f1->V1(j) ) &&
|
||||||
|
( f0->V1(i)==f1->V0(j) || f0->V1(i)==f1->V1(j) ) )
|
||||||
|
return true;
|
||||||
|
i=-1;j=-1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue