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