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