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