Salome HOME
53ee8a0d12b8569fc68ec61a05a589f19b0533d4
[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_SERVER_HEADER(HOMARD_YACS)
31 #include CORBA_CLIENT_HEADER(SALOMEDS)
32 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
33
34 #include "HOMARD_Gen.hxx"
35 #include "HomardDriver.hxx"
36 #include "YACSDriver.hxx"
37 #include "SALOME_Component_i.hxx"
38 #include "SALOME_NamingService.hxx"
39 #include "Utils_CorbaException.hxx"
40
41
42 #include <string>
43 #include <map>
44
45 class HOMARD_Gen_i:
46   public virtual Engines_Component_i,
47   public virtual POA_HOMARD::HOMARD_Gen
48 {
49 public:
50   HOMARD_Gen_i( CORBA::ORB_ptr orb,
51                 PortableServer::POA_ptr poa,
52                 PortableServer::ObjectId* contId,
53                 const char* instanceName,
54                 const char* interfaceName );
55   virtual ~HOMARD_Gen_i();
56
57
58 // Generalites
59
60 // Les creations
61   HOMARD::HOMARD_Boundary_ptr     CreateBoundary (const char* nomBoundary, CORBA::Long typeBoundary);
62   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryDi (const char* nomBoundary,
63                                                     const char* MeshName, const char* FileName);
64   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryCylinder (const char* nomBoundary,
65                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
66                                       CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis,
67                                       CORBA::Double Rayon);
68   HOMARD::HOMARD_Boundary_ptr     CreateBoundarySphere (const char* nomBoundary,
69                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
70                                       CORBA::Double Rayon);
71   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryConeR (const char* nomBoundary,
72                                       CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
73                                       CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2);
74   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryConeA (const char* nomBoundary,
75                                       CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis, CORBA::Double Angle,
76                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre);
77
78   HOMARD::HOMARD_Cas_ptr          CreateCase (const char* nomCas, const char* MeshName, const char* FileName);
79   HOMARD::HOMARD_Cas_ptr          CreateCaseFromIteration (const char* nomCas, const char* DirNameStart);
80   HOMARD::HOMARD_Cas_ptr          CreateCaseFromCaseLastIteration (const char* nomCas, const char* DirNameStart);
81   HOMARD::HOMARD_Cas_ptr          CreateCaseFromCaseIteration (const char* nomCas, const char* DirNameStart, CORBA::Long Number);
82   HOMARD::HOMARD_Cas_ptr          CreateCase0 (const char* nomCas, const char* MeshName, const char* FileName, CORBA::Long MeshOption, CORBA::Long NumeIter, CORBA::Long Option);
83   std::string                     CreateCase1 (const char* DirNameStart, CORBA::Long Number);
84
85   HOMARD::HOMARD_Hypothesis_ptr   CreateHypothesis(const char* nomHypothesis);
86
87   HOMARD::HOMARD_Iteration_ptr    CreateIteration (const char* nomIter, const char* nomIterParent);
88
89   HOMARD::HOMARD_Zone_ptr         CreateZone (const char* nomZone, CORBA::Long typeZone);
90   HOMARD::HOMARD_Zone_ptr         CreateZoneBox (const char* nomZone,
91                                       CORBA::Double Xmini, CORBA::Double Xmaxi,
92                                       CORBA::Double Ymini, CORBA::Double Ymaxi,
93                                       CORBA::Double Zmini, CORBA::Double Zmaxi);
94   HOMARD::HOMARD_Zone_ptr         CreateZoneBox2D (const char* nomZone,
95                                       CORBA::Double Umini, CORBA::Double Umaxi,
96                                       CORBA::Double Vmini, CORBA::Double Vmaxi,
97                                       CORBA::Long Orient);
98   HOMARD::HOMARD_Zone_ptr         CreateZoneCylinder (const char* nomZone,
99                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
100                                       CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
101                                       CORBA::Double Rayon, CORBA::Double Haut);
102   HOMARD::HOMARD_Zone_ptr         CreateZoneDisk (const char* nomZone,
103                                       CORBA::Double Ucentre, CORBA::Double Vcentre,
104                                       CORBA::Double Rayon,
105                                       CORBA::Long Orient);
106   HOMARD::HOMARD_Zone_ptr         CreateZoneDiskWithHole (const char* nomZone,
107                                       CORBA::Double Ucentre, CORBA::Double Vcentre,
108                                       CORBA::Double Rayon, CORBA::Double Rayonint,
109                                       CORBA::Long Orient);
110   HOMARD::HOMARD_Zone_ptr         CreateZonePipe (const char* nomZone,
111                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
112                                       CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
113                                       CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint);
114   HOMARD::HOMARD_Zone_ptr         CreateZoneSphere (const char* nomZone,
115                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon);
116
117 // Les informations
118   HOMARD::HOMARD_Boundary_ptr     GetBoundary   (const char* nomBoundary);
119   HOMARD::HOMARD_Cas_ptr          GetCase       (const char* nomCas);
120   HOMARD::HOMARD_Hypothesis_ptr   GetHypothesis (const char* nomHypothesis);
121   HOMARD::HOMARD_Iteration_ptr    GetIteration  (const char* nomIteration);
122   HOMARD::HOMARD_YACS_ptr         GetYACS       (const char* nomYACS);
123   HOMARD::HOMARD_Zone_ptr         GetZone       (const char* nomZone);
124
125   HOMARD::listeBoundarys*         GetAllBoundarysName();
126   HOMARD::listeCases*             GetAllCasesName();
127   HOMARD::listeHypotheses*        GetAllHypothesesName();
128   HOMARD::listeIterations*        GetAllIterationsName();
129   HOMARD::listeYACSs*             GetAllYACSsName();
130   HOMARD::listeZones*             GetAllZonesName();
131
132   void                            MeshInfo      (const char* nomCas,
133                                                  const char* MeshName, const char* FileName, const char* DirName,
134                                                  CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte);
135
136   HOMARD::HOMARD_Iteration_ptr    LastIteration  (const char* nomCas);
137
138 // L'etude
139   SALOMEDS::Study_ptr             GetCurrentStudy();
140   void                            SetCurrentStudy(SALOMEDS::Study_ptr theStudy);
141   CORBA::Long                     GetCurrentStudyID();
142   void                            IsValidStudy();
143
144 // Liens entre structures
145   void                            InvalideBoundary(const char* nomBoundary);
146   void                            InvalideHypo(const char* nomHypo);
147   void                            InvalideIter(const char* nomIter);
148   void                            InvalideIterOption(const char* nomIter, CORBA::Long Option);
149   void                            InvalideIterInfo(const char* nomIter);
150   void                            InvalideZone(const char* nomZone);
151
152   CORBA::Long                     DeleteBoundary(const char* nomBoundary);
153   CORBA::Long                     DeleteCase(const char* nomCas, CORBA::Long Option);
154   CORBA::Long                     DeleteHypo(const char* nomHypothesis);
155   CORBA::Long                     DeleteIteration(const char* nomIter, CORBA::Long Option);
156   CORBA::Long                     DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2);
157   CORBA::Long                     DeleteYACS(const char* nomYACS, CORBA::Long Option);
158   CORBA::Long                     DeleteZone(const char* nomZone);
159
160   void                            AssociateIterHypo(const char* nomIter, const char* nomHypothesis);
161
162   void                            AssociateHypoZone(const char* nomHypothesis, const char* nomZone, CORBA::Long TypeUse);
163   void                            DissociateHypoZone(const char* nomHypothesis, const char* nomZone);
164
165   void                            AssociateCaseIter(const char* nomCas, const char* nomIter,
166                                                     const char* labelIter);
167
168 // Actions
169   void                            SetEtatIter(const char* nomIter,const CORBA::Long Etat);
170   char*                           CreateDirNameIter(const char* nomrep, CORBA::Long num );
171
172   CORBA::Long                     Compute(const char* nomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2);
173   CORBA::Long                     ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage, HomardDriver* myDriver, CORBA::Long Option1, CORBA::Long Option2);
174   char*                           ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage);
175   char*                           ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration);
176   void                            DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
177   void                            DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
178   void                            DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver);
179   void                            DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
180
181   CORBA::Boolean                  VerifieDir(const char* nomDir);
182
183   void                            PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire);
184   void                            PublishFileUnderYACS(const char* NomYACS, const char* NomFich, const char* Commentaire);
185   void                            PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName);
186   void                            PublishCaseUnderYACS(const char* YACSName, const char* CaseName);
187   void                            PublishResultInSmesh(const char* NomFich, CORBA::Long Option);
188   void                            DeleteResultInSmesh(std::string NomFich, std::string MeshName);
189
190 // YACS
191   HOMARD::HOMARD_YACS_ptr         CreateYACSSchema (const char* YACSName, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile);
192   CORBA::Long                     YACSWrite(const char* nomYACS);
193   CORBA::Long                     YACSWriteOnFile(const char* nomYACS, const char* XMLFile);
194   std::string                     YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver);
195   std::string                     YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver);
196
197 // Divers
198   void                            SetLanguageShort(const char* LanguageShort);
199   char*                           GetLanguageShort();
200
201
202   // ---------------------------------------------------------------
203   // next functions are inherited from SALOMEDS::Driver interface
204   // ---------------------------------------------------------------
205
206   // --> Persistence
207   virtual SALOMEDS::TMPFile*      Save(SALOMEDS::SComponent_ptr theComponent,
208                                         const char* theURL,
209                                         CORBA::Boolean isMultiFile);
210
211   virtual SALOMEDS::TMPFile*      SaveASCII(SALOMEDS::SComponent_ptr theComponent,
212                                              const char* theURL,
213                                              CORBA::Boolean isMultiFile);
214
215   virtual CORBA::Boolean          Load(SALOMEDS::SComponent_ptr theComponent,
216                                         const SALOMEDS::TMPFile& theStream,
217                                         const char* theURL,
218                                         CORBA::Boolean isMultiFile);
219
220   virtual CORBA::Boolean          LoadASCII(SALOMEDS::SComponent_ptr theComponent,
221                                              const SALOMEDS::TMPFile& theStream,
222                                              const char* theURL,
223                                              CORBA::Boolean isMultiFile);
224
225   virtual void                    Close(SALOMEDS::SComponent_ptr IORSComponent);
226
227   virtual char*                   ComponentDataType();
228
229   virtual char*                   IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
230                                                           const char* IORString,
231                                                           CORBA::Boolean isMultiFile,
232                                                           CORBA::Boolean isASCII);
233
234   virtual char*                   LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
235                                                           const char* aLocalPersistentID,
236                                                           CORBA::Boolean isMultiFile,
237                                                           CORBA::Boolean isASCII);
238
239   // --> Data publishing
240   virtual CORBA::Boolean          CanPublishInStudy(CORBA::Object_ptr theIOR);
241
242   virtual SALOMEDS::SObject_ptr   PublishInStudy(SALOMEDS::Study_ptr theStudy,
243                                                  SALOMEDS::SObject_ptr theSObject,
244                                                  CORBA::Object_ptr theObject,
245                                                  const char* theName);
246
247   // --> Copy/Paste
248   virtual CORBA::Boolean          CanCopy(SALOMEDS::SObject_ptr theObject);
249
250   virtual SALOMEDS::TMPFile*      CopyFrom(SALOMEDS::SObject_ptr theObject,
251                                             CORBA::Long& theObjectID);
252
253   virtual CORBA::Boolean          CanPaste(const char* theComponentName, CORBA::Long theObjectID);
254
255   virtual SALOMEDS::SObject_ptr   PasteInto(const SALOMEDS::TMPFile& theStream,
256                                              CORBA::Long theObjectID,
257                                              SALOMEDS::SObject_ptr theObject);
258
259 //   virtual void SALOMEException( std::string message );
260
261 private:
262   void                            addInStudy(SALOMEDS::Study_ptr theStudy);
263   SALOMEDS::SObject_ptr           PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
264                                                      HOMARD::HOMARD_Boundary_ptr theObject, const char* theName);
265   SALOMEDS::SObject_ptr           PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
266                                                      HOMARD::HOMARD_Cas_ptr theObject, const char* theName);
267   SALOMEDS::SObject_ptr           PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
268                                                      HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName);
269   SALOMEDS::SObject_ptr           PublishYACSInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
270                                                      HOMARD::HOMARD_YACS_ptr theObject, const char* theName);
271   SALOMEDS::SObject_ptr           PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
272                                                      HOMARD::HOMARD_Zone_ptr theObject, const char* theName);
273   virtual void                    PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
274                                                      SALOMEDS::SObject_var aResultSO,
275                                                      const char* theName, const char* comment, const char* icone, const char* ior);
276
277   PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
278
279   HOMARD::HOMARD_Boundary_ptr     newBoundary();
280   HOMARD::HOMARD_Cas_ptr          newCase();
281   HOMARD::HOMARD_Hypothesis_ptr   newHypothesis();
282   HOMARD::HOMARD_Iteration_ptr    newIteration();
283   HOMARD::HOMARD_YACS_ptr         newYACS();
284   HOMARD::HOMARD_Zone_ptr         newZone();
285
286
287   virtual Engines::TMPFile*       DumpPython(CORBA::Object_ptr theStudy,
288                                              CORBA::Boolean isPublished,
289                                              CORBA::Boolean isMultiFile,
290                                              CORBA::Boolean& isValidScript);
291
292   virtual char*                   getVersion();
293   std::string GetStringInTexte( const std::string Texte, const std::string String, int option ) ;
294
295 private:
296   struct StudyContext
297   {
298     std::map<std::string, HOMARD::HOMARD_Boundary_var>   _mesBoundarys;
299     std::map<std::string, HOMARD::HOMARD_Cas_var>        _mesCas;
300     std::map<std::string, HOMARD::HOMARD_Hypothesis_var> _mesHypotheses;
301     std::map<std::string, HOMARD::HOMARD_Iteration_var>  _mesIterations;
302     std::map<std::string, HOMARD::HOMARD_YACS_var>       _mesYACSs;
303     std::map<std::string, HOMARD::HOMARD_Zone_var>       _mesZones;
304     std::map<int, PortableServer::ServantBase*>          _idmap;
305   };
306   typedef std::map<int, StudyContext> ContextMap;
307
308   ::HOMARD_Gen*                 myHomard;
309   SALOMEDS::Study_var           myCurrentStudy;
310   ContextMap                    myContextMap;
311   SALOME_NamingService*         _NS;
312
313   int _tag_gene ;
314   int _tag_boun ;
315   int _tag_hypo ;
316   int _tag_yacs ;
317   int _tag_zone ;
318   std::string _Langue ;
319   std::string _LangueShort ;
320
321 };
322
323 #endif