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