From 242c9749fc04a8483cd44290b617815d6c259a8d Mon Sep 17 00:00:00 2001
From: Philippe Delandmeter <philippe.delandmeter@uclouvain.be>
Date: Mon, 23 Sep 2013 08:48:30 +0000
Subject: [PATCH] MFace sorted with the index of Vertices

---
 Geo/MFace.cpp | 4 +++-
 Geo/MFace.h   | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Geo/MFace.cpp b/Geo/MFace.cpp
index 99b1b39640..146c4091d4 100644
--- a/Geo/MFace.cpp
+++ b/Geo/MFace.cpp
@@ -10,10 +10,12 @@
 #include "Numeric.h"
 #include "Context.h"
 
+bool compare (MVertex* v0, MVertex* v1) {return v0->getNum() < v1->getNum();}
+
 void sortVertices(std::vector<MVertex*> v, std::vector<char> &si)
 {
   std::vector<MVertex*> sorted = v;
-  std::sort(sorted.begin(), sorted.end());
+  std::sort(sorted.begin(), sorted.end(), compare);
   for(unsigned int i = 0; i < sorted.size(); i++)
     si.push_back(std::distance(v.begin(), std::find(v.begin(), v.end(), sorted[i])));
 }
diff --git a/Geo/MFace.h b/Geo/MFace.h
index 6ad37f7cba..c2774c819a 100644
--- a/Geo/MFace.h
+++ b/Geo/MFace.h
@@ -134,8 +134,8 @@ struct Less_Face : public std::binary_function<MFace, MFace, bool> {
     if (f1.getNumVertices() != f2.getNumVertices())
       return f1.getNumVertices() <  f2.getNumVertices();
     for(int i = 0; i < f1.getNumVertices(); i++) {
-      if(f1.getSortedVertex(i) < f2.getSortedVertex(i)) return true;
-      if(f1.getSortedVertex(i) > f2.getSortedVertex(i)) return false;
+      if(f1.getSortedVertex(i)->getNum() < f2.getSortedVertex(i)->getNum()) return true;
+      if(f1.getSortedVertex(i)->getNum() > f2.getSortedVertex(i)->getNum()) return false;
     }
     return false;
   }
-- 
GitLab