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