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