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