1 // Copyright (C) 2007-2012 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
25 #include "DriverDAT_R_SMDS_Mesh.h"
26 #include "SMDS_Mesh.hxx"
28 #include "utilities.h"
30 #include <Basics_Utils.hxx>
34 Driver_Mesh::Status DriverDAT_R_SMDS_Mesh::Perform()
36 Kernel_Utils::Localizer loc;
37 Status aResult = DRS_OK;
42 float coordX, coordY, coordZ;
45 int intNumMaille, Degre;
50 MESSAGE("in DriverDAT_R_SMDS_Mesh::Read()");
51 /****************************************************************************
52 * OUVERTURE DU FICHIER EN LECTURE *
53 ****************************************************************************/
54 char *file2Read = (char *)myFile.c_str();
55 FILE* aFileId = fopen(file2Read, "r");
57 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
61 fscanf(aFileId, "%d %d\n", &nbNodes, &nbCells);
63 /****************************************************************************
64 * LECTURE DES NOEUDS *
65 ****************************************************************************/
66 fprintf(stdout, "\n(************************)\n");
67 fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
68 fprintf(stdout, "(************************)\n");
70 for (i = 0; i < nbNodes; i++){
71 fscanf(aFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY, &coordZ);
72 myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint);
75 fprintf(stdout, "%d noeuds\n", myMesh->NbNodes());
76 /****************************************************************************
77 * LECTURE DES ELEMENTS *
78 ****************************************************************************/
79 fprintf(stdout, "\n(**************************)\n");
80 fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
81 fprintf(stdout, "(**************************)");
83 fprintf(stdout, "%d elements\n", nbCells);
85 for (i = 0; i < nbCells; i++) {
86 fscanf(aFileId, "%d %d", &intNumMaille, &ValElement);
87 Degre = abs(ValElement / 100);
88 nbNoeuds = ValElement - (Degre * 100);
90 // Recuperation des noeuds de la maille
91 for (j = 0; j < nbNoeuds; j++) {
92 fscanf(aFileId, "%d", &NoeudMaille);
93 NoeudsMaille[j] = NoeudMaille;
96 // Analyse des cas de cellules
101 myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1],
107 myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
108 NoeudsMaille[2], NoeudsMaille[3],
114 myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
115 NoeudsMaille[2], intNumMaille);
120 if (ValElement == 320){
121 //A voir, correspondance VTK
122 NoeudsMaille[4] = NoeudsMaille[8];
123 NoeudsMaille[5] = NoeudsMaille[9];
124 NoeudsMaille[6] = NoeudsMaille[10];
125 NoeudsMaille[7] = NoeudsMaille[11];
127 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
128 NoeudsMaille[2], NoeudsMaille[3],
129 NoeudsMaille[4], NoeudsMaille[5],
130 NoeudsMaille[6], NoeudsMaille[7],
136 if (ValElement == 310)
137 NoeudsMaille[3] = NoeudsMaille[6];
138 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
139 NoeudsMaille[2], NoeudsMaille[3],
145 if (ValElement == 315) {
146 NoeudsMaille[3] = NoeudsMaille[6];
147 NoeudsMaille[4] = NoeudsMaille[7];
148 NoeudsMaille[5] = NoeudsMaille[8];
150 NoeudsMaille[7] = NoeudsMaille[5];
151 NoeudsMaille[6] = NoeudsMaille[5];
152 NoeudsMaille[5] = NoeudsMaille[4];
153 NoeudsMaille[4] = NoeudsMaille[3];
154 NoeudsMaille[3] = NoeudsMaille[2];
155 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
156 NoeudsMaille[2], NoeudsMaille[3],
157 NoeudsMaille[4], NoeudsMaille[5],
162 /****************************************************************************
163 * FERMETURE DU FICHIER *
164 ****************************************************************************/