From 1b04301606f575119c6c605525d323a3ff68c13e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sun, 7 Dec 2014 21:20:39 +0000
Subject: [PATCH] dix

---
 Geo/GModelIO_STL.cpp | 9 ++++++---
 Geo/GRbf.cpp         | 8 +++-----
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Geo/GModelIO_STL.cpp b/Geo/GModelIO_STL.cpp
index 476477ff8f..f8ab2026c5 100644
--- a/Geo/GModelIO_STL.cpp
+++ b/Geo/GModelIO_STL.cpp
@@ -146,7 +146,7 @@ int GModel::readSTL(const std::string &name, double tolerance)
   MVertexRTree pos(eps);
   pos.insert(vertices);
 
-  std::set<MFace,Less_Face> unique;
+  std::set<MFace, Less_Face> unique;
   int nbDuplic = 0;
   for(unsigned int i = 0; i < points.size(); i ++){
     for(unsigned int j = 0; j < points[i].size(); j += 3){
@@ -157,7 +157,10 @@ int GModel::readSTL(const std::string &name, double tolerance)
         double z = points[i][j + k].z();
         v[k] = pos.find(x, y, z);
       }
-      MFace mf (v[0], v[1], v[2]);
+      // FIXME: is this unicity test really useful? it slows down large STL
+      // reads. It would be better to provide an API to detect/remove duplicate
+      // elements
+      MFace mf(v[0], v[1], v[2]);
       if (unique.find(mf) == unique.end()){
 	faces[i]->triangles.push_back(new MTriangle(v[0], v[1], v[2]));
 	unique.insert(mf);
@@ -167,7 +170,7 @@ int GModel::readSTL(const std::string &name, double tolerance)
       }
     }
   }
-  if (nbDuplic)
+  if(nbDuplic)
     Msg::Warning("%d duplicate triangles in STL file", nbDuplic);
 
   _associateEntityWithMeshVertices();
diff --git a/Geo/GRbf.cpp b/Geo/GRbf.cpp
index b2fc854b90..eabf28654b 100644
--- a/Geo/GRbf.cpp
+++ b/Geo/GRbf.cpp
@@ -112,18 +112,16 @@ GRbf::GRbf(double sizeBox, int variableEps, int rbfFun,
   pos.insert(vertices);
   for(unsigned int i = 0; i < vertices.size(); i++){
     MVertex *v = vertices[i];
-    pos.find(v->x(), v->y(), v->z());
+    if(!pos.find(v->x(), v->y(), v->z()))
+      myNodes.insert(v); // keep only no duplicate vertices
     allCenters(i,0) = v->x()/sBox;
     allCenters(i,1) = v->y()/sBox;
     allCenters(i,2) = v->z()/sBox;
     _mapAllV.insert(std::make_pair(v, i));
   }
-  // keep only no duplicate vertices
-  for(unsigned int i = 0; i < vertices.size(); i++)
-    if(vertices[i]->getIndex()) myNodes.insert(vertices[i]);
 
   // initialize with  points
-  nbNodes= myNodes.size();
+  nbNodes = myNodes.size();
   centers.resize(nbNodes,3);
   normals.resize(nbNodes,3);
   int index = 0;
-- 
GitLab