Commit a79af175 authored by Pierre Kraemer's avatar Pierre Kraemer

la suite..

parent b0022134
......@@ -32,13 +32,14 @@ namespace CGoGN
/**
* Class of 2-dimensional maps
* with lazily managed embeddings
* with managed embeddings
*/
template <typename MAP2>
class EmbeddedMap2 : public MAP2
{
public:
typedef MAP2 TOPO_MAP;
/**
* The attributes attached to the old vertex are duplicated on both resulting vertices
* No attribute is attached to the new edge
......@@ -65,7 +66,7 @@ public:
/**
* The attributes attached to the edge of d are kept on the resulting edge
*/
virtual void uncutEdge(Dart d) ;
virtual bool uncutEdge(Dart d) ;
/**
* Check if the edge of d can be collapsed or not based on some topological conditions
......
......@@ -102,23 +102,20 @@ void EmbeddedMap2<MAP2>::cutEdge(Dart d)
{
MAP2::copyDartEmbedding(FACE, MAP2::phi1(d), d) ;
Dart e = MAP2::phi2(nd) ;
if(e != nd)
MAP2::copyDartEmbedding(FACE, MAP2::phi1(e), e) ;
MAP2::copyDartEmbedding(FACE, MAP2::phi1(e), e) ;
}
}
template <typename MAP2>
void EmbeddedMap2<MAP2>::uncutEdge(Dart d)
bool EmbeddedMap2<MAP2>::uncutEdge(Dart d)
{
bool doSomethg = (d != MAP2::phi2(d)) ;
MAP2::uncutEdge(d) ;
if(doSomethg)
if(MAP2::uncutEdge(d))
{
if(MAP2::isOrbitEmbedded(EDGE))
MAP2::copyDartEmbedding(EDGE, MAP2::phi2(d), d) ;
return true ;
}
return false ;
}
template <typename MAP2>
......
......@@ -130,31 +130,32 @@ public:
* @param d first dart in vertex v
* @param e second dart in vertex v
*/
virtual void splitVertex(Dart d, Dart e);
virtual void splitVertex(Dart d, Dart e); // OK boundary
//! Delete the vertex of d (works only for internal vertices)
/*! All the faces around the vertex are merged into one face
* @param d a dart of the vertex to delete
* @return true if the deletion has been executed, false otherwise
*/
virtual bool deleteVertex(Dart d) ;
virtual bool deleteVertex(Dart d) ; // OK boundary
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
virtual void linkVertices(Dart d, Dart e);
virtual void linkVertices(Dart d, Dart e); //TODO removing ??
//! Cut the edge of d and its opposite edge if it exists
//! Cut the edge of d
/*! @param d a dart of the edge to cut
*/
virtual void cutEdge(Dart d);
virtual void cutEdge(Dart d);// OK boundary
//! Undo the cut of the edge of d and its opposite edge if it exists
//! Undo the cut of the edge of d
/*! @param d a dart of the edge to uncut
* @return true if the uncut has been executed, false otherwise
*/
virtual void uncutEdge(Dart d);
virtual bool uncutEdge(Dart d);// OK boundary
//! Collapse an edge (that is deleted) possibly merging its vertices
/*! If delDegenerateFaces is true, the method checks that no degenerate
......@@ -336,10 +337,15 @@ public:
Dart findBoundaryVertex(Dart d);
/**
* tell if the vertex of d is on the boundary of the map
* tell if the edge of d is on the boundary of the map
*/
bool isBoundaryEdge(Dart d) ; // OK boundary
/**
* tell if the face of d is on the boundary of the map
*/
bool isBoundaryFace(Dart d) ;
//! Follow the boundary of a surface as if it was a oriented face.
/*! This operation alternate phi1 and phi2 operator until another
......
......@@ -150,7 +150,7 @@ public:
//! Uncut the edge of d
/*! @param d a dart of the edge to uncut
*/
virtual void uncutEdge(Dart d);
virtual bool uncutEdge(Dart d);
//!
/*!
......
......@@ -138,10 +138,9 @@ void Map2::cutEdge(Dart d)
phi2sew(d, ne); // Correct the phi2 links
phi2sew(e, nd);
}
void Map2::uncutEdge(Dart d)
bool Map2::uncutEdge(Dart d)
{
// assert(vertexDegree(phi1(d)) == 2) ;
// Dart ne = phi2(d) ;
......@@ -158,15 +157,19 @@ void Map2::uncutEdge(Dart d)
// phi2sew(d, e) ;
// }
assert(vertexDegree(phi1(d)) == 2) ;
Dart ne = phi2(d) ;
Dart nd = phi1(d) ;
Dart e = phi_1(ne) ;
phi2unsew(e) ;
phi2unsew(d) ;
Map1::collapseEdge(nd) ;
Map1::collapseEdge(ne) ;
phi2sew(d, e) ;
if(vertexDegree(phi1(d)) == 2)
{
Dart ne = phi2(d) ;
Dart nd = phi1(d) ;
Dart e = phi_1(ne) ;
phi2unsew(e) ;
phi2unsew(d) ;
Map1::collapseEdge(nd) ;
Map1::collapseEdge(ne) ;
phi2sew(d, e) ;
return true ;
}
return false ;
}
Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces)
......@@ -219,7 +222,7 @@ Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces)
//
// return resV ;
Dart resV=Dart::nil() ;
Dart resV = NIL ;
Dart e = phi2(d);
phi2unsew(d); // Unlink the opposite edges
......@@ -228,7 +231,7 @@ Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces)
{
Dart f = phi1(e) ;
Map1::collapseEdge(e) ; // Collapse edge e
if (f!=e)
if (f != e)
collapseDegeneratedFace(f) ;// and collapse its face if degenerated
}
else
......@@ -256,7 +259,7 @@ Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces)
{
Dart f = phi1(d) ;
Map1::collapseEdge(d) ; // Collapse edge d
if (f!=d)
if (f != d)
collapseDegeneratedFace(f) ;// and collapse its face if degenerated
}
else
......@@ -264,7 +267,7 @@ Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces)
Dart f = phi1(d) ;
Dart g = phi_1(d) ;
if(resV == Dart::nil())
if(resV == NIL)
{
if(f != e && !isFaceTriangle(d))
resV = f ;
......@@ -309,8 +312,6 @@ bool Map2::flipBackEdge(Dart d)
if (!isBoundaryEdge(d))
{
Dart e = phi2(d);
Dart dNext = phi1(d);
Dart eNext = phi1(e);
Dart dPrev = phi_1(d);
Dart ePrev = phi_1(e);
phi1sew(d, ePrev); // Detach the two
......@@ -324,14 +325,14 @@ bool Map2::flipBackEdge(Dart d)
void Map2::insertEdgeInVertex(Dart d, Dart e)
{
assert(!sameVertex(d,e) && phi2(e)==phi_1(e));
assert(!sameVertex(d,e) && phi2(e) == phi_1(e));
phi1sew(phi_1(d),phi_1(e));
}
void Map2::removeEdgeFromVertex(Dart d)
{
assert(phi2(d)!=d);
assert(phi2(d) != d);
phi1sew(phi_1(d),phi2(d));
}
......@@ -373,12 +374,11 @@ void Map2::unsewFaces(Dart d)
// sew faces to the boundary
phi2sew(d,e);
phi2sew(dd,phi1(e));
}
bool Map2::collapseDegeneratedFace(Dart d)
{
Dart e = phi1(d); // Check if the face is a loop
Dart e = phi1(d); // Check if the face is degenerated
if (phi1(e) == d) // Yes: it contains one or two edge(s)
{
Dart d2 = phi2(d); // Check opposite edges
......@@ -783,15 +783,6 @@ unsigned int Map2::volumeDegree(Dart d)
bool Map2::isBoundaryVertex(Dart d)
{
// Dart dNext = d ;
// do
// {
// if(phi2(dNext) == dNext)
// return true ;
// dNext = alpha1(dNext) ;
// } while (dNext != d) ;
// return false ;
Dart dNext = d ;
do
{
......@@ -814,13 +805,23 @@ Dart Map2::findBoundaryVertex(Dart d)
return Dart::nil();
}
bool Map2::isBoundaryEdge(Dart d)
{
Dart e = phi2(d);
return isBoundaryMarked(e) || isBoundaryMarked(d);
return isBoundaryMarked(e) || isBoundaryMarked(d);
}
bool Map2::isBoundaryFace(Dart d)
{
Dart it = d ;
do
{
if (isBoundaryMarked(phi2(it)))
return true ;
it = phi1(it) ;
} while (it != d) ;
return false ;
}
Dart Map2::nextOnBoundary(Dart d)
{
......@@ -853,15 +854,10 @@ bool Map2::isTriangular()
if(!m.isMarked(d))
{
m.markOrbit(FACE, d) ;
Dart dd = d ; // ???
if (!isBoundaryMarked(d))
{
bool t = isFaceTriangle(d) ;
if(!t)
{
if(!isFaceTriangle(d))
return false ;
}
}
}
}
......@@ -880,6 +876,11 @@ bool Map2::check()
CGoGNout << "Check: phi2 is not an involution" << CGoGNendl;
return false;
}
if(d2 == d)
{
CGoGNout << "Check: phi2 fixed point" << CGoGNendl;
return false;
}
Dart d1 = phi1(d);
if (phi_1(d1) != d) // phi1 a une image correcte ?
......
......@@ -178,29 +178,33 @@ void Map3::cutEdge(Dart d)
}
}
void Map3::uncutEdge(Dart d)
bool Map3::uncutEdge(Dart d)
{
if(phi3(d) == d)
d = phi_1(phi2(d));
if(vertexDegree(phi1(d)) == 2)
{
if(phi3(d) == d)
d = phi_1(phi2(d));
Dart prev = d;
Dart dd = alpha2(d);
Dart prev = d;
Dart dd = alpha2(d);
Map2::uncutEdge(prev);
Map2::uncutEdge(prev);
if(phi3(dd) != dd)
phi3sew(dd,phi2(prev));
if(phi3(dd) != dd)
phi3sew(dd,phi2(prev));
while (dd!=d)
{
prev = dd;
dd = alpha2(dd);
while (dd!=d)
{
prev = dd;
dd = alpha2(dd);
Map2::uncutEdge(prev);
Map2::uncutEdge(prev);
phi3sew(dd, phi2(prev));
phi3sew(dd, phi2(prev));
}
return true;
}
return false;
}
//besoin d'un iterator pour chaque face autour d'un sommet
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment