Salome HOME
integration of modifications from Gérald Nicolas
[modules/homard.git] / src / HOMARD_I / HOMARD_Iteration_i.cxx
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 #include "HOMARD_Iteration_i.hxx"
21 #include "HOMARD_Gen_i.hxx"
22 #include "HOMARD_Iteration.hxx"
23 #include "HOMARD_DriverTools.hxx"
24
25 #include "SALOMEDS_Tool.hxx"
26
27 #include "utilities.h"
28
29 //=============================================================================
30 /*!
31  *  standard constructor
32  */
33 //=============================================================================
34 HOMARD_Iteration_i::HOMARD_Iteration_i()
35 {
36   MESSAGE( "Default constructor, not for use" );
37   ASSERT( 0 );
38 }
39
40 //=============================================================================
41 /*!
42  *  standard constructor
43  */
44 //=============================================================================
45 HOMARD_Iteration_i::HOMARD_Iteration_i( CORBA::ORB_ptr orb,
46                                         HOMARD::HOMARD_Gen_var engine )
47 {
48   MESSAGE("constructor");
49   _gen_i = engine;
50   _orb = orb;
51   myHomardIteration = new ::HOMARD_Iteration();
52   ASSERT( myHomardIteration );
53 }
54
55 //=============================================================================
56 /*!
57  *  standard destructor
58  */
59 //=============================================================================
60 HOMARD_Iteration_i::~HOMARD_Iteration_i()
61 {
62 }
63
64 //=============================================================================
65 /*!
66  */
67 //=============================================================================
68 void HOMARD_Iteration_i::SetName( const char* Name )
69 {
70   ASSERT( myHomardIteration );
71   myHomardIteration->SetName( Name );
72 }
73
74 //=============================================================================
75 char* HOMARD_Iteration_i::GetName()
76 {
77   ASSERT( myHomardIteration );
78   return CORBA::string_dup( myHomardIteration->GetName().c_str() );
79 }
80
81 //=============================================================================
82 char* HOMARD_Iteration_i::GetDumpPython()
83 {
84   ASSERT( myHomardIteration );
85   return CORBA::string_dup( myHomardIteration->GetDumpPython().c_str() );
86 }
87
88 //=============================================================================
89 void HOMARD_Iteration_i::SetEtat( CORBA::Boolean Etat )
90 {
91   ASSERT( myHomardIteration );
92   myHomardIteration->SetEtat( Etat );
93 }
94
95 //=============================================================================
96 CORBA::Boolean HOMARD_Iteration_i::GetEtat()
97 {
98   ASSERT( myHomardIteration );
99   return CORBA::Boolean( myHomardIteration->GetEtat());
100 }
101
102 //=============================================================================
103 void HOMARD_Iteration_i::SetNumber( CORBA::Long NumIter )
104 {
105   ASSERT( myHomardIteration );
106   myHomardIteration->SetNumber( NumIter );
107 }
108
109 //=============================================================================
110 CORBA::Long HOMARD_Iteration_i::GetNumber()
111 {
112   ASSERT( myHomardIteration );
113   return  myHomardIteration->GetNumber() ;
114 }
115
116 //=============================================================================
117 void HOMARD_Iteration_i::SetMeshName( const char* NomMesh )
118 {
119   ASSERT( myHomardIteration );
120   myHomardIteration->SetMeshName( NomMesh );
121 }
122
123 //=============================================================================
124 char* HOMARD_Iteration_i::GetMeshName()
125 {
126   ASSERT( myHomardIteration );
127   return CORBA::string_dup( myHomardIteration->GetMeshName().c_str() );
128 }
129
130 //=============================================================================
131 char* HOMARD_Iteration_i::GetIterParentName()
132 {
133   ASSERT( myHomardIteration );
134   return CORBA::string_dup( myHomardIteration->GetIterParentName().c_str() );
135
136 }
137 //=============================================================================
138 HOMARD::HOMARD_Iteration_ptr HOMARD_Iteration_i::GetIterParent()
139 {
140 // Nom de l'iteration parent
141   char* NomIterParent = GetIterParentName() ;
142   MESSAGE ( "GetIterParent : NomIterParent = " << NomIterParent );
143 // On passe par la methode sur l'objet HOMARD
144 // Il serait plus elegant de tout faire ici, mais il est complexe de passer tout le contexte
145   return _gen_i->GetIteration(NomIterParent) ;
146 }
147
148
149
150 //=============================================================================
151 HOMARD::listeIterFilles* HOMARD_Iteration_i::GetIterations()
152 {
153   ASSERT( myHomardIteration );
154   const std::list<std::string>& maListe = myHomardIteration->GetIterations();
155   HOMARD::listeIterFilles_var aResult = new HOMARD::listeIterFilles;
156   aResult->length( maListe.size() );
157   std::list<std::string>::const_iterator it;
158   int i = 0;
159   for ( it = maListe.begin(); it != maListe.end(); it++ )
160   {
161     aResult[i++] = CORBA::string_dup( (*it).c_str() );
162   }
163   return aResult._retn();
164 }
165
166 //=============================================================================
167 void HOMARD_Iteration_i::SetIterParentName( const char* NomIterParent )
168 {
169   ASSERT( myHomardIteration );
170   myHomardIteration->SetIterParentName( NomIterParent );
171 }
172
173 //=============================================================================
174 void HOMARD_Iteration_i::AddIteration( const char* NomIteration )
175 {
176   ASSERT( myHomardIteration );
177   myHomardIteration->AddIteration( NomIteration );
178 }
179
180 //=============================================================================
181 HOMARD::HOMARD_Iteration_ptr HOMARD_Iteration_i::NextIteration( const char* IterName )
182 {
183 // Nom de l'iteration parent
184   char* NomIterParent = GetName() ;
185   MESSAGE ( "NextIteration : IterName      = " << IterName );
186   MESSAGE ( "NextIteration : NomIterParent = " << NomIterParent );
187 // On passe par la methode sur l'objet HOMARD
188 // Il serait plus elegant de tout faire ici, mais il est complexe de passer tout le contexte
189   return _gen_i->CreateIteration(IterName, NomIterParent) ;
190 }
191
192
193 //=============================================================================
194 CORBA::Long  HOMARD_Iteration_i::Compute(CORBA::Long etatMenage)
195 {
196   MESSAGE ( "Compute : calcul d'une iteration" );
197   ASSERT( myHomardIteration );
198 //
199 // Nom de l'iteration
200   char* IterName = GetName() ;
201   MESSAGE ( ". IterName = " << IterName );
202 // On passe par la methode sur l'objet HOMARD
203 // Il serait plus elegant de tout faire ici, mais il est complexe de passer tout le contexte
204   return _gen_i->Compute(IterName, etatMenage) ;
205 }
206
207 //=============================================================================
208 void HOMARD_Iteration_i::SetMeshFile( const char* MeshFile )
209 {
210   ASSERT( myHomardIteration );
211   myHomardIteration->SetMeshFile( MeshFile );
212 }
213
214 //=============================================================================
215 char* HOMARD_Iteration_i::GetMeshFile()
216 {
217   ASSERT( myHomardIteration );
218   return CORBA::string_dup( myHomardIteration->GetMeshFile().c_str() );
219 }
220
221 //=============================================================================
222 char* HOMARD_Iteration_i::GetCaseName()
223 {
224   ASSERT( myHomardIteration );
225   return CORBA::string_dup( myHomardIteration->GetCaseName().c_str() );
226 }
227
228 //=============================================================================
229 void HOMARD_Iteration_i::SetCaseName( const char* NomCas )
230 {
231   ASSERT( myHomardIteration );
232   myHomardIteration->SetCaseName( NomCas );
233 }
234
235 //=============================================================================
236 char* HOMARD_Iteration_i::GetDirName()
237 {
238   ASSERT( myHomardIteration );
239   return CORBA::string_dup( myHomardIteration->GetDirName().c_str() );
240 }
241
242 //=============================================================================
243 void HOMARD_Iteration_i::SetDirName( const char* NomDir )
244 {
245   ASSERT( myHomardIteration );
246   myHomardIteration->SetDirName( NomDir );
247 }
248
249 //=============================================================================
250 void HOMARD_Iteration_i::AssociateHypo( const char* NomHypo )
251 {
252   ASSERT( myHomardIteration );
253 //
254 // Nom de l'iteration
255   char* IterName = GetName() ;
256   MESSAGE ( ". IterName = " << IterName );
257 // On passe par la methode sur l'objet HOMARD
258 // Il serait plus elegant de tout faire ici, mais il est complexe de passer tout le contexte
259   return _gen_i->AssociateIterHypo(IterName, NomHypo) ;
260 }
261
262 //=============================================================================
263 char* HOMARD_Iteration_i::GetHypoName()
264 {
265   ASSERT( myHomardIteration );
266   return CORBA::string_dup( myHomardIteration->GetHypoName().c_str() );
267 }
268
269 //=============================================================================
270 // HOMARD::HOMARD_Hypothesis_ptr HOMARD_Iteration_i::GetHypo()
271 // {
272 // // Nom de l'hypothese
273 //   char* NomHypo = GetHypoName() ;
274 //   MESSAGE ( "GetHypo : NomHypo = " << NomHypo );
275 // // On passe par la methode sur l'objet HOMARD
276 // // Il serait plus elegant de tout faire ici, mais il est complexe de passer tout le contexte
277 //   return _gen_i->GetHypothesis(NomHypo) ;
278 // }
279
280 //=============================================================================
281 void HOMARD_Iteration_i::SetHypoName( const char* NomHypo )
282 {
283   ASSERT( myHomardIteration );
284   myHomardIteration->SetHypoName( NomHypo );
285 }
286
287 //=============================================================================
288 void HOMARD_Iteration_i::SetFieldFile( const char* FieldFile )
289 {
290   ASSERT( myHomardIteration );
291   myHomardIteration->SetFieldFile( FieldFile );
292 }
293
294 //=============================================================================
295 char* HOMARD_Iteration_i::GetFieldFile()
296 {
297   ASSERT( myHomardIteration );
298   return CORBA::string_dup( myHomardIteration->GetFieldFile().c_str() );
299 }
300
301 //=============================================================================
302 void HOMARD_Iteration_i::SetTimeStepRank( CORBA::Long TimeStep, CORBA::Long Rank )
303 {
304   ASSERT( myHomardIteration );
305   myHomardIteration->SetTimeStepRank( TimeStep, Rank );
306 }
307
308 //=============================================================================
309 CORBA::Long HOMARD_Iteration_i::GetTimeStep()
310 {
311   ASSERT( myHomardIteration );
312   return  CORBA::Long( myHomardIteration->GetTimeStep() );
313 }
314
315 //=============================================================================
316 CORBA::Long HOMARD_Iteration_i::GetRank()
317 {
318   ASSERT( myHomardIteration );
319   return  CORBA::Long( myHomardIteration->GetRank() );
320 }
321
322 //=============================================================================
323 void HOMARD_Iteration_i::SetMessFile( const char* MessFile )
324 {
325   ASSERT( myHomardIteration );
326   myHomardIteration->SetMessFile( MessFile );
327 }
328
329 //=============================================================================
330 char* HOMARD_Iteration_i::GetMessFile()
331 {
332   ASSERT( myHomardIteration );
333   return CORBA::string_dup( myHomardIteration->GetMessFile().c_str() );
334 }
335 //=============================================================================
336 std::string HOMARD_Iteration_i::Dump() const
337 {
338   return HOMARD::Dump( *myHomardIteration );
339 }
340
341 //=============================================================================
342 bool HOMARD_Iteration_i::Restore( const std::string& stream )
343 {
344   return HOMARD::Restore( *myHomardIteration, stream );
345 }