2021-03-23 19:44:27 +05:00
|
|
|
// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
2014-02-20 18:25:37 +06:00
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2009-02-17 10:27:49 +05:00
|
|
|
//
|
2012-08-09 16:03:55 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-05-19 19:18:36 +06:00
|
|
|
#include "DriverDAT_R_SMDS_Mesh.h"
|
2004-12-01 15:48:31 +05:00
|
|
|
#include "SMDS_Mesh.hxx"
|
2004-03-15 23:42:16 +05:00
|
|
|
|
2004-06-18 14:34:31 +06:00
|
|
|
#include "utilities.h"
|
2004-03-15 23:42:16 +05:00
|
|
|
|
2012-08-09 16:03:55 +06:00
|
|
|
#include <Basics_Utils.hxx>
|
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
using namespace std;
|
2003-05-19 19:18:36 +06:00
|
|
|
|
2004-12-01 15:48:31 +05:00
|
|
|
Driver_Mesh::Status DriverDAT_R_SMDS_Mesh::Perform()
|
2003-09-04 18:03:27 +06:00
|
|
|
{
|
2012-08-09 16:03:55 +06:00
|
|
|
Kernel_Utils::Localizer loc;
|
2004-12-01 15:48:31 +05:00
|
|
|
Status aResult = DRS_OK;
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
int nbNodes, nbCells;
|
|
|
|
int intNumPoint;
|
|
|
|
float coordX, coordY, coordZ;
|
|
|
|
int nbNoeuds;
|
|
|
|
|
|
|
|
int intNumMaille, Degre;
|
|
|
|
int ValElement;
|
|
|
|
int NoeudsMaille[20];
|
|
|
|
int NoeudMaille;
|
|
|
|
|
2003-05-19 19:18:36 +06:00
|
|
|
/****************************************************************************
|
2004-12-01 15:48:31 +05:00
|
|
|
* OUVERTURE DU FICHIER EN LECTURE *
|
|
|
|
****************************************************************************/
|
2019-02-21 14:00:42 +05:00
|
|
|
#if defined(WIN32) && defined(UNICODE)
|
|
|
|
std::wstring file2Read = Kernel_Utils::utf8_decode_s(myFile);
|
|
|
|
FILE* aFileId = _wfopen(file2Read.c_str(), L"r");
|
|
|
|
#else
|
2004-12-01 15:48:31 +05:00
|
|
|
char *file2Read = (char *)myFile.c_str();
|
|
|
|
FILE* aFileId = fopen(file2Read, "r");
|
2019-02-21 14:00:42 +05:00
|
|
|
#endif
|
2015-05-05 17:47:33 +05:00
|
|
|
if ( !aFileId ) {
|
2004-12-01 15:48:31 +05:00
|
|
|
fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
|
|
|
|
return DRS_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
fscanf(aFileId, "%d %d\n", &nbNodes, &nbCells);
|
|
|
|
|
2003-05-19 19:18:36 +06:00
|
|
|
/****************************************************************************
|
2004-12-01 15:48:31 +05:00
|
|
|
* LECTURE DES NOEUDS *
|
|
|
|
****************************************************************************/
|
|
|
|
fprintf(stdout, "\n(************************)\n");
|
|
|
|
fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
|
|
|
|
fprintf(stdout, "(************************)\n");
|
|
|
|
|
|
|
|
for (i = 0; i < nbNodes; i++){
|
|
|
|
fscanf(aFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY, &coordZ);
|
2012-08-09 16:03:55 +06:00
|
|
|
myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint);
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
|
2021-07-06 18:17:33 +05:00
|
|
|
fprintf(stdout, "%ld noeuds\n", static_cast< long >( myMesh->NbNodes() ));
|
2003-05-19 19:18:36 +06:00
|
|
|
/****************************************************************************
|
2004-12-01 15:48:31 +05:00
|
|
|
* LECTURE DES ELEMENTS *
|
|
|
|
****************************************************************************/
|
|
|
|
fprintf(stdout, "\n(**************************)\n");
|
|
|
|
fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
|
|
|
|
fprintf(stdout, "(**************************)");
|
|
|
|
|
|
|
|
fprintf(stdout, "%d elements\n", nbCells);
|
|
|
|
|
|
|
|
for (i = 0; i < nbCells; i++) {
|
|
|
|
fscanf(aFileId, "%d %d", &intNumMaille, &ValElement);
|
|
|
|
Degre = abs(ValElement / 100);
|
|
|
|
nbNoeuds = ValElement - (Degre * 100);
|
|
|
|
|
|
|
|
// Recuperation des noeuds de la maille
|
|
|
|
for (j = 0; j < nbNoeuds; j++) {
|
|
|
|
fscanf(aFileId, "%d", &NoeudMaille);
|
|
|
|
NoeudsMaille[j] = NoeudMaille;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Analyse des cas de cellules
|
|
|
|
switch (ValElement) {
|
|
|
|
case 102:
|
|
|
|
case 103:
|
|
|
|
nbNoeuds = 2;
|
2012-08-09 16:03:55 +06:00
|
|
|
myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1],
|
|
|
|
intNumMaille);
|
2004-12-01 15:48:31 +05:00
|
|
|
break;
|
|
|
|
case 204:
|
|
|
|
case 208:
|
|
|
|
nbNoeuds = 4;
|
2012-08-09 16:03:55 +06:00
|
|
|
myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
|
|
|
|
NoeudsMaille[2], NoeudsMaille[3],
|
|
|
|
intNumMaille);
|
2004-12-01 15:48:31 +05:00
|
|
|
break;
|
|
|
|
case 203:
|
|
|
|
case 206:
|
|
|
|
nbNoeuds = 3;
|
2012-08-09 16:03:55 +06:00
|
|
|
myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
|
|
|
|
NoeudsMaille[2], intNumMaille);
|
2004-12-01 15:48:31 +05:00
|
|
|
break;
|
|
|
|
case 308:
|
|
|
|
case 320:
|
|
|
|
nbNoeuds = 8;
|
|
|
|
if (ValElement == 320){
|
2012-08-09 16:03:55 +06:00
|
|
|
//A voir, correspondance VTK
|
|
|
|
NoeudsMaille[4] = NoeudsMaille[8];
|
|
|
|
NoeudsMaille[5] = NoeudsMaille[9];
|
|
|
|
NoeudsMaille[6] = NoeudsMaille[10];
|
|
|
|
NoeudsMaille[7] = NoeudsMaille[11];
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
2012-08-09 16:03:55 +06:00
|
|
|
myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
|
|
|
|
NoeudsMaille[2], NoeudsMaille[3],
|
|
|
|
NoeudsMaille[4], NoeudsMaille[5],
|
|
|
|
NoeudsMaille[6], NoeudsMaille[7],
|
|
|
|
intNumMaille);
|
2004-12-01 15:48:31 +05:00
|
|
|
break;
|
|
|
|
case 304:
|
|
|
|
case 310:
|
|
|
|
nbNoeuds = 4;
|
|
|
|
if (ValElement == 310)
|
2012-08-09 16:03:55 +06:00
|
|
|
NoeudsMaille[3] = NoeudsMaille[6];
|
|
|
|
myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
|
|
|
|
NoeudsMaille[2], NoeudsMaille[3],
|
|
|
|
intNumMaille);
|
2004-12-01 15:48:31 +05:00
|
|
|
break;
|
|
|
|
case 306:
|
|
|
|
case 315:
|
|
|
|
nbNoeuds = 8;
|
|
|
|
if (ValElement == 315) {
|
2012-08-09 16:03:55 +06:00
|
|
|
NoeudsMaille[3] = NoeudsMaille[6];
|
|
|
|
NoeudsMaille[4] = NoeudsMaille[7];
|
|
|
|
NoeudsMaille[5] = NoeudsMaille[8];
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
NoeudsMaille[7] = NoeudsMaille[5];
|
|
|
|
NoeudsMaille[6] = NoeudsMaille[5];
|
|
|
|
NoeudsMaille[5] = NoeudsMaille[4];
|
|
|
|
NoeudsMaille[4] = NoeudsMaille[3];
|
|
|
|
NoeudsMaille[3] = NoeudsMaille[2];
|
2012-08-09 16:03:55 +06:00
|
|
|
myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
|
|
|
|
NoeudsMaille[2], NoeudsMaille[3],
|
|
|
|
NoeudsMaille[4], NoeudsMaille[5],
|
|
|
|
intNumMaille);
|
|
|
|
break;
|
2004-12-01 15:48:31 +05:00
|
|
|
}
|
|
|
|
}
|
2003-05-19 19:18:36 +06:00
|
|
|
/****************************************************************************
|
2004-12-01 15:48:31 +05:00
|
|
|
* FERMETURE DU FICHIER *
|
|
|
|
****************************************************************************/
|
|
|
|
fclose(aFileId);
|
|
|
|
return aResult;
|
2003-05-19 19:18:36 +06:00
|
|
|
}
|