Salome HOME
c0ee27f95d29600dcaccae4280ee63484cfa9995
[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          GetCase       (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                            AssociateIterHypo(const char* nomIter, const char* nomHypothesis);
112   void                            DissociateHypoZone(const char* nomZone, const char* nomHypothesis);
113
114   void                            InvalideBoundary(const char* nomBoundary);
115   void                            InvalideZone(const char* nomZone);
116   void                            InvalideHypo(const char* nomHypo);
117   void                            InvalideIter(const char* nomIter);
118
119   void                            SetEtatIter(const char* nomIter,const CORBA::Boolean EtatCalcul);
120
121   HOMARD::listeCases*             GetAllCasesName();
122   HOMARD::listeHypotheses*        GetAllHypothesesName();
123   HOMARD::listeZones*             GetAllZonesName();
124   HOMARD::listeIterations*        GetAllIterationsName();
125   HOMARD::listeBoundarys*         GetAllBoundarysName();
126
127   CORBA::Long                     Compute(const char* nomIteration, CORBA::Long etatMenage);
128   CORBA::Boolean                  VerifieDir(const char* nomDir);
129
130   void                            PublishResultInSmesh(const char* NomFich, CORBA::Long IconeType);
131   void                            DeleteResultInSmesh(const char* NomFich, const char* MeshName);
132   void                            PublishFileUnderIteration(const char* NomIter, const char* NomFich,
133                                                             const char* Commentaire);
134
135   void                            IsValidStudy();
136
137   // ---------------------------------------------------------------
138   // next functions are inherited from SALOMEDS::Driver interface
139   // ---------------------------------------------------------------
140
141   // --> Persistence
142   virtual SALOMEDS::TMPFile*      Save(SALOMEDS::SComponent_ptr theComponent,
143                                         const char* theURL,
144                                         CORBA::Boolean isMultiFile);
145
146   virtual SALOMEDS::TMPFile*      SaveASCII(SALOMEDS::SComponent_ptr theComponent,
147                                              const char* theURL,
148                                              CORBA::Boolean isMultiFile);
149
150   virtual CORBA::Boolean          Load(SALOMEDS::SComponent_ptr theComponent,
151                                         const SALOMEDS::TMPFile& theStream,
152                                         const char* theURL,
153                                         CORBA::Boolean isMultiFile);
154
155   virtual CORBA::Boolean          LoadASCII(SALOMEDS::SComponent_ptr theComponent,
156                                              const SALOMEDS::TMPFile& theStream,
157                                              const char* theURL,
158                                              CORBA::Boolean isMultiFile);
159
160   virtual void                    Close(SALOMEDS::SComponent_ptr IORSComponent);
161
162   virtual char*                   ComponentDataType();
163
164   virtual char*                   IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
165                                                           const char* IORString,
166                                                           CORBA::Boolean isMultiFile,
167                                                           CORBA::Boolean isASCII);
168
169   virtual char*                   LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
170                                                           const char* aLocalPersistentID,
171                                                           CORBA::Boolean isMultiFile,
172                                                           CORBA::Boolean isASCII);
173
174   // --> Data publishing
175   virtual CORBA::Boolean          CanPublishInStudy(CORBA::Object_ptr theIOR);
176
177   virtual SALOMEDS::SObject_ptr   PublishInStudy(SALOMEDS::Study_ptr theStudy,
178                                                  SALOMEDS::SObject_ptr theSObject,
179                                                  CORBA::Object_ptr theObject,
180                                                  const char* theName);
181
182   // --> Copy/Paste
183   virtual CORBA::Boolean          CanCopy(SALOMEDS::SObject_ptr theObject);
184
185   virtual SALOMEDS::TMPFile*      CopyFrom(SALOMEDS::SObject_ptr theObject,
186                                             CORBA::Long& theObjectID);
187
188   virtual CORBA::Boolean          CanPaste(const char* theComponentName, CORBA::Long theObjectID);
189
190   virtual SALOMEDS::SObject_ptr   PasteInto(const SALOMEDS::TMPFile& theStream,
191                                              CORBA::Long theObjectID,
192                                              SALOMEDS::SObject_ptr theObject);
193
194
195 private:
196   void                            addInStudy(SALOMEDS::Study_ptr theStudy);
197   SALOMEDS::SObject_ptr           PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
198                                                      HOMARD::HOMARD_Cas_ptr theObject, const char* theName);
199
200   SALOMEDS::SObject_ptr           PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
201                                                      HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName);
202
203   SALOMEDS::SObject_ptr           PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
204                                                      HOMARD::HOMARD_Zone_ptr theObject, const char* theName);
205   SALOMEDS::SObject_ptr           PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
206                                                      HOMARD::HOMARD_Boundary_ptr theObject, const char* theName);
207   virtual void                    PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
208                                                      SALOMEDS::SObject_var aResultSO,
209                                                      const char* theName, const char* value, const char* icone, const char* ior);
210   PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
211
212   HOMARD::HOMARD_Cas_ptr          newCase();
213   HOMARD::HOMARD_Hypothesis_ptr   newHypothesis();
214   HOMARD::HOMARD_Iteration_ptr    newIteration();
215   HOMARD::HOMARD_Zone_ptr         newZone();
216   HOMARD::HOMARD_Boundary_ptr     newBoundary();
217
218
219   virtual Engines::TMPFile*       DumpPython(CORBA::Object_ptr theStudy,
220                                              CORBA::Boolean isPublished,
221                                              CORBA::Boolean isMultiFile,
222                                              CORBA::Boolean& isValidScript);
223
224   virtual char*                   getVersion();
225
226 private:
227   struct StudyContext
228   {
229     std::map<std::string, HOMARD::HOMARD_Cas_var>        _mesCas;
230     std::map<std::string, HOMARD::HOMARD_Hypothesis_var> _mesHypotheses;
231     std::map<std::string, HOMARD::HOMARD_Iteration_var>  _mesIterations;
232     std::map<std::string, HOMARD::HOMARD_Zone_var>       _mesZones;
233     std::map<std::string, HOMARD::HOMARD_Boundary_var>   _mesBoundarys;
234     std::map<int, PortableServer::ServantBase*>          _idmap;
235   };
236   typedef std::map<int, StudyContext> ContextMap;
237
238   ::HOMARD_Gen*                 myHomard;
239   SALOMEDS::Study_var           myCurrentStudy;
240   ContextMap                    myContextMap;
241   SALOME_NamingService*         _NS;
242
243 };
244
245 #endif