Salome HOME
Introduction of informations on the meshes
[modules/homard.git] / src / HOMARD_I / HOMARD_Gen_i.hxx
1 // Copyright (C) 2011-2012  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 "SALOME_Component_i.hxx"
36 #include "SALOME_NamingService.hxx"
37 #include "Utils_CorbaException.hxx"
38
39
40 #include <string>
41 #include <map>
42
43 class HOMARD_Gen_i:
44   public virtual Engines_Component_i,
45   public virtual POA_HOMARD::HOMARD_Gen
46 {
47 public:
48   HOMARD_Gen_i( CORBA::ORB_ptr orb,
49                 PortableServer::POA_ptr poa,
50                 PortableServer::ObjectId* contId,
51                 const char* instanceName,
52                 const char* interfaceName );
53   virtual ~HOMARD_Gen_i();
54
55
56 // Generalites
57
58 // Les creations
59   HOMARD::HOMARD_Boundary_ptr     CreateBoundary (const char* nomBoundary, CORBA::Long typeBoundary);
60   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryDi (const char* nomBoundary,
61                                                     const char* MeshName, const char* FileName);
62   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryCylinder (const char* nomBoundary,
63                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
64                                       CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis,
65                                       CORBA::Double Rayon);
66   HOMARD::HOMARD_Boundary_ptr     CreateBoundarySphere (const char* nomBoundary,
67                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
68                                       CORBA::Double Rayon);
69
70   HOMARD::HOMARD_Cas_ptr          CreateCase      (const char* nomCas,
71                                                    const char* MeshName, const char* FileName);
72
73   HOMARD::HOMARD_Hypothesis_ptr   CreateHypothesis(const char* nomHypothesis);
74
75   HOMARD::HOMARD_Iteration_ptr    CreateIteration (const char* nomIter, const char* nomIterParent);
76
77   HOMARD::HOMARD_Zone_ptr         CreateZone (const char* nomZone, CORBA::Long typeZone);
78   HOMARD::HOMARD_Zone_ptr         CreateZoneBox (const char* nomZone,
79                                       CORBA::Double Xmini, CORBA::Double Xmaxi,
80                                       CORBA::Double Ymini, CORBA::Double Ymaxi,
81                                       CORBA::Double Zmini, CORBA::Double Zmaxi);
82   HOMARD::HOMARD_Zone_ptr         CreateZoneBox2D (const char* nomZone,
83                                       CORBA::Double Umini, CORBA::Double Umaxi,
84                                       CORBA::Double Vmini, CORBA::Double Vmaxi,
85                                       CORBA::Long Orient);
86   HOMARD::HOMARD_Zone_ptr         CreateZoneCylinder (const char* nomZone,
87                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
88                                       CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
89                                       CORBA::Double Rayon, CORBA::Double Haut);
90   HOMARD::HOMARD_Zone_ptr         CreateZoneDisk (const char* nomZone,
91                                       CORBA::Double Ucentre, CORBA::Double Vcentre,
92                                       CORBA::Double Rayon,
93                                       CORBA::Long Orient);
94   HOMARD::HOMARD_Zone_ptr         CreateZoneDiskWithHole (const char* nomZone,
95                                       CORBA::Double Ucentre, CORBA::Double Vcentre,
96                                       CORBA::Double Rayon, CORBA::Double Rayonint,
97                                       CORBA::Long Orient);
98   HOMARD::HOMARD_Zone_ptr         CreateZonePipe (const char* nomZone,
99                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
100                                       CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
101                                       CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint);
102   HOMARD::HOMARD_Zone_ptr         CreateZoneSphere (const char* nomZone,
103                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon);
104
105 // Les informations
106   HOMARD::HOMARD_Boundary_ptr     GetBoundary   (const char* nomBoundary);
107   HOMARD::HOMARD_Cas_ptr          GetCase       (const char* nomCas);
108   HOMARD::HOMARD_Hypothesis_ptr   GetHypothesis (const char* nomHypothesis);
109   HOMARD::HOMARD_Iteration_ptr    GetIteration  (const char* nomIteration);
110   HOMARD::HOMARD_Zone_ptr         GetZone       (const char* nomZone);
111
112   HOMARD::listeBoundarys*         GetAllBoundarysName();
113   HOMARD::listeCases*             GetAllCasesName();
114   HOMARD::listeHypotheses*        GetAllHypothesesName();
115   HOMARD::listeIterations*        GetAllIterationsName();
116   HOMARD::listeZones*             GetAllZonesName();
117
118   void                            MeshInfo      (const char* nomCas,
119                                                  const char* MeshName, const char* FileName, const char* DirName,
120                                                  CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte);
121
122   HOMARD::HOMARD_Iteration_ptr    LastIteration  (const char* nomCas);
123
124 // L'etude
125   SALOMEDS::Study_ptr             GetCurrentStudy();
126   void                            SetCurrentStudy(SALOMEDS::Study_ptr theStudy);
127   CORBA::Long                     GetCurrentStudyID();
128
129 // Liens entre structures
130   void                            InvalideBoundary(const char* nomBoundary);
131   void                            InvalideHypo(const char* nomHypo);
132   void                            InvalideIter(const char* nomIter);
133   void                            InvalideIterInfo(const char* nomIter);
134   void                            InvalideZone(const char* nomZone);
135
136   CORBA::Long                     DeleteBoundary(const char* nomBoundary);
137   CORBA::Long                     DeleteCase(const char* nomCas);
138   CORBA::Long                     DeleteHypo(const char* nomHypothesis);
139   CORBA::Long                     DeleteIteration(const char* nomIter);
140   CORBA::Long                     DeleteIterationOption(const char* nomIter, CORBA::Long Option);
141   CORBA::Long                     DeleteZone(const char* nomZone);
142
143   void                            AssociateIterHypo(const char* nomIter, const char* nomHypothesis);
144
145   void                            AssociateHypoZone(const char* nomHypothesis, const char* nomZone, CORBA::Long TypeUse);
146   void                            DissociateHypoZone(const char* nomHypothesis, const char* nomZone);
147
148   void                            AssociateCaseIter(const char* nomCas, const char* nomIter,
149                                                     const char* labelIter);
150
151   void                            SetEtatIter(const char* nomIter,const CORBA::Boolean EtatCalcul);
152
153   CORBA::Long                     Compute(const char* nomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option);
154   CORBA::Long                     ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage, HomardDriver* myDriver, CORBA::Long Option);
155   char*                           ComputeDir(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage);
156   char*                           ComputeDirPa(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration);
157   void                            DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
158   void                            DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
159   void                            DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver);
160   void                            DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver);
161
162   CORBA::Boolean                  VerifieDir(const char* nomDir);
163
164   void                            PublishResultInSmesh(const char* NomFich, CORBA::Long IconeType);
165   void                            DeleteResultInSmesh(const char* NomFich, const char* MeshName);
166   void                            PublishFileUnderIteration(const char* NomIter, const char* NomFich,
167                                                             const char* Commentaire);
168   void                            PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName);
169
170   void                            IsValidStudy();
171
172   // ---------------------------------------------------------------
173   // next functions are inherited from SALOMEDS::Driver interface
174   // ---------------------------------------------------------------
175
176   // --> Persistence
177   virtual SALOMEDS::TMPFile*      Save(SALOMEDS::SComponent_ptr theComponent,
178                                         const char* theURL,
179                                         CORBA::Boolean isMultiFile);
180
181   virtual SALOMEDS::TMPFile*      SaveASCII(SALOMEDS::SComponent_ptr theComponent,
182                                              const char* theURL,
183                                              CORBA::Boolean isMultiFile);
184
185   virtual CORBA::Boolean          Load(SALOMEDS::SComponent_ptr theComponent,
186                                         const SALOMEDS::TMPFile& theStream,
187                                         const char* theURL,
188                                         CORBA::Boolean isMultiFile);
189
190   virtual CORBA::Boolean          LoadASCII(SALOMEDS::SComponent_ptr theComponent,
191                                              const SALOMEDS::TMPFile& theStream,
192                                              const char* theURL,
193                                              CORBA::Boolean isMultiFile);
194
195   virtual void                    Close(SALOMEDS::SComponent_ptr IORSComponent);
196
197   virtual char*                   ComponentDataType();
198
199   virtual char*                   IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
200                                                           const char* IORString,
201                                                           CORBA::Boolean isMultiFile,
202                                                           CORBA::Boolean isASCII);
203
204   virtual char*                   LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
205                                                           const char* aLocalPersistentID,
206                                                           CORBA::Boolean isMultiFile,
207                                                           CORBA::Boolean isASCII);
208
209   // --> Data publishing
210   virtual CORBA::Boolean          CanPublishInStudy(CORBA::Object_ptr theIOR);
211
212   virtual SALOMEDS::SObject_ptr   PublishInStudy(SALOMEDS::Study_ptr theStudy,
213                                                  SALOMEDS::SObject_ptr theSObject,
214                                                  CORBA::Object_ptr theObject,
215                                                  const char* theName);
216
217   // --> Copy/Paste
218   virtual CORBA::Boolean          CanCopy(SALOMEDS::SObject_ptr theObject);
219
220   virtual SALOMEDS::TMPFile*      CopyFrom(SALOMEDS::SObject_ptr theObject,
221                                             CORBA::Long& theObjectID);
222
223   virtual CORBA::Boolean          CanPaste(const char* theComponentName, CORBA::Long theObjectID);
224
225   virtual SALOMEDS::SObject_ptr   PasteInto(const SALOMEDS::TMPFile& theStream,
226                                              CORBA::Long theObjectID,
227                                              SALOMEDS::SObject_ptr theObject);
228
229 //   virtual void SALOMEException( std::string message );
230
231 private:
232   void                            addInStudy(SALOMEDS::Study_ptr theStudy);
233   SALOMEDS::SObject_ptr           PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
234                                                      HOMARD::HOMARD_Cas_ptr theObject, const char* theName);
235
236   SALOMEDS::SObject_ptr           PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
237                                                      HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName);
238
239   SALOMEDS::SObject_ptr           PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
240                                                      HOMARD::HOMARD_Zone_ptr theObject, const char* theName);
241   SALOMEDS::SObject_ptr           PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
242                                                      HOMARD::HOMARD_Boundary_ptr theObject, const char* theName);
243   virtual void                    PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
244                                                      SALOMEDS::SObject_var aResultSO,
245                                                      const char* theName, const char* value, const char* icone, const char* ior);
246
247 PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
248
249   HOMARD::HOMARD_Cas_ptr          newCase();
250   HOMARD::HOMARD_Hypothesis_ptr   newHypothesis();
251   HOMARD::HOMARD_Iteration_ptr    newIteration();
252   HOMARD::HOMARD_Zone_ptr         newZone();
253   HOMARD::HOMARD_Boundary_ptr     newBoundary();
254
255
256   virtual Engines::TMPFile*       DumpPython(CORBA::Object_ptr theStudy,
257                                              CORBA::Boolean isPublished,
258                                              CORBA::Boolean isMultiFile,
259                                              CORBA::Boolean& isValidScript);
260
261   virtual char*                   getVersion();
262
263 private:
264   struct StudyContext
265   {
266     std::map<std::string, HOMARD::HOMARD_Cas_var>        _mesCas;
267     std::map<std::string, HOMARD::HOMARD_Hypothesis_var> _mesHypotheses;
268     std::map<std::string, HOMARD::HOMARD_Iteration_var>  _mesIterations;
269     std::map<std::string, HOMARD::HOMARD_Zone_var>       _mesZones;
270     std::map<std::string, HOMARD::HOMARD_Boundary_var>   _mesBoundarys;
271     std::map<int, PortableServer::ServantBase*>          _idmap;
272   };
273   typedef std::map<int, StudyContext> ContextMap;
274
275   ::HOMARD_Gen*                 myHomard;
276   SALOMEDS::Study_var           myCurrentStudy;
277   ContextMap                    myContextMap;
278   SALOME_NamingService*         _NS;
279
280 };
281
282 #endif