2 #include "DriverUNV_W_SMDS_Mesh.h"
4 #include "SMDS_MeshElement.hxx"
5 #include "SMDS_MeshNode.hxx"
11 #include <utilities.h>
13 #define sNODE_UNV_ID " 2411"
14 #define sELT_UNV_ID " 2412"
15 #define sUNV_SEPARATOR " -1"
16 #define sNODE_UNV_DESCR "%10d 1 1 11\n"
17 #define sELT_SURF_DESC "%10d %2d 1 1 11 %1d\n"
18 #define sELT_VOLU_DESC "%10d %2d 1 1 9 %1d\n"
19 #define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n"
20 #define sELT_BEAM_DESC2 " 0 1 1\n"
22 DriverUNV_W_SMDS_Mesh::DriverUNV_W_SMDS_Mesh()
27 DriverUNV_W_SMDS_Mesh::~DriverUNV_W_SMDS_Mesh()
32 void DriverUNV_W_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
37 void DriverUNV_W_SMDS_Mesh::SetFile(string aFile)
42 void DriverUNV_W_SMDS_Mesh::SetFileId(FILE * aFileId)
47 void DriverUNV_W_SMDS_Mesh::SetMeshId(int aMeshId)
52 void DriverUNV_W_SMDS_Mesh::Add()
57 void DriverUNV_W_SMDS_Mesh::Write()
63 char *file2Read = (char *)myFile.c_str();
64 myFileId = fopen(file2Read, "w+");
67 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
71 /****************************************************************************
73 ****************************************************************************/
74 fprintf(stdout, "\n(****************************)\n");
75 fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n");
76 fprintf(stdout, "(****************************)\n");
78 /* Combien de noeuds ? */
79 nbNodes = myMesh->NbNodes();
81 /* Combien de mailles, faces ou aretes ? */
82 int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes;
83 nb_of_edges = myMesh->NbEdges();
84 nb_of_faces = myMesh->NbFaces();
85 nb_of_volumes = myMesh->NbVolumes();
86 nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
89 SCRUTE(nb_of_volumes);
91 fprintf(stdout, "%d %d\n", nbNodes, nbCells);
92 fprintf(myFileId, "%d %d\n", nbNodes, nbCells);
94 /****************************************************************************
95 * ECRITURE DES NOEUDS *
96 ****************************************************************************/
97 fprintf(stdout, "\n(************************)\n");
98 fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
99 fprintf(stdout, "(************************)\n");
101 fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
102 fprintf(myFileId, "%s\n", sNODE_UNV_ID);
104 SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
105 while(itNodes->more())
107 const SMDS_MeshNode * node = itNodes->next();
109 fprintf(myFileId, sNODE_UNV_DESCR, node->GetID());
110 fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(),
114 fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
116 /****************************************************************************
117 * ECRITURE DES ELEMENTS *
118 ****************************************************************************/
119 fprintf(stdout, "\n(**************************)\n");
120 fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
121 fprintf(stdout, "(**************************)");
122 /* Ecriture des connectivites, noms, numeros des mailles */
124 fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
125 fprintf(myFileId, "%s\n", sELT_UNV_ID);
127 SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
128 while(itEdges->more())
130 const SMDS_MeshElement * elem = itEdges->next();
131 SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
133 switch (elem->NbNodes())
136 fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21,
138 fprintf(myFileId, sELT_BEAM_DESC2);
139 fprintf(myFileId, "%10d%10d\n", itn->next()->GetID(),
140 itn->next()->GetID());
144 fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24,
146 fprintf(myFileId, sELT_BEAM_DESC2);
147 fprintf(myFileId, "%10d%10d%10d\n", itn->next()->GetID(),
148 itn->next()->GetID(), itn->next()->GetID());
156 SMDS_Iterator<const SMDS_MeshFace*> * itFaces=myMesh->facesIterator();
157 while(itFaces->more())
159 const SMDS_MeshElement * elem = itFaces->next();
161 switch (elem->NbNodes())
165 fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74,
169 // linear quadrilateral
170 fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71,
174 // parabolic triangle
175 fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72,
179 // parabolic quadrilateral
180 fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75,
184 fprintf(myFileId, "element not registered\n");
187 SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
188 while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
191 fprintf(myFileId, "\n");
195 SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
196 while(itVolumes->more())
198 const SMDS_MeshElement * elem = itVolumes->next();
200 switch (elem->NbNodes())
203 // linear tetrahedron
204 fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111,
208 // linear tetrahedron
209 fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112,
214 fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115,
219 SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
220 while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
223 fprintf(myFileId, "\n");
227 fprintf(myFileId, "%s\n", sUNV_SEPARATOR);