]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD_I/HOMARD_Gen_i.hxx
Salome HOME
Création automatique de schémas YACS à partir d'un cas
[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   void                            YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver);
187
188   void                            IsValidStudy();
189
190   // ---------------------------------------------------------------
191   // next functions are inherited from SALOMEDS::Driver interface
192   // ---------------------------------------------------------------
193
194   // --> Persistence
195   virtual SALOMEDS::TMPFile*      Save(SALOMEDS::SComponent_ptr theComponent,
196                                         const char* theURL,
197                                         CORBA::Boolean isMultiFile);
198
199   virtual SALOMEDS::TMPFile*      SaveASCII(SALOMEDS::SComponent_ptr theComponent,
200                                              const char* theURL,
201                                              CORBA::Boolean isMultiFile);
202
203   virtual CORBA::Boolean          Load(SALOMEDS::SComponent_ptr theComponent,
204                                         const SALOMEDS::TMPFile& theStream,
205                                         const char* theURL,
206                                         CORBA::Boolean isMultiFile);
207
208   virtual CORBA::Boolean          LoadASCII(SALOMEDS::SComponent_ptr theComponent,
209                                              const SALOMEDS::TMPFile& theStream,
210                                              const char* theURL,
211                                              CORBA::Boolean isMultiFile);
212
213   virtual void                    Close(SALOMEDS::SComponent_ptr IORSComponent);
214
215   virtual char*                   ComponentDataType();
216
217   virtual char*                   IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
218                                                           const char* IORString,
219                                                           CORBA::Boolean isMultiFile,
220                                                           CORBA::Boolean isASCII);
221
222   virtual char*                   LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
223                                                           const char* aLocalPersistentID,
224                                                           CORBA::Boolean isMultiFile,
225                                                           CORBA::Boolean isASCII);
226
227   // --> Data publishing
228   virtual CORBA::Boolean          CanPublishInStudy(CORBA::Object_ptr theIOR);
229
230   virtual SALOMEDS::SObject_ptr   PublishInStudy(SALOMEDS::Study_ptr theStudy,
231                                                  SALOMEDS::SObject_ptr theSObject,
232                                                  CORBA::Object_ptr theObject,
233                                                  const char* theName);
234
235   // --> Copy/Paste
236   virtual CORBA::Boolean          CanCopy(SALOMEDS::SObject_ptr theObject);
237
238   virtual SALOMEDS::TMPFile*      CopyFrom(SALOMEDS::SObject_ptr theObject,
239                                             CORBA::Long& theObjectID);
240
241   virtual CORBA::Boolean          CanPaste(const char* theComponentName, CORBA::Long theObjectID);
242
243   virtual SALOMEDS::SObject_ptr   PasteInto(const SALOMEDS::TMPFile& theStream,
244                                              CORBA::Long theObjectID,
245                                              SALOMEDS::SObject_ptr theObject);
246
247 //   virtual void SALOMEException( std::string message );
248
249 private:
250   void                            addInStudy(SALOMEDS::Study_ptr theStudy);
251   SALOMEDS::SObject_ptr           PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
252                                                      HOMARD::HOMARD_Cas_ptr theObject, const char* theName);
253
254   SALOMEDS::SObject_ptr           PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
255                                                      HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName);
256
257   SALOMEDS::SObject_ptr           PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
258                                                      HOMARD::HOMARD_Zone_ptr theObject, const char* theName);
259   SALOMEDS::SObject_ptr           PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
260                                                      HOMARD::HOMARD_Boundary_ptr theObject, const char* theName);
261   virtual void                    PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
262                                                      SALOMEDS::SObject_var aResultSO,
263                                                      const char* theName, const char* value, const char* icone, const char* ior);
264
265 PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
266
267   HOMARD::HOMARD_Cas_ptr          newCase();
268   HOMARD::HOMARD_Hypothesis_ptr   newHypothesis();
269   HOMARD::HOMARD_Iteration_ptr    newIteration();
270   HOMARD::HOMARD_Zone_ptr         newZone();
271   HOMARD::HOMARD_Boundary_ptr     newBoundary();
272
273
274   virtual Engines::TMPFile*       DumpPython(CORBA::Object_ptr theStudy,
275                                              CORBA::Boolean isPublished,
276                                              CORBA::Boolean isMultiFile,
277                                              CORBA::Boolean& isValidScript);
278
279   virtual char*                   getVersion();
280   std::string GetStringInTexte( const std::string Texte, const std::string String, int option ) ;
281
282 private:
283   struct StudyContext
284   {
285     std::map<std::string, HOMARD::HOMARD_Cas_var>        _mesCas;
286     std::map<std::string, HOMARD::HOMARD_Hypothesis_var> _mesHypotheses;
287     std::map<std::string, HOMARD::HOMARD_Iteration_var>  _mesIterations;
288     std::map<std::string, HOMARD::HOMARD_Zone_var>       _mesZones;
289     std::map<std::string, HOMARD::HOMARD_Boundary_var>   _mesBoundarys;
290     std::map<int, PortableServer::ServantBase*>          _idmap;
291   };
292   typedef std::map<int, StudyContext> ContextMap;
293
294   ::HOMARD_Gen*                 myHomard;
295   SALOMEDS::Study_var           myCurrentStudy;
296   ContextMap                    myContextMap;
297   SALOME_NamingService*         _NS;
298
299 };
300
301 #endif