1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 #include "DriverDAT_R_SMDS_Mesh.h"
23 #include "SMDS_Mesh.hxx"
25 #include "utilities.h"
29 Driver_Mesh::Status DriverDAT_R_SMDS_Mesh::Perform()
31 Status aResult = DRS_OK;
36 float coordX, coordY, coordZ;
39 int intNumMaille, Degre;
47 MESSAGE("in DriverDAT_R_SMDS_Mesh::Read()");
48 /****************************************************************************
49 * OUVERTURE DU FICHIER EN LECTURE *
50 ****************************************************************************/
51 char *file2Read = (char *)myFile.c_str();
52 FILE* aFileId = fopen(file2Read, "r");
54 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
58 fscanf(aFileId, "%d %d\n", &nbNodes, &nbCells);
60 /****************************************************************************
61 * LECTURE DES NOEUDS *
62 ****************************************************************************/
63 fprintf(stdout, "\n(************************)\n");
64 fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
65 fprintf(stdout, "(************************)\n");
67 for (i = 0; i < nbNodes; i++){
68 fscanf(aFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY, &coordZ);
69 ok = myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint);
72 fprintf(stdout, "%d noeuds\n", myMesh->NbNodes());
73 /****************************************************************************
74 * LECTURE DES ELEMENTS *
75 ****************************************************************************/
76 fprintf(stdout, "\n(**************************)\n");
77 fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
78 fprintf(stdout, "(**************************)");
80 fprintf(stdout, "%d elements\n", nbCells);
82 for (i = 0; i < nbCells; i++) {
83 fscanf(aFileId, "%d %d", &intNumMaille, &ValElement);
84 Degre = abs(ValElement / 100);
85 nbNoeuds = ValElement - (Degre * 100);
87 // Recuperation des noeuds de la maille
88 for (j = 0; j < nbNoeuds; j++) {
89 fscanf(aFileId, "%d", &NoeudMaille);
90 NoeudsMaille[j] = NoeudMaille;
93 // Analyse des cas de cellules
99 ok = myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1],
106 ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
107 NoeudsMaille[2], NoeudsMaille[3],
114 ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
115 NoeudsMaille[2], intNumMaille);
121 if (ValElement == 320){
122 //A voir, correspondance VTK
123 NoeudsMaille[4] = NoeudsMaille[8];
124 NoeudsMaille[5] = NoeudsMaille[9];
125 NoeudsMaille[6] = NoeudsMaille[10];
126 NoeudsMaille[7] = NoeudsMaille[11];
128 ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
129 NoeudsMaille[2], NoeudsMaille[3],
130 NoeudsMaille[4], NoeudsMaille[5],
131 NoeudsMaille[6], NoeudsMaille[7],
138 if (ValElement == 310)
139 NoeudsMaille[3] = NoeudsMaille[6];
140 ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
141 NoeudsMaille[2], NoeudsMaille[3],
148 if (ValElement == 315) {
149 NoeudsMaille[3] = NoeudsMaille[6];
150 NoeudsMaille[4] = NoeudsMaille[7];
151 NoeudsMaille[5] = NoeudsMaille[8];
153 NoeudsMaille[7] = NoeudsMaille[5];
154 NoeudsMaille[6] = NoeudsMaille[5];
155 NoeudsMaille[5] = NoeudsMaille[4];
156 NoeudsMaille[4] = NoeudsMaille[3];
157 NoeudsMaille[3] = NoeudsMaille[2];
158 ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
159 NoeudsMaille[2], NoeudsMaille[3],
160 NoeudsMaille[4], NoeudsMaille[5],
165 /****************************************************************************
166 * FERMETURE DU FICHIER *
167 ****************************************************************************/