1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 #include "DriverDAT_W_SMDS_Mesh.h"
24 #include "SMDS_Mesh.hxx"
26 #include "utilities.h"
30 Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform()
32 Status aResult = DRS_OK;
37 char *file2Read = (char *)myFile.c_str();
38 FILE* aFileId = fopen(file2Read, "w+");
40 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
44 /****************************************************************************
46 ****************************************************************************/
47 fprintf(stdout, "\n(****************************)\n");
48 fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n");
49 fprintf(stdout, "(****************************)\n");
51 /* Combien de noeuds ? */
52 nbNodes = myMesh->NbNodes();
54 /* Combien de mailles, faces ou aretes ? */
55 int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes;
56 nb_of_edges = myMesh->NbEdges();
57 nb_of_faces = myMesh->NbFaces();
58 nb_of_volumes = myMesh->NbVolumes();
59 nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
62 SCRUTE(nb_of_volumes);
64 fprintf(stdout, "%d %d\n", nbNodes, nbCells);
65 fprintf(aFileId, "%d %d\n", nbNodes, nbCells);
67 /****************************************************************************
68 * ECRITURE DES NOEUDS *
69 ****************************************************************************/
70 fprintf(stdout, "\n(************************)\n");
71 fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
72 fprintf(stdout, "(************************)\n");
74 SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
75 while(itNodes->more()){
76 const SMDS_MeshNode * node = itNodes->next();
77 fprintf(aFileId, "%d %e %e %e\n", node->GetID(), node->X(), node->Y(), node->Z());
80 /****************************************************************************
81 * ECRITURE DES ELEMENTS *
82 ****************************************************************************/
83 fprintf(stdout, "\n(**************************)\n");
84 fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
85 fprintf(stdout, "(**************************)");
86 /* Ecriture des connectivites, noms, numeros des mailles */
88 SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
89 while(itEdges->more()){
90 const SMDS_MeshElement * elem = itEdges->next();
91 switch (elem->NbNodes()) {
93 fprintf(aFileId, "%d %d ", elem->GetID(), 102);
96 fprintf(aFileId, "%d %d ", elem->GetID(), 103);
99 SMDS_ElemIteratorPtr it=elem->nodesIterator();
101 fprintf(aFileId, "%d ", it->next()->GetID());
102 fprintf(aFileId, "\n");
105 SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
106 while(itFaces->more()){
107 const SMDS_MeshElement * elem = itFaces->next();
108 switch (elem->NbNodes()) {
110 fprintf(aFileId, "%d %d ", elem->GetID(), 203);
113 fprintf(aFileId, "%d %d ", elem->GetID(), 204);
116 fprintf(aFileId, "%d %d ", elem->GetID(), 206);
119 SMDS_ElemIteratorPtr it=elem->nodesIterator();
121 fprintf(aFileId, "%d ", it->next()->GetID());
122 fprintf(aFileId, "\n");
125 SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
126 while(itVolumes->more()){
127 const SMDS_MeshElement * elem = itVolumes->next();
128 switch (elem->NbNodes()) {
130 fprintf(aFileId, "%d %d ", elem->GetID(), 308);
134 SMDS_ElemIteratorPtr it=elem->nodesIterator();
136 fprintf(aFileId, "%d ", it->next()->GetID());
138 fprintf(aFileId, "\n");