1 // Copyright (C) 2007-2019 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, or (at your option) any later version.
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 /****************************************************************************
51 * OUVERTURE DU FICHIER EN LECTURE *
52 ****************************************************************************/
53 char *file2Read = (char *)myFile.c_str();
54 FILE* aFileId = fopen(file2Read, "r");
56 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
60 fscanf(aFileId, "%d %d\n", &nbNodes, &nbCells);
62 /****************************************************************************
63 * LECTURE DES NOEUDS *
64 ****************************************************************************/
65 fprintf(stdout, "\n(************************)\n");
66 fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
67 fprintf(stdout, "(************************)\n");
69 for (i = 0; i < nbNodes; i++){
70 fscanf(aFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY, &coordZ);
71 myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint);
74 fprintf(stdout, "%d noeuds\n", myMesh->NbNodes());
75 /****************************************************************************
76 * LECTURE DES ELEMENTS *
77 ****************************************************************************/
78 fprintf(stdout, "\n(**************************)\n");
79 fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
80 fprintf(stdout, "(**************************)");
82 fprintf(stdout, "%d elements\n", nbCells);
84 for (i = 0; i < nbCells; i++) {
85 fscanf(aFileId, "%d %d", &intNumMaille, &ValElement);
86 Degre = abs(ValElement / 100);
87 nbNoeuds = ValElement - (Degre * 100);
89 // Recuperation des noeuds de la maille
90 for (j = 0; j < nbNoeuds; j++) {
91 fscanf(aFileId, "%d", &NoeudMaille);
92 NoeudsMaille[j] = NoeudMaille;
95 // Analyse des cas de cellules
100 myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1],
106 myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
107 NoeudsMaille[2], NoeudsMaille[3],
113 myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
114 NoeudsMaille[2], intNumMaille);
119 if (ValElement == 320){
120 //A voir, correspondance VTK
121 NoeudsMaille[4] = NoeudsMaille[8];
122 NoeudsMaille[5] = NoeudsMaille[9];
123 NoeudsMaille[6] = NoeudsMaille[10];
124 NoeudsMaille[7] = NoeudsMaille[11];
126 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
127 NoeudsMaille[2], NoeudsMaille[3],
128 NoeudsMaille[4], NoeudsMaille[5],
129 NoeudsMaille[6], NoeudsMaille[7],
135 if (ValElement == 310)
136 NoeudsMaille[3] = NoeudsMaille[6];
137 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
138 NoeudsMaille[2], NoeudsMaille[3],
144 if (ValElement == 315) {
145 NoeudsMaille[3] = NoeudsMaille[6];
146 NoeudsMaille[4] = NoeudsMaille[7];
147 NoeudsMaille[5] = NoeudsMaille[8];
149 NoeudsMaille[7] = NoeudsMaille[5];
150 NoeudsMaille[6] = NoeudsMaille[5];
151 NoeudsMaille[5] = NoeudsMaille[4];
152 NoeudsMaille[4] = NoeudsMaille[3];
153 NoeudsMaille[3] = NoeudsMaille[2];
154 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
155 NoeudsMaille[2], NoeudsMaille[3],
156 NoeudsMaille[4], NoeudsMaille[5],
161 /****************************************************************************
162 * FERMETURE DU FICHIER *
163 ****************************************************************************/