1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #include "DriverDAT_R_SMDS_Mesh.h"
25 #include "SMDS_Mesh.hxx"
27 #include "utilities.h"
29 #include <Basics_Utils.hxx>
33 Driver_Mesh::Status DriverDAT_R_SMDS_Mesh::Perform()
35 Kernel_Utils::Localizer loc;
36 Status aResult = DRS_OK;
41 float coordX, coordY, coordZ;
44 int intNumMaille, Degre;
52 MESSAGE("in DriverDAT_R_SMDS_Mesh::Read()");
53 /****************************************************************************
54 * OUVERTURE DU FICHIER EN LECTURE *
55 ****************************************************************************/
56 char *file2Read = (char *)myFile.c_str();
57 FILE* aFileId = fopen(file2Read, "r");
59 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
63 fscanf(aFileId, "%d %d\n", &nbNodes, &nbCells);
65 /****************************************************************************
66 * LECTURE DES NOEUDS *
67 ****************************************************************************/
68 fprintf(stdout, "\n(************************)\n");
69 fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
70 fprintf(stdout, "(************************)\n");
72 for (i = 0; i < nbNodes; i++){
73 fscanf(aFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY, &coordZ);
74 ok = myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint);
77 fprintf(stdout, "%d noeuds\n", myMesh->NbNodes());
78 /****************************************************************************
79 * LECTURE DES ELEMENTS *
80 ****************************************************************************/
81 fprintf(stdout, "\n(**************************)\n");
82 fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
83 fprintf(stdout, "(**************************)");
85 fprintf(stdout, "%d elements\n", nbCells);
87 for (i = 0; i < nbCells; i++) {
88 fscanf(aFileId, "%d %d", &intNumMaille, &ValElement);
89 Degre = abs(ValElement / 100);
90 nbNoeuds = ValElement - (Degre * 100);
92 // Recuperation des noeuds de la maille
93 for (j = 0; j < nbNoeuds; j++) {
94 fscanf(aFileId, "%d", &NoeudMaille);
95 NoeudsMaille[j] = NoeudMaille;
98 // Analyse des cas de cellules
104 ok = myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1],
111 ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
112 NoeudsMaille[2], NoeudsMaille[3],
119 ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
120 NoeudsMaille[2], intNumMaille);
126 if (ValElement == 320){
127 //A voir, correspondance VTK
128 NoeudsMaille[4] = NoeudsMaille[8];
129 NoeudsMaille[5] = NoeudsMaille[9];
130 NoeudsMaille[6] = NoeudsMaille[10];
131 NoeudsMaille[7] = NoeudsMaille[11];
133 ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
134 NoeudsMaille[2], NoeudsMaille[3],
135 NoeudsMaille[4], NoeudsMaille[5],
136 NoeudsMaille[6], NoeudsMaille[7],
143 if (ValElement == 310)
144 NoeudsMaille[3] = NoeudsMaille[6];
145 ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
146 NoeudsMaille[2], NoeudsMaille[3],
153 if (ValElement == 315) {
154 NoeudsMaille[3] = NoeudsMaille[6];
155 NoeudsMaille[4] = NoeudsMaille[7];
156 NoeudsMaille[5] = NoeudsMaille[8];
158 NoeudsMaille[7] = NoeudsMaille[5];
159 NoeudsMaille[6] = NoeudsMaille[5];
160 NoeudsMaille[5] = NoeudsMaille[4];
161 NoeudsMaille[4] = NoeudsMaille[3];
162 NoeudsMaille[3] = NoeudsMaille[2];
163 ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
164 NoeudsMaille[2], NoeudsMaille[3],
165 NoeudsMaille[4], NoeudsMaille[5],
170 /****************************************************************************
171 * FERMETURE DU FICHIER *
172 ****************************************************************************/