Skip to content
Snippets Groups Projects
Commit 9214b523 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

cleanup

parent 0cc801b7
Branches
Tags
No related merge requests found
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "GModel.h" #include "GModel.h"
#include "MPoint.h"
#include "MLine.h" #include "MLine.h"
#include "MTriangle.h" #include "MTriangle.h"
#include "MQuadrangle.h" #include "MQuadrangle.h"
...@@ -15,20 +14,6 @@ ...@@ -15,20 +14,6 @@
#include "MPrism.h" #include "MPrism.h"
#include "MPyramid.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) static int getFormatBDF(char *buffer, int &keySize)
{ {
if(buffer[keySize] == '*'){ keySize++; return 2; } // long fields if(buffer[keySize] == '*'){ keySize++; return 2; } // long fields
...@@ -175,7 +160,15 @@ static int readElementBDF(FILE *fp, char *buffer, int keySize, int numVertices, ...@@ -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 // ignore the extra fields when we know how many vertices we need
int numCheck = (numVertices > 0) ? numVertices : fields.size() - 2; 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; return 1;
} }
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
#include "MHexahedron.h" #include "MHexahedron.h"
static bool getVertices(int num, int *indices, std::vector<MVertex*> &vec, 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++){ 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]); Msg::Error("Wrong vertex index %d", indices[i]);
return false; return false;
} }
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
#endif #endif
static bool getVertices(int num, int *indices, std::vector<MVertex*> &vec, 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++){ 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]); Msg::Error("Wrong vertex index %d", indices[i]);
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment