From 9214b5237904d5f7b38c4103bafd17c60f4e3e29 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 21 Sep 2012 19:57:16 +0000 Subject: [PATCH] cleanup --- Geo/GModelIO_BDF.cpp | 25 +++++++++---------------- Geo/GModelIO_MESH.cpp | 4 ++-- Geo/GModelIO_PLY.cpp | 4 ++-- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Geo/GModelIO_BDF.cpp b/Geo/GModelIO_BDF.cpp index 2decedd0e6..32cf58e3cc 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 0081084e60..da85f3d351 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 408036ad62..3a6983a4cb 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; } -- GitLab