Commit 742d8e66 authored by Pierre Kraemer's avatar Pierre Kraemer

operator const dans les Dart + micro optim oldest dart IHM

parent ce36e5a4
......@@ -54,19 +54,19 @@ struct Dart
* equality operator
* @param d the dart to compare with
*/
bool operator==(Dart d) { return d.index == index; }
bool operator==(Dart d) const { return d.index == index; }
/**
* different operator
* @param d the dart to compare with
*/
bool operator!=(Dart d) { return d.index != index; }
bool operator!=(Dart d) const { return d.index != index; }
/**
* less operator, can be used for sorting
* @param d the dart to compare with
*/
bool operator<(Dart d) { return d.index < index; }
bool operator<(Dart d) const { return index < d.index; }
friend std::ostream& operator<<( std::ostream &out, const Dart& fa ) { return out << fa.index; }
friend std::istream& operator>>( std::istream &in, Dart& fa ) { in >> fa.index; return in; }
......
......@@ -81,6 +81,7 @@ void ImplicitHierarchicalMap::initEdgeId()
unsigned int ImplicitHierarchicalMap::faceLevel(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
if(m_curLevel == 0)
return 0 ;
......@@ -126,14 +127,19 @@ unsigned int ImplicitHierarchicalMap::faceLevel(Dart d)
Dart it = d ;
Dart old = it ;
unsigned int l_old = m_dartLevel[old] ;
unsigned int fLevel = edgeLevel(it) ;
do
{
it = phi1(it) ;
if(m_dartLevel[it] < m_dartLevel[old]) // in a first time, the level of a face
old = it ; // is the minimum of the levels
unsigned int l = edgeLevel(it) ; // of its edges
fLevel = l < fLevel ? l : fLevel ;
unsigned int dl = m_dartLevel[it] ;
if(dl < l_old) // compute the oldest dart of the face
{ // in the same time
old = it ;
l_old = dl ;
} // in a first time, the level of a face
unsigned int l = edgeLevel(it) ; // is the minimum of the levels
fLevel = l < fLevel ? l : fLevel ; // of its edges
} while(it != d) ;
unsigned int cur = m_curLevel ;
......@@ -180,11 +186,16 @@ Dart ImplicitHierarchicalMap::faceOldestDart(Dart d)
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
Dart it = d ;
Dart oldest = it ;
unsigned int l_old = m_dartLevel[oldest] ;
do
{
it = phi1(it) ;
if(m_dartLevel[it] < m_dartLevel[oldest])
unsigned int l = m_dartLevel[it] ;
if(l < l_old || (l == l_old && it < oldest))
{
oldest = it ;
l_old = l ;
}
it = phi1(it) ;
} while(it != d) ;
return oldest ;
}
......
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