2 #include "DriverUNV_R_SMDS_Mesh.h"
6 DriverUNV_R_SMDS_Mesh::DriverUNV_R_SMDS_Mesh() {
10 DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh() {
14 void DriverUNV_R_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) {
18 void DriverUNV_R_SMDS_Mesh::SetFile(string aFile) {
22 void DriverUNV_R_SMDS_Mesh::SetFileId(FILE* aFileId) {
26 void DriverUNV_R_SMDS_Mesh::SetMeshId(int aMeshId) {
30 void DriverUNV_R_SMDS_Mesh::Add() {
34 void DriverUNV_R_SMDS_Mesh::Read() {
36 int cell=0,node=0,n1,n2,n3,n4,n_nodes,nodes[6],blockId,i;
38 string str1,str2,str3;
40 bool ok, found_block2411, found_block2412;
42 /****************************************************************************
43 * OUVERTURE DU FICHIER EN LECTURE *
44 ****************************************************************************/
45 char* file2Read = (char*)myFile.c_str();
46 myFileId = fopen(file2Read,"r");
49 fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
53 s1 = (char*) malloc(sizeof(char)*100);
54 s2 = (char*) malloc(sizeof(char)*100);
55 s3 = (char*) malloc(sizeof(char)*100);
57 found_block2411 = false;
58 found_block2412 = false;
63 fscanf(myFileId,"%d\n",&blockId);
66 MESSAGE("BlockId "<<blockId);
67 fscanf(myFileId,"%d",&node);
68 //MESSAGE("Node "<<node);
70 fscanf(myFileId,"%d %d %d\n",&n1,&n2,&n3);
71 fscanf(myFileId,"%s %s %s\n",s1,s2,s3);
75 if (str1.find("D")!=string::npos) str1.replace(str1.find("D"),1,"E");
76 if (str2.find("D")!=string::npos) str2.replace(str2.find("D"),1,"E");
77 if (str3.find("D")!=string::npos) str3.replace(str3.find("D"),1,"E");
78 ok = myMesh->AddNodeWithID(atof(str1.c_str()),atof(str2.c_str()),atof(str3.c_str()),node);
79 fscanf(myFileId,"%d",&node);
82 found_block2411 = true;
86 MESSAGE("BlockId "<<blockId);
87 fscanf(myFileId,"%d",&cell);
88 //MESSAGE("Cell "<<cell);
90 fscanf(myFileId,"%d %d %d %d %d\n",&n1,&n2,&n3,&n4,&n_nodes);
92 if ((n1==71)||(n1==72)||(n1==74)||(n1==91)||(n1==92)) {//203
94 for (i=1;i<=n_nodes;i++)
95 fscanf(myFileId,"%d",&nodes[i-1]);
96 ok = myMesh->AddFaceWithID(nodes[0],nodes[1],nodes[2],cell);
98 else if (n_nodes==6) {//206
99 for (i=1;i<=n_nodes;i++)
100 fscanf(myFileId,"%d",&nodes[i-1]);
101 ok = myMesh->AddFaceWithID(nodes[0],nodes[2],nodes[4],cell);
105 else if ((n1==11)||(n1==21)||(n1==24)||(n1==25)) {//103
106 fgets(s2,100,myFileId);
108 for (i=1;i<=n_nodes;i++)
109 fscanf(myFileId,"%d",&nodes[i-1]);
110 ok = myMesh->AddEdgeWithID(nodes[0],nodes[1],cell);
111 //MESSAGE("in 103 "<<cell);
113 else if (n_nodes==2) {//102
114 for (i=1;i<=n_nodes;i++)
115 fscanf(myFileId,"%d",&nodes[i-1]);
116 ok = myMesh->AddEdgeWithID(nodes[0],nodes[1],cell);
117 //MESSAGE("in 102 "<<cell);
121 fscanf(myFileId,"\n");
122 fscanf(myFileId,"%d",&cell);
126 found_block2412 = true;
133 MESSAGE("BlockId "<<blockId);
139 fscanf(myFileId,"%s\n",s1);
143 while ((!feof(myFileId))&&((!found_block2411)||(!found_block2412)));
145 /****************************************************************************
146 * FERMETURE DU FICHIER *
147 ****************************************************************************/