diff --git a/Geo/GModelIO_BDF.cpp b/Geo/GModelIO_BDF.cpp index 2decedd0e6af11634579a9ba83ba76a870aabe0c..32cf58e3cc490dd1b6c9182bd6e3a180f475c2be 100644 --- a/Geo/GModelIO_BDF.cpp +++ b/Geo/GModelIO_BDF.cpp @@ -6,7 +6,6 @@ #include <stdlib.h> #include <string.h> #include "GModel.h" -#include "MPoint.h" #include "MLine.h" #include "MTriangle.h" #include "MQuadrangle.h" @@ -15,20 +14,6 @@ #include "MPrism.h" #include "MPyramid.h" -static bool getVertices(int num, int *indices, std::map<int, MVertex*> &map, - std::vector<MVertex*> &vertices) -{ - for(int i = 0; i < num; i++){ - if(!map.count(indices[i])){ - Msg::Error("Wrong vertex index %d", indices[i]); - return false; - } - else - vertices.push_back(map[indices[i]]); - } - return true; -} - static int getFormatBDF(char *buffer, int &keySize) { if(buffer[keySize] == '*'){ keySize++; return 2; } // long fields @@ -175,7 +160,15 @@ static int readElementBDF(FILE *fp, char *buffer, int keySize, int numVertices, // ignore the extra fields when we know how many vertices we need int numCheck = (numVertices > 0) ? numVertices : fields.size() - 2; - if(!getVertices(numCheck, n, vertexMap, vertices)) return 0; + + for(int i = 0; i < numCheck; i++){ + std::map<int, MVertex*>::iterator it = vertexMap.find(n[i]); + if(it == vertexMap.end()){ + Msg::Error("Wrong vertex index %d", n[i]); + return 0; + } + vertices.push_back(it->second); + } return 1; } diff --git a/Geo/GModelIO_MESH.cpp b/Geo/GModelIO_MESH.cpp index 0081084e608a72862966fce963e185a2819e0fb7..da85f3d35153370a57be9ddcce703c33c570506b 100644 --- a/Geo/GModelIO_MESH.cpp +++ b/Geo/GModelIO_MESH.cpp @@ -13,10 +13,10 @@ #include "MHexahedron.h" static bool getVertices(int num, int *indices, std::vector<MVertex*> &vec, - std::vector<MVertex*> &vertices, int minVertex = 0) + std::vector<MVertex*> &vertices) { for(int i = 0; i < num; i++){ - if(indices[i] < minVertex || indices[i] > (int)(vec.size() - 1 + minVertex)){ + if(indices[i] < 0 || indices[i] > (int)(vec.size() - 1)){ Msg::Error("Wrong vertex index %d", indices[i]); return false; } diff --git a/Geo/GModelIO_PLY.cpp b/Geo/GModelIO_PLY.cpp index 408036ad622c4bdfdeb849de63db7e0eea455eb7..3a6983a4cb7e1d745f0a68bb985a44d20fa23bb8 100644 --- a/Geo/GModelIO_PLY.cpp +++ b/Geo/GModelIO_PLY.cpp @@ -16,10 +16,10 @@ #endif static bool getVertices(int num, int *indices, std::vector<MVertex*> &vec, - std::vector<MVertex*> &vertices, int minVertex = 0) + std::vector<MVertex*> &vertices) { for(int i = 0; i < num; i++){ - if(indices[i] < minVertex || indices[i] > (int)(vec.size() - 1 + minVertex)){ + if(indices[i] < 0 || indices[i] > (int)(vec.size() - 1)){ Msg::Error("Wrong vertex index %d", indices[i]); return false; }