Fix IsOrientedMesh
This commit is contained in:
parent
47da0f6a24
commit
34acf11b61
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.23 2005/12/16 13:13:44 cignoni
|
||||
Reimplemented SelfIntersection
|
||||
|
||||
Revision 1.22 2005/12/16 10:54:59 corsini
|
||||
Reimplement isOrientedMesh
|
||||
|
||||
|
@ -606,35 +609,75 @@ namespace vcg {
|
|||
|
||||
static void IsOrientedMesh(MeshType &m, bool &Oriented, bool &Orientable)
|
||||
{
|
||||
FaceIterator fi;
|
||||
// This algorithms requires FF topology
|
||||
assert(m.HasFFTopology());
|
||||
|
||||
Orientable = true;
|
||||
Oriented = true;
|
||||
|
||||
// check the orientation of each face
|
||||
// Ensure that each face is deselected
|
||||
FaceIterator fi;
|
||||
for (fi = m.face.begin(); fi != m.face.end(); ++fi)
|
||||
fi->ClearS();
|
||||
|
||||
// initialize stack
|
||||
stack<FacePointer> faces;
|
||||
|
||||
// for each face of the mesh
|
||||
FacePointer fp,fpaux;
|
||||
int iaux;
|
||||
for (fi = m.face.begin(); fi != m.face.end(); ++fi)
|
||||
{
|
||||
if (!fi->IsD())
|
||||
if (!fi->IsD() && !fi->IsS())
|
||||
{
|
||||
// each face put in the stack is selected (and oriented)
|
||||
fi->SetS();
|
||||
faces.push(&(*fi));
|
||||
|
||||
// empty the stack
|
||||
while (!faces.empty())
|
||||
{
|
||||
fp = faces.top();
|
||||
faces.pop();
|
||||
|
||||
// make consistently oriented the adjacent faces
|
||||
for (int j = 0; j < 3; j++)
|
||||
if (!CheckOrientation(*fi, j))
|
||||
{
|
||||
// get one of the adjacent face
|
||||
fpaux = fp->FFp(j);
|
||||
iaux = fp->FFi(j);
|
||||
|
||||
if (!fpaux->IsD() && fpaux != fp)
|
||||
{
|
||||
if (!CheckOrientation(*fpaux, iaux))
|
||||
{
|
||||
Oriented = false;
|
||||
|
||||
// if this face has just been swapped the mesh is not orientable
|
||||
if (fi->IsS())
|
||||
if (!fpaux->IsS())
|
||||
{
|
||||
SwapEdge(*fpaux, iaux);
|
||||
assert(CheckOrientation(*fpaux, iaux));
|
||||
}
|
||||
else
|
||||
Orientable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
SwapEdge(*fi, j);
|
||||
fi->SetS();
|
||||
assert(CheckOrientation(*fi, j));
|
||||
// put the oriented face into the stack
|
||||
|
||||
if (!fpaux->IsS())
|
||||
{
|
||||
fpaux->SetS();
|
||||
faces.push(fpaux);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Orientable)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool SelfIntersections(MeshType &m, std::vector<FaceType*> &ret)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue