Commit 56266509 authored by Thomas Pitiot 's avatar Thomas Pitiot

réparation IHM2

parent 5419938e
......@@ -131,6 +131,10 @@ protected:
*/
void coarsenEdge(Dart d) ;
/**
* checkForSurrounded check if the cell wont be surrounded by subdivided cells (before subdividing phi2(d)) to avoid the case of a non subdivided cell surrounded by subdivided ones.
*/
bool checkForSurrounded (Dart d);
public:
/**
* subdivide the face of d to the next level
......
......@@ -60,8 +60,8 @@ unsigned int IHM2<PFP>::edgeLevel(Dart d)
assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
unsigned int ld = m_map.getDartLevel(d);
// unsigned int ldd = m_dartLevel[phi2(d)] ; // the level of an edge is the maximum of the
unsigned int ldd = m_map.getDartLevel(m_map.phi2(d));
return ld < ldd ? ldd : ld ;
unsigned int ldd = m_map.getDartLevel(m_map.phi1(d));
return std::max(ldd,ld) ;
}
template <typename PFP>
......@@ -131,27 +131,27 @@ unsigned int IHM2<PFP>::faceLevel(Dart d)
fLevel = l < fLevel ? l : fLevel ; // of its edges
} while(it != d) ;
unsigned int cur = m_map.getCurrentLevel() ;
m_map.setCurrentLevel(fLevel) ;
// unsigned int cur = m_map.getCurrentLevel() ;
// m_map.setCurrentLevel(fLevel) ;
unsigned int nbSubd = 0 ;
it = old ;
unsigned int eId = m_map.getEdgeId(old) ; // the particular case of a face
CGoGNout<<"catastrophe"<<m_map.getEdgeId(it)<<CGoGNendl;
do // with all neighboring faces regularly subdivided
{
// but not the face itself
++nbSubd ; // is treated here
it = m_map.phi1(it) ;
} while(m_map.getEdgeId(it) == eId && it!=old) ;
// unsigned int nbSubd = 0 ;
// it = old ;
// unsigned int eId = m_map.getEdgeId(old) ; // the particular case of a face
// CGoGNout<<"catastrophe"<<m_map.getEdgeId(it)<<CGoGNendl;
// do // with all neighboring faces regularly subdivided
// {
// // but not the face itself
// ++nbSubd ; // is treated here
// it = m_map.phi1(it) ;
// } while(m_map.getEdgeId(it) == eId && it!=old) ;
while(nbSubd > 1)
{
nbSubd /= 2 ;
--fLevel ;
}
// while(nbSubd > 1)
// {
// nbSubd /= 2 ;
// --fLevel ;
// }
m_map.setCurrentLevel(cur) ;
// m_map.setCurrentLevel(cur) ;
return fLevel ;
}
......@@ -246,7 +246,7 @@ bool IHM2<PFP>::faceIsSubdivided(Dart d)
assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
unsigned int fLevel = faceLevel(d) ;
if(fLevel <= m_map.getCurrentLevel())
if(fLevel < m_map.getCurrentLevel())
return false ;
bool subd = false ;
......@@ -350,6 +350,20 @@ void IHM2<PFP>::coarsenEdge(Dart d)
m_map.uncutEdge(d) ;
m_map.setCurrentLevel(cur) ;
}
template <typename PFP>
bool IHM2<PFP>:: checkForSurrounded (Dart d)
{
Dart dd=m_map.phi1(d);
while(dd!=d)
{
if(!faceIsSubdivided(m_map.phi2(dd)))
{
return false;
}
dd=m_map.phi1(dd);
}
return true;
}
template <typename PFP>
unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDifference)
......@@ -358,7 +372,7 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
unsigned int fLevel = faceLevel(d) ;
CGoGNout<<" Subdivision : "<<fLevel<<CGoGNendl;
// CGoGNout<<" Subdivision : "<<fLevel<<CGoGNendl;
Dart old = faceOldestDart(d) ;
unsigned int cur = m_map.getCurrentLevel() ;
......@@ -373,8 +387,21 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
if(OneLevelDifference)
{
Dart nf = m_map.phi2(it) ;
if(faceLevel(nf) == fLevel - 1) // check if neighboring faces have to be subdivided first
int levelneighbor=faceLevel(nf);
if(levelneighbor== fLevel - 1) // check if neighboring faces have to be subdivided first to avoid 2 level differencies
{
subdivideFace(nf,triQuad) ;
}
else if(!faceIsSubdivided(nf)) //check if neighboring faces have to be subdivided first to avoid one cell surrounded by subdivided ones
{
if(checkForSurrounded(nf))
{
subdivideFace(nf,triQuad,false);
}
}
}
if(!edgeIsSubdivided(it))
......@@ -384,10 +411,10 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
m_map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision
// CGoGNout<<" degree : "<<degree<<CGoGNendl;
if((degree == 3) && triQuad) // if subdividing a triangle
{
CGoGNout<<" Subdivided a triangle "<<CGoGNendl;
// CGoGNout<<" Subdivided a triangle "<<CGoGNendl;
Dart dd = m_map.phi1(old) ;
Dart e = m_map.phi1(dd) ;
(*vertexVertexFunctor)(e) ;
......
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