- * ECRITURE DES NOEUDS *
- ****************************************************************************/
- fprintf(stdout, "\n(************************)\n");
- fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
- fprintf(stdout, "(************************)\n");
-
- SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
- while(itNodes->more())
- {
- const SMDS_MeshNode * node = itNodes->next();
- fprintf(myFileId, "%d %e %e %e\n", node->GetID(), node->X(),
- node->Y(), node->Z());
- }
-
- /****************************************************************************
- * ECRITURE DES ELEMENTS *
- ****************************************************************************/
- fprintf(stdout, "\n(**************************)\n");
- fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
- fprintf(stdout, "(**************************)");
- /* Ecriture des connectivites, noms, numeros des mailles */
-
- SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
- while(itEdges->more())
- {
- const SMDS_MeshElement * elem = itEdges->next();
-
- switch (elem->NbNodes())
- {
- case 2:
- {
- fprintf(myFileId, "%d %d ", elem->GetID(), 102);
- break;
- }
- case 3:
- {
- fprintf(myFileId, "%d %d ", elem->GetID(), 103);
- break;
- }
- }
-
- SMDS_ElemIteratorPtr it=elem->nodesIterator();
- while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
-
- fprintf(myFileId, "\n");
- }
-
- SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
- while(itFaces->more())
- {
- const SMDS_MeshElement * elem = itFaces->next();
-
- switch (elem->NbNodes())
- {
- case 3:
- {
- fprintf(myFileId, "%d %d ", elem->GetID(), 203);
- break;
- }
- case 4:
- {
- fprintf(myFileId, "%d %d ", elem->GetID(), 204);
- break;
- }
- case 6:
- {
- fprintf(myFileId, "%d %d ", elem->GetID(), 206);
- break;
- }
- }
-
- SMDS_ElemIteratorPtr it=elem->nodesIterator();
- while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
-
- fprintf(myFileId, "\n");
- }
-
- SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
- while(itVolumes->more())
- {
- const SMDS_MeshElement * elem = itVolumes->next();
-
- switch (elem->NbNodes())
- {
- case 8:
- {
- fprintf(myFileId, "%d %d ", elem->GetID(), 308);
- break;
- }
- }
-
- SMDS_ElemIteratorPtr it=elem->nodesIterator();
- while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
-
- fprintf(myFileId, "\n");
- }
-
- fclose(myFileId);
+ * ECRITURE DES ELEMENTS *
+ ****************************************************************************/
+ /* Ecriture des connectivites, noms, numeros des mailles */
+
+ num = 1;
+ for ( SMDS_EdgeIteratorPtr itEdges = myMesh->edgesIterator(); itEdges->more(); ++num )
+ {
+ const SMDS_MeshElement * elem = itEdges->next();
+ if ( !myRenumber )
+ num = elem->GetID();
+
+ fprintf(aFileId, "%d %d ", num, 100 + elem->NbNodes());
+
+ for ( SMDS_ElemIteratorPtr it = elem->nodesIterator(); it->more(); )
+ {
+ smIdType nodeID = it->next()->GetID();
+ if ( !nodeNumByID.empty() )
+ nodeID = nodeNumByID[ nodeID ];
+ fprintf(aFileId, "%ld ", static_cast< long >( nodeID ));
+ }
+ fprintf(aFileId, "\n");
+ }
+
+ for ( SMDS_FaceIteratorPtr itFaces = myMesh->facesIterator(); itFaces->more(); ++num )
+ {
+ const SMDS_MeshElement * elem = itFaces->next();
+ if ( !myRenumber )
+ num = elem->GetID();
+
+ fprintf(aFileId, "%d %d ", num, (elem->IsPoly() ? 400 : 200 ) + elem->NbNodes() );
+
+ for( SMDS_ElemIteratorPtr it = elem->nodesIterator(); it->more(); )
+ {
+ smIdType nodeID = it->next()->GetID();
+ if ( !nodeNumByID.empty() )
+ nodeID = nodeNumByID[ nodeID ];
+ fprintf(aFileId, "%ld ", static_cast< long >( nodeID ));
+ }
+ fprintf(aFileId, "\n");
+ }
+
+
+ const SMDS_MeshVolume* v;
+ for ( SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator(); itVolumes->more(); ++num )
+ {
+ const SMDS_MeshElement * elem = itVolumes->next();
+ if ( !myRenumber )
+ num = elem->GetID();
+
+ if ( elem->IsPoly() )
+ {
+ fprintf(aFileId, "%d %d ", num, 500 + elem->NbNodes());
+
+ if (( v = myMesh->DownCast< SMDS_MeshVolume >( elem )))
+ {
+ std::vector<int> quant = v->GetQuantities();
+ if ( !quant.empty() )
+ {
+ fprintf(aFileId, "%d %d ", (int)quant.size(), quant[0]);
+ for ( size_t i = 1; i < quant.size(); ++i )
+ fprintf(aFileId, "%d ", quant[i]);
+ }
+ }
+ }
+ else
+ {
+ fprintf(aFileId, "%d %d ", num, 300 + elem->NbNodes());
+ }
+
+ for( SMDS_ElemIteratorPtr it = elem->nodesIterator(); it->more(); )
+ {
+ smIdType nodeID = it->next()->GetID();
+ if ( !nodeNumByID.empty() )
+ nodeID = nodeNumByID[ nodeID ];
+ fprintf(aFileId, "%ld ", static_cast< long >( nodeID ));
+ }
+
+ fprintf(aFileId, "\n");
+ }
+
+ fclose(aFileId);
+
+ return aResult;