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