Salome HOME
Some forgotten return statments
[modules/smesh.git] / src / DriverDAT / DriverDAT_R_SMESHDS_Document.cxx
1 //  SMESH DriverDAT : driver to read and write 'dat' files
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DriverDAT_R_SMESHDS_Document.cxx
25 //  Module : SMESH
26
27 using namespace std;
28 #include "DriverDAT_R_SMESHDS_Document.h"
29 #include "DriverDAT_R_SMESHDS_Mesh.h"
30
31 #include "utilities.h"
32
33 int getOne()
34 {
35         printf("in getOne");
36         return (1);
37 }
38
39 extern "C"
40 {
41         //  Document_Reader* maker() {
42         DriverDAT_R_SMESHDS_Document *maker()
43         {
44                 fprintf(stdout, "here in maker\n");
45                 return new DriverDAT_R_SMESHDS_Document;
46         }
47 }
48
49 DriverDAT_R_SMESHDS_Document::DriverDAT_R_SMESHDS_Document()
50 {
51         myFile = string("");
52 }
53
54 DriverDAT_R_SMESHDS_Document::~DriverDAT_R_SMESHDS_Document()
55 {
56         ;
57 }
58
59 //void DriverDAT_R_SMESHDS_Document::SetFile(string aFile) {
60 //myFile = aFile;
61 //}
62
63 //void DriverDAT_R_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDoc) {
64 //myDocument = aDoc;
65 //}
66
67 void DriverDAT_R_SMESHDS_Document::Read()
68 {
69
70         int myMeshId;
71         MESSAGE("in read");
72         SCRUTE(myFile);
73         //Handle(SMESHDS_Document) myDocument = new SMESHDS_Document(1);
74
75   /****************************************************************************
76   *                      OUVERTURE DU FICHIER EN LECTURE                      *
77   ****************************************************************************/
78         char *file2Read = (char *)myFile.c_str();
79         FILE *fid = fopen(file2Read, "r");
80         if (fid < 0)
81         {
82                 fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
83                 exit(EXIT_FAILURE);
84         }
85
86   /****************************************************************************
87   *                      COMBIEN DE MAILLAGES ?                               *
88   ****************************************************************************/
89         int nmaa = 1;
90
91   /****************************************************************************
92   *                      FERMETURE DU FICHIER                                 *
93   ****************************************************************************/
94         fclose(fid);
95
96         printf("Nombre de maillages = %d\n", nmaa);
97
98         string myClass = string("SMESHDS_Mesh");
99         string myExtension = string("DAT");
100
101         for (int meshIt = 1; meshIt <= nmaa; meshIt++)
102         {
103                 myMeshId = myDocument->NewMesh();
104
105                 SMDS_Mesh * myMesh = myDocument->GetMesh(myMeshId);
106
107                 DriverDAT_R_SMESHDS_Mesh *myReader = new DriverDAT_R_SMESHDS_Mesh;
108
109                 myReader->SetMesh(myMesh);
110                 myReader->SetFile(myFile);
111                 //myReader->SetFileId(fid);
112
113                 myReader->Read();
114
115         }
116
117 }