From 742d8e6675c317685d13b8095bdf3282c1956a9d Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Tue, 15 Feb 2011 15:00:00 +0100 Subject: [PATCH] operator const dans les Dart + micro optim oldest dart IHM --- include/Topology/generic/dart.h | 6 +++--- src/Algo/ImplicitHierarchicalMesh/ihm.cpp | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/Topology/generic/dart.h b/include/Topology/generic/dart.h index 10b739b5..b677b79d 100644 --- a/include/Topology/generic/dart.h +++ b/include/Topology/generic/dart.h @@ -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; } diff --git a/src/Algo/ImplicitHierarchicalMesh/ihm.cpp b/src/Algo/ImplicitHierarchicalMesh/ihm.cpp index 10c4b574..dc67e310 100644 --- a/src/Algo/ImplicitHierarchicalMesh/ihm.cpp +++ b/src/Algo/ImplicitHierarchicalMesh/ihm.cpp @@ -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 ; } -- GitLab