Salome HOME
Update to match the changes in SMDS
[modules/smesh.git] / src / DriverUNV / DriverUNV_R_SMESHDS_Document.cxx
1 using namespace std;
2 #include "DriverUNV_R_SMESHDS_Document.h"
3 #include "DriverUNV_R_SMESHDS_Mesh.h"
4
5 #include "utilities.h"
6
7 int getOne()
8 {
9         printf("in getOne");
10         return (1);
11 }
12
13 extern "C"
14 {
15         //  Document_Reader* maker() {
16         DriverUNV_R_SMESHDS_Document *maker()
17         {
18                 fprintf(stdout, "here in maker\n");
19                 return new DriverUNV_R_SMESHDS_Document;
20         }
21 }
22
23 DriverUNV_R_SMESHDS_Document::DriverUNV_R_SMESHDS_Document()
24 {
25         myFile = string("");
26 }
27
28 DriverUNV_R_SMESHDS_Document::~DriverUNV_R_SMESHDS_Document()
29 {
30         ;
31 }
32
33 //void DriverUNV_R_SMESHDS_Document::SetFile(string aFile) {
34 //myFile = aFile;
35 //}
36
37 //void DriverUNV_R_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDoc) {
38 //myDocument = aDoc;
39 //}
40
41 void DriverUNV_R_SMESHDS_Document::Read()
42 {
43
44         int myMeshId;
45         SCRUTE(myFile);
46         //Handle(SMESHDS_Document) myDocument = new SMESHDS_Document(1);
47
48   /****************************************************************************
49   *                      OUVERTURE DU FICHIER EN LECTURE                      *
50   ****************************************************************************/
51         char *file2Read = (char *)myFile.c_str();
52         FILE *fid = fopen(file2Read, "r");
53         if (fid < 0)
54         {
55                 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
56                 exit(EXIT_FAILURE);
57         }
58
59   /****************************************************************************
60   *                      COMBIEN DE MAILLAGES ?                               *
61   ****************************************************************************/
62         int nmaa = 1;
63
64   /****************************************************************************
65   *                      FERMETURE DU FICHIER                                 *
66   ****************************************************************************/
67         fclose(fid);
68
69         printf("Nombre de maillages = %d\n", nmaa);
70
71         string myClass = string("SMESHDS_Mesh");
72         string myExtension = string("UNV");
73
74         for (int meshIt = 1; meshIt <= nmaa; meshIt++)
75         {
76                 myMeshId = myDocument->NewMesh();
77
78                 SMDS_Mesh * myMesh = myDocument->GetMesh(myMeshId);
79
80                 DriverUNV_R_SMESHDS_Mesh *myReader = new DriverUNV_R_SMESHDS_Mesh;
81
82                 myReader->SetMesh(myMesh);
83                 myReader->SetFile(myFile);
84                 //myReader->SetFileId(fid);
85
86                 myReader->Read();
87
88         }
89
90 }