Salome HOME
Merge br_enable_import_mesh. Enable import mesh and save/load SMESH study.
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.hxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
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   : SMESH_Gen_i.hxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _SMESH_GEN_I_HXX_
30 #define _SMESH_GEN_I_HXX_
31
32 #include <SALOMEconfig.h>
33 #include CORBA_SERVER_HEADER(SMESH_Gen)
34 #include CORBA_SERVER_HEADER(SMESH_Mesh)
35 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
36 #include CORBA_CLIENT_HEADER(GEOM_Gen)
37 #include CORBA_CLIENT_HEADER(GEOM_Shape)
38 #include CORBA_CLIENT_HEADER(SALOMEDS)
39 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
40
41
42 class SMESH_Mesh_i;
43
44 #include "SMESH_HypothesisFactory_i.hxx"
45 #include "SMESH_Mesh_i.hxx"
46 #include "SALOME_Component_i.hxx"
47 #include "SALOME_NamingService.hxx"
48
49 #include "SMESH_Gen.hxx"
50 #include "SMESH_topo.hxx"
51 #include "GEOM_Client.hxx"
52
53 #include <HDFOI.hxx>
54
55 #include <map>
56
57 typedef struct studyContext_iStruct
58 {
59   map<int,SMESH_Mesh_i*> mapMesh_i;
60 } StudyContext_iStruct;
61
62 class SMESH_Gen_i:
63   public POA_SMESH::SMESH_Gen,
64   public Engines_Component_i 
65 {
66 public:
67
68   SMESH_Gen_i();
69   SMESH_Gen_i(CORBA::ORB_ptr orb,
70               PortableServer::POA_ptr poa,
71               PortableServer::ObjectId * contId, 
72               const char *instanceName, 
73               const char *interfaceName);
74   virtual ~SMESH_Gen_i();
75   
76   SMESH::SMESH_Hypothesis_ptr CreateHypothesis(const char* anHyp,
77                                                CORBA::Long studyId)
78     throw (SALOME::SALOME_Exception);
79   
80   SMESH::SMESH_Mesh_ptr Init(GEOM::GEOM_Gen_ptr geomEngine,
81                              CORBA::Long studyId,
82                              GEOM::GEOM_Shape_ptr aShape)
83     throw (SALOME::SALOME_Exception);
84
85   CORBA::Boolean Compute(SMESH::SMESH_Mesh_ptr aMesh,
86                          GEOM::GEOM_Shape_ptr aShape)
87     throw (SALOME::SALOME_Exception);
88
89   CORBA::Boolean IsReadyToCompute(SMESH::SMESH_Mesh_ptr aMesh,
90                                   GEOM::GEOM_Shape_ptr aShape)
91     throw (SALOME::SALOME_Exception);
92
93   SMESH::long_array* GetSubShapesId(GEOM::GEOM_Gen_ptr geomEngine,
94                                    CORBA::Long studyId,
95                                    GEOM::GEOM_Shape_ptr mainShape,
96                                    const SMESH::shape_array& listOfSubShape)
97     throw (SALOME::SALOME_Exception);
98
99         SMESH::SMESH_Mesh_ptr Import(CORBA::Long studyId, const char* fileName,
100                 const char* fileType);
101
102   // inherited methods from SALOMEDS::Driver
103
104   SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
105                           const char* theURL,
106                           bool isMultiFile);
107   bool Load(SALOMEDS::SComponent_ptr theComponent,
108             const SALOMEDS::TMPFile& theStream,
109             const char* theURL,
110             bool isMultiFile);
111
112   SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
113                                const char* theURL,
114                                bool isMultiFile);
115   bool LoadASCII(SALOMEDS::SComponent_ptr theComponent,
116                  const SALOMEDS::TMPFile& theStream,
117                  const char* theURL,
118                  bool isMultiFile);
119
120   void Close(SALOMEDS::SComponent_ptr theComponent);
121   char* ComponentDataType();
122     
123   char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
124                                const char* IORString,
125                                CORBA::Boolean isMultiFile,
126                                CORBA::Boolean isASCII);
127   char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
128                                const char* aLocalPersistentID,
129                                CORBA::Boolean isMultiFile,
130                                CORBA::Boolean isASCII);
131
132   bool CanPublishInStudy(CORBA::Object_ptr theIOR) { return false; }
133   SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
134                                        SALOMEDS::SObject_ptr theSObject,
135                                        CORBA::Object_ptr theObject,
136                                        const char* theName) throw (SALOME::SALOME_Exception) {
137     SALOMEDS::SObject_var aResultSO;
138     return aResultSO._retn();
139   }
140
141   CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject) {return false;}
142   SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {return false;}
143   CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID) {return false;}
144   SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
145                                   CORBA::Long theObjectID,
146                                   SALOMEDS::SObject_ptr theObject) {
147     SALOMEDS::SObject_var aResultSO;
148     return aResultSO._retn();
149   }
150
151   GEOM_Client* _ShapeReader;
152 protected:
153   SMESH_topo* ExploreMainShape(GEOM::GEOM_Gen_ptr geomEngine,
154                                CORBA::Long studyId,
155                                GEOM::GEOM_Shape_ptr aShape);
156   
157 private:
158         void loadMesh(char * name, HDFfile * hdf_file, char * meshFile,
159                 SALOMEDS::Study_var study);
160         void loadHypothesis(char * name, HDFfile * hdf_file, char * hypothesisFile,
161                 int studyId);
162         void loadAlgorithms(char * name, HDFfile * hdf_file, char * algorithmsFile,
163                 int studyId);
164         void loadAppliedHypothesis(HDFgroup * hdfGroupMeshId, bool _found,
165                 SALOMEDS::Study_var Study, SMESH::SMESH_Mesh_var myNewMesh,
166                 GEOM::GEOM_Shape_var aShape);
167         GEOM::GEOM_Gen_var getGeomEngine();
168         GEOM::GEOM_Shape_var getShape(SALOMEDS::Study_var Study, char * refFromFile);
169
170 void loadAppliedAlgorithms(HDFgroup * hdfGroupMeshId, 
171         bool _found, SALOMEDS::Study_var Study, SMESH::SMESH_Mesh_var myNewMesh, 
172         GEOM::GEOM_Shape_var aShape);
173 void loadSubMeshes(HDFgroup * hdfGroupMeshId, char * msgname,
174         SALOMEDS::Study_var Study, SMESH::SMESH_Mesh_var myNewMesh);
175                         
176   SMESH_HypothesisFactory_i _hypothesisFactory_i;
177   ::SMESH_Gen _impl;  // no namespace here
178   int _localId; // unique Id of created objects, within SMESH_Gen_i entity
179
180   map<int, StudyContext_iStruct*> _mapStudyContext_i;
181   map <string, string> _SMESHCorbaObj;
182 };
183
184 #endif