Salome HOME
mise a jour pour la poursuite d'iterations
[modules/homard.git] / src / HOMARD_I / HOMARD_Iteration_i.cxx
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 // Remarques :
20 // L'ordre de description des fonctions est le meme dans tous les fichiers
21 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
22 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
23 // 2. Les caracteristiques
24 // 3. Le lien avec les autres structures
25 //
26 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
27 //
28
29 #include "HOMARD_Iteration_i.hxx"
30 #include "HOMARD_Gen_i.hxx"
31 #include "HOMARD_Iteration.hxx"
32 #include "HOMARD_DriverTools.hxx"
33
34 #include "SALOMEDS_Tool.hxx"
35
36 #include "utilities.h"
37
38 //=============================================================================
39 /*!
40  *  standard constructor
41  */
42 //=============================================================================
43 HOMARD_Iteration_i::HOMARD_Iteration_i()
44 {
45   MESSAGE( "Default constructor, not for use" );
46   ASSERT( 0 );
47 }
48 //=============================================================================
49 /*!
50  *  standard constructor
51  */
52 //=============================================================================
53 HOMARD_Iteration_i::HOMARD_Iteration_i( CORBA::ORB_ptr orb,
54                                         HOMARD::HOMARD_Gen_var engine )
55 {
56   MESSAGE("constructor");
57   _gen_i = engine;
58   _orb = orb;
59   myHomardIteration = new ::HOMARD_Iteration();
60   ASSERT( myHomardIteration );
61 }
62 //=============================================================================
63 /*!
64  *  standard destructor
65  */
66 //=============================================================================
67 HOMARD_Iteration_i::~HOMARD_Iteration_i()
68 {
69 }
70 //=============================================================================
71 //=============================================================================
72 // Generalites
73 //=============================================================================
74 //=============================================================================
75 void HOMARD_Iteration_i::SetName( const char* Name )
76 {
77   ASSERT( myHomardIteration );
78   myHomardIteration->SetName( Name );
79 }
80 //=============================================================================
81 char* HOMARD_Iteration_i::GetName()
82 {
83   ASSERT( myHomardIteration );
84   return CORBA::string_dup( myHomardIteration->GetName().c_str() );
85 }
86 //=============================================================================
87 CORBA::Long  HOMARD_Iteration_i::Delete( CORBA::Long Option )
88 {
89   ASSERT( myHomardIteration );
90   char* IterName = GetName() ;
91   MESSAGE ( "Delete : destruction de l'iteration " << IterName << ", Option = " << Option );
92   return _gen_i->DeleteIteration(IterName, Option) ;
93 }
94 //=============================================================================
95 char* HOMARD_Iteration_i::GetDumpPython()
96 {
97   ASSERT( myHomardIteration );
98   return CORBA::string_dup( myHomardIteration->GetDumpPython().c_str() );
99 }
100 //=============================================================================
101 std::string HOMARD_Iteration_i::Dump() const
102 {
103   return HOMARD::Dump( *myHomardIteration );
104 }
105 //=============================================================================
106 bool HOMARD_Iteration_i::Restore( const std::string& stream )
107 {
108   return HOMARD::Restore( *myHomardIteration, stream );
109 }
110 //=============================================================================
111 //=============================================================================
112 // Caracteristiques
113 //=============================================================================
114 //=============================================================================
115 void HOMARD_Iteration_i::SetDirName( const char* NomDir )
116 {
117   ASSERT( myHomardIteration );
118   myHomardIteration->SetDirName( NomDir );
119 }
120 //=============================================================================
121 char* HOMARD_Iteration_i::GetDirName()
122 {
123   ASSERT( myHomardIteration );
124   return CORBA::string_dup( myHomardIteration->GetDirName().c_str() );
125 }
126 //=============================================================================
127 void HOMARD_Iteration_i::SetNumber( CORBA::Long NumIter )
128 {
129   ASSERT( myHomardIteration );
130   myHomardIteration->SetNumber( NumIter );
131 }
132 //=============================================================================
133 CORBA::Long HOMARD_Iteration_i::GetNumber()
134 {
135   ASSERT( myHomardIteration );
136   return  myHomardIteration->GetNumber() ;
137 }
138 //=============================================================================
139 void HOMARD_Iteration_i::SetState( CORBA::Long Etat )
140 {
141   ASSERT( myHomardIteration );
142   myHomardIteration->SetState( Etat );
143 }
144 //=============================================================================
145 CORBA::Long HOMARD_Iteration_i::GetState()
146 {
147   ASSERT( myHomardIteration );
148   return myHomardIteration->GetState() ;
149 }
150 //=============================================================================
151 void HOMARD_Iteration_i::SetMeshName( const char* NomMesh )
152 {
153   ASSERT( myHomardIteration );
154   myHomardIteration->SetMeshName( NomMesh );
155 }
156 //=============================================================================
157 char* HOMARD_Iteration_i::GetMeshName()
158 {
159   ASSERT( myHomardIteration );
160   return CORBA::string_dup( myHomardIteration->GetMeshName().c_str() );
161 }
162 //=============================================================================
163 void HOMARD_Iteration_i::SetMeshFile( const char* MeshFile )
164 {
165   ASSERT( myHomardIteration );
166   myHomardIteration->SetMeshFile( MeshFile );
167 }
168 //=============================================================================
169 char* HOMARD_Iteration_i::GetMeshFile()
170 {
171   ASSERT( myHomardIteration );
172   return CORBA::string_dup( myHomardIteration->GetMeshFile().c_str() );
173 }
174 //=============================================================================
175 void HOMARD_Iteration_i::SetFieldFile( const char* FieldFile )
176 {
177   ASSERT( myHomardIteration );
178   myHomardIteration->SetFieldFile( FieldFile );
179 }
180 //=============================================================================
181 char* HOMARD_Iteration_i::GetFieldFile()
182 {
183   ASSERT( myHomardIteration );
184   return CORBA::string_dup( myHomardIteration->GetFieldFile().c_str() );
185 }
186 //=============================================================================
187 void HOMARD_Iteration_i::SetTimeStepRank( CORBA::Long TimeStep, CORBA::Long Rank )
188 {
189   ASSERT( myHomardIteration );
190   myHomardIteration->SetTimeStepRank( TimeStep, Rank );
191 }
192 //=============================================================================
193 void HOMARD_Iteration_i::SetTimeStepRankLast()
194 {
195   ASSERT( myHomardIteration );
196   myHomardIteration->SetTimeStepRankLast();
197 }
198 //=============================================================================
199 CORBA::Long HOMARD_Iteration_i::GetTimeStep()
200 {
201   ASSERT( myHomardIteration );
202   return  CORBA::Long( myHomardIteration->GetTimeStep() );
203 }
204 //=============================================================================
205 CORBA::Long HOMARD_Iteration_i::GetRank()
206 {
207   ASSERT( myHomardIteration );
208   return  CORBA::Long( myHomardIteration->GetRank() );
209 }
210 //=============================================================================
211 void HOMARD_Iteration_i::SetLogFile( const char* LogFile )
212 {
213   ASSERT( myHomardIteration );
214   myHomardIteration->SetLogFile( LogFile );
215 }
216 //=============================================================================
217 char* HOMARD_Iteration_i::GetLogFile()
218 {
219   ASSERT( myHomardIteration );
220   return CORBA::string_dup( myHomardIteration->GetLogFile().c_str() );
221 }
222 //=============================================================================
223 CORBA::Long HOMARD_Iteration_i::Compute(CORBA::Long etatMenage, CORBA::Long Option)
224 {
225   MESSAGE ( "Compute : calcul d'une iteration"<<", Option = "<<Option );
226   ASSERT( myHomardIteration );
227 //
228 // Nom de l'iteration
229   char* IterName = GetName() ;
230   CORBA::Long modeHOMARD = 1 ;
231   CORBA::Long Option1 = 1 ;
232   MESSAGE ( "Compute : calcul de l'teration " << IterName );
233   return _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option1, Option) ;
234 }
235 //=============================================================================
236 void HOMARD_Iteration_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
237 {
238   MESSAGE ( "MeshInfo : information sur le maillage associe a une iteration" );
239   ASSERT( myHomardIteration );
240 //
241   int Option = 1 ;
242   MeshInfoOption( Qual, Diam, Conn, Tail, Inte, Option ) ;
243 //
244   return ;
245 }
246 //=============================================================================
247 void HOMARD_Iteration_i::MeshInfoOption(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte, CORBA::Long Option)
248 {
249   MESSAGE ( "MeshInfoOption : information sur le maillage associe a une iteration" );
250   ASSERT( myHomardIteration );
251 //
252 // Nom de l'iteration
253   char* IterName = GetName() ;
254   CORBA::Long etatMenage = -1 ;
255   CORBA::Long modeHOMARD = 7 ;
256   if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5 ; }
257   if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19 ; }
258   if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11 ; }
259   if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13 ; }
260   if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3 ; }
261   MESSAGE ( "MeshInfoOption : information sur le maillage de l'iteration " << IterName );
262   CORBA::Long Option2 = 1 ;
263   CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option, Option2) ;
264   MESSAGE ( "MeshInfoOption : codret = " << codret );
265 //
266   return ;
267 }
268 //=============================================================================
269 void HOMARD_Iteration_i::SetFileInfo( const char* FileInfo )
270 {
271   ASSERT( myHomardIteration );
272   myHomardIteration->SetFileInfo( FileInfo );
273 }
274 //=============================================================================
275 char* HOMARD_Iteration_i::GetFileInfo()
276 {
277   ASSERT( myHomardIteration );
278   return CORBA::string_dup( myHomardIteration->GetFileInfo().c_str() );
279 }
280 //=============================================================================
281 //=============================================================================
282 // Liens avec les autres iterations
283 //=============================================================================
284 //=============================================================================
285 HOMARD::HOMARD_Iteration_ptr HOMARD_Iteration_i::NextIteration( const char* IterName )
286 {
287 // Nom de l'iteration parent
288   char* NomIterParent = GetName() ;
289   MESSAGE ( "NextIteration : creation de l'iteration " << IterName << " comme fille de " << NomIterParent );
290   return _gen_i->CreateIteration(IterName, NomIterParent) ;
291 }
292 //=============================================================================
293 void HOMARD_Iteration_i::LinkNextIteration( const char* NomIteration )
294 {
295   ASSERT( myHomardIteration );
296   myHomardIteration->LinkNextIteration( NomIteration );
297 }
298 //=============================================================================
299 void HOMARD_Iteration_i::UnLinkNextIteration( const char* NomIteration )
300 {
301   ASSERT( myHomardIteration );
302   myHomardIteration->UnLinkNextIteration( NomIteration );
303 }
304 //=============================================================================
305 HOMARD::listeIterFilles* HOMARD_Iteration_i::GetIterations()
306 {
307   ASSERT( myHomardIteration );
308   const std::list<std::string>& maListe = myHomardIteration->GetIterations();
309   HOMARD::listeIterFilles_var aResult = new HOMARD::listeIterFilles;
310   aResult->length( maListe.size() );
311   std::list<std::string>::const_iterator it;
312   int i = 0;
313   for ( it = maListe.begin(); it != maListe.end(); it++ )
314   {
315     aResult[i++] = CORBA::string_dup( (*it).c_str() );
316   }
317   return aResult._retn();
318 }
319 //=============================================================================
320 void HOMARD_Iteration_i::SetIterParentName( const char* NomIterParent )
321 {
322   ASSERT( myHomardIteration );
323   myHomardIteration->SetIterParentName( NomIterParent );
324 }
325 //=============================================================================
326 char* HOMARD_Iteration_i::GetIterParentName()
327 {
328   ASSERT( myHomardIteration );
329   return CORBA::string_dup( myHomardIteration->GetIterParentName().c_str() );
330 }
331 //=============================================================================
332 HOMARD::HOMARD_Iteration_ptr HOMARD_Iteration_i::GetIterParent()
333 {
334 // Nom de l'iteration parent
335   char* NomIterParent = GetIterParentName() ;
336   MESSAGE ( "GetIterParent : NomIterParent = " << NomIterParent );
337   return _gen_i->GetIteration(NomIterParent) ;
338 }
339 //=============================================================================
340 //=============================================================================
341 // Liens avec les autres structures
342 //=============================================================================
343 //=============================================================================
344 void HOMARD_Iteration_i::SetCaseName( const char* NomCas )
345 {
346   ASSERT( myHomardIteration );
347   myHomardIteration->SetCaseName( NomCas );
348 }
349 //=============================================================================
350 char* HOMARD_Iteration_i::GetCaseName()
351 {
352   ASSERT( myHomardIteration );
353   return CORBA::string_dup( myHomardIteration->GetCaseName().c_str() );
354 }
355 //=============================================================================
356 void HOMARD_Iteration_i::AssociateHypo( const char* NomHypo )
357 {
358   ASSERT( myHomardIteration );
359 //
360 // Nom de l'iteration
361   char* IterName = GetName() ;
362   MESSAGE ( ". IterName = " << IterName );
363   return _gen_i->AssociateIterHypo(IterName, NomHypo) ;
364 }
365 //=============================================================================
366 void HOMARD_Iteration_i::SetHypoName( const char* NomHypo )
367 {
368   ASSERT( myHomardIteration );
369   myHomardIteration->SetHypoName( NomHypo );
370 }
371 //=============================================================================
372 char* HOMARD_Iteration_i::GetHypoName()
373 {
374   ASSERT( myHomardIteration );
375   return CORBA::string_dup( myHomardIteration->GetHypoName().c_str() );
376 }