Salome HOME
sources v1.2
[modules/smesh.git] / src / DriverUNV / DriverUNV_R_SMESHDS_Document.cxx
1 //  SMESH DriverUNV : driver to read and write 'unv' 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   : DriverUNV_R_SMESHDS_Document.cxx
25 //  Module : SMESH
26
27 using namespace std;
28 #include "DriverUNV_R_SMESHDS_Document.h"
29 #include "DriverUNV_R_SMESHDS_Mesh.h"
30
31 #include "utilities.h"
32
33 int getOne() {
34   printf("in getOne");
35   return (1);
36 }
37
38 extern "C" {
39   //  Document_Reader* maker() {
40   DriverUNV_R_SMESHDS_Document* maker() {
41     fprintf(stdout,"here in maker\n");
42     return new DriverUNV_R_SMESHDS_Document;
43   }
44 }
45
46 DriverUNV_R_SMESHDS_Document::DriverUNV_R_SMESHDS_Document() {
47   myFile = string("");
48 }
49
50 DriverUNV_R_SMESHDS_Document::~DriverUNV_R_SMESHDS_Document() {
51 ;
52 }
53
54 //void DriverUNV_R_SMESHDS_Document::SetFile(string aFile) {
55 //myFile = aFile;
56 //}
57
58 //void DriverUNV_R_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDoc) {
59 //myDocument = aDoc;
60 //}
61
62 void DriverUNV_R_SMESHDS_Document::Read() {
63
64   int myMeshId;
65   SCRUTE(myFile);
66   //Handle(SMESHDS_Document) myDocument = new SMESHDS_Document(1);
67
68   /****************************************************************************
69   *                      OUVERTURE DU FICHIER EN LECTURE                      *
70   ****************************************************************************/
71   char* file2Read = (char*)myFile.c_str();
72   FILE* fid = fopen(file2Read,"r");
73   if (fid < 0)
74     {
75       fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
76       exit(EXIT_FAILURE);
77     }
78
79   /****************************************************************************
80   *                      COMBIEN DE MAILLAGES ?                               *
81   ****************************************************************************/
82   int nmaa = 1;
83
84   /****************************************************************************
85   *                      FERMETURE DU FICHIER                                 *
86   ****************************************************************************/
87   fclose(fid);
88   
89   printf("Nombre de maillages = %d\n",nmaa);
90
91   string myClass = string("SMESHDS_Mesh");
92   string myExtension = string("UNV");
93
94   for (int meshIt=1;meshIt<=nmaa;meshIt++) {
95     myMeshId = myDocument->NewMesh();
96
97     Handle(SMDS_Mesh) myMesh = myDocument->GetMesh(myMeshId);
98
99     DriverUNV_R_SMESHDS_Mesh* myReader = new DriverUNV_R_SMESHDS_Mesh;
100
101
102     myReader->SetMesh(myMesh);
103     myReader->SetFile(myFile);
104     //myReader->SetFileId(fid);
105
106     myReader->Read();
107
108   }
109
110
111 }