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

cleanup

parent 3afd8474
Branches
Tags
No related merge requests found
...@@ -14,20 +14,6 @@ ...@@ -14,20 +14,6 @@
#include "MPrism.h" #include "MPrism.h"
#include "Context.h" #include "Context.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;
}
int GModel::readUNV(const std::string &name) int GModel::readUNV(const std::string &name)
{ {
FILE *fp = fopen(name.c_str(), "r"); FILE *fp = fopen(name.c_str(), "r");
...@@ -37,10 +23,11 @@ int GModel::readUNV(const std::string &name) ...@@ -37,10 +23,11 @@ int GModel::readUNV(const std::string &name)
} }
char buffer[256]; char buffer[256];
std::map<int, MVertex*> vertexMap;
std::map<int, std::vector<MElement*> > elements[7]; std::map<int, std::vector<MElement*> > elements[7];
std::map<int, std::map<int, std::string> > physicals[4]; std::map<int, std::map<int, std::string> > physicals[4];
_vertexMapCache.clear();
while(!feof(fp)) { while(!feof(fp)) {
if(!fgets(buffer, sizeof(buffer), fp)) break; if(!fgets(buffer, sizeof(buffer), fp)) break;
if(!strncmp(buffer, " -1", 6)){ if(!strncmp(buffer, " -1", 6)){
...@@ -59,7 +46,7 @@ int GModel::readUNV(const std::string &name) ...@@ -59,7 +46,7 @@ int GModel::readUNV(const std::string &name)
for(unsigned int i = 0; i < strlen(buffer); i++) for(unsigned int i = 0; i < strlen(buffer); i++)
if(buffer[i] == 'D') buffer[i] = 'E'; if(buffer[i] == 'D') buffer[i] = 'E';
if(sscanf(buffer, "%lf %lf %lf", &x, &y, &z) != 3) break; if(sscanf(buffer, "%lf %lf %lf", &x, &y, &z) != 3) break;
vertexMap[num] = new MVertex(x, y, z, 0, num); _vertexMapCache[num] = new MVertex(x, y, z, 0, num);
} }
} }
else if(record == 2412){ // elements else if(record == 2412){ // elements
...@@ -86,11 +73,16 @@ int GModel::readUNV(const std::string &name) ...@@ -86,11 +73,16 @@ int GModel::readUNV(const std::string &name)
if(sscanf(buffer, "%d %d %d", &dum, &dum, &dum) != 3) break; if(sscanf(buffer, "%d %d %d", &dum, &dum, &dum) != 3) break;
break; break;
} }
int n[30]; std::vector<MVertex*> vertices(numNodes);
for(int i = 0; i < numNodes; i++) if(!fscanf(fp, "%d", &n[i])) return 0; for(int i = 0; i < numNodes; i++){
std::vector<MVertex*> vertices; int n;
if(!getVertices(numNodes, n, vertexMap, vertices)) return 0; if(!fscanf(fp, "%d", &n)) return 0;
vertices[i] = getMeshVertexByTag(n);
if(!vertices[i]){
Msg::Error("Wrong vertex index %d", n);
return 0;
}
}
int dim = -1; int dim = -1;
switch(type){ switch(type){
case 11: case 21: case 22: case 31: case 11: case 21: case 22: case 31:
...@@ -173,7 +165,7 @@ int GModel::readUNV(const std::string &name) ...@@ -173,7 +165,7 @@ int GModel::readUNV(const std::string &name)
for(int i = 0; i < (int)(sizeof(elements) / sizeof(elements[0])); i++) for(int i = 0; i < (int)(sizeof(elements) / sizeof(elements[0])); i++)
_storeElementsInEntities(elements[i]); _storeElementsInEntities(elements[i]);
_associateEntityWithMeshVertices(); _associateEntityWithMeshVertices();
_storeVerticesInEntities(vertexMap); _storeVerticesInEntities(_vertexMapCache);
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
_storePhysicalTagsInEntities(i, physicals[i]); _storePhysicalTagsInEntities(i, physicals[i]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment