Commit a08ce280 authored by untereiner's avatar untereiner

embeddedMap3 almost over !

parent d1687ca2
...@@ -152,6 +152,14 @@ public: ...@@ -152,6 +152,14 @@ public:
{} {}
}; };
template <typename MAP>
class TraversorOF : public TraversorCell<MAP>
{
public:
TraversorOF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, ORIENTED_FACE, good, thread)
{}
};
template <typename MAP> template <typename MAP>
class TraversorF : public TraversorCell<MAP> class TraversorF : public TraversorCell<MAP>
{ {
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
/*! /*!
* *
*/ */
virtual void sewVolumes(Dart d, Dart e); virtual void sewVolumes(Dart d, Dart e, bool withBoundary = true);
/*! /*!
* *
......
...@@ -364,6 +364,11 @@ public: ...@@ -364,6 +364,11 @@ public:
* Should be executed after import * Should be executed after import
*/ */
virtual bool check(); virtual bool check();
/**
* Check if a serie of darts is an oriented simple close path
*/
virtual bool checkSimpleOrientedPath(std::vector<Dart>& vd);
//@} //@}
/*! @name Cell Functors /*! @name Cell Functors
......
...@@ -259,24 +259,15 @@ bool EmbeddedMap2::flipBackEdge(Dart d) ...@@ -259,24 +259,15 @@ bool EmbeddedMap2::flipBackEdge(Dart d)
void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary) void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary)
{ {
// for fixed point construction (import & primitives) // if (!withBoundary)
if (!withBoundary) // return Map2::sewFaces(d, e, false) ;
return Map2::sewFaces(d, e, false) ;
unsigned int vEmb1 = EMBNULL ; Map2::sewFaces(d, e, withBoundary) ;
unsigned int vEmb2 = EMBNULL ;
if (isOrbitEmbedded(VERTEX))
{
vEmb1 = getEmbedding(VERTEX, d) ;
vEmb2 = getEmbedding(VERTEX, phi1(d)) ;
}
Map2::sewFaces(d, e, true) ;
if (isOrbitEmbedded(VERTEX)) if (isOrbitEmbedded(VERTEX))
{ {
embedOrbit(VERTEX, d, vEmb1) ; embedOrbit(VERTEX, d, getEmbedding(VERTEX, d)) ;
embedOrbit(VERTEX, e, vEmb2) ; embedOrbit(VERTEX, e, getEmbedding(VERTEX, phi1(d))) ;
} }
if (isOrbitEmbedded(EDGE)) if (isOrbitEmbedded(EDGE))
...@@ -343,6 +334,7 @@ void EmbeddedMap2::splitFace(Dart d, Dart e) ...@@ -343,6 +334,7 @@ void EmbeddedMap2::splitFace(Dart d, Dart e)
} }
if (isOrbitEmbedded(FACE)) if (isOrbitEmbedded(FACE))
{ {
copyDartEmbedding(FACE, phi_1(d), d) ;
embedNewCell(FACE, e) ; embedNewCell(FACE, e) ;
copyCell(FACE, e, d) ; copyCell(FACE, e, d) ;
} }
...@@ -367,7 +359,9 @@ bool EmbeddedMap2::mergeVolumes(Dart d, Dart e) ...@@ -367,7 +359,9 @@ bool EmbeddedMap2::mergeVolumes(Dart d, Dart e)
{ {
std::vector<Dart> darts ; std::vector<Dart> darts ;
std::vector<unsigned int> vEmb ; std::vector<unsigned int> vEmb ;
vEmb.reserve(32) ;
std::vector<unsigned int> eEmb ; std::vector<unsigned int> eEmb ;
eEmb.reserve(32) ;
Dart fit = d ; Dart fit = d ;
do do
{ {
...@@ -452,6 +446,15 @@ bool EmbeddedMap2::check() ...@@ -452,6 +446,15 @@ bool EmbeddedMap2::check()
} }
} }
if (isOrbitEmbedded(ORIENTED_FACE))
{
if (getEmbedding(ORIENTED_FACE, d) != getEmbedding(ORIENTED_FACE, phi1(d)))
{
CGoGNout << "Check: different embeddings on oriented face" << CGoGNendl ;
return false ;
}
}
if (isOrbitEmbedded(FACE)) if (isOrbitEmbedded(FACE))
{ {
if (getEmbedding(FACE, d) != getEmbedding(FACE, phi1(d))) if (getEmbedding(FACE, d) != getEmbedding(FACE, phi1(d)))
......
...@@ -55,15 +55,27 @@ void EmbeddedMap3::cutEdge(Dart d) ...@@ -55,15 +55,27 @@ void EmbeddedMap3::cutEdge(Dart d)
copyCell(EDGE, nd, d) ; copyCell(EDGE, nd, d) ;
} }
if(isOrbitEmbedded(FACE)) if(isOrbitEmbedded(ORIENTED_FACE))
{ {
Dart f = d; Dart f = d;
do do
{ {
Dart nd = phi1(f) ; Dart nd = phi1(f) ;
copyDartEmbedding(FACE, nd, f); copyDartEmbedding(ORIENTED_FACE, nd, f);
Dart e = phi2(nd); Dart e = phi3(nd);
copyDartEmbedding(FACE, phi1(e), e); copyDartEmbedding(ORIENTED_FACE, phi1(e), e);
f = alpha2(f);
} while(f != d);
}
if(isOrbitEmbedded(FACE))
{
Dart f = d;
do
{
unsigned int fEmb = getEmbedding(FACE, f) ;
setDartEmbedding(FACE, phi1(f), fEmb);
setDartEmbedding(FACE, phi3(f), fEmb);
f = alpha2(f); f = alpha2(f);
} while(f != d); } while(f != d);
} }
...@@ -97,62 +109,67 @@ bool EmbeddedMap3::uncutEdge(Dart d) ...@@ -97,62 +109,67 @@ bool EmbeddedMap3::uncutEdge(Dart d)
void EmbeddedMap3::splitFace(Dart d, Dart e) void EmbeddedMap3::splitFace(Dart d, Dart e)
{ {
Map3::splitFace(d,e); Dart dd = phi1(phi3(d));
Dart ee = phi1(phi3(e));
Map3::splitFace(d, e);
//copy the vertex embedding to new darts (same vertex embedding for all darts) //copy the vertex embedding to new darts (same vertex embedding for all darts)
if(isOrbitEmbedded(VERTEX)) if(isOrbitEmbedded(VERTEX))
{ {
copyDartEmbedding(VERTEX, phi2(phi_1(d)), d); copyDartEmbedding(VERTEX, phi_1(e), d);
copyDartEmbedding(VERTEX, phi2(phi_1(e)), e); copyDartEmbedding(VERTEX, phi_1(d), e);
copyDartEmbedding(VERTEX, phi_1(ee), dd);
copyDartEmbedding(VERTEX, phi_1(dd), ee);
}
if(!isBoundaryFace(d)) if(isOrbitEmbedded(ORIENTED_FACE))
{ {
Dart d3 = phi3(d); copyDartEmbedding(ORIENTED_FACE, phi_1(d), d) ;
Dart e3 = phi3(e); embedNewCell(ORIENTED_FACE, e) ;
copyCell(ORIENTED_FACE, e, d) ;
copyDartEmbedding(VERTEX, phi1(d3), phi1(phi2(phi1(d3)))); copyDartEmbedding(ORIENTED_FACE, phi_1(dd), dd) ;
copyDartEmbedding(VERTEX, phi1(e3), phi1(phi2(phi1(e3)))); embedNewCell(ORIENTED_FACE, ee) ;
} copyCell(ORIENTED_FACE, ee, dd) ;
} }
//add a new face embedding to the created face //add a new face embedding to the created face
if(isOrbitEmbedded(FACE)) if(isOrbitEmbedded(FACE))
{ {
embedNewCell(FACE, phi2(phi_1(d))); unsigned int fEmb = getEmbedding(FACE, d) ;
copyCell(FACE, phi2(phi_1(d)), d); setDartEmbedding(FACE, phi_1(d), fEmb) ;
setDartEmbedding(FACE, phi3(phi_1(d)), fEmb) ;
embedNewCell(FACE, e);
copyCell(FACE, e, d);
} }
//copy the volume embedding to new darts (same volume embedding for all darts on the faces) //copy the volume embedding to new darts (same volume embedding for all darts on the faces)
if(isOrbitEmbedded(VOLUME)) if(isOrbitEmbedded(VOLUME))
{ {
copyDartEmbedding(VOLUME, phi_1(d), d); unsigned int vEmb1 = getEmbedding(VOLUME, d) ;
copyDartEmbedding(VOLUME, phi2(phi_1(d)), d); setDartEmbedding(VOLUME, phi_1(d), vEmb1);
setDartEmbedding(VOLUME, phi_1(e), vEmb1);
if(!isBoundaryFace(d)) unsigned int vEmb2 = getEmbedding(VOLUME, dd) ;
{ setDartEmbedding(VOLUME, phi_1(dd), vEmb2);
Dart d3 = phi3(d); setDartEmbedding(VOLUME, phi_1(ee), vEmb2);
copyDartEmbedding(VOLUME, phi1(d3), d3);
copyDartEmbedding(VOLUME, phi2(phi1(d3)), d3);
}
} }
} }
void EmbeddedMap3::sewVolumes(Dart d, Dart e) void EmbeddedMap3::sewVolumes(Dart d, Dart e, bool withBoundary)
{ {
//topological sewing //topological sewing
Map3::sewVolumes(d,e); Map3::sewVolumes(d, e, withBoundary);
//embed the vertex orbits from the oriented face with dart e //embed the vertex orbits from the oriented face with dart e
//with vertex orbits value from oriented face with dart d //with vertex orbits value from oriented face with dart d
if (isOrbitEmbedded(VERTEX)) if (isOrbitEmbedded(VERTEX))
{ {
unsigned int vEmb1 = EMBNULL ;
Dart dd = d ; Dart dd = d ;
do { do
vEmb1 = getEmbedding(VERTEX, dd); {
embedOrbit(VERTEX, dd, vEmb1) ; embedOrbit(VERTEX, dd, getEmbedding(VERTEX, dd)) ;
dd = phi1(dd) ; dd = phi1(dd) ;
} while(dd != d) ; } while(dd != d) ;
} }
...@@ -161,11 +178,10 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e) ...@@ -161,11 +178,10 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e)
//for all the face //for all the face
if (isOrbitEmbedded(EDGE)) if (isOrbitEmbedded(EDGE))
{ {
unsigned int vEmb1 = EMBNULL ;
Dart dd = d ; Dart dd = d ;
do { do
vEmb1 = getEmbedding(EDGE, d); {
embedOrbit(EDGE, d, vEmb1) ; embedOrbit(EDGE, d, getEmbedding(EDGE, d)) ;
dd = phi1(dd) ; dd = phi1(dd) ;
} while(dd != d) ; } while(dd != d) ;
} }
...@@ -173,52 +189,57 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e) ...@@ -173,52 +189,57 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e)
//embed the face orbit from the volume sewn //embed the face orbit from the volume sewn
if (isOrbitEmbedded(FACE)) if (isOrbitEmbedded(FACE))
{ {
unsigned int vEmb1 = getEmbedding(FACE, d); embedOrbit(FACE, e, getEmbedding(FACE, d)) ;
embedOrbit(FACE, e, vEmb1) ;
} }
} }
void EmbeddedMap3::unsewVolumes(Dart d) void EmbeddedMap3::unsewVolumes(Dart d)
{ {
if(!Map3::isBoundaryFace(d)) Dart dd = phi1(phi3(d));
{ Map3::unsewVolumes(d);
Dart dd = phi1(phi3(d));
Map3::unsewVolumes(d);
Dart dit = d; unsigned int fEmb = EMBNULL ;
do if(isOrbitEmbedded(FACE))
fEmb = getEmbedding(FACE, d) ;
Dart dit = d;
do
{
// embed the unsewn vertex orbit with the vertex embedding if it is deconnected
if(isOrbitEmbedded(VERTEX))
{ {
//embed the unsewn vertex orbit with the vertex embedding if it is deconnected if(!sameVertex(dit, dd))
if(isOrbitEmbedded(VERTEX))
{ {
if(!sameVertex(dit,dd)) embedNewCell(VERTEX, dd);
{ copyCell(VERTEX, dd, dit);
embedNewCell(VERTEX, dd);
copyCell(VERTEX, dd, dit);
}
} }
}
dd = phi_1(dd); dd = phi_1(dd);
//embed the unsewn edge with the edge embedding if it is deconnected // embed the unsewn edge with the edge embedding if it is deconnected
if(isOrbitEmbedded(EDGE)) if(isOrbitEmbedded(EDGE))
{
if(!sameEdge(dit, dd))
{ {
if(!sameEdge(dit,dd)) embedNewCell(EDGE, dd);
{ copyCell(EDGE, dd, dit);
embedNewCell(EDGE, dd);
copyCell(EDGE, dd, dit);
}
} }
}
dit = phi1(dit); if(isOrbitEmbedded(FACE))
} while(dit!=d);
//embed the unsewn face with the face embedding
if (isOrbitEmbedded(FACE))
{ {
embedNewCell(FACE, dd); setDartEmbedding(FACE, phi3(dit), fEmb) ;
copyCell(FACE, dd, d);
} }
dit = phi1(dit);
} while(dit != d);
// embed the unsewn face with the face embedding
if (isOrbitEmbedded(FACE))
{
embedNewCell(FACE, dd);
copyCell(FACE, dd, d);
} }
} }
...@@ -230,8 +251,7 @@ bool EmbeddedMap3::mergeVolumes(Dart d) ...@@ -230,8 +251,7 @@ bool EmbeddedMap3::mergeVolumes(Dart d)
{ {
if (isOrbitEmbedded(VOLUME)) if (isOrbitEmbedded(VOLUME))
{ {
unsigned int vEmb = getEmbedding(VOLUME, d2); embedOrbit(VOLUME, d2, getEmbedding(VOLUME, d2)) ;
embedOrbit(VOLUME, d2, vEmb) ;
} }
return true; return true;
} }
...@@ -242,33 +262,87 @@ void EmbeddedMap3::splitVolume(std::vector<Dart>& vd) ...@@ -242,33 +262,87 @@ void EmbeddedMap3::splitVolume(std::vector<Dart>& vd)
{ {
Map3::splitVolume(vd); Map3::splitVolume(vd);
//follow the edge path a second time to embed the vertex, edge and volume orbits // follow the edge path a second time to embed the vertex, edge and volume orbits
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it) for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
{ {
Dart dit = *it; Dart dit = *it;
Dart dit3 = alpha2(dit); Dart dit23 = alpha2(dit);
//embed the vertex embedded from the origin volume to the new darts // embed the vertex embedded from the origin volume to the new darts
if(isOrbitEmbedded(VERTEX)) if(isOrbitEmbedded(VERTEX))
{ {
copyDartEmbedding(VERTEX, dit3, dit); copyDartEmbedding(VERTEX, dit23, dit);
copyDartEmbedding(VERTEX, phi2(dit), phi2(dit3)); copyDartEmbedding(VERTEX, phi2(dit), phi1(dit));
} }
//embed the edge embedded from the origin volume to the new darts // embed the edge embedded from the origin volume to the new darts
if(isOrbitEmbedded(EDGE)) if(isOrbitEmbedded(EDGE))
{ {
copyDartEmbedding(EDGE, dit3, dit); unsigned int eEmb = getEmbedding(EDGE, dit) ;
copyDartEmbedding(EDGE, phi2(dit), dit); setDartEmbedding(EDGE, dit23, eEmb);
setDartEmbedding(EDGE, phi2(dit), eEmb);
} }
//embed the volume embedded from the origin volume to the new darts // embed the volume embedded from the origin volume to the new darts
if(isOrbitEmbedded(VOLUME)) if(isOrbitEmbedded(VOLUME))
{ {
copyDartEmbedding(VOLUME, dit3, dit);
copyDartEmbedding(VOLUME, phi2(dit), dit); copyDartEmbedding(VOLUME, phi2(dit), dit);
} }
} }
if(isOrbitEmbedded(VOLUME))
{
Dart v = vd.begin() ;
Dart v23 = alpha2(v) ;
embedNewCell(VOLUME, v23) ;
copyCell(VOLUME, v23, v) ;
}
}
unsigned int EmbeddedMap3::closeHole(Dart d, bool forboundary)
{
unsigned int nbF = Map3::closeHole(d, forboundary) ;
Dart d3 = phi3(d) ;
DartMarkerStore mark(*this); // Lock a marker
std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(1024) ;
visitedFaces.push_back(d); // Start with the face of d
// For every face added to the list
for (std::vector<Dart>::iterator it = visitedFaces.begin(); it != visitedFaces.end(); ++it)
{
if (!mark.isMarked(*it)) // Face has not been visited yet
{
Dart f = *it ;
do
{
mark.mark(f);
if(isOrbitEmbedded(VERTEX))
{
copyDartEmbedding(VERTEX, f, alpha1(f)) ;
}
if(isOrbitEmbedded(EDGE))
{
copyDartEmbedding(EDGE, f, phi3(f)) ;
}
if(isOrbitEmbedded(FACE))
{
copyDartEmbedding(FACE, f, phi3(f)) ;
}
Dart adj = phi2(f); // Get adjacent face
if (!mark.isMarked(adj))
visitedFaces.push_back(adj); // Add it
f = phi1(f) ;
} while(f != *it) ;
}
}
return nbF ;
} }
bool EmbeddedMap3::check() bool EmbeddedMap3::check()
...@@ -278,23 +352,56 @@ bool EmbeddedMap3::check() ...@@ -278,23 +352,56 @@ bool EmbeddedMap3::check()
return false ; return false ;
std::cout << "Check: embedding begin" << std::endl ; std::cout << "Check: embedding begin" << std::endl ;
DartMarker mv(*this);
for(Dart d = begin(); d != end(); next(d)) for(Dart d = begin(); d != end(); next(d))
{ {
if(isOrbitEmbedded(VERTEX)) if(isOrbitEmbedded(VERTEX))
{ {
if(!mv.isMarked(d)) if( getEmbedding(VERTEX, d) != getEmbedding(VERTEX, alpha1(d)) ||
getEmbedding(VERTEX, d) != getEmbedding(VERTEX, alpha2(d)) )
{ {
mv.markOrbit(VERTEX, d); std::cout << "Embedding Check : different embeddings on vertex" << std::endl ;
unsigned int emb = getEmbedding(VERTEX, d); return false ;
FunctorCheckEmbedding<Map3> fce(*this, VERTEX, emb); }
if(foreach_dart_of_orbit(VERTEX, d, fce)) }
{
std::cout << "Embedding Check : different embeddings on vertex" << std::endl; if(isOrbitEmbedded(EDGE))
} {
if( getEmbedding(EDGE, d) != getEmbedding(EDGE, phi2(d)) ||
getEmbedding(EDGE, d) != getEmbedding(EDGE, phi3(d)) )
{
std::cout << "Embedding Check : different embeddings on edge" << std::endl ;
return false ;
}
}
if (isOrbitEmbedded(ORIENTED_FACE))
{
if (getEmbedding(ORIENTED_FACE, d) != getEmbedding(ORIENTED_FACE, phi1(d)))
{
CGoGNout << "Check: different embeddings on oriented face" << CGoGNendl ;
return false ;
} }
} }
if (isOrbitEmbedded(FACE))
{
if( getEmbedding(FACE, d) != getEmbedding(FACE, phi1(d)) ||
getEmbedding(FACE, d) != getEmbedding(FACE, phi3(d)) )
{
CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
return false ;
}
}
if (isOrbitEmbedded(VOLUME))
{
if( getEmbedding(VOLUME, d) != getEmbedding(VOLUME, phi1(d)) ||
getEmbedding(VOLUME, d) != getEmbedding(VOLUME, phi2(d)) )
{
CGoGNout << "Check: different embeddings on volume" << CGoGNendl ;
return false ;
}
}
} }
std::cout << "Check: embedding ok" << std::endl ; std::cout << "Check: embedding ok" << std::endl ;
return true ; return true ;
......
...@@ -474,7 +474,7 @@ bool Map2::mergeVolumes(Dart d, Dart e) ...@@ -474,7 +474,7 @@ bool Map2::mergeVolumes(Dart d, Dart e)
{ {
assert(!isBoundaryMarked(d) && !isBoundaryMarked(e)) ; assert(!isBoundaryMarked(d) && !isBoundaryMarked(e)) ;
if (isBoundaryFace(d) || isBoundaryFace(e)) if (Map2::isBoundaryFace(d) || Map2::isBoundaryFace(e))
return false; return false;