Salome HOME
3fcf18a1bfdeb110a3f38e0bb1e57ce735b8f479
[modules/homard.git] / src / HOMARD_I / HOMARD_Gen_i.hxx
1 // Copyright (C) 2011-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _HOMARD_GEN_I_HXX_
21 #define _HOMARD_GEN_I_HXX_
22
23 #include <SALOMEconfig.h>
24 #include CORBA_SERVER_HEADER(HOMARD_Gen)
25 #include CORBA_SERVER_HEADER(HOMARD_Cas)
26 #include CORBA_SERVER_HEADER(HOMARD_Hypothesis)
27 #include CORBA_SERVER_HEADER(HOMARD_Iteration)
28 #include CORBA_SERVER_HEADER(HOMARD_Zone)
29 #include CORBA_SERVER_HEADER(HOMARD_Boundary)
30 #include CORBA_CLIENT_HEADER(SALOMEDS)
31 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
32
33 #include "HOMARD_Gen.hxx"
34 #include "HomardDriver.hxx"
35 #include "SALOME_Component_i.hxx"
36 #include "SALOME_NamingService.hxx"
37 #include "Utils_CorbaException.hxx"
38
39
40 #include <string>
41 #include <map>
42
43 class HOMARD_Gen_i:
44   public virtual Engines_Component_i,
45   public virtual POA_HOMARD::HOMARD_Gen
46 {
47 public:
48   HOMARD_Gen_i( CORBA::ORB_ptr orb,
49                 PortableServer::POA_ptr poa,
50                 PortableServer::ObjectId* contId,
51                 const char* instanceName,
52                 const char* interfaceName );
53   virtual ~HOMARD_Gen_i();
54
55
56 // Generalites
57
58 // Les creations
59   HOMARD::HOMARD_Boundary_ptr     CreateBoundary (const char* nomBoundary, CORBA::Long typeBoundary);
60   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryDi (const char* nomBoundary,
61                                                     const char* MeshName, const char* FileName);
62   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryCylinder (const char* nomBoundary,
63                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
64                                       CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis,
65                                       CORBA::Double Rayon);
66   HOMARD::HOMARD_Boundary_ptr     CreateBoundarySphere (const char* nomBoundary,
67                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
68                                       CORBA::Double Rayon);
69   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryConeR (const char* nomBoundary,
70                                       CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
71                                       CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2);
72   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryConeA (const char* nomBoundary,
73                                       CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis, CORBA::Double Angle,
74                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre);
75
76   HOMARD::HOMARD_Cas_ptr          CreateCase (const char* nomCas, const char* MeshName, const char* FileName);
77   HOMARD::HOMARD_Cas_ptr          CreateCaseFromIteration (const char* nomCas, const char* DirNameStart);
78   HOMARD::HOMARD_Cas_ptr          CreateCaseFromCaseLastIteration (const char* nomCas, const char* DirNameStart);
79   HOMARD::HOMARD_Cas_ptr          CreateCaseFromCaseIteration (const char* nomCas, const char* DirNameStart, CORBA::Long Number);
80   HOMARD::HOMARD_Cas_ptr          CreateCase0 (const char* nomCas, const char* MeshName, const char* FileName, CORBA::Long MeshOption, CORBA::Long NumeIter, CORBA::Long Option);
81   std::string                     CreateCase1 (const char* DirNameStart, CORBA::Long Number);
82
83   HOMARD::HOMARD_Hypothesis_ptr   CreateHypothesis(const char* nomHypothesis);
84
85   HOMARD::HOMARD_Iteration_ptr    CreateIteration (const char* nomIter, const char* nomIterParent);
86
87   HOMARD::HOMARD_Zone_ptr         CreateZone (const char* nomZone, CORBA::Long typeZone);
88   HOMARD::HOMARD_Zone_ptr         CreateZoneBox (const char* nomZone,
89                                       CORBA::Double Xmini, CORBA::Double Xmaxi,
90                                       CORBA::Double Ymini, CORBA::Double Ymaxi,
91                                       CORBA::Double Zmini, CORBA::Double Zmaxi);
92   HOMARD::HOMARD_Zone_ptr         CreateZoneBox2D (const char* nomZone,
93                                       CORBA::Double Umini, CORBA::Double Umaxi,
94                                       CORBA::Double Vmini, CORBA::Double Vmaxi,
95                                       CORBA::Long Orient);
96   HOMARD::HOMARD_Zone_ptr         CreateZoneCylinder (const char* nomZone,
97                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
98                                       CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
99                                       CORBA::Double Rayon, CORBA::Double Haut);
100   HOMARD::HOMARD_Zone_ptr         CreateZoneDisk (const char* nomZone,
101                                       CORBA::Double Ucentre, CORBA::Double Vcentre,
102                                       CORBA::Double Rayon,
103                                       CORBA::Long Orient);
104   HOMARD::HOMARD_Zone_ptr         CreateZoneDiskWithHole (const char* nomZone,
105                                       CORBA::Double Ucentre, CORBA::Double Vcentre,
106                                       CORBA::Double Rayon, CORBA::Double Rayonint,
107                                       CORBA::Long Orient);
108   HOMARD::HOMARD_Zone_ptr         CreateZonePipe (const char* nomZone,
109                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
110                                       CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
111                                       CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint);
112   HOMARD::HOMARD_Zone_ptr         CreateZoneSphere (const char* nomZone,
113                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon);
114
115 // Les informations
116   HOMARD::HOMARD_Boundary_ptr     GetBoundary   (const char* nomBoundary);
117   HOMARD::HOMARD_Cas_ptr          GetCase       (const char* nomCas);
118   HOMARD::HOMARD_Hypothesis_ptr   GetHypothesis (const char* nomHypothesis);
119   HOMARD::HOMARD_Iteration_ptr    GetIteration  (const char* nomIteration);
120   HOMARD::HOMARD_Zone_ptr         GetZone       (const char* nomZone);
121
122   HOMARD::listeBoundarys*         GetAllBoundarysName();
123   HOMARD::listeCases*             GetAllCasesName();
124   HOMARD::listeHypotheses*        GetAllHypothesesName();
125   HOMARD::listeIterations*        GetAllIterationsName();
126   HOMARD::listeZones*             GetAllZonesName();
127
128   void                            MeshInfo      (const char* nomCas,
129                                                  const char* MeshName, const char* FileName, const char* DirName,
130                                                  CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte);
131
132   HOMARD::HOMARD_Iteration_ptr    LastIteration  (const char* nomCas);
133
134 // L'etude
135   SALOMEDS::Study_ptr             GetCurrentStudy();
136   void                            SetCurrentStudy(SALOMEDS::Study_ptr theStudy);
137   CORBA::Long                     GetCurrentStudyID();
138
139 // Liens entre structures
140   void                            InvalideBoundary(const char* nomBoundary);
141   void                            InvalideHypo(const char* nomHypo);
142   void                            InvalideIter(const char* nomIter);
143   void                            InvalideIterOption(const char* nomIter, CORBA::Long Option);
144   void                            InvalideIterInfo(const char* nomIter);
145   void                            InvalideZone(const char* nomZone);
146
147   CORBA::Long                     DeleteBoundary(const char* nomBoundary);
148   CORBA::Long                     DeleteCase(const char* nomCas);
149   CORBA::Long                     DeleteHypo(const char* nomHypothesis);
150   CORBA::Long                     DeleteIteration(const char* nomIter, CORBA::Long Option);
151   CORBA::Long                     DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2);
152   CORBA::Long                     DeleteZone(const char* nomZone);
153
154   void                            AssociateIterHypo(const char* nomIter, const char* nomHypothesis);
155
156   void                            AssociateHypoZone(const char* nomHypothesis, const char* nomZone, CORBA::Long TypeUse);
157   void                            DissociateHypoZone(const char* nomHypothesis, const char* nomZone);
158
159   void                            AssociateCaseIter(const char* nomCas, const char* nomIter,
160                                                     const char* labelIter);
161
162 // Actions
163   void                            SetEtatIter(const char* nomIter,const CORBA::Long Etat);
164   char*                           CreateDirNameIter(const char* nomrep, CORBA::Long num );
165
166   CORBA::Long                     Compute(const char* nomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2);
167   CORBA::Long                     ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage, HomardDriver* myDriver, CORBA::Long Option1, CORBA::Long Option2);
168   char*                           ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage);
169   char*                           ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration);
170   void                            DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
171   void                            DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
172   void                            DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver);
173   void                            DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
174
175   CORBA::Boolean                  VerifieDir(const char* nomDir);
176
177   void                            PublishResultInSmesh(const char* NomFich, CORBA::Long Option);
178   void                            DeleteResultInSmesh(const char* NomFich, const char* MeshName);
179   void                            PublishFileUnderIteration(const char* NomIter, const char* NomFich,
180                                                             const char* Commentaire);
181   void                            PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName);
182
183   void                            IsValidStudy();
184
185   // ---------------------------------------------------------------
186   // next functions are inherited from SALOMEDS::Driver interface
187   // ---------------------------------------------------------------
188
189   // --> Persistence
190   virtual SALOMEDS::TMPFile*      Save(SALOMEDS::SComponent_ptr theComponent,
191                                         const char* theURL,
192                                         CORBA::Boolean isMultiFile);
193
194   virtual SALOMEDS::TMPFile*      SaveASCII(SALOMEDS::SComponent_ptr theComponent,
195                                              const char* theURL,
196                                              CORBA::Boolean isMultiFile);
197
198   virtual CORBA::Boolean          Load(SALOMEDS::SComponent_ptr theComponent,
199                                         const SALOMEDS::TMPFile& theStream,
200                                         const char* theURL,
201                                         CORBA::Boolean isMultiFile);
202
203   virtual CORBA::Boolean          LoadASCII(SALOMEDS::SComponent_ptr theComponent,
204                                              const SALOMEDS::TMPFile& theStream,
205                                              const char* theURL,
206                                              CORBA::Boolean isMultiFile);
207
208   virtual void                    Close(SALOMEDS::SComponent_ptr IORSComponent);
209
210   virtual char*                   ComponentDataType();
211
212   virtual char*                   IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
213                                                           const char* IORString,
214                                                           CORBA::Boolean isMultiFile,
215                                                           CORBA::Boolean isASCII);
216
217   virtual char*                   LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
218                                                           const char* aLocalPersistentID,
219                                                           CORBA::Boolean isMultiFile,
220                                                           CORBA::Boolean isASCII);
221
222   // --> Data publishing
223   virtual CORBA::Boolean          CanPublishInStudy(CORBA::Object_ptr theIOR);
224
225   virtual SALOMEDS::SObject_ptr   PublishInStudy(SALOMEDS::Study_ptr theStudy,
226                                                  SALOMEDS::SObject_ptr theSObject,
227                                                  CORBA::Object_ptr theObject,
228                                                  const char* theName);
229
230   // --> Copy/Paste
231   virtual CORBA::Boolean          CanCopy(SALOMEDS::SObject_ptr theObject);
232
233   virtual SALOMEDS::TMPFile*      CopyFrom(SALOMEDS::SObject_ptr theObject,
234                                             CORBA::Long& theObjectID);
235
236   virtual CORBA::Boolean          CanPaste(const char* theComponentName, CORBA::Long theObjectID);
237
238   virtual SALOMEDS::SObject_ptr   PasteInto(const SALOMEDS::TMPFile& theStream,
239                                              CORBA::Long theObjectID,
240                                              SALOMEDS::SObject_ptr theObject);
241
242 //   virtual void SALOMEException( std::string message );
243
244 private:
245   void                            addInStudy(SALOMEDS::Study_ptr theStudy);
246   SALOMEDS::SObject_ptr           PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
247                                                      HOMARD::HOMARD_Cas_ptr theObject, const char* theName);
248
249   SALOMEDS::SObject_ptr           PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
250                                                      HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName);
251
252   SALOMEDS::SObject_ptr           PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
253                                                      HOMARD::HOMARD_Zone_ptr theObject, const char* theName);
254   SALOMEDS::SObject_ptr           PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
255                                                      HOMARD::HOMARD_Boundary_ptr theObject, const char* theName);
256   virtual void                    PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
257                                                      SALOMEDS::SObject_var aResultSO,
258                                                      const char* theName, const char* value, const char* icone, const char* ior);
259
260 PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
261
262   HOMARD::HOMARD_Cas_ptr          newCase();
263   HOMARD::HOMARD_Hypothesis_ptr   newHypothesis();
264   HOMARD::HOMARD_Iteration_ptr    newIteration();
265   HOMARD::HOMARD_Zone_ptr         newZone();
266   HOMARD::HOMARD_Boundary_ptr     newBoundary();
267
268
269   virtual Engines::TMPFile*       DumpPython(CORBA::Object_ptr theStudy,
270                                              CORBA::Boolean isPublished,
271                                              CORBA::Boolean isMultiFile,
272                                              CORBA::Boolean& isValidScript);
273
274   virtual char*                   getVersion();
275
276 private:
277   struct StudyContext
278   {
279     std::map<std::string, HOMARD::HOMARD_Cas_var>        _mesCas;
280     std::map<std::string, HOMARD::HOMARD_Hypothesis_var> _mesHypotheses;
281     std::map<std::string, HOMARD::HOMARD_Iteration_var>  _mesIterations;
282     std::map<std::string, HOMARD::HOMARD_Zone_var>       _mesZones;
283     std::map<std::string, HOMARD::HOMARD_Boundary_var>   _mesBoundarys;
284     std::map<int, PortableServer::ServantBase*>          _idmap;
285   };
286   typedef std::map<int, StudyContext> ContextMap;
287
288   ::HOMARD_Gen*                 myHomard;
289   SALOMEDS::Study_var           myCurrentStudy;
290   ContextMap                    myContextMap;
291   SALOME_NamingService*         _NS;
292
293 };
294
295 #endif