2 #include "DriverUNV_R_SMDS_Mesh.h"
6 DriverUNV_R_SMDS_Mesh::DriverUNV_R_SMDS_Mesh()
11 DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh()
16 void DriverUNV_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
21 void DriverUNV_R_SMDS_Mesh::SetFile(string aFile)
26 void DriverUNV_R_SMDS_Mesh::SetFileId(FILE * aFileId)
31 void DriverUNV_R_SMDS_Mesh::SetMeshId(int aMeshId)
36 void DriverUNV_R_SMDS_Mesh::Add()
41 void DriverUNV_R_SMDS_Mesh::Read()
44 int cell = 0, node = 0, n1, n2, n3, n4, n_nodes, nodes[6], blockId, i;
46 string str1, str2, str3;
48 bool ok, found_block2411, found_block2412;
50 /****************************************************************************
51 * OUVERTURE DU FICHIER EN LECTURE *
52 ****************************************************************************/
53 char *file2Read = (char *)myFile.c_str();
54 myFileId = fopen(file2Read, "r");
57 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
61 s1 = (char *)malloc(sizeof(char) * 100);
62 s2 = (char *)malloc(sizeof(char) * 100);
63 s3 = (char *)malloc(sizeof(char) * 100);
65 found_block2411 = false;
66 found_block2412 = false;
73 fscanf(myFileId, "%d\n", &blockId);
78 MESSAGE("BlockId " << blockId);
79 fscanf(myFileId, "%d", &node);
80 //MESSAGE("Node "<<node);
83 fscanf(myFileId, "%d %d %d\n", &n1, &n2, &n3);
84 fscanf(myFileId, "%s %s %s\n", s1, s2, s3);
88 if (str1.find("D") != string::npos)
89 str1.replace(str1.find("D"), 1, "E");
90 if (str2.find("D") != string::npos)
91 str2.replace(str2.find("D"), 1, "E");
92 if (str3.find("D") != string::npos)
93 str3.replace(str3.find("D"), 1, "E");
94 ok = myMesh->AddNodeWithID(atof(str1.c_str()),
95 atof(str2.c_str()), atof(str3.c_str()), node);
96 fscanf(myFileId, "%d", &node);
99 found_block2411 = true;
104 MESSAGE("BlockId " << blockId);
105 fscanf(myFileId, "%d", &cell);
106 //MESSAGE("Cell "<<cell);
109 fscanf(myFileId, "%d %d %d %d %d\n", &n1, &n2, &n3, &n4,
112 if ((n1 == 71) || (n1 == 72) || (n1 == 74) || (n1 == 91) ||
117 for (i = 1; i <= n_nodes; i++)
118 fscanf(myFileId, "%d", &nodes[i - 1]);
119 ok = myMesh->AddFaceWithID(nodes[0], nodes[1],
122 else if (n_nodes == 6)
124 for (i = 1; i <= n_nodes; i++)
125 fscanf(myFileId, "%d", &nodes[i - 1]);
126 ok = myMesh->AddFaceWithID(nodes[0], nodes[2],
131 else if ((n1 == 11) || (n1 == 21) || (n1 == 24) ||
134 fgets(s2, 100, myFileId);
137 for (i = 1; i <= n_nodes; i++)
138 fscanf(myFileId, "%d", &nodes[i - 1]);
139 ok = myMesh->AddEdgeWithID(nodes[0], nodes[1],
141 //MESSAGE("in 103 "<<cell);
143 else if (n_nodes == 2)
145 for (i = 1; i <= n_nodes; i++)
146 fscanf(myFileId, "%d", &nodes[i - 1]);
147 ok = myMesh->AddEdgeWithID(nodes[0], nodes[1],
149 //MESSAGE("in 102 "<<cell);
153 fscanf(myFileId, "\n");
154 fscanf(myFileId, "%d", &cell);
158 found_block2412 = true;
166 MESSAGE("BlockId " << blockId);
172 fscanf(myFileId, "%s\n", s1);
176 while ((!feof(myFileId)) && ((!found_block2411) || (!found_block2412)));
178 /****************************************************************************
179 * FERMETURE DU FICHIER *
180 ****************************************************************************/