Salome HOME
Creating and importing 2 meshes from the same engine was not working. Mesh ID managem...
[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   SMESH::SMESH_Mesh_ptr Init(GEOM::GEOM_Gen_ptr geomEngine,
86                              CORBA::Long studyId,
87                              GEOM::GEOM_Shape_ptr aShape,
88                                                          int meshID)
89     throw (SALOME::SALOME_Exception);
90
91   CORBA::Boolean Compute(SMESH::SMESH_Mesh_ptr aMesh,
92                          GEOM::GEOM_Shape_ptr aShape)
93     throw (SALOME::SALOME_Exception);
94
95   CORBA::Boolean IsReadyToCompute(SMESH::SMESH_Mesh_ptr aMesh,
96                                   GEOM::GEOM_Shape_ptr aShape)
97     throw (SALOME::SALOME_Exception);
98
99   SMESH::long_array* GetSubShapesId(GEOM::GEOM_Gen_ptr geomEngine,
100                                    CORBA::Long studyId,
101                                    GEOM::GEOM_Shape_ptr mainShape,
102                                    const SMESH::shape_array& listOfSubShape)
103     throw (SALOME::SALOME_Exception);
104
105         SMESH::SMESH_Mesh_ptr Import(CORBA::Long studyId, const char* fileName,
106                 const char* fileType);
107
108   // inherited methods from SALOMEDS::Driver
109
110   SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
111                           const char* theURL,
112                           bool isMultiFile);
113   bool Load(SALOMEDS::SComponent_ptr theComponent,
114             const SALOMEDS::TMPFile& theStream,
115             const char* theURL,
116             bool isMultiFile);
117
118   SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
119                                const char* theURL,
120                                bool isMultiFile);
121   bool LoadASCII(SALOMEDS::SComponent_ptr theComponent,
122                  const SALOMEDS::TMPFile& theStream,
123                  const char* theURL,
124                  bool isMultiFile);
125
126   void Close(SALOMEDS::SComponent_ptr theComponent);
127   char* ComponentDataType();
128     
129   char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
130                                const char* IORString,
131                                CORBA::Boolean isMultiFile,
132                                CORBA::Boolean isASCII);
133   char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
134                                const char* aLocalPersistentID,
135                                CORBA::Boolean isMultiFile,
136                                CORBA::Boolean isASCII);
137
138   bool CanPublishInStudy(CORBA::Object_ptr theIOR) { return false; }
139   SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
140                                        SALOMEDS::SObject_ptr theSObject,
141                                        CORBA::Object_ptr theObject,
142                                        const char* theName) throw (SALOME::SALOME_Exception) {
143     SALOMEDS::SObject_var aResultSO;
144     return aResultSO._retn();
145   }
146
147   CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject) {return false;}
148   SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {return false;}
149   CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID) {return false;}
150   SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
151                                   CORBA::Long theObjectID,
152                                   SALOMEDS::SObject_ptr theObject) {
153     SALOMEDS::SObject_var aResultSO;
154     return aResultSO._retn();
155   }
156
157   GEOM_Client* _ShapeReader;
158 protected:
159   SMESH_topo* ExploreMainShape(GEOM::GEOM_Gen_ptr geomEngine,
160                                CORBA::Long studyId,
161                                GEOM::GEOM_Shape_ptr aShape);
162   
163 private:
164         void loadMesh(char * name, HDFfile * hdf_file, char * meshFile,
165                 SALOMEDS::Study_var study);
166         void loadHypothesis(char * name, HDFfile * hdf_file, char * hypothesisFile,
167                 int studyId);
168         void loadAlgorithms(char * name, HDFfile * hdf_file, char * algorithmsFile,
169                 int studyId);
170         void loadAppliedHypothesis(HDFgroup * hdfGroupMeshId, bool _found,
171                 SALOMEDS::Study_var Study, SMESH::SMESH_Mesh_var myNewMesh,
172                 GEOM::GEOM_Shape_var aShape);
173         GEOM::GEOM_Gen_var getGeomEngine();
174         GEOM::GEOM_Shape_var getShape(SALOMEDS::Study_var Study, char * refFromFile);
175
176 void loadAppliedAlgorithms(HDFgroup * hdfGroupMeshId, 
177         bool _found, SALOMEDS::Study_var Study, SMESH::SMESH_Mesh_var myNewMesh, 
178         GEOM::GEOM_Shape_var aShape);
179 void loadSubMeshes(HDFgroup * hdfGroupMeshId, char * msgname,
180         SALOMEDS::Study_var Study, SMESH::SMESH_Mesh_var myNewMesh);
181                         
182   SMESH_HypothesisFactory_i _hypothesisFactory_i;
183   ::SMESH_Gen _impl;  // no namespace here
184
185   map<int, StudyContext_iStruct*> _mapStudyContext_i;
186   map <string, string> _SMESHCorbaObj;
187 };
188
189 #endif