2 #include "DriverUNV_R_SMDS_Mesh.h"
11 * Factory function which will be called by SMESHDriver
13 void * SMESH_createUNVMeshReader()
15 return new DriverUNV_R_SMDS_Mesh();
20 DriverUNV_R_SMDS_Mesh::DriverUNV_R_SMDS_Mesh()
25 DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh()
30 void DriverUNV_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
35 void DriverUNV_R_SMDS_Mesh::SetFile(string aFile)
40 void DriverUNV_R_SMDS_Mesh::SetFileId(FILE * aFileId)
45 void DriverUNV_R_SMDS_Mesh::SetMeshId(int aMeshId)
50 void DriverUNV_R_SMDS_Mesh::Add()
55 void DriverUNV_R_SMDS_Mesh::Read()
58 int cell = 0, node = 0, n1, n2, n3, n4, n_nodes, nodes[6], blockId, i;
60 string str1, str2, str3;
62 bool ok, found_block2411, found_block2412;
64 /****************************************************************************
65 * OUVERTURE DU FICHIER EN LECTURE *
66 ****************************************************************************/
67 char *file2Read = (char *)myFile.c_str();
68 myFileId = fopen(file2Read, "r");
71 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
75 s1 = (char *)malloc(sizeof(char) * 100);
76 s2 = (char *)malloc(sizeof(char) * 100);
77 s3 = (char *)malloc(sizeof(char) * 100);
79 found_block2411 = false;
80 found_block2412 = false;
87 fscanf(myFileId, "%d\n", &blockId);
92 MESSAGE("BlockId " << blockId);
93 fscanf(myFileId, "%d", &node);
94 //MESSAGE("Node "<<node);
97 fscanf(myFileId, "%d %d %d\n", &n1, &n2, &n3);
98 fscanf(myFileId, "%s %s %s\n", s1, s2, s3);
102 if (str1.find("D") != string::npos)
103 str1.replace(str1.find("D"), 1, "E");
104 if (str2.find("D") != string::npos)
105 str2.replace(str2.find("D"), 1, "E");
106 if (str3.find("D") != string::npos)
107 str3.replace(str3.find("D"), 1, "E");
108 ok = myMesh->AddNodeWithID(atof(str1.c_str()),
109 atof(str2.c_str()), atof(str3.c_str()), node);
110 fscanf(myFileId, "%d", &node);
113 found_block2411 = true;
118 MESSAGE("BlockId " << blockId);
119 fscanf(myFileId, "%d", &cell);
120 //MESSAGE("Cell "<<cell);
123 fscanf(myFileId, "%d %d %d %d %d\n", &n1, &n2, &n3, &n4,
126 if ((n1 == 71) || (n1 == 72) || (n1 == 74) || (n1 == 91) ||
131 for (i = 1; i <= n_nodes; i++)
132 fscanf(myFileId, "%d", &nodes[i - 1]);
133 ok = myMesh->AddFaceWithID(nodes[0], nodes[1],
136 else if (n_nodes == 6)
138 for (i = 1; i <= n_nodes; i++)
139 fscanf(myFileId, "%d", &nodes[i - 1]);
140 ok = myMesh->AddFaceWithID(nodes[0], nodes[2],
145 else if ((n1 == 11) || (n1 == 21) || (n1 == 24) ||
148 fgets(s2, 100, myFileId);
151 for (i = 1; i <= n_nodes; i++)
152 fscanf(myFileId, "%d", &nodes[i - 1]);
153 ok = myMesh->AddEdgeWithID(nodes[0], nodes[1],
155 //MESSAGE("in 103 "<<cell);
157 else if (n_nodes == 2)
159 for (i = 1; i <= n_nodes; i++)
160 fscanf(myFileId, "%d", &nodes[i - 1]);
161 ok = myMesh->AddEdgeWithID(nodes[0], nodes[1],
163 //MESSAGE("in 102 "<<cell);
167 fscanf(myFileId, "\n");
168 fscanf(myFileId, "%d", &cell);
172 found_block2412 = true;
180 MESSAGE("BlockId " << blockId);
186 fscanf(myFileId, "%s\n", s1);
190 while ((!feof(myFileId)) && ((!found_block2411) || (!found_block2412)));
192 /****************************************************************************
193 * FERMETURE DU FICHIER *
194 ****************************************************************************/