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