1 // Copyright (C) 2007-2021 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 #if defined(WIN32) && defined(UNICODE)
54 std::wstring file2Read = Kernel_Utils::utf8_decode_s(myFile);
55 FILE* aFileId = _wfopen(file2Read.c_str(), L"r");
57 char *file2Read = (char *)myFile.c_str();
58 FILE* aFileId = fopen(file2Read, "r");
61 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
65 fscanf(aFileId, "%d %d\n", &nbNodes, &nbCells);
67 /****************************************************************************
68 * LECTURE DES NOEUDS *
69 ****************************************************************************/
70 fprintf(stdout, "\n(************************)\n");
71 fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
72 fprintf(stdout, "(************************)\n");
74 for (i = 0; i < nbNodes; i++){
75 fscanf(aFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY, &coordZ);
76 myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint);
79 fprintf(stdout, "%d noeuds\n", myMesh->NbNodes());
80 /****************************************************************************
81 * LECTURE DES ELEMENTS *
82 ****************************************************************************/
83 fprintf(stdout, "\n(**************************)\n");
84 fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
85 fprintf(stdout, "(**************************)");
87 fprintf(stdout, "%d elements\n", nbCells);
89 for (i = 0; i < nbCells; i++) {
90 fscanf(aFileId, "%d %d", &intNumMaille, &ValElement);
91 Degre = abs(ValElement / 100);
92 nbNoeuds = ValElement - (Degre * 100);
94 // Recuperation des noeuds de la maille
95 for (j = 0; j < nbNoeuds; j++) {
96 fscanf(aFileId, "%d", &NoeudMaille);
97 NoeudsMaille[j] = NoeudMaille;
100 // Analyse des cas de cellules
101 switch (ValElement) {
105 myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1],
111 myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
112 NoeudsMaille[2], NoeudsMaille[3],
118 myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
119 NoeudsMaille[2], intNumMaille);
124 if (ValElement == 320){
125 //A voir, correspondance VTK
126 NoeudsMaille[4] = NoeudsMaille[8];
127 NoeudsMaille[5] = NoeudsMaille[9];
128 NoeudsMaille[6] = NoeudsMaille[10];
129 NoeudsMaille[7] = NoeudsMaille[11];
131 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
132 NoeudsMaille[2], NoeudsMaille[3],
133 NoeudsMaille[4], NoeudsMaille[5],
134 NoeudsMaille[6], NoeudsMaille[7],
140 if (ValElement == 310)
141 NoeudsMaille[3] = NoeudsMaille[6];
142 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
143 NoeudsMaille[2], NoeudsMaille[3],
149 if (ValElement == 315) {
150 NoeudsMaille[3] = NoeudsMaille[6];
151 NoeudsMaille[4] = NoeudsMaille[7];
152 NoeudsMaille[5] = NoeudsMaille[8];
154 NoeudsMaille[7] = NoeudsMaille[5];
155 NoeudsMaille[6] = NoeudsMaille[5];
156 NoeudsMaille[5] = NoeudsMaille[4];
157 NoeudsMaille[4] = NoeudsMaille[3];
158 NoeudsMaille[3] = NoeudsMaille[2];
159 myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
160 NoeudsMaille[2], NoeudsMaille[3],
161 NoeudsMaille[4], NoeudsMaille[5],
166 /****************************************************************************
167 * FERMETURE DU FICHIER *
168 ****************************************************************************/