Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/smesh.git] / src / DriverDAT / DriverDAT_W_SMDS_Mesh.cxx
index d99a124fa89f4500f8ce028f6234da23a92c14b1..8f6a7068d6ea865289302b3bb8f95635c5c44e4a 100644 (file)
 //  File   : DriverDAT_W_SMDS_Mesh.cxx
 //  Module : SMESH
 
+using namespace std;
 #include "DriverDAT_W_SMDS_Mesh.h"
+
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
-#include "utilities.h"
 
-extern "C"
-{
-
-/**
- * Factory function which will be called by SMESHDriver
- */
-void * SMESH_createDATMeshWriter()
-{
-       return new DriverDAT_W_SMDS_Mesh();
-}
-}
+#include "utilities.h"
 
 DriverDAT_W_SMDS_Mesh::DriverDAT_W_SMDS_Mesh()
 {
+       ;
 }
 
 DriverDAT_W_SMDS_Mesh::~DriverDAT_W_SMDS_Mesh()
@@ -72,12 +64,12 @@ void DriverDAT_W_SMDS_Mesh::SetMeshId(int aMeshId)
 
 void DriverDAT_W_SMDS_Mesh::Add()
 {
-       MESSAGE("Adding a mesh to a DAT document. As DAT do not support more than one mesh in a file, the previous mesh is deleted");
-       Write();
+       ;
 }
 
 void DriverDAT_W_SMDS_Mesh::Write()
 {
+
        int nbNodes, nbCells;
        int i;
 
@@ -88,7 +80,7 @@ void DriverDAT_W_SMDS_Mesh::Write()
                fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
                exit(EXIT_FAILURE);
        }
-
+       SCRUTE(myMesh);
   /****************************************************************************
   *                       NOMBRES D'OBJETS                                    *
   ****************************************************************************/
@@ -105,6 +97,9 @@ void DriverDAT_W_SMDS_Mesh::Write()
        nb_of_faces = myMesh->NbFaces();
        nb_of_volumes = myMesh->NbVolumes();
        nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
+       SCRUTE(nb_of_edges);
+       SCRUTE(nb_of_faces);
+       SCRUTE(nb_of_volumes);
 
        fprintf(stdout, "%d %d\n", nbNodes, nbCells);
        fprintf(myFileId, "%d %d\n", nbNodes, nbCells);
@@ -116,15 +111,14 @@ void DriverDAT_W_SMDS_Mesh::Write()
        fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
        fprintf(stdout, "(************************)\n");
 
-       SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
+       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());
        }
-       delete itNodes;
-
+       
   /****************************************************************************
   *                       ECRITURE DES ELEMENTS                                *
   ****************************************************************************/
@@ -133,10 +127,10 @@ void DriverDAT_W_SMDS_Mesh::Write()
        fprintf(stdout, "(**************************)");
        /* Ecriture des connectivites, noms, numeros des mailles */
 
-       SMDS_Iterator<const SMDS_MeshEdge*> * itEdges=myMesh->edgesIterator();
+       SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
        while(itEdges->more())
        {
-               const SMDS_MeshEdge * elem = itEdges->next();
+               const SMDS_MeshElement * elem = itEdges->next();
 
                switch (elem->NbNodes())
                {
@@ -152,15 +146,13 @@ void DriverDAT_W_SMDS_Mesh::Write()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
-               while(itNodes->more())
-                       fprintf(myFileId, "%d ", itNodes->next()->GetID());
-               
+               SMDS_ElemIteratorPtr it=elem->nodesIterator();
+               while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
+
                fprintf(myFileId, "\n");
        }
-       delete itEdges;
 
-       SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
+       SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
        while(itFaces->more())
        {
                const SMDS_MeshElement * elem = itFaces->next();
@@ -184,16 +176,13 @@ void DriverDAT_W_SMDS_Mesh::Write()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
-               while(itNodes->more())
-                       fprintf(myFileId, "%d ", itNodes->next()->GetID());
-               delete itNodes;
-       
+               SMDS_ElemIteratorPtr it=elem->nodesIterator();
+               while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
+
                fprintf(myFileId, "\n");
        }
-       delete itFaces;
 
-       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
+       SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
        while(itVolumes->more())
        {
                const SMDS_MeshElement * elem = itVolumes->next();
@@ -207,14 +196,11 @@ void DriverDAT_W_SMDS_Mesh::Write()
                }
                }
 
-               SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
-               while(itNodes->more())
-                       fprintf(myFileId, "%d ", itNodes->next()->GetID());
-               delete itNodes; 
+               SMDS_ElemIteratorPtr it=elem->nodesIterator();
+               while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
 
                fprintf(myFileId, "\n");
        }
-       delete itVolumes;
 
        fclose(myFileId);
 }