1 // Copyright (C) 2007-2008 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
24 #include "DriverDAT_W_SMDS_Mesh.h"
26 #include "SMDS_Mesh.hxx"
28 #include "utilities.h"
32 Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform()
34 Status aResult = DRS_OK;
39 char *file2Read = (char *)myFile.c_str();
40 FILE* aFileId = fopen(file2Read, "w+");
42 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
46 /****************************************************************************
48 ****************************************************************************/
49 fprintf(stdout, "\n(****************************)\n");
50 fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n");
51 fprintf(stdout, "(****************************)\n");
53 /* Combien de noeuds ? */
54 nbNodes = myMesh->NbNodes();
56 /* Combien de mailles, faces ou aretes ? */
57 int /*nb_of_nodes,*/ nb_of_edges, nb_of_faces, nb_of_volumes;
58 nb_of_edges = myMesh->NbEdges();
59 nb_of_faces = myMesh->NbFaces();
60 nb_of_volumes = myMesh->NbVolumes();
61 nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
64 SCRUTE(nb_of_volumes);
66 fprintf(stdout, "%d %d\n", nbNodes, nbCells);
67 fprintf(aFileId, "%d %d\n", nbNodes, nbCells);
69 /****************************************************************************
70 * ECRITURE DES NOEUDS *
71 ****************************************************************************/
72 fprintf(stdout, "\n(************************)\n");
73 fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
74 fprintf(stdout, "(************************)\n");
76 SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
77 while(itNodes->more()){
78 const SMDS_MeshNode * node = itNodes->next();
79 fprintf(aFileId, "%d %e %e %e\n", node->GetID(), node->X(), node->Y(), node->Z());
82 /****************************************************************************
83 * ECRITURE DES ELEMENTS *
84 ****************************************************************************/
85 fprintf(stdout, "\n(**************************)\n");
86 fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
87 fprintf(stdout, "(**************************)");
88 /* Ecriture des connectivites, noms, numeros des mailles */
90 SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
91 while(itEdges->more()){
92 const SMDS_MeshElement * elem = itEdges->next();
93 switch (elem->NbNodes()) {
95 fprintf(aFileId, "%d %d ", elem->GetID(), 102);
98 fprintf(aFileId, "%d %d ", elem->GetID(), 103);
101 SMDS_ElemIteratorPtr it=elem->nodesIterator();
103 fprintf(aFileId, "%d ", it->next()->GetID());
104 fprintf(aFileId, "\n");
107 SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
108 while(itFaces->more()){
109 const SMDS_MeshElement * elem = itFaces->next();
110 switch (elem->NbNodes()) {
112 fprintf(aFileId, "%d %d ", elem->GetID(), 203);
115 fprintf(aFileId, "%d %d ", elem->GetID(), 204);
118 fprintf(aFileId, "%d %d ", elem->GetID(), 206);
121 SMDS_ElemIteratorPtr it=elem->nodesIterator();
123 fprintf(aFileId, "%d ", it->next()->GetID());
124 fprintf(aFileId, "\n");
127 SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
128 while(itVolumes->more()){
129 const SMDS_MeshElement * elem = itVolumes->next();
130 switch (elem->NbNodes()) {
132 fprintf(aFileId, "%d %d ", elem->GetID(), 308);
136 SMDS_ElemIteratorPtr it=elem->nodesIterator();
138 fprintf(aFileId, "%d ", it->next()->GetID());
140 fprintf(aFileId, "\n");