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