Salome HOME
Update to match the changes in SMDS
[modules/smesh.git] / src / DriverUNV / DriverUNV_W_SMESHDS_Document.cxx
1 using namespace std;
2 #include "DriverUNV_W_SMESHDS_Document.h"
3 #include "DriverUNV_W_SMESHDS_Mesh.h"
4
5 #include "utilities.h"
6
7 extern "C"
8 {
9         Document_Writer *Wmaker()
10         {
11                 return new DriverUNV_W_SMESHDS_Document;
12         }
13 }
14
15 DriverUNV_W_SMESHDS_Document::DriverUNV_W_SMESHDS_Document()
16 {
17         ;
18 }
19
20 DriverUNV_W_SMESHDS_Document::~DriverUNV_W_SMESHDS_Document()
21 {
22         ;
23 }
24
25 //void DriverUNV_W_SMESHDS_Document::SetFile(string aFile) {
26 //myFile = aFile;
27 //}
28
29 //void DriverUNV_W_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDocument) {
30 //myDocument = aDocument;
31 //}
32
33 void DriverUNV_W_SMESHDS_Document::Write()
34 {
35
36         SMESHDS_Mesh * myMesh;
37
38   /****************************************************************************
39   *                      OUVERTURE DU FICHIER EN ECRITURE                      *
40   ****************************************************************************/
41         char *file2Write = (char *)myFile.c_str();
42         FILE *fid = fopen(file2Write, "w+");
43         if (fid < 0)
44         {
45                 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Write);
46                 exit(EXIT_FAILURE);
47         }
48
49   /****************************************************************************
50   *                      FERMETURE DU FICHIER                                 *
51   ****************************************************************************/
52
53         fclose(fid);
54
55   /******** Nombre de maillages ********/
56         int nb_of_meshes = myDocument->NbMeshes();      //voir avec Yves
57         //nb_of_meshes = 1;
58         int numero = 0;
59
60         string myClass = string("SMESHDS_Mesh");
61         string myExtension = string("UNV");
62
63         //while (numero<nb_of_meshes) {
64         //numero++;
65         //myMesh = myDocument->GetMesh(numero);
66         myDocument->InitMeshesIterator();
67         while(myDocument->MoreMesh())
68         {
69                 numero++;
70                 myMesh = myDocument->NextMesh();
71
72                 DriverUNV_W_SMESHDS_Mesh *myWriter = new DriverUNV_W_SMESHDS_Mesh;
73                 //Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass);
74
75                 myWriter->SetMesh(myMesh);
76                 myWriter->SetFile(myFile);
77                 SCRUTE(myMesh);
78                 //myWriter->SetFileId(fid);
79                 myWriter->SetMeshId(numero);
80                 myWriter->Write();
81         }
82
83 }